Working on removing ui label
This commit is contained in:
@ -15,86 +15,90 @@ VNTextboxScroller::VNTextboxScroller(SceneItem *item) :
|
||||
}
|
||||
|
||||
void VNTextboxScroller::onStart() {
|
||||
assertNotNull(label);
|
||||
// assertNotNull(label);
|
||||
|
||||
std::function<void()> x = [&]{
|
||||
this->lineCurrent = 0;
|
||||
this->timeCharacter = 0;
|
||||
this->label->startQuad = 0;
|
||||
this->label->quadCount = 0;
|
||||
this->readyToClose = false;
|
||||
};
|
||||
x();
|
||||
// std::function<void()> x = [&]{
|
||||
// this->lineCurrent = 0;
|
||||
// this->timeCharacter = 0;
|
||||
// this->label->startQuad = 0;
|
||||
// this->label->quadCount = 0;
|
||||
// this->readyToClose = false;
|
||||
// };
|
||||
// x();
|
||||
|
||||
useEvent(x, this->label->eventTextChanged);
|
||||
// useEvent(x, this->label->eventTextChanged);
|
||||
|
||||
useEvent([&](float_t delta){
|
||||
auto game = this->getGame();
|
||||
// useEvent([&](float_t delta){
|
||||
// auto game = this->getGame();
|
||||
|
||||
this->timeCharacter += delta;
|
||||
if(this->hasRevealedAllCurrentCharacters()) {
|
||||
if(this->hasRevealedAllCharacters()) {
|
||||
if(!this->readyToClose) {
|
||||
this->readyToClose = true;
|
||||
this->eventReadyToClose.invoke();
|
||||
}
|
||||
} else {
|
||||
if(game->inputManager.isPressed(INPUT_BIND_ACCEPT)) {
|
||||
this->lineCurrent += this->getCountOfVisibleLines();
|
||||
this->label->startQuad = 0;
|
||||
for(int32_t i = 0; i < this->lineCurrent; i++) {
|
||||
this->label->startQuad += this->label->measure.getQuadsOnLine(i);
|
||||
}
|
||||
this->label->quadCount = 0;
|
||||
this->timeCharacter = 0.0f;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
// this->timeCharacter += delta;
|
||||
// if(this->hasRevealedAllCurrentCharacters()) {
|
||||
// if(this->hasRevealedAllCharacters()) {
|
||||
// if(!this->readyToClose) {
|
||||
// this->readyToClose = true;
|
||||
// this->eventReadyToClose.invoke();
|
||||
// }
|
||||
// } else {
|
||||
// if(game->inputManager.isPressed(INPUT_BIND_ACCEPT)) {
|
||||
// this->lineCurrent += this->getCountOfVisibleLines();
|
||||
// this->label->startQuad = 0;
|
||||
// for(int32_t i = 0; i < this->lineCurrent; i++) {
|
||||
// this->label->startQuad += this->label->measure.getQuadsOnLine(i);
|
||||
// }
|
||||
// this->label->quadCount = 0;
|
||||
// this->timeCharacter = 0.0f;
|
||||
// }
|
||||
// }
|
||||
// return;
|
||||
// }
|
||||
|
||||
auto lastTimeCharacter = mathFloor<int32_t>(this->timeCharacter);
|
||||
if(game->inputManager.isDown(INPUT_BIND_ACCEPT)) {
|
||||
this->timeCharacter += game->timeManager.delta * VN_TEXTBOX_SPEED_FASTER;
|
||||
} else {
|
||||
this->timeCharacter += game->timeManager.delta * VN_TEXTBOX_SPEED;
|
||||
}
|
||||
// auto lastTimeCharacter = mathFloor<int32_t>(this->timeCharacter);
|
||||
// if(game->inputManager.isDown(INPUT_BIND_ACCEPT)) {
|
||||
// this->timeCharacter += game->timeManager.delta * VN_TEXTBOX_SPEED_FASTER;
|
||||
// } else {
|
||||
// this->timeCharacter += game->timeManager.delta * VN_TEXTBOX_SPEED;
|
||||
// }
|
||||
|
||||
auto newCount = mathFloor<int32_t>(this->timeCharacter);
|
||||
if(newCount == this->label->quadCount) return;
|
||||
this->label->quadCount = mathFloor<int32_t>(this->timeCharacter);
|
||||
this->eventCharacterRevealed.invoke();
|
||||
}, getScene()->eventSceneUpdate);
|
||||
// auto newCount = mathFloor<int32_t>(this->timeCharacter);
|
||||
// if(newCount == this->label->quadCount) return;
|
||||
// this->label->quadCount = mathFloor<int32_t>(this->timeCharacter);
|
||||
// this->eventCharacterRevealed.invoke();
|
||||
// }, getScene()->eventSceneUpdate);
|
||||
assertUnreachable();
|
||||
}
|
||||
|
||||
size_t VNTextboxScroller::getCountOfVisibleLines() {
|
||||
float_t y = this->label->getHeight();
|
||||
size_t i = 1;
|
||||
for(i = this->label->measure.getLineCount(); i > 0; --i) {
|
||||
if(y >= this->label->measure.getHeightOfLineCount(i)) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return this->label->measure.getLineCount();
|
||||
// float_t y = this->label->getHeight();
|
||||
// size_t i = 1;
|
||||
// for(i = this->label->measure.getLineCount(); i > 0; --i) {
|
||||
// if(y >= this->label->measure.getHeightOfLineCount(i)) {
|
||||
// return i;
|
||||
// }
|
||||
// }
|
||||
// return this->label->measure.getLineCount();
|
||||
assertUnreachable();
|
||||
}
|
||||
|
||||
bool_t VNTextboxScroller::hasRevealedAllCurrentCharacters() {
|
||||
int32_t quadsTotal = 0;
|
||||
for(
|
||||
size_t i = this->lineCurrent;
|
||||
i < mathMin<size_t>(
|
||||
this->label->measure.getLineCount(),
|
||||
this->lineCurrent + this->getCountOfVisibleLines()
|
||||
);
|
||||
i++
|
||||
) {
|
||||
quadsTotal += this->label->measure.getQuadsOnLine(i);
|
||||
}
|
||||
return mathFloor<int32_t>(this->timeCharacter) >= quadsTotal;
|
||||
// int32_t quadsTotal = 0;
|
||||
// for(
|
||||
// size_t i = this->lineCurrent;
|
||||
// i < mathMin<size_t>(
|
||||
// this->label->measure.getLineCount(),
|
||||
// this->lineCurrent + this->getCountOfVisibleLines()
|
||||
// );
|
||||
// i++
|
||||
// ) {
|
||||
// quadsTotal += this->label->measure.getQuadsOnLine(i);
|
||||
// }
|
||||
// return mathFloor<int32_t>(this->timeCharacter) >= quadsTotal;
|
||||
assertUnreachable();
|
||||
}
|
||||
|
||||
bool_t VNTextboxScroller::hasRevealedAllCharacters() {
|
||||
return (
|
||||
this->lineCurrent + this->getCountOfVisibleLines() >=
|
||||
this->label->measure.getLineCount()
|
||||
);
|
||||
// return (
|
||||
// this->lineCurrent + this->getCountOfVisibleLines() >=
|
||||
// this->label->measure.getLineCount()
|
||||
// );
|
||||
assertUnreachable();
|
||||
}
|
@ -5,7 +5,7 @@
|
||||
|
||||
#pragma once
|
||||
#include "scene/SceneItemComponent.hpp"
|
||||
#include "scene/components/ui/UILabel.hpp"
|
||||
#include "scene/components/ui/text/UILabelNew.hpp"
|
||||
#include "input/InputManager.hpp"
|
||||
|
||||
#define VN_TEXTBOX_SPEED 25.0f
|
||||
@ -15,7 +15,7 @@ namespace Dawn {
|
||||
class VNTextboxScroller : public SceneItemComponent {
|
||||
public:
|
||||
// @optional
|
||||
StateProperty<UILabel*> label;
|
||||
StateProperty<UILabelNew*> label;
|
||||
|
||||
StateEvent<> eventReadyToClose;
|
||||
StateEvent<> eventCharacterRevealed;
|
||||
|
@ -20,7 +20,8 @@ namespace Dawn {
|
||||
scroller = this->getScene()->findComponent<VNTextboxScroller>();
|
||||
assertNotNull(scroller);
|
||||
|
||||
scroller->label->text = text;
|
||||
assertUnreachable();
|
||||
// scroller->label->text = text;
|
||||
|
||||
useEvent([&](inputbind_t bind){
|
||||
if(bind != INPUT_BIND_ACCEPT) return;
|
||||
|
Reference in New Issue
Block a user