From b84a5401359a442b2dff14599f80d47626290fa1 Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Thu, 6 Jun 2024 14:35:57 -0400 Subject: Shade owls to indicate entrance/exit --- src/ap_state.cpp | 7 +++++++ src/ap_state.h | 2 ++ src/subway_map.cpp | 54 +++++++++++++++++++++++++++++++----------------------- 3 files changed, 40 insertions(+), 23 deletions(-) diff --git a/src/ap_state.cpp b/src/ap_state.cpp index 0c75eae..0ce4582 100644 --- a/src/ap_state.cpp +++ b/src/ap_state.cpp @@ -70,6 +70,7 @@ struct APState { bool sunwarp_shuffle = false; std::map painting_mapping; + std::set painting_codomain; std::map sunwarp_mapping; void Connect(std::string server, std::string player, std::string password) { @@ -137,6 +138,7 @@ struct APState { color_shuffle = false; painting_shuffle = false; painting_mapping.clear(); + painting_codomain.clear(); mastery_requirement = 21; level_2_requirement = 223; location_checks = kNORMAL_LOCATIONS; @@ -253,6 +255,7 @@ struct APState { for (const auto& mapping_it : slot_data["painting_entrance_to_exit"].items()) { painting_mapping[mapping_it.key()] = mapping_it.value(); + painting_codomain.insert(mapping_it.value()); } } @@ -510,6 +513,10 @@ const std::map& AP_GetPaintingMapping() { return GetState().painting_mapping; } +bool AP_IsPaintingMappedTo(const std::string& painting_id) { + return GetState().painting_codomain.count(painting_id); +} + const std::set& AP_GetCheckedPaintings() { return GetState().GetCheckedPaintings(); } diff --git a/src/ap_state.h b/src/ap_state.h index 2769bb8..7af7395 100644 --- a/src/ap_state.h +++ b/src/ap_state.h @@ -59,6 +59,8 @@ bool AP_IsPaintingShuffle(); const std::map& AP_GetPaintingMapping(); +bool AP_IsPaintingMappedTo(const std::string& painting_id); + const std::set& AP_GetCheckedPaintings(); bool AP_IsPaintingChecked(const std::string& painting_id); diff --git a/src/subway_map.cpp b/src/subway_map.cpp index 0beef76..dde817b 100644 --- a/src/subway_map.cpp +++ b/src/subway_map.cpp @@ -457,7 +457,9 @@ void SubwayMap::OnClickHelp(wxCommandEvent &event) { "your mouse. Click again to stop.\nHover over a door to see the " "requirements to open it.\nHover over a warp or active painting to see " "what it is connected to.\nIn painting shuffle, paintings that have not " - "yet been checked will not show their connections.\nClick on a door or " + "yet been checked will not show their connections.\nA green shaded owl " + "means that there is a painting entrance there.\nA red shaded owl means " + "that there are only painting exits there.\nClick on a door or " "warp to make the popup stick until you click again.", "Subway Map Help"); } @@ -468,28 +470,19 @@ void SubwayMap::Redraw() { wxMemoryDC dc; dc.SelectObject(rendered_); + wxGCDC gcdc(dc); + for (const SubwayItem &subway_item : GD_GetSubwayItems()) { ItemDrawType draw_type = ItemDrawType::kNone; const wxBrush *brush_color = wxGREY_BRUSH; std::optional shade_color; - if (subway_item.door) { - draw_type = ItemDrawType::kBox; - - if (IsDoorOpen(*subway_item.door)) { - if (!subway_item.paintings.empty()) { - draw_type = ItemDrawType::kOwl; - } else { - brush_color = wxGREEN_BRUSH; - } - } else { - brush_color = wxRED_BRUSH; - } - } else if (!subway_item.paintings.empty()) { + if (!subway_item.paintings.empty()) { if (AP_IsPaintingShuffle()) { bool has_checked_painting = false; bool has_unchecked_painting = false; bool has_mapped_painting = false; + bool has_codomain_painting = false; for (const std::string &painting_id : subway_item.paintings) { if (checked_paintings_.count(painting_id)) { @@ -497,26 +490,36 @@ void SubwayMap::Redraw() { if (AP_GetPaintingMapping().count(painting_id)) { has_mapped_painting = true; + } else if (AP_IsPaintingMappedTo(painting_id)) { + has_codomain_painting = true; } } else { has_unchecked_painting = true; } } - if (has_unchecked_painting || has_mapped_painting) { + if (has_unchecked_painting || has_mapped_painting || has_codomain_painting) { draw_type = ItemDrawType::kOwl; - if (has_unchecked_painting) { - if (has_checked_painting) { - shade_color = wxColour(255, 255, 0, 100); + if (has_checked_painting) { + if (has_mapped_painting) { + shade_color = wxColour(0, 255, 0, 128); } else { - shade_color = wxColour(100, 100, 100, 100); + shade_color = wxColour(255, 0, 0, 128); } } } } else if (!subway_item.tags.empty()) { draw_type = ItemDrawType::kOwl; } + } else if (subway_item.door) { + draw_type = ItemDrawType::kBox; + + if (IsDoorOpen(*subway_item.door)) { + brush_color = wxGREEN_BRUSH; + } else { + brush_color = wxRED_BRUSH; + } } wxPoint real_area_pos = {subway_item.x, subway_item.y}; @@ -525,13 +528,18 @@ void SubwayMap::Redraw() { (draw_type == ItemDrawType::kOwl ? OWL_ACTUAL_SIZE : AREA_ACTUAL_SIZE); if (draw_type == ItemDrawType::kBox) { - dc.SetPen(*wxThePenList->FindOrCreatePen(*wxBLACK, 1)); - dc.SetBrush(*brush_color); - dc.DrawRectangle(real_area_pos, {real_area_size, real_area_size}); + gcdc.SetPen(*wxThePenList->FindOrCreatePen(*wxBLACK, 1)); + gcdc.SetBrush(*brush_color); + gcdc.DrawRectangle(real_area_pos, {real_area_size, real_area_size}); } else if (draw_type == ItemDrawType::kOwl) { wxBitmap owl_bitmap = wxBitmap(owl_image_.Scale( real_area_size, real_area_size, wxIMAGE_QUALITY_BILINEAR)); - dc.DrawBitmap(owl_bitmap, real_area_pos); + gcdc.DrawBitmap(owl_bitmap, real_area_pos); + + if (shade_color) { + gcdc.SetBrush(wxBrush(*shade_color)); + gcdc.DrawRectangle(real_area_pos, {real_area_size, real_area_size}); + } } } } -- cgit 1.4.1