From 4fa8f5b6c933dcbab5940d39a515937e86e9d280 Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Fri, 7 Mar 2025 22:49:57 -0500 Subject: Added pane that shows painting mapping --- CMakeLists.txt | 1 + src/game_data.cpp | 3 ++- src/game_data.h | 1 + src/paintings_pane.cpp | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++ src/paintings_pane.h | 22 ++++++++++++++++++ src/tracker_frame.cpp | 7 ++++++ src/tracker_frame.h | 2 ++ 7 files changed, 96 insertions(+), 1 deletion(-) create mode 100644 src/paintings_pane.cpp create mode 100644 src/paintings_pane.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 0929cd7..deb6bbd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -55,6 +55,7 @@ set(SOURCE_FILES "src/report_popup.cpp" "src/updater.cpp" "src/icons.cpp" + "src/paintings_pane.cpp" "vendor/whereami/whereami.c" ) diff --git a/src/game_data.cpp b/src/game_data.cpp index a3ac27d..e92e6a2 100644 --- a/src/game_data.cpp +++ b/src/game_data.cpp @@ -723,7 +723,8 @@ struct GameData { MapArea &map_area = map_areas_[area_id]; for (int painting_id : room.paintings) { - const PaintingExit &painting_obj = paintings_.at(painting_id); + PaintingExit &painting_obj = paintings_.at(painting_id); + painting_obj.map_area = area_id; if (painting_obj.entrance) { map_area.paintings.push_back(painting_id); } diff --git a/src/game_data.h b/src/game_data.h index fd7301f..51fbf09 100644 --- a/src/game_data.h +++ b/src/game_data.h @@ -105,6 +105,7 @@ struct PaintingExit { std::string display_name; std::optional door; bool entrance = false; + int map_area; }; struct Room { diff --git a/src/paintings_pane.cpp b/src/paintings_pane.cpp new file mode 100644 index 0000000..352533f --- /dev/null +++ b/src/paintings_pane.cpp @@ -0,0 +1,61 @@ +#include "paintings_pane.h" + +#include +#include + +#include +#include + +#include "ap_state.h" +#include "game_data.h" +#include "tracker_state.h" + +namespace { + +std::string GetPaintingDisplayName(const std::string& id) { + const PaintingExit& painting = GD_GetPaintingExit(GD_GetPaintingByName(id)); + const MapArea& map_area = GD_GetMapArea(painting.map_area); + + return fmt::format("{} - {}", map_area.name, painting.display_name); +} + +} // namespace + +PaintingsPane::PaintingsPane(wxWindow* parent) + : wxPanel(parent, wxID_ANY) { + wxStaticText* label = new wxStaticText(this, wxID_ANY, "Shuffled paintings grouped by destination:"); + tree_ctrl_ = new wxDataViewTreeCtrl(this, wxID_ANY); + + wxBoxSizer* top_sizer = new wxBoxSizer(wxVERTICAL); + top_sizer->Add(label, wxSizerFlags().Border()); + top_sizer->Add(tree_ctrl_, wxSizerFlags().Expand().Proportion(1)); + + SetSizerAndFit(top_sizer); +} + +void PaintingsPane::UpdateIndicators() { + tree_ctrl_->DeleteAllItems(); + + if (!AP_IsPaintingShuffle()) { + return; + } + + std::map> grouped_paintings; + + for (const auto& [from, to] : AP_GetPaintingMapping()) { + if (IsPaintingReachable(GD_GetPaintingByName(from)) && + AP_IsPaintingChecked(from)) { + grouped_paintings[GetPaintingDisplayName(to)].insert( + GetPaintingDisplayName(from)); + } + } + + for (const auto& [to, froms] : grouped_paintings) { + wxDataViewItem tree_branch = + tree_ctrl_->AppendContainer(wxDataViewItem(0), to); + + for (const std::string& from : froms) { + tree_ctrl_->AppendItem(tree_branch, from); + } + } +} diff --git a/src/paintings_pane.h b/src/paintings_pane.h new file mode 100644 index 0000000..f8d3e09 --- /dev/null +++ b/src/paintings_pane.h @@ -0,0 +1,22 @@ +#ifndef PAINTINGS_PANE_H_815370D2 +#define PAINTINGS_PANE_H_815370D2 + +#include + +#ifndef WX_PRECOMP +#include +#endif + +class wxDataViewTreeCtrl; + +class PaintingsPane : public wxPanel { + public: + explicit PaintingsPane(wxWindow* parent); + + void UpdateIndicators(); + + private: + wxDataViewTreeCtrl* tree_ctrl_; +}; + +#endif /* end of include guard: PAINTINGS_PANE_H_815370D2 */ diff --git a/src/tracker_frame.cpp b/src/tracker_frame.cpp index a1bd23e..a697f9a 100644 --- a/src/tracker_frame.cpp +++ b/src/tracker_frame.cpp @@ -17,6 +17,7 @@ #include "connection_dialog.h" #include "ipc_dialog.h" #include "ipc_state.h" +#include "paintings_pane.h" #include "settings_dialog.h" #include "subway_map.h" #include "tracker_config.h" @@ -120,9 +121,13 @@ TrackerFrame::TrackerFrame() splitter_window_->SetMinimumPaneSize(logicalSize.x / 5); wxChoicebook *choicebook = new wxChoicebook(splitter_window_, wxID_ANY); + achievements_pane_ = new AchievementsPane(choicebook); choicebook->AddPage(achievements_pane_, "Achievements"); + paintings_pane_ = new PaintingsPane(choicebook); + choicebook->AddPage(paintings_pane_, "Paintings"); + notebook_ = new wxNotebook(splitter_window_, wxID_ANY); tracker_panel_ = new TrackerPanel(notebook_); subway_map_ = new SubwayMap(notebook_); @@ -299,6 +304,7 @@ void TrackerFrame::OnSashPositionChanged(wxSplitterEvent& event) { void TrackerFrame::OnStateReset(wxCommandEvent &event) { tracker_panel_->UpdateIndicators(); achievements_pane_->UpdateIndicators(); + paintings_pane_->UpdateIndicators(); subway_map_->OnConnect(); if (panels_panel_ != nullptr) { notebook_->DeletePage(notebook_->FindPage(panels_panel_)); @@ -313,6 +319,7 @@ void TrackerFrame::OnStateChanged(wxCommandEvent &event) { if (mode == kUPDATE_ALL_INDICATORS) { tracker_panel_->UpdateIndicators(); achievements_pane_->UpdateIndicators(); + paintings_pane_->UpdateIndicators(); subway_map_->UpdateIndicators(); if (panels_panel_ != nullptr) { panels_panel_->UpdateIndicators(); diff --git a/src/tracker_frame.h b/src/tracker_frame.h index 9aff0a5..4f1f464 100644 --- a/src/tracker_frame.h +++ b/src/tracker_frame.h @@ -13,6 +13,7 @@ #include "updater.h" class AchievementsPane; +class PaintingsPane; class SubwayMap; class TrackerPanel; class wxBookCtrlEvent; @@ -90,6 +91,7 @@ class TrackerFrame : public wxFrame { wxNotebook *notebook_; TrackerPanel *tracker_panel_; AchievementsPane *achievements_pane_; + PaintingsPane *paintings_pane_; SubwayMap *subway_map_; TrackerPanel *panels_panel_ = nullptr; -- cgit 1.4.1