only trigger confirmation popup if state changed

This commit is contained in:
Cvolton 2024-06-17 10:20:47 +02:00
parent aeaf7f7b88
commit 8f3f4d7a05
No known key found for this signature in database
2 changed files with 13 additions and 10 deletions

View file

@ -95,15 +95,6 @@ bool ModsStatusNode::init() {
}
void ModsStatusNode::updateState() {
enum class DownloadState {
None,
SomeCancelled,
AllDone,
SomeErrored,
SomeToBeConfirmed,
SomeFetching,
SomeDownloading,
};
DownloadState state = DownloadState::None;
auto upgradeState = [&](DownloadState into) {
if (static_cast<int>(state) < static_cast<int>(into)) {
@ -206,7 +197,7 @@ void ModsStatusNode::updateState() {
m_viewBtn->setVisible(true);
m_viewBtn->setTarget(this, menu_selector(ModsStatusNode::onConfirm));
askConfirmModInstalls();
if(m_lastState != state) askConfirmModInstalls();
} break;
case DownloadState::SomeFetching: {
@ -243,6 +234,7 @@ void ModsStatusNode::updateState() {
} break;
}
m_lastState = state;
m_btnMenu->updateLayout();
}

View file

@ -17,6 +17,16 @@ using namespace geode::prelude;
class ModsStatusNode : public CCNode {
protected:
enum class DownloadState {
None,
SomeCancelled,
AllDone,
SomeErrored,
SomeToBeConfirmed,
SomeFetching,
SomeDownloading,
};
CCScale9Sprite* m_statusBG;
CCLabelBMFont* m_status;
CCLabelBMFont* m_statusPercentage;
@ -28,6 +38,7 @@ protected:
CCMenuItemSpriteExtra* m_restartBtn;
EventListener<UpdateModListStateFilter> m_updateStateListener;
EventListener<server::ModDownloadFilter> m_downloadListener;
DownloadState m_lastState = DownloadState::None;
bool init();
void updateState();