Part one - removed references and smart pointers
This commit is contained in:
@ -8,7 +8,7 @@
|
||||
|
||||
using namespace Dawn;
|
||||
|
||||
VisualNovelTextbox::VisualNovelTextbox(UICanvas &canvas) :
|
||||
VisualNovelTextbox::VisualNovelTextbox(UICanvas *canvas) :
|
||||
UIComponent(canvas),
|
||||
border(canvas),
|
||||
label(canvas)
|
||||
@ -21,7 +21,7 @@ VisualNovelTextbox::VisualNovelTextbox(UICanvas &canvas) :
|
||||
this->label.startQuad = 0;
|
||||
this->label.quadCount = 0;
|
||||
|
||||
this->canvas.getScene().eventSceneUnpausedUpdate.addListener(
|
||||
this->canvas->getScene()->eventSceneUnpausedUpdate.addListener(
|
||||
this, &VisualNovelTextbox::textboxOnSceneUpdate
|
||||
);
|
||||
}
|
||||
@ -53,15 +53,15 @@ void VisualNovelTextbox::updatePositions() {
|
||||
}
|
||||
|
||||
void VisualNovelTextbox::textboxOnSceneUpdate() {
|
||||
DawnGame &game = this->canvas.getGame();
|
||||
DawnGame *game = this->canvas->getGame();
|
||||
|
||||
if(this->hasRevealedAllCurrentCharacters()) {
|
||||
if(this->hasRevealedAllCharacters()) {
|
||||
if(game.inputManager.isPressed(INPUT_BIND_ACCEPT)) {
|
||||
if(game->inputManager.isPressed(INPUT_BIND_ACCEPT)) {
|
||||
this->eventClose.invoke();
|
||||
}
|
||||
} else {
|
||||
if(game.inputManager.isPressed(INPUT_BIND_ACCEPT)) {
|
||||
if(game->inputManager.isPressed(INPUT_BIND_ACCEPT)) {
|
||||
this->lineCurrent += this->getCountOfVisibleLines();
|
||||
this->label.startQuad = 0;
|
||||
for(int32_t i = 0; i < this->lineCurrent; i++) {
|
||||
@ -90,10 +90,10 @@ void VisualNovelTextbox::textboxOnSceneUpdate() {
|
||||
}
|
||||
|
||||
auto lastTimeCharacter = (int32_t)mathFloorFloat(this->timeCharacter);
|
||||
if(game.inputManager.isDown(INPUT_BIND_ACCEPT)) {
|
||||
this->timeCharacter += game.timeManager.delta * VISUAL_NOVEL_TEXTBOX_SPEED_FASTER;
|
||||
if(game->inputManager.isDown(INPUT_BIND_ACCEPT)) {
|
||||
this->timeCharacter += game->timeManager.delta * VISUAL_NOVEL_TEXTBOX_SPEED_FASTER;
|
||||
} else {
|
||||
this->timeCharacter += game.timeManager.delta * VISUAL_NOVEL_TEXTBOX_SPEED;
|
||||
this->timeCharacter += game->timeManager.delta * VISUAL_NOVEL_TEXTBOX_SPEED;
|
||||
}
|
||||
auto newTimeCharacter = (int32_t)mathFloorFloat(this->timeCharacter);
|
||||
if(newTimeCharacter == lastTimeCharacter) return;
|
||||
@ -114,7 +114,7 @@ int32_t VisualNovelTextbox::getCountOfVisibleLines() {
|
||||
return this->label.measure.getLineCount();
|
||||
}
|
||||
|
||||
void VisualNovelTextbox::drawSelf(UIShader &shader, glm::mat4 self) {}
|
||||
void VisualNovelTextbox::drawSelf(UIShader *shader, glm::mat4 self) {}
|
||||
|
||||
void VisualNovelTextbox::setBorder(Texture *texture, glm::vec2 dimensions) {
|
||||
this->border.texture = texture;
|
||||
@ -156,7 +156,7 @@ bool_t VisualNovelTextbox::hasRevealedAllCharacters() {
|
||||
}
|
||||
|
||||
VisualNovelTextbox::~VisualNovelTextbox() {
|
||||
this->canvas.getScene().eventSceneUnpausedUpdate.removeListener(
|
||||
this->canvas->getScene()->eventSceneUnpausedUpdate.removeListener(
|
||||
this, &VisualNovelTextbox::textboxOnSceneUpdate
|
||||
);
|
||||
}
|
@ -22,7 +22,7 @@ namespace Dawn {
|
||||
float_t timeCharacter = 0.0f;
|
||||
|
||||
void updatePositions() override;
|
||||
void drawSelf(UIShader &shader, glm::mat4 selfTransform) override;
|
||||
void drawSelf(UIShader *shader, glm::mat4 selfTransform) override;
|
||||
|
||||
/**
|
||||
* Listens for scene updates.
|
||||
@ -44,17 +44,12 @@ namespace Dawn {
|
||||
Event<> eventAllCharactersRevealed;
|
||||
Event<> eventClose;
|
||||
|
||||
VisualNovelTextbox(UICanvas &canvas);
|
||||
|
||||
|
||||
|
||||
VisualNovelTextbox(UICanvas *canvas);
|
||||
void setFont(Font *font);
|
||||
void setBorder(Texture *texture, glm::vec2 dimensions);
|
||||
void setText(std::string text, float_t fontSize);
|
||||
|
||||
bool_t hasRevealedAllCurrentCharacters();
|
||||
bool_t hasRevealedAllCharacters();
|
||||
|
||||
~VisualNovelTextbox();
|
||||
};
|
||||
}
|
Reference in New Issue
Block a user