diff --git a/mod.json b/mod.json index d01575f2..789c2e09 100644 --- a/mod.json +++ b/mod.json @@ -35,7 +35,7 @@ }, { "id": "hjfod.bettersave", - "version": "1.1.0", + "version": "1.1.1", "importance": "required" } ], @@ -47,6 +47,12 @@ } }, "settings": { + "auto-save": { + "type": "bool", + "default": true, + "name": "Auto-save", + "description": "Automatically saves the level every 5 minutes, as well as creates a backup. The backups created by autosave get automatically deleted after 3 new ones have been created to avoid using too much disk space" + }, "mouse-move-on-zoom": { "type": "bool", "default": true, @@ -126,12 +132,6 @@ "name": "Show Grid on Size Change", "description": "If the grid is currently hidden and you use the controls to change its size, its toggled on", "platforms": ["windows", "android64"] - }, - "auto-save": { - "type": "bool", - "default": true, - "name": "Auto-save", - "description": "Automatically saves the level every 5 minutes, as well as creates a backup. The backups created by autosave get automatically deleted after 3 new ones have been created to avoid using too much disk space" } }, "tags": ["editor", "enhancement", "utility", "customization"] diff --git a/resources/backups.png b/resources/backups.png new file mode 100644 index 00000000..01bab3c1 Binary files /dev/null and b/resources/backups.png differ diff --git a/src/features/backups/AutoSave.cpp b/src/features/backups/AutoSave.cpp index 8054a87b..fd4d7f03 100644 --- a/src/features/backups/AutoSave.cpp +++ b/src/features/backups/AutoSave.cpp @@ -21,7 +21,7 @@ class $modify(AutoSaveUI, EditorUI) { } void onAutoSaveTick(float) { constexpr size_t COUNTDOWN = 5; - constexpr size_t AUTO_SAVE_INTERVAL = 20; + constexpr size_t AUTO_SAVE_INTERVAL = 60 * 5; m_fields->secondsSinceLastAutoSave += 1; if (m_fields->secondsSinceLastAutoSave > AUTO_SAVE_INTERVAL - COUNTDOWN) { diff --git a/src/features/backups/Backup.cpp b/src/features/backups/Backup.cpp index 91bdee26..ce619edb 100644 --- a/src/features/backups/Backup.cpp +++ b/src/features/backups/Backup.cpp @@ -165,15 +165,17 @@ Result<> Backup::cleanAutomated(GJGameLevel* level) { constexpr size_t MAX_AUTOMATED_COUNT = 3; - // Do the cleanup - size_t ix = 0; - for (auto backup : automated) { - // Keep only the MAX_AUTOMATED_COUNT newest automated backups - if (++ix > MAX_AUTOMATED_COUNT) { - GEODE_UNWRAP(backup->deleteThis()); + // Do the cleanup if needed + if (automated.size() > MAX_AUTOMATED_COUNT) { + size_t ix = 0; + for (auto backup : automated) { + // Keep only the MAX_AUTOMATED_COUNT newest automated backups + if (++ix > MAX_AUTOMATED_COUNT) { + GEODE_UNWRAP(backup->deleteThis()); + } } + automated.erase(automated.begin() + MAX_AUTOMATED_COUNT, automated.end()); } - automated.erase(automated.begin() + MAX_AUTOMATED_COUNT, automated.end()); return Ok(); } diff --git a/src/features/backups/BackupsUI.cpp b/src/features/backups/BackupsUI.cpp index e63caa95..6f121891 100644 --- a/src/features/backups/BackupsUI.cpp +++ b/src/features/backups/BackupsUI.cpp @@ -9,8 +9,10 @@ class $modify(BackupLevelLayer, EditLevelLayer) { return false; if (auto menu = this->getChildByID("folder-menu")) { - auto backupsSpr = CCSprite::createWithSpriteFrameName("GJ_myServerBtn_001.png"); - backupsSpr->setScale(.65f); + auto backupsSpr = CircleButtonSprite::createWithSpriteFrameName( + "backups.png"_spr, 1.f, CircleBaseColor::Green + ); + backupsSpr->setScale(.8f); auto backupsBtn = CCMenuItemSpriteExtra::create( backupsSpr, this, menu_selector(BackupLevelLayer::onBackups) );