Starting new VN Structure
This commit is contained in:
10
archive/visualnovel/scene/CMakeLists.txt
Normal file
10
archive/visualnovel/scene/CMakeLists.txt
Normal file
@ -0,0 +1,10 @@
|
||||
# Copyright (c) 2022 Dominic Masters
|
||||
#
|
||||
# This software is released under the MIT License.
|
||||
# https://opensource.org/licenses/MIT
|
||||
|
||||
# Sources
|
||||
target_sources(${DAWN_TARGET_NAME}
|
||||
PRIVATE
|
||||
SimpleVNScene.cpp
|
||||
)
|
61
archive/visualnovel/scene/SimpleVNScene.cpp
Normal file
61
archive/visualnovel/scene/SimpleVNScene.cpp
Normal file
@ -0,0 +1,61 @@
|
||||
// Copyright (c) 2022 Dominic Masters
|
||||
//
|
||||
// This software is released under the MIT License.
|
||||
// https://opensource.org/licenses/MIT
|
||||
|
||||
#include "SimpleVNScene.hpp"
|
||||
#include "prefabs/ui/VisualNovelTextboxPrefab.hpp"
|
||||
|
||||
using namespace Dawn;
|
||||
|
||||
SimpleVNScene::SimpleVNScene(DawnGame *game) : Scene(game) {
|
||||
|
||||
}
|
||||
|
||||
void SimpleVNScene::vnStage() {
|
||||
|
||||
}
|
||||
|
||||
std::vector<Asset*> SimpleVNScene::getRequiredAssets() {
|
||||
auto assMan = &this->game->assetManager;
|
||||
std::vector<Asset*> assets;
|
||||
vectorAppend(&assets, VisualNovelTextboxPrefab::getRequiredAssets(assMan));
|
||||
return assets;
|
||||
}
|
||||
|
||||
void SimpleVNScene::stage() {
|
||||
auto assMan = &this->game->assetManager;
|
||||
|
||||
// Camera
|
||||
this->camera = Camera::create(this);
|
||||
this->camera->transform->lookAt(
|
||||
glm::vec3(0, 0, 2),
|
||||
glm::vec3(0, 0, 0)
|
||||
);
|
||||
|
||||
this->background = SimpleVisualNovelBackground::create(this);
|
||||
this->canvas = UICanvas::create(this);
|
||||
|
||||
// Stage VN Items
|
||||
this->vnStage();
|
||||
|
||||
// UI
|
||||
this->textbox = VisualNovelTextboxPrefab::create(this->canvas);
|
||||
|
||||
// VN Manager
|
||||
auto vnManagerItem = this->createSceneItem();
|
||||
this->vnManager = vnManagerItem->addComponent<VisualNovelManager>();
|
||||
|
||||
// Audio
|
||||
auto listenerItem = this->createSceneItem();
|
||||
this->audioListener = listenerItem->addComponent<AudioListener>();
|
||||
|
||||
auto audioBackgroundItem = this->createSceneItem();
|
||||
vnManager->audioBackground = audioBackgroundItem->addComponent<AudioSource>();
|
||||
|
||||
auto audioCharacterItem = this->createSceneItem();
|
||||
vnManager->audioCharacter = audioCharacterItem->addComponent<AudioSource>();
|
||||
|
||||
// Fader (Drawn over the top of everything else)
|
||||
this->vnFader = VisualNovelFader::create(canvas);
|
||||
}
|
55
archive/visualnovel/scene/SimpleVNScene.hpp
Normal file
55
archive/visualnovel/scene/SimpleVNScene.hpp
Normal file
@ -0,0 +1,55 @@
|
||||
// Copyright (c) 2022 Dominic Masters
|
||||
//
|
||||
// This software is released under the MIT License.
|
||||
// https://opensource.org/licenses/MIT
|
||||
|
||||
#pragma once
|
||||
#include "scene/Scene.hpp"
|
||||
#include "game/DawnGame.hpp"
|
||||
#include "util/array.hpp"
|
||||
#include "scene/components/Components.hpp"
|
||||
#include "scene/components/audio/AudioListener.hpp"
|
||||
#include "visualnovel/VisualNovelManager.hpp"
|
||||
#include "visualnovel/events/VisualNovelTextboxEvent.hpp"
|
||||
#include "visualnovel/events/timing/VisualNovelPauseEvent.hpp"
|
||||
#include "visualnovel/events/VisualNovelFadeEvent.hpp"
|
||||
#include "visualnovel/events/VisualNovelCallbackEvent.hpp"
|
||||
#include "visualnovel/events/VisualNovelChangeSimpleBackgroundEvent.hpp"
|
||||
|
||||
namespace Dawn {
|
||||
class SimpleVNScene : public Scene {
|
||||
protected:
|
||||
Camera *camera = nullptr;
|
||||
UICanvas *canvas = nullptr;
|
||||
VisualNovelTextbox *textbox = nullptr;
|
||||
SimpleVisualNovelBackground *background = nullptr;
|
||||
VisualNovelFader *vnFader = nullptr;
|
||||
VisualNovelManager *vnManager = nullptr;
|
||||
AudioListener *audioListener = nullptr;
|
||||
|
||||
/**
|
||||
* Internal method to stage the VN scene.
|
||||
*/
|
||||
virtual void vnStage();
|
||||
|
||||
public:
|
||||
/**
|
||||
* Constructs a new Simple VN Scene. Custom class that implements the most
|
||||
* common VN Things.
|
||||
*
|
||||
* @param game
|
||||
*/
|
||||
SimpleVNScene(DawnGame *game);
|
||||
|
||||
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;
|
||||
};
|
||||
}
|
Reference in New Issue
Block a user