diff options
-rw-r--r-- | src/ap_state.cpp | 18 | ||||
-rw-r--r-- | src/ap_state.h | 2 | ||||
-rw-r--r-- | src/game_data.cpp | 4 | ||||
-rw-r--r-- | src/game_data.h | 1 | ||||
-rw-r--r-- | src/paintings_pane.cpp | 33 | ||||
-rw-r--r-- | 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 { | |||
245 | 245 | ||
246 | std::string GetItemName(int id) { return apclient->get_item_name(id); } | 246 | std::string GetItemName(int id) { return apclient->get_item_name(id); } |
247 | 247 | ||
248 | void RevealPaintings() { | ||
249 | std::lock_guard state_guard(state_mutex); | ||
250 | |||
251 | std::vector<std::string> paintings; | ||
252 | for (const PaintingExit& painting : GD_GetPaintings()) { | ||
253 | paintings.push_back(painting.internal_id); | ||
254 | } | ||
255 | |||
256 | APClient::DataStorageOperation operation; | ||
257 | operation.operation = "replace"; | ||
258 | operation.value = paintings; | ||
259 | |||
260 | apclient->Set(fmt::format("{}Paintings", data_storage_prefix), "", true, | ||
261 | {operation}); | ||
262 | } | ||
263 | |||
248 | bool HasReachedGoal() { | 264 | bool HasReachedGoal() { |
249 | std::lock_guard state_guard(state_mutex); | 265 | std::lock_guard state_guard(state_mutex); |
250 | 266 | ||
@@ -713,6 +729,8 @@ bool AP_IsPaintingChecked(const std::string& painting_id) { | |||
713 | return GetState().IsPaintingChecked(painting_id); | 729 | return GetState().IsPaintingChecked(painting_id); |
714 | } | 730 | } |
715 | 731 | ||
732 | void AP_RevealPaintings() { GetState().RevealPaintings(); } | ||
733 | |||
716 | int AP_GetMasteryRequirement() { | 734 | int AP_GetMasteryRequirement() { |
717 | std::lock_guard state_guard(GetState().state_mutex); | 735 | std::lock_guard state_guard(GetState().state_mutex); |
718 | 736 | ||
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<std::string> AP_GetCheckedPaintings(); | |||
76 | 76 | ||
77 | bool AP_IsPaintingChecked(const std::string& painting_id); | 77 | bool AP_IsPaintingChecked(const std::string& painting_id); |
78 | 78 | ||
79 | void AP_RevealPaintings(); | ||
80 | |||
79 | int AP_GetMasteryRequirement(); | 81 | int AP_GetMasteryRequirement(); |
80 | 82 | ||
81 | int AP_GetLevel2Requirement(); | 83 | 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) { | |||
963 | return GetState().panels_.at(panel_id); | 963 | return GetState().panels_.at(panel_id); |
964 | } | 964 | } |
965 | 965 | ||
966 | const std::vector<PaintingExit> &GD_GetPaintings() { | ||
967 | return GetState().paintings_; | ||
968 | } | ||
969 | |||
966 | const PaintingExit &GD_GetPaintingExit(int painting_id) { | 970 | const PaintingExit &GD_GetPaintingExit(int painting_id) { |
967 | return GetState().paintings_.at(painting_id); | 971 | return GetState().paintings_.at(painting_id); |
968 | } | 972 | } |
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); | |||
176 | int GD_GetDoorByName(const std::string& name); | 176 | int GD_GetDoorByName(const std::string& name); |
177 | const Panel& GD_GetPanel(int panel_id); | 177 | const Panel& GD_GetPanel(int panel_id); |
178 | const PanelDoor& GD_GetPanelDoor(int panel_door_id); | 178 | const PanelDoor& GD_GetPanelDoor(int panel_door_id); |
179 | const std::vector<PaintingExit>& GD_GetPaintings(); | ||
179 | const PaintingExit& GD_GetPaintingExit(int painting_id); | 180 | const PaintingExit& GD_GetPaintingExit(int painting_id); |
180 | int GD_GetPaintingByName(const std::string& name); | 181 | int GD_GetPaintingByName(const std::string& name); |
181 | const std::vector<int>& GD_GetAchievementPanels(); | 182 | const std::vector<int>& 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 @@ | |||
1 | #include "paintings_pane.h" | 1 | #include "paintings_pane.h" |
2 | 2 | ||
3 | #include <map> | ||
4 | #include <set> | ||
5 | |||
6 | #include <fmt/core.h> | 3 | #include <fmt/core.h> |
7 | #include <wx/dataview.h> | 4 | #include <wx/dataview.h> |
8 | 5 | ||
6 | #include <map> | ||
7 | #include <set> | ||
8 | |||
9 | #include "ap_state.h" | 9 | #include "ap_state.h" |
10 | #include "game_data.h" | 10 | #include "game_data.h" |
11 | #include "tracker_state.h" | 11 | #include "tracker_state.h" |
@@ -21,25 +21,34 @@ std::string GetPaintingDisplayName(const std::string& id) { | |||
21 | 21 | ||
22 | } // namespace | 22 | } // namespace |
23 | 23 | ||
24 | PaintingsPane::PaintingsPane(wxWindow* parent) | 24 | PaintingsPane::PaintingsPane(wxWindow* parent) : wxPanel(parent, wxID_ANY) { |
25 | : wxPanel(parent, wxID_ANY) { | 25 | wxStaticText* label = new wxStaticText( |
26 | wxStaticText* label = new wxStaticText(this, wxID_ANY, "Shuffled paintings grouped by destination:"); | 26 | this, wxID_ANY, "Shuffled paintings grouped by destination:"); |
27 | tree_ctrl_ = new wxDataViewTreeCtrl(this, wxID_ANY); | 27 | tree_ctrl_ = new wxDataViewTreeCtrl(this, wxID_ANY); |
28 | 28 | ||
29 | reveal_btn_ = new wxButton(this, wxID_ANY, "Reveal shuffled paintings"); | ||
30 | reveal_btn_->Disable(); | ||
31 | |||
29 | wxBoxSizer* top_sizer = new wxBoxSizer(wxVERTICAL); | 32 | wxBoxSizer* top_sizer = new wxBoxSizer(wxVERTICAL); |
30 | top_sizer->Add(label, wxSizerFlags().Border()); | 33 | top_sizer->Add(label, wxSizerFlags().Border()); |
31 | top_sizer->Add(tree_ctrl_, wxSizerFlags().Expand().Proportion(1)); | 34 | top_sizer->Add(tree_ctrl_, wxSizerFlags().Expand().Proportion(1)); |
35 | top_sizer->Add(reveal_btn_, wxSizerFlags().Border().Expand()); | ||
32 | 36 | ||
33 | SetSizerAndFit(top_sizer); | 37 | SetSizerAndFit(top_sizer); |
38 | |||
39 | reveal_btn_->Bind(wxEVT_BUTTON, &PaintingsPane::OnClickRevealPaintings, this); | ||
34 | } | 40 | } |
35 | 41 | ||
36 | void PaintingsPane::UpdateIndicators() { | 42 | void PaintingsPane::UpdateIndicators() { |
37 | tree_ctrl_->DeleteAllItems(); | 43 | tree_ctrl_->DeleteAllItems(); |
38 | 44 | ||
39 | if (!AP_IsPaintingShuffle()) { | 45 | if (!AP_IsPaintingShuffle()) { |
46 | reveal_btn_->Disable(); | ||
40 | return; | 47 | return; |
41 | } | 48 | } |
42 | 49 | ||
50 | reveal_btn_->Enable(); | ||
51 | |||
43 | std::map<std::string, std::set<std::string>> grouped_paintings; | 52 | std::map<std::string, std::set<std::string>> grouped_paintings; |
44 | 53 | ||
45 | for (const auto& [from, to] : AP_GetPaintingMapping()) { | 54 | for (const auto& [from, to] : AP_GetPaintingMapping()) { |
@@ -59,3 +68,15 @@ void PaintingsPane::UpdateIndicators() { | |||
59 | } | 68 | } |
60 | } | 69 | } |
61 | } | 70 | } |
71 | |||
72 | void PaintingsPane::OnClickRevealPaintings(wxCommandEvent& event) { | ||
73 | if (wxMessageBox("Clicking yes will reveal the mapping between all shuffled " | ||
74 | "paintings. This is usually considered a spoiler, and is " | ||
75 | "likely not allowed during competitions. This action is not " | ||
76 | "reversible. Are you sure you want to proceed?", | ||
77 | "Warning", wxYES_NO | wxICON_WARNING) == wxNO) { | ||
78 | return; | ||
79 | } | ||
80 | |||
81 | AP_RevealPaintings(); | ||
82 | } | ||
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 { | |||
16 | void UpdateIndicators(); | 16 | void UpdateIndicators(); |
17 | 17 | ||
18 | private: | 18 | private: |
19 | void OnClickRevealPaintings(wxCommandEvent& event); | ||
20 | |||
19 | wxDataViewTreeCtrl* tree_ctrl_; | 21 | wxDataViewTreeCtrl* tree_ctrl_; |
22 | wxButton* reveal_btn_; | ||
20 | }; | 23 | }; |
21 | 24 | ||
22 | #endif /* end of include guard: PAINTINGS_PANE_H_815370D2 */ | 25 | #endif /* end of include guard: PAINTINGS_PANE_H_815370D2 */ |