From 64b7b6b2975056823d6dccc394ea8690c9af2a78 Mon Sep 17 00:00:00 2001 From: lunarcleint <88809950+lunarcleint@users.noreply.github.com> Date: Fri, 22 Mar 2024 16:52:25 -0700 Subject: [PATCH] canceling autosaves --- assets/images/editors/autosave-delete.png | Bin 0 -> 174 bytes assets/images/editors/autosave-icons.png | Bin 321 -> 519 bytes source/funkin/editors/charter/Charter.hx | 29 +++++----- .../editors/charter/CharterAutoSaveUI.hx | 51 ++++++++++++++---- 4 files changed, 58 insertions(+), 22 deletions(-) create mode 100644 assets/images/editors/autosave-delete.png diff --git a/assets/images/editors/autosave-delete.png b/assets/images/editors/autosave-delete.png new file mode 100644 index 0000000000000000000000000000000000000000..2de6cbad48c207f0dc9dea0fa330da6da3b67fa5 GIT binary patch literal 174 zcmeAS@N?(olHy`uVBq!ia0vp^0zk~g!3HGv?z=Y!NHG=%xjQkeJ16rJ$jR_@aSYLz zn4Hqkq~6&0U$TS6==F8uLpOR1&Z^7Vsf5`d-unByPx$!AV3xR5*>5lrd}DKorM+Ct~AvDb>-YgGX<|4bhUUrCB@#4}pGw(%E03{tTT< z$$3_ujpeq9hR!fIQCu z&{``Rv~#*I<#_S*Yoo6Sf{L$|B+lnPvMiH2sOfCybYIR_=NpjAgJs2c-0jN2YE|*P z1;#fw3c!QgPAwqIGFPS6T9xB}LCRgJhEY)f@X#1eIvw#gGTosc z&o4OJO*Wu$95a{=-T9H{@qT-oJkJ>wg@e9nwK(!_kz4iTN-0&Jf>j*H^!t4WFGGI@ zSKQ0*SNv(3lBQ{66OA1!r7Cx8HJA;F;~3xfH=t!j#_()D2Vfe8Ov4cPJ9>aE3#o5! zdD(3Dy-6U0*^rNXaD`atqg?atMWR~Z7HArVy!#{002ov JPDHLkV1oK%^!xw- 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- { + if (cancelled || !showedAnimation) return; + cancelled = true; __timer.cancel(); __tween.cancel(); + + icon.animation.curAnim.curFrame = 2; + (new FlxTimer()).start(1, (_) -> {disappearAnimation(true);}); + autosavingText.text += "(Canceled!)"; cancelButton.visible = false; + for (member in [this, progressBar, progressBarBack, autosavingText]) member.color = 0xFFB94848; + }, 24, 14); + cancelButton.frames = Paths.getFrames("editors/ui/grayscale-button"); + cancelButton.color = 0xFFAC3D3D; cancelButton.alpha = 0.2; + members.push(cancelButton); + + cancelIcon = new FlxSprite(x-(10+16), y+8).loadGraphic(Paths.image("editors/autosave-delete")); + members.push(cancelIcon); + alpha = 0; } + var __timer:FlxTimer; + var __tween:FlxTween; + public function startAutoSave(time:Float, sucessText:String) { appearAnimation(); - FlxTween.num(0, 1, time, null, (v:Float) -> { + __tween = 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; + __timer = new FlxTimer(); + __timer.start(time, (_) -> { + autosavingText.text = sucessText; cancelButton.visible = false; icon.animation.curAnim.curFrame = 1; for (member in [this, progressBar, progressBarBack, autosavingText]) member.color = 0xFFA3EC95; @@ -61,6 +85,14 @@ class CharterAutoSaveUI extends UISliceSprite { public override function update(elapsed:Float) { super.update(elapsed); + cancelButton.follow(this, bWidth-(10+24), 7); + cancelButton.alpha = alpha * .7; + + cancelIcon.follow(cancelButton, 3.5+1, 2); + cancelIcon.alpha = alpha; + + cancelIcon.visible = cancelButton.visible; + icon.follow(this, 12, 9); icon.alpha = alpha; @@ -78,16 +110,17 @@ class CharterAutoSaveUI extends UISliceSprite { 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); + x = -(320); alpha=0; FlxTween.cancelTweensOf(this); cancelled = false; cancelButton.visible = true; 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() { + public function disappearAnimation(?canned:Bool = false) { x = 20; alpha = 1; FlxTween.cancelTweensOf(this); - FlxTween.tween(this, {alpha: 0}, .4, {ease: FlxEase.sineOut}); + if (canned) FlxTween.tween(this, {x: -320}, .4, {ease: FlxEase.circInOut}); + FlxTween.tween(this, {alpha: 0}, .3, {ease: FlxEase.sineOut}); showedAnimation = false; }