This commit is contained in:
2023-06-23 16:33:53 -07:00
parent b1f16c80cf
commit a17cc8e30c
11 changed files with 50 additions and 91 deletions

View File

@ -10,56 +10,4 @@
<QuadMeshHost xy0="-0.78236397748, 1" xy1="0.78236397748, -1" />
<SimpleTexturedMaterial ref="bodyMaterial" />
</item>
<asset type="texture" name="texture_eth_face_day_anger" ref="faceDayAnger" />
<asset type="texture" name="texture_eth_face_day_confused" ref="faceDayConfused" />
<asset type="texture" name="texture_eth_face_day_eyeroll" ref="faceDayEyeroll" />
<asset type="texture" name="texture_eth_face_day_fear" ref="faceDayFear" />
<asset type="texture" name="texture_eth_face_day_happy" ref="faceDayHappy" />
<asset type="texture" name="texture_eth_face_day_haughty" ref="faceDayHaughty" />
<asset type="texture" name="texture_eth_face_day_neutral" ref="faceDayNeutral" />
<asset type="texture" name="texture_eth_face_day_sad" ref="faceDaySad" />
<asset type="texture" name="texture_eth_face_day_surprised" ref="faceDaySurprised" />
<asset type="texture" name="texture_eth_pose_day_back" ref="poseDayBack" />
<asset type="texture" name="texture_eth_pose_day_cross" ref="poseDayCross" />
<asset type="texture" name="texture_eth_pose_day_front" ref="poseDayFront" />
<asset type="texture" name="texture_eth_pose_day_hips" ref="poseDayHips" />
<asset type="texture" name="texture_eth_pose_day_neutral" ref="poseDayNeutral" />
<code type="properties">
StateProperty&lt;int32_t&gt; faceTile;
StateProperty&lt;int32_t&gt; poseTile;
</code>
<code type="init">
faceTile = 0;
poseTile = 0;
useEffect([&amp;]{
faceMaterial->texture = &amp;(
faceTile == 0 ? faceDayHappy->texture :
faceTile == 1 ? faceDayAnger->texture :
faceTile == 2 ? faceDayConfused->texture :
faceTile == 3 ? faceDayEyeroll->texture :
faceTile == 4 ? faceDayFear->texture :
faceTile == 5 ? faceDayHaughty->texture :
faceTile == 6 ? faceDayNeutral->texture :
faceTile == 7 ? faceDaySad->texture :
faceTile == 8 ? faceDaySurprised->texture :
faceDayHappy->texture
);
}, faceTile)();
useEffect([&amp;]{
bodyMaterial->texture = &amp;(
poseTile == 0 ? poseDayBack->texture :
poseTile == 1 ? poseDayCross->texture :
poseTile == 2 ? poseDayFront->texture :
poseTile == 3 ? poseDayHips->texture :
poseTile == 4 ? poseDayNeutral->texture :
poseDayBack->texture
);
}, poseTile)();
</code>
</prefab>

View File

@ -4,4 +4,4 @@
# https://opensource.org/licenses/MIT
tool_scene(${CMAKE_CURRENT_LIST_DIR}/SceneBase.xml)
tool_vnscene(${CMAKE_CURRENT_LIST_DIR}/Scene1Prologue0.xml)
# tool_vnscene(${CMAKE_CURRENT_LIST_DIR}/Scene1Prologue0.xml)

View File

@ -1,23 +1,25 @@
<vnscene name="Scene1Prologue" extend="scenes/SceneBase">
<asset type="texture" name="texture_eth_face_day_anger" ref="faceDayAnger" />
<asset type="texture" name="texture_eth_pose_day_back" ref="poseDayBack" />
<events>
<set property="eth->faceMaterial->texture" to="&faceDayAnger->texture" type="Texture*" />
<set property="eth->faceMaterial->texture" to="&faceDayAnger->texture" type="Texture*" />
<set property="eth->faceMaterial->texture" to="&faceDayAnger->texture" type="Texture*" />
<text>
<string lang="en"><font style="italics">There is a bucket.</font></string>
</text>
<set property="eth->faceTile" to="1" type="int32_t" />
<text>
<string lang="en">It sways above your head like the mouth of a god. You are on Angelwood's best stage, and they are cheering for you, calling you their Queen, their Prom Queen.</string>
</text>
<!-- <set property="eth->faceSprite->tile" to="0" type="int32_t" /> -->
<text>
<string lang="en">And you are dead soon.</string>
</text>
<!-- <set property="eth->bodySprite->tile" to="3" type="int32_t" /> -->
<text>
<string lang="en">It's Prom Day. The metal bucket is swaying. Over you. Drenching your white pristine dress in guts and gore red. They aren't cheering anymore. They're gasping. But not screaming: oh, no, not in respectable Angelwood.</string>
</text>

View File

@ -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();
}
};
}

View File

@ -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();

View File

@ -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();", "");

View File

@ -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);

View File

@ -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;
};

View File

@ -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:

View File

@ -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;
}

View File

@ -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 = "";
};