Subscenes
This commit is contained in:
@ -36,6 +36,7 @@ tool_texture(texture_tavern_morning borrowed/tavern_morning.png)
|
||||
tool_texture(texture_tavern_night borrowed/tavern_night.png)
|
||||
tool_texture(texture_village_day borrowed/village_day.png)
|
||||
tool_tileset(tileset_penny texture_penny characters/penny/penny-blink.png 1 22)
|
||||
tool_tileset(tileset_cards texture_cards ${DIR_GAME_ASSETS}/cards.png 14 4)
|
||||
tool_truetype(truetype_ark
|
||||
ark-pixel.ttf
|
||||
truetype_ark
|
||||
@ -46,8 +47,10 @@ tool_truetype(truetype_ark
|
||||
|
||||
add_dependencies(${DAWN_TARGET_NAME}
|
||||
language_en
|
||||
texture_test
|
||||
tileset_penny
|
||||
tileset_cards
|
||||
|
||||
texture_test
|
||||
truetype_ark
|
||||
texture_city_day
|
||||
texture_city_night
|
||||
|
@ -4,8 +4,7 @@
|
||||
// https://opensource.org/licenses/MIT
|
||||
|
||||
#include "DawnGame.hpp"
|
||||
#include "scenes/Scene_1_1.hpp"
|
||||
#include "scenes/TestScene.hpp"
|
||||
#include "scenes/SubsceneTest.hpp"
|
||||
|
||||
using namespace Dawn;
|
||||
|
||||
@ -23,7 +22,7 @@ int32_t DawnGame::init() {
|
||||
this->localeManager.init();
|
||||
this->renderManager.init();
|
||||
|
||||
this->scene = new TestScene(this);
|
||||
this->scene = new SubsceneTest(this);
|
||||
|
||||
return DAWN_GAME_INIT_RESULT_SUCCESS;
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ namespace Dawn {
|
||||
static void prefabApply(AssetManager *man, UIBorder *border) {
|
||||
auto text = man->get<TextureAsset>("texture_test");
|
||||
border->texture = &text->texture;
|
||||
border->setBorderSize(glm::vec2(16, 16));
|
||||
border->setBorderSize(glm::vec2(8, 8));
|
||||
}
|
||||
};
|
||||
}
|
@ -22,11 +22,11 @@ namespace Dawn {
|
||||
auto assetFont = man->get<TrueTypeAsset>("truetype_ark");
|
||||
UIBorderPrefab::apply(&textbox->border);
|
||||
textbox->setFont(&assetFont->font);
|
||||
textbox->setFontSize(40);
|
||||
textbox->setLabelPadding(glm::vec2(10, 8));
|
||||
textbox->setFontSize(11);
|
||||
textbox->setLabelPadding(glm::vec2(4, 4));
|
||||
textbox->setTransform(
|
||||
UI_COMPONENT_ALIGN_STRETCH, UI_COMPONENT_ALIGN_END,
|
||||
glm::vec4(0, 238, 0, 0),
|
||||
glm::vec4(0, assetFont->font.getLineHeight(textbox->getFontSize()) * 4, 0, 0),
|
||||
0.0f
|
||||
);
|
||||
}
|
||||
|
@ -7,19 +7,27 @@
|
||||
|
||||
using namespace Dawn;
|
||||
|
||||
PokerVNScene::PokerVNScene(DawnGame *game) : SimpleVNScene(game) {
|
||||
PokerVNScene::PokerVNScene(DawnGame *game) :
|
||||
SimpleVNScene(game),
|
||||
renderTarget(320, 180)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
std::vector<Asset*> PokerVNScene::getRequiredAssets() {
|
||||
auto assMan = &this->game->assetManager;
|
||||
std::vector<Asset*> assets, l;
|
||||
vectorAppend(&assets,SimpleVNScene::getRequiredAssets());
|
||||
vectorAppend(&assets, &(l = PokerPlayerDisplay::getAssets(assMan)));
|
||||
std::vector<Asset*> assets;
|
||||
vectorAppend(&assets, SimpleVNScene::getRequiredAssets());
|
||||
vectorAppend(&assets, PokerPlayerDisplay::getAssets(assMan));
|
||||
return assets;
|
||||
}
|
||||
|
||||
void PokerVNScene::vnStage() {
|
||||
this->renderTarget.setClearColor(COLOR_RED);
|
||||
this->camera->setRenderTarget(&this->renderTarget);
|
||||
|
||||
auto pixelPerfectCamera = this->camera->item->addComponent<PixelPerfectCamera>();
|
||||
|
||||
auto pokerGameItem = this->createSceneItem();
|
||||
this->pokerGame = pokerGameItem->addComponent<PokerGame>();
|
||||
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include "visualnovel/events/PokerBetLoopEvent.hpp"
|
||||
#include "visualnovel/events/PokerInitialEvent.hpp"
|
||||
#include "ui/PokerPlayerDisplay.hpp"
|
||||
#include "display/TextureRenderTarget.hpp"
|
||||
|
||||
namespace Dawn {
|
||||
class PokerVNScene : public SimpleVNScene {
|
||||
@ -23,7 +24,10 @@ namespace Dawn {
|
||||
*/
|
||||
virtual std::vector<PokerPlayer*> getPokerPlayers() = 0;
|
||||
|
||||
|
||||
|
||||
public:
|
||||
TextureRenderTarget renderTarget;
|
||||
PokerGame *pokerGame;
|
||||
std::vector<PokerPlayer*> pokerPlayers;
|
||||
std::map<PokerPlayer*, PokerPlayerDisplay*> pokerPlayerDisplays;
|
||||
|
50
src/dawnpokergame/scenes/SubsceneTest.hpp
Normal file
50
src/dawnpokergame/scenes/SubsceneTest.hpp
Normal file
@ -0,0 +1,50 @@
|
||||
// Copyright (c) 2023 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 "scenes/TestScene.hpp"
|
||||
|
||||
namespace Dawn {
|
||||
class SubsceneTest : public Scene {
|
||||
public:
|
||||
Camera *camera;
|
||||
SceneItem *sceneItem;
|
||||
TestScene subScene;
|
||||
|
||||
SubsceneTest(DawnGame *game) : Scene(game), subScene(game) {
|
||||
|
||||
}
|
||||
|
||||
std::vector<Asset*> getRequiredAssets() override {
|
||||
return this->subScene.getRequiredAssets();
|
||||
}
|
||||
|
||||
void stage() override {
|
||||
this->camera = Camera::create(this);
|
||||
this->camera->transform->lookAt(glm::vec3(300, 300, 300), glm::vec3(0, 0, 0));
|
||||
|
||||
this->subScene.stage();
|
||||
|
||||
this->sceneItem = this->createSceneItem();
|
||||
auto host = this->sceneItem->addComponent<MeshHost>();
|
||||
auto renderer = this->sceneItem->addComponent<MeshRenderer>();
|
||||
|
||||
auto material = this->sceneItem->addComponent<Material>();
|
||||
material->textureValues[material->getShader()->getParameterByName("u_Text")] = this->subScene.renderTarget.getTexture();
|
||||
|
||||
auto renderTargetQuad = this->sceneItem->addComponent<SimpleRenderTargetQuad>();
|
||||
renderTargetQuad->setRenderTarget(&this->subScene.renderTarget);
|
||||
|
||||
auto subSceneController = this->sceneItem->addComponent<SubSceneController>();
|
||||
subSceneController->setSubScene(&this->subScene);
|
||||
|
||||
auto subSceneCameraAlign = this->sceneItem->addComponent<SubSceneCameraAlign>();
|
||||
subSceneCameraAlign->setRenderTarget(&this->subScene.renderTarget);
|
||||
subSceneCameraAlign->setCamera(this->camera);
|
||||
}
|
||||
};
|
||||
}
|
Reference in New Issue
Block a user