From e7e4be0d114226c14b9ead7791a52c95c63066e8 Mon Sep 17 00:00:00 2001 From: Vincent-FK Date: Thu, 12 Mar 2020 23:22:37 +0100 Subject: [PATCH] do not display battery untils values are ready Signed-off-by: Vincent-FK --- RetroFE/Source/Graphics/Component/Battery.cpp | 7 +++++-- RetroFE/Source/Graphics/Component/Battery.h | 1 + 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/RetroFE/Source/Graphics/Component/Battery.cpp b/RetroFE/Source/Graphics/Component/Battery.cpp index e053112..68cb039 100644 --- a/RetroFE/Source/Graphics/Component/Battery.cpp +++ b/RetroFE/Source/Graphics/Component/Battery.cpp @@ -89,6 +89,7 @@ bool Battery::noBat_ = false; bool Battery::prevNoBat_ = false; float Battery::currentWaitTime_ = 0.0f; bool Battery::mustRender_ = false; +bool Battery::valuesReady_ = false; Battery::Battery(Page &p, Configuration &config, float reloadPeriod, SDL_Color fontColor, float scaleX, float scaleY) @@ -342,6 +343,8 @@ void Battery::update(float dt) noBat_ = !isBatConnected(); charging_ = isUsbConnected(); + valuesReady_ = true; + currentWaitTime_ = 0.0f; } @@ -379,7 +382,7 @@ void Battery::draw() Component::draw(); - if(texture_) + if(texture_ && valuesReady_) { SDL_Rect rect; rect.x = static_cast(baseViewInfo.XRelativeToOrigin()); @@ -418,7 +421,7 @@ bool Battery::mustRender( ) { if ( Component::mustRender( ) ) return true; - if ( mustRender_ && baseViewInfo.Alpha > 0.0f ) + if ( mustRender_ && baseViewInfo.Alpha > 0.0f && valuesReady_ ) { mustRender_ = false; return true; diff --git a/RetroFE/Source/Graphics/Component/Battery.h b/RetroFE/Source/Graphics/Component/Battery.h index 729ab8e..770a0fd 100644 --- a/RetroFE/Source/Graphics/Component/Battery.h +++ b/RetroFE/Source/Graphics/Component/Battery.h @@ -44,4 +44,5 @@ protected: static bool prevCharging_; static bool noBat_; static bool prevNoBat_; + static bool valuesReady_; };