From 738d970d26794db8bb3dcf459c4a787b624910ba Mon Sep 17 00:00:00 2001 From: art0007i Date: Tue, 24 Sep 2024 15:11:32 +0200 Subject: make paintings 1 directional and add "arrows" the "arrows" are circles because I couldn't figure out how to use the DrawPolygon function... --- src/subway_map.cpp | 80 ++++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 60 insertions(+), 20 deletions(-) (limited to 'src/subway_map.cpp') 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() { networks_.Clear(); std::map> tagged; + std::map> entrances; + std::map> exits; for (const SubwayItem &subway_item : GD_GetSubwayItems()) { if (AP_HasEarlyColorHallways() && subway_item.special == "starting_room_paintings") { - tagged["early_ch"].push_back(subway_item.id); + entrances["early_ch"].push_back(subway_item.id); } if (AP_IsPaintingShuffle() && !subway_item.paintings.empty()) { @@ -104,17 +106,33 @@ void SubwayMap::OnConnect() { for (const std::string &tag : subway_item.tags) { tagged[tag].push_back(subway_item.id); } + for (const std::string &tag : subway_item.entrances) { + entrances[tag].push_back(subway_item.id); + } + for (const std::string &tag : subway_item.exits) { + exits[tag].push_back(subway_item.id); + } - if (!AP_IsSunwarpShuffle() && subway_item.sunwarp && - subway_item.sunwarp->type != SubwaySunwarpType::kFinal) { + if (!AP_IsSunwarpShuffle() && subway_item.sunwarp) { std::string tag = fmt::format("sunwarp{}", subway_item.sunwarp->dots); - tagged[tag].push_back(subway_item.id); + switch (subway_item.sunwarp->type) { + case SubwaySunwarpType::kEnter: + entrances[tag].push_back(subway_item.id); + break; + case SubwaySunwarpType::kExit: + exits[tag].push_back(subway_item.id); + break; + default: + break; + } } - if (!AP_IsPilgrimageEnabled() && - (subway_item.special == "sun_painting" || - subway_item.special == "sun_painting_exit")) { - tagged["sun_painting"].push_back(subway_item.id); + if (!AP_IsPilgrimageEnabled()) { + if (subway_item.special == "sun_painting") { + entrances["sun_painting"].push_back(subway_item.id); + } else if (subway_item.special == "sun_painting_exit") { + exits["sun_painting"].push_back(subway_item.id); + } } } @@ -143,13 +161,14 @@ void SubwayMap::OnConnect() { toWarp.type = SubwaySunwarpType::kExit; } - tagged[tag].push_back(GD_GetSubwayItemForSunwarp(fromWarp)); - tagged[tag].push_back(GD_GetSubwayItemForSunwarp(toWarp)); - + entrances[tag].push_back(GD_GetSubwayItemForSunwarp(fromWarp)); + exits[tag].push_back(GD_GetSubwayItemForSunwarp(toWarp)); + networks_.AddLinkToNetwork( final_sunwarp_item, GD_GetSubwayItemForSunwarp(fromWarp), mapping.dots == 6 ? final_sunwarp_item - : GD_GetSubwayItemForSunwarp(toWarp)); + : GD_GetSubwayItemForSunwarp(toWarp), + false); } } @@ -159,7 +178,17 @@ void SubwayMap::OnConnect() { tag_it1++) { for (auto tag_it2 = std::next(tag_it1); tag_it2 != items.end(); tag_it2++) { - networks_.AddLink(*tag_it1, *tag_it2); + // two links because tags are bi-directional + networks_.AddLink(*tag_it1, *tag_it2, true); + } + } + } + + for (const auto &[tag, items] : entrances) { + if (!exits.contains(tag)) continue; + for (auto exit : exits[tag]) { + for (auto entrance : items) { + networks_.AddLink(entrance, exit, false); } } } @@ -179,7 +208,7 @@ void SubwayMap::UpdateIndicators() { AP_GetPaintingMapping().at(painting_id)); if (from_id && to_id) { - networks_.AddLink(*from_id, *to_id); + networks_.AddLink(*from_id, *to_id, false); } } } @@ -192,7 +221,7 @@ void SubwayMap::UpdateIndicators() { void SubwayMap::UpdateSunwarp(SubwaySunwarp from_sunwarp, SubwaySunwarp to_sunwarp) { networks_.AddLink(GD_GetSubwayItemForSunwarp(from_sunwarp), - GD_GetSubwayItemForSunwarp(to_sunwarp)); + GD_GetSubwayItemForSunwarp(to_sunwarp), false); } void SubwayMap::Zoom(bool in) { @@ -358,10 +387,9 @@ void SubwayMap::OnPaint(wxPaintEvent &event) { if (networks_.IsItemInNetwork(*hovered_item_)) { dc.SetBrush(*wxTRANSPARENT_BRUSH); - for (const auto &[item_id1, item_id2] : - networks_.GetNetworkGraph(*hovered_item_)) { - const SubwayItem &item1 = GD_GetSubwayItem(item_id1); - const SubwayItem &item2 = GD_GetSubwayItem(item_id2); + for (const auto node : networks_.GetNetworkGraph(*hovered_item_)) { + const SubwayItem &item1 = GD_GetSubwayItem(node.entry); + const SubwayItem &item2 = GD_GetSubwayItem(node.exit); wxPoint item1_pos = MapPosToRenderPos( {item1.x + AREA_ACTUAL_SIZE / 2, item1.y + AREA_ACTUAL_SIZE / 2}); @@ -381,6 +409,12 @@ void SubwayMap::OnPaint(wxPaintEvent &event) { dc.DrawLine(item1_pos, item2_pos); dc.SetPen(*wxThePenList->FindOrCreatePen(*wxCYAN, 2)); dc.DrawLine(item1_pos, item2_pos); + if (!node.two_way) { + dc.SetPen(*wxThePenList->FindOrCreatePen(*wxBLACK, 2)); + dc.SetBrush(*wxCYAN_BRUSH); + dc.DrawCircle(item2_pos, 4); + dc.SetBrush(*wxTRANSPARENT_BRUSH); + } } else { int ellipse_x; int ellipse_y; @@ -423,6 +457,12 @@ void SubwayMap::OnPaint(wxPaintEvent &event) { dc.SetPen(*wxThePenList->FindOrCreatePen(*wxCYAN, 2)); dc.DrawEllipticArc(ellipse_x, ellipse_y, halfwidth * 2, halfheight * 2, start, end); + if (!node.two_way) { + dc.SetPen(*wxThePenList->FindOrCreatePen(*wxBLACK, 2)); + dc.SetBrush(*wxCYAN_BRUSH); + dc.DrawCircle(item2_pos, 4); + dc.SetBrush(*wxTRANSPARENT_BRUSH); + } } } } @@ -622,7 +662,7 @@ void SubwayMap::Redraw() { } } } - } else if (!subway_item.tags.empty()) { + } else if (subway_item.HasWarps()) { draw_type = ItemDrawType::kOwl; } } else if (subway_door) { -- cgit 1.4.1