diff --git a/buildnumber.txt b/buildnumber.txt index a907bf03..50b46273 100644 --- a/buildnumber.txt +++ b/buildnumber.txt @@ -1 +1 @@ -1571 \ No newline at end of file +1578 \ No newline at end of file diff --git a/source/funkin/options/Options.hx b/source/funkin/options/Options.hx index 34ebdbac..393197e6 100644 --- a/source/funkin/options/Options.hx +++ b/source/funkin/options/Options.hx @@ -22,6 +22,7 @@ class Options public static var autoPause:Bool = true; public static var antialiasing:Bool = true; public static var volume:Float = 1; + public static var betaUpdates:Bool = false; /** * PLAYER 1 CONTROLS diff --git a/source/funkin/options/OptionsMenu.hx b/source/funkin/options/OptionsMenu.hx index 4f38a9ce..8191e37c 100644 --- a/source/funkin/options/OptionsMenu.hx +++ b/source/funkin/options/OptionsMenu.hx @@ -37,9 +37,9 @@ class OptionsMenu extends MusicBeatState { state: BehaviourOptions }, { - name: 'Save Data', + name: 'Miscellaneous', desc: 'Use this menu to reset save data or engine settings.', - state: SaveDataOptions + state: MiscOptions }, { name: 'Debug Options', diff --git a/source/funkin/options/OptionsScreen.hx b/source/funkin/options/OptionsScreen.hx index bc326c83..0638a001 100644 --- a/source/funkin/options/OptionsScreen.hx +++ b/source/funkin/options/OptionsScreen.hx @@ -118,7 +118,11 @@ class OptionsScreen extends MusicBeatState { } public function updateDesc() { - descText.text = '/ ${options[curSelected].desc} /'; + updateDescText(options[curSelected].desc); + } + + public function updateDescText(text:String) { + descText.text = '/ ${text} /'; @:privateAccess descText.regenGraphic(); //updates the thing descDrop.loadFrame(descText.frame); diff --git a/source/funkin/options/categories/MiscOptions.hx b/source/funkin/options/categories/MiscOptions.hx new file mode 100644 index 00000000..3ac7318e --- /dev/null +++ b/source/funkin/options/categories/MiscOptions.hx @@ -0,0 +1,35 @@ +package funkin.options.categories; + +import flixel.FlxG; + +class MiscOptions extends OptionsScreen { + public override function create() { + options = [ + #if UPDATE_CHECKING + new Checkbox( + "Enable Beta Updates", + "If checked, will also include beta (prereleases) updates in the update checking.", + "betaUpdates"), + new TextOption( + "Check for Updates", + "Select this option to check for new engine updates.", + function() { + var report = funkin.updating.UpdateUtil.checkForUpdates(); + if (report.newUpdate) { + FlxG.switchState(new funkin.updating.UpdateAvailableScreen(report)); + } else { + CoolUtil.playMenuSFX(2); + updateDescText("No update found."); + } + }), + #end + new TextOption( + "Reset Save Data", + "Select this option to reset save data. This will remove all of your highscores", + function() { + // TODO!! + }) + ]; + super.create(); + } +} \ No newline at end of file diff --git a/source/funkin/options/categories/SaveDataOptions.hx b/source/funkin/options/categories/SaveDataOptions.hx deleted file mode 100644 index 9a9cb21b..00000000 --- a/source/funkin/options/categories/SaveDataOptions.hx +++ /dev/null @@ -1,15 +0,0 @@ -package funkin.options.categories; - -class SaveDataOptions extends OptionsScreen { - public override function create() { - options = [ - new TextOption( - "Reset Save Data", - "Select this option to reset save data. This will remove all of your highscores", - function() { - // TODO!! - }) - ]; - super.create(); - } -} \ No newline at end of file diff --git a/source/funkin/system/MusicBeatState.hx b/source/funkin/system/MusicBeatState.hx index aace2587..e0bc875e 100644 --- a/source/funkin/system/MusicBeatState.hx +++ b/source/funkin/system/MusicBeatState.hx @@ -188,7 +188,8 @@ class MusicBeatState extends FlxUIState implements IBeatReceiver public override function destroy() { super.destroy(); call("onDestroy"); - stateScript.destroy(); + if (stateScript != null) + stateScript.destroy(); } public override function switchTo(nextState:FlxState) { diff --git a/source/funkin/updating/AsyncUpdater.hx b/source/funkin/updating/AsyncUpdater.hx index a3110cd4..ba31e6c6 100644 --- a/source/funkin/updating/AsyncUpdater.hx +++ b/source/funkin/updating/AsyncUpdater.hx @@ -40,6 +40,7 @@ class AsyncUpdater { public var progress:UpdaterProgress = new UpdaterProgress(); public var path:String; public var downloadStream:URLLoader; + public var executableReplaced:Bool = false; public function installUpdates() { prepareInstallationEnvironment(); @@ -58,16 +59,14 @@ class AsyncUpdater { progress.curZipProgress = new ZipProgress(); ZipUtils.uncompressZip(reader, './', null, progress.curZipProgress); } - - var progPath = Sys.programPath(); - var bakFile = '${Path.withoutExtension(progPath)}.bak'; - if (FileSystem.exists(bakFile)) - FileSystem.deleteFile(bakFile); - FileSystem.rename(progPath, bakFile); - FileSystem.rename('$path$executableName', progPath); - - Sys.command('start /B $executableName'); - openfl.system.System.exit(0); + if (executableReplaced = FileSystem.exists('$path$executableName')) { + var progPath = Sys.programPath(); + var bakFile = '${Path.withoutExtension(progPath)}.bak'; + if (FileSystem.exists(bakFile)) + FileSystem.deleteFile(bakFile); + FileSystem.rename(progPath, bakFile); + FileSystem.rename('$path$executableName', progPath); + } } public function downloadFiles() { diff --git a/source/funkin/updating/UpdateScreen.hx b/source/funkin/updating/UpdateScreen.hx index 4ce7f624..913e82b0 100644 --- a/source/funkin/updating/UpdateScreen.hx +++ b/source/funkin/updating/UpdateScreen.hx @@ -1,5 +1,6 @@ package funkin.updating; +import funkin.menus.TitleState; import flixel.math.FlxRect; import flixel.system.FlxSound; import flixel.FlxSprite; @@ -71,7 +72,14 @@ class UpdateScreen extends MusicBeatState { bf.animation.play("loading-anim"); bf.alpha = 1; FlxG.camera.fade(0xFF000000, overSound.length / 1000, false, function() { - trace("crap"); + if (updater.executableReplaced) { + // the executable has been replaced, restart the game entirely + Sys.command('start /B ${updater.executableName}'); + openfl.system.System.exit(0); + } else { + // assets update, switch back to TitleState. + FlxG.switchState(new TitleState()); + } }); bf.clipRect = null; } diff --git a/source/funkin/updating/UpdateUtil.hx b/source/funkin/updating/UpdateUtil.hx index f29a2b05..307f2542 100644 --- a/source/funkin/updating/UpdateUtil.hx +++ b/source/funkin/updating/UpdateUtil.hx @@ -1,5 +1,6 @@ package funkin.updating; +import funkin.options.Options; import sys.FileSystem; import haxe.io.Path; import funkin.github.GitHubRelease; @@ -53,7 +54,7 @@ class UpdateUtil { static var __curVersionPos = 0; static function __doReleaseFiltering(releases:Array, currentVersionTag:String) { - releases = releases.filterReleases(false, false); + releases = releases.filterReleases(Options.betaUpdates, false); if (releases.length <= 0) return releases;