Adding VN Character interface
This commit is contained in:
@ -1,3 +1,4 @@
|
|||||||
test,Some test string,
|
|
||||||
test2,Some other test string
|
|
||||||
undefined,UNDEFINED
|
undefined,UNDEFINED
|
||||||
|
scene.first.test,Bruh
|
||||||
|
character.unknown,Unknown
|
||||||
|
character.penny.name,Penny
|
||||||
|
|
@ -1,3 +0,0 @@
|
|||||||
test,Some FRENCH string,
|
|
||||||
test2,Some FRENCHER string,
|
|
||||||
undefined,UNDEFINED
|
|
|
@ -7,4 +7,5 @@
|
|||||||
target_sources(${DAWN_TARGET_NAME}
|
target_sources(${DAWN_TARGET_NAME}
|
||||||
PRIVATE
|
PRIVATE
|
||||||
SimpleVisualNovelBackground.cpp
|
SimpleVisualNovelBackground.cpp
|
||||||
|
VisualNovelCharacter.cpp
|
||||||
)
|
)
|
14
src/dawn/visualnovel/components/VisualNovelCharacter.cpp
Normal file
14
src/dawn/visualnovel/components/VisualNovelCharacter.cpp
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
// Copyright (c) 2022 Dominic Masters
|
||||||
|
//
|
||||||
|
// This software is released under the MIT License.
|
||||||
|
// https://opensource.org/licenses/MIT
|
||||||
|
|
||||||
|
#include "VisualNovelCharacter.hpp"
|
||||||
|
|
||||||
|
using namespace Dawn;
|
||||||
|
|
||||||
|
VisualNovelCharacter::VisualNovelCharacter(SceneItem *item) :
|
||||||
|
SceneItemComponent(item)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
22
src/dawn/visualnovel/components/VisualNovelCharacter.hpp
Normal file
22
src/dawn/visualnovel/components/VisualNovelCharacter.hpp
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
// Copyright (c) 2022 Dominic Masters
|
||||||
|
//
|
||||||
|
// This software is released under the MIT License.
|
||||||
|
// https://opensource.org/licenses/MIT
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
#include "scene/SceneItemComponent.hpp"
|
||||||
|
|
||||||
|
namespace Dawn {
|
||||||
|
class VisualNovelCharacter : public SceneItemComponent {
|
||||||
|
public:
|
||||||
|
std::string nameKey = "character.unknown";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Visual Novel Character Component. Mostly logic-less but provides nice
|
||||||
|
* interfaces for sibling components.
|
||||||
|
*
|
||||||
|
* @param item Item that this component belongs to.
|
||||||
|
*/
|
||||||
|
VisualNovelCharacter(SceneItem *item);
|
||||||
|
};
|
||||||
|
}
|
@ -8,16 +8,19 @@
|
|||||||
using namespace Dawn;
|
using namespace Dawn;
|
||||||
|
|
||||||
VisualNovelTextboxEvent::VisualNovelTextboxEvent(
|
VisualNovelTextboxEvent::VisualNovelTextboxEvent(
|
||||||
VisualNovelManager *manager,
|
VisualNovelManager *manager,
|
||||||
std::string key
|
VisualNovelCharacter *character,
|
||||||
|
std::string languageKey
|
||||||
) : IVisualNovelEvent(manager) {
|
) : IVisualNovelEvent(manager) {
|
||||||
this->key = key;
|
this->character = character;
|
||||||
|
this->languageKey = languageKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
void VisualNovelTextboxEvent::onStart(IVisualNovelEvent *previous) {
|
void VisualNovelTextboxEvent::onStart(IVisualNovelEvent *previous) {
|
||||||
if(this->manager->textBox == nullptr) return;
|
if(this->manager->textBox == nullptr) return;
|
||||||
|
|
||||||
this->manager->textBox->setText(this->key);
|
this->manager->textBox->setText(this->languageKey);
|
||||||
|
this->manager->textBox->setCharacter(this->character);
|
||||||
this->manager->textBox->show();
|
this->manager->textBox->show();
|
||||||
this->hasSetText = true;
|
this->hasSetText = true;
|
||||||
}
|
}
|
||||||
@ -26,7 +29,8 @@ bool_t VisualNovelTextboxEvent::onUpdate() {
|
|||||||
if(this->manager->textBox == nullptr) return true;
|
if(this->manager->textBox == nullptr) return true;
|
||||||
|
|
||||||
if(!this->hasSetText) {
|
if(!this->hasSetText) {
|
||||||
this->manager->textBox->setText(this->key);
|
this->manager->textBox->setText(this->languageKey);
|
||||||
|
this->manager->textBox->setCharacter(this->character);
|
||||||
this->manager->textBox->show();
|
this->manager->textBox->show();
|
||||||
this->hasSetText = true;
|
this->hasSetText = true;
|
||||||
}
|
}
|
||||||
|
@ -5,11 +5,13 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "visualnovel/VisualNovelManager.hpp"
|
#include "visualnovel/VisualNovelManager.hpp"
|
||||||
|
#include "visualnovel/components/VisualNovelCharacter.hpp"
|
||||||
|
|
||||||
namespace Dawn {
|
namespace Dawn {
|
||||||
class VisualNovelTextboxEvent : public IVisualNovelEvent {
|
class VisualNovelTextboxEvent : public IVisualNovelEvent {
|
||||||
protected:
|
protected:
|
||||||
std::string key;
|
std::string languageKey;
|
||||||
|
VisualNovelCharacter *character;
|
||||||
bool_t hasSetText = false;
|
bool_t hasSetText = false;
|
||||||
|
|
||||||
void onStart(IVisualNovelEvent *previous) override;
|
void onStart(IVisualNovelEvent *previous) override;
|
||||||
@ -17,9 +19,18 @@ namespace Dawn {
|
|||||||
void onEnd() override;
|
void onEnd() override;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
/**
|
||||||
|
* Create a new Textbox Event. This will queue a conversation item for the
|
||||||
|
* textbox to display.
|
||||||
|
*
|
||||||
|
* @param manager Visual Novel Manager instance for this event.
|
||||||
|
* @param character Character that is intended to be speaking.
|
||||||
|
* @param languageKey Language Key to talk.
|
||||||
|
*/
|
||||||
VisualNovelTextboxEvent(
|
VisualNovelTextboxEvent(
|
||||||
VisualNovelManager *manager,
|
VisualNovelManager *manager,
|
||||||
std::string text
|
VisualNovelCharacter *character,
|
||||||
|
std::string languageKey
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
}
|
}
|
@ -153,6 +153,10 @@ void VisualNovelTextbox::setText(std::string key, float_t fontSize) {
|
|||||||
this->label.updateMesh();
|
this->label.updateMesh();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void VisualNovelTextbox::setCharacter(VisualNovelCharacter *character) {
|
||||||
|
this->character = character;
|
||||||
|
}
|
||||||
|
|
||||||
void VisualNovelTextbox::setText(std::string key) {
|
void VisualNovelTextbox::setText(std::string key) {
|
||||||
this->label.setText(key);
|
this->label.setText(key);
|
||||||
this->label.updateMesh();
|
this->label.updateMesh();
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
#include "ui/UILabel.hpp"
|
#include "ui/UILabel.hpp"
|
||||||
#include "ui/UIEmpty.hpp"
|
#include "ui/UIEmpty.hpp"
|
||||||
#include "util/mathutils.hpp"
|
#include "util/mathutils.hpp"
|
||||||
|
#include "visualnovel/components/VisualNovelCharacter.hpp"
|
||||||
|
|
||||||
#define VISUAL_NOVEL_TEXTBOX_SPEED 25.0f
|
#define VISUAL_NOVEL_TEXTBOX_SPEED 25.0f
|
||||||
#define VISUAL_NOVEL_TEXTBOX_SPEED_FASTER 40.0f
|
#define VISUAL_NOVEL_TEXTBOX_SPEED_FASTER 40.0f
|
||||||
@ -21,6 +22,7 @@ namespace Dawn {
|
|||||||
UIEmpty selfParent;
|
UIEmpty selfParent;
|
||||||
float_t timeCharacter = 0.0f;
|
float_t timeCharacter = 0.0f;
|
||||||
bool_t visible = false;
|
bool_t visible = false;
|
||||||
|
VisualNovelCharacter *character = nullptr;
|
||||||
|
|
||||||
void updatePositions() override;
|
void updatePositions() override;
|
||||||
void drawSelf(UIShader *shader, glm::mat4 selfTransform) override;
|
void drawSelf(UIShader *shader, glm::mat4 selfTransform) override;
|
||||||
@ -82,6 +84,13 @@ namespace Dawn {
|
|||||||
*/
|
*/
|
||||||
void setText(std::string key);
|
void setText(std::string key);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the VN Character for this text.
|
||||||
|
*
|
||||||
|
* @param character Character to set.
|
||||||
|
*/
|
||||||
|
void setCharacter(VisualNovelCharacter *character);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the font size to use.
|
* Sets the font size to use.
|
||||||
*
|
*
|
||||||
|
@ -25,7 +25,6 @@ add_subdirectory(scenes)
|
|||||||
|
|
||||||
# Assets
|
# Assets
|
||||||
tool_language(language_en locale/en.csv)
|
tool_language(language_en locale/en.csv)
|
||||||
tool_language(language_fr locale/fr.csv)
|
|
||||||
tool_texture(texture_test texture_test.png)
|
tool_texture(texture_test texture_test.png)
|
||||||
tool_texture(texture_city_day borrowed/city_day.png)
|
tool_texture(texture_city_day borrowed/city_day.png)
|
||||||
tool_texture(texture_city_night borrowed/city_night.png)
|
tool_texture(texture_city_night borrowed/city_night.png)
|
||||||
@ -44,7 +43,6 @@ tool_truetype(truetype_ark
|
|||||||
|
|
||||||
add_dependencies(${DAWN_TARGET_NAME}
|
add_dependencies(${DAWN_TARGET_NAME}
|
||||||
language_en
|
language_en
|
||||||
language_fr
|
|
||||||
texture_test
|
texture_test
|
||||||
tileset_penny
|
tileset_penny
|
||||||
truetype_ark
|
truetype_ark
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
#include "asset/AssetManager.hpp"
|
#include "asset/AssetManager.hpp"
|
||||||
#include "poker/PokerPlayer.hpp"
|
#include "poker/PokerPlayer.hpp"
|
||||||
#include "scene/components/Components.hpp"
|
#include "scene/components/Components.hpp"
|
||||||
|
#include "visualnovel/components/VisualNovelCharacter.hpp"
|
||||||
#include "display/animation/TiledSpriteAnimation.hpp"
|
#include "display/animation/TiledSpriteAnimation.hpp"
|
||||||
|
|
||||||
namespace Dawn {
|
namespace Dawn {
|
||||||
@ -31,6 +32,9 @@ namespace Dawn {
|
|||||||
auto tiledSprite = item->addComponent<TiledSprite>();
|
auto tiledSprite = item->addComponent<TiledSprite>();
|
||||||
auto animation = item->addComponent<AnimationController>();
|
auto animation = item->addComponent<AnimationController>();
|
||||||
auto pokerPlayer = item->addComponent<PokerPlayer>();
|
auto pokerPlayer = item->addComponent<PokerPlayer>();
|
||||||
|
auto vnCharacter = item->addComponent<VisualNovelCharacter>();
|
||||||
|
|
||||||
|
vnCharacter->nameKey = "character.penny.name";
|
||||||
|
|
||||||
auto param = material->getShader()->getParameterByName("u_Text");
|
auto param = material->getShader()->getParameterByName("u_Text");
|
||||||
material->textureValues[param] = &textureAsset->texture;
|
material->textureValues[param] = &textureAsset->texture;
|
||||||
|
@ -41,10 +41,10 @@ namespace Dawn {
|
|||||||
);
|
);
|
||||||
|
|
||||||
start
|
start
|
||||||
->then(new VisualNovelTextboxEvent(vnManager, "test"))
|
->then(new VisualNovelTextboxEvent(vnManager, penny->getComponent<VisualNovelCharacter>(), "undefined"))
|
||||||
->then(new PokerNewGameEvent(vnManager))
|
// ->then(new PokerNewGameEvent(vnManager))
|
||||||
->then(new VisualNovelTextboxEvent(vnManager, "test"))
|
->then(new VisualNovelTextboxEvent(vnManager, penny->getComponent<VisualNovelCharacter>(), "undefined"))
|
||||||
->then(new PokerInitialEvent(vnManager))
|
// ->then(new PokerInitialEvent(vnManager))
|
||||||
;
|
;
|
||||||
|
|
||||||
return start;
|
return start;
|
||||||
|
@ -16,49 +16,49 @@ void PokerBetLoopEvent::onStart(IVisualNovelEvent *prev) {
|
|||||||
|
|
||||||
auto betting = this->then(evt2);
|
auto betting = this->then(evt2);
|
||||||
betting
|
betting
|
||||||
->whenEveryoneFolded(new VisualNovelTextboxEvent(this->manager, "Everyone Folded"))
|
// ->whenEveryoneFolded(new VisualNovelTextboxEvent(this->manager, "Everyone Folded"))
|
||||||
->then(new PokerWinnerEvent(this->manager))
|
->then(new PokerWinnerEvent(this->manager))
|
||||||
->then(new PokerInitialEvent(this->manager))
|
->then(new PokerInitialEvent(this->manager))
|
||||||
;
|
;
|
||||||
betting
|
betting
|
||||||
->whenBettingFinished(new VisualNovelTextboxEvent(this->manager, "Betting Finished"))
|
// ->whenBettingFinished(new VisualNovelTextboxEvent(this->manager, "Betting Finished"))
|
||||||
->then(new PokerWinnerEvent(this->manager))
|
->then(new PokerWinnerEvent(this->manager))
|
||||||
->then(new PokerInitialEvent(this->manager))
|
->then(new PokerInitialEvent(this->manager))
|
||||||
;
|
;
|
||||||
betting
|
betting
|
||||||
->whenTurn(new PokerTurnEvent(this->manager))
|
->whenTurn(new PokerTurnEvent(this->manager))
|
||||||
->then(new VisualNovelTextboxEvent(this->manager, "Turn Time"))
|
// ->then(new VisualNovelTextboxEvent(this->manager, "Turn Time"))
|
||||||
->then(new PokerNewBettingRoundEvent(this->manager))
|
->then(new PokerNewBettingRoundEvent(this->manager))
|
||||||
->then(new PokerBetLoopEvent(this->manager))
|
->then(new PokerBetLoopEvent(this->manager))
|
||||||
;
|
;
|
||||||
betting
|
betting
|
||||||
->whenHumanBet(new VisualNovelTextboxEvent(this->manager, "Human Bet"))
|
// ->whenHumanBet(new VisualNovelTextboxEvent(this->manager, "Human Bet"))
|
||||||
->then(new PokerBetLoopEvent(this->manager))
|
->then(new PokerBetLoopEvent(this->manager))
|
||||||
;
|
;
|
||||||
|
|
||||||
// AI Betting
|
// AI Betting
|
||||||
auto aiBet = betting
|
auto aiBet = betting
|
||||||
->whenAiBet(new VisualNovelTextboxEvent(this->manager, "AI Bet"))
|
// ->whenAiBet(new VisualNovelTextboxEvent(this->manager, "AI Bet"))
|
||||||
->then(new PokerAIBetEvent(this->manager))
|
->then(new PokerAIBetEvent(this->manager))
|
||||||
;
|
;
|
||||||
aiBet
|
aiBet
|
||||||
->whenFolded(new VisualNovelTextboxEvent(this->manager, "Folded"))
|
// ->whenFolded(new VisualNovelTextboxEvent(this->manager, "Folded"))
|
||||||
->then(new PokerBetLoopEvent(this->manager))
|
->then(new PokerBetLoopEvent(this->manager))
|
||||||
;
|
;
|
||||||
aiBet
|
aiBet
|
||||||
->whenAllIn(new VisualNovelTextboxEvent(this->manager, "All In"))
|
// ->whenAllIn(new VisualNovelTextboxEvent(this->manager, "All In"))
|
||||||
->then(new PokerBetLoopEvent(this->manager))
|
->then(new PokerBetLoopEvent(this->manager))
|
||||||
;
|
;
|
||||||
aiBet
|
aiBet
|
||||||
->whenBetting(new VisualNovelTextboxEvent(this->manager, "Betting"))
|
// ->whenBetting(new VisualNovelTextboxEvent(this->manager, "Betting"))
|
||||||
->then(new PokerBetLoopEvent(this->manager))
|
->then(new PokerBetLoopEvent(this->manager))
|
||||||
;
|
;
|
||||||
aiBet
|
aiBet
|
||||||
->whenCalling(new VisualNovelTextboxEvent(this->manager, "Calling"))
|
// ->whenCalling(new VisualNovelTextboxEvent(this->manager, "Calling"))
|
||||||
->then(new PokerBetLoopEvent(this->manager))
|
->then(new PokerBetLoopEvent(this->manager))
|
||||||
;
|
;
|
||||||
aiBet
|
aiBet
|
||||||
->whenChecking(new VisualNovelTextboxEvent(this->manager, "Checking"))
|
// ->whenChecking(new VisualNovelTextboxEvent(this->manager, "Checking"))
|
||||||
->then(new PokerBetLoopEvent(this->manager))
|
->then(new PokerBetLoopEvent(this->manager))
|
||||||
;
|
;
|
||||||
}
|
}
|
@ -20,11 +20,11 @@ namespace Dawn {
|
|||||||
|
|
||||||
this
|
this
|
||||||
->then(new PokerNewRoundEvent(this->manager))
|
->then(new PokerNewRoundEvent(this->manager))
|
||||||
->then(new VisualNovelTextboxEvent(this->manager, "Round Started"))
|
// ->then(new VisualNovelTextboxEvent(this->manager, "Round Started"))
|
||||||
->then(new PokerTakeBlindsEvent(this->manager))
|
->then(new PokerTakeBlindsEvent(this->manager))
|
||||||
->then(new VisualNovelTextboxEvent(this->manager, "Blinds Taken"))
|
// ->then(new VisualNovelTextboxEvent(this->manager, "Blinds Taken"))
|
||||||
->then(new PokerDealEvent(this->manager))
|
->then(new PokerDealEvent(this->manager))
|
||||||
->then(new VisualNovelTextboxEvent(this->manager, "Cards Dealt"))
|
// ->then(new VisualNovelTextboxEvent(this->manager, "Cards Dealt"))
|
||||||
->then(new PokerBetLoopEvent(this->manager))
|
->then(new PokerBetLoopEvent(this->manager))
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user