diff options
Diffstat (limited to 'tools/util')
| -rw-r--r-- | tools/util/godot_scene.cpp | 6 | ||||
| -rw-r--r-- | tools/util/ids_yaml_format.cpp | 60 |
2 files changed, 62 insertions, 4 deletions
| diff --git a/tools/util/godot_scene.cpp b/tools/util/godot_scene.cpp index 1e77c9e..f788d21 100644 --- a/tools/util/godot_scene.cpp +++ b/tools/util/godot_scene.cpp | |||
| @@ -1,10 +1,8 @@ | |||
| 1 | #include "godot_scene.h" | 1 | #include "godot_scene.h" |
| 2 | 2 | ||
| 3 | #include <absl/strings/str_split.h> | ||
| 4 | #include <absl/strings/string_view.h> | ||
| 5 | |||
| 6 | #include <fstream> | 3 | #include <fstream> |
| 7 | #include <sstream> | 4 | #include <sstream> |
| 5 | #include <string_view> | ||
| 8 | #include <variant> | 6 | #include <variant> |
| 9 | 7 | ||
| 10 | namespace com::fourisland::lingo2_archipelago { | 8 | namespace com::fourisland::lingo2_archipelago { |
| @@ -23,7 +21,7 @@ struct Heading { | |||
| 23 | GodotInstanceType instance_type; | 21 | GodotInstanceType instance_type; |
| 24 | }; | 22 | }; |
| 25 | 23 | ||
| 26 | Heading ParseTscnHeading(absl::string_view line) { | 24 | Heading ParseTscnHeading(std::string_view line) { |
| 27 | std::string original_line(line); | 25 | std::string original_line(line); |
| 28 | Heading heading; | 26 | Heading heading; |
| 29 | 27 | ||
| diff --git a/tools/util/ids_yaml_format.cpp b/tools/util/ids_yaml_format.cpp index f72f60e..c23c66b 100644 --- a/tools/util/ids_yaml_format.cpp +++ b/tools/util/ids_yaml_format.cpp | |||
| @@ -56,6 +56,21 @@ IdMappings ReadIdsFromYaml(const std::string& filename) { | |||
| 56 | mastery_it.second.as<uint64_t>(); | 56 | mastery_it.second.as<uint64_t>(); |
| 57 | } | 57 | } |
| 58 | } | 58 | } |
| 59 | |||
| 60 | if (room_it.second["keyholders"]) { | ||
| 61 | for (const auto& keyholder_it : room_it.second["keyholders"]) { | ||
| 62 | (*room_ids.mutable_keyholders())[keyholder_it.first | ||
| 63 | .as<std::string>()] = | ||
| 64 | keyholder_it.second.as<uint64_t>(); | ||
| 65 | } | ||
| 66 | } | ||
| 67 | |||
| 68 | if (room_it.second["ports"]) { | ||
| 69 | for (const auto& port_it : room_it.second["ports"]) { | ||
| 70 | (*room_ids.mutable_ports())[port_it.first.as<std::string>()] = | ||
| 71 | port_it.second.as<uint64_t>(); | ||
| 72 | } | ||
| 73 | } | ||
| 59 | } | 74 | } |
| 60 | } | 75 | } |
| 61 | 76 | ||
| @@ -65,6 +80,10 @@ IdMappings ReadIdsFromYaml(const std::string& filename) { | |||
| 65 | door_it.second.as<uint64_t>(); | 80 | door_it.second.as<uint64_t>(); |
| 66 | } | 81 | } |
| 67 | } | 82 | } |
| 83 | |||
| 84 | if (map_it.second["rte"]) { | ||
| 85 | map_ids.set_rte(map_it.second["rte"].as<uint64_t>()); | ||
| 86 | } | ||
| 68 | } | 87 | } |
| 69 | } | 88 | } |
| 70 | 89 | ||
| @@ -89,6 +108,20 @@ IdMappings ReadIdsFromYaml(const std::string& filename) { | |||
| 89 | } | 108 | } |
| 90 | } | 109 | } |
| 91 | 110 | ||
| 111 | if (document["progressives"]) { | ||
| 112 | for (const auto& prog_it : document["progressives"]) { | ||
| 113 | (*result.mutable_progressives())[prog_it.first.as<std::string>()] = | ||
| 114 | prog_it.second.as<uint64_t>(); | ||
| 115 | } | ||
| 116 | } | ||
| 117 | |||
| 118 | if (document["door_groups"]) { | ||
| 119 | for (const auto& group_it : document["door_groups"]) { | ||
| 120 | (*result.mutable_door_groups())[group_it.first.as<std::string>()] = | ||
| 121 | group_it.second.as<uint64_t>(); | ||
| 122 | } | ||
| 123 | } | ||
| 124 | |||
| 92 | return result; | 125 | return result; |
| 93 | } | 126 | } |
| 94 | 127 | ||
| @@ -117,6 +150,19 @@ void WriteIdsAsYaml(const IdMappings& ids, const std::string& filename) { | |||
| 117 | mastery_id; | 150 | mastery_id; |
| 118 | }); | 151 | }); |
| 119 | 152 | ||
| 153 | OperateOnSortedMap(room_ids.keyholders(), | ||
| 154 | [&room_node](const std::string& keyholder_name, | ||
| 155 | uint64_t keyholder_id) { | ||
| 156 | room_node["keyholders"][keyholder_name] = | ||
| 157 | keyholder_id; | ||
| 158 | }); | ||
| 159 | |||
| 160 | OperateOnSortedMap( | ||
| 161 | room_ids.ports(), | ||
| 162 | [&room_node](const std::string& port_name, uint64_t port_id) { | ||
| 163 | room_node["ports"][port_name] = port_id; | ||
| 164 | }); | ||
| 165 | |||
| 120 | map_node["rooms"][room_name] = std::move(room_node); | 166 | map_node["rooms"][room_name] = std::move(room_node); |
| 121 | }); | 167 | }); |
| 122 | 168 | ||
| @@ -126,6 +172,10 @@ void WriteIdsAsYaml(const IdMappings& ids, const std::string& filename) { | |||
| 126 | map_node["doors"][door_name] = door_id; | 172 | map_node["doors"][door_name] = door_id; |
| 127 | }); | 173 | }); |
| 128 | 174 | ||
| 175 | if (map_ids.has_rte()) { | ||
| 176 | map_node["rte"] = map_ids.rte(); | ||
| 177 | } | ||
| 178 | |||
| 129 | result["maps"][map_name] = std::move(map_node); | 179 | result["maps"][map_name] = std::move(map_node); |
| 130 | }); | 180 | }); |
| 131 | 181 | ||
| @@ -144,6 +194,16 @@ void WriteIdsAsYaml(const IdMappings& ids, const std::string& filename) { | |||
| 144 | result["special"][special_name] = special_id; | 194 | result["special"][special_name] = special_id; |
| 145 | }); | 195 | }); |
| 146 | 196 | ||
| 197 | OperateOnSortedMap(ids.progressives(), | ||
| 198 | [&result](const std::string& prog_name, uint64_t prog_id) { | ||
| 199 | result["progressives"][prog_name] = prog_id; | ||
| 200 | }); | ||
| 201 | |||
| 202 | OperateOnSortedMap(ids.door_groups(), [&result](const std::string& group_name, | ||
| 203 | uint64_t group_id) { | ||
| 204 | result["door_groups"][group_name] = group_id; | ||
| 205 | }); | ||
| 206 | |||
| 147 | std::ofstream output_stream(filename); | 207 | std::ofstream output_stream(filename); |
| 148 | output_stream << result << std::endl; | 208 | output_stream << result << std::endl; |
| 149 | } | 209 | } |
