The fruits of my labor

This commit is contained in:
2023-01-20 00:00:36 -08:00
parent 97fd59f28d
commit 3ee07af4db
55 changed files with 563 additions and 459 deletions

Submodule lib/SDL updated: 5d1e6b28d9...7b8f0ba8b7

View File

@ -73,6 +73,8 @@ void RenderPipeline::renderScene(Scene *scene) {
}
void RenderPipeline::renderSceneCamera(Scene *scene, Camera *camera) {
std::vector<struct ShaderPassItem>::iterator itPassItem;
assertNotNull(scene);
assertNotNull(camera);
@ -80,8 +82,12 @@ void RenderPipeline::renderSceneCamera(Scene *scene, Camera *camera) {
// not sending parameters to shaders more than we need.
this->renderId--;
// Get the render target.
auto renderTarget = camera->getRenderTarget();
assertNotNull(renderTarget);
// Get the list of things to render first.
std::vector<struct RenderPipelineItem> pipelineItems;
std::vector<struct ShaderPassItem> shaderPassItems;
// Meshes
auto meshes = scene->findComponents<MeshRenderer>();
@ -89,6 +95,7 @@ void RenderPipeline::renderSceneCamera(Scene *scene, Camera *camera) {
while(itMesh != meshes.end()) {
// Get Mesh
auto mesh = *itMesh;
assertNotNull(mesh);
assertNotNull(mesh->mesh);
// Make sure this mesh has a material
@ -98,62 +105,76 @@ void RenderPipeline::renderSceneCamera(Scene *scene, Camera *camera) {
auto shader = mat->getShader();
assertNotNull(shader);
// Now do each pass.
auto passes = shader->getItemPasses(mesh, mat);
auto itPass = passes.begin();
while(itPass != passes.end()) {
struct RenderPipelineItem item;
item.mesh = mesh;
item.pass = *itPass;
// Now get and validate the pass items for this material/shader
auto materialPassItems = shader->getPassItems(mesh->mesh, mat, camera);
itPassItem = materialPassItems.begin();
while(itPassItem != materialPassItems.end()) {
auto item = *itPassItem;
// Validate the pass
assertNotNull(item.pass.shaderProgram);
// Do we need to get the W Vector?
if(item.pass.needsW) {
assertUnreachable();// TODO: Add distance from camera for W vector.
} else {
item.w = 0;
}
assertNotNull(item.mesh);
assertTrue(item.start >= 0);
assertTrue(item.count > 0 || item.count == -1);
assertNotNull(item.shaderProgram);
// Queue
pipelineItems.push_back(item);
++itPass;
shaderPassItems.push_back(item);
++itPassItem;
}
// Now, for optimization, we bind the global parameters here, once for each
// shader.
if(shader->renderId != this->renderId) {
shader->setGlobalParameters(
camera->projection,
camera->transform->getWorldTransform()
);
shader->renderId = this->renderId;
}
++itMesh;
}
// UI Elements
auto canvases = scene->findComponents<UICanvas>();
auto itCanvas = canvases.begin();
while(itCanvas != canvases.end()) {
auto canvas = *itCanvas;
glm::mat4 model;
glm::mat4 projection;
glm::mat4 view;
// TODO: Get UI stuff here.
switch(canvas->drawType) {
case UI_DRAW_TYPE_WORLD_ABSOLUTE:
projection = camera->projection;
view = camera->transform->getWorldTransform();
model = canvas->transform->getWorldTransform();
break;
case UI_DRAW_TYPE_WORLD_CAMERA_RELATIVE:
projection = glm::ortho(0.0f, renderTarget->getWidth(), renderTarget->getHeight(), 0.0f);
view = glm::mat4(1.0f);
model = canvas->transform->getWorldTransform();
break;
default:
assertUnreachable();
}
auto itChild = canvas->children.begin();
while(itChild != canvas->children.end()) {
vectorAppend(&shaderPassItems, (*itChild)->getPassItems(
projection, view, model
));
++itChild;
}
++itCanvas;
}
// Now we've queued everything, let's sort the rendering queue by the priority
std::sort(
pipelineItems.begin(),
pipelineItems.end(),
[](struct RenderPipelineItem &a, struct RenderPipelineItem &b){
if(a.pass.orderShader == b.pass.orderShader) {
shaderPassItems.begin(),
shaderPassItems.end(),
[](struct ShaderPassItem &a, struct ShaderPassItem &b){
if(a.priority == b.priority) {
return a.w < b.w;
}
return a.pass.orderShader < b.pass.orderShader;
return a.priority < b.priority;
}
);
// Now we've sorted everything! Let's actually start rendering.
ShaderProgram *boundProgram = nullptr;
std::map<textureslot_t, Texture*> boundTextures;
auto renderTarget = camera->getRenderTarget();
assertNotNull(renderTarget);
// TODO: This will be editable!
renderTarget->bind();
@ -161,24 +182,20 @@ void RenderPipeline::renderSceneCamera(Scene *scene, Camera *camera) {
RENDER_TARGET_CLEAR_FLAG_DEPTH |
RENDER_TARGET_CLEAR_FLAG_COLOR
);
this->renderManager->setRenderFlags(
RENDER_MANAGER_RENDER_FLAG_DEPTH_TEST |
RENDER_MANAGER_RENDER_FLAG_BLEND
);
auto itItems = pipelineItems.begin();
while(itItems != pipelineItems.end()) {
auto item = *itItems;
itPassItem = shaderPassItems.begin();
while(itPassItem != shaderPassItems.end()) {
auto item = *itPassItem;
// Bind the program.
if(boundProgram != item.pass.shaderProgram) {
boundProgram = item.pass.shaderProgram;
if(boundProgram != item.shaderProgram) {
boundProgram = item.shaderProgram;
boundProgram->bind();
}
// Bind the textures to the slots
auto itTextureSlot = item.pass.textureSlots.begin();
while(itTextureSlot != item.pass.textureSlots.end()) {
auto itTextureSlot = item.textureSlots.begin();
while(itTextureSlot != item.textureSlots.end()) {
// Assert texture isn't null, just don't include it.
assertNotNull(itTextureSlot->second);
@ -190,45 +207,52 @@ void RenderPipeline::renderSceneCamera(Scene *scene, Camera *camera) {
}
// Now set each of the parameters. Nothing exciting here.
auto itColors = item.pass.colorValues.begin();
while(itColors != item.pass.colorValues.end()) {
item.pass.shaderProgram->setColor(itColors->first, itColors->second);
auto itColors = item.colorValues.begin();
while(itColors != item.colorValues.end()) {
item.shaderProgram->setColor(itColors->first, itColors->second);
++itColors;
}
auto itBool = item.pass.boolValues.begin();
while(itBool != item.pass.boolValues.end()) {
item.pass.shaderProgram->setBoolean(itBool->first, itBool->second);
auto itBool = item.boolValues.begin();
while(itBool != item.boolValues.end()) {
item.shaderProgram->setBoolean(itBool->first, itBool->second);
++itBool;
}
auto itMat = item.pass.matrixValues.begin();
while(itMat != item.pass.matrixValues.end()) {
item.pass.shaderProgram->setMatrix(itMat->first, itMat->second);
auto itMat = item.matrixValues.begin();
while(itMat != item.matrixValues.end()) {
item.shaderProgram->setMatrix(itMat->first, itMat->second);
++itMat;
}
auto itVec3 = item.pass.vec3Values.begin();
while(itVec3 != item.pass.vec3Values.end()) {
item.pass.shaderProgram->setVector3(itVec3->first, itVec3->second);
auto itVec3 = item.vec3Values.begin();
while(itVec3 != item.vec3Values.end()) {
item.shaderProgram->setVector3(itVec3->first, itVec3->second);
++itVec3;
}
auto itText = item.pass.textureValues.begin();
while(itText != item.pass.textureValues.end()) {
item.pass.shaderProgram->setTexture(itText->first, itText->second);
auto itText = item.textureValues.begin();
while(itText != item.textureValues.end()) {
item.shaderProgram->setTexture(itText->first, itText->second);
++itText;
}
auto itFloat = item.pass.floatValues.begin();
while(itFloat != item.pass.floatValues.end()) {
item.pass.shaderProgram->setFloat(itFloat->first, itFloat->second);
auto itFloat = item.floatValues.begin();
while(itFloat != item.floatValues.end()) {
item.shaderProgram->setFloat(itFloat->first, itFloat->second);
++itFloat;
}
// Set Render flags
this->renderManager->setRenderFlags(item.renderFlags);
// Thank god that's done, now just draw the damn mesh.
item.mesh->mesh->draw(MESH_DRAW_MODE_TRIANGLES, 0, -1);
++itItems;
item.mesh->draw(
MESH_DRAW_MODE_TRIANGLES,
item.start,
item.count
);
++itPassItem;
}
}

View File

@ -10,16 +10,11 @@
#include "scene/components/display/Material.hpp"
#include "scene/components/display/MeshRenderer.hpp"
#include "scene/components/display/Camera.hpp"
#include "ui/UIComponent.hpp"
namespace Dawn {
class RenderManager;
struct RenderPipelineItem {
MeshRenderer *mesh;
struct ShaderPass pass;
float_t w;
};
class RenderPipeline {
private:
int_fast16_t renderId = -1;

View File

@ -5,13 +5,10 @@
#pragma once
#include "RenderTarget.hpp"
#include "display/shader/Shader.hpp"
#include "display/shader/UIShader.hpp"
#include "util/flag.hpp"
#define RENDER_MANAGER_RENDER_FLAG_DEPTH_TEST FLAG_DEFINE(0)
#define RENDER_MANAGER_RENDER_FLAG_BLEND FLAG_DEFINE(1)
typedef flag_t renderflag_t;
namespace Dawn {
@ -51,13 +48,6 @@ namespace Dawn {
* @return Reference to the currently active main scene render pipeline.
*/
virtual RenderPipeline * getRenderPipeline() = 0;
/**
* Returns the UI Shader used by the game's UI engine.
*
* @return Pointer to the UI Shader.
*/
virtual UIShader * getUIShader() = 0;
/**
* Sets the render flags for the render manager to use.

View File

@ -6,14 +6,21 @@
#pragma once
#include "display/shader/ShaderProgram.hpp"
#include "scene/components/display/MeshRenderer.hpp"
#include "scene/components/display/Camera.hpp"
#include "display/_RenderManager.hpp"
namespace Dawn {
class Material;
struct ShaderPass {
struct ShaderPassItem {
ShaderProgram *shaderProgram = nullptr;
int32_t orderShader = 0;
bool_t needsW = false;
int32_t priority = 0;
Mesh *mesh;
int32_t start = 0;
int32_t count = -1;
float_t w = 0;
renderflag_t renderFlags = RENDER_MANAGER_RENDER_FLAG_DEPTH_TEST;
// Parameters
std::map<shaderparameter_t, struct Color> colorValues;
@ -39,27 +46,17 @@ namespace Dawn {
virtual void compile() = 0;
/**
* Returns the list of passes to render for the given scene item.
* Returns the list of pass items to render for the given scene item.
*
* @param mesh Mesh Renderer for the scene item.
* @param material Material for the scene item.
* @param camera Camera for the scene.
* @return List of passes to render.
*/
virtual std::vector<struct ShaderPass> getItemPasses(
MeshRenderer *mesh,
Material *material
) = 0;
/**
* Called once per frame, set the global shader parameters that is used by
* every item in the scene.
*
* @param cameraProjection Projection matrix of the camera.
* @param cameraView View matrix of the camera.
*/
virtual void setGlobalParameters(
glm::mat4 cameraProjection,
glm::mat4 cameraView
virtual std::vector<struct ShaderPassItem> getPassItems(
Mesh *mesh,
Material *material,
Camera *camera
) = 0;
};
}

View File

@ -4,6 +4,7 @@
// https://opensource.org/licenses/MIT
#include "UIBorder.hpp"
#include "game/DawnGame.hpp"
using namespace Dawn;
@ -20,6 +21,7 @@ void UIBorder::updatePositions() {
glm::vec2 overallDimensions = glm::vec2(this->getWidth(), this->getHeight());
glm::vec2 innerDimensions = overallDimensions - (this->edgeDimensions * 2.0f);
// Top Left.
QuadMesh::bufferQuadMesh(&this->mesh,
glm::vec2(0, 0),
@ -102,13 +104,25 @@ void UIBorder::updatePositions() {
);
}
void UIBorder::drawSelf(UIShader *shader, glm::mat4 transform) {
if(this->texture == nullptr) return;
std::vector<struct ShaderPassItem> UIBorder::getSelfPassItems(
glm::mat4 projection,
glm::mat4 view,
glm::mat4 transform
) {
std::vector<struct ShaderPassItem> items;
if(this->texture == nullptr) return items;
shader->setUIColor(COLOR_WHITE);
shader->setUIModel(transform);
shader->setUITexture(this->texture);
this->mesh.draw(MESH_DRAW_MODE_TRIANGLES, 0, -1);
items.push_back(this->getGame()->renderManager.uiShaderProgram.getUIPassItem(
projection,
view,
transform,
this->texture,
COLOR_WHITE,
&this->mesh,
this->z
));
return items;
}
void UIBorder::setBorderSize(glm::vec2 borderSize) {

View File

@ -17,7 +17,11 @@ namespace Dawn {
glm::vec2 uv1 = glm::vec2(1.0f, 1.0f);
void updatePositions() override;
void drawSelf(UIShader *shader, glm::mat4 selfTransform) override;
std::vector<struct ShaderPassItem> getSelfPassItems(
glm::mat4 projection,
glm::mat4 view,
glm::mat4 transform
) override;
public:
Texture *texture = nullptr;

View File

@ -138,21 +138,29 @@ void UIComponent::setTransform(
this->updatePositions();
}
void UIComponent::draw(UIShader *uiShader, glm::mat4 parentTransform) {
std::vector<struct ShaderPassItem> UIComponent::getPassItems(
glm::mat4 projection,
glm::mat4 view,
glm::mat4 parent
) {
// Calculate self transform matrix
glm::mat4 selfTransform = parentTransform * glm::translate(
glm::mat4(1.0f), glm::vec3(this->relativeX, this->relativeY, this->z)
glm::mat4 selfTransform = parent * glm::translate(
glm::mat4(1.0f),
glm::vec3(this->relativeX, this->relativeY, this->z)
);
// Draw Self
this->drawSelf(uiShader, selfTransform);
auto items = this->getSelfPassItems(projection, view, selfTransform);
// Render children
auto it = this->children.begin();
while(it != this->children.end()) {
(*it)->draw(uiShader, selfTransform);
vectorAppend(&items, (*it)->getPassItems(projection, view, selfTransform));
++it;
}
return items;
}
void UIComponent::addChild(UIComponent *child) {

View File

@ -7,7 +7,9 @@
#include "scene/components/ui/UICanvas.hpp"
#include "scene/Scene.hpp"
#include "display/Color.hpp"
#include "display/shader/UIShader.hpp"
#include "util/array.hpp"
#include "util/mathutils.hpp"
#include "display/shader/Shader.hpp"
namespace Dawn {
enum UIComponentAlign {
@ -53,10 +55,16 @@ namespace Dawn {
* Intended to be overwritten by subclass. Called by the draw method to
* ask this child to draw.
*
* @param uiShader UI Shader for the child to use.
* @param selfTransform Self alignment transform.
* @param projection Projection matrix of the camera.
* @param view View matrix of the camera.
* @param parent Matrix of the parent of this UI item.
* @return The list of shader pass items.
*/
virtual void drawSelf(UIShader *uiShader, glm::mat4 selfTransform) = 0;
virtual std::vector<struct ShaderPassItem> getSelfPassItems(
glm::mat4 projection,
glm::mat4 view,
glm::mat4 transform
) = 0;
public:
UICanvas *canvas;
@ -136,7 +144,21 @@ namespace Dawn {
float_t z
);
void draw(UIShader *uiShader, glm::mat4 parentTransform);
/**
* Returns the list of renderable shader pass items for this UI element.
* This is basically how you get your UI item to draw, this is called by
* the RenderPipeline.
*
* @param projection Projection matrix of the camera.
* @param view View matrix of the camera.
* @param parent Matrix of the parent of this UI item.
* @return The list of shader pass items, including children.
*/
std::vector<struct ShaderPassItem> getPassItems(
glm::mat4 projection,
glm::mat4 view,
glm::mat4 parent
);
/**
* Adds a child to this UI Component.

View File

@ -11,6 +11,10 @@ UIEmpty::UIEmpty(UICanvas *canvas) : UIComponent(canvas) {
}
void UIEmpty::drawSelf(UIShader *shader, glm::mat4 selfTrans) {
std::vector<struct ShaderPassItem> UIEmpty::getSelfPassItems(
glm::mat4 projection,
glm::mat4 view,
glm::mat4 transform
) {
return std::vector<struct ShaderPassItem>();
}

View File

@ -8,8 +8,14 @@
namespace Dawn {
class UIEmpty : public UIComponent {
protected:
std::vector<struct ShaderPassItem> getSelfPassItems(
glm::mat4 projection,
glm::mat4 view,
glm::mat4 transform
) override;
public:
UIEmpty(UICanvas *canvas);
void drawSelf(UIShader *uiShader, glm::mat4 selfTransform) override;
};
}

View File

@ -71,15 +71,29 @@ float_t UILabel::getContentHeight() {
return this->measure.getHeight();
}
void UILabel::drawSelf(UIShader *shader, glm::mat4 selfTransform) {
if(this->font == nullptr || !this->hasText) return;
std::vector<struct ShaderPassItem> UILabel::getSelfPassItems(
glm::mat4 projection,
glm::mat4 view,
glm::mat4 transform
) {
std::vector<struct ShaderPassItem> items;
if(this->font == nullptr) return items;
// this has to go eventually
this->updateMesh();
shader->setUIColor(this->textColor);
shader->setUIModel(selfTransform);
shader->setUITexture(this->font->getTexture());
this->font->draw(&this->mesh, this->startQuad, this->quadCount);
auto item = this->getGame()->renderManager.uiShaderProgram.getUIPassItem(
projection,
view,
transform,
this->font->getTexture(),
this->textColor,
&this->mesh,
this->z
);
item.start = this->startQuad * QUAD_INDICE_COUNT;
item.count = this->quadCount * QUAD_INDICE_COUNT;
items.push_back(item);
return items;
}
void UILabel::setTransform(

View File

@ -23,6 +23,12 @@ namespace Dawn {
/** Event for when the language strings are updated */
void onLanguageUpdated();
std::vector<struct ShaderPassItem> getSelfPassItems(
glm::mat4 projection,
glm::mat4 view,
glm::mat4 transform
) override;
public:
struct FontMeasure measure;
int32_t startQuad = 0;
@ -32,7 +38,6 @@ namespace Dawn {
struct Color textColor = COLOR_MAGENTA;
UILabel(UICanvas *canvas);
void drawSelf(UIShader *shader, glm::mat4 selfTransform) override;
virtual float_t getContentWidth() override;
virtual float_t getContentHeight() override;
void setTransform(

View File

@ -4,6 +4,7 @@
// https://opensource.org/licenses/MIT
#include "UISprite.hpp"
#include "game/DawnGame.hpp"
using namespace Dawn;
@ -22,12 +23,21 @@ void UISprite::updatePositions() {
);
}
void UISprite::drawSelf(UIShader *uiShader, glm::mat4 selfTransform) {
uiShader->setUITexture(nullptr);
uiShader->setUIModel(selfTransform);
uiShader->setUIModel(glm::mat4(1.0f));
uiShader->setUIColor(this->color);
uiShader->setUITexture(this->texture);
std::vector<struct ShaderPassItem> UISprite::getSelfPassItems(
glm::mat4 projection,
glm::mat4 view,
glm::mat4 transform
) {
std::vector<struct ShaderPassItem> items;
this->mesh.draw(MESH_DRAW_MODE_TRIANGLES, 0, -1);
items.push_back(this->getGame()->renderManager.uiShaderProgram.getUIPassItem(
projection,
view,
transform,
this->texture,
this->color,
&this->mesh,
this->z
));
return items;
}

View File

@ -12,7 +12,11 @@ namespace Dawn {
class UISprite : public UIComponent {
protected:
void updatePositions() override;
void drawSelf(UIShader *uiShader, glm::mat4 selfTransform) override;
std::vector<struct ShaderPassItem> getSelfPassItems(
glm::mat4 projection,
glm::mat4 view,
glm::mat4 transform
) override;
public:
Mesh mesh;

View File

@ -4,6 +4,7 @@
// https://opensource.org/licenses/MIT
#include "VisualNovelManager.hpp"
#include "visualnovel/scene/SimpleVNScene.hpp"
using namespace Dawn;
@ -24,6 +25,13 @@ void VisualNovelManager::onStart() {
assertNotNull(this->textBox);
this->getScene()->eventSceneUnpausedUpdate.addListener(this, &VisualNovelManager::onUnpausedUpdate);
// Handle queuing simple VN Manager
auto scene = this->getScene();
auto sceneAsSimple = dynamic_cast<SimpleVNScene*>(scene);
if(sceneAsSimple != nullptr) {
this->setEvent(sceneAsSimple->getVNEvent());
}
if(this->currentEvent != nullptr) this->currentEvent->start(nullptr);
}

View File

@ -11,7 +11,7 @@ SimpleVisualNovelBackground * SimpleVisualNovelBackground::create(Scene *s) {
auto item = s->createSceneItem();
// item->addComponent<MeshRenderer>();
item->addComponent<MeshHost>();
item->addComponent<Material>();
item->addComponent<SimpleTexturedMaterial>();
auto background = item->addComponent<SimpleVisualNovelBackground>();
return background;
}
@ -24,14 +24,14 @@ SimpleVisualNovelBackground::SimpleVisualNovelBackground(SceneItem *item) :
std::vector<SceneItemComponent*> SimpleVisualNovelBackground::getDependencies(){
return std::vector<SceneItemComponent*>{
this->material = this->item->getComponent<Material>(),
this->material = this->item->getComponent<SimpleTexturedMaterial>(),
this->meshHost = this->item->getComponent<MeshHost>()
};
}
void SimpleVisualNovelBackground::setTexture(Texture *texture) {
auto param = this->material->getShader()->getParameterByName("u_Text");
this->material->textureValues[param] = texture;
assertNotNull(texture);
this->material->texture = texture;
// Since we go both negative and positive, actual height is doubled
float_t aspect = (float_t)texture->getWidth() / (float_t)texture->getHeight();

View File

@ -5,11 +5,12 @@
#pragma once
#include "scene/components/Components.hpp"
#include "scene/components/display/material/SimpleTexturedMaterial.hpp"
namespace Dawn {
class SimpleVisualNovelBackground : public SceneItemComponent {
public:
Material *material;
SimpleTexturedMaterial *material;
MeshHost *meshHost;
/**

View File

@ -12,17 +12,12 @@ VisualNovelCharacter::VisualNovelCharacter(SceneItem *item) :
{
}
void VisualNovelCharacter::setOpacity(float_t opacity) {
auto interface = this->item->getComponent<SimpleTexturedShaderInterface>();
assertNotNull(interface);
auto color = interface->getColor();
color.a = opacity;
interface->setColor(color);
std::vector<SceneItemComponent*> VisualNovelCharacter::getDependencies() {
return std::vector<SceneItemComponent*>{
(this->material = this->item->getComponent<SimpleTexturedMaterial>())
};
}
float_t VisualNovelCharacter::getOpacity() {
auto interface = this->item->getComponent<SimpleTexturedShaderInterface>();
assertNotNull(interface);
auto color = interface->getColor();
return color.a;
void VisualNovelCharacter::onStart() {
assertNotNull(this->material);
}

View File

@ -5,15 +5,13 @@
#pragma once
#include "scene/SceneItemComponent.hpp"
#include "scene/components/display/shader/SimpleTexturedShaderInterface.hpp"
#include "scene/components/display/material/SimpleTexturedMaterial.hpp"
namespace Dawn {
class VisualNovelCharacter : public SceneItemComponent {
protected:
SimpleTexturedShaderInterface *shaderInterface = nullptr;
public:
std::string nameKey = "character.unknown";
SimpleTexturedMaterial *material = nullptr;
/**
* Visual Novel Character Component. Mostly logic-less but provides nice
@ -23,10 +21,7 @@ namespace Dawn {
*/
VisualNovelCharacter(SceneItem *item);
SimpleTexturedShaderInterface * getShaderInterface();
void setOpacity(float_t opacity);
float_t getOpacity();
std::vector<SceneItemComponent*> getDependencies() override;
void onStart() override;
};
}

View File

@ -13,17 +13,16 @@ VisualNovelFadeCharacterEvent::VisualNovelFadeCharacterEvent(
bool_t fadeIn,
easefunction_t *ease,
float_t duration
) : VisualNovelSimpleCallbackAnimationEvent<float_t, VisualNovelCharacter>(man)
{
this->callbackAnimation.easing = ease;
this->callbackAnimation.setCallback(
character, &VisualNovelCharacter::setOpacity
);
) : VisualNovelSimpleAnimationEvent<float_t>(
man,
&character->material->color.a
) {
this->simpleAnimation.easing = ease;
if(fadeIn) {
this->callbackAnimation.addKeyframe(0.0f, 0.0f);
this->callbackAnimation.addKeyframe(duration, 1.0f);
this->simpleAnimation.addKeyframe(0.0f, 0.0f);
this->simpleAnimation.addKeyframe(duration, 1.0f);
} else {
this->callbackAnimation.addKeyframe(0.0f, 1.0f);
this->callbackAnimation.addKeyframe(duration, 0.0f);
this->simpleAnimation.addKeyframe(0.0f, 1.0f);
this->simpleAnimation.addKeyframe(duration, 0.0f);
}
}

View File

@ -4,13 +4,13 @@
// https://opensource.org/licenses/MIT
#pragma once
#include "visualnovel/events/animation/VisualNovelSimpleCallbackAnimationEvent.hpp"
#include "visualnovel/events/animation/VisualNovelSimpleAnimationEvent.hpp"
#include "visualnovel/components/VisualNovelCharacter.hpp"
#include "scene/components/display/Material.hpp"
namespace Dawn {
class VisualNovelFadeCharacterEvent :
public VisualNovelSimpleCallbackAnimationEvent<float_t,VisualNovelCharacter>
public VisualNovelSimpleAnimationEvent<float_t>
{
public:
VisualNovelFadeCharacterEvent(

View File

@ -37,21 +37,19 @@ void SimpleVNScene::stage() {
auto listenerItem = this->createSceneItem();
this->audioListener = listenerItem->addComponent<AudioListener>();
this->background = SimpleVisualNovelBackground::create(this);
// Stage VN Items
this->vnStage();
// UI
this->canvas = UICanvas::create(this);
this->textbox = VisualNovelTextboxPrefab::create(this->canvas);
this->background = SimpleVisualNovelBackground::create(this);
// VN Manager
auto vnManagerItem = this->createSceneItem();
this->vnManager = vnManagerItem->addComponent<VisualNovelManager>();
// Stage VN Items
this->vnStage();
// Fader (Drawn over the top of everything else)
this->vnFader = VisualNovelFader::create(canvas);
// Begin VN.
this->vnManager->setEvent(this->getVNEvent());
}

View File

@ -27,8 +27,10 @@ namespace Dawn {
VisualNovelManager *vnManager = nullptr;
AudioListener *audioListener = nullptr;
/**
* Internal method to stage the VN scene.
*/
virtual void vnStage() = 0;
virtual IVisualNovelEvent * getVNEvent() = 0;
public:
/**
@ -41,5 +43,13 @@ namespace Dawn {
std::vector<Asset*> getRequiredAssets() override;
void stage() override;
/**
* Returns the first VN event for the scene. Called by the VN Manager for
* simple scenes.
*
* @return First VN event to be queued.
*/
virtual IVisualNovelEvent * getVNEvent() = 0;
};
}

View File

@ -138,8 +138,12 @@ int32_t VisualNovelTextbox::getCountOfVisibleLines() {
return this->label.measure.getLineCount();
}
void VisualNovelTextbox::drawSelf(UIShader *shader, glm::mat4 self) {
std::vector<struct ShaderPassItem> VisualNovelTextbox::getSelfPassItems(
glm::mat4 projection,
glm::mat4 view,
glm::mat4 transform
) {
return std::vector<struct ShaderPassItem>();
}
void VisualNovelTextbox::setFont(Font *font) {

View File

@ -25,7 +25,12 @@ namespace Dawn {
VisualNovelCharacter *character = nullptr;
void updatePositions() override;
void drawSelf(UIShader *shader, glm::mat4 selfTransform) override;
std::vector<struct ShaderPassItem> getSelfPassItems(
glm::mat4 projection,
glm::mat4 view,
glm::mat4 transform
) override;
/**
* Listens for scene updates.

View File

@ -14,13 +14,13 @@ RenderManager::RenderManager(DawnGame *game) :
backBuffer(*this),
renderPipeline(this)
{
this->uiShader = new UIShader();
}
void RenderManager::init() {
this->renderPipeline.init();
this->simpleShader.compile();
this->uiShader->compile();
this->uiShaderProgram.compile();
// Prepare the initial values
glEnable(GL_TEXTURE_2D);
@ -37,10 +37,6 @@ RenderPipeline * RenderManager::getRenderPipeline() {
return &this->renderPipeline;
}
UIShader * RenderManager::getUIShader() {
return this->uiShader;
}
void RenderManager::setRenderFlags(renderflag_t flags) {
this->renderFlags = flags;
@ -62,5 +58,4 @@ void RenderManager::update() {
}
RenderManager::~RenderManager() {
delete this->uiShader;
}

View File

@ -7,6 +7,7 @@
#include "display/_RenderManager.hpp"
#include "display/BackBufferRenderTarget.hpp"
#include "display/shader/SimpleTexturedShader.hpp"
#include "display/shader/UIShaderProgram.hpp"
#include "display/RenderPipeline.hpp"
namespace Dawn {
@ -17,7 +18,7 @@ namespace Dawn {
public:
BackBufferRenderTarget backBuffer;
SimpleTexturedShader simpleShader;
UIShader *uiShader;
UIShaderProgram uiShaderProgram;
/**
* Construct a new RenderManager for a game instance.
@ -26,7 +27,6 @@ namespace Dawn {
RenderTarget * getBackBuffer() override;
RenderPipeline * getRenderPipeline() override;
UIShader * getUIShader() override;
void setRenderFlags(renderflag_t renderFlags) override;
void init() override;
void update() override;

View File

@ -7,4 +7,5 @@
target_sources(${DAWN_TARGET_NAME}
PRIVATE
ShaderProgram.cpp
SimpleTexturedShader.cpp
)

View File

@ -11,16 +11,25 @@ void SimpleTexturedShader::compile() {
this->program.compile();
}
std::vector<struct ShaderPass> SimpleTexturedShader::getItemPasses(
MeshRenderer *mesh, Material *material
std::vector<struct ShaderPassItem> SimpleTexturedShader::getPassItems(
Mesh *mesh,
Material *material,
Camera *camera
) {
SimpleTexturedMaterial *simpleMaterial = dynamic_cast<SimpleTexturedMaterial*>(material);
assertNotNull(simpleMaterial);
struct ShaderPass onlyPass;
struct ShaderPassItem onlyPass;
onlyPass.mesh = mesh;
onlyPass.shaderProgram = &program;
onlyPass.colorValues[program.paramColor] = simpleMaterial->color;
onlyPass.matrixValues[program.paramModel] = mesh->transform->getWorldTransform();
onlyPass.matrixValues[program.paramModel] = material->transform->getWorldTransform();
onlyPass.matrixValues[program.paramView] = camera->transform->getWorldTransform();
onlyPass.matrixValues[program.paramProjection] = camera->projection;
onlyPass.renderFlags = (
RENDER_MANAGER_RENDER_FLAG_BLEND |
RENDER_MANAGER_RENDER_FLAG_DEPTH_TEST
);
if(simpleMaterial->texture != nullptr) {
onlyPass.boolValues[program.paramHasTexture] = true;
@ -30,14 +39,7 @@ std::vector<struct ShaderPass> SimpleTexturedShader::getItemPasses(
onlyPass.boolValues[program.paramHasTexture] = false;
}
std::vector<struct ShaderPass> passes;
std::vector<struct ShaderPassItem> passes;
passes.push_back(onlyPass);
return passes;
}
void SimpleTexturedShader::setGlobalParameters(
glm::mat4 cameraProjection, glm::mat4 cameraView
) {
this->program.setMatrix(this->program.paramProjection, cameraProjection);
this->program.setMatrix(this->program.paramView, cameraView);
}

View File

@ -16,12 +16,10 @@ namespace Dawn {
public:
void compile() override;
std::vector<struct ShaderPass> getItemPasses(
MeshRenderer *mesh, Material *material
) override;
void setGlobalParameters(
glm::mat4 cameraProjection, glm::mat4 cameraView
std::vector<struct ShaderPassItem> getPassItems(
Mesh *mesh,
Material *material,
Camera *camera
) override;
};
}

View File

@ -1,12 +0,0 @@
// Copyright (c) 2022 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#pragma once
#include "SimpleTexturedShader.hpp"
namespace Dawn {
class UIShader : public SimpleTexturedShader {
};
}

View File

@ -0,0 +1,43 @@
// Copyright (c) 2022 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#pragma once
#include "SimpleTexturedShaderProgram.hpp"
#define UI_SHADER_PROGRAM_PRIORITY 100
namespace Dawn {
class UIShaderProgram : public SimpleTexturedShaderProgram {
public:
struct ShaderPassItem getUIPassItem(
glm::mat4 projection,
glm::mat4 view,
glm::mat4 transform,
Texture *texture,
struct Color color,
Mesh *mesh,
float_t z
) {
struct ShaderPassItem item;
item.shaderProgram = this;
item.colorValues[this->paramColor] = color;
if(texture == nullptr) {
item.boolValues[this->paramHasTexture] = false;
} else {
item.textureSlots[0] = texture;
item.textureValues[this->paramTexture] = 0;
item.boolValues[this->paramHasTexture] = true;
}
item.matrixValues[this->paramProjection] = projection;
item.matrixValues[this->paramView] = view;
item.matrixValues[this->paramModel] = transform;
item.priority = UI_SHADER_PROGRAM_PRIORITY;
item.w = z;
item.renderFlags = RENDER_MANAGER_RENDER_FLAG_BLEND;
item.mesh = mesh;
return item;
}
};
}

View File

@ -10,13 +10,12 @@
#include "scene/components/Components.hpp"
#include "visualnovel/components/VisualNovelCharacter.hpp"
#include "display/animation/TiledSpriteAnimation.hpp"
#include "scene/components/display/shader/SimpleTexturedShaderInterface.hpp"
#include "scene/components/display/material/SimpleTexturedMaterial.hpp"
namespace Dawn {
class DeathPrefab : public SceneItemPrefab<DeathPrefab> {
public:
VisualNovelCharacter *vnCharacter;
SimpleTexturedShaderInterface *shaderInterface;
AnimationController *animation;
static std::vector<Asset*> prefabAssets(AssetManager *assMan) {
@ -36,11 +35,10 @@ namespace Dawn {
auto tilesetAsset = man->get<TilesetAsset>("tileset_death");
auto meshRenderer = this->addComponent<MeshRenderer>();
auto material = this->addComponent<Material>();
auto meshHost = this->addComponent<MeshHost>();
shaderInterface = this->addComponent<SimpleTexturedShaderInterface>();
shaderInterface->setTexture(&textureAsset->texture);
auto material = this->addComponent<SimpleTexturedMaterial>();
material->texture = &textureAsset->texture;
vnCharacter = this->addComponent<VisualNovelCharacter>();
vnCharacter->nameKey = "character.death.name";

View File

@ -10,40 +10,45 @@
#include "scene/components/Components.hpp"
#include "visualnovel/components/VisualNovelCharacter.hpp"
#include "display/animation/TiledSpriteAnimation.hpp"
#include "scene/components/display/material/SimpleTexturedMaterial.hpp"
namespace Dawn {
class PennyPrefab : public SceneItemPrefab<PennyPrefab> {
public:
VisualNovelCharacter *vnCharacter;
PokerPlayer *pokerPlayer;
SimpleTexturedMaterial *material;
static std::vector<Asset*> prefabAssets(AssetManager *assMan) {
return std::vector<Asset*>{
assMan->get<TextureAsset>("texture_penny"),
assMan->get<TilesetAsset>("tileset_penny")
assMan->get<TextureAsset>("texture_death"),
assMan->get<TilesetAsset>("tileset_death")
};
}
PennyPrefab(Scene *scene, sceneitemid_t id) : SceneItemPrefab(scene, id){}
void prefabInit(AssetManager *man) override {
auto textureAsset = man->get<TextureAsset>("texture_penny");
auto tilesetAsset = man->get<TilesetAsset>("tileset_penny");
auto textureAsset = man->get<TextureAsset>("texture_death");
auto tilesetAsset = man->get<TilesetAsset>("tileset_death");
auto meshRenderer = this->addComponent<MeshRenderer>();
auto material = this->addComponent<Material>();
auto meshHost = this->addComponent<MeshHost>();
auto tiledSprite = this->addComponent<TiledSprite>();
auto animation = this->addComponent<AnimationController>();
auto pokerPlayer = this->addComponent<PokerPlayer>();
vnCharacter = this->addComponent<VisualNovelCharacter>();
vnCharacter->nameKey = "character.penny.name";
auto param = material->getShader()->getParameterByName("u_Text");
material->textureValues[param] = &textureAsset->texture;
material = this->addComponent<SimpleTexturedMaterial>();
material->texture = &textureAsset->texture;
auto animation = this->addComponent<AnimationController>();
pokerPlayer = this->addComponent<PokerPlayer>();
vnCharacter = this->addComponent<VisualNovelCharacter>();
vnCharacter->nameKey = "character.penny.name";
auto tiledSprite = this->addComponent<TiledSprite>();
tiledSprite->setTilesetAndSize(&tilesetAsset->tileset);
tiledSprite->setTile(0);
this->transform.setLocalPosition(glm::vec3(0, 0, 0));
// auto anim = new TiledSpriteAnimation(tiledSprite);

View File

@ -22,8 +22,6 @@ namespace Dawn {
PixelVNScene::vnStage();
this->death = DeathPrefab::create(this);
this->death->vnCharacter->setOpacity(0);
this->death2 = DeathPrefab::create(this);
this->death2->transform.setLocalPosition(glm::vec3(100, 0, 0));
}
@ -38,8 +36,21 @@ namespace Dawn {
this->game->sceneCutover(scene);
}
public:
Scene_1(DawnGame *game) : PixelVNScene(game) {
}
std::vector<Asset*> getRequiredAssets() override {
auto man = &this->game->assetManager;
std::vector<Asset*> assets = PixelVNScene::getRequiredAssets();
vectorAppend(&assets, DeathPrefab::getRequiredAssets(man));
assets.push_back(man->get<AudioAsset>("audio_test"));
return assets;
}
IVisualNovelEvent * getVNEvent() override {
auto start = new VisualNovelPauseEvent(vnManager, 1.0f);
auto start = new VisualNovelPauseEvent(vnManager, 0.1f);
start
->then(new VisualNovelBatchEvent(
vnManager,
@ -61,22 +72,9 @@ namespace Dawn {
}
))
->then(new VisualNovelTextboxEvent(vnManager, nullptr, "scene.1.1"))
->then(new VisualNovelCallbackEvent<Scene_1>(vnManager, this, &Scene_1::onSceneEnded))
// ->then(new VisualNovelCallbackEvent<Scene_1>(vnManager, this, &Scene_1::onSceneEnded))
;
return start;
}
public:
Scene_1(DawnGame *game) : PixelVNScene(game) {
}
std::vector<Asset*> getRequiredAssets() override {
auto man = &this->game->assetManager;
std::vector<Asset*> assets = PixelVNScene::getRequiredAssets();
vectorAppend(&assets, DeathPrefab::getRequiredAssets(man));
assets.push_back(man->get<AudioAsset>("audio_test"));
return assets;
}
};
}

View File

@ -24,17 +24,6 @@ namespace Dawn {
this->game->sceneCutover(scene);
}
IVisualNovelEvent * getVNEvent() override {
auto start = new VisualNovelPauseEvent(vnManager, 0.1f);
start
->then(new VisualNovelTextboxEvent(vnManager, nullptr, "scene.10.1"))
->then(new VisualNovelCallbackEvent<Scene_10>(vnManager, this, &Scene_10::onSceneEnded))
;
return start;
}
public:
Scene_10(DawnGame *game) : PixelVNScene(game) {
}
@ -43,5 +32,14 @@ namespace Dawn {
std::vector<Asset*> assets = PixelVNScene::getRequiredAssets();
return assets;
}
IVisualNovelEvent * getVNEvent() override {
auto start = new VisualNovelPauseEvent(vnManager, 0.1f);
start
->then(new VisualNovelTextboxEvent(vnManager, nullptr, "scene.10.1"))
->then(new VisualNovelCallbackEvent<Scene_10>(vnManager, this, &Scene_10::onSceneEnded))
;
return start;
}
};
}

View File

@ -24,17 +24,6 @@ namespace Dawn {
this->game->sceneCutover(scene);
}
IVisualNovelEvent * getVNEvent() override {
auto start = new VisualNovelPauseEvent(vnManager, 0.1f);
start
->then(new VisualNovelTextboxEvent(vnManager, nullptr, "scene.11.1"))
->then(new VisualNovelCallbackEvent<Scene_11>(vnManager, this, &Scene_11::onSceneEnded))
;
return start;
}
public:
Scene_11(DawnGame *game) : PixelVNScene(game) {
}
@ -43,5 +32,14 @@ namespace Dawn {
std::vector<Asset*> assets = PixelVNScene::getRequiredAssets();
return assets;
}
IVisualNovelEvent * getVNEvent() override {
auto start = new VisualNovelPauseEvent(vnManager, 0.1f);
start
->then(new VisualNovelTextboxEvent(vnManager, nullptr, "scene.11.1"))
->then(new VisualNovelCallbackEvent<Scene_11>(vnManager, this, &Scene_11::onSceneEnded))
;
return start;
}
};
}

View File

@ -44,16 +44,6 @@ namespace Dawn {
};
}
IVisualNovelEvent * getVNEvent() override {
auto start = new VisualNovelTextboxEvent(vnManager, penny->vnCharacter, "scene.12.1");
start
->then(new VisualNovelCallbackEvent<Scene_12>(vnManager, this, &Scene_12::onSceneEnded))
;
return start;
}
public:
Scene_12(DawnGame *game) : PokerVNScene(game) {}
@ -64,5 +54,13 @@ namespace Dawn {
vectorAppend(&assets, PennyPrefab::getRequiredAssets(assMan));
return assets;
}
IVisualNovelEvent * getVNEvent() override {
auto start = new VisualNovelTextboxEvent(vnManager, penny->vnCharacter, "scene.12.1");
start
->then(new VisualNovelCallbackEvent<Scene_12>(vnManager, this, &Scene_12::onSceneEnded))
;
return start;
}
};
}

View File

@ -24,17 +24,6 @@ namespace Dawn {
this->game->sceneCutover(scene);
}
IVisualNovelEvent * getVNEvent() override {
auto start = new VisualNovelPauseEvent(vnManager, 0.1f);
start
->then(new VisualNovelTextboxEvent(vnManager, nullptr, "scene.13.1"))
->then(new VisualNovelCallbackEvent<Scene_13>(vnManager, this, &Scene_13::onSceneEnded))
;
return start;
}
public:
Scene_13(DawnGame *game) : PixelVNScene(game) {
}
@ -43,5 +32,14 @@ namespace Dawn {
std::vector<Asset*> assets = PixelVNScene::getRequiredAssets();
return assets;
}
IVisualNovelEvent * getVNEvent() override {
auto start = new VisualNovelPauseEvent(vnManager, 0.1f);
start
->then(new VisualNovelTextboxEvent(vnManager, nullptr, "scene.13.1"))
->then(new VisualNovelCallbackEvent<Scene_13>(vnManager, this, &Scene_13::onSceneEnded))
;
return start;
}
};
}

View File

@ -24,17 +24,6 @@ namespace Dawn {
this->game->sceneCutover(scene);
}
IVisualNovelEvent * getVNEvent() override {
auto start = new VisualNovelPauseEvent(vnManager, 0.1f);
start
->then(new VisualNovelTextboxEvent(vnManager, nullptr, "scene.14.1"))
->then(new VisualNovelCallbackEvent<Scene_14>(vnManager, this, &Scene_14::onSceneEnded))
;
return start;
}
public:
Scene_14(DawnGame *game) : PixelVNScene(game) {
}
@ -43,5 +32,14 @@ namespace Dawn {
std::vector<Asset*> assets = PixelVNScene::getRequiredAssets();
return assets;
}
IVisualNovelEvent * getVNEvent() override {
auto start = new VisualNovelPauseEvent(vnManager, 0.1f);
start
->then(new VisualNovelTextboxEvent(vnManager, nullptr, "scene.14.1"))
->then(new VisualNovelCallbackEvent<Scene_14>(vnManager, this, &Scene_14::onSceneEnded))
;
return start;
}
};
}

View File

@ -24,17 +24,6 @@ namespace Dawn {
this->game->sceneCutover(scene);
}
IVisualNovelEvent * getVNEvent() override {
auto start = new VisualNovelPauseEvent(vnManager, 0.1f);
start
->then(new VisualNovelTextboxEvent(vnManager, nullptr, "scene.15.1"))
->then(new VisualNovelCallbackEvent<Scene_15>(vnManager, this, &Scene_15::onSceneEnded))
;
return start;
}
public:
Scene_15(DawnGame *game) : PixelVNScene(game) {
}
@ -43,5 +32,14 @@ namespace Dawn {
std::vector<Asset*> assets = PixelVNScene::getRequiredAssets();
return assets;
}
IVisualNovelEvent * getVNEvent() override {
auto start = new VisualNovelPauseEvent(vnManager, 0.1f);
start
->then(new VisualNovelTextboxEvent(vnManager, nullptr, "scene.15.1"))
->then(new VisualNovelCallbackEvent<Scene_15>(vnManager, this, &Scene_15::onSceneEnded))
;
return start;
}
};
}

View File

@ -23,18 +23,6 @@ namespace Dawn {
scene->stage();
this->game->sceneCutover(scene);
}
IVisualNovelEvent * getVNEvent() override {
auto start = new VisualNovelPauseEvent(vnManager, 0.1f);
start
->then(new VisualNovelTextboxEvent(vnManager, nullptr, "scene.16.1"))
->then(new VisualNovelCallbackEvent<Scene_16>(vnManager, this, &Scene_16::onSceneEnded))
;
return start;
}
public:
Scene_16(DawnGame *game) : PixelVNScene(game) {
}
@ -43,5 +31,15 @@ namespace Dawn {
std::vector<Asset*> assets = PixelVNScene::getRequiredAssets();
return assets;
}
IVisualNovelEvent * getVNEvent() override {
auto start = new VisualNovelPauseEvent(vnManager, 0.1f);
start
->then(new VisualNovelTextboxEvent(vnManager, nullptr, "scene.16.1"))
->then(new VisualNovelCallbackEvent<Scene_16>(vnManager, this, &Scene_16::onSceneEnded))
;
return start;
}
};
}

View File

@ -44,16 +44,6 @@ namespace Dawn {
};
}
IVisualNovelEvent * getVNEvent() override {
auto start = new VisualNovelTextboxEvent(vnManager, penny->vnCharacter, "scene.17.1");
start
->then(new VisualNovelCallbackEvent<Scene_17>(vnManager, this, &Scene_17::onSceneEnded))
;
return start;
}
public:
Scene_17(DawnGame *game) : PokerVNScene(game) {}
@ -64,5 +54,13 @@ namespace Dawn {
vectorAppend(&assets, PennyPrefab::getRequiredAssets(assMan));
return assets;
}
IVisualNovelEvent * getVNEvent() override {
auto start = new VisualNovelTextboxEvent(vnManager, penny->vnCharacter, "scene.17.1");
start
->then(new VisualNovelCallbackEvent<Scene_17>(vnManager, this, &Scene_17::onSceneEnded))
;
return start;
}
};
}

View File

@ -16,17 +16,6 @@ namespace Dawn {
void onSceneEnded() {
}
IVisualNovelEvent * getVNEvent() override {
auto start = new VisualNovelPauseEvent(vnManager, 0.1f);
start
->then(new VisualNovelTextboxEvent(vnManager, nullptr, "scene.18.1"))
->then(new VisualNovelCallbackEvent<Scene_18>(vnManager, this, &Scene_18::onSceneEnded))
;
return start;
}
public:
Scene_18(DawnGame *game) : PixelVNScene(game) {
}
@ -35,5 +24,14 @@ namespace Dawn {
std::vector<Asset*> assets = PixelVNScene::getRequiredAssets();
return assets;
}
IVisualNovelEvent * getVNEvent() override {
auto start = new VisualNovelPauseEvent(vnManager, 0.1f);
start
->then(new VisualNovelTextboxEvent(vnManager, nullptr, "scene.18.1"))
->then(new VisualNovelCallbackEvent<Scene_18>(vnManager, this, &Scene_18::onSceneEnded))
;
return start;
}
};
}

View File

@ -24,17 +24,6 @@ namespace Dawn {
this->game->sceneCutover(scene);
}
IVisualNovelEvent * getVNEvent() override {
auto start = new VisualNovelPauseEvent(vnManager, 0.1f);
start
->then(new VisualNovelTextboxEvent(vnManager, nullptr, "scene.2.1"))
->then(new VisualNovelCallbackEvent<Scene_2>(vnManager, this, &Scene_2::onSceneEnded))
;
return start;
}
public:
Scene_2(DawnGame *game) : PixelVNScene(game) {
@ -44,5 +33,14 @@ namespace Dawn {
std::vector<Asset*> assets = PixelVNScene::getRequiredAssets();
return assets;
}
IVisualNovelEvent * getVNEvent() override {
auto start = new VisualNovelPauseEvent(vnManager, 0.1f);
start
->then(new VisualNovelTextboxEvent(vnManager, nullptr, "scene.2.1"))
->then(new VisualNovelCallbackEvent<Scene_2>(vnManager, this, &Scene_2::onSceneEnded))
;
return start;
}
};
}

View File

@ -24,17 +24,6 @@ namespace Dawn {
this->game->sceneCutover(scene);
}
IVisualNovelEvent * getVNEvent() override {
auto start = new VisualNovelPauseEvent(vnManager, 0.1f);
start
->then(new VisualNovelTextboxEvent(vnManager, nullptr, "scene.3.1"))
->then(new VisualNovelCallbackEvent<Scene_3>(vnManager, this, &Scene_3::onSceneEnded))
;
return start;
}
public:
Scene_3(DawnGame *game) : PixelVNScene(game) {
@ -44,5 +33,14 @@ namespace Dawn {
std::vector<Asset*> assets = PixelVNScene::getRequiredAssets();
return assets;
}
IVisualNovelEvent * getVNEvent() override {
auto start = new VisualNovelPauseEvent(vnManager, 0.1f);
start
->then(new VisualNovelTextboxEvent(vnManager, nullptr, "scene.3.1"))
->then(new VisualNovelCallbackEvent<Scene_3>(vnManager, this, &Scene_3::onSceneEnded))
;
return start;
}
};
}

View File

@ -44,16 +44,6 @@ namespace Dawn {
};
}
IVisualNovelEvent * getVNEvent() override {
auto start = new VisualNovelTextboxEvent(vnManager, penny->vnCharacter, "scene.4.1");
start
->then(new VisualNovelCallbackEvent<Scene_4>(vnManager, this, &Scene_4::onSceneEnded))
;
return start;
}
public:
Scene_4(DawnGame *game) : PokerVNScene(game) {}
@ -64,5 +54,13 @@ namespace Dawn {
vectorAppend(&assets, PennyPrefab::getRequiredAssets(assMan));
return assets;
}
IVisualNovelEvent * getVNEvent() override {
auto start = new VisualNovelTextboxEvent(vnManager, penny->vnCharacter, "scene.4.1");
start
->then(new VisualNovelCallbackEvent<Scene_4>(vnManager, this, &Scene_4::onSceneEnded))
;
return start;
}
};
}

View File

@ -24,17 +24,6 @@ namespace Dawn {
this->game->sceneCutover(scene);
}
IVisualNovelEvent * getVNEvent() override {
auto start = new VisualNovelPauseEvent(vnManager, 0.1f);
start
->then(new VisualNovelTextboxEvent(vnManager, nullptr, "scene.5.1"))
->then(new VisualNovelCallbackEvent<Scene_5>(vnManager, this, &Scene_5::onSceneEnded))
;
return start;
}
public:
Scene_5(DawnGame *game) : PixelVNScene(game) {
@ -44,5 +33,14 @@ namespace Dawn {
std::vector<Asset*> assets = PixelVNScene::getRequiredAssets();
return assets;
}
IVisualNovelEvent * getVNEvent() override {
auto start = new VisualNovelPauseEvent(vnManager, 0.1f);
start
->then(new VisualNovelTextboxEvent(vnManager, nullptr, "scene.5.1"))
->then(new VisualNovelCallbackEvent<Scene_5>(vnManager, this, &Scene_5::onSceneEnded))
;
return start;
}
};
}

View File

@ -24,17 +24,6 @@ namespace Dawn {
this->game->sceneCutover(scene);
}
IVisualNovelEvent * getVNEvent() override {
auto start = new VisualNovelPauseEvent(vnManager, 0.1f);
start
->then(new VisualNovelTextboxEvent(vnManager, nullptr, "scene.6.1"))
->then(new VisualNovelCallbackEvent<Scene_6>(vnManager, this, &Scene_6::onSceneEnded))
;
return start;
}
public:
Scene_6(DawnGame *game) : PixelVNScene(game) {
@ -44,5 +33,14 @@ namespace Dawn {
std::vector<Asset*> assets = PixelVNScene::getRequiredAssets();
return assets;
}
IVisualNovelEvent * getVNEvent() override {
auto start = new VisualNovelPauseEvent(vnManager, 0.1f);
start
->then(new VisualNovelTextboxEvent(vnManager, nullptr, "scene.6.1"))
->then(new VisualNovelCallbackEvent<Scene_6>(vnManager, this, &Scene_6::onSceneEnded))
;
return start;
}
};
}

View File

@ -24,17 +24,6 @@ namespace Dawn {
this->game->sceneCutover(scene);
}
IVisualNovelEvent * getVNEvent() override {
auto start = new VisualNovelPauseEvent(vnManager, 0.1f);
start
->then(new VisualNovelTextboxEvent(vnManager, nullptr, "scene.7.1"))
->then(new VisualNovelCallbackEvent<Scene_7>(vnManager, this, &Scene_7::onSceneEnded))
;
return start;
}
public:
Scene_7(DawnGame *game) : PixelVNScene(game) {
}
@ -43,5 +32,14 @@ namespace Dawn {
std::vector<Asset*> assets = PixelVNScene::getRequiredAssets();
return assets;
}
IVisualNovelEvent * getVNEvent() override {
auto start = new VisualNovelPauseEvent(vnManager, 0.1f);
start
->then(new VisualNovelTextboxEvent(vnManager, nullptr, "scene.7.1"))
->then(new VisualNovelCallbackEvent<Scene_7>(vnManager, this, &Scene_7::onSceneEnded))
;
return start;
}
};
}

View File

@ -44,16 +44,6 @@ namespace Dawn {
};
}
IVisualNovelEvent * getVNEvent() override {
auto start = new VisualNovelTextboxEvent(vnManager, penny->vnCharacter, "scene.8.1");
start
->then(new VisualNovelCallbackEvent<Scene_8>(vnManager, this, &Scene_8::onSceneEnded))
;
return start;
}
public:
Scene_8(DawnGame *game) : PokerVNScene(game) {}
@ -64,5 +54,13 @@ namespace Dawn {
vectorAppend(&assets, PennyPrefab::getRequiredAssets(assMan));
return assets;
}
IVisualNovelEvent * getVNEvent() override {
auto start = new VisualNovelTextboxEvent(vnManager, penny->vnCharacter, "scene.8.1");
start
->then(new VisualNovelCallbackEvent<Scene_8>(vnManager, this, &Scene_8::onSceneEnded))
;
return start;
}
};
}

View File

@ -24,17 +24,6 @@ namespace Dawn {
this->game->sceneCutover(scene);
}
IVisualNovelEvent * getVNEvent() override {
auto start = new VisualNovelPauseEvent(vnManager, 0.1f);
start
->then(new VisualNovelTextboxEvent(vnManager, nullptr, "scene.9.1"))
->then(new VisualNovelCallbackEvent<Scene_9>(vnManager, this, &Scene_9::onSceneEnded))
;
return start;
}
public:
Scene_9(DawnGame *game) : PixelVNScene(game) {
}
@ -43,5 +32,14 @@ namespace Dawn {
std::vector<Asset*> assets = PixelVNScene::getRequiredAssets();
return assets;
}
IVisualNovelEvent * getVNEvent() override {
auto start = new VisualNovelPauseEvent(vnManager, 0.1f);
start
->then(new VisualNovelTextboxEvent(vnManager, nullptr, "scene.9.1"))
->then(new VisualNovelCallbackEvent<Scene_9>(vnManager, this, &Scene_9::onSceneEnded))
;
return start;
}
};
}

View File

@ -33,17 +33,6 @@ namespace Dawn {
};
}
IVisualNovelEvent * getVNEvent() override {
auto texture = this->game->assetManager.get<TextureAsset>("texture_tavern_night");
auto start = new VisualNovelChangeSimpleBackgroundEvent(
vnManager, &texture->texture
);
start->then(new VisualNovelTextboxEvent(vnManager, penny->getComponent<VisualNovelCharacter>(), "1234"));
return start;
}
public:
TestScene(DawnGame *game) : PokerVNScene(game) {}
@ -55,5 +44,14 @@ namespace Dawn {
assets.push_back(assMan->get<TextureAsset>("texture_tavern_night"));
return assets;
}
IVisualNovelEvent * getVNEvent() override {
auto texture = this->game->assetManager.get<TextureAsset>("texture_tavern_night");
auto start = new VisualNovelChangeSimpleBackgroundEvent(
vnManager, &texture->texture
);
start->then(new VisualNovelTextboxEvent(vnManager, penny->getComponent<VisualNovelCharacter>(), "1234"));
return start;
}
};
}

View File

@ -35,7 +35,7 @@ namespace Dawn {
static std::vector<Asset*> getAssets(AssetManager *assMan) {
std::vector<Asset*> assets;
assets = PokerGameBorder::getAssets(assMan);
assets.push_back(assMan->get<TrueTypeAsset>("truetype_ark"));
assets.push_back(assMan->get<TrueTypeAsset>("truetype_alice"));
return assets;
}