diff options
Diffstat (limited to 'tools/util/godot_scene.h')
| -rw-r--r-- | tools/util/godot_scene.h | 57 |
1 files changed, 57 insertions, 0 deletions
| diff --git a/tools/util/godot_scene.h b/tools/util/godot_scene.h new file mode 100644 index 0000000..17f3f50 --- /dev/null +++ b/tools/util/godot_scene.h | |||
| @@ -0,0 +1,57 @@ | |||
| 1 | #ifndef TOOLS_UTIL_TSCN_H_ | ||
| 2 | #define TOOLS_UTIL_TSCN_H_ | ||
| 3 | |||
| 4 | #include <map> | ||
| 5 | #include <memory> | ||
| 6 | #include <string> | ||
| 7 | #include <utility> | ||
| 8 | #include <variant> | ||
| 9 | #include <vector> | ||
| 10 | |||
| 11 | namespace com::fourisland::lingo2_archipelago { | ||
| 12 | |||
| 13 | struct GodotExtResource { | ||
| 14 | std::string type; | ||
| 15 | std::string path; | ||
| 16 | }; | ||
| 17 | |||
| 18 | struct GodotExtResourceRef { | ||
| 19 | std::string id; | ||
| 20 | }; | ||
| 21 | |||
| 22 | using GodotInstanceType = std::variant<std::monostate, GodotExtResourceRef>; | ||
| 23 | |||
| 24 | struct GodotNode { | ||
| 25 | std::string name; | ||
| 26 | std::string parent; | ||
| 27 | GodotInstanceType instance_type; | ||
| 28 | |||
| 29 | std::string GetPath() const; | ||
| 30 | }; | ||
| 31 | |||
| 32 | class GodotScene { | ||
| 33 | public: | ||
| 34 | GodotScene(std::map<std::string, GodotExtResource> ext_resources, | ||
| 35 | std::vector<GodotNode> nodes) | ||
| 36 | : ext_resources_(std::move(ext_resources)), nodes_(std::move(nodes)) {} | ||
| 37 | |||
| 38 | const GodotExtResource* GetExtResource(const std::string& id) const { | ||
| 39 | auto it = ext_resources_.find(id); | ||
| 40 | if (it != ext_resources_.end()) { | ||
| 41 | return &it->second; | ||
| 42 | } else { | ||
| 43 | return nullptr; | ||
| 44 | } | ||
| 45 | } | ||
| 46 | const std::vector<GodotNode>& GetNodes() const { return nodes_; } | ||
| 47 | |||
| 48 | private: | ||
| 49 | std::map<std::string, GodotExtResource> ext_resources_; | ||
| 50 | std::vector<GodotNode> nodes_; | ||
| 51 | }; | ||
| 52 | |||
| 53 | GodotScene ReadGodotSceneFromFile(const std::string& path); | ||
| 54 | |||
| 55 | } // namespace com::fourisland::lingo2_archipelago | ||
| 56 | |||
| 57 | #endif /* TOOLS_UTIL_TSCN_H_ */ | ||
