stuck
This commit is contained in:
@ -4,24 +4,20 @@
|
||||
// https://opensource.org/licenses/MIT
|
||||
|
||||
#pragma once
|
||||
#include "VNAnimateEvent.hpp"
|
||||
#include "VNEvent.hpp"
|
||||
|
||||
namespace Dawn {
|
||||
template<typename T>
|
||||
class VNSetEvent : public VNAnimateEvent<T> {
|
||||
template<class T>
|
||||
class VNSetEvent : public VNEvent {
|
||||
public:
|
||||
StateProperty<T> *modifies = nullptr;
|
||||
T *modifies = nullptr;
|
||||
T value;
|
||||
|
||||
protected:
|
||||
void onStart() override {
|
||||
assertNotNull(this->modifies);
|
||||
this->from = modifies->getValue();
|
||||
|
||||
VNAnimateEvent<T>::onStart();
|
||||
}
|
||||
|
||||
void setValue(T value) override {
|
||||
modifies->setValue(value);
|
||||
*modifies = value;
|
||||
this->next();
|
||||
}
|
||||
};
|
||||
}
|
@ -14,13 +14,15 @@ void SceneGenerator::generate(
|
||||
struct MethodGenInfo &methodInit
|
||||
) {
|
||||
assertNotNull(scene);
|
||||
|
||||
std::map<std::string, std::string> assetMap;
|
||||
int32_t assetNumber = 0;
|
||||
std::string baseClassName = "Scene";
|
||||
|
||||
classInfo.clazz = scene->name;
|
||||
classInfo.constructorArgs = "DawnGame *game";
|
||||
classInfo.extendArgs = "game";
|
||||
|
||||
std::string baseClassName = "Scene";
|
||||
|
||||
// Determine extends
|
||||
if(scene->extend.empty()) {
|
||||
classInfo.includes.push_back("scene/Scene.hpp");
|
||||
@ -39,7 +41,7 @@ void SceneGenerator::generate(
|
||||
methodAssets.name = "getRequiredAssets";
|
||||
methodAssets.isOverride = true;
|
||||
methodAssets.type = "std::vector<Asset*>";
|
||||
line(&methodAssets.body, "auto assMan = &this->game->assetManager;", "");
|
||||
line(&methodAssets.body, "auto man = &this->game->assetManager;", "");
|
||||
|
||||
methodInit.name = "stage";
|
||||
methodInit.isOverride = true;
|
||||
@ -51,11 +53,26 @@ void SceneGenerator::generate(
|
||||
line(&methodInit.body, baseClassName + "::stage();", "");
|
||||
}
|
||||
|
||||
// Scene assets
|
||||
line(&methodInit.body, "auto man = &this->game->assetManager;", "");
|
||||
|
||||
auto itAssets = scene->assets.begin();
|
||||
while(itAssets != scene->assets.end()) {
|
||||
SceneAssetGenerator::generate(
|
||||
assetMap,
|
||||
assetNumber,
|
||||
&classInfo.publicProperties,
|
||||
&methodInit.body,
|
||||
&methodAssets.body,
|
||||
&(*itAssets),
|
||||
""
|
||||
);
|
||||
++itAssets;
|
||||
}
|
||||
|
||||
// Generate
|
||||
int32_t assetNumber = 0;
|
||||
int32_t childNumber = 0;
|
||||
int32_t componentNumber = 0;
|
||||
std::map<std::string, std::string> assetMap;
|
||||
std::vector<struct SceneItemComponent> componentsUnused;
|
||||
|
||||
auto itDeps = scene->dependencies.begin();
|
||||
|
@ -118,7 +118,7 @@ void SceneItemGenerator::generate(
|
||||
// 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));", "");
|
||||
line(assetBody, "vectorAppend(&assets, " + prefabName + "::getRequiredAssets(man));", "");
|
||||
} else {
|
||||
// Not a prefab, init empty child.
|
||||
line(initBody, (item->ref.empty() ? "auto " : "") + name + " = " + sceneRef + "->createSceneItem();", "");
|
||||
|
@ -35,8 +35,14 @@ int32_t SceneParser::onParse(
|
||||
auto itChildren = node->children.begin();
|
||||
while(itChildren != node->children.end()) {
|
||||
Xml *child = *itChildren;
|
||||
|
||||
if(child->node == "item") {
|
||||
|
||||
if(child->node == "asset") {
|
||||
struct SceneAsset asset;
|
||||
auto ret = (SceneAssetParser()).parse(child, &asset, error);
|
||||
if(ret != 0) return ret;
|
||||
out->assets.push_back(asset);
|
||||
|
||||
} else if(child->node == "item") {
|
||||
struct SceneItem item;
|
||||
item.registry = out->registry;
|
||||
ret = (SceneItemParser()).parse(child, &item, error);
|
||||
|
@ -13,6 +13,7 @@ namespace Dawn {
|
||||
std::string extend;
|
||||
std::vector<struct SceneItem> items;
|
||||
std::vector<struct SceneCode> code;
|
||||
std::vector<struct SceneAsset> assets;
|
||||
struct SceneItemComponentRegistry *registry;
|
||||
std::vector<struct SceneItemDependency> dependencies;
|
||||
};
|
||||
|
@ -39,9 +39,7 @@ void VNSceneGen::test(
|
||||
initType = "VNSetEvent<" + event->set.type + ">";
|
||||
toInclude = "games/vn/events/VNSetEvent.hpp";
|
||||
line(&afterLines, eventName + "->modifies = &" + event->set.property + ";", "");
|
||||
line(&afterLines, eventName + "->to = " + event->set.to + ";", "");
|
||||
if(event->set.from != "") line(&afterLines, eventName + "->from = " + event->set.from + ";", "");
|
||||
if(event->set.duration != "") line(&afterLines, eventName + "->duration = " + event->set.duration + ";", "");
|
||||
line(&afterLines, eventName + "->value = " + event->set.to + ";", "");
|
||||
break;
|
||||
|
||||
case VN_SCENE_EVENT_TYPE_WAIT:
|
||||
|
@ -14,10 +14,7 @@ std::vector<std::string> VNSetEventParser::getRequiredAttributes() {
|
||||
std::map<std::string, std::string> VNSetEventParser::getOptionalAttributes() {
|
||||
return {
|
||||
{ "to", "" },
|
||||
{ "value", "" },
|
||||
{ "from", "" },
|
||||
{ "duration", "" },
|
||||
{ "curve", "" }
|
||||
{ "value", "" }
|
||||
};
|
||||
}
|
||||
|
||||
@ -38,8 +35,5 @@ int32_t VNSetEventParser::onParse(
|
||||
|
||||
out->type = values["type"];
|
||||
out->property = values["property"];
|
||||
out->from = values["from"];
|
||||
out->duration = values["duration"];
|
||||
out->curve = values["curve"];
|
||||
return 0;
|
||||
}
|
@ -10,9 +10,6 @@ namespace Dawn {
|
||||
struct VNSetEvent {
|
||||
std::string property = "";
|
||||
std::string to = "";
|
||||
std::string from = "";
|
||||
std::string duration = "";
|
||||
std::string curve = "";
|
||||
std::string type = "";
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user