mirror of
https://github.com/FunKey-Project/RetroFE.git
synced 2025-12-12 17:58:53 +01:00
render scrolling text only if necessary
Signed-off-by: Vincent-FK <vincent.buso@funkey-project.com>
This commit is contained in:
parent
ebc035c869
commit
5b51c7de41
@ -59,6 +59,7 @@ ReloadableScrollingText::ReloadableScrollingText(Configuration &config, bool sys
|
|||||||
, displayOffset_(displayOffset)
|
, displayOffset_(displayOffset)
|
||||||
, scrollForward_(true)
|
, scrollForward_(true)
|
||||||
, needScrolling_(true)
|
, needScrolling_(true)
|
||||||
|
, needRender_(false)
|
||||||
|
|
||||||
{
|
{
|
||||||
text_.clear( );
|
text_.clear( );
|
||||||
@ -85,20 +86,22 @@ void ReloadableScrollingText::update(float dt)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (direction_ == "horizontal")
|
if (direction_ == "horizontal")
|
||||||
{
|
{
|
||||||
//currentPosition_ += scrollingSpeed_ * dt * scaleX_;
|
//currentPosition_ += scrollingSpeed_ * dt * scaleX_;
|
||||||
currentPosition_ += (scrollForward_?1.0f:-1.0f) * scrollingSpeed_ * dt * scaleX_;
|
currentPosition_ += (scrollForward_?1.0f:-1.0f) * scrollingSpeed_ * dt * scaleX_;
|
||||||
|
|
||||||
// Sanity check
|
// Sanity check
|
||||||
if(currentPosition_ < -startPosition_ * scaleX_){
|
if(currentPosition_ < -startPosition_ * scaleX_){
|
||||||
currentPosition_ = -startPosition_ * scaleX_;
|
currentPosition_ = -startPosition_ * scaleX_;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if (direction_ == "vertical")
|
}
|
||||||
{
|
else if (direction_ == "vertical")
|
||||||
|
{
|
||||||
currentPosition_ += scrollingSpeed_ * dt * scaleY_;
|
currentPosition_ += scrollingSpeed_ * dt * scaleY_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
needRender_ = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -141,6 +144,7 @@ void ReloadableScrollingText::initializeFonts( )
|
|||||||
|
|
||||||
void ReloadableScrollingText::reloadTexture( )
|
void ReloadableScrollingText::reloadTexture( )
|
||||||
{
|
{
|
||||||
|
needRender_ = true;
|
||||||
|
|
||||||
if (direction_ == "horizontal")
|
if (direction_ == "horizontal")
|
||||||
{
|
{
|
||||||
@ -705,13 +709,13 @@ void ReloadableScrollingText::draw( )
|
|||||||
Font::GlyphInfo glyph;
|
Font::GlyphInfo glyph;
|
||||||
if (font->getRect( text_[l][i], glyph ))
|
if (font->getRect( text_[l][i], glyph ))
|
||||||
{
|
{
|
||||||
if ( glyph.minX < 0 )
|
if ( glyph.minX < 0 )
|
||||||
{
|
{
|
||||||
curLineWidth += glyph.minX;
|
curLineWidth += glyph.minX;
|
||||||
}
|
}
|
||||||
|
|
||||||
char_width = static_cast<int>( glyph.rect.w?glyph.rect.w:glyph.advance );
|
char_width = static_cast<int>( glyph.rect.w?glyph.rect.w:glyph.advance );
|
||||||
curLineWidth += char_width;
|
curLineWidth += char_width;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -728,8 +732,9 @@ void ReloadableScrollingText::draw( )
|
|||||||
waitStartTime_ <= 0 &&
|
waitStartTime_ <= 0 &&
|
||||||
imageWidth * scale * scaleX_ - currentPosition_ <= imageMaxWidth)
|
imageWidth * scale * scaleX_ - currentPosition_ <= imageMaxWidth)
|
||||||
{
|
{
|
||||||
waitEndTime_ = endTime_;
|
waitEndTime_ = endTime_;
|
||||||
scrollForward_ = false;
|
scrollForward_ = false;
|
||||||
|
needRender_ = true;
|
||||||
}
|
}
|
||||||
else if(!scrollForward_ &&
|
else if(!scrollForward_ &&
|
||||||
waitEndTime_ <= 0 &&
|
waitEndTime_ <= 0 &&
|
||||||
@ -738,6 +743,7 @@ void ReloadableScrollingText::draw( )
|
|||||||
waitStartTime_ = startTime_;
|
waitStartTime_ = startTime_;
|
||||||
currentPosition_ = -startPosition_ * scaleX_;
|
currentPosition_ = -startPosition_ * scaleX_;
|
||||||
scrollForward_ = true;
|
scrollForward_ = true;
|
||||||
|
needRender_ = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -959,9 +965,10 @@ bool ReloadableScrollingText::mustRender( )
|
|||||||
{
|
{
|
||||||
if ( Component::mustRender( ) ) return true;
|
if ( Component::mustRender( ) ) return true;
|
||||||
|
|
||||||
if (!text_.empty( ) && baseViewInfo.Alpha > 0.0f)
|
if (!text_.empty( ) && baseViewInfo.Alpha > 0.0f && needRender_)
|
||||||
{
|
{
|
||||||
return true;
|
needRender_ = false;
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@ -65,4 +65,5 @@ private:
|
|||||||
int displayOffset_;
|
int displayOffset_;
|
||||||
bool scrollForward_;
|
bool scrollForward_;
|
||||||
bool needScrolling_;
|
bool needScrolling_;
|
||||||
|
bool needRender_;
|
||||||
};
|
};
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user