From b15e0874dab723e7b1ceeb19af6c645530c8a52b Mon Sep 17 00:00:00 2001 From: Vincent-FK Date: Mon, 17 Feb 2020 07:11:27 +0100 Subject: [PATCH] horizontal scolling text now goes forward and backwards Signed-off-by: Vincent-FK --- .../Component/ReloadableScrollingText.cpp | 25 ++++++++++++++++--- .../Component/ReloadableScrollingText.h | 1 + 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/RetroFE/Source/Graphics/Component/ReloadableScrollingText.cpp b/RetroFE/Source/Graphics/Component/ReloadableScrollingText.cpp index d3bf41b..81a1421 100644 --- a/RetroFE/Source/Graphics/Component/ReloadableScrollingText.cpp +++ b/RetroFE/Source/Graphics/Component/ReloadableScrollingText.cpp @@ -57,6 +57,7 @@ ReloadableScrollingText::ReloadableScrollingText(Configuration &config, bool sys , currentCollection_("") , page_(NULL) , displayOffset_(displayOffset) + , scrollForward_(true) { text_.clear( ); @@ -83,7 +84,8 @@ void ReloadableScrollingText::update(float dt) { if (direction_ == "horizontal") { - currentPosition_ += scrollingSpeed_ * dt * scaleX_; + //currentPosition_ += scrollingSpeed_ * dt * scaleX_; + currentPosition_ += (scrollForward_?1.0f:-1.0f) * scrollingSpeed_ * dt * scaleX_; } else if (direction_ == "vertical") { @@ -643,12 +645,29 @@ void ReloadableScrollingText::draw( ) imageWidth * scale * scaleX_, (static_cast( xOrigin ) + imageMaxWidth));*/ //if (currentPosition_ > imageWidth * scale * scaleX_) - if (waitStartTime_ <= 0 && - imageWidth * scale * scaleX_ - currentPosition_ <= imageMaxWidth) + + /*if (waitStartTime_ <= 0 && + imageWidth * scale * scaleX_ - currentPosition_ <= imageMaxWidth) { waitStartTime_ = startTime_; waitEndTime_ = endTime_; currentPosition_ = -startPosition_ * scaleX_; + */ + + if (scrollForward_ && + waitStartTime_ <= 0 && + imageWidth * scale * scaleX_ - currentPosition_ <= imageMaxWidth) + { + waitEndTime_ = endTime_; + //currentPosition_ = -startPosition_ * scaleX_; + scrollForward_ = false; + } + else if(!scrollForward_ && + waitEndTime_ <= 0 && + currentPosition_ <= -startPosition_ * scaleX_) + { + waitStartTime_ = startTime_; + scrollForward_ = true; } } diff --git a/RetroFE/Source/Graphics/Component/ReloadableScrollingText.h b/RetroFE/Source/Graphics/Component/ReloadableScrollingText.h index 343eff2..263837c 100644 --- a/RetroFE/Source/Graphics/Component/ReloadableScrollingText.h +++ b/RetroFE/Source/Graphics/Component/ReloadableScrollingText.h @@ -63,4 +63,5 @@ private: std::string currentCollection_; Page *page_; int displayOffset_; + bool scrollForward_; };