diff options
-rw-r--r-- | assets/subway.yaml | 18 | ||||
-rw-r--r-- | src/ap_state.cpp | 9 | ||||
-rw-r--r-- | src/ap_state.h | 2 | ||||
-rw-r--r-- | src/game_data.cpp | 58 | ||||
-rw-r--r-- | src/game_data.h | 2 | ||||
-rw-r--r-- | src/subway_map.cpp | 12 |
6 files changed, 72 insertions, 29 deletions
diff --git a/assets/subway.yaml b/assets/subway.yaml index 080a139..8c0df38 100644 --- a/assets/subway.yaml +++ b/assets/subway.yaml | |||
@@ -1042,3 +1042,21 @@ | |||
1042 | - pos: [815, 1002] | 1042 | - pos: [815, 1002] |
1043 | room: Challenge Room | 1043 | room: Challenge Room |
1044 | door: Welcome Door | 1044 | door: Welcome Door |
1045 | - pos: [104, 1208] | ||
1046 | special: color_black | ||
1047 | - pos: [104, 1249] | ||
1048 | special: color_red | ||
1049 | - pos: [104, 1290] | ||
1050 | special: color_yellow | ||
1051 | - pos: [104, 1330] | ||
1052 | special: color_blue | ||
1053 | - pos: [104, 1371] | ||
1054 | special: color_purple | ||
1055 | - pos: [104, 1411] | ||
1056 | special: color_orange | ||
1057 | - pos: [104, 1451] | ||
1058 | special: color_green | ||
1059 | - pos: [104, 1491] | ||
1060 | special: color_brown | ||
1061 | - pos: [104, 1531] | ||
1062 | special: color_gray | ||
diff --git a/src/ap_state.cpp b/src/ap_state.cpp index 1e5621d..023bf7f 100644 --- a/src/ap_state.cpp +++ b/src/ap_state.cpp | |||
@@ -228,6 +228,11 @@ struct APState { | |||
228 | return inventory.count(item_id) && inventory.at(item_id) >= quantity; | 228 | return inventory.count(item_id) && inventory.at(item_id) >= quantity; |
229 | } | 229 | } |
230 | 230 | ||
231 | bool HasItemSafe(int item_id, int quantity) { | ||
232 | std::lock_guard state_guard(state_mutex); | ||
233 | return HasItem(item_id, quantity); | ||
234 | } | ||
235 | |||
231 | bool HasAchievement(const std::string& name) { | 236 | bool HasAchievement(const std::string& name) { |
232 | std::lock_guard state_guard(state_mutex); | 237 | std::lock_guard state_guard(state_mutex); |
233 | 238 | ||
@@ -723,6 +728,10 @@ bool AP_HasItem(int item_id, int quantity) { | |||
723 | return GetState().HasItem(item_id, quantity); | 728 | return GetState().HasItem(item_id, quantity); |
724 | } | 729 | } |
725 | 730 | ||
731 | bool AP_HasItemSafe(int item_id, int quantity) { | ||
732 | return GetState().HasItemSafe(item_id, quantity); | ||
733 | } | ||
734 | |||
726 | std::string AP_GetItemName(int item_id) { | 735 | std::string AP_GetItemName(int item_id) { |
727 | return GetState().GetItemName(item_id); | 736 | return GetState().GetItemName(item_id); |
728 | } | 737 | } |
diff --git a/src/ap_state.h b/src/ap_state.h index 298df8c..482c155 100644 --- a/src/ap_state.h +++ b/src/ap_state.h | |||
@@ -63,6 +63,8 @@ bool AP_HasCheckedHuntPanel(int location_id); | |||
63 | // RecalculateReachability, which is only called from the APState thread anyway. | 63 | // RecalculateReachability, which is only called from the APState thread anyway. |
64 | bool AP_HasItem(int item_id, int quantity = 1); | 64 | bool AP_HasItem(int item_id, int quantity = 1); |
65 | 65 | ||
66 | bool AP_HasItemSafe(int item_id, int quantity = 1); | ||
67 | |||
66 | // This doesn't lock the client mutex because it is ONLY to be called from | 68 | // This doesn't lock the client mutex because it is ONLY to be called from |
67 | // RecalculateReachability, which is only called from within a client callback | 69 | // RecalculateReachability, which is only called from within a client callback |
68 | // anyway. | 70 | // anyway. |
diff --git a/src/game_data.cpp b/src/game_data.cpp index a4a441d..7c221e9 100644 --- a/src/game_data.cpp +++ b/src/game_data.cpp | |||
@@ -12,32 +12,6 @@ | |||
12 | 12 | ||
13 | namespace { | 13 | namespace { |
14 | 14 | ||
15 | LingoColor GetColorForString(const std::string &str) { | ||
16 | if (str == "black") { | ||
17 | return LingoColor::kBlack; | ||
18 | } else if (str == "red") { | ||
19 | return LingoColor::kRed; | ||
20 | } else if (str == "blue") { | ||
21 | return LingoColor::kBlue; | ||
22 | } else if (str == "yellow") { | ||
23 | return LingoColor::kYellow; | ||
24 | } else if (str == "orange") { | ||
25 | return LingoColor::kOrange; | ||
26 | } else if (str == "green") { | ||
27 | return LingoColor::kGreen; | ||
28 | } else if (str == "gray") { | ||
29 | return LingoColor::kGray; | ||
30 | } else if (str == "brown") { | ||
31 | return LingoColor::kBrown; | ||
32 | } else if (str == "purple") { | ||
33 | return LingoColor::kPurple; | ||
34 | } else { | ||
35 | TrackerLog(fmt::format("Invalid color: {}", str)); | ||
36 | |||
37 | return LingoColor::kNone; | ||
38 | } | ||
39 | } | ||
40 | |||
41 | struct GameData { | 15 | struct GameData { |
42 | std::vector<Room> rooms_; | 16 | std::vector<Room> rooms_; |
43 | std::vector<Door> doors_; | 17 | std::vector<Door> doors_; |
@@ -84,7 +58,7 @@ struct GameData { | |||
84 | ids_config["special_items"][color_name]) { | 58 | ids_config["special_items"][color_name]) { |
85 | std::string input_name = color_name; | 59 | std::string input_name = color_name; |
86 | input_name[0] = std::tolower(input_name[0]); | 60 | input_name[0] = std::tolower(input_name[0]); |
87 | ap_id_by_color_[GetColorForString(input_name)] = | 61 | ap_id_by_color_[GetLingoColorForString(input_name)] = |
88 | ids_config["special_items"][color_name].as<int>(); | 62 | ids_config["special_items"][color_name].as<int>(); |
89 | } else { | 63 | } else { |
90 | TrackerLog(fmt::format("Missing AP item ID for color {}", color_name)); | 64 | TrackerLog(fmt::format("Missing AP item ID for color {}", color_name)); |
@@ -181,12 +155,12 @@ struct GameData { | |||
181 | 155 | ||
182 | if (panel_it.second["colors"]) { | 156 | if (panel_it.second["colors"]) { |
183 | if (panel_it.second["colors"].IsScalar()) { | 157 | if (panel_it.second["colors"].IsScalar()) { |
184 | panels_[panel_id].colors.push_back(GetColorForString( | 158 | panels_[panel_id].colors.push_back(GetLingoColorForString( |
185 | panel_it.second["colors"].as<std::string>())); | 159 | panel_it.second["colors"].as<std::string>())); |
186 | } else { | 160 | } else { |
187 | for (const auto &color_node : panel_it.second["colors"]) { | 161 | for (const auto &color_node : panel_it.second["colors"]) { |
188 | panels_[panel_id].colors.push_back( | 162 | panels_[panel_id].colors.push_back( |
189 | GetColorForString(color_node.as<std::string>())); | 163 | GetLingoColorForString(color_node.as<std::string>())); |
190 | } | 164 | } |
191 | } | 165 | } |
192 | } | 166 | } |
@@ -1010,3 +984,29 @@ std::optional<int> GD_GetSubwayItemForPainting(const std::string &painting_id) { | |||
1010 | int GD_GetSubwayItemForSunwarp(const SubwaySunwarp &sunwarp) { | 984 | int GD_GetSubwayItemForSunwarp(const SubwaySunwarp &sunwarp) { |
1011 | return GetState().subway_item_by_sunwarp_.at(sunwarp); | 985 | return GetState().subway_item_by_sunwarp_.at(sunwarp); |
1012 | } | 986 | } |
987 | |||
988 | LingoColor GetLingoColorForString(const std::string &str) { | ||
989 | if (str == "black") { | ||
990 | return LingoColor::kBlack; | ||
991 | } else if (str == "red") { | ||
992 | return LingoColor::kRed; | ||
993 | } else if (str == "blue") { | ||
994 | return LingoColor::kBlue; | ||
995 | } else if (str == "yellow") { | ||
996 | return LingoColor::kYellow; | ||
997 | } else if (str == "orange") { | ||
998 | return LingoColor::kOrange; | ||
999 | } else if (str == "green") { | ||
1000 | return LingoColor::kGreen; | ||
1001 | } else if (str == "gray") { | ||
1002 | return LingoColor::kGray; | ||
1003 | } else if (str == "brown") { | ||
1004 | return LingoColor::kBrown; | ||
1005 | } else if (str == "purple") { | ||
1006 | return LingoColor::kPurple; | ||
1007 | } else { | ||
1008 | TrackerLog(fmt::format("Invalid color: {}", str)); | ||
1009 | |||
1010 | return LingoColor::kNone; | ||
1011 | } | ||
1012 | } | ||
diff --git a/src/game_data.h b/src/game_data.h index 24760de..0facd12 100644 --- a/src/game_data.h +++ b/src/game_data.h | |||
@@ -189,4 +189,6 @@ const SubwayItem& GD_GetSubwayItem(int id); | |||
189 | std::optional<int> GD_GetSubwayItemForPainting(const std::string& painting_id); | 189 | std::optional<int> GD_GetSubwayItemForPainting(const std::string& painting_id); |
190 | int GD_GetSubwayItemForSunwarp(const SubwaySunwarp& sunwarp); | 190 | int GD_GetSubwayItemForSunwarp(const SubwaySunwarp& sunwarp); |
191 | 191 | ||
192 | LingoColor GetLingoColorForString(const std::string& str); | ||
193 | |||
192 | #endif /* end of include guard: GAME_DATA_H_9C42AC51 */ | 194 | #endif /* end of include guard: GAME_DATA_H_9C42AC51 */ |
diff --git a/src/subway_map.cpp b/src/subway_map.cpp index 94292fd..55ac411 100644 --- a/src/subway_map.cpp +++ b/src/subway_map.cpp | |||
@@ -551,6 +551,18 @@ void SubwayMap::Redraw() { | |||
551 | brush_color = wxGREEN_BRUSH; | 551 | brush_color = wxGREEN_BRUSH; |
552 | } else if (subway_item.special == "starting_room_overhead") { | 552 | } else if (subway_item.special == "starting_room_overhead") { |
553 | // Do not draw. | 553 | // Do not draw. |
554 | } else if (AP_IsColorShuffle() && subway_item.special && | ||
555 | subway_item.special->starts_with("color_")) { | ||
556 | std::string color_name = subway_item.special->substr(6); | ||
557 | LingoColor lingo_color = GetLingoColorForString(color_name); | ||
558 | int color_item_id = GD_GetItemIdForColor(lingo_color); | ||
559 | |||
560 | draw_type = ItemDrawType::kBox; | ||
561 | if (AP_HasItemSafe(color_item_id)) { | ||
562 | brush_color = wxGREEN_BRUSH; | ||
563 | } else { | ||
564 | brush_color = wxRED_BRUSH; | ||
565 | } | ||
554 | } else if (subway_item.special == "sun_painting") { | 566 | } else if (subway_item.special == "sun_painting") { |
555 | if (!AP_IsPilgrimageEnabled()) { | 567 | if (!AP_IsPilgrimageEnabled()) { |
556 | draw_type = ItemDrawType::kOwl; | 568 | draw_type = ItemDrawType::kOwl; |