about summary refs log tree commit diff stats
path: root/data/maps/daedalus/rooms/Computer Room.txtpb
blob: 1d5a56dc2c2e11593931da12c94c2d4311288c1e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
name: "Computer Room"
panel_display_name: "Computer Room"
panels {
  name: "MONITOR (1)"
  path: "Panels/Computer/computer_1"
  clue: "monitor"
  answer: "television"
  symbols: AGE
}
panels {
  name: "MICROPHONE"
  path: "Panels/Computer/computer_2"
  clue: "microphone"
  answer: "headset"
  symbols: BOXES
}
panels {
  name: "SPEAKER"
  path: "Panels/Computer/computer_3"
  clue: "speaker"
  answer: "headset"
  symbols: BOXES
}
panels {
  name: "PROCESSOR (1)"
  path: "Panels/Computer/computer_4"
  clue: "processor"
  answer: "circuit"
  symbols: AGE
}
panels {
  name: "MOUSE (1)"
  path: "Panels/Computer/computer_5"
  clue: "mouse"
  answer: "joystick"
  symbols: EXAMPLE
}
panels {
  name: "KEYBOARD (1)"
  path: "Panels/Computer/computer_6"
  clue: "keyboard"
  answer: "typewriter"
  symbols: AGE
}
panels {
  name: "MONITOR (2)"
  path: "Panels/Computer/computer_7"
  clue: "monitor"
  answer: "computer"
  symbols: BOXES
}
panels {
  name: "PROCESSOR (2)"
  path: "Panels/Computer/computer_8"
  clue: "processor"
  answer: "computer"
  symbols: BOXES
}
panels {
  name: "MOUSE (2)"
  path: "Panels/Computer/computer_9"
  clue: "mouse"
  answer: "computer"
  symbols: BOXES
}
panels {
  name: "KEYBOARD (2)"
  path: "Panels/Computer/computer_10"
  clue: "keyboard"
  answer: "computer"
  symbols: BOXES
}
r_panel.cpp?h=v0.6.6&id=f7530492119f94a83bdb85bb3887b50ddb5a6ffd'>f753049 ^
9798316 ^
f753049 ^

9f25878 ^
02c331f ^





























9f25878 ^
02c331f ^


















22014b9 ^



02c331f ^

22014b9 ^
02c331f ^

22014b9 ^
02c331f ^
9f25878 ^
9798316 ^
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152

                          
                     
                       
                      




                                                                            
 





                                                                          
                                                               






                                                  

   


                                                  
                                                       

 


                                       

                                      


   






                                                 














                                                                      


                             


















                                                                     
                       

                                                                         
 





























                                                                     
                        


















                                                                                   



                                                                       

                                                                             
     

                                                                               
     
                                                
   
 
#include "tracker_panel.h"

#include "ap_state.h"
#include "area_popup.h"
#include "game_data.h"
#include "tracker_state.h"

constexpr int AREA_ACTUAL_SIZE = 64;
constexpr int AREA_BORDER_SIZE = 5;
constexpr int AREA_EFFECTIVE_SIZE = AREA_ACTUAL_SIZE + AREA_BORDER_SIZE * 2;

TrackerPanel::TrackerPanel(wxWindow *parent) : wxPanel(parent, wxID_ANY) {
  map_image_ = wxImage("assets/lingo_map.png", wxBITMAP_TYPE_PNG);
  if (!map_image_.IsOk()) {
    return;
  }

  for (const MapArea &map_area : GetGameData().GetMapAreas()) {
    AreaIndicator area;
    area.area_id = map_area.id;

    area.popup = new AreaPopup(this, map_area.id);
    area.popup->SetPosition({0, 0});
    
    areas_.push_back(area);
  }

  Redraw();

  Bind(wxEVT_PAINT, &TrackerPanel::OnPaint, this);
  Bind(wxEVT_MOTION, &TrackerPanel::OnMouseMove, this);
}

void TrackerPanel::UpdateIndicators() {
  Redraw();

  for (AreaIndicator& area : areas_) {
    area.popup->UpdateIndicators();
  }
}

void TrackerPanel::OnPaint(wxPaintEvent &event) {
  if (GetSize() != rendered_.GetSize()) {
    Redraw();
  }

  wxPaintDC dc(this);
  dc.DrawBitmap(rendered_, 0, 0);

  event.Skip();
}

void TrackerPanel::OnMouseMove(wxMouseEvent &event) {
  for (AreaIndicator &area : areas_) {
    if (area.real_x1 <= event.GetX() && event.GetX() < area.real_x2 &&
        area.real_y1 <= event.GetY() && event.GetY() < area.real_y2) {
      area.popup->Show();
    } else {
      area.popup->Hide();
    }
  }

  event.Skip();
}

void TrackerPanel::Redraw() {
  wxSize panel_size = GetSize();
  wxSize image_size = map_image_.GetSize();

  int final_x = 0;
  int final_y = 0;
  int final_width = panel_size.GetWidth();
  int final_height = panel_size.GetHeight();

  if (image_size.GetWidth() * panel_size.GetHeight() >
      panel_size.GetWidth() * image_size.GetHeight()) {
    final_height = (panel_size.GetWidth() * image_size.GetHeight()) /
                   image_size.GetWidth();
    final_y = (panel_size.GetHeight() - final_height) / 2;
  } else {
    final_width = (image_size.GetWidth() * panel_size.GetHeight()) /
                  image_size.GetHeight();
    final_x = (panel_size.GetWidth() - final_width) / 2;
  }

  rendered_ = wxBitmap(
      map_image_.Scale(final_width, final_height, wxIMAGE_QUALITY_NORMAL)
          .Size(panel_size, {final_x, final_y}, 0, 0, 0));

  wxMemoryDC dc;
  dc.SelectObject(rendered_);

  for (AreaIndicator& area : areas_) {
    const wxBrush *brush_color = wxGREY_BRUSH;

    const MapArea &map_area = GetGameData().GetMapArea(area.area_id);
    bool has_reachable_unchecked = false;
    bool has_unreachable_unchecked = false;
    for (int section_id = 0; section_id < map_area.locations.size();
         section_id++) {
      if (!GetAPState().HasCheckedGameLocation(area.area_id,
                                               section_id)) {
        if (GetTrackerState().IsLocationReachable(area.area_id,
                                                  section_id)) {
          has_reachable_unchecked = true;
        } else {
          has_unreachable_unchecked = true;
        }
      }
    }

    if (has_reachable_unchecked && has_unreachable_unchecked) {
      brush_color = wxYELLOW_BRUSH;
    } else if (has_reachable_unchecked) {
      brush_color = wxGREEN_BRUSH;
    } else if (has_unreachable_unchecked) {
      brush_color = wxRED_BRUSH;
    }

    int real_area_size =
        final_width * AREA_EFFECTIVE_SIZE / image_size.GetWidth();
    int actual_border_size =
        real_area_size * AREA_BORDER_SIZE / AREA_EFFECTIVE_SIZE;
    int real_area_x =
        final_x + (map_area.map_x - (AREA_EFFECTIVE_SIZE / 2)) *
                      final_width / image_size.GetWidth();
    int real_area_y =
        final_y + (map_area.map_y - (AREA_EFFECTIVE_SIZE / 2)) *
                      final_width / image_size.GetWidth();
    
    dc.SetPen(*wxThePenList->FindOrCreatePen(*wxBLACK, actual_border_size));
    dc.SetBrush(*brush_color);
    dc.DrawRectangle({real_area_x, real_area_y}, {real_area_size, real_area_size});

    area.real_x1 = real_area_x;
    area.real_x2 = real_area_x + real_area_size;
    area.real_y1 = real_area_y;
    area.real_y2 = real_area_y + real_area_size;

    int popup_x =
        final_x + map_area.map_x * final_width / image_size.GetWidth();
    int popup_y =
        final_y + map_area.map_y * final_width / image_size.GetWidth();
    if (popup_x + area.popup->GetSize().GetWidth() > panel_size.GetWidth()) {
      popup_x = panel_size.GetWidth() - area.popup->GetSize().GetWidth();
    }
    if (popup_y + area.popup->GetSize().GetHeight() > panel_size.GetHeight()) {
      popup_y = panel_size.GetHeight() - area.popup->GetSize().GetHeight();
    }
    area.popup->SetPosition({popup_x, popup_y});
  }
}