Browse Source

small trails improvements in scene editor

ncannasse 8 years ago
parent
commit
deefa02e71
3 changed files with 45 additions and 17 deletions
  1. 13 7
      hide/comp/Range.hx
  2. 2 2
      hide/comp/Tabs.hx
  3. 30 8
      hide/view/SceneEditor.hx

+ 13 - 7
hide/comp/Range.hx

@@ -14,6 +14,7 @@ class Range extends Component {
 
 	var f : Element;
 	var inputView : Element;
+	var scale : Float;
 
 	public function new(f:Element) {
 		f.wrap('<div class="hide-range"/>');
@@ -23,6 +24,11 @@ class Range extends Component {
 		this.f = f;
 		if( f.attr("step") == null )
 			f.attr("step", "any");
+
+
+		scale = Std.parseFloat(f.attr("scale"));
+		if( Math.isNaN(scale) ) scale = 1.;
+
 		inputView = new Element('<input type="text">').appendTo(p);
 		originMin = Std.parseFloat(f.attr("min"));
 		originMax = Std.parseFloat(f.attr("max"));
@@ -43,18 +49,18 @@ class Range extends Component {
 		});
 
 		f.on("input", function(_) {
-			var v = Math.round(Std.parseFloat(f.val()) * 100) / 100;
+			var v = Math.round(Std.parseFloat(f.val()) * 100 * scale) / 100;
 			inputView.val(v);
-			current = v;
+			current = v * scale;
 			onChange(true);
 		});
 		inputView.keyup(function(e) {
 			if( e.keyCode == 13 || e.keyCode == 27 ) {
 				inputView.blur();
-				inputView.val(current);
+				inputView.val(current * scale);
 				return;
 			}
-			var v = Std.parseFloat(inputView.val());
+			var v = Std.parseFloat(inputView.val()) / scale;
 			if( Math.isNaN(v) ) return;
 			setInner(v);
 			f.val(v);
@@ -65,8 +71,8 @@ class Range extends Component {
 		inputView.val(current);
 
 		f.change(function(e) {
-			var v = Math.round(Std.parseFloat(f.val()) * 100) / 100;
-			setInner(v);
+			var v = Math.round(Std.parseFloat(f.val()) * 100 * scale) / 100;
+			setInner(v/scale);
 			inputView.val(v);
 			onChange(false);
 		});
@@ -76,7 +82,7 @@ class Range extends Component {
 		if( original == null ) original = v;
 		setInner(v);
 		current = v;
-		inputView.val(current);
+		inputView.val(current * scale);
 		f.val(current);
 		return v;
 	}

+ 2 - 2
hide/comp/Tabs.hx

@@ -29,9 +29,9 @@ class Tabs extends Component {
 		var index = 0;
 		for( t in getTabs().elements() ) {
 			var icon = t.attr("icon");
-			var title = t.attr("tabtitle");
+			var name = t.attr("name");
 			var index = index++;
-			var tab = new Element("<div>").html( (icon != null ? '<div class="fa fa-$icon"></div> ' : '') + (title != null ? title : '') );
+			var tab = new Element("<div>").html( (icon != null ? '<div class="fa fa-$icon"></div> ' : '') + (name != null ? name : '') );
 			t.attr("index", index);
 			tab.attr("index", index);
 			tab.appendTo(header);

+ 30 - 8
hide/view/SceneEditor.hx

@@ -32,7 +32,7 @@ class SceneEditor extends FileView {
 					<div class="scene">
 					</div>
 					<div class="tabs">
-						<div class="tab" tabtitle="Scene" icon="sitemap">
+						<div class="tab" name="Scene" icon="sitemap">
 							<div class="hide-block">
 								<div class="hide-list">
 									<div class="tree"></div>
@@ -40,7 +40,7 @@ class SceneEditor extends FileView {
 							</div>
 							<div class="props"></div>
 						</div>
-						<div class="tab" tabtitle="Properties" icon="gears">
+						<div class="tab" name="Properties" icon="gears">
 						</div>
 					</div>
 				</div>
@@ -76,16 +76,18 @@ class SceneEditor extends FileView {
 
 		if( obj != null )
 			properties.add(new Element('
+			<div class="group" name="Position">
 				<dl>
 					<dt>Name</dt><dd><input field="name"></dd>
-					<dt>X</dt><dd><input field="x"/></dd>
-					<dt>Y</dt><dd><input field="y"/></dd>
-					<dt>Z</dt><dd><input field="z"/></dd>
-					<dt>ScaleX</dt><dd><input field="scaleX"/></dd>
-					<dt>ScaleY</dt><dd><input field="scaleY"/></dd>
-					<dt>ScaleZ</dt><dd><input field="scaleZ"/></dd>
+					<dt>X</dt><dd><input type="range" min="-10" max="10" field="x"/></dd>
+					<dt>Y</dt><dd><input type="range" min="-10" max="10" field="y"/></dd>
+					<dt>Z</dt><dd><input type="range" min="-10" max="10" field="z"/></dd>
+					<dt>ScaleX</dt><dd><input type="range" min="0" max="5" field="scaleX"/></dd>
+					<dt>ScaleY</dt><dd><input type="range" min="0" max="5" field="scaleY"/></dd>
+					<dt>ScaleZ</dt><dd><input type="range" min="0" max="5" field="scaleZ"/></dd>
 					<dt>Visible</dt><dd><input type="checkbox" field="visible"/></dd>
 				</dl>
+			</div>
 			'),obj, function(name) {
 				elt.x = obj.x;
 				elt.y = obj.y;
@@ -162,6 +164,26 @@ class SceneEditor extends FileView {
 				select.val(Reflect.field(elt, select.attr("field")));
 			}
 
+		case Trail:
+
+			var elt : ExtraProperties = cast elt;
+			var obj : h3d.scene.Trail = cast obj;
+			var props = properties.add(new Element('
+			<div class="group" name="Trail Properties">
+				<dl>
+					<dt>Angle</dt><dd><input type="range" field="angle" scale="${180/Math.PI}" min="0" max="${Math.PI*2}"/></dd>
+					<dt>Duration</dt><dd><input type="range" field="duration" min="0" max="10"/></dd>
+					<dt>Size Start</dt><dd><input type="range" field="sizeStart" min="0" max="10"/></dd>
+					<dt>Size End</dt><dd><input type="range" field="sizeEnd" min="0" max="10"/></dd>
+					<dt>Movement Min.</dt><dd><input type="range" field="movementMin" min="0" max="1"/></dd>
+					<dt>Movement Max.</dt><dd><input type="range" field="movementMax" min="0" max="1"/></dd>
+					<dt>Texture</dt><dd><input type="texture" field="texture"/></dd>
+				</dl>
+			</div>
+			'),obj, function(_) {
+				elt.data = obj.save();
+			});
+
 		default:
 		}
 	}