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 --- src/paintings_pane.cpp | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 src/paintings_pane.cpp (limited to 'src/paintings_pane.cpp') 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); + } + } +} -- cgit 1.4.1