diff options
Diffstat (limited to 'src/subway_map.cpp')
| -rw-r--r-- | src/subway_map.cpp | 77 | 
1 files changed, 50 insertions, 27 deletions
| diff --git a/src/subway_map.cpp b/src/subway_map.cpp index 408c4f0..044e6fa 100644 --- a/src/subway_map.cpp +++ b/src/subway_map.cpp | |||
| @@ -1,5 +1,6 @@ | |||
| 1 | #include "subway_map.h" | 1 | #include "subway_map.h" | 
| 2 | 2 | ||
| 3 | #include <fmt/core.h> | ||
| 3 | #include <wx/dcbuffer.h> | 4 | #include <wx/dcbuffer.h> | 
| 4 | #include <wx/dcgraph.h> | 5 | #include <wx/dcgraph.h> | 
| 5 | 6 | ||
| @@ -15,6 +16,29 @@ constexpr int OWL_ACTUAL_SIZE = 32; | |||
| 15 | 16 | ||
| 16 | enum class ItemDrawType { kNone, kBox, kOwl }; | 17 | enum class ItemDrawType { kNone, kBox, kOwl }; | 
| 17 | 18 | ||
| 19 | namespace { | ||
| 20 | |||
| 21 | std::optional<int> GetRealSubwayDoor(const SubwayItem subway_item) { | ||
| 22 | std::optional<int> subway_door = subway_item.door; | ||
| 23 | if (AP_IsSunwarpShuffle() && subway_item.sunwarp && | ||
| 24 | subway_item.sunwarp->type != SubwaySunwarpType::kFinal) { | ||
| 25 | int sunwarp_index = subway_item.sunwarp->dots - 1; | ||
| 26 | if (subway_item.sunwarp->type == SubwaySunwarpType::kExit) { | ||
| 27 | sunwarp_index += 6; | ||
| 28 | } | ||
| 29 | |||
| 30 | for (const auto &[start_index, mapping] : AP_GetSunwarpMapping()) { | ||
| 31 | if (start_index == sunwarp_index || mapping.exit_index == sunwarp_index) { | ||
| 32 | subway_door = GD_GetSunwarpDoors().at(mapping.dots - 1); | ||
| 33 | } | ||
| 34 | } | ||
| 35 | |||
| 36 | return subway_door; | ||
| 37 | } | ||
| 38 | } | ||
| 39 | |||
| 40 | } // namespace | ||
| 41 | |||
| 18 | SubwayMap::SubwayMap(wxWindow *parent) : wxPanel(parent, wxID_ANY) { | 42 | SubwayMap::SubwayMap(wxWindow *parent) : wxPanel(parent, wxID_ANY) { | 
| 19 | SetBackgroundStyle(wxBG_STYLE_PAINT); | 43 | SetBackgroundStyle(wxBG_STYLE_PAINT); | 
| 20 | 44 | ||
| @@ -70,9 +94,8 @@ void SubwayMap::OnConnect() { | |||
| 70 | std::map<std::string, std::vector<int>> tagged; | 94 | std::map<std::string, std::vector<int>> tagged; | 
| 71 | for (const SubwayItem &subway_item : GD_GetSubwayItems()) { | 95 | for (const SubwayItem &subway_item : GD_GetSubwayItems()) { | 
| 72 | if (AP_HasEarlyColorHallways() && | 96 | if (AP_HasEarlyColorHallways() && | 
| 73 | (subway_item.special == "starting_room_paintings" || | 97 | subway_item.special == "starting_room_paintings") { | 
| 74 | subway_item.special == "early_color_hallways")) { | 98 | tagged["early_ch"].push_back(subway_item.id); | 
| 75 | tagged["early_color_hallways"].push_back(subway_item.id); | ||
| 76 | } | 99 | } | 
| 77 | 100 | ||
| 78 | if (AP_IsPaintingShuffle() && !subway_item.paintings.empty()) { | 101 | if (AP_IsPaintingShuffle() && !subway_item.paintings.empty()) { | 
| @@ -85,10 +108,8 @@ void SubwayMap::OnConnect() { | |||
| 85 | 108 | ||
| 86 | if (!AP_IsSunwarpShuffle() && subway_item.sunwarp && | 109 | if (!AP_IsSunwarpShuffle() && subway_item.sunwarp && | 
| 87 | subway_item.sunwarp->type != SubwaySunwarpType::kFinal) { | 110 | subway_item.sunwarp->type != SubwaySunwarpType::kFinal) { | 
| 88 | std::ostringstream tag; | 111 | std::string tag = fmt::format("subway{}", subway_item.sunwarp->dots); | 
| 89 | tag << "sunwarp" << subway_item.sunwarp->dots; | 112 | tagged[tag].push_back(subway_item.id); | 
| 90 | |||
| 91 | tagged[tag.str()].push_back(subway_item.id); | ||
| 92 | } | 113 | } | 
| 93 | 114 | ||
| 94 | if (!AP_IsPilgrimageEnabled() && | 115 | if (!AP_IsPilgrimageEnabled() && | 
| @@ -100,8 +121,7 @@ void SubwayMap::OnConnect() { | |||
| 100 | 121 | ||
| 101 | if (AP_IsSunwarpShuffle()) { | 122 | if (AP_IsSunwarpShuffle()) { | 
| 102 | for (const auto &[index, mapping] : AP_GetSunwarpMapping()) { | 123 | for (const auto &[index, mapping] : AP_GetSunwarpMapping()) { | 
| 103 | std::ostringstream tag; | 124 | std::string tag = fmt::format("sunwarp{}", mapping.dots); | 
| 104 | tag << "sunwarp" << mapping.dots; | ||
| 105 | 125 | ||
| 106 | SubwaySunwarp fromWarp; | 126 | SubwaySunwarp fromWarp; | 
| 107 | if (index < 6) { | 127 | if (index < 6) { | 
| @@ -121,8 +141,8 @@ void SubwayMap::OnConnect() { | |||
| 121 | toWarp.type = SubwaySunwarpType::kExit; | 141 | toWarp.type = SubwaySunwarpType::kExit; | 
| 122 | } | 142 | } | 
| 123 | 143 | ||
| 124 | tagged[tag.str()].push_back(GD_GetSubwayItemForSunwarp(fromWarp)); | 144 | tagged[tag].push_back(GD_GetSubwayItemForSunwarp(fromWarp)); | 
| 125 | tagged[tag.str()].push_back(GD_GetSubwayItemForSunwarp(toWarp)); | 145 | tagged[tag].push_back(GD_GetSubwayItemForSunwarp(toWarp)); | 
| 126 | } | 146 | } | 
| 127 | } | 147 | } | 
| 128 | 148 | ||
| @@ -147,9 +167,13 @@ void SubwayMap::UpdateIndicators() { | |||
| 147 | checked_paintings_.insert(painting_id); | 167 | checked_paintings_.insert(painting_id); | 
| 148 | 168 | ||
| 149 | if (AP_GetPaintingMapping().count(painting_id)) { | 169 | if (AP_GetPaintingMapping().count(painting_id)) { | 
| 150 | networks_.AddLink(GD_GetSubwayItemForPainting(painting_id), | 170 | std::optional<int> from_id = GD_GetSubwayItemForPainting(painting_id); | 
| 151 | GD_GetSubwayItemForPainting( | 171 | std::optional<int> to_id = GD_GetSubwayItemForPainting( | 
| 152 | AP_GetPaintingMapping().at(painting_id))); | 172 | AP_GetPaintingMapping().at(painting_id)); | 
| 173 | |||
| 174 | if (from_id && to_id) { | ||
| 175 | networks_.AddLink(*from_id, *to_id); | ||
| 176 | } | ||
| 153 | } | 177 | } | 
| 154 | } | 178 | } | 
| 155 | } | 179 | } | 
| @@ -266,9 +290,11 @@ void SubwayMap::OnPaint(wxPaintEvent &event) { | |||
| 266 | // Note that these requirements are duplicated on OnMouseClick so that it | 290 | // Note that these requirements are duplicated on OnMouseClick so that it | 
| 267 | // knows when an item has a hover effect. | 291 | // knows when an item has a hover effect. | 
| 268 | const SubwayItem &subway_item = GD_GetSubwayItem(*hovered_item_); | 292 | const SubwayItem &subway_item = GD_GetSubwayItem(*hovered_item_); | 
| 269 | if (subway_item.door && !GetDoorRequirements(*subway_item.door).empty()) { | 293 | std::optional<int> subway_door = GetRealSubwayDoor(subway_item); | 
| 294 | |||
| 295 | if (subway_door && !GetDoorRequirements(*subway_door).empty()) { | ||
| 270 | const std::map<std::string, bool> &report = | 296 | const std::map<std::string, bool> &report = | 
| 271 | GetDoorRequirements(*subway_item.door); | 297 | GetDoorRequirements(*subway_door); | 
| 272 | 298 | ||
| 273 | int acc_height = 10; | 299 | int acc_height = 10; | 
| 274 | int col_width = 0; | 300 | int col_width = 0; | 
| @@ -404,7 +430,7 @@ void SubwayMap::OnMouseMove(wxMouseEvent &event) { | |||
| 404 | std::vector<int> hovered = tree_->query( | 430 | std::vector<int> hovered = tree_->query( | 
| 405 | {static_cast<float>(mouse_pos.x), static_cast<float>(mouse_pos.y), 2, 2}); | 431 | {static_cast<float>(mouse_pos.x), static_cast<float>(mouse_pos.y), 2, 2}); | 
| 406 | if (!hovered.empty()) { | 432 | if (!hovered.empty()) { | 
| 407 | actual_hover_= hovered[0]; | 433 | actual_hover_ = hovered[0]; | 
| 408 | } else { | 434 | } else { | 
| 409 | actual_hover_ = std::nullopt; | 435 | actual_hover_ = std::nullopt; | 
| 410 | } | 436 | } | 
| @@ -449,7 +475,9 @@ void SubwayMap::OnMouseClick(wxMouseEvent &event) { | |||
| 449 | 475 | ||
| 450 | if (actual_hover_) { | 476 | if (actual_hover_) { | 
| 451 | const SubwayItem &subway_item = GD_GetSubwayItem(*actual_hover_); | 477 | const SubwayItem &subway_item = GD_GetSubwayItem(*actual_hover_); | 
| 452 | if ((subway_item.door && !GetDoorRequirements(*subway_item.door).empty()) || | 478 | std::optional<int> subway_door = GetRealSubwayDoor(subway_item); | 
| 479 | |||
| 480 | if ((subway_door && !GetDoorRequirements(*subway_door).empty()) || | ||
| 453 | networks_.IsItemInNetwork(*hovered_item_)) { | 481 | networks_.IsItemInNetwork(*hovered_item_)) { | 
| 454 | if (actual_hover_ != hovered_item_) { | 482 | if (actual_hover_ != hovered_item_) { | 
| 455 | hovered_item_ = actual_hover_; | 483 | hovered_item_ = actual_hover_; | 
| @@ -530,15 +558,9 @@ void SubwayMap::Redraw() { | |||
| 530 | std::optional<wxColour> shade_color; | 558 | std::optional<wxColour> shade_color; | 
| 531 | 559 | ||
| 532 | if (AP_HasEarlyColorHallways() && | 560 | if (AP_HasEarlyColorHallways() && | 
| 533 | (subway_item.special == "starting_room_paintings" || | 561 | subway_item.special == "starting_room_paintings") { | 
| 534 | subway_item.special == "early_color_hallways")) { | ||
| 535 | draw_type = ItemDrawType::kOwl; | 562 | draw_type = ItemDrawType::kOwl; | 
| 536 | 563 | shade_color = wxColour(0, 255, 0, 128); | |
| 537 | if (subway_item.special == "starting_room_paintings") { | ||
| 538 | shade_color = wxColour(0, 255, 0, 128); | ||
| 539 | } else { | ||
| 540 | shade_color = wxColour(255, 0, 0, 128); | ||
| 541 | } | ||
| 542 | } else if (subway_item.special == "sun_painting") { | 564 | } else if (subway_item.special == "sun_painting") { | 
| 543 | if (!AP_IsPilgrimageEnabled()) { | 565 | if (!AP_IsPilgrimageEnabled()) { | 
| 544 | if (IsDoorOpen(*subway_item.door)) { | 566 | if (IsDoorOpen(*subway_item.door)) { | 
| @@ -570,7 +592,8 @@ void SubwayMap::Redraw() { | |||
| 570 | } | 592 | } | 
| 571 | } | 593 | } | 
| 572 | 594 | ||
| 573 | if (has_unchecked_painting || has_mapped_painting || has_codomain_painting) { | 595 | if (has_unchecked_painting || has_mapped_painting || | 
| 596 | has_codomain_painting) { | ||
| 574 | draw_type = ItemDrawType::kOwl; | 597 | draw_type = ItemDrawType::kOwl; | 
| 575 | 598 | ||
| 576 | if (has_checked_painting) { | 599 | if (has_checked_painting) { | 
