1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
#include "paintings_pane.h"
#include <fmt/core.h>
#include <wx/dataview.h>
#include <map>
#include <set>
#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<std::string>&) {
// TODO: Optimize this by using the paintings delta.
tree_ctrl_->DeleteAllItems();
std::map<std::string, std::set<std::string>> 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();
}
|