Browse Source

call super.save()

ncannasse 6 years ago
parent
commit
271ba8f59c

+ 9 - 9
hide/view/FileView.hx

@@ -5,6 +5,7 @@ class FileView extends hide.ui.View<{ path : String }> {
 	public var extension(get,never) : String;
 	public var modified(default, set) : Bool;
 	var skipNextChange : Bool;
+	var lastSaveTag : Int;
 
 	public function new(state) {
 		super(state);
@@ -38,26 +39,25 @@ class FileView extends hide.ui.View<{ path : String }> {
 	}
 
 	public function getDefaultContent() : haxe.io.Bytes {
+		throw "Not implemented";
 		return null;
 	}
 
 	override function setContainer(cont) {
 		super.setContainer(cont);
-		var lastSave = undo.currentID;
+		lastSaveTag = undo.currentID;
 		undo.onChange = function() {
-			modified = (undo.currentID != lastSave);
+			modified = (undo.currentID != lastSaveTag);
 		};
 		keys.register("undo", function() undo.undo());
 		keys.register("redo", function() undo.redo());
-		keys.register("save", function() {
-			save();
-			skipNextChange = true;
-			modified = false;
-			lastSave = undo.currentID;
-		});
+		keys.register("save", function() save());
 	}
 
 	public function save() {
+		skipNextChange = true;
+		modified = false;
+		lastSaveTag = undo.currentID;
 	}
 
 	public function saveAs() {
@@ -65,7 +65,7 @@ class FileView extends hide.ui.View<{ path : String }> {
 			if( target == null ) return;
 			state.path = target;
 			save();
-			modified = false;
+			skipNextChange = false;
 			syncTitle();
 		});
 	}

+ 1 - 0
hide/view/Model.hx

@@ -55,6 +55,7 @@ class Model extends FileView {
 			bytes.writeString(haxe.Json.stringify(hideData, "\t"));
 			hxd.File.saveBytes(ide.getPath(propsPath), bytes.getBytes());
 		}
+		super.save();
 	}
 
 	override function onDisplay() {

+ 1 - 0
hide/view/Particles2D.hx

@@ -34,6 +34,7 @@ class Particles2D extends FileView {
 
 	override function save() {
 		sys.io.File.saveContent(getPath(), ide.toJSON(parts.save()));
+		super.save();
 	}
 
 	function init() {

+ 1 - 0
hide/view/Particles3D.hx

@@ -31,6 +31,7 @@ class Particles3D extends FileView {
 
 	override function save() {
 		sys.io.File.saveContent(getPath(), ide.toJSON(parts.save()));
+		super.save();
 	}
 
 	function addGroup( g : h3d.parts.GpuParticles.GpuPartGroup ) {

+ 1 - 0
hide/view/Prefab.hx

@@ -64,6 +64,7 @@ class Prefab extends FileView {
 		var content = ide.toJSON(data.save());
 		currentSign = haxe.crypto.Md5.encode(content);
 		sys.io.File.saveContent(getPath(), content);
+		super.save();
 	}
 
 	override function onDisplay() {

+ 1 - 0
hide/view/l3d/Level3D.hx

@@ -474,6 +474,7 @@ class Level3D extends FileView {
 		var content = ide.toJSON(data.save());
 		currentSign = haxe.crypto.Md5.encode(content);
 		sys.io.File.saveContent(getPath(), content);
+		super.save();
 	}
 
 	function updateGrid() {