diff options
| author | Star Rauchenberger <fefferburbia@gmail.com> | 2025-03-07 22:49:57 -0500 |
|---|---|---|
| committer | Star Rauchenberger <fefferburbia@gmail.com> | 2025-03-07 22:49:57 -0500 |
| commit | 4fa8f5b6c933dcbab5940d39a515937e86e9d280 (patch) | |
| tree | e61cdd340c79780523ff88e148bb56b5565fe430 /src/paintings_pane.cpp | |
| parent | b06f534cd0023d753932b4932c95da5d4854b804 (diff) | |
| download | lingo-ap-tracker-4fa8f5b6c933dcbab5940d39a515937e86e9d280.tar.gz lingo-ap-tracker-4fa8f5b6c933dcbab5940d39a515937e86e9d280.tar.bz2 lingo-ap-tracker-4fa8f5b6c933dcbab5940d39a515937e86e9d280.zip | |
Added pane that shows painting mapping
Diffstat (limited to 'src/paintings_pane.cpp')
| -rw-r--r-- | src/paintings_pane.cpp | 61 |
1 files changed, 61 insertions, 0 deletions
| 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 @@ | |||
| 1 | #include "paintings_pane.h" | ||
| 2 | |||
| 3 | #include <map> | ||
| 4 | #include <set> | ||
| 5 | |||
| 6 | #include <fmt/core.h> | ||
| 7 | #include <wx/dataview.h> | ||
| 8 | |||
| 9 | #include "ap_state.h" | ||
| 10 | #include "game_data.h" | ||
| 11 | #include "tracker_state.h" | ||
| 12 | |||
| 13 | namespace { | ||
| 14 | |||
| 15 | std::string GetPaintingDisplayName(const std::string& id) { | ||
| 16 | const PaintingExit& painting = GD_GetPaintingExit(GD_GetPaintingByName(id)); | ||
| 17 | const MapArea& map_area = GD_GetMapArea(painting.map_area); | ||
| 18 | |||
| 19 | return fmt::format("{} - {}", map_area.name, painting.display_name); | ||
| 20 | } | ||
| 21 | |||
| 22 | } // namespace | ||
| 23 | |||
| 24 | PaintingsPane::PaintingsPane(wxWindow* parent) | ||
| 25 | : wxPanel(parent, wxID_ANY) { | ||
| 26 | wxStaticText* label = new wxStaticText(this, wxID_ANY, "Shuffled paintings grouped by destination:"); | ||
| 27 | tree_ctrl_ = new wxDataViewTreeCtrl(this, wxID_ANY); | ||
| 28 | |||
| 29 | wxBoxSizer* top_sizer = new wxBoxSizer(wxVERTICAL); | ||
| 30 | top_sizer->Add(label, wxSizerFlags().Border()); | ||
| 31 | top_sizer->Add(tree_ctrl_, wxSizerFlags().Expand().Proportion(1)); | ||
| 32 | |||
| 33 | SetSizerAndFit(top_sizer); | ||
| 34 | } | ||
| 35 | |||
| 36 | void PaintingsPane::UpdateIndicators() { | ||
| 37 | tree_ctrl_->DeleteAllItems(); | ||
| 38 | |||
| 39 | if (!AP_IsPaintingShuffle()) { | ||
| 40 | return; | ||
| 41 | } | ||
| 42 | |||
| 43 | std::map<std::string, std::set<std::string>> grouped_paintings; | ||
| 44 | |||
| 45 | for (const auto& [from, to] : AP_GetPaintingMapping()) { | ||
| 46 | if (IsPaintingReachable(GD_GetPaintingByName(from)) && | ||
| 47 | AP_IsPaintingChecked(from)) { | ||
| 48 | grouped_paintings[GetPaintingDisplayName(to)].insert( | ||
| 49 | GetPaintingDisplayName(from)); | ||
| 50 | } | ||
| 51 | } | ||
| 52 | |||
| 53 | for (const auto& [to, froms] : grouped_paintings) { | ||
| 54 | wxDataViewItem tree_branch = | ||
| 55 | tree_ctrl_->AppendContainer(wxDataViewItem(0), to); | ||
| 56 | |||
| 57 | for (const std::string& from : froms) { | ||
| 58 | tree_ctrl_->AppendItem(tree_branch, from); | ||
| 59 | } | ||
| 60 | } | ||
| 61 | } | ||
