canceling autosaves
This commit is contained in:
Binary file not shown.
|
After Width: | Height: | Size: 174 B |
Binary file not shown.
|
Before Width: | Height: | Size: 321 B After Width: | Height: | Size: 519 B |
@@ -670,28 +670,31 @@ class Charter extends UIState {
|
||||
public static var autoSaveTimer:Float = 0;
|
||||
var __autoSaveLocation:String = null;
|
||||
public function updateAutoSaving(elapsed:Float) {
|
||||
if (Options.charterAutoSaves) {
|
||||
autoSaveTimer -= elapsed;
|
||||
if (autoSaveTimer < Options.charterAutoSaveWarningTime && !autoSaveNotif.showedAnimation) {
|
||||
if (Options.charterAutoSavesSeperateFolder)
|
||||
__autoSaveLocation = DateTools.format(Date.now(), "%Y-%m-%d_%H-%M");
|
||||
if (!Options.charterAutoSaves) return;
|
||||
autoSaveTimer -= elapsed;
|
||||
|
||||
autoSaveNotif.startAutoSave(autoSaveTimer,
|
||||
!Options.charterAutoSavesSeperateFolder ? 'Saved chart at ${__diff.toLowerCase()}.json!' :
|
||||
'Saved chart at $__autoSaveLocation.json!'
|
||||
);
|
||||
}
|
||||
if (autoSaveTimer < Options.charterAutoSaveWarningTime && !autoSaveNotif.cancelled && !autoSaveNotif.showedAnimation) {
|
||||
if (Options.charterAutoSavesSeperateFolder)
|
||||
__autoSaveLocation = DateTools.format(Date.now(), "%Y-%m-%d_%H-%M");
|
||||
autoSaveNotif.startAutoSave(autoSaveTimer,
|
||||
!Options.charterAutoSavesSeperateFolder ? 'Saved chart at ${__diff.toLowerCase()}.json!' :
|
||||
'Saved chart at $__autoSaveLocation.json!'
|
||||
);
|
||||
}
|
||||
|
||||
if (autoSaveTimer <= 0) {
|
||||
autoSaveTimer = Options.charterAutoSaveTime; buildChart();
|
||||
if (autoSaveTimer <= 0) {
|
||||
autoSaveTimer = Options.charterAutoSaveTime;
|
||||
if (!autoSaveNotif.cancelled) {
|
||||
buildChart();
|
||||
var songPath:String = '${Paths.getAssetsRoot()}/songs/${__song.toLowerCase()}';
|
||||
|
||||
|
||||
if (Options.charterAutoSavesSeperateFolder)
|
||||
Chart.save(songPath, PlayState.SONG, __autoSaveLocation, {saveMetaInChart: false, folder: "autosaves"});
|
||||
else
|
||||
Chart.save(songPath, PlayState.SONG, __diff.toLowerCase(), {saveMetaInChart: false});
|
||||
undos.save();
|
||||
}
|
||||
autoSaveNotif.cancelled = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -12,13 +12,17 @@ class CharterAutoSaveUI extends UISliceSprite {
|
||||
public var progressBarBack:FlxSprite;
|
||||
public var progressBar:FlxSprite;
|
||||
|
||||
public var cancelButton:UIButton;
|
||||
public var cancelIcon:FlxSprite;
|
||||
|
||||
public var showedAnimation:Bool = false;
|
||||
public var cancelled: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 = new FlxSprite(x+12, y+9).loadGraphic(Paths.image("editors/autosave-icons"), true, 10, 10);
|
||||
icon.animation.add("icon", [for(i in 0...3) i], 0, true);
|
||||
icon.animation.play("icon"); icon.animation.curAnim.curFrame = 0;
|
||||
members.push(icon);
|
||||
|
||||
@@ -27,7 +31,7 @@ class CharterAutoSaveUI extends UISliceSprite {
|
||||
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);
|
||||
members.push(progressBarBack); progressBarBack.antialiasing = false;
|
||||
|
||||
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});
|
||||
@@ -35,20 +39,40 @@ class CharterAutoSaveUI extends UISliceSprite {
|
||||
progressBar.antialiasing = false; progressBar.clipRect = new FlxRect(0, 0, progressBar.width, progressBar.height);
|
||||
members.push(progressBar);
|
||||
|
||||
cancelButton = new UIButton(x-(10+16), y+8, "", () -> {
|
||||
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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user