summary refs log tree commit diff stats
path: root/tools/util/godot_scene.h
diff options
context:
space:
mode:
authorStar Rauchenberger <fefferburbia@gmail.com>2025-08-18 12:56:13 -0400
committerStar Rauchenberger <fefferburbia@gmail.com>2025-08-18 12:56:13 -0400
commit1ac21d4a67ddd211fda841aa6e368bc2cf52a3d6 (patch)
treebdcf651c156c27982e37bddb7cb7e0b09aa90d5a /tools/util/godot_scene.h
parent15b8794bbe80be0bcf1f482674455efe002cec2c (diff)
downloadlingo2-archipelago-1ac21d4a67ddd211fda841aa6e368bc2cf52a3d6.tar.gz
lingo2-archipelago-1ac21d4a67ddd211fda841aa6e368bc2cf52a3d6.tar.bz2
lingo2-archipelago-1ac21d4a67ddd211fda841aa6e368bc2cf52a3d6.zip
Validate that nodes in game files are used
You can now also list out nodes that you are explicitly not mapping out. The current state of the repo does produce some warnings when the validator is run and they're either endings, paintings that I'm not sure what to do with yet, and weird proxy stuff I'm not sure how to handle yet.
Diffstat (limited to 'tools/util/godot_scene.h')
-rw-r--r--tools/util/godot_scene.h67
1 files changed, 67 insertions, 0 deletions
diff --git a/tools/util/godot_scene.h b/tools/util/godot_scene.h new file mode 100644 index 0000000..529e38e --- /dev/null +++ b/tools/util/godot_scene.h
@@ -0,0 +1,67 @@
1#ifndef TOOLS_UTIL_TSCN_H_
2#define TOOLS_UTIL_TSCN_H_
3
4#include <absl/strings/string_view.h>
5
6#include <map>
7#include <memory>
8#include <string>
9#include <string_view>
10#include <variant>
11
12namespace com::fourisland::lingo2_archipelago {
13
14struct GodotExtResource {
15 std::string type;
16 std::string path;
17};
18
19struct GodotExtResourceRef {
20 std::string id;
21};
22
23using GodotInstanceType = std::variant<std::monostate, GodotExtResourceRef>;
24
25class GodotNode {
26 public:
27 GodotNode(std::string name, GodotInstanceType instance_type)
28 : name_(std::move(name)), instance_type_(std::move(instance_type)) {}
29
30 const std::string& GetName() const { return name_; }
31
32 const GodotInstanceType& GetInstanceType() const { return instance_type_; }
33
34 const GodotNode* GetParent() const { return parent_; }
35 GodotNode* GetParent() { return parent_; }
36
37 std::string GetPath() const;
38
39 void AddChild(GodotNode& child);
40
41 const GodotNode* GetNode(absl::string_view path) const;
42 GodotNode* GetNode(absl::string_view path);
43
44 const std::map<std::string, GodotNode*> GetChildren() const {
45 return children_;
46 }
47
48 private:
49 std::string name_;
50 GodotInstanceType instance_type_;
51
52 GodotNode* parent_ = nullptr;
53 std::map<std::string, GodotNode*> children_;
54};
55
56class GodotScene {
57 public:
58 virtual const GodotExtResource* GetExtResource(
59 const std::string& id) const = 0;
60 virtual const GodotNode& GetRoot() const = 0;
61};
62
63std::unique_ptr<GodotScene> ReadGodotSceneFromFile(const std::string& path);
64
65} // namespace com::fourisland::lingo2_archipelago
66
67#endif /* TOOLS_UTIL_TSCN_H_ */