mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2025-04-10 19:15:13 +00:00
Fixed some issues with the system status indicators
This commit is contained in:
parent
72c254bd0e
commit
819b79c8c1
|
@ -2109,7 +2109,7 @@ returnValue = Utils::Platform::launchGameUnix(command, startDirectory, runInBack
|
||||||
if (!runInBackground) {
|
if (!runInBackground) {
|
||||||
window->setAllowTextScrolling(true);
|
window->setAllowTextScrolling(true);
|
||||||
window->setAllowFileAnimation(true);
|
window->setAllowFileAnimation(true);
|
||||||
SystemStatus::getInstance().pollImmediately();
|
SystemStatus::getInstance().setPollImmediately(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update number of times the game has been launched.
|
// Update number of times the game has been launched.
|
||||||
|
|
|
@ -147,7 +147,7 @@ void GuiSettings::save()
|
||||||
|
|
||||||
if (mNeedsUpdateStatusComponents) {
|
if (mNeedsUpdateStatusComponents) {
|
||||||
SystemStatus::getInstance().setCheckFlags();
|
SystemStatus::getInstance().setCheckFlags();
|
||||||
SystemStatus::getInstance().pollImmediately();
|
SystemStatus::getInstance().setPollImmediately(true);
|
||||||
// If we're not done within this time window it's not the end of the world,
|
// If we're not done within this time window it's not the end of the world,
|
||||||
// the indicators will still get updated shortly.
|
// the indicators will still get updated shortly.
|
||||||
SDL_Delay(100);
|
SDL_Delay(100);
|
||||||
|
|
|
@ -22,7 +22,7 @@ public:
|
||||||
|
|
||||||
void setCheckFlags();
|
void setCheckFlags();
|
||||||
void setPolling(const bool state);
|
void setPolling(const bool state);
|
||||||
void pollImmediately() { mPollImmediately = true; }
|
void setPollImmediately(const bool state) { mPollImmediately = state; }
|
||||||
const bool getPollImmediately() { return mPollImmediately; }
|
const bool getPollImmediately() { return mPollImmediately; }
|
||||||
|
|
||||||
struct Status {
|
struct Status {
|
||||||
|
|
|
@ -82,7 +82,16 @@ void SystemStatusComponent::updateGrid()
|
||||||
for (auto it = mDisplayEntries.cbegin(); it != mDisplayEntries.cend(); ++it) {
|
for (auto it = mDisplayEntries.cbegin(); it != mDisplayEntries.cend(); ++it) {
|
||||||
if (*it == "battery") {
|
if (*it == "battery") {
|
||||||
mBattery = std::make_shared<ImageComponent>(false, true);
|
mBattery = std::make_shared<ImageComponent>(false, true);
|
||||||
mBattery->setImage(mIconPathMap["battery_full"]);
|
if (mBatteryCharging)
|
||||||
|
mBattery->setImage(mIconPathMap["battery_charging"]);
|
||||||
|
else if (mBatteryCapacity >= 0 && mBatteryCapacity <= 25)
|
||||||
|
mBattery->setImage(mIconPathMap["battery_low"]);
|
||||||
|
else if (mBatteryCapacity >= 26 && mBatteryCapacity <= 60)
|
||||||
|
mBattery->setImage(mIconPathMap["battery_medium"]);
|
||||||
|
else if (mBatteryCapacity >= 61 && mBatteryCapacity <= 90)
|
||||||
|
mBattery->setImage(mIconPathMap["battery_high"]);
|
||||||
|
else
|
||||||
|
mBattery->setImage(mIconPathMap["battery_full"]);
|
||||||
mBattery->setColorShift(mColorShift);
|
mBattery->setColorShift(mColorShift);
|
||||||
mBattery->setResize(0, mSize.y);
|
mBattery->setResize(0, mSize.y);
|
||||||
mBattery->setOpacity(mThemeOpacity);
|
mBattery->setOpacity(mThemeOpacity);
|
||||||
|
@ -120,6 +129,7 @@ void SystemStatusComponent::updateGrid()
|
||||||
width += mBatteryPercentage->getSize().x;
|
width += mBatteryPercentage->getSize().x;
|
||||||
mEntryMap["batteryText"] = i;
|
mEntryMap["batteryText"] = i;
|
||||||
mGrid->setEntry(mBatteryPercentage, glm::ivec2 {i, 0}, false, false);
|
mGrid->setEntry(mBatteryPercentage, glm::ivec2 {i, 0}, false, false);
|
||||||
|
mBatteryPercentage->setValue(std::to_string(mBatteryCapacity) + "%");
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i {0}; i < static_cast<int>(mGrid->getChildCount()); ++i) {
|
for (int i {0}; i < static_cast<int>(mGrid->getChildCount()); ++i) {
|
||||||
|
@ -290,10 +300,12 @@ void SystemStatusComponent::update(int deltaTime)
|
||||||
#if defined(__ANDROID__)
|
#if defined(__ANDROID__)
|
||||||
// For Android we poll on the main thread instead of in a separate thread.
|
// For Android we poll on the main thread instead of in a separate thread.
|
||||||
SystemStatus::Status status;
|
SystemStatus::Status status;
|
||||||
if (mAccumulatorAndroid >= SystemStatus::pollingTime ||
|
const bool pollImmediately {SystemStatus::getInstance().getPollImmediately()};
|
||||||
SystemStatus::getInstance().getPollImmediately()) {
|
if (mAccumulatorAndroid >= SystemStatus::pollingTime || pollImmediately) {
|
||||||
status = SystemStatus::getInstance().getStatus(true);
|
status = SystemStatus::getInstance().getStatus(true);
|
||||||
mAccumulatorAndroid = 0;
|
mAccumulatorAndroid = 0;
|
||||||
|
if (pollImmediately)
|
||||||
|
SystemStatus::getInstance().setPollImmediately(false);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
status = SystemStatus::getInstance().getStatus(false);
|
status = SystemStatus::getInstance().getStatus(false);
|
||||||
|
@ -332,10 +344,13 @@ void SystemStatusComponent::update(int deltaTime)
|
||||||
batteryStatusChanged = true;
|
batteryStatusChanged = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (statusChanged)
|
if (statusChanged) {
|
||||||
updateGrid();
|
updateGrid();
|
||||||
|
}
|
||||||
if (mHasBattery && batteryStatusChanged) {
|
else if (mHasBattery && batteryStatusChanged) {
|
||||||
|
// Slight optimization, just update the battery charge percentage and icon in
|
||||||
|
// case only the battery status has changed, instead of having to recreate the
|
||||||
|
// entire grid when this happens.
|
||||||
if (mBatteryPercentage != nullptr)
|
if (mBatteryPercentage != nullptr)
|
||||||
mBatteryPercentage->setValue(std::to_string(mBatteryCapacity) + "%");
|
mBatteryPercentage->setValue(std::to_string(mBatteryCapacity) + "%");
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue