mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2025-04-10 19:15:13 +00:00
Fixed an issue where the battery text was not updated correctly when changing its menu option
This commit is contained in:
parent
819b79c8c1
commit
3d56fd68d1
|
|
@ -21,6 +21,8 @@ SystemStatusComponent::SystemStatusComponent()
|
||||||
, mHasCellular {false}
|
, mHasCellular {false}
|
||||||
, mHasBattery {false}
|
, mHasBattery {false}
|
||||||
, mBatteryCharging {false}
|
, mBatteryCharging {false}
|
||||||
|
, mBatteryText {Settings::getInstance()->getBool("SystemStatusBattery") &&
|
||||||
|
Settings::getInstance()->getBool("SystemStatusBatteryPercentage")}
|
||||||
, mBatteryCapacity {100}
|
, mBatteryCapacity {100}
|
||||||
, mEntries {sAllowedEntries}
|
, mEntries {sAllowedEntries}
|
||||||
, mColorShift {0xFFFFFFFF}
|
, mColorShift {0xFFFFFFFF}
|
||||||
|
|
@ -64,13 +66,13 @@ void SystemStatusComponent::updateGrid()
|
||||||
if (mDisplayEntries.empty())
|
if (mDisplayEntries.empty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const bool batteryText {Settings::getInstance()->getBool("SystemStatusBattery") &&
|
mBatteryText = Settings::getInstance()->getBool("SystemStatusBattery") &&
|
||||||
Settings::getInstance()->getBool("SystemStatusBatteryPercentage")};
|
Settings::getInstance()->getBool("SystemStatusBatteryPercentage");
|
||||||
|
|
||||||
int numEntries {static_cast<int>(mDisplayEntries.size())};
|
int numEntries {static_cast<int>(mDisplayEntries.size())};
|
||||||
if (mEntrySpacing != 0.0f)
|
if (mEntrySpacing != 0.0f)
|
||||||
numEntries += numEntries - 1;
|
numEntries += numEntries - 1;
|
||||||
if (mHasBattery && batteryText)
|
if (mHasBattery && mBatteryText)
|
||||||
++numEntries;
|
++numEntries;
|
||||||
|
|
||||||
mGrid = std::make_shared<ComponentGrid>(glm::ivec2 {numEntries, 1});
|
mGrid = std::make_shared<ComponentGrid>(glm::ivec2 {numEntries, 1});
|
||||||
|
|
@ -118,7 +120,7 @@ void SystemStatusComponent::updateGrid()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mHasBattery && batteryText) {
|
if (mHasBattery && mBatteryText) {
|
||||||
// We set the initial value to "100%" to calculate the cell size based on this, as this
|
// We set the initial value to "100%" to calculate the cell size based on this, as this
|
||||||
// will be the longest text that will ever be displayed for the battery capacity.
|
// will be the longest text that will ever be displayed for the battery capacity.
|
||||||
mBatteryPercentage = std::make_shared<TextComponent>(
|
mBatteryPercentage = std::make_shared<TextComponent>(
|
||||||
|
|
@ -134,7 +136,7 @@ void SystemStatusComponent::updateGrid()
|
||||||
|
|
||||||
for (int i {0}; i < static_cast<int>(mGrid->getChildCount()); ++i) {
|
for (int i {0}; i < static_cast<int>(mGrid->getChildCount()); ++i) {
|
||||||
mGrid->setColWidthPerc(i, mGrid->getChild(i)->getSize().x / width);
|
mGrid->setColWidthPerc(i, mGrid->getChild(i)->getSize().x / width);
|
||||||
if (mHasBattery && batteryText && i == static_cast<int>(mGrid->getChildCount()) - 2)
|
if (mHasBattery && mBatteryText && i == static_cast<int>(mGrid->getChildCount()) - 2)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (mEntrySpacing != 0.0f && i != static_cast<int>(mGrid->getChildCount()) - 1) {
|
if (mEntrySpacing != 0.0f && i != static_cast<int>(mGrid->getChildCount()) - 1) {
|
||||||
|
|
@ -335,14 +337,21 @@ void SystemStatusComponent::update(int deltaTime)
|
||||||
statusChanged = true;
|
statusChanged = true;
|
||||||
batteryStatusChanged = true;
|
batteryStatusChanged = true;
|
||||||
}
|
}
|
||||||
if (mHasBattery && mBatteryCharging != status.batteryCharging) {
|
if (mHasBattery) {
|
||||||
|
if (mBatteryCharging != status.batteryCharging) {
|
||||||
mBatteryCharging = status.batteryCharging;
|
mBatteryCharging = status.batteryCharging;
|
||||||
batteryStatusChanged = true;
|
batteryStatusChanged = true;
|
||||||
}
|
}
|
||||||
if (mHasBattery && mBatteryCapacity != status.batteryCapacity) {
|
if (mBatteryCapacity != status.batteryCapacity) {
|
||||||
mBatteryCapacity = status.batteryCapacity;
|
mBatteryCapacity = status.batteryCapacity;
|
||||||
batteryStatusChanged = true;
|
batteryStatusChanged = true;
|
||||||
}
|
}
|
||||||
|
if ((Settings::getInstance()->getBool("SystemStatusBattery") &&
|
||||||
|
Settings::getInstance()->getBool("SystemStatusBatteryPercentage")) !=
|
||||||
|
mBatteryText) {
|
||||||
|
statusChanged = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (statusChanged) {
|
if (statusChanged) {
|
||||||
updateGrid();
|
updateGrid();
|
||||||
|
|
|
||||||
|
|
@ -43,6 +43,7 @@ private:
|
||||||
bool mHasCellular;
|
bool mHasCellular;
|
||||||
bool mHasBattery;
|
bool mHasBattery;
|
||||||
bool mBatteryCharging;
|
bool mBatteryCharging;
|
||||||
|
bool mBatteryText;
|
||||||
int mBatteryCapacity;
|
int mBatteryCapacity;
|
||||||
|
|
||||||
std::vector<std::string> mEntries;
|
std::vector<std::string> mEntries;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue