diff options
author | Star Rauchenberger <fefferburbia@gmail.com> | 2023-11-17 11:43:13 -0500 |
---|---|---|
committer | Star Rauchenberger <fefferburbia@gmail.com> | 2023-11-17 11:43:13 -0500 |
commit | 4adfe42a300a597cf8e7036cd189d197b08a7f01 (patch) | |
tree | 684a9f825bc1ae919ea68049a941f6190b8b4f96 | |
parent | a9bc708c7eeeada4c59952ce71aa071175f8f27d (diff) | |
download | lingo-ap-tracker-4adfe42a300a597cf8e7036cd189d197b08a7f01.tar.gz lingo-ap-tracker-4adfe42a300a597cf8e7036cd189d197b08a7f01.tar.bz2 lingo-ap-tracker-4adfe42a300a597cf8e7036cd189d197b08a7f01.zip |
Show hunt panels option
-rw-r--r-- | src/ap_state.cpp | 17 | ||||
-rw-r--r-- | src/ap_state.h | 2 | ||||
-rw-r--r-- | src/area_popup.cpp | 8 | ||||
-rw-r--r-- | src/game_data.cpp | 7 | ||||
-rw-r--r-- | src/game_data.h | 2 | ||||
-rw-r--r-- | src/settings_dialog.cpp | 5 | ||||
-rw-r--r-- | src/settings_dialog.h | 2 | ||||
-rw-r--r-- | src/tracker_config.cpp | 5 | ||||
-rw-r--r-- | src/tracker_config.h | 1 | ||||
-rw-r--r-- | src/tracker_frame.cpp | 1 | ||||
-rw-r--r-- | src/tracker_panel.cpp | 10 |
11 files changed, 54 insertions, 6 deletions
diff --git a/src/ap_state.cpp b/src/ap_state.cpp index 50601d4..5b02ba6 100644 --- a/src/ap_state.cpp +++ b/src/ap_state.cpp | |||
@@ -85,6 +85,13 @@ struct APState { | |||
85 | "Achievement|" + GD_GetPanel(panel_id).achievement_name); | 85 | "Achievement|" + GD_GetPanel(panel_id).achievement_name); |
86 | } | 86 | } |
87 | 87 | ||
88 | for (const MapArea& map_area : GD_GetMapAreas()) { | ||
89 | for (const Location& location : map_area.locations) { | ||
90 | tracked_data_storage_keys.push_back( | ||
91 | "Hunt|" + std::to_string(location.ap_location_id)); | ||
92 | } | ||
93 | } | ||
94 | |||
88 | initialized = true; | 95 | initialized = true; |
89 | } | 96 | } |
90 | 97 | ||
@@ -311,6 +318,12 @@ struct APState { | |||
311 | return checked_locations.count(location_id); | 318 | return checked_locations.count(location_id); |
312 | } | 319 | } |
313 | 320 | ||
321 | bool HasCheckedHuntPanel(int location_id) { | ||
322 | std::string key = | ||
323 | data_storage_prefix + "Hunt|" + std::to_string(location_id); | ||
324 | return data_storage.count(key) && data_storage.at(key); | ||
325 | } | ||
326 | |||
314 | bool HasItem(int item_id, int quantity) { | 327 | bool HasItem(int item_id, int quantity) { |
315 | return inventory.count(item_id) && inventory.at(item_id) >= quantity; | 328 | return inventory.count(item_id) && inventory.at(item_id) >= quantity; |
316 | } | 329 | } |
@@ -360,6 +373,10 @@ bool AP_HasCheckedGameLocation(int location_id) { | |||
360 | return GetState().HasCheckedGameLocation(location_id); | 373 | return GetState().HasCheckedGameLocation(location_id); |
361 | } | 374 | } |
362 | 375 | ||
376 | bool AP_HasCheckedHuntPanel(int location_id) { | ||
377 | return GetState().HasCheckedHuntPanel(location_id); | ||
378 | } | ||
379 | |||
363 | bool AP_HasItem(int item_id, int quantity) { | 380 | bool AP_HasItem(int item_id, int quantity) { |
364 | return GetState().HasItem(item_id, quantity); | 381 | return GetState().HasItem(item_id, quantity); |
365 | } | 382 | } |
diff --git a/src/ap_state.h b/src/ap_state.h index 3fd51aa..9b94a72 100644 --- a/src/ap_state.h +++ b/src/ap_state.h | |||
@@ -20,6 +20,8 @@ void AP_Connect(std::string server, std::string player, std::string password); | |||
20 | 20 | ||
21 | bool AP_HasCheckedGameLocation(int location_id); | 21 | bool AP_HasCheckedGameLocation(int location_id); |
22 | 22 | ||
23 | bool AP_HasCheckedHuntPanel(int location_id); | ||
24 | |||
23 | bool AP_HasItem(int item_id, int quantity = 1); | 25 | bool AP_HasItem(int item_id, int quantity = 1); |
24 | 26 | ||
25 | DoorShuffleMode AP_GetDoorShuffleMode(); | 27 | DoorShuffleMode AP_GetDoorShuffleMode(); |
diff --git a/src/area_popup.cpp b/src/area_popup.cpp index 0657ea3..6bbc0cf 100644 --- a/src/area_popup.cpp +++ b/src/area_popup.cpp | |||
@@ -2,6 +2,7 @@ | |||
2 | 2 | ||
3 | #include "ap_state.h" | 3 | #include "ap_state.h" |
4 | #include "game_data.h" | 4 | #include "game_data.h" |
5 | #include "tracker_config.h" | ||
5 | #include "tracker_state.h" | 6 | #include "tracker_state.h" |
6 | 7 | ||
7 | AreaPopup::AreaPopup(wxWindow* parent, int area_id) | 8 | AreaPopup::AreaPopup(wxWindow* parent, int area_id) |
@@ -48,7 +49,8 @@ void AreaPopup::UpdateIndicators() { | |||
48 | wxSizer* container_sizer = | 49 | wxSizer* container_sizer = |
49 | section_labels_[section_id]->GetContainingSizer(); | 50 | section_labels_[section_id]->GetContainingSizer(); |
50 | 51 | ||
51 | if (!AP_IsLocationVisible(location.classification)) { | 52 | if (!AP_IsLocationVisible(location.classification) && |
53 | !(location.hunt && GetTrackerConfig().show_hunt_panels)) { | ||
52 | container_sizer->Hide(section_labels_[section_id]); | 54 | container_sizer->Hide(section_labels_[section_id]); |
53 | container_sizer->Hide(eye_indicators_[section_id]); | 55 | container_sizer->Hide(eye_indicators_[section_id]); |
54 | continue; | 56 | continue; |
@@ -57,7 +59,9 @@ void AreaPopup::UpdateIndicators() { | |||
57 | container_sizer->Show(eye_indicators_[section_id]); | 59 | container_sizer->Show(eye_indicators_[section_id]); |
58 | } | 60 | } |
59 | 61 | ||
60 | bool checked = AP_HasCheckedGameLocation(location.ap_location_id); | 62 | bool checked = |
63 | AP_HasCheckedGameLocation(location.ap_location_id) || | ||
64 | (location.hunt && AP_HasCheckedHuntPanel(location.ap_location_id)); | ||
61 | bool reachable = IsLocationReachable(location.ap_location_id); | 65 | bool reachable = IsLocationReachable(location.ap_location_id); |
62 | const wxColour* text_color = reachable ? wxWHITE : wxRED; | 66 | const wxColour* text_color = reachable ? wxWHITE : wxRED; |
63 | 67 | ||
diff --git a/src/game_data.cpp b/src/game_data.cpp index f51d7ac..2022097 100644 --- a/src/game_data.cpp +++ b/src/game_data.cpp | |||
@@ -247,6 +247,10 @@ struct GameData { | |||
247 | achievement_panels_.push_back(panel_id); | 247 | achievement_panels_.push_back(panel_id); |
248 | } | 248 | } |
249 | 249 | ||
250 | if (panel_it.second["hunt"]) { | ||
251 | panel_obj.hunt = panel_it.second["hunt"].as<bool>(); | ||
252 | } | ||
253 | |||
250 | if (panel_it.second["exclude_reduce"]) { | 254 | if (panel_it.second["exclude_reduce"]) { |
251 | panel_obj.exclude_reduce = | 255 | panel_obj.exclude_reduce = |
252 | panel_it.second["exclude_reduce"].as<bool>(); | 256 | panel_it.second["exclude_reduce"].as<bool>(); |
@@ -493,7 +497,8 @@ struct GameData { | |||
493 | .ap_location_id = panel.ap_location_id, | 497 | .ap_location_id = panel.ap_location_id, |
494 | .room = panel.room, | 498 | .room = panel.room, |
495 | .panels = {panel.id}, | 499 | .panels = {panel.id}, |
496 | .classification = classification}); | 500 | .classification = classification, |
501 | .hunt = panel.hunt}); | ||
497 | locations_by_name[map_area.locations.back().ap_location_name] = { | 502 | locations_by_name[map_area.locations.back().ap_location_name] = { |
498 | area_id, map_area.locations.size() - 1}; | 503 | area_id, map_area.locations.size() - 1}; |
499 | } | 504 | } |
diff --git a/src/game_data.h b/src/game_data.h index b3e2466..721ecc6 100644 --- a/src/game_data.h +++ b/src/game_data.h | |||
@@ -37,6 +37,7 @@ struct Panel { | |||
37 | std::string achievement_name; | 37 | std::string achievement_name; |
38 | bool non_counting = false; | 38 | bool non_counting = false; |
39 | int ap_location_id = -1; | 39 | int ap_location_id = -1; |
40 | bool hunt = false; | ||
40 | }; | 41 | }; |
41 | 42 | ||
42 | struct ProgressiveRequirement { | 43 | struct ProgressiveRequirement { |
@@ -87,6 +88,7 @@ struct Location { | |||
87 | int room; | 88 | int room; |
88 | std::vector<int> panels; | 89 | std::vector<int> panels; |
89 | int classification = 0; | 90 | int classification = 0; |
91 | bool hunt = false; | ||
90 | }; | 92 | }; |
91 | 93 | ||
92 | struct MapArea { | 94 | struct MapArea { |
diff --git a/src/settings_dialog.cpp b/src/settings_dialog.cpp index 58e5988..0321b5a 100644 --- a/src/settings_dialog.cpp +++ b/src/settings_dialog.cpp | |||
@@ -8,10 +8,12 @@ SettingsDialog::SettingsDialog() : wxDialog(nullptr, wxID_ANY, "Settings") { | |||
8 | hybrid_areas_box_ = new wxCheckBox( | 8 | hybrid_areas_box_ = new wxCheckBox( |
9 | this, wxID_ANY, | 9 | this, wxID_ANY, |
10 | "Use two colors to show that an area has partial availability"); | 10 | "Use two colors to show that an area has partial availability"); |
11 | show_hunt_panels_box_ = new wxCheckBox(this, wxID_ANY, "Show hunt panels"); | ||
11 | 12 | ||
12 | should_check_for_updates_box_->SetValue( | 13 | should_check_for_updates_box_->SetValue( |
13 | GetTrackerConfig().should_check_for_updates); | 14 | GetTrackerConfig().should_check_for_updates); |
14 | hybrid_areas_box_->SetValue(GetTrackerConfig().hybrid_areas); | 15 | hybrid_areas_box_->SetValue(GetTrackerConfig().hybrid_areas); |
16 | show_hunt_panels_box_->SetValue(GetTrackerConfig().show_hunt_panels); | ||
15 | 17 | ||
16 | wxBoxSizer* form_sizer = new wxBoxSizer(wxVERTICAL); | 18 | wxBoxSizer* form_sizer = new wxBoxSizer(wxVERTICAL); |
17 | 19 | ||
@@ -21,6 +23,9 @@ SettingsDialog::SettingsDialog() : wxDialog(nullptr, wxID_ANY, "Settings") { | |||
21 | form_sizer->Add(hybrid_areas_box_, wxSizerFlags().HorzBorder()); | 23 | form_sizer->Add(hybrid_areas_box_, wxSizerFlags().HorzBorder()); |
22 | form_sizer->AddSpacer(2); | 24 | form_sizer->AddSpacer(2); |
23 | 25 | ||
26 | form_sizer->Add(show_hunt_panels_box_, wxSizerFlags().HorzBorder()); | ||
27 | form_sizer->AddSpacer(2); | ||
28 | |||
24 | form_sizer->Add(CreateButtonSizer(wxOK | wxCANCEL), wxSizerFlags().Center()); | 29 | form_sizer->Add(CreateButtonSizer(wxOK | wxCANCEL), wxSizerFlags().Center()); |
25 | 30 | ||
26 | SetSizerAndFit(form_sizer); | 31 | SetSizerAndFit(form_sizer); |
diff --git a/src/settings_dialog.h b/src/settings_dialog.h index 150a7a8..d7c1ed3 100644 --- a/src/settings_dialog.h +++ b/src/settings_dialog.h | |||
@@ -15,10 +15,12 @@ class SettingsDialog : public wxDialog { | |||
15 | return should_check_for_updates_box_->GetValue(); | 15 | return should_check_for_updates_box_->GetValue(); |
16 | } | 16 | } |
17 | bool GetHybridAreas() const { return hybrid_areas_box_->GetValue(); } | 17 | bool GetHybridAreas() const { return hybrid_areas_box_->GetValue(); } |
18 | bool GetShowHuntPanels() const { return show_hunt_panels_box_->GetValue(); } | ||
18 | 19 | ||
19 | private: | 20 | private: |
20 | wxCheckBox* should_check_for_updates_box_; | 21 | wxCheckBox* should_check_for_updates_box_; |
21 | wxCheckBox* hybrid_areas_box_; | 22 | wxCheckBox* hybrid_areas_box_; |
23 | wxCheckBox* show_hunt_panels_box_; | ||
22 | }; | 24 | }; |
23 | 25 | ||
24 | #endif /* end of include guard: SETTINGS_DIALOG_H_D8635719 */ | 26 | #endif /* end of include guard: SETTINGS_DIALOG_H_D8635719 */ |
diff --git a/src/tracker_config.cpp b/src/tracker_config.cpp index 9318091..11e1cec 100644 --- a/src/tracker_config.cpp +++ b/src/tracker_config.cpp | |||
@@ -1,8 +1,9 @@ | |||
1 | #include "tracker_config.h" | 1 | #include "tracker_config.h" |
2 | 2 | ||
3 | #include <fstream> | ||
4 | #include <yaml-cpp/yaml.h> | 3 | #include <yaml-cpp/yaml.h> |
5 | 4 | ||
5 | #include <fstream> | ||
6 | |||
6 | constexpr const char* CONFIG_FILE_NAME = "config.yaml"; | 7 | constexpr const char* CONFIG_FILE_NAME = "config.yaml"; |
7 | 8 | ||
8 | void TrackerConfig::Load() { | 9 | void TrackerConfig::Load() { |
@@ -15,6 +16,7 @@ void TrackerConfig::Load() { | |||
15 | asked_to_check_for_updates = file["asked_to_check_for_updates"].as<bool>(); | 16 | asked_to_check_for_updates = file["asked_to_check_for_updates"].as<bool>(); |
16 | should_check_for_updates = file["should_check_for_updates"].as<bool>(); | 17 | should_check_for_updates = file["should_check_for_updates"].as<bool>(); |
17 | hybrid_areas = file["hybrid_areas"].as<bool>(); | 18 | hybrid_areas = file["hybrid_areas"].as<bool>(); |
19 | show_hunt_panels = file["show_hunt_panels"].as<bool>(); | ||
18 | } catch (const std::exception&) { | 20 | } catch (const std::exception&) { |
19 | // It's fine if the file can't be loaded. | 21 | // It's fine if the file can't be loaded. |
20 | } | 22 | } |
@@ -28,6 +30,7 @@ void TrackerConfig::Save() { | |||
28 | output["asked_to_check_for_updates"] = asked_to_check_for_updates; | 30 | output["asked_to_check_for_updates"] = asked_to_check_for_updates; |
29 | output["should_check_for_updates"] = should_check_for_updates; | 31 | output["should_check_for_updates"] = should_check_for_updates; |
30 | output["hybrid_areas"] = hybrid_areas; | 32 | output["hybrid_areas"] = hybrid_areas; |
33 | output["show_hunt_panels"] = show_hunt_panels; | ||
31 | 34 | ||
32 | std::ofstream filewriter(CONFIG_FILE_NAME); | 35 | std::ofstream filewriter(CONFIG_FILE_NAME); |
33 | filewriter << output; | 36 | filewriter << output; |
diff --git a/src/tracker_config.h b/src/tracker_config.h index 6c94e1b..0a29d2c 100644 --- a/src/tracker_config.h +++ b/src/tracker_config.h | |||
@@ -15,6 +15,7 @@ class TrackerConfig { | |||
15 | bool asked_to_check_for_updates = false; | 15 | bool asked_to_check_for_updates = false; |
16 | bool should_check_for_updates = false; | 16 | bool should_check_for_updates = false; |
17 | bool hybrid_areas = false; | 17 | bool hybrid_areas = false; |
18 | bool show_hunt_panels = false; | ||
18 | }; | 19 | }; |
19 | 20 | ||
20 | TrackerConfig& GetTrackerConfig(); | 21 | TrackerConfig& GetTrackerConfig(); |
diff --git a/src/tracker_frame.cpp b/src/tracker_frame.cpp index 5341fa6..4e3a8a8 100644 --- a/src/tracker_frame.cpp +++ b/src/tracker_frame.cpp | |||
@@ -133,6 +133,7 @@ void TrackerFrame::OnSettings(wxCommandEvent &event) { | |||
133 | GetTrackerConfig().should_check_for_updates = | 133 | GetTrackerConfig().should_check_for_updates = |
134 | dlg.GetShouldCheckForUpdates(); | 134 | dlg.GetShouldCheckForUpdates(); |
135 | GetTrackerConfig().hybrid_areas = dlg.GetHybridAreas(); | 135 | GetTrackerConfig().hybrid_areas = dlg.GetHybridAreas(); |
136 | GetTrackerConfig().show_hunt_panels = dlg.GetShowHuntPanels(); | ||
136 | GetTrackerConfig().Save(); | 137 | GetTrackerConfig().Save(); |
137 | 138 | ||
138 | UpdateIndicators(); | 139 | UpdateIndicators(); |
diff --git a/src/tracker_panel.cpp b/src/tracker_panel.cpp index 466440f..f6fed25 100644 --- a/src/tracker_panel.cpp +++ b/src/tracker_panel.cpp | |||
@@ -114,8 +114,14 @@ void TrackerPanel::Redraw() { | |||
114 | bool has_reachable_unchecked = false; | 114 | bool has_reachable_unchecked = false; |
115 | bool has_unreachable_unchecked = false; | 115 | bool has_unreachable_unchecked = false; |
116 | for (const Location §ion : map_area.locations) { | 116 | for (const Location §ion : map_area.locations) { |
117 | if (AP_IsLocationVisible(section.classification) && | 117 | bool has_unchecked = false; |
118 | !AP_HasCheckedGameLocation(section.ap_location_id)) { | 118 | if (AP_IsLocationVisible(section.classification)) { |
119 | has_unchecked = !AP_HasCheckedGameLocation(section.ap_location_id); | ||
120 | } else if (section.hunt && GetTrackerConfig().show_hunt_panels) { | ||
121 | has_unchecked = !AP_HasCheckedHuntPanel(section.ap_location_id); | ||
122 | } | ||
123 | |||
124 | if (has_unchecked) { | ||
119 | if (IsLocationReachable(section.ap_location_id)) { | 125 | if (IsLocationReachable(section.ap_location_id)) { |
120 | has_reachable_unchecked = true; | 126 | has_reachable_unchecked = true; |
121 | } else { | 127 | } else { |