From ea16cff14ff4faf5782da8ff684a6ec412b7b6ac Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Sun, 12 May 2024 17:48:02 -0400 Subject: Started making subway map --- CMakeLists.txt | 1 + assets/owl.png | Bin 0 -> 439 bytes assets/subway.png | Bin 0 -> 184533 bytes assets/subway.yaml | 614 ++++++++++++++++++++++++++++++++++++++++++++++++++ src/game_data.cpp | 62 ++++- src/game_data.h | 25 ++ src/subway_map.cpp | 89 ++++++++ src/subway_map.h | 35 +++ src/tracker_frame.cpp | 13 +- src/tracker_frame.h | 2 + src/tracker_state.cpp | 20 ++ src/tracker_state.h | 2 + 12 files changed, 859 insertions(+), 4 deletions(-) create mode 100644 assets/owl.png create mode 100644 assets/subway.png create mode 100644 assets/subway.yaml create mode 100644 src/subway_map.cpp create mode 100644 src/subway_map.h diff --git a/CMakeLists.txt b/CMakeLists.txt index a6f6342..99b15f8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -43,6 +43,7 @@ add_executable(lingo_ap_tracker "src/achievements_pane.cpp" "src/settings_dialog.cpp" "src/global.cpp" + "src/subway_map.cpp" "vendor/whereami/whereami.c" ) set_property(TARGET lingo_ap_tracker PROPERTY CXX_STANDARD 20) diff --git a/assets/owl.png b/assets/owl.png new file mode 100644 index 0000000..0210303 Binary files /dev/null and b/assets/owl.png differ diff --git a/assets/subway.png b/assets/subway.png new file mode 100644 index 0000000..3860d2c Binary files /dev/null and b/assets/subway.png differ diff --git a/assets/subway.yaml b/assets/subway.yaml new file mode 100644 index 0000000..b0d9c84 --- /dev/null +++ b/assets/subway.yaml @@ -0,0 +1,614 @@ +--- +- pos: [1050, 954] + room: Starting Room + door: Back Right Door +- pos: [986, 1034] + room: Starting Room + door: Rhyme Room Entrance +- pos: [990, 956] + special: starting_room_paintings # Early Color Hallways painting is a hardcoded special case + paintings: + - arrows_painting +- pos: [905, 841] + room: Hedge Maze + door: Painting Shortcut + paintings: + - garden_painting_tower2 + tags: + - garden_starting +- pos: [1066, 841] + room: Courtyard + door: Painting Shortcut + paintings: + - flower_painting_8 + tags: + - flower_starting +- pos: [905, 895] + room: The Wondrous (Doorknob) + door: Painting Shortcut + paintings: + - symmetry_painting_a_starter + tags: + - symmetry_starting +- pos: [1066, 868] + room: Outside The Bold + door: Painting Shortcut + paintings: + - pencil_painting6 + tags: + - pencil_starting +- pos: [1066, 895] + room: Outside The Undeterred + door: Painting Shortcut + paintings: + - blueman_painting_3 + tags: + - blueman_starting +- pos: [905, 868] + room: Outside The Agreeable + door: Painting Shortcut + paintings: + - eyes_yellow_painting2 + tags: + - street_starting +- pos: [1211, 879] + room: Hidden Room + door: Dead End Door +- pos: [1291, 906] + room: Hidden Room + door: Knight Night Entrance +- pos: [1103, 980] + room: Hidden Room + door: Seeker Entrance +- pos: [1173, 980] + room: Hidden Room + door: Rhyme Room Entrance +- pos: [1116, 939] + paintings: + - owl_painting + tags: + - owl_hidden +- pos: [986, 793] + room: Second Room + door: Exit Door +- pos: [798, 584] + room: Hub Room + door: Crossroads Entrance +- pos: [932, 665] + room: Hub Room + door: Tenacious Entrance +- pos: [1361, 578] + room: Hub Room + door: Shortcut to Hedge Maze +- pos: [1312, 841] + room: Hub Room + door: Near RAT Door +- pos: [1371, 729] + room: Hub Room + door: Traveled Entrance +- pos: [1313, 686] + paintings: + - maze_painting + tags: + - green_owl + - green_numbers +- pos: [1172, 760] + sunwarp: + dots: 1 + type: enter +- pos: [1302, 638] + room: Outside The Undeterred + door: Fours +- pos: [1243, 819] + room: Outside The Undeterred + door: Fours +- pos: [1276, 819] + room: Outside The Undeterred + door: Eights +- pos: [1263, 867] + paintings: + - smile_painting_6 + tags: + - smiley_deadend +- pos: [1012, 1086] + sunwarp: + dots: 6 + type: final +- pos: [938, 1002] + room: Pilgrim Antechamber + door: Sun Painting + special: sun_painting +- pos: [1053, 1090] + invisible: true + special: sun_painting_exit +- pos: [1077, 1061] + room: Pilgrim Room + door: Shortcut to The Seeker +- pos: [713, 359] + room: Number Hunt + door: Eights +- pos: [932, 348] + room: Crossroads + door: Hollow Hallway +- pos: [798, 290] + room: Crossroads + door: Tower Entrance +- pos: [932, 477] + room: Crossroads + door: Tenacious Entrance +- pos: [638, 477] + room: Crossroads + door: Discerning Entrance +- pos: [905, 290] + room: Crossroads + door: Tower Back Entrance +- pos: [894, 423] + room: Crossroads + door: Words Sword Door +- pos: [632, 643] + room: Crossroads + door: Eye Wall +- pos: [638, 520] + room: Crossroads + door: Roof Access +- pos: [756, 400] + paintings: + - smile_painting_4 + tags: + - smiley_crossroads +- pos: [878, 509] + sunwarp: + dots: 1 + type: exit +- pos: [1056, 344] + room: Lost Area + door: Exit +- pos: [954, 290] + room: Lost Area + door: Exit +- pos: [986, 290] + room: Number Hunt + door: Eights +- pos: [954, 247] + room: Amen Name Area + door: Exit +- pos: [954, 222] + paintings: + - west_afar +- pos: [986, 697] + room: The Tenacious + door: Shortcut to Hub Room +- pos: [1173, 665] + room: Near Far Area + door: Door +- pos: [1173, 622] + room: Warts Straw Area + door: Door +- pos: [1173, 579] + room: Leaf Feel Area + door: Door +- pos: [1173, 333] + room: Outside The Agreeable + door: Purple Barrier +- pos: [1088, 289] + room: Outside The Undeterred + door: Fives +- pos: [1088, 418] + room: Outside The Undeterred + door: Fives +- pos: [1039, 477] + room: Outside The Agreeable + door: Tenacious Entrance +- pos: [1147, 525] + room: Outside The Agreeable + door: Black Door +- pos: [1216, 525] + room: Outside The Agreeable + door: Agreeable Entrance +- pos: [1138, 287] + paintings: + - eyes_yellow_painting + tags: + - street_starting +- pos: [1088, 385] + sunwarp: + dots: 6 + type: enter +- pos: [1195, 450] + room: Compass Room + door: Lookout Entrance +- pos: [1214, 457] + paintings: + - pencil_painting7 + tags: + - pencil_compass +- pos: [1196, 417] + invisible: true + tags: + - agreeable_to_lookout +- pos: [1657, 1392] + room: Room Room + door: Excavation +- pos: [1725, 1441] + invisible: true + tags: + - agreeable_to_lookout +- pos: [1040, 665] + room: Dread Hallway + door: Tenacious Entrance +- pos: [1324, 525] + room: The Agreeable + door: Shortcut to Hedge Maze +- pos: [1484, 392] + room: Hedge Maze + door: Perceptive Entrance +- pos: [1441, 241] + room: Hedge Maze + door: Observant Entrance +- pos: [1714, 434] + room: Hedge Maze + door: Observant Entrance +- pos: [1477, 343] + paintings: + - garden_painting_tower + tags: + - garden_starting +- pos: [1565, 311] + room: The Fearless (First Floor) + door: Second Floor +- pos: [1597, 279] + room: The Fearless (Second Floor) + door: Third Floor +- pos: [1414, 209] + room: The Observant + door: Backside Door +- pos: [1624, 188] + room: The Observant + door: Stairs +- pos: [1667, 686] + room: The Incomparable + door: Eight Door +- pos: [1784, 569] + paintings: + - crown_painting + tags: + - crown_tower6 +- pos: [1653, 717] + paintings: + - eight_painting2 + tags: + - eight_alcove +- pos: [1653, 662] + paintings: + - eight_painting + tags: + - eight_alcove +- pos: [697, 1471] + room: Orange Tower + door: Second Floor +- pos: [633, 1406] + room: Orange Tower + door: Third Floor +- pos: [570, 1343] + room: Orange Tower + door: Fourth Floor +- pos: [504, 1279] + room: Orange Tower + door: Fifth Floor +- pos: [440, 1215] + room: Orange Tower + door: Sixth Floor +- pos: [379, 1153] + room: Orange Tower + door: Seventh Floor +- pos: [905, 793] + room: Orange Tower First Floor + door: Shortcut to Hub Room +- pos: [686, 820] + room: Orange Tower First Floor + door: Salt Pepper Door +- pos: [755, 787] + sunwarp: + dots: 4 + type: enter +- pos: [719, 846] + tags: + - tower1_tower1 +- pos: [681, 1506] + tags: + - tower1_tower1 +- pos: [722, 1439] + tags: + - tower2_undeterred +- pos: [533, 1375] + tags: + - tower3_tower3 +- pos: [662, 1375] + tags: + - tower3_gallery +- pos: [483, 1307] + tags: + - tower4_room +- pos: [598, 1307] + tags: + - tower4_tower4 +- pos: [598, 1287] + tags: + - tower4_courtyard +- pos: [533, 1245] + tags: + - tower5_welcome +- pos: [419, 1245] + tags: + - tower5_cellar +- pos: [419, 1267] + tags: + - tower5_quadruple +- pos: [203, 1014] + tags: + - tower2_undeterred +- pos: [1325, 1191] + tags: + - tower3_tower3 +- pos: [1700, 1021] + tags: + - tower3_gallery +- pos: [1653, 1318] + tags: + - tower4_room +- pos: [918, 222] + tags: + - tower4_tower4 +- pos: [806, 222] + tags: + - tower4_courtyard +- pos: [652, 951] + tags: + - tower5_welcome +- pos: [1553, 1440] + tags: + - tower5_cellar +- pos: [1459, 1119] + tags: + - tower5_quadruple +- pos: [1216, 1280] + room: Orange Tower Third Floor + door: Red Barrier +- pos: [1173, 1248] + room: Orange Tower Third Floor + door: Rhyme Room Entrance +- pos: [1270, 1231] + paintings: + - arrows_painting_6 + - flower_painting_5 +- pos: [1216, 1216] + sunwarp: + dots: 2 + type: exit +- pos: [1253, 1172] + sunwarp: + dots: 3 + type: enter +- pos: [852, 198] + room: Orange Tower Fourth Floor + door: Hot Crusts Door +- pos: [830, 289] + sunwarp: + dots: 5 + type: enter +- pos: [877, 155] + room: Number Hunt + door: Eights +- pos: [844, 134] + paintings: + - smile_painting_8 + tags: + - smiley_hotcrusts +- pos: [797, 155] + sunwarp: + dots: 2 + type: enter +- pos: [679, 985] + room: Number Hunt + door: Nines +- pos: [723, 953] + room: Orange Tower Fifth Floor + door: Welcome Back +- pos: [683, 944] + paintings: + - east_afar +- pos: [548, 1221] + paintings: + - hi_solved_painting3 +- pos: [1574, 1425] + paintings: + - hi_solved_painting2 +- pos: [411, 1186] + paintings: + - arrows_painting_10 + - owl_painting_3 + - clock_painting + - scenery_painting_5d_2 + - symmetry_painting_b_7 + - panda_painting_2 + - crown_painting2 + - colors_painting2 + - cherry_painting2 + - hi_solved_painting + tags: + - owl_tower6 + - wise_tower6 + - panda_tower6 + - crown_tower6 + - apple_tower6 + - hi_scientific +- pos: [349, 1124] + paintings: + - map_painting2 +- pos: [436, 1159] + room: Orange Tower Seventh Floor + door: Mastery +- pos: [544, 1159] + paintings: + - arrows_painting_11 +- pos: [498, 284] + room: Courtyard + door: Green Barrier +- pos: [556, 233] + paintings: + - flower_painting_7 + tags: + - flower_starting + - flower_arrow +- pos: [600, 332] + room: Number Hunt + door: Nines +- pos: [579, 350] + paintings: + - blueman_painting + tags: + - blueman_courtyard +- pos: [530, 310] + room: First Second Third Fourth + door: Backside Door +- pos: [584, 107] + room: The Colorful (White) + door: Progress Door +- pos: [622, 107] + room: The Colorful (Black) + door: Progress Door +- pos: [659, 107] + room: The Colorful (Red) + door: Progress Door +- pos: [697, 107] + room: The Colorful (Yellow) + door: Progress Door +- pos: [734, 107] + room: The Colorful (Blue) + door: Progress Door +- pos: [772, 107] + room: The Colorful (Purple) + door: Progress Door +- pos: [809, 107] + room: The Colorful (Orange) + door: Progress Door +- pos: [847, 107] + room: The Colorful (Green) + door: Progress Door +- pos: [884, 107] + room: The Colorful (Brown) + door: Progress Door +- pos: [922, 107] + room: The Colorful (Gray) + door: Progress Door +- pos: [967, 107] + paintings: + - arrows_painting_12 +- pos: [878, 954] + room: Welcome Back Area + door: Shortcut to Starting Room +- pos: [773, 954] + tags: + - hub_wb + - wondrous_wb + - undeterred_wb + - agreeable_wb + - wanderer_wb + - observant_wb + - gallery_wb + - scientific_wb + - cellar_wb +- pos: [1107, 749] + tags: + - hub_wb +- pos: [408, 817] + tags: + - wondrous_wb +- pos: [281, 1017] + tags: + - undeterred_wb +- pos: [1017, 289] + tags: + - agreeable_wb +- pos: [907, 1385] + tags: + - wanderer_wb +- pos: [1737, 1053] + tags: + - gallery_wb +- pos: [1690, 268] + tags: + - observant_wb +- pos: [250, 604] + tags: + - scientific_wb +- pos: [1553, 1467] + tags: + - cellar_wb +- pos: [1478, 498] + room: Owl Hallway + door: Shortcut to Hedge Maze +- pos: [1480, 551] + paintings: + - arrows_painting_8 + - maze_painting_2 + - owl_painting_2 + - clock_painting_4 + tags: + - green_owl + - owl_hidden + - owl_tower6 +- pos: [1478, 938] + room: Number Hunt + door: Sevens +- pos: [1580, 853] + room: Number Hunt + door: Sevens +- pos: [1478, 905] + room: Number Hunt + door: Eights +- pos: [1452, 841] + room: Number Hunt + door: Nines +- pos: [1420, 841] + room: Outside The Initiated + door: Blue Barrier +- pos: [1479, 1018] + room: Outside The Initiated + door: Orange Barrier +- pos: [1360, 847] + room: Outside The Initiated + door: Shortcut to Hub Room +- pos: [1511, 841] + room: Outside The Initiated + door: Initiated Entrance +- pos: [1141, 1441] + room: Orange Tower Third Floor + door: Orange Barrier +- pos: [1173, 1441] + room: Outside The Initiated + door: Green Barrier +- pos: [1206, 1441] + room: Outside The Initiated + door: Purple Barrier +- pos: [1189, 1355] + room: Outside The Initiated + door: Entrance +- pos: [1580, 729] + room: Outside The Initiated + door: Eight Door +- pos: [1530, 938] + paintings: + - clock_painting_5 + tags: + - clock_initiated +- pos: [1546, 938] + paintings: + - clock_painting_2 + tags: + - clock_tower6 + - clock_initiated +- pos: [1579, 813] + sunwarp: + dots: 3 + type: exit diff --git a/src/game_data.cpp b/src/game_data.cpp index c98f532..4348967 100644 --- a/src/game_data.cpp +++ b/src/game_data.cpp @@ -44,6 +44,7 @@ struct GameData { std::vector doors_; std::vector panels_; std::vector map_areas_; + std::vector subway_items_; std::map room_by_id_; std::map door_by_id_; @@ -606,6 +607,56 @@ struct GameData { errstr << "Area data not found for: " << area; TrackerLog(errstr.str()); } + + // Read in subway items. + YAML::Node subway_config = + YAML::LoadFile(GetAbsolutePath("assets/subway.yaml")); + for (const auto &subway_it : subway_config) { + SubwayItem subway_item; + subway_item.id = subway_items_.size(); + subway_item.x = subway_it["pos"][0].as(); + subway_item.y = subway_it["pos"][1].as(); + + if (subway_it["door"]) { + subway_item.door = AddOrGetDoor(subway_it["room"].as(), + subway_it["door"].as()); + } + + if (subway_it["paintings"]) { + for (const auto &painting_it : subway_it["paintings"]) { + subway_item.paintings.push_back(painting_it.as()); + } + } + + if (subway_it["tags"]) { + for (const auto &tag_it : subway_it["tags"]) { + subway_item.tags.push_back(tag_it.as()); + } + } + + if (subway_it["sunwarp"]) { + SubwaySunwarp sunwarp; + sunwarp.dots = subway_it["sunwarp"]["dots"].as(); + + std::string sunwarp_type = + subway_it["sunwarp"]["type"].as(); + if (sunwarp_type == "final") { + sunwarp.type = SubwaySunwarpType::kFinal; + } else if (sunwarp_type == "exit") { + sunwarp.type = SubwaySunwarpType::kExit; + } else { + sunwarp.type = SubwaySunwarpType::kEnter; + } + + subway_item.sunwarp = sunwarp; + } + + if (subway_it["special"]) { + subway_item.special = subway_it["special"].as(); + } + + subway_items_.push_back(subway_item); + } } int AddOrGetRoom(std::string room) { @@ -621,8 +672,9 @@ struct GameData { std::string full_name = room + " - " + door; if (!door_by_id_.count(full_name)) { + int door_id = doors_.size(); door_by_id_[full_name] = doors_.size(); - doors_.push_back({.room = AddOrGetRoom(room), .name = door}); + doors_.push_back({.id = door_id, .room = AddOrGetRoom(room), .name = door}); } return door_by_id_[full_name]; @@ -704,3 +756,11 @@ const std::vector &GD_GetSunwarpDoors() { int GD_GetRoomForSunwarp(int index) { return GetState().room_by_sunwarp_.at(index); } + +const std::vector &GD_GetSubwayItems() { + return GetState().subway_items_; +} + +const SubwayItem &GD_GetSubwayItem(int id) { + return GetState().subway_items_.at(id); +} diff --git a/src/game_data.h b/src/game_data.h index cd09627..37d1eb3 100644 --- a/src/game_data.h +++ b/src/game_data.h @@ -62,6 +62,7 @@ struct ProgressiveRequirement { }; struct Door { + int id; int room; std::string name; std::string location_name; @@ -118,6 +119,28 @@ struct MapArea { bool hunt = false; }; +enum class SubwaySunwarpType { + kEnter, + kExit, + kFinal +}; + +struct SubwaySunwarp { + int dots; + SubwaySunwarpType type; +}; + +struct SubwayItem { + int id; + int x; + int y; + std::optional door; + std::vector paintings; + std::vector tags; + std::optional sunwarp; + std::optional special; +}; + const std::vector& GD_GetMapAreas(); const MapArea& GD_GetMapArea(int id); int GD_GetRoomByName(const std::string& name); @@ -131,5 +154,7 @@ const std::vector& GD_GetAchievementPanels(); int GD_GetItemIdForColor(LingoColor color); const std::vector& GD_GetSunwarpDoors(); int GD_GetRoomForSunwarp(int index); +const std::vector& GD_GetSubwayItems(); +const SubwayItem& GD_GetSubwayItem(int id); #endif /* end of include guard: GAME_DATA_H_9C42AC51 */ diff --git a/src/subway_map.cpp b/src/subway_map.cpp new file mode 100644 index 0000000..c58b2d1 --- /dev/null +++ b/src/subway_map.cpp @@ -0,0 +1,89 @@ +#include "subway_map.h" + +#include "game_data.h" +#include "global.h" +#include "tracker_state.h" + +constexpr int AREA_ACTUAL_SIZE = 21; + +SubwayMap::SubwayMap(wxWindow *parent) : wxPanel(parent, wxID_ANY) { + map_image_ = + wxImage(GetAbsolutePath("assets/subway.png").c_str(), wxBITMAP_TYPE_PNG); + if (!map_image_.IsOk()) { + return; + } + + Redraw(); + Resize(); + + Bind(wxEVT_PAINT, &SubwayMap::OnPaint, this); + Bind(wxEVT_MOTION, &SubwayMap::OnMouseMove, this); +} + +void SubwayMap::UpdateIndicators() { + Redraw(); + Resize(); +} + +void SubwayMap::OnPaint(wxPaintEvent &event) { + if (GetSize() != resized_.GetSize()) { + Resize(); + } + + wxPaintDC dc(this); + dc.DrawBitmap(resized_, 0, 0); + + event.Skip(); +} + +void SubwayMap::OnMouseMove(wxMouseEvent &event) { + event.Skip(); +} + +void SubwayMap::Redraw() { + rendered_ = wxBitmap(map_image_); + + wxMemoryDC dc; + dc.SelectObject(rendered_); + + for (const SubwayItem &subway_item : GD_GetSubwayItems()) { + const wxBrush *brush_color = wxGREY_BRUSH; + if (subway_item.door) { + if (IsDoorOpen(*subway_item.door)) { + brush_color = wxGREEN_BRUSH; + } else { + brush_color = wxRED_BRUSH; + } + } + + dc.SetPen(*wxThePenList->FindOrCreatePen(*wxBLACK, 1)); + dc.SetBrush(*brush_color); + dc.DrawRectangle({subway_item.x, subway_item.y}, + {AREA_ACTUAL_SIZE, AREA_ACTUAL_SIZE}); + } +} + +void SubwayMap::Resize() { + wxSize panel_size = GetSize(); + wxSize image_size = rendered_.GetSize(); + + render_x_ = 0; + render_y_ = 0; + render_width_ = panel_size.GetWidth(); + render_height_ = panel_size.GetHeight(); + + if (image_size.GetWidth() * panel_size.GetHeight() > + panel_size.GetWidth() * image_size.GetHeight()) { + render_height_ = (panel_size.GetWidth() * image_size.GetHeight()) / + image_size.GetWidth(); + render_y_ = (panel_size.GetHeight() - render_height_) / 2; + } else { + render_width_ = (image_size.GetWidth() * panel_size.GetHeight()) / + image_size.GetHeight(); + render_x_ = (panel_size.GetWidth() - render_width_) / 2; + } + + resized_ = wxBitmap(rendered_.ConvertToImage() + .Scale(render_width_, render_height_, wxIMAGE_QUALITY_BILINEAR) + .Size(panel_size, {render_x_, render_y_}, 0, 0, 0)); +} diff --git a/src/subway_map.h b/src/subway_map.h new file mode 100644 index 0000000..dc67867 --- /dev/null +++ b/src/subway_map.h @@ -0,0 +1,35 @@ +#ifndef SUBWAY_MAP_H_BD2D843E +#define SUBWAY_MAP_H_BD2D843E + +#include + +#ifndef WX_PRECOMP +#include +#endif + +#include + +class SubwayMap : public wxPanel { + public: + SubwayMap(wxWindow *parent); + + void UpdateIndicators(); + + private: + void OnPaint(wxPaintEvent &event); + void OnMouseMove(wxMouseEvent &event); + + void Redraw(); + void Resize(); + + wxImage map_image_; + wxBitmap rendered_; + wxBitmap resized_; + int render_x_ = 0; + int render_y_ = 0; + int render_width_ = 0; + int render_height_ = 0; + +}; + +#endif /* end of include guard: SUBWAY_MAP_H_BD2D843E */ diff --git a/src/tracker_frame.cpp b/src/tracker_frame.cpp index 8a0c764..70fee2d 100644 --- a/src/tracker_frame.cpp +++ b/src/tracker_frame.cpp @@ -11,6 +11,7 @@ #include "ap_state.h" #include "connection_dialog.h" #include "settings_dialog.h" +#include "subway_map.h" #include "tracker_config.h" #include "tracker_panel.h" #include "version.h" @@ -58,15 +59,20 @@ TrackerFrame::TrackerFrame() Bind(STATE_CHANGED, &TrackerFrame::OnStateChanged, this); Bind(STATUS_CHANGED, &TrackerFrame::OnStatusChanged, this); - wxChoicebook *choicebook = new wxChoicebook(this, wxID_ANY); achievements_pane_ = new AchievementsPane(this); + + wxChoicebook *choicebook = new wxChoicebook(this, wxID_ANY); choicebook->AddPage(achievements_pane_, "Achievements"); - tracker_panel_ = new TrackerPanel(this); + wxNotebook *rightpane = new wxNotebook(this, wxID_ANY); + tracker_panel_ = new TrackerPanel(rightpane); + subway_map_ = new SubwayMap(rightpane); + rightpane->AddPage(tracker_panel_, "Map"); + rightpane->AddPage(subway_map_, "Subway"); wxBoxSizer *top_sizer = new wxBoxSizer(wxHORIZONTAL); top_sizer->Add(choicebook, wxSizerFlags().Expand().Proportion(1)); - top_sizer->Add(tracker_panel_, wxSizerFlags().Expand().Proportion(3)); + top_sizer->Add(rightpane, wxSizerFlags().Expand().Proportion(3)); SetSizerAndFit(top_sizer); SetSize(1280, 728); @@ -165,6 +171,7 @@ void TrackerFrame::OnCheckForUpdates(wxCommandEvent &event) { void TrackerFrame::OnStateChanged(wxCommandEvent &event) { tracker_panel_->UpdateIndicators(); achievements_pane_->UpdateIndicators(); + subway_map_->UpdateIndicators(); Refresh(); } diff --git a/src/tracker_frame.h b/src/tracker_frame.h index e5bf97e..c7c6772 100644 --- a/src/tracker_frame.h +++ b/src/tracker_frame.h @@ -8,6 +8,7 @@ #endif class AchievementsPane; +class SubwayMap; class TrackerPanel; wxDECLARE_EVENT(STATE_CHANGED, wxCommandEvent); @@ -35,6 +36,7 @@ class TrackerFrame : public wxFrame { TrackerPanel *tracker_panel_; AchievementsPane *achievements_pane_; + SubwayMap *subway_map_; }; #endif /* end of include guard: TRACKER_FRAME_H_86BD8DFB */ diff --git a/src/tracker_state.cpp b/src/tracker_state.cpp index 640a159..5588c7f 100644 --- a/src/tracker_state.cpp +++ b/src/tracker_state.cpp @@ -14,6 +14,7 @@ namespace { struct TrackerState { std::map reachability; + std::set reachable_doors; std::mutex reachability_mutex; }; @@ -156,6 +157,11 @@ class StateCalculator { flood_boundary = new_boundary; panel_boundary = new_panel_boundary; } + + // Now that we know the full reachable area, let's make sure all doors are evaluated. + for (const Door& door : GD_GetDoors()) { + int discard = IsDoorReachable(door.id); + } } const std::set& GetReachableRooms() const { return reachable_rooms_; } @@ -422,9 +428,17 @@ void RecalculateReachability() { } } + std::set new_reachable_doors; + for (const auto& [door_id, decision] : state_calculator.GetDoorDecisions()) { + if (decision == kYes) { + new_reachable_doors.insert(door_id); + } + } + { std::lock_guard reachability_guard(GetState().reachability_mutex); std::swap(GetState().reachability, new_reachability); + std::swap(GetState().reachable_doors, new_reachable_doors); } } @@ -437,3 +451,9 @@ bool IsLocationReachable(int location_id) { return false; } } + +bool IsDoorOpen(int door_id) { + std::lock_guard reachability_guard(GetState().reachability_mutex); + + return GetState().reachable_doors.count(door_id); +} diff --git a/src/tracker_state.h b/src/tracker_state.h index e73607f..119b3b5 100644 --- a/src/tracker_state.h +++ b/src/tracker_state.h @@ -5,4 +5,6 @@ void RecalculateReachability(); bool IsLocationReachable(int location_id); +bool IsDoorOpen(int door_id); + #endif /* end of include guard: TRACKER_STATE_H_8639BC90 */ -- cgit 1.4.1