diff options
| author | Star Rauchenberger <fefferburbia@gmail.com> | 2024-02-18 09:38:08 -0500 |
|---|---|---|
| committer | Star Rauchenberger <fefferburbia@gmail.com> | 2024-02-18 09:38:08 -0500 |
| commit | cf3fc6cbcb9ad00f4b99502344431bef469cec8d (patch) | |
| tree | fb803654f6aa432a495b820647931e6d79cebaf7 /src | |
| parent | 7cb55acb62c5a03df75edd0c3c8f228295c1bee8 (diff) | |
| download | lingo-ap-tracker-cf3fc6cbcb9ad00f4b99502344431bef469cec8d.tar.gz lingo-ap-tracker-cf3fc6cbcb9ad00f4b99502344431bef469cec8d.tar.bz2 lingo-ap-tracker-cf3fc6cbcb9ad00f4b99502344431bef469cec8d.zip | |
Make win condition checkable
Diffstat (limited to 'src')
| -rw-r--r-- | src/ap_state.cpp | 41 | ||||
| -rw-r--r-- | src/ap_state.h | 2 | ||||
| -rw-r--r-- | src/area_popup.cpp | 3 | ||||
| -rw-r--r-- | src/global.cpp | 16 | ||||
| -rw-r--r-- | src/global.h | 4 | ||||
| -rw-r--r-- | 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 @@ | |||
| 6 | 6 | ||
| 7 | #include <hkutil/string.h> | 7 | #include <hkutil/string.h> |
| 8 | 8 | ||
| 9 | #include <any> | ||
| 9 | #include <apclient.hpp> | 10 | #include <apclient.hpp> |
| 10 | #include <apuuid.hpp> | 11 | #include <apuuid.hpp> |
| 11 | #include <chrono> | 12 | #include <chrono> |
| @@ -15,6 +16,7 @@ | |||
| 15 | #include <memory> | 16 | #include <memory> |
| 16 | #include <mutex> | 17 | #include <mutex> |
| 17 | #include <set> | 18 | #include <set> |
| 19 | #include <sstream> | ||
| 18 | #include <thread> | 20 | #include <thread> |
| 19 | #include <tuple> | 21 | #include <tuple> |
| 20 | 22 | ||
| @@ -47,10 +49,11 @@ struct APState { | |||
| 47 | 49 | ||
| 48 | std::string data_storage_prefix; | 50 | std::string data_storage_prefix; |
| 49 | std::list<std::string> tracked_data_storage_keys; | 51 | std::list<std::string> tracked_data_storage_keys; |
| 52 | std::string victory_data_storage_key; | ||
| 50 | 53 | ||
| 51 | std::map<int64_t, int> inventory; | 54 | std::map<int64_t, int> inventory; |
| 52 | std::set<int64_t> checked_locations; | 55 | std::set<int64_t> checked_locations; |
| 53 | std::map<std::string, bool> data_storage; | 56 | std::map<std::string, std::any> data_storage; |
| 54 | 57 | ||
| 55 | DoorShuffleMode door_shuffle_mode = kNO_DOORS; | 58 | DoorShuffleMode door_shuffle_mode = kNO_DOORS; |
| 56 | bool color_shuffle = false; | 59 | bool color_shuffle = false; |
| @@ -119,6 +122,7 @@ struct APState { | |||
| 119 | inventory.clear(); | 122 | inventory.clear(); |
| 120 | checked_locations.clear(); | 123 | checked_locations.clear(); |
| 121 | data_storage.clear(); | 124 | data_storage.clear(); |
| 125 | victory_data_storage_key.clear(); | ||
| 122 | door_shuffle_mode = kNO_DOORS; | 126 | door_shuffle_mode = kNO_DOORS; |
| 123 | color_shuffle = false; | 127 | color_shuffle = false; |
| 124 | painting_shuffle = false; | 128 | painting_shuffle = false; |
| @@ -187,6 +191,10 @@ struct APState { | |||
| 187 | data_storage[key] = value.get<bool>(); | 191 | data_storage[key] = value.get<bool>(); |
| 188 | TrackerLog("Data storage " + key + " retrieved as " + | 192 | TrackerLog("Data storage " + key + " retrieved as " + |
| 189 | (value.get<bool>() ? "true" : "false")); | 193 | (value.get<bool>() ? "true" : "false")); |
| 194 | } else if (value.is_number()) { | ||
| 195 | data_storage[key] = value.get<int>(); | ||
| 196 | TrackerLog("Data storage " + key + " retrieved as " + | ||
| 197 | std::to_string(value.get<int>())); | ||
| 190 | } | 198 | } |
| 191 | } | 199 | } |
| 192 | 200 | ||
| @@ -198,11 +206,15 @@ struct APState { | |||
| 198 | const nlohmann::json&) { | 206 | const nlohmann::json&) { |
| 199 | if (value.is_boolean()) { | 207 | if (value.is_boolean()) { |
| 200 | data_storage[key] = value.get<bool>(); | 208 | data_storage[key] = value.get<bool>(); |
| 201 | TrackerLog("Data storage " + key + " set to " + | 209 | TrackerLog("Data storage " + key + " retrieved as " + |
| 202 | (value.get<bool>() ? "true" : "false")); | 210 | (value.get<bool>() ? "true" : "false")); |
| 203 | 211 | } else if (value.is_number()) { | |
| 204 | RefreshTracker(); | 212 | data_storage[key] = value.get<int>(); |
| 213 | TrackerLog("Data storage " + key + " retrieved as " + | ||
| 214 | std::to_string(value.get<int>())); | ||
| 205 | } | 215 | } |
| 216 | |||
| 217 | RefreshTracker(); | ||
| 206 | }); | 218 | }); |
| 207 | 219 | ||
| 208 | apclient->set_slot_connected_handler([this]( | 220 | apclient->set_slot_connected_handler([this]( |
| @@ -242,6 +254,15 @@ struct APState { | |||
| 242 | corrected_keys.push_back(data_storage_prefix + key); | 254 | corrected_keys.push_back(data_storage_prefix + key); |
| 243 | } | 255 | } |
| 244 | 256 | ||
| 257 | { | ||
| 258 | std::ostringstream vdsks; | ||
| 259 | vdsks << "_read_client_status_" << apclient->get_team_number() << "_" | ||
| 260 | << apclient->get_player_number(); | ||
| 261 | victory_data_storage_key = vdsks.str(); | ||
| 262 | } | ||
| 263 | |||
| 264 | corrected_keys.push_back(victory_data_storage_key); | ||
| 265 | |||
| 245 | apclient->Get(corrected_keys); | 266 | apclient->Get(corrected_keys); |
| 246 | apclient->SetNotify(corrected_keys); | 267 | apclient->SetNotify(corrected_keys); |
| 247 | }); | 268 | }); |
| @@ -321,7 +342,7 @@ struct APState { | |||
| 321 | bool HasCheckedHuntPanel(int location_id) { | 342 | bool HasCheckedHuntPanel(int location_id) { |
| 322 | std::string key = | 343 | std::string key = |
| 323 | data_storage_prefix + "Hunt|" + std::to_string(location_id); | 344 | data_storage_prefix + "Hunt|" + std::to_string(location_id); |
| 324 | return data_storage.count(key) && data_storage.at(key); | 345 | return data_storage.count(key) && std::any_cast<bool>(data_storage.at(key)); |
| 325 | } | 346 | } |
| 326 | 347 | ||
| 327 | bool HasItem(int item_id, int quantity) { | 348 | bool HasItem(int item_id, int quantity) { |
| @@ -330,7 +351,7 @@ struct APState { | |||
| 330 | 351 | ||
| 331 | bool HasAchievement(const std::string& name) { | 352 | bool HasAchievement(const std::string& name) { |
| 332 | std::string key = data_storage_prefix + "Achievement|" + name; | 353 | std::string key = data_storage_prefix + "Achievement|" + name; |
| 333 | return data_storage.count(key) && data_storage.at(key); | 354 | return data_storage.count(key) && std::any_cast<bool>(data_storage.at(key)); |
| 334 | } | 355 | } |
| 335 | 356 | ||
| 336 | void RefreshTracker() { | 357 | void RefreshTracker() { |
| @@ -349,6 +370,12 @@ struct APState { | |||
| 349 | return ap_id; | 370 | return ap_id; |
| 350 | } | 371 | } |
| 351 | 372 | ||
| 373 | bool HasReachedGoal() { | ||
| 374 | return data_storage.count(victory_data_storage_key) && | ||
| 375 | std::any_cast<int>(data_storage.at(victory_data_storage_key)) == | ||
| 376 | 30; // CLIENT_GOAL | ||
| 377 | } | ||
| 378 | |||
| 352 | void DestroyClient() { | 379 | void DestroyClient() { |
| 353 | client_active = false; | 380 | client_active = false; |
| 354 | apclient->reset(); | 381 | apclient->reset(); |
| @@ -417,3 +444,5 @@ bool AP_HasAchievement(const std::string& achievement_name) { | |||
| 417 | } | 444 | } |
| 418 | 445 | ||
| 419 | bool AP_HasEarlyColorHallways() { return GetState().early_color_hallways; } | 446 | bool AP_HasEarlyColorHallways() { return GetState().early_color_hallways; } |
| 447 | |||
| 448 | 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); | |||
| 44 | 44 | ||
| 45 | bool AP_HasEarlyColorHallways(); | 45 | bool AP_HasEarlyColorHallways(); |
| 46 | 46 | ||
| 47 | bool AP_HasReachedGoal(); | ||
| 48 | |||
| 47 | #endif /* end of include guard: AP_STATE_H_664A4180 */ | 49 | #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() { | |||
| 87 | 87 | ||
| 88 | bool checked = | 88 | bool checked = |
| 89 | AP_HasCheckedGameLocation(location.ap_location_id) || | 89 | AP_HasCheckedGameLocation(location.ap_location_id) || |
| 90 | (location.hunt && AP_HasCheckedHuntPanel(location.ap_location_id)); | 90 | (location.hunt && AP_HasCheckedHuntPanel(location.ap_location_id)) || |
| 91 | (IsLocationWinCondition(location) && AP_HasReachedGoal()); | ||
| 91 | 92 | ||
| 92 | wxBitmap* eye_ptr = checked ? &checked_eye_ : &unchecked_eye_; | 93 | wxBitmap* eye_ptr = checked ? &checked_eye_ : &unchecked_eye_; |
| 93 | 94 | ||
| 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 @@ | |||
| 6 | #include <string> | 6 | #include <string> |
| 7 | #include <string_view> | 7 | #include <string_view> |
| 8 | 8 | ||
| 9 | #include "ap_state.h" | ||
| 10 | #include "game_data.h" | ||
| 11 | |||
| 9 | const std::filesystem::path& GetExecutableDirectory() { | 12 | const std::filesystem::path& GetExecutableDirectory() { |
| 10 | static const std::filesystem::path* executable_directory = []() { | 13 | static const std::filesystem::path* executable_directory = []() { |
| 11 | int length = wai_getExecutablePath(NULL, 0, NULL); | 14 | int length = wai_getExecutablePath(NULL, 0, NULL); |
| @@ -22,3 +25,16 @@ const std::filesystem::path& GetExecutableDirectory() { | |||
| 22 | std::string GetAbsolutePath(std::string_view path) { | 25 | std::string GetAbsolutePath(std::string_view path) { |
| 23 | return (GetExecutableDirectory() / path).string(); | 26 | return (GetExecutableDirectory() / path).string(); |
| 24 | } | 27 | } |
| 28 | |||
| 29 | bool IsLocationWinCondition(const Location& location) { | ||
| 30 | switch (AP_GetVictoryCondition()) { | ||
| 31 | case kTHE_END: | ||
| 32 | return location.ap_location_name == | ||
| 33 | "Orange Tower Seventh Floor - THE END"; | ||
| 34 | case kTHE_MASTER: | ||
| 35 | return location.ap_location_name == | ||
| 36 | "Orange Tower Seventh Floor - THE MASTER"; | ||
| 37 | case kLEVEL_2: | ||
| 38 | return location.ap_location_name == "Second Room - LEVEL 2"; | ||
| 39 | } | ||
| 40 | } | ||
| 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 @@ | |||
| 4 | #include <filesystem> | 4 | #include <filesystem> |
| 5 | #include <string_view> | 5 | #include <string_view> |
| 6 | 6 | ||
| 7 | struct Location; | ||
| 8 | |||
| 7 | const std::filesystem::path& GetExecutableDirectory(); | 9 | const std::filesystem::path& GetExecutableDirectory(); |
| 8 | 10 | ||
| 9 | std::string GetAbsolutePath(std::string_view path); | 11 | std::string GetAbsolutePath(std::string_view path); |
| 10 | 12 | ||
| 13 | bool IsLocationWinCondition(const Location& location); | ||
| 14 | |||
| 11 | #endif /* end of include guard: GLOBAL_H_44945DBA */ | 15 | #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() { | |||
| 118 | bool has_unreachable_unchecked = false; | 118 | bool has_unreachable_unchecked = false; |
| 119 | for (const Location §ion : map_area.locations) { | 119 | for (const Location §ion : map_area.locations) { |
| 120 | bool has_unchecked = false; | 120 | bool has_unchecked = false; |
| 121 | if (AP_IsLocationVisible(section.classification)) { | 121 | if (IsLocationWinCondition(section)) { |
| 122 | has_unchecked = !AP_HasReachedGoal(); | ||
| 123 | } else if (AP_IsLocationVisible(section.classification)) { | ||
| 122 | has_unchecked = !AP_HasCheckedGameLocation(section.ap_location_id); | 124 | has_unchecked = !AP_HasCheckedGameLocation(section.ap_location_id); |
| 123 | } else if (section.hunt && GetTrackerConfig().show_hunt_panels) { | 125 | } else if (section.hunt && GetTrackerConfig().show_hunt_panels) { |
| 124 | has_unchecked = !AP_HasCheckedHuntPanel(section.ap_location_id); | 126 | has_unchecked = !AP_HasCheckedHuntPanel(section.ap_location_id); |
