From 4adfe42a300a597cf8e7036cd189d197b08a7f01 Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Fri, 17 Nov 2023 11:43:13 -0500 Subject: Show hunt panels option --- src/ap_state.cpp | 17 +++++++++++++++++ src/ap_state.h | 2 ++ src/area_popup.cpp | 8 ++++++-- src/game_data.cpp | 7 ++++++- src/game_data.h | 2 ++ src/settings_dialog.cpp | 5 +++++ src/settings_dialog.h | 2 ++ src/tracker_config.cpp | 5 ++++- src/tracker_config.h | 1 + src/tracker_frame.cpp | 1 + src/tracker_panel.cpp | 10 ++++++++-- 11 files changed, 54 insertions(+), 6 deletions(-) (limited to 'src') 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 { "Achievement|" + GD_GetPanel(panel_id).achievement_name); } + for (const MapArea& map_area : GD_GetMapAreas()) { + for (const Location& location : map_area.locations) { + tracked_data_storage_keys.push_back( + "Hunt|" + std::to_string(location.ap_location_id)); + } + } + initialized = true; } @@ -311,6 +318,12 @@ struct APState { return checked_locations.count(location_id); } + bool HasCheckedHuntPanel(int location_id) { + std::string key = + data_storage_prefix + "Hunt|" + std::to_string(location_id); + return data_storage.count(key) && data_storage.at(key); + } + bool HasItem(int item_id, int quantity) { return inventory.count(item_id) && inventory.at(item_id) >= quantity; } @@ -360,6 +373,10 @@ bool AP_HasCheckedGameLocation(int location_id) { return GetState().HasCheckedGameLocation(location_id); } +bool AP_HasCheckedHuntPanel(int location_id) { + return GetState().HasCheckedHuntPanel(location_id); +} + bool AP_HasItem(int item_id, int quantity) { return GetState().HasItem(item_id, quantity); } 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); bool AP_HasCheckedGameLocation(int location_id); +bool AP_HasCheckedHuntPanel(int location_id); + bool AP_HasItem(int item_id, int quantity = 1); 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 @@ #include "ap_state.h" #include "game_data.h" +#include "tracker_config.h" #include "tracker_state.h" AreaPopup::AreaPopup(wxWindow* parent, int area_id) @@ -48,7 +49,8 @@ void AreaPopup::UpdateIndicators() { wxSizer* container_sizer = section_labels_[section_id]->GetContainingSizer(); - if (!AP_IsLocationVisible(location.classification)) { + if (!AP_IsLocationVisible(location.classification) && + !(location.hunt && GetTrackerConfig().show_hunt_panels)) { container_sizer->Hide(section_labels_[section_id]); container_sizer->Hide(eye_indicators_[section_id]); continue; @@ -57,7 +59,9 @@ void AreaPopup::UpdateIndicators() { container_sizer->Show(eye_indicators_[section_id]); } - bool checked = AP_HasCheckedGameLocation(location.ap_location_id); + bool checked = + AP_HasCheckedGameLocation(location.ap_location_id) || + (location.hunt && AP_HasCheckedHuntPanel(location.ap_location_id)); bool reachable = IsLocationReachable(location.ap_location_id); const wxColour* text_color = reachable ? wxWHITE : wxRED; 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 { achievement_panels_.push_back(panel_id); } + if (panel_it.second["hunt"]) { + panel_obj.hunt = panel_it.second["hunt"].as(); + } + if (panel_it.second["exclude_reduce"]) { panel_obj.exclude_reduce = panel_it.second["exclude_reduce"].as(); @@ -493,7 +497,8 @@ struct GameData { .ap_location_id = panel.ap_location_id, .room = panel.room, .panels = {panel.id}, - .classification = classification}); + .classification = classification, + .hunt = panel.hunt}); locations_by_name[map_area.locations.back().ap_location_name] = { area_id, map_area.locations.size() - 1}; } 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 { std::string achievement_name; bool non_counting = false; int ap_location_id = -1; + bool hunt = false; }; struct ProgressiveRequirement { @@ -87,6 +88,7 @@ struct Location { int room; std::vector panels; int classification = 0; + bool hunt = false; }; 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") { hybrid_areas_box_ = new wxCheckBox( this, wxID_ANY, "Use two colors to show that an area has partial availability"); + show_hunt_panels_box_ = new wxCheckBox(this, wxID_ANY, "Show hunt panels"); should_check_for_updates_box_->SetValue( GetTrackerConfig().should_check_for_updates); hybrid_areas_box_->SetValue(GetTrackerConfig().hybrid_areas); + show_hunt_panels_box_->SetValue(GetTrackerConfig().show_hunt_panels); wxBoxSizer* form_sizer = new wxBoxSizer(wxVERTICAL); @@ -21,6 +23,9 @@ SettingsDialog::SettingsDialog() : wxDialog(nullptr, wxID_ANY, "Settings") { form_sizer->Add(hybrid_areas_box_, wxSizerFlags().HorzBorder()); form_sizer->AddSpacer(2); + form_sizer->Add(show_hunt_panels_box_, wxSizerFlags().HorzBorder()); + form_sizer->AddSpacer(2); + form_sizer->Add(CreateButtonSizer(wxOK | wxCANCEL), wxSizerFlags().Center()); 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 { return should_check_for_updates_box_->GetValue(); } bool GetHybridAreas() const { return hybrid_areas_box_->GetValue(); } + bool GetShowHuntPanels() const { return show_hunt_panels_box_->GetValue(); } private: wxCheckBox* should_check_for_updates_box_; wxCheckBox* hybrid_areas_box_; + wxCheckBox* show_hunt_panels_box_; }; #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 @@ #include "tracker_config.h" -#include #include +#include + constexpr const char* CONFIG_FILE_NAME = "config.yaml"; void TrackerConfig::Load() { @@ -15,6 +16,7 @@ void TrackerConfig::Load() { asked_to_check_for_updates = file["asked_to_check_for_updates"].as(); should_check_for_updates = file["should_check_for_updates"].as(); hybrid_areas = file["hybrid_areas"].as(); + show_hunt_panels = file["show_hunt_panels"].as(); } catch (const std::exception&) { // It's fine if the file can't be loaded. } @@ -28,6 +30,7 @@ void TrackerConfig::Save() { output["asked_to_check_for_updates"] = asked_to_check_for_updates; output["should_check_for_updates"] = should_check_for_updates; output["hybrid_areas"] = hybrid_areas; + output["show_hunt_panels"] = show_hunt_panels; std::ofstream filewriter(CONFIG_FILE_NAME); 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 { bool asked_to_check_for_updates = false; bool should_check_for_updates = false; bool hybrid_areas = false; + bool show_hunt_panels = false; }; 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) { GetTrackerConfig().should_check_for_updates = dlg.GetShouldCheckForUpdates(); GetTrackerConfig().hybrid_areas = dlg.GetHybridAreas(); + GetTrackerConfig().show_hunt_panels = dlg.GetShowHuntPanels(); GetTrackerConfig().Save(); 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() { bool has_reachable_unchecked = false; bool has_unreachable_unchecked = false; for (const Location §ion : map_area.locations) { - if (AP_IsLocationVisible(section.classification) && - !AP_HasCheckedGameLocation(section.ap_location_id)) { + bool has_unchecked = false; + if (AP_IsLocationVisible(section.classification)) { + has_unchecked = !AP_HasCheckedGameLocation(section.ap_location_id); + } else if (section.hunt && GetTrackerConfig().show_hunt_panels) { + has_unchecked = !AP_HasCheckedHuntPanel(section.ap_location_id); + } + + if (has_unchecked) { if (IsLocationReachable(section.ap_location_id)) { has_reachable_unchecked = true; } else { -- cgit 1.4.1