From eb1986b246402bdecb655b2bee70e19cd0504bd3 Mon Sep 17 00:00:00 2001 From: TechnikTil Date: Wed, 30 Apr 2025 19:50:33 -0600 Subject: [PATCH] move clear save data to the top, add clear ng save data --- source/funkin/api/newgrounds/NGSaveSlot.hx | 22 ++++++++ source/funkin/save/Save.hx | 1 + source/funkin/ui/options/SaveDataMenu.hx | 61 ++++++++++++---------- 3 files changed, 55 insertions(+), 29 deletions(-) diff --git a/source/funkin/api/newgrounds/NGSaveSlot.hx b/source/funkin/api/newgrounds/NGSaveSlot.hx index 8f39be482..4b941e0d6 100644 --- a/source/funkin/api/newgrounds/NGSaveSlot.hx +++ b/source/funkin/api/newgrounds/NGSaveSlot.hx @@ -122,6 +122,28 @@ class NGSaveSlot } } + public function clear():Void + { + try + { + ngSaveSlot?.clear(function(outcome:Outcome) { + switch (outcome) + { + case SUCCESS: + trace('[NEWGROUNDS] Successfully cleared save slot!'); + case FAIL(error): + trace('[NEWGROUNDS] Failed to clear save slot!'); + trace(error); + } + }); + } + catch (error:String) + { + trace('[NEWGROUNDS] Failed to clear save slot!'); + trace(error); + } + } + public function checkSlot():Void { trace('[NEWGROUNDS] Checking save slot with the ID of ${ngSaveSlot?.id}...'); diff --git a/source/funkin/save/Save.hx b/source/funkin/save/Save.hx index a04cac82c..5586fed08 100644 --- a/source/funkin/save/Save.hx +++ b/source/funkin/save/Save.hx @@ -1381,6 +1381,7 @@ class Save var gameSave = SaveDataMigrator.migrate(data); FlxG.save.mergeData(gameSave.data, true); + FlxG.save.flush(); }, function(error:io.newgrounds.Call.CallError) { var errorMsg:String = io.newgrounds.Call.CallErrorTools.toString(error); diff --git a/source/funkin/ui/options/SaveDataMenu.hx b/source/funkin/ui/options/SaveDataMenu.hx index 6575aa4a0..f81a59e74 100644 --- a/source/funkin/ui/options/SaveDataMenu.hx +++ b/source/funkin/ui/options/SaveDataMenu.hx @@ -5,9 +5,6 @@ import funkin.api.newgrounds.NewgroundsClient; #end import funkin.save.Save; -/** - * Our default Page when we enter the OptionsState, a bit of the root - */ class SaveDataMenu extends Page { var items:TextMenuList; @@ -18,32 +15,6 @@ class SaveDataMenu extends Page add(items = new TextMenuList()); - #if FEATURE_NEWGROUNDS - if (NewgroundsClient.instance.isLoggedIn()) - { - createItem("LOAD FROM NEWGROUNDS", function() { - openConfirmPrompt("This will overwrite - \nALL your save data. - \nAre you sure? - ", "Overwrite", function() { - Save.loadFromNewgrounds(); - - FlxG.switchState(() -> new funkin.InitState()); - }); - }); - - createItem("SAVE TO NEWGROUNDS", function() { - openConfirmPrompt("This will overwrite - \nALL save data saved - \non Newgrounds. - \nAre you sure? - ", "Overwrite", function() { - Save.saveToNewgrounds(); - }); - }); - } - #end - createItem("CLEAR SAVE DATA", function() { openConfirmPrompt("This will delete \nALL your save data. @@ -56,6 +27,38 @@ class SaveDataMenu extends Page }); }); + #if FEATURE_NEWGROUNDS + if (NewgroundsClient.instance.isLoggedIn()) + { + createItem("LOAD FROM NG", function() { + openConfirmPrompt("This will overwrite + \nALL your save data. + \nAre you sure? + ", "Overwrite", function() { + Save.loadFromNewgrounds(); + + FlxG.switchState(() -> new funkin.InitState()); + }); + }); + + createItem("SAVE TO NG", function() { + openConfirmPrompt("This will overwrite + \nALL save data saved + \non NG. Are you sure?", "Overwrite", function() { + Save.saveToNewgrounds(); + }); + }); + + createItem("CLEAR NG SAVE DATA", function() { + openConfirmPrompt("This will delete + \nALL save data saved + \non NG. Are you sure?", "Delete", function() { + funkin.api.newgrounds.NGSaveSlot.instance.clear(); + }); + }); + } + #end + createItem("EXIT", exit); }