From ac4617437a21023bcef169ab72cb6afe9ec78583 Mon Sep 17 00:00:00 2001 From: lunarcleint <88809950+lunarcleint@users.noreply.github.com> Date: Fri, 22 Mar 2024 04:30:09 -0700 Subject: [PATCH] autosaves :D --- assets/images/editors/autosave-icons.png | Bin 0 -> 321 bytes source/funkin/backend/chart/Chart.hx | 9 +- source/funkin/editors/DebugOptions.hx | 24 ++++- source/funkin/editors/charter/Charter.hx | 36 ++++++- .../editors/charter/CharterAutoSaveUI.hx | 94 ++++++++++++++++++ source/funkin/options/Options.hx | 4 + 6 files changed, 159 insertions(+), 8 deletions(-) create mode 100644 assets/images/editors/autosave-icons.png create mode 100644 source/funkin/editors/charter/CharterAutoSaveUI.hx diff --git a/assets/images/editors/autosave-icons.png b/assets/images/editors/autosave-icons.png new file mode 100644 index 0000000000000000000000000000000000000000..8c61f82e5112152d48282bfb343a5f03379af0de GIT binary patch literal 321 zcmV-H0lxl;P)Px#`$^l08cUK@f(Y5gToUT?BtXy5o%LVkz3B3RnpK#dKCSLRwq199T$5 z7ZLVQ5L1qY%(A)LfO)H(*_mhF{SY##ssgla3xM}tC}_ACYaYLxKc~91h%ssxP|6J# zV_ki$dPBZ$-UZ;moLOUxF-`a0OCIlnEk_L}PiG1ss;VNATy$g0U4%<^!JKo15V(E4 z|8w|XeO|9wj+!EDGM@r)*liM#o@-MGfx4~}G>3gx8;;uJvO^Ksx;xWkJ|%>JbFK$V zy-(); clipboard = []; playtestInfo = null; waveformHandler = new CharterWaveformHandler(); + autoSaveTimer = Options.charterAutoSaveTime; } @:noCompletion public function __clearStatics() { selection = null; undos = null; clipboard = null; playtestInfo = null; - waveformHandler.destroy(); Charter.waveformHandler = null; + waveformHandler.destroy(); Charter.waveformHandler = null; autoSaveTimer = 0; } @:noCompletion public function __updatePlaytestInfo() { diff --git a/source/funkin/editors/charter/CharterAutoSaveUI.hx b/source/funkin/editors/charter/CharterAutoSaveUI.hx new file mode 100644 index 00000000..12cbcf07 --- /dev/null +++ b/source/funkin/editors/charter/CharterAutoSaveUI.hx @@ -0,0 +1,94 @@ +package funkin.editors.charter; + +import flixel.util.FlxTimer; +import flixel.tweens.FlxTween; +import flixel.math.FlxRect; + +using flixel.util.FlxSpriteUtil; + +class CharterAutoSaveUI extends UISliceSprite { + public var icon:FlxSprite; + public var autosavingText:UIText; + public var progressBarBack:FlxSprite; + public var progressBar:FlxSprite; + + public var showedAnimation:Bool = false; + + public function new(x:Float, y:Float) { + super(x, y, 300, 46, "editors/ui/inputbox"); + + icon = new FlxSprite(x+12, y+10).loadGraphic(Paths.image("editors/autosave-icons"), true, 10, 10); + icon.animation.add("icon", [for(i in 0...2) i], 0, true); + icon.animation.play("icon"); icon.animation.curAnim.curFrame = 0; + members.push(icon); + + members.push(autosavingText = new UIText(x+12+10+4, y+8, 0, "Autosaving in 10 seconds...", 12)); + + progressBarBack = new FlxSprite(x + 10, y + bHeight - 20).makeGraphic(Std.int(bWidth-20), 10, 0x00000000, true); + progressBarBack.drawRoundRect(0, 0, progressBarBack.width, progressBarBack.height, 4, 6, 0xFF727272, null, {smoothing: false}); + progressBarBack.drawRoundRect(1, 1, progressBarBack.width-2, progressBarBack.height-2, 4, 6, 0xFF0D0D0D, null, {smoothing: false}); + members.push(progressBarBack); + + progressBar = new FlxSprite(x + 10, y + bHeight - 20).makeGraphic(Std.int(bWidth-20), 10, 0x00000000, true); + progressBar.drawRoundRect(0, 0, progressBar.width, progressBar.height, 4, 6, 0xFF727272, null, {smoothing: false}); + progressBar.drawRoundRect(1, 1, progressBar.width-2, progressBar.height-2, 4, 6, 0xFFFFFFFF, null, {smoothing: false}); + progressBar.antialiasing = false; progressBar.clipRect = new FlxRect(0, 0, progressBar.width, progressBar.height); + members.push(progressBar); + + alpha = 0; + } + + public function startAutoSave(time:Float, sucessText:String) { + appearAnimation(); + + FlxTween.num(0, 1, time, null, (v:Float) -> { + if ((progress = v) < .95) { + autosavingText.text = 'Autosaving in ${Math.min(Math.round(time), 1+Math.floor(Math.abs(time-(progress*time))))} seconds'; + autosavingText.text += [for (i in 0...(Math.floor((progress*time*3)%4))) "."].join(""); + } + }); + (new FlxTimer()).start(time, (_) -> { + autosavingText.text = sucessText; + + icon.animation.curAnim.curFrame = 1; + for (member in [this, progressBar, progressBarBack, autosavingText]) member.color = 0xFFA3EC95; + + (new FlxTimer()).start(1, (_) -> {disappearAnimation();}); + }); + } + + public var progress:Float = 0; + public override function update(elapsed:Float) { + super.update(elapsed); + + icon.follow(this, 12, 9); + icon.alpha = alpha; + + autosavingText.follow(this, 12+10+4, 8); + autosavingText.alpha = alpha; + + for (bar in [progressBar, progressBarBack]) { + bar.follow(this, 10, bHeight-20); + bar.alpha = alpha; + } + progressBar.clipRect = progressBar.clipRect.set(0, 0, progressBar.width*progress,progressBar.height); + } + + public function appearAnimation() { + autosavingText.text = "Autosaving in seconds..."; progress = 0; icon.animation.curAnim.curFrame = 0; + for (member in [this, autosavingText, progressBar, progressBarBack]) member.color = 0xFFFFFFFF; + + x = -(320); alpha=0; FlxTween.cancelTweensOf(this); + FlxTween.tween(this, {x: 20}, .4, {ease: FlxEase.circInOut}); + FlxTween.tween(this, {alpha: 1}, .3, {ease: FlxEase.sineOut, startDelay: .1}); + + showedAnimation = true; + } + + public function disappearAnimation() { + x = 20; alpha = 1; FlxTween.cancelTweensOf(this); + FlxTween.tween(this, {alpha: 0}, .4, {ease: FlxEase.sineOut}); + + showedAnimation = false; + } +} \ No newline at end of file diff --git a/source/funkin/options/Options.hx b/source/funkin/options/Options.hx index 5935e623..debe4a13 100644 --- a/source/funkin/options/Options.hx +++ b/source/funkin/options/Options.hx @@ -63,6 +63,10 @@ class Options public static var charterShowBeats:Bool = true; public static var charterEnablePlaytestScripts:Bool = true; public static var charterLowDetailWaveforms:Bool = false; + public static var charterAutoSaves:Bool = true; + public static var charterAutoSaveTime:Float = 60*5; + public static var charterAutoSaveWarningTime:Float = 5; + public static var charterAutoSavesSeperateFolder:Bool = false; /** * PLAYER 1 CONTROLS