diff options
| author | Star Rauchenberger <fefferburbia@gmail.com> | 2023-05-02 17:26:46 -0400 |
|---|---|---|
| committer | Star Rauchenberger <fefferburbia@gmail.com> | 2023-05-02 17:26:46 -0400 |
| commit | 09d67fbad9df92caf2251d36b4abd7979fd27126 (patch) | |
| tree | 287be3da3588f1fb991ffd3212fdfd53a703d6ab /ap_state.cpp | |
| parent | 116ba412079ddf647d19a54d09eb61e67a2f9aac (diff) | |
| download | lingo-ap-tracker-09d67fbad9df92caf2251d36b4abd7979fd27126.tar.gz lingo-ap-tracker-09d67fbad9df92caf2251d36b4abd7979fd27126.tar.bz2 lingo-ap-tracker-09d67fbad9df92caf2251d36b4abd7979fd27126.zip | |
Map + popups reflect checked locations
Diffstat (limited to 'ap_state.cpp')
| -rw-r--r-- | ap_state.cpp | 37 |
1 files changed, 34 insertions, 3 deletions
| diff --git a/ap_state.cpp b/ap_state.cpp index d85fde5..4d7ddb7 100644 --- a/ap_state.cpp +++ b/ap_state.cpp | |||
| @@ -8,6 +8,8 @@ | |||
| 8 | #include <list> | 8 | #include <list> |
| 9 | #include <thread> | 9 | #include <thread> |
| 10 | 10 | ||
| 11 | #include "game_data.h" | ||
| 12 | |||
| 11 | constexpr int AP_MAJOR = 0; | 13 | constexpr int AP_MAJOR = 0; |
| 12 | constexpr int AP_MINOR = 4; | 14 | constexpr int AP_MINOR = 4; |
| 13 | constexpr int AP_REVISION = 0; | 15 | constexpr int AP_REVISION = 0; |
| @@ -64,7 +66,7 @@ void APState::Connect(std::string server, std::string player, | |||
| 64 | std::cout << "Location: " << location_id << std::endl; | 66 | std::cout << "Location: " << location_id << std::endl; |
| 65 | } | 67 | } |
| 66 | 68 | ||
| 67 | tracker_frame_->Refresh(); | 69 | RefreshTracker(); |
| 68 | }); | 70 | }); |
| 69 | 71 | ||
| 70 | apclient_->set_slot_disconnected_handler([&]() { | 72 | apclient_->set_slot_disconnected_handler([&]() { |
| @@ -84,7 +86,7 @@ void APState::Connect(std::string server, std::string player, | |||
| 84 | std::cout << "Item: " << item.item << std::endl; | 86 | std::cout << "Item: " << item.item << std::endl; |
| 85 | } | 87 | } |
| 86 | 88 | ||
| 87 | tracker_frame_->Refresh(); | 89 | RefreshTracker(); |
| 88 | }); | 90 | }); |
| 89 | 91 | ||
| 90 | apclient_->set_slot_connected_handler([&](const nlohmann::json& slot_data) { | 92 | apclient_->set_slot_connected_handler([&](const nlohmann::json& slot_data) { |
| @@ -151,11 +153,40 @@ void APState::Connect(std::string server, std::string player, | |||
| 151 | interval--; | 153 | interval--; |
| 152 | } | 154 | } |
| 153 | 155 | ||
| 154 | if (!connected) { | 156 | if (connected) { |
| 157 | for (const MapArea& map_area : GetGameData().GetMapAreas()) { | ||
| 158 | for (int section_id = 0; section_id < map_area.locations.size(); | ||
| 159 | section_id++) { | ||
| 160 | const Location& location = map_area.locations.at(section_id); | ||
| 161 | |||
| 162 | int64_t ap_id = apclient_->get_location_id(location.ap_location_name); | ||
| 163 | if (ap_id == APClient::INVALID_NAME_ID) { | ||
| 164 | std::cout << "Could not find AP location ID for " | ||
| 165 | << location.ap_location_name << std::endl; | ||
| 166 | } else { | ||
| 167 | ap_id_by_location_id_[{map_area.id, section_id}] = ap_id; | ||
| 168 | } | ||
| 169 | } | ||
| 170 | } | ||
| 171 | |||
| 172 | RefreshTracker(); | ||
| 173 | } else { | ||
| 155 | client_active_ = false; | 174 | client_active_ = false; |
| 156 | } | 175 | } |
| 157 | } | 176 | } |
| 158 | 177 | ||
| 178 | bool APState::HasCheckedGameLocation(int area_id, int section_id) const { | ||
| 179 | std::tuple<int, int> location_key = {area_id, section_id}; | ||
| 180 | |||
| 181 | if (ap_id_by_location_id_.count(location_key)) { | ||
| 182 | return checked_locations_.count(ap_id_by_location_id_.at(location_key)); | ||
| 183 | } else { | ||
| 184 | return false; | ||
| 185 | } | ||
| 186 | } | ||
| 187 | |||
| 188 | void APState::RefreshTracker() { tracker_frame_->UpdateIndicators(); } | ||
| 189 | |||
| 159 | APState& GetAPState() { | 190 | APState& GetAPState() { |
| 160 | static APState* instance = new APState(); | 191 | static APState* instance = new APState(); |
| 161 | return *instance; | 192 | return *instance; |
