Added a great scene generator
This commit is contained in:
@ -17,23 +17,42 @@ void SceneItemGenerator::generate(
|
||||
std::vector<std::string> *initBody,
|
||||
std::vector<std::string> *assetBody,
|
||||
std::string parentRef,
|
||||
std::string sceneRef,
|
||||
struct SceneItem *item,
|
||||
std::string tabs
|
||||
) {
|
||||
auto name = "itm" + std::to_string(childNumber++);
|
||||
// Determine interface
|
||||
std::string name = "itm" + std::to_string(childNumber++);
|
||||
std::string itemType = "SceneItem";
|
||||
|
||||
if(item->ref == "this") {
|
||||
name = item->ref;
|
||||
} else {
|
||||
bool_t init = true;
|
||||
if(item->ref.size() > 0) {
|
||||
init = false;
|
||||
name = item->ref;
|
||||
if(item->ref != "this") {
|
||||
line(publicProperties, "SceneItemComponent *" + name + " = nullptr;", "");
|
||||
// Determine name
|
||||
if(!item->ref.empty()) name = item->ref;
|
||||
|
||||
// Initialize, either prefab or created.
|
||||
if(!item->prefab.empty()) {
|
||||
// Determine prefab name, type and include
|
||||
std::string prefabName = item->prefab;
|
||||
if(prefabName.find("/") != std::string::npos) {
|
||||
prefabName = prefabName.substr(prefabName.find_last_of("/") + 1);
|
||||
}
|
||||
itemType = prefabName;
|
||||
|
||||
// Create prefab
|
||||
includes.push_back(item->prefab + ".hpp");
|
||||
line(initBody, (item->ref.empty() ? "auto " : "") + name + " = " + prefabName + "::create(" + sceneRef + ");", "");
|
||||
line(assetBody, "vectorAppend(&assets, " + prefabName + "::getRequiredAssets(assMan));", "");
|
||||
} else {
|
||||
// Not a prefab, init empty child.
|
||||
line(initBody, (item->ref.empty() ? "auto " : "") + name + " = " + sceneRef + "->createSceneItem();", "");
|
||||
}
|
||||
|
||||
// Property/Ref defintion
|
||||
if(!item->ref.empty() && item->ref != "this") {
|
||||
line(publicProperties, itemType + " *" + name + " = nullptr;", "");
|
||||
}
|
||||
line(initBody, (init ? "auto " : "") + name + " = scene->createSceneItem();", "");
|
||||
}
|
||||
|
||||
// Process extra properties
|
||||
@ -88,6 +107,7 @@ void SceneItemGenerator::generate(
|
||||
initBody,
|
||||
assetBody,
|
||||
name,
|
||||
sceneRef,
|
||||
&(*itChildren),
|
||||
""
|
||||
);
|
||||
|
@ -21,6 +21,7 @@ namespace Dawn {
|
||||
std::vector<std::string> *initBody,
|
||||
std::vector<std::string> *assetBody,
|
||||
std::string parentRef,
|
||||
std::string sceneRef,
|
||||
struct SceneItem *item,
|
||||
std::string tabs
|
||||
);
|
||||
|
Reference in New Issue
Block a user