unsaved shit in the chart editor wip
This commit is contained in:
@@ -107,6 +107,7 @@ class Main extends Sprite
|
||||
}
|
||||
|
||||
public static function loadGameSettings() {
|
||||
WindowTitle.init();
|
||||
MemoryUtil.init();
|
||||
@:privateAccess
|
||||
FlxG.game.getTimer = getTimer;
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
package funkin.backend.utils;
|
||||
|
||||
import openfl.Lib;
|
||||
|
||||
class WindowTitle {
|
||||
public static var winTitle(default, set):String;
|
||||
public static function set_winTitle(newWinTitle:String):String {
|
||||
winTitle = newWinTitle;
|
||||
updateTitle();
|
||||
return newWinTitle;
|
||||
}
|
||||
public static var prefix(default, set):String = "";
|
||||
public static function set_prefix(newPrefix:String):String {
|
||||
prefix = newPrefix;
|
||||
updateTitle();
|
||||
return newPrefix;
|
||||
}
|
||||
public static var endfix(default, set):String = "";
|
||||
public static function set_endfix(endPrefix:String):String {
|
||||
endfix = endPrefix;
|
||||
updateTitle();
|
||||
return endPrefix;
|
||||
}
|
||||
|
||||
public static inline function init()
|
||||
reset();
|
||||
|
||||
public static inline function reset() {
|
||||
winTitle = Lib.application.meta["name"];
|
||||
prefix = endfix = "";
|
||||
updateTitle();
|
||||
}
|
||||
|
||||
public static inline function updateTitle()
|
||||
Lib.application.window.title = '$prefix$winTitle$endfix';
|
||||
}
|
||||
@@ -4,6 +4,12 @@ class UndoList<T> {
|
||||
public var undoList:Array<T> = [];
|
||||
public var redoList:Array<T> = [];
|
||||
|
||||
var savedLength:Int = 0;
|
||||
|
||||
public var unsaved(get, never):Bool;
|
||||
public inline function get_unsaved():Bool
|
||||
return undoList.length != savedLength;
|
||||
|
||||
public function new() {}
|
||||
|
||||
public inline function addToUndo(c:T) {
|
||||
@@ -26,4 +32,7 @@ class UndoList<T> {
|
||||
undoList.insert(0, redo);
|
||||
return redo;
|
||||
}
|
||||
|
||||
public inline function save()
|
||||
savedLength = undoList.length;
|
||||
}
|
||||
@@ -97,6 +97,7 @@ class Charter extends UIState {
|
||||
public override function create() {
|
||||
super.create();
|
||||
|
||||
WindowTitle.endfix = " (Chart Editor)";
|
||||
topMenu = [
|
||||
{
|
||||
label: "File",
|
||||
@@ -468,6 +469,7 @@ class Charter extends UIState {
|
||||
Framerate.memoryCounter.alpha = 1;
|
||||
Framerate.codenameBuildField.alpha = 1;
|
||||
}
|
||||
WindowTitle.reset();
|
||||
super.destroy();
|
||||
}
|
||||
|
||||
@@ -961,6 +963,8 @@ class Charter extends UIState {
|
||||
if (charterCamera.zoom != (charterCamera.zoom = lerp(charterCamera.zoom, __camZoom, 0.125))) {
|
||||
updateDisplaySprites();
|
||||
}
|
||||
|
||||
WindowTitle.prefix = undos.unsaved ? "UNSAVED | " : "";
|
||||
}
|
||||
|
||||
public static var startTime:Float = 0;
|
||||
@@ -1016,12 +1020,25 @@ class Charter extends UIState {
|
||||
// TOP MENU OPTIONS
|
||||
#if REGION
|
||||
function _file_exit(_) {
|
||||
FlxG.switchState(new CharterSelection());
|
||||
if (undos.unsaved) {
|
||||
FlxG.state.openSubState(new UIWarningSubstate("Unsaved Changes", "Your changes will be lost if you don't save them.", [
|
||||
{
|
||||
label: "Exit",
|
||||
onClick: function(_) FlxG.switchState(new CharterSelection())
|
||||
},
|
||||
{
|
||||
label: "Cancel",
|
||||
onClick: function (_) {}
|
||||
}
|
||||
]));
|
||||
} else
|
||||
FlxG.switchState(new CharterSelection());
|
||||
}
|
||||
|
||||
function _file_save(_) {
|
||||
#if sys
|
||||
saveTo('${Paths.getAssetsRoot()}/songs/${__song.toLowerCase().replace("-", " ")}');
|
||||
undos.save();
|
||||
return;
|
||||
#end
|
||||
_file_saveas(_);
|
||||
@@ -1031,6 +1048,7 @@ class Charter extends UIState {
|
||||
openSubState(new SaveSubstate(Json.stringify(Chart.filterChartForSaving(PlayState.SONG, false)), {
|
||||
defaultSaveFile: '${__diff.toLowerCase()}.json'
|
||||
}));
|
||||
undos.save();
|
||||
}
|
||||
|
||||
function _file_meta_save(_) {
|
||||
|
||||
Reference in New Issue
Block a user