CSEngine
Loading...
Searching...
No Matches
CSE::SSceneLoader Class Reference

Static Public Member Functions

static SSceneLoadScene (const std::string &path)
 
static bool SaveScene (SScene *scene, std::string path)
 
static bool SavePrefab (SGameObject *root, std::string path)
 

Detailed Description

Definition at line 13 of file SSceneLoader.h.

Member Function Documentation

◆ LoadScene()

SScene * SSceneLoader::LoadScene ( const std::string &  path)
static

Definition at line 111 of file SSceneLoader.cpp.

111 {
112 const XNode* m_root;
113
114 try {
115 m_root = XFILE(path.c_str()).getRoot();
116 }
117 catch (int e) {
118 return nullptr;
119 }
120
121 auto scene = new SScene();
122
123 XNode sce_scene = m_root->getChild("CSESCENE");
124
125 auto node_gameobjects = sce_scene.children;
126 std::vector<NodeKey*> gameobjects;
127 std::vector<ComponentValue*> components;
128
129 for (const auto& node_obj: node_gameobjects) {
130 if (node_obj.name == "gameobject") {
131 ExploringScene(node_obj, gameobjects, components);
132 } else if (node_obj.name == "prefab") {
133 ExploringPrefab(node_obj, gameobjects, components, scene);
134 }
135 }
136
137 LinkingID(gameobjects, scene->GetRoot());
138 LinkingReference(components);
139
140 for (auto gameobj: gameobjects) {
141 SAFE_DELETE(gameobj);
142 }
143
144 for (auto comp: components) {
145 SAFE_DELETE(comp);
146 }
147
148// Exploring(scene->GetRoot());
149 SAFE_DELETE(m_root);
150
151 return scene;
152}
Definition XML.h:77
Definition XML.h:43

◆ SavePrefab()

bool SSceneLoader::SavePrefab ( SGameObject root,
std::string  path 
)
static

Definition at line 85 of file SSceneLoader.cpp.

85 {
86 std::stringstream value;
87
88 value << "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n";
89 value << "<CSEPREFAB version=\"" << "1.0.0" << "\">\n";
90
91 value << GetGameObjectValue(root);
92
93 value << "</CSEPREFAB>";
94
95 return Save(value.str(), std::move(path));
96}

◆ SaveScene()

bool SSceneLoader::SaveScene ( SScene scene,
std::string  path 
)
static

Definition at line 47 of file SSceneLoader.cpp.

47 {
48
49 std::stringstream value;
50 value << "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n";
51 value << "<CSESCENE version = \"" << "1.0.0" << "\">\n";
52
53 value << GetGameObjectValue(scene->GetRoot());
54
55 value << "</CSESCENE>";
56
57 return Save(value.str(), std::move(path));
58}

The documentation for this class was generated from the following files: