From cf3fc6cbcb9ad00f4b99502344431bef469cec8d Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Sun, 18 Feb 2024 09:38:08 -0500 Subject: Make win condition checkable --- src/ap_state.cpp | 41 +++++++++++++++++++++++++++++++++++------ src/ap_state.h | 2 ++ src/area_popup.cpp | 3 ++- src/global.cpp | 16 ++++++++++++++++ src/global.h | 4 ++++ src/tracker_panel.cpp | 4 +++- 6 files changed, 62 insertions(+), 8 deletions(-) diff --git a/src/ap_state.cpp b/src/ap_state.cpp index 5b02ba6..fdc0219 100644 --- a/src/ap_state.cpp +++ b/src/ap_state.cpp @@ -6,6 +6,7 @@ #include +#include #include #include #include @@ -15,6 +16,7 @@ #include #include #include +#include #include #include @@ -47,10 +49,11 @@ struct APState { std::string data_storage_prefix; std::list tracked_data_storage_keys; + std::string victory_data_storage_key; std::map inventory; std::set checked_locations; - std::map data_storage; + std::map data_storage; DoorShuffleMode door_shuffle_mode = kNO_DOORS; bool color_shuffle = false; @@ -119,6 +122,7 @@ struct APState { inventory.clear(); checked_locations.clear(); data_storage.clear(); + victory_data_storage_key.clear(); door_shuffle_mode = kNO_DOORS; color_shuffle = false; painting_shuffle = false; @@ -187,6 +191,10 @@ struct APState { data_storage[key] = value.get(); TrackerLog("Data storage " + key + " retrieved as " + (value.get() ? "true" : "false")); + } else if (value.is_number()) { + data_storage[key] = value.get(); + TrackerLog("Data storage " + key + " retrieved as " + + std::to_string(value.get())); } } @@ -198,11 +206,15 @@ struct APState { const nlohmann::json&) { if (value.is_boolean()) { data_storage[key] = value.get(); - TrackerLog("Data storage " + key + " set to " + + TrackerLog("Data storage " + key + " retrieved as " + (value.get() ? "true" : "false")); - - RefreshTracker(); + } else if (value.is_number()) { + data_storage[key] = value.get(); + TrackerLog("Data storage " + key + " retrieved as " + + std::to_string(value.get())); } + + RefreshTracker(); }); apclient->set_slot_connected_handler([this]( @@ -242,6 +254,15 @@ struct APState { corrected_keys.push_back(data_storage_prefix + key); } + { + std::ostringstream vdsks; + vdsks << "_read_client_status_" << apclient->get_team_number() << "_" + << apclient->get_player_number(); + victory_data_storage_key = vdsks.str(); + } + + corrected_keys.push_back(victory_data_storage_key); + apclient->Get(corrected_keys); apclient->SetNotify(corrected_keys); }); @@ -321,7 +342,7 @@ struct APState { 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); + return data_storage.count(key) && std::any_cast(data_storage.at(key)); } bool HasItem(int item_id, int quantity) { @@ -330,7 +351,7 @@ struct APState { bool HasAchievement(const std::string& name) { std::string key = data_storage_prefix + "Achievement|" + name; - return data_storage.count(key) && data_storage.at(key); + return data_storage.count(key) && std::any_cast(data_storage.at(key)); } void RefreshTracker() { @@ -349,6 +370,12 @@ struct APState { return ap_id; } + bool HasReachedGoal() { + return data_storage.count(victory_data_storage_key) && + std::any_cast(data_storage.at(victory_data_storage_key)) == + 30; // CLIENT_GOAL + } + void DestroyClient() { client_active = false; apclient->reset(); @@ -417,3 +444,5 @@ bool AP_HasAchievement(const std::string& achievement_name) { } bool AP_HasEarlyColorHallways() { return GetState().early_color_hallways; } + +bool AP_HasReachedGoal() { return GetState().HasReachedGoal(); } diff --git a/src/ap_state.h b/src/ap_state.h index 9b94a72..cc51a78 100644 --- a/src/ap_state.h +++ b/src/ap_state.h @@ -44,4 +44,6 @@ bool AP_HasAchievement(const std::string& achievement_name); bool AP_HasEarlyColorHallways(); +bool AP_HasReachedGoal(); + #endif /* end of include guard: AP_STATE_H_664A4180 */ diff --git a/src/area_popup.cpp b/src/area_popup.cpp index 9c97d78..3b5d8d4 100644 --- a/src/area_popup.cpp +++ b/src/area_popup.cpp @@ -87,7 +87,8 @@ void AreaPopup::UpdateIndicators() { bool checked = AP_HasCheckedGameLocation(location.ap_location_id) || - (location.hunt && AP_HasCheckedHuntPanel(location.ap_location_id)); + (location.hunt && AP_HasCheckedHuntPanel(location.ap_location_id)) || + (IsLocationWinCondition(location) && AP_HasReachedGoal()); wxBitmap* eye_ptr = checked ? &checked_eye_ : &unchecked_eye_; diff --git a/src/global.cpp b/src/global.cpp index 3ee4f58..bd0dcaa 100644 --- a/src/global.cpp +++ b/src/global.cpp @@ -6,6 +6,9 @@ #include #include +#include "ap_state.h" +#include "game_data.h" + const std::filesystem::path& GetExecutableDirectory() { static const std::filesystem::path* executable_directory = []() { int length = wai_getExecutablePath(NULL, 0, NULL); @@ -22,3 +25,16 @@ const std::filesystem::path& GetExecutableDirectory() { std::string GetAbsolutePath(std::string_view path) { return (GetExecutableDirectory() / path).string(); } + +bool IsLocationWinCondition(const Location& location) { + switch (AP_GetVictoryCondition()) { + case kTHE_END: + return location.ap_location_name == + "Orange Tower Seventh Floor - THE END"; + case kTHE_MASTER: + return location.ap_location_name == + "Orange Tower Seventh Floor - THE MASTER"; + case kLEVEL_2: + return location.ap_location_name == "Second Room - LEVEL 2"; + } +} diff --git a/src/global.h b/src/global.h index 2eb7884..31ebde3 100644 --- a/src/global.h +++ b/src/global.h @@ -4,8 +4,12 @@ #include #include +struct Location; + const std::filesystem::path& GetExecutableDirectory(); std::string GetAbsolutePath(std::string_view path); +bool IsLocationWinCondition(const Location& location); + #endif /* end of include guard: GLOBAL_H_44945DBA */ diff --git a/src/tracker_panel.cpp b/src/tracker_panel.cpp index 3102110..daaeff7 100644 --- a/src/tracker_panel.cpp +++ b/src/tracker_panel.cpp @@ -118,7 +118,9 @@ void TrackerPanel::Redraw() { bool has_unreachable_unchecked = false; for (const Location §ion : map_area.locations) { bool has_unchecked = false; - if (AP_IsLocationVisible(section.classification)) { + if (IsLocationWinCondition(section)) { + has_unchecked = !AP_HasReachedGoal(); + } else 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); -- cgit 1.4.1 From 765aaa0f8654ed970ceb7ed096458cf504b8d746 Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Sun, 18 Feb 2024 09:38:22 -0500 Subject: Bump version --- src/version.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/version.h b/src/version.h index e9c8264..62a4cd1 100644 --- a/src/version.h +++ b/src/version.h @@ -35,6 +35,6 @@ std::ostream& operator<<(std::ostream& out, const Version& ver) { return out << "v" << ver.major << "." << ver.minor << "." << ver.revision; } -constexpr const Version kTrackerVersion = Version(0, 6, 4); +constexpr const Version kTrackerVersion = Version(0, 6, 5); #endif /* end of include guard: VERSION_H_C757E53C */ \ No newline at end of file -- cgit 1.4.1 From c714f8d2a5827196ca86ed4351ae22cfce5dfce5 Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Sun, 18 Feb 2024 09:45:02 -0500 Subject: Released v0.6.5 --- CHANGELOG.md | 8 ++++++++ VERSION | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c4f575d..0bbde7d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # lingo-ap-tracker Releases +## Initial Testing: v0.6.5 - 2024-02-18 + +- Victory condition will now be checked off when the player reaches the goal. + +Download: +[lingo-ap-tracker-v0.6.5-win64.zip](https://files.fourisland.com/releases/lingo-ap-tracker/lingo-ap-tracker-v0.6.5-win64.zip)
+Source: [v0.6.5](https://code.fourisland.com/lingo-ap-tracker/tag/?h=v0.6.5) + ## Initial Testing: v0.6.4 - 2024-01-27 - Fixed issue where area popups would appear too big. diff --git a/VERSION b/VERSION index af53794..bc21b44 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -v0.6.4 \ No newline at end of file +v0.6.5 \ No newline at end of file -- cgit 1.4.1