diff options
Diffstat (limited to 'src/subway_map.cpp')
-rw-r--r-- | src/subway_map.cpp | 80 |
1 files changed, 60 insertions, 20 deletions
diff --git a/src/subway_map.cpp b/src/subway_map.cpp index 5b3ff5f..44f754f 100644 --- a/src/subway_map.cpp +++ b/src/subway_map.cpp | |||
@@ -91,10 +91,12 @@ void SubwayMap::OnConnect() { | |||
91 | networks_.Clear(); | 91 | networks_.Clear(); |
92 | 92 | ||
93 | std::map<std::string, std::vector<int>> tagged; | 93 | std::map<std::string, std::vector<int>> tagged; |
94 | std::map<std::string, std::vector<int>> entrances; | ||
95 | std::map<std::string, std::vector<int>> exits; | ||
94 | for (const SubwayItem &subway_item : GD_GetSubwayItems()) { | 96 | for (const SubwayItem &subway_item : GD_GetSubwayItems()) { |
95 | if (AP_HasEarlyColorHallways() && | 97 | if (AP_HasEarlyColorHallways() && |
96 | subway_item.special == "starting_room_paintings") { | 98 | subway_item.special == "starting_room_paintings") { |
97 | tagged["early_ch"].push_back(subway_item.id); | 99 | entrances["early_ch"].push_back(subway_item.id); |
98 | } | 100 | } |
99 | 101 | ||
100 | if (AP_IsPaintingShuffle() && !subway_item.paintings.empty()) { | 102 | if (AP_IsPaintingShuffle() && !subway_item.paintings.empty()) { |
@@ -104,17 +106,33 @@ void SubwayMap::OnConnect() { | |||
104 | for (const std::string &tag : subway_item.tags) { | 106 | for (const std::string &tag : subway_item.tags) { |
105 | tagged[tag].push_back(subway_item.id); | 107 | tagged[tag].push_back(subway_item.id); |
106 | } | 108 | } |
109 | for (const std::string &tag : subway_item.entrances) { | ||
110 | entrances[tag].push_back(subway_item.id); | ||
111 | } | ||
112 | for (const std::string &tag : subway_item.exits) { | ||
113 | exits[tag].push_back(subway_item.id); | ||
114 | } | ||
107 | 115 | ||
108 | if (!AP_IsSunwarpShuffle() && subway_item.sunwarp && | 116 | if (!AP_IsSunwarpShuffle() && subway_item.sunwarp) { |
109 | subway_item.sunwarp->type != SubwaySunwarpType::kFinal) { | ||
110 | std::string tag = fmt::format("sunwarp{}", subway_item.sunwarp->dots); | 117 | std::string tag = fmt::format("sunwarp{}", subway_item.sunwarp->dots); |
111 | tagged[tag].push_back(subway_item.id); | 118 | switch (subway_item.sunwarp->type) { |
119 | case SubwaySunwarpType::kEnter: | ||
120 | entrances[tag].push_back(subway_item.id); | ||
121 | break; | ||
122 | case SubwaySunwarpType::kExit: | ||
123 | exits[tag].push_back(subway_item.id); | ||
124 | break; | ||
125 | default: | ||
126 | break; | ||
127 | } | ||
112 | } | 128 | } |
113 | 129 | ||
114 | if (!AP_IsPilgrimageEnabled() && | 130 | if (!AP_IsPilgrimageEnabled()) { |
115 | (subway_item.special == "sun_painting" || | 131 | if (subway_item.special == "sun_painting") { |
116 | subway_item.special == "sun_painting_exit")) { | 132 | entrances["sun_painting"].push_back(subway_item.id); |
117 | tagged["sun_painting"].push_back(subway_item.id); | 133 | } else if (subway_item.special == "sun_painting_exit") { |
134 | exits["sun_painting"].push_back(subway_item.id); | ||
135 | } | ||
118 | } | 136 | } |
119 | } | 137 | } |
120 | 138 | ||
@@ -143,13 +161,14 @@ void SubwayMap::OnConnect() { | |||
143 | toWarp.type = SubwaySunwarpType::kExit; | 161 | toWarp.type = SubwaySunwarpType::kExit; |
144 | } | 162 | } |
145 | 163 | ||
146 | tagged[tag].push_back(GD_GetSubwayItemForSunwarp(fromWarp)); | 164 | entrances[tag].push_back(GD_GetSubwayItemForSunwarp(fromWarp)); |
147 | tagged[tag].push_back(GD_GetSubwayItemForSunwarp(toWarp)); | 165 | exits[tag].push_back(GD_GetSubwayItemForSunwarp(toWarp)); |
148 | 166 | ||
149 | networks_.AddLinkToNetwork( | 167 | networks_.AddLinkToNetwork( |
150 | final_sunwarp_item, GD_GetSubwayItemForSunwarp(fromWarp), | 168 | final_sunwarp_item, GD_GetSubwayItemForSunwarp(fromWarp), |
151 | mapping.dots == 6 ? final_sunwarp_item | 169 | mapping.dots == 6 ? final_sunwarp_item |
152 | : GD_GetSubwayItemForSunwarp(toWarp)); | 170 | : GD_GetSubwayItemForSunwarp(toWarp), |
171 | false); | ||
153 | } | 172 | } |
154 | } | 173 | } |
155 | 174 | ||
@@ -159,7 +178,17 @@ void SubwayMap::OnConnect() { | |||
159 | tag_it1++) { | 178 | tag_it1++) { |
160 | for (auto tag_it2 = std::next(tag_it1); tag_it2 != items.end(); | 179 | for (auto tag_it2 = std::next(tag_it1); tag_it2 != items.end(); |
161 | tag_it2++) { | 180 | tag_it2++) { |
162 | networks_.AddLink(*tag_it1, *tag_it2); | 181 | // two links because tags are bi-directional |
182 | networks_.AddLink(*tag_it1, *tag_it2, true); | ||
183 | } | ||
184 | } | ||
185 | } | ||
186 | |||
187 | for (const auto &[tag, items] : entrances) { | ||
188 | if (!exits.contains(tag)) continue; | ||
189 | for (auto exit : exits[tag]) { | ||
190 | for (auto entrance : items) { | ||
191 | networks_.AddLink(entrance, exit, false); | ||
163 | } | 192 | } |
164 | } | 193 | } |
165 | } | 194 | } |
@@ -179,7 +208,7 @@ void SubwayMap::UpdateIndicators() { | |||
179 | AP_GetPaintingMapping().at(painting_id)); | 208 | AP_GetPaintingMapping().at(painting_id)); |
180 | 209 | ||
181 | if (from_id && to_id) { | 210 | if (from_id && to_id) { |
182 | networks_.AddLink(*from_id, *to_id); | 211 | networks_.AddLink(*from_id, *to_id, false); |
183 | } | 212 | } |
184 | } | 213 | } |
185 | } | 214 | } |
@@ -192,7 +221,7 @@ void SubwayMap::UpdateIndicators() { | |||
192 | void SubwayMap::UpdateSunwarp(SubwaySunwarp from_sunwarp, | 221 | void SubwayMap::UpdateSunwarp(SubwaySunwarp from_sunwarp, |
193 | SubwaySunwarp to_sunwarp) { | 222 | SubwaySunwarp to_sunwarp) { |
194 | networks_.AddLink(GD_GetSubwayItemForSunwarp(from_sunwarp), | 223 | networks_.AddLink(GD_GetSubwayItemForSunwarp(from_sunwarp), |
195 | GD_GetSubwayItemForSunwarp(to_sunwarp)); | 224 | GD_GetSubwayItemForSunwarp(to_sunwarp), false); |
196 | } | 225 | } |
197 | 226 | ||
198 | void SubwayMap::Zoom(bool in) { | 227 | void SubwayMap::Zoom(bool in) { |
@@ -358,10 +387,9 @@ void SubwayMap::OnPaint(wxPaintEvent &event) { | |||
358 | if (networks_.IsItemInNetwork(*hovered_item_)) { | 387 | if (networks_.IsItemInNetwork(*hovered_item_)) { |
359 | dc.SetBrush(*wxTRANSPARENT_BRUSH); | 388 | dc.SetBrush(*wxTRANSPARENT_BRUSH); |
360 | 389 | ||
361 | for (const auto &[item_id1, item_id2] : | 390 | for (const auto node : networks_.GetNetworkGraph(*hovered_item_)) { |
362 | networks_.GetNetworkGraph(*hovered_item_)) { | 391 | const SubwayItem &item1 = GD_GetSubwayItem(node.entry); |
363 | const SubwayItem &item1 = GD_GetSubwayItem(item_id1); | 392 | const SubwayItem &item2 = GD_GetSubwayItem(node.exit); |
364 | const SubwayItem &item2 = GD_GetSubwayItem(item_id2); | ||
365 | 393 | ||
366 | wxPoint item1_pos = MapPosToRenderPos( | 394 | wxPoint item1_pos = MapPosToRenderPos( |
367 | {item1.x + AREA_ACTUAL_SIZE / 2, item1.y + AREA_ACTUAL_SIZE / 2}); | 395 | {item1.x + AREA_ACTUAL_SIZE / 2, item1.y + AREA_ACTUAL_SIZE / 2}); |
@@ -381,6 +409,12 @@ void SubwayMap::OnPaint(wxPaintEvent &event) { | |||
381 | dc.DrawLine(item1_pos, item2_pos); | 409 | dc.DrawLine(item1_pos, item2_pos); |
382 | dc.SetPen(*wxThePenList->FindOrCreatePen(*wxCYAN, 2)); | 410 | dc.SetPen(*wxThePenList->FindOrCreatePen(*wxCYAN, 2)); |
383 | dc.DrawLine(item1_pos, item2_pos); | 411 | dc.DrawLine(item1_pos, item2_pos); |
412 | if (!node.two_way) { | ||
413 | dc.SetPen(*wxThePenList->FindOrCreatePen(*wxBLACK, 2)); | ||
414 | dc.SetBrush(*wxCYAN_BRUSH); | ||
415 | dc.DrawCircle(item2_pos, 4); | ||
416 | dc.SetBrush(*wxTRANSPARENT_BRUSH); | ||
417 | } | ||
384 | } else { | 418 | } else { |
385 | int ellipse_x; | 419 | int ellipse_x; |
386 | int ellipse_y; | 420 | int ellipse_y; |
@@ -423,6 +457,12 @@ void SubwayMap::OnPaint(wxPaintEvent &event) { | |||
423 | dc.SetPen(*wxThePenList->FindOrCreatePen(*wxCYAN, 2)); | 457 | dc.SetPen(*wxThePenList->FindOrCreatePen(*wxCYAN, 2)); |
424 | dc.DrawEllipticArc(ellipse_x, ellipse_y, halfwidth * 2, | 458 | dc.DrawEllipticArc(ellipse_x, ellipse_y, halfwidth * 2, |
425 | halfheight * 2, start, end); | 459 | halfheight * 2, start, end); |
460 | if (!node.two_way) { | ||
461 | dc.SetPen(*wxThePenList->FindOrCreatePen(*wxBLACK, 2)); | ||
462 | dc.SetBrush(*wxCYAN_BRUSH); | ||
463 | dc.DrawCircle(item2_pos, 4); | ||
464 | dc.SetBrush(*wxTRANSPARENT_BRUSH); | ||
465 | } | ||
426 | } | 466 | } |
427 | } | 467 | } |
428 | } | 468 | } |
@@ -622,7 +662,7 @@ void SubwayMap::Redraw() { | |||
622 | } | 662 | } |
623 | } | 663 | } |
624 | } | 664 | } |
625 | } else if (!subway_item.tags.empty()) { | 665 | } else if (subway_item.HasWarps()) { |
626 | draw_type = ItemDrawType::kOwl; | 666 | draw_type = ItemDrawType::kOwl; |
627 | } | 667 | } |
628 | } else if (subway_door) { | 668 | } else if (subway_door) { |