Added code support, not great but hey it works
This commit is contained in:
@ -10,6 +10,7 @@ set(
|
||||
${DAWN_TOOL_SOURCES}
|
||||
${D}/SceneItemGenerator.cpp
|
||||
${D}/SceneAssetGenerator.cpp
|
||||
${D}/SceneCodeGenerator.cpp
|
||||
${D}/SceneGenerator.cpp
|
||||
${D}/SceneItemComponentGenerator.cpp
|
||||
|
||||
|
28
src/dawntools/util/generator/SceneCodeGenerator.cpp
Normal file
28
src/dawntools/util/generator/SceneCodeGenerator.cpp
Normal file
@ -0,0 +1,28 @@
|
||||
// Copyright (c) 2023 Dominic Masters
|
||||
//
|
||||
// This software is released under the MIT License.
|
||||
// https://opensource.org/licenses/MIT
|
||||
|
||||
#include "SceneCodeGenerator.hpp"
|
||||
|
||||
using namespace Dawn;
|
||||
|
||||
void SceneCodeGenerator::generate(
|
||||
std::vector<std::string> *publicProperties,
|
||||
std::vector<std::string> *initBody,
|
||||
struct SceneCode *code,
|
||||
std::string tabs
|
||||
) {
|
||||
switch(code->codeType) {
|
||||
case SCENE_CODE_TYPE_PROPERTIES:
|
||||
line(publicProperties, code->code, "");
|
||||
break;
|
||||
|
||||
case SCENE_CODE_TYPE_INIT:
|
||||
line(initBody, code->code, "");
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
20
src/dawntools/util/generator/SceneCodeGenerator.hpp
Normal file
20
src/dawntools/util/generator/SceneCodeGenerator.hpp
Normal file
@ -0,0 +1,20 @@
|
||||
// Copyright (c) 2023 Dominic Masters
|
||||
//
|
||||
// This software is released under the MIT License.
|
||||
// https://opensource.org/licenses/MIT
|
||||
|
||||
#pragma once
|
||||
#include "util/parser/SceneCodeParser.hpp"
|
||||
#include "util/CodeGen.hpp"
|
||||
|
||||
namespace Dawn {
|
||||
class SceneCodeGenerator : public CodeGen {
|
||||
public:
|
||||
static void generate(
|
||||
std::vector<std::string> *publicProperties,
|
||||
std::vector<std::string> *initBody,
|
||||
struct SceneCode *code,
|
||||
std::string tabs
|
||||
);
|
||||
};
|
||||
}
|
@ -76,4 +76,16 @@ void SceneGenerator::generate(
|
||||
|
||||
// Seal methods
|
||||
line(&methodAssets.body, "return assets;", "");
|
||||
|
||||
// Code
|
||||
auto itCode = scene->code.begin();
|
||||
while(itCode != scene->code.end()) {
|
||||
SceneCodeGenerator::generate(
|
||||
&classInfo.publicProperties,
|
||||
&methodInit.body,
|
||||
&(*itCode),
|
||||
""
|
||||
);
|
||||
++itCode;
|
||||
}
|
||||
}
|
@ -122,4 +122,16 @@ void SceneItemGenerator::generate(
|
||||
if(!parentRef.empty()) {
|
||||
line(initBody, name + "->transform.setParent(&"+parentRef+"->transform);", "");
|
||||
}
|
||||
|
||||
// Code
|
||||
auto itCode = item->code.begin();
|
||||
while(itCode != item->code.end()) {
|
||||
SceneCodeGenerator::generate(
|
||||
publicProperties,
|
||||
initBody,
|
||||
&(*itCode),
|
||||
""
|
||||
);
|
||||
++itCode;
|
||||
}
|
||||
}
|
@ -7,6 +7,7 @@
|
||||
#include "SceneItemComponentGenerator.hpp"
|
||||
#include "SceneAssetGenerator.hpp"
|
||||
#include "util/parser/SceneItemParser.hpp"
|
||||
#include "util/generator/SceneCodeGenerator.hpp"
|
||||
|
||||
namespace Dawn {
|
||||
class SceneItemGenerator : public CodeGen {
|
||||
|
Reference in New Issue
Block a user