about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--area_window.cpp5
-rw-r--r--game_data.cpp64
-rw-r--r--game_data.h3
3 files changed, 65 insertions, 7 deletions
diff --git a/area_window.cpp b/area_window.cpp index b142525..482dcb0 100644 --- a/area_window.cpp +++ b/area_window.cpp
@@ -25,6 +25,11 @@ void AreaWindow::OnPaint(wxPaintEvent& event) {
25 25
26void AreaWindow::OnEnterWindow(wxMouseEvent& event) { 26void AreaWindow::OnEnterWindow(wxMouseEvent& event) {
27 std::cout << GetGameData().GetMapArea(area_id_).name << std::endl; 27 std::cout << GetGameData().GetMapArea(area_id_).name << std::endl;
28 std::cout << "---" << std::endl;
29 for (const Location& loc : GetGameData().GetMapArea(area_id_).locations) {
30 std::cout << loc.name << std::endl;
31 }
32 std::cout << "---" << std::endl;
28} 33}
29 34
30void AreaWindow::Redraw() { 35void AreaWindow::Redraw() {
diff --git a/game_data.cpp b/game_data.cpp index f377e0b..54a01ed 100644 --- a/game_data.cpp +++ b/game_data.cpp
@@ -34,7 +34,7 @@ GameData::GameData() {
34 YAML::Node lingo_config = YAML::LoadFile("assets/LL1.yaml"); 34 YAML::Node lingo_config = YAML::LoadFile("assets/LL1.yaml");
35 YAML::Node areas_config = YAML::LoadFile("assets/areas.yaml"); 35 YAML::Node areas_config = YAML::LoadFile("assets/areas.yaml");
36 36
37 rooms_.reserve(lingo_config.size() + 1); // The +1 is for Menu 37 rooms_.reserve(lingo_config.size() * 2);
38 38
39 for (const auto &room_it : lingo_config) { 39 for (const auto &room_it : lingo_config) {
40 int room_id = AddOrGetRoom(room_it.first.as<std::string>()); 40 int room_id = AddOrGetRoom(room_it.first.as<std::string>());
@@ -183,6 +183,10 @@ GameData::GameData() {
183 door_obj.skip_location = door_it.second["skip_location"].as<bool>(); 183 door_obj.skip_location = door_it.second["skip_location"].as<bool>();
184 } 184 }
185 185
186 if (door_it.second["event"]) {
187 door_obj.skip_location = door_it.second["event"].as<bool>();
188 }
189
186 if (door_it.second["item_name"]) { 190 if (door_it.second["item_name"]) {
187 door_obj.item_name = door_it.second["item_name"].as<std::string>(); 191 door_obj.item_name = door_it.second["item_name"].as<std::string>();
188 } else if (!door_it.second["skip_item"] && !door_it.second["event"]) { 192 } else if (!door_it.second["skip_item"] && !door_it.second["event"]) {
@@ -232,6 +236,52 @@ GameData::GameData() {
232 AddOrGetArea(area_it.second["fold_into"].as<std::string>()); 236 AddOrGetArea(area_it.second["fold_into"].as<std::string>());
233 } 237 }
234 } 238 }
239
240 for (const Panel &panel : panels_) {
241 if (panel.check) {
242 int room_id = panel.room;
243 std::string room_name = rooms_[room_id].name;
244
245 std::string area_name = room_name;
246 if (fold_areas.count(room_name)) {
247 int fold_area_id = fold_areas[room_name];
248 area_name = map_areas_[fold_area_id].name;
249 }
250
251 int area_id = AddOrGetArea(area_name);
252 MapArea &map_area = map_areas_[area_id];
253 // room field should be the original room ID
254 map_area.locations.push_back(
255 {.name = panel.name, .room = panel.room, .panels = {panel.id}});
256 }
257 }
258
259 for (const Door &door : doors_) {
260 if (!door.skip_location) {
261 int room_id = door.room;
262 std::string area_name = rooms_[room_id].name;
263 std::string section_name;
264
265 size_t divider_pos = door.location_name.find(" - ");
266 if (divider_pos == std::string::npos) {
267 section_name = door.location_name;
268 } else {
269 area_name = door.location_name.substr(0, divider_pos);
270 section_name = door.location_name.substr(divider_pos + 3);
271 }
272
273 if (fold_areas.count(area_name)) {
274 int fold_area_id = fold_areas[area_name];
275 area_name = map_areas_[fold_area_id].name;
276 }
277
278 int area_id = AddOrGetArea(area_name);
279 MapArea &map_area = map_areas_[area_id];
280 // room field should be the original room ID
281 map_area.locations.push_back(
282 {.name = section_name, .room = door.room, .panels = door.panels});
283 }
284 }
235} 285}
236 286
237int GameData::AddOrGetRoom(std::string room) { 287int GameData::AddOrGetRoom(std::string room) {
@@ -258,8 +308,10 @@ int GameData::AddOrGetPanel(std::string room, std::string panel) {
258 std::string full_name = room + " - " + panel; 308 std::string full_name = room + " - " + panel;
259 309
260 if (!panel_by_id_.count(full_name)) { 310 if (!panel_by_id_.count(full_name)) {
261 panel_by_id_[full_name] = panels_.size(); 311 int panel_id = panels_.size();
262 panels_.push_back({.name = panel, .room = AddOrGetRoom(room)}); 312 panel_by_id_[full_name] = panel_id;
313 panels_.push_back(
314 {.id = panel_id, .name = panel, .room = AddOrGetRoom(room)});
263 } 315 }
264 316
265 return panel_by_id_[full_name]; 317 return panel_by_id_[full_name];
@@ -267,9 +319,9 @@ int GameData::AddOrGetPanel(std::string room, std::string panel) {
267 319
268int GameData::AddOrGetArea(std::string area) { 320int GameData::AddOrGetArea(std::string area) {
269 if (!area_by_id_.count(area)) { 321 if (!area_by_id_.count(area)) {
270 area_by_id_[area] = map_areas_.size(); 322 int area_id = map_areas_.size();
271 map_areas_.push_back( 323 area_by_id_[area] = area_id;
272 {.id = static_cast<int>(map_areas_.size()), .name = area}); 324 map_areas_.push_back({.id = area_id, .name = area});
273 } 325 }
274 326
275 return area_by_id_[area]; 327 return area_by_id_[area];
diff --git a/game_data.h b/game_data.h index 91b48a5..00d6328 100644 --- a/game_data.h +++ b/game_data.h
@@ -19,6 +19,7 @@ enum class LingoColor {
19}; 19};
20 20
21struct Panel { 21struct Panel {
22 int id;
22 int room; 23 int room;
23 std::string name; 24 std::string name;
24 std::vector<LingoColor> colors; 25 std::vector<LingoColor> colors;
@@ -51,7 +52,7 @@ struct Room {
51 52
52struct Location { 53struct Location {
53 std::string name; 54 std::string name;
54 int location_id; 55 int location_id = -1;
55 int room; 56 int room;
56 std::vector<int> panels; 57 std::vector<int> panels;
57}; 58};