mirror of
https://github.com/FunKey-Project/RetroFE.git
synced 2025-12-12 17:58:53 +01:00
BUG correction: battery charge is not displayed after exiting game
Signed-off-by: Vincent-FK <vincent.buso@funkey-project.com>
This commit is contained in:
parent
5b51c7de41
commit
290d160677
@ -97,6 +97,7 @@ Battery::Battery(Page &p, Configuration &config, float reloadPeriod, SDL_Color f
|
|||||||
, config_(config)
|
, config_(config)
|
||||||
, texture_(NULL)
|
, texture_(NULL)
|
||||||
, texture_prescaled_(NULL)
|
, texture_prescaled_(NULL)
|
||||||
|
, mustUpdate_(false)
|
||||||
, reloadPeriod_(reloadPeriod)
|
, reloadPeriod_(reloadPeriod)
|
||||||
, scaleX_(scaleX)
|
, scaleX_(scaleX)
|
||||||
, scaleY_(scaleY)
|
, scaleY_(scaleY)
|
||||||
@ -184,6 +185,7 @@ void Battery::allocateGraphicsMemory()
|
|||||||
|
|
||||||
Component::allocateGraphicsMemory();
|
Component::allocateGraphicsMemory();
|
||||||
|
|
||||||
|
mustUpdate_ = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Battery::drawBatteryPercent()
|
void Battery::drawBatteryPercent()
|
||||||
@ -333,7 +335,7 @@ void Battery::update(float dt)
|
|||||||
{
|
{
|
||||||
currentWaitTime_ += dt;
|
currentWaitTime_ += dt;
|
||||||
}
|
}
|
||||||
else if(baseViewInfo.Alpha > 0.0f)
|
else
|
||||||
{
|
{
|
||||||
prevPercentage_ = percentage_;
|
prevPercentage_ = percentage_;
|
||||||
prevNoBat_ = noBat_;
|
prevNoBat_ = noBat_;
|
||||||
@ -351,17 +353,14 @@ void Battery::update(float dt)
|
|||||||
/* Redraw icon if necessary */
|
/* Redraw icon if necessary */
|
||||||
bool stateChange = ((prevNoBat_ != noBat_) || (prevCharging_ != charging_));
|
bool stateChange = ((prevNoBat_ != noBat_) || (prevCharging_ != charging_));
|
||||||
|
|
||||||
|
if(stateChange || mustUpdate_){
|
||||||
if(noBat_){
|
if(noBat_){
|
||||||
if(prevNoBat_ != noBat_ || stateChange){
|
|
||||||
drawNoBattery();
|
drawNoBattery();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else if(charging_){
|
else if(charging_){
|
||||||
if(prevCharging_ != charging_ || stateChange){
|
|
||||||
drawBatteryCharging();
|
drawBatteryCharging();
|
||||||
}
|
}
|
||||||
}
|
else if(prevPercentage_ != percentage_){
|
||||||
else if(prevPercentage_ != percentage_ || stateChange){
|
|
||||||
float percentagePixelWidth = percentage_ * BATTERY_FILL_REGION_OFFSET_WIDTH / 100;
|
float percentagePixelWidth = percentage_ * BATTERY_FILL_REGION_OFFSET_WIDTH / 100;
|
||||||
float prevPercentagePixelWidth = prevPercentage_ * BATTERY_FILL_REGION_OFFSET_WIDTH / 100;
|
float prevPercentagePixelWidth = prevPercentage_ * BATTERY_FILL_REGION_OFFSET_WIDTH / 100;
|
||||||
if (prevPercentagePixelWidth != percentagePixelWidth || stateChange)
|
if (prevPercentagePixelWidth != percentagePixelWidth || stateChange)
|
||||||
@ -369,6 +368,9 @@ void Battery::update(float dt)
|
|||||||
drawBatteryPercent();
|
drawBatteryPercent();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
mustUpdate_ = false;
|
||||||
|
|
||||||
Component::update(dt);
|
Component::update(dt);
|
||||||
}
|
}
|
||||||
@ -382,7 +384,7 @@ void Battery::draw()
|
|||||||
|
|
||||||
Component::draw();
|
Component::draw();
|
||||||
|
|
||||||
if(texture_ && valuesReady_)
|
if(texture_ && valuesReady_ && baseViewInfo.Alpha > 0.0f )
|
||||||
{
|
{
|
||||||
SDL_Rect rect;
|
SDL_Rect rect;
|
||||||
rect.x = static_cast<int>(baseViewInfo.XRelativeToOrigin());
|
rect.x = static_cast<int>(baseViewInfo.XRelativeToOrigin());
|
||||||
|
|||||||
@ -31,6 +31,7 @@ protected:
|
|||||||
float scaleX_;
|
float scaleX_;
|
||||||
float scaleY_;
|
float scaleY_;
|
||||||
float reloadPeriod_;
|
float reloadPeriod_;
|
||||||
|
bool mustUpdate_;
|
||||||
|
|
||||||
static std::string fileUsbConnected_;
|
static std::string fileUsbConnected_;
|
||||||
static std::string fileBatConnected_;
|
static std::string fileBatConnected_;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user