ncannasse 7 years ago
parent
commit
7d5217fde9
2 changed files with 8 additions and 6 deletions
  1. 4 1
      hide/comp/Scene.hx
  2. 4 5
      hide/view/Model.hx

+ 4 - 1
hide/comp/Scene.hx

@@ -234,7 +234,10 @@ class Scene extends Component implements h3d.IDrawable {
 		var name = path.split("/").pop();
 		var name = path.split("/").pop();
 		if( StringTools.startsWith(name, "Anim_") )
 		if( StringTools.startsWith(name, "Anim_") )
 			name = name.substr(5);
 			name = name.substr(5);
-		return name.substr(0, -4);
+		name = name.substr(0, -4);
+		if( StringTools.endsWith(name,"_loop") )
+			name = name.substr(0,-5);
+		return name;
 	}
 	}
 
 
 	function initMaterials( obj : h3d.scene.Object, path : String, reset = true ) {
 	function initMaterials( obj : h3d.scene.Object, path : String, reset = true ) {

+ 4 - 5
hide/view/Model.hx

@@ -17,7 +17,7 @@ class Model extends FileView {
 	var apause : { function toggle( v : Bool ) : Void; var element : Element; };
 	var apause : { function toggle( v : Bool ) : Void; var element : Element; };
 	var timeline : h2d.Graphics;
 	var timeline : h2d.Graphics;
 	var timecursor : h2d.Bitmap;
 	var timecursor : h2d.Bitmap;
-	var currentAnimation : String;
+	var currentAnimation : { file : String, name : String };
 
 
 	override function onDisplay() {
 	override function onDisplay() {
 		root.html('
 		root.html('
@@ -202,7 +202,6 @@ class Model extends FileView {
 			var sel = tools.addSelect("play-circle");
 			var sel = tools.addSelect("play-circle");
 			var content = [for( a in anims ) {
 			var content = [for( a in anims ) {
 				var label = scene.animationName(a);
 				var label = scene.animationName(a);
-				if( StringTools.endsWith(label,"_loop") ) label = label.substr(0,-5);
 				{ label : label, value : a }
 				{ label : label, value : a }
 			}];
 			}];
 			content.unshift({ label : "-- no anim --", value : null });
 			content.unshift({ label : "-- no anim --", value : null });
@@ -285,8 +284,8 @@ class Model extends FileView {
 				});
 				});
 			} },
 			} },
 			{ label : "Export Animation", enabled : this.extension != "hsd" && currentAnimation != null, click : function() {
 			{ label : "Export Animation", enabled : this.extension != "hsd" && currentAnimation != null, click : function() {
-				ide.chooseFileSave(this.getPath().substr(0,-4)+"_"+obj.currentAnimation.name+"_dump.txt", function(file) {
-					var lib = @:privateAccess scene.loadHMD(ide.getPath(currentAnimation),true);
+				ide.chooseFileSave(this.getPath().substr(0,-4)+"_"+currentAnimation.name+"_dump.txt", function(file) {
+					var lib = @:privateAccess scene.loadHMD(ide.getPath(currentAnimation.file),true);
 					var hmd = lib.header;
 					var hmd = lib.header;
 					hmd.data = lib.getData();
 					hmd.data = lib.getData();
 					sys.io.File.saveContent(ide.getPath(file), new hxd.fmt.hmd.Dump().dump(hmd));
 					sys.io.File.saveContent(ide.getPath(file), new hxd.fmt.hmd.Dump().dump(hmd));
@@ -313,7 +312,7 @@ class Model extends FileView {
 			return;
 			return;
 		}
 		}
 		var anim = scene.loadAnimation(file);
 		var anim = scene.loadAnimation(file);
-		currentAnimation = file;
+		currentAnimation = { file : file, name : scene.animationName(file) };
 		obj.playAnimation(anim);
 		obj.playAnimation(anim);
 		buildTimeline();
 		buildTimeline();
 	}
 	}