From 5fe5bec92e86a4a94cddefec51fabc22212b7364 Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Sat, 8 Mar 2025 09:33:06 -0500 Subject: Added button to reveal paintings --- src/ap_state.cpp | 18 ++++++++++++++++++ src/ap_state.h | 2 ++ src/game_data.cpp | 4 ++++ src/game_data.h | 1 + src/paintings_pane.cpp | 33 +++++++++++++++++++++++++++------ src/paintings_pane.h | 3 +++ 6 files changed, 55 insertions(+), 6 deletions(-) diff --git a/src/ap_state.cpp b/src/ap_state.cpp index cbe622a..29e649f 100644 --- a/src/ap_state.cpp +++ b/src/ap_state.cpp @@ -245,6 +245,22 @@ struct APState { std::string GetItemName(int id) { return apclient->get_item_name(id); } + void RevealPaintings() { + std::lock_guard state_guard(state_mutex); + + std::vector paintings; + for (const PaintingExit& painting : GD_GetPaintings()) { + paintings.push_back(painting.internal_id); + } + + APClient::DataStorageOperation operation; + operation.operation = "replace"; + operation.value = paintings; + + apclient->Set(fmt::format("{}Paintings", data_storage_prefix), "", true, + {operation}); + } + bool HasReachedGoal() { std::lock_guard state_guard(state_mutex); @@ -713,6 +729,8 @@ bool AP_IsPaintingChecked(const std::string& painting_id) { return GetState().IsPaintingChecked(painting_id); } +void AP_RevealPaintings() { GetState().RevealPaintings(); } + int AP_GetMasteryRequirement() { std::lock_guard state_guard(GetState().state_mutex); diff --git a/src/ap_state.h b/src/ap_state.h index e2ff22b..4de7689 100644 --- a/src/ap_state.h +++ b/src/ap_state.h @@ -76,6 +76,8 @@ std::set AP_GetCheckedPaintings(); bool AP_IsPaintingChecked(const std::string& painting_id); +void AP_RevealPaintings(); + int AP_GetMasteryRequirement(); int AP_GetLevel2Requirement(); diff --git a/src/game_data.cpp b/src/game_data.cpp index 5fbd244..54b25b4 100644 --- a/src/game_data.cpp +++ b/src/game_data.cpp @@ -963,6 +963,10 @@ const Panel &GD_GetPanel(int panel_id) { return GetState().panels_.at(panel_id); } +const std::vector &GD_GetPaintings() { + return GetState().paintings_; +} + const PaintingExit &GD_GetPaintingExit(int painting_id) { return GetState().paintings_.at(painting_id); } diff --git a/src/game_data.h b/src/game_data.h index 51fbf09..b087734 100644 --- a/src/game_data.h +++ b/src/game_data.h @@ -176,6 +176,7 @@ const Door& GD_GetDoor(int door_id); int GD_GetDoorByName(const std::string& name); const Panel& GD_GetPanel(int panel_id); const PanelDoor& GD_GetPanelDoor(int panel_door_id); +const std::vector& GD_GetPaintings(); const PaintingExit& GD_GetPaintingExit(int painting_id); int GD_GetPaintingByName(const std::string& name); const std::vector& GD_GetAchievementPanels(); diff --git a/src/paintings_pane.cpp b/src/paintings_pane.cpp index 352533f..dc6f050 100644 --- a/src/paintings_pane.cpp +++ b/src/paintings_pane.cpp @@ -1,11 +1,11 @@ #include "paintings_pane.h" -#include -#include - #include #include +#include +#include + #include "ap_state.h" #include "game_data.h" #include "tracker_state.h" @@ -21,25 +21,34 @@ std::string GetPaintingDisplayName(const std::string& id) { } // namespace -PaintingsPane::PaintingsPane(wxWindow* parent) - : wxPanel(parent, wxID_ANY) { - wxStaticText* label = new wxStaticText(this, wxID_ANY, "Shuffled paintings grouped by destination:"); +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::UpdateIndicators() { tree_ctrl_->DeleteAllItems(); if (!AP_IsPaintingShuffle()) { + reveal_btn_->Disable(); return; } + reveal_btn_->Enable(); + std::map> grouped_paintings; for (const auto& [from, to] : AP_GetPaintingMapping()) { @@ -59,3 +68,15 @@ void PaintingsPane::UpdateIndicators() { } } } + +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(); +} diff --git a/src/paintings_pane.h b/src/paintings_pane.h index f8d3e09..4c7856f 100644 --- a/src/paintings_pane.h +++ b/src/paintings_pane.h @@ -16,7 +16,10 @@ class PaintingsPane : public wxPanel { void UpdateIndicators(); private: + void OnClickRevealPaintings(wxCommandEvent& event); + wxDataViewTreeCtrl* tree_ctrl_; + wxButton* reveal_btn_; }; #endif /* end of include guard: PAINTINGS_PANE_H_815370D2 */ -- cgit 1.4.1