diff options
-rw-r--r-- | CMakeLists.txt | 1 | ||||
-rw-r--r-- | area_window.cpp | 39 | ||||
-rw-r--r-- | area_window.h | 30 | ||||
-rwxr-xr-x | assets/areas.yaml | 129 | ||||
-rw-r--r-- | game_data.cpp | 25 | ||||
-rw-r--r-- | game_data.h | 10 | ||||
-rw-r--r-- | tracker_panel.cpp | 20 | ||||
-rw-r--r-- | tracker_panel.h | 4 |
8 files changed, 257 insertions, 1 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 2e4ece5..9000583 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt | |||
@@ -19,6 +19,7 @@ add_executable(lingo_ap_tracker | |||
19 | tracker_frame.cpp | 19 | tracker_frame.cpp |
20 | tracker_panel.cpp | 20 | tracker_panel.cpp |
21 | game_data.cpp | 21 | game_data.cpp |
22 | area_window.cpp | ||
22 | ) | 23 | ) |
23 | set_property(TARGET lingo_ap_tracker PROPERTY CXX_STANDARD 17) | 24 | set_property(TARGET lingo_ap_tracker PROPERTY CXX_STANDARD 17) |
24 | set_property(TARGET lingo_ap_tracker PROPERTY CXX_STANDARD_REQUIRED ON) | 25 | set_property(TARGET lingo_ap_tracker PROPERTY CXX_STANDARD_REQUIRED ON) |
diff --git a/area_window.cpp b/area_window.cpp new file mode 100644 index 0000000..b142525 --- /dev/null +++ b/area_window.cpp | |||
@@ -0,0 +1,39 @@ | |||
1 | #include "area_window.h" | ||
2 | |||
3 | #include <iostream> | ||
4 | |||
5 | #include "game_data.h" | ||
6 | |||
7 | AreaWindow::AreaWindow(wxWindow* parent, int area_id) | ||
8 | : wxWindow(parent, wxID_ANY), area_id_(area_id) { | ||
9 | SetSize(EFFECTIVE_SIZE, EFFECTIVE_SIZE); | ||
10 | |||
11 | Redraw(); | ||
12 | |||
13 | Bind(wxEVT_PAINT, &AreaWindow::OnPaint, this); | ||
14 | Bind(wxEVT_ENTER_WINDOW, &AreaWindow::OnEnterWindow, this); | ||
15 | } | ||
16 | |||
17 | void AreaWindow::OnPaint(wxPaintEvent& event) { | ||
18 | if (GetSize() != rendered_.GetSize()) { | ||
19 | Redraw(); | ||
20 | } | ||
21 | |||
22 | wxPaintDC dc(this); | ||
23 | dc.DrawBitmap(rendered_, 0, 0); | ||
24 | } | ||
25 | |||
26 | void AreaWindow::OnEnterWindow(wxMouseEvent& event) { | ||
27 | std::cout << GetGameData().GetMapArea(area_id_).name << std::endl; | ||
28 | } | ||
29 | |||
30 | void AreaWindow::Redraw() { | ||
31 | int actual_border_size = GetSize().GetWidth() * BORDER_SIZE / EFFECTIVE_SIZE; | ||
32 | |||
33 | rendered_ = wxBitmap(GetSize()); | ||
34 | wxMemoryDC dc; | ||
35 | dc.SelectObject(rendered_); | ||
36 | dc.SetPen(*wxThePenList->FindOrCreatePen(*wxBLACK, actual_border_size)); | ||
37 | dc.SetBrush(*wxGREEN_BRUSH); | ||
38 | dc.DrawRectangle({0, 0}, GetSize()); | ||
39 | } | ||
diff --git a/area_window.h b/area_window.h new file mode 100644 index 0000000..0806da4 --- /dev/null +++ b/area_window.h | |||
@@ -0,0 +1,30 @@ | |||
1 | #ifndef AREA_WINDOW_H_C2653ACF | ||
2 | #define AREA_WINDOW_H_C2653ACF | ||
3 | |||
4 | #include <wx/wxprec.h> | ||
5 | |||
6 | #ifndef WX_PRECOMP | ||
7 | #include <wx/wx.h> | ||
8 | #endif | ||
9 | |||
10 | class AreaWindow : public wxWindow { | ||
11 | public: | ||
12 | static constexpr int ACTUAL_SIZE = 64; | ||
13 | static constexpr int BORDER_SIZE = 5; | ||
14 | static constexpr int EFFECTIVE_SIZE = ACTUAL_SIZE + BORDER_SIZE * 2; | ||
15 | |||
16 | AreaWindow(wxWindow* parent, int area_id); | ||
17 | |||
18 | int GetAreaId() const { return area_id_; } | ||
19 | |||
20 | private: | ||
21 | void OnPaint(wxPaintEvent& event); | ||
22 | void OnEnterWindow(wxMouseEvent& event); | ||
23 | |||
24 | void Redraw(); | ||
25 | |||
26 | int area_id_; | ||
27 | wxBitmap rendered_; | ||
28 | }; | ||
29 | |||
30 | #endif /* end of include guard: AREA_WINDOW_H_C2653ACF */ | ||
diff --git a/assets/areas.yaml b/assets/areas.yaml new file mode 100755 index 0000000..423ecd1 --- /dev/null +++ b/assets/areas.yaml | |||
@@ -0,0 +1,129 @@ | |||
1 | --- | ||
2 | Starting Room: | ||
3 | map: [1589, 1192] | ||
4 | Hidden Room: | ||
5 | map: [1725, 1236] | ||
6 | The Seeker: | ||
7 | map: [1686, 1361] | ||
8 | Second Room: | ||
9 | map: [1589, 1029] | ||
10 | Hub Room: | ||
11 | map: [1589, 924] | ||
12 | Pilgrim Room: | ||
13 | map: [1493, 1564] | ||
14 | Crossroads: | ||
15 | map: [1294, 720] | ||
16 | Amen Name Area: | ||
17 | fold_into: Crossroads | ||
18 | The Tenacious: | ||
19 | map: [1589, 780] | ||
20 | Warts Straw Area: | ||
21 | fold_into: Outside The Agreeable | ||
22 | Leaf Feel Area: | ||
23 | fold_into: Outside The Agreeable | ||
24 | Outside The Agreeable: | ||
25 | map: [1766, 700] | ||
26 | Hallway Room: | ||
27 | map: [573, 1631] | ||
28 | Dread Hallway: | ||
29 | fold_into: Outside The Agreeable | ||
30 | The Agreeable: | ||
31 | map: [1909, 699] | ||
32 | Hedge Maze: | ||
33 | map: [2102, 600] | ||
34 | The Perceptive: | ||
35 | map: [2251, 600] | ||
36 | The Fearless: | ||
37 | map: [1790, 2220] | ||
38 | The Observant: | ||
39 | map: [2252, 193] | ||
40 | The Incomparable: | ||
41 | map: [2642, 872] | ||
42 | Orange Tower First Floor: | ||
43 | map: [1285, 928] | ||
44 | Color Hunt: | ||
45 | map: [1790, 2079] | ||
46 | Orange Tower Third Floor: | ||
47 | map: [1935, 1575] | ||
48 | Orange Tower Fourth Floor: | ||
49 | map: [1365, 394] | ||
50 | Orange Tower Fifth Floor: | ||
51 | map: [1252, 1259] | ||
52 | Orange Tower Seventh Floor: | ||
53 | map: [1587, 1900] | ||
54 | Courtyard: | ||
55 | map: [863, 387] | ||
56 | The Colorful: | ||
57 | map: [863, 200] | ||
58 | Welcome Back Area: | ||
59 | map: [1472, 1233] | ||
60 | Owl Hallway: | ||
61 | map: [2080, 886] | ||
62 | Outside The Initiated: | ||
63 | map: [2282, 1483] | ||
64 | The Initiated: | ||
65 | map: [2294, 1174] | ||
66 | The Traveled: | ||
67 | map: [1964, 994] | ||
68 | Outside The Bold: | ||
69 | map: [2325, 1927] | ||
70 | The Bold: | ||
71 | map: [2297, 2053] | ||
72 | The Red: | ||
73 | map: [2352, 2053] | ||
74 | Outside The Undeterred: | ||
75 | map: [657, 1315] | ||
76 | The Undeterred: | ||
77 | map: [618, 1456] | ||
78 | Number Hunt: | ||
79 | map: [1108, 1315] | ||
80 | Directional Gallery: | ||
81 | map: [943, 1169] | ||
82 | Champion's Rest: | ||
83 | map: [1845, 1883] | ||
84 | The Bearer: | ||
85 | map: [2155, 1764] | ||
86 | The Steady: | ||
87 | map: [2121, 2182] | ||
88 | Knight Night Room: | ||
89 | map: [1990, 1322] | ||
90 | The Artistic: | ||
91 | map: [1151, 1793] | ||
92 | The Artistic (Smiley): | ||
93 | fold_into: The Artistic | ||
94 | The Discerning: | ||
95 | map: [1098, 807] | ||
96 | The Ecstatic: | ||
97 | map: [972, 805] | ||
98 | The Eyes They See: | ||
99 | map: [955, 933] | ||
100 | Outside The Wondrous: | ||
101 | map: [691, 524] | ||
102 | The Wondrous: | ||
103 | map: [648, 338] | ||
104 | Elements Area: | ||
105 | map: [908, 1632] | ||
106 | Wanderlust Tutorial: | ||
107 | map: [1587, 1765] | ||
108 | Rhyme Room (Smiley): | ||
109 | fold_into: Rhyme Room | ||
110 | Rhyme Room (Cross): | ||
111 | fold_into: Rhyme Room | ||
112 | Rhyme Room: | ||
113 | map: [1587, 1492] | ||
114 | Rhyme Room (Target): | ||
115 | fold_into: Rhyme Room | ||
116 | Room Room: | ||
117 | map: [2553, 2153] | ||
118 | Outside The Wise: | ||
119 | map: [1087, 1986] | ||
120 | The Wise: | ||
121 | map: [759, 1986] | ||
122 | Outside The Scientific: | ||
123 | map: [510, 2271] | ||
124 | The Scientific: | ||
125 | map: [1368, 2103] | ||
126 | Art Gallery: | ||
127 | map: [2474, 1366] | ||
128 | Challenge Room: | ||
129 | map: [1486, 1357] | ||
diff --git a/game_data.cpp b/game_data.cpp index 0ae5468..f377e0b 100644 --- a/game_data.cpp +++ b/game_data.cpp | |||
@@ -217,6 +217,21 @@ GameData::GameData() { | |||
217 | } | 217 | } |
218 | } | 218 | } |
219 | } | 219 | } |
220 | |||
221 | map_areas_.reserve(areas_config.size()); | ||
222 | |||
223 | std::map<std::string, int> fold_areas; | ||
224 | for (const auto &area_it : areas_config) { | ||
225 | if (area_it.second["map"]) { | ||
226 | int area_id = AddOrGetArea(area_it.first.as<std::string>()); | ||
227 | MapArea &area_obj = map_areas_[area_id]; | ||
228 | area_obj.map_x = area_it.second["map"][0].as<int>(); | ||
229 | area_obj.map_y = area_it.second["map"][1].as<int>(); | ||
230 | } else if (area_it.second["fold_into"]) { | ||
231 | fold_areas[area_it.first.as<std::string>()] = | ||
232 | AddOrGetArea(area_it.second["fold_into"].as<std::string>()); | ||
233 | } | ||
234 | } | ||
220 | } | 235 | } |
221 | 236 | ||
222 | int GameData::AddOrGetRoom(std::string room) { | 237 | int GameData::AddOrGetRoom(std::string room) { |
@@ -250,6 +265,16 @@ int GameData::AddOrGetPanel(std::string room, std::string panel) { | |||
250 | return panel_by_id_[full_name]; | 265 | return panel_by_id_[full_name]; |
251 | } | 266 | } |
252 | 267 | ||
268 | int GameData::AddOrGetArea(std::string area) { | ||
269 | if (!area_by_id_.count(area)) { | ||
270 | area_by_id_[area] = map_areas_.size(); | ||
271 | map_areas_.push_back( | ||
272 | {.id = static_cast<int>(map_areas_.size()), .name = area}); | ||
273 | } | ||
274 | |||
275 | return area_by_id_[area]; | ||
276 | } | ||
277 | |||
253 | const GameData &GetGameData() { | 278 | const GameData &GetGameData() { |
254 | static GameData *instance = new GameData(); | 279 | static GameData *instance = new GameData(); |
255 | return *instance; | 280 | return *instance; |
diff --git a/game_data.h b/game_data.h index 761b233..91b48a5 100644 --- a/game_data.h +++ b/game_data.h | |||
@@ -57,6 +57,7 @@ struct Location { | |||
57 | }; | 57 | }; |
58 | 58 | ||
59 | struct MapArea { | 59 | struct MapArea { |
60 | int id; | ||
60 | std::string name; | 61 | std::string name; |
61 | std::vector<Location> locations; | 62 | std::vector<Location> locations; |
62 | int map_x; | 63 | int map_x; |
@@ -67,20 +68,27 @@ class GameData { | |||
67 | public: | 68 | public: |
68 | GameData(); | 69 | GameData(); |
69 | 70 | ||
71 | const std::vector<MapArea>& GetMapAreas() const { return map_areas_; } | ||
72 | |||
73 | const MapArea& GetMapArea(int id) const { return map_areas_.at(id); } | ||
74 | |||
70 | private: | 75 | private: |
71 | int AddOrGetRoom(std::string room); | 76 | int AddOrGetRoom(std::string room); |
72 | int AddOrGetDoor(std::string room, std::string door); | 77 | int AddOrGetDoor(std::string room, std::string door); |
73 | int AddOrGetPanel(std::string room, std::string panel); | 78 | int AddOrGetPanel(std::string room, std::string panel); |
79 | int AddOrGetArea(std::string area); | ||
74 | 80 | ||
75 | std::vector<Room> rooms_; | 81 | std::vector<Room> rooms_; |
76 | std::vector<Door> doors_; | 82 | std::vector<Door> doors_; |
77 | std::vector<Panel> panels_; | 83 | std::vector<Panel> panels_; |
84 | std::vector<MapArea> map_areas_; | ||
78 | 85 | ||
79 | std::map<std::string, int> room_by_id_; | 86 | std::map<std::string, int> room_by_id_; |
80 | std::map<std::string, int> door_by_id_; | 87 | std::map<std::string, int> door_by_id_; |
81 | std::map<std::string, int> panel_by_id_; | 88 | std::map<std::string, int> panel_by_id_; |
89 | std::map<std::string, int> area_by_id_; | ||
82 | }; | 90 | }; |
83 | 91 | ||
84 | const GameData &GetGameData(); | 92 | const GameData& GetGameData(); |
85 | 93 | ||
86 | #endif /* end of include guard: GAME_DATA_H_9C42AC51 */ | 94 | #endif /* end of include guard: GAME_DATA_H_9C42AC51 */ |
diff --git a/tracker_panel.cpp b/tracker_panel.cpp index 38d7c86..0cd65cc 100644 --- a/tracker_panel.cpp +++ b/tracker_panel.cpp | |||
@@ -1,11 +1,17 @@ | |||
1 | #include "tracker_panel.h" | 1 | #include "tracker_panel.h" |
2 | 2 | ||
3 | #include "game_data.h" | ||
4 | |||
3 | TrackerPanel::TrackerPanel(wxWindow *parent) : wxPanel(parent, wxID_ANY) { | 5 | TrackerPanel::TrackerPanel(wxWindow *parent) : wxPanel(parent, wxID_ANY) { |
4 | map_image_ = wxImage("assets/lingo_map.png", wxBITMAP_TYPE_PNG); | 6 | map_image_ = wxImage("assets/lingo_map.png", wxBITMAP_TYPE_PNG); |
5 | if (!map_image_.IsOk()) { | 7 | if (!map_image_.IsOk()) { |
6 | return; | 8 | return; |
7 | } | 9 | } |
8 | 10 | ||
11 | for (const MapArea &map_area : GetGameData().GetMapAreas()) { | ||
12 | area_windows_.push_back(new AreaWindow(this, map_area.id)); | ||
13 | } | ||
14 | |||
9 | Redraw(); | 15 | Redraw(); |
10 | 16 | ||
11 | Bind(wxEVT_PAINT, &TrackerPanel::OnPaint, this); | 17 | Bind(wxEVT_PAINT, &TrackerPanel::OnPaint, this); |
@@ -43,4 +49,18 @@ void TrackerPanel::Redraw() { | |||
43 | rendered_ = wxBitmap( | 49 | rendered_ = wxBitmap( |
44 | map_image_.Scale(final_width, final_height, wxIMAGE_QUALITY_NORMAL) | 50 | map_image_.Scale(final_width, final_height, wxIMAGE_QUALITY_NORMAL) |
45 | .Size(panel_size, {final_x, final_y}, 0, 0, 0)); | 51 | .Size(panel_size, {final_x, final_y}, 0, 0, 0)); |
52 | |||
53 | for (AreaWindow *area_window : area_windows_) { | ||
54 | const MapArea &map_area = | ||
55 | GetGameData().GetMapArea(area_window->GetAreaId()); | ||
56 | int real_area_size = | ||
57 | final_width * AreaWindow::EFFECTIVE_SIZE / image_size.GetWidth(); | ||
58 | area_window->SetSize({real_area_size, real_area_size}); | ||
59 | area_window->SetPosition({ | ||
60 | final_x + (map_area.map_x - (AreaWindow::EFFECTIVE_SIZE / 2)) * | ||
61 | final_width / image_size.GetWidth(), | ||
62 | final_y + (map_area.map_y - (AreaWindow::EFFECTIVE_SIZE / 2)) * | ||
63 | final_width / image_size.GetWidth(), | ||
64 | }); | ||
65 | } | ||
46 | } | 66 | } |
diff --git a/tracker_panel.h b/tracker_panel.h index 32f7537..ae15271 100644 --- a/tracker_panel.h +++ b/tracker_panel.h | |||
@@ -7,6 +7,8 @@ | |||
7 | #include <wx/wx.h> | 7 | #include <wx/wx.h> |
8 | #endif | 8 | #endif |
9 | 9 | ||
10 | #include "area_window.h" | ||
11 | |||
10 | class TrackerPanel : public wxPanel { | 12 | class TrackerPanel : public wxPanel { |
11 | public: | 13 | public: |
12 | TrackerPanel(wxWindow *parent); | 14 | TrackerPanel(wxWindow *parent); |
@@ -18,6 +20,8 @@ class TrackerPanel : public wxPanel { | |||
18 | 20 | ||
19 | wxImage map_image_; | 21 | wxImage map_image_; |
20 | wxBitmap rendered_; | 22 | wxBitmap rendered_; |
23 | |||
24 | std::vector<AreaWindow *> area_windows_; | ||
21 | }; | 25 | }; |
22 | 26 | ||
23 | #endif /* end of include guard: TRACKER_PANEL_H_D675A54D */ | 27 | #endif /* end of include guard: TRACKER_PANEL_H_D675A54D */ |