#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); reveal_btn_ = new wxButton(this, wxID_ANY, "Reveal shuffled paintings"); reveal_btn_->Disable(); wxBoxSizer* top_sizer = new wxBoxSizer(wxVERTICAL); top_sizer->Add(label, wxSizerFlags().Border()); top_sizer->Add(tree_ctrl_, wxSizerFlags().Expand().Proportion(1)); top_sizer->Add(reveal_btn_, wxSizerFlags().Border().Expand()); SetSizerAndFit(top_sizer); reveal_btn_->Bind(wxEVT_BUTTON, &PaintingsPane::OnClickRevealPaintings, this); } void PaintingsPane::ResetIndicators() { tree_ctrl_->DeleteAllItems(); reveal_btn_->Enable(AP_IsPaintingShuffle()); } void PaintingsPane::UpdateIndicators(const std::vector&) { // TODO: Optimize this by using the paintings delta. tree_ctrl_->DeleteAllItems(); 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); } } } void PaintingsPane::OnClickRevealPaintings(wxCommandEvent& event) { if (wxMessageBox("Clicking yes will reveal the mapping between all shuffled " "paintings. This is usually considered a spoiler, and is " "likely not allowed during competitions. This action is not " "reversible. Are you sure you want to proceed?", "Warning", wxYES_NO | wxICON_WARNING) == wxNO) { return; } AP_RevealPaintings(); }