Moved C++ tools out
This commit is contained in:
@ -0,0 +1,43 @@
|
||||
// Copyright (c) 2023 Dominic Masters
|
||||
//
|
||||
// This software is released under the MIT License.
|
||||
// https://opensource.org/licenses/MIT
|
||||
|
||||
#include "SceneItemComponentGenerator.hpp"
|
||||
|
||||
using namespace Dawn;
|
||||
|
||||
void SceneItemComponentGenerator::generate(
|
||||
std::map<std::string, std::string> &assetMap,
|
||||
int32_t &componentNumber,
|
||||
std::vector<std::string> &includes,
|
||||
std::string itemRef,
|
||||
std::vector<std::string> *publicProperties,
|
||||
std::vector<std::string> *initBody,
|
||||
struct SceneItemComponent *component,
|
||||
std::string tabs
|
||||
) {
|
||||
auto componentName = "cmp" + std::to_string(componentNumber++);
|
||||
bool_t componentInit = true;
|
||||
if(component->ref.size() > 0) {
|
||||
componentInit = false;
|
||||
componentName = component->ref;
|
||||
line(publicProperties, component->type + " *" + component->ref + " = nullptr;", "");
|
||||
}
|
||||
|
||||
// Initialize
|
||||
line(initBody, (componentInit ? "auto " : "") + componentName + " = " + itemRef + "->addComponent<" + component->type + ">();", "");
|
||||
|
||||
// Now set each property
|
||||
auto itValues = component->values.begin();
|
||||
while(itValues != component->values.end()) {
|
||||
auto value = itValues->second;
|
||||
if(assetMap.find(value) != assetMap.end()) {
|
||||
value = assetMap[value];
|
||||
}
|
||||
line(initBody, componentName + "->" + itValues->first + " = " + value + ";", "");
|
||||
++itValues;
|
||||
}
|
||||
|
||||
includes.push_back(component->include);
|
||||
}
|
Reference in New Issue
Block a user