소스 검색

minor fixes

Nicolas Cannasse 8 년 전
부모
커밋
3c4f87b023
5개의 변경된 파일53개의 추가작업 그리고 4개의 파일을 삭제
  1. 8 0
      bin/style.css
  2. 10 0
      bin/style.less
  3. 11 0
      hide/comp/Scene.hx
  4. 19 1
      hide/comp/TextureSelect.hx
  5. 5 3
      hide/view/Particles2D.hx

+ 8 - 0
bin/style.css

@@ -308,6 +308,14 @@ input[type=checkbox]:checked:after {
 .hide-properties dd .range-group input[type=text]:active {
 .hide-properties dd .range-group input[type=text]:active {
   border-color: #444;
   border-color: #444;
 }
 }
+.hide-properties dd .texture-preview {
+  display: inline-block;
+  width: 15px;
+  height: 15px;
+  position: absolute;
+  margin-left: -17px;
+  margin-top: 2px;
+}
 .hide-properties .group {
 .hide-properties .group {
   margin-bottom: 5px;
   margin-bottom: 5px;
 }
 }

+ 10 - 0
bin/style.less

@@ -335,6 +335,16 @@ input[type=checkbox] {
 				border-color: #444;
 				border-color: #444;
 			}
 			}
 		}
 		}
+
+		.texture-preview {
+			display:inline-block;
+			width : 15px;
+			height: 15px;
+			position : absolute;
+			margin-left : -17px;
+			margin-top : 2px;
+		}
+
 	}
 	}
 
 
 	.group {
 	.group {

+ 11 - 0
hide/comp/Scene.hx

@@ -123,6 +123,8 @@ class Scene extends Component implements h3d.IDrawable {
 	var canvas : js.html.CanvasElement;
 	var canvas : js.html.CanvasElement;
 	var engine : h3d.Engine;
 	var engine : h3d.Engine;
 	var hmdCache = new Map<String, hxd.fmt.hmd.Library>();
 	var hmdCache = new Map<String, hxd.fmt.hmd.Library>();
+	public var width(get, never) : Int;
+	public var height(get, never) : Int;
 	public var s2d : h2d.Scene;
 	public var s2d : h2d.Scene;
 	public var s3d : h3d.scene.Scene;
 	public var s3d : h3d.scene.Scene;
 	public var sevents : hxd.SceneEvents;
 	public var sevents : hxd.SceneEvents;
@@ -162,6 +164,7 @@ class Scene extends Component implements h3d.IDrawable {
 			sevents.addScene(s2d);
 			sevents.addScene(s2d);
 			sevents.addScene(s3d);
 			sevents.addScene(s3d);
 			onReady();
 			onReady();
+			onResize();
 			sync();
 			sync();
 			ide.registerUpdate(sync);
 			ide.registerUpdate(sync);
 		};
 		};
@@ -171,6 +174,14 @@ class Scene extends Component implements h3d.IDrawable {
 		engine.init();
 		engine.init();
 	}
 	}
 
 
+	function get_width() {
+		return engine.width;
+	}
+
+	function get_height() {
+		return engine.height;
+	}
+
 	public function init( props : hide.ui.Props, ?root : h3d.scene.Object ) {
 	public function init( props : hide.ui.Props, ?root : h3d.scene.Object ) {
 		var autoHide : Array<String> = props.get("scene.autoHide");
 		var autoHide : Array<String> = props.get("scene.autoHide");
 		function initRec( obj : h3d.scene.Object ) {
 		function initRec( obj : h3d.scene.Object ) {

+ 19 - 1
hide/comp/TextureSelect.hx

@@ -3,9 +3,19 @@ package hide.comp;
 class TextureSelect extends FileSelect {
 class TextureSelect extends FileSelect {
 
 
 	public var value(default, set) : h3d.mat.Texture;
 	public var value(default, set) : h3d.mat.Texture;
+	public var area(default, set) : { x : Int, y : Int, width : Int, height : Int };
+	var preview : Element;
 
 
 	public function new(root) {
 	public function new(root) {
-		super(root,["jpg", "jpeg", "gif", "png"]);
+		preview = new Element("<div class='texture-preview'>");
+		preview.insertAfter(root);
+		super(root, ["jpg", "jpeg", "gif", "png"]);
+	}
+
+	function set_area(v) {
+		area = v;
+		this.path = path;
+		return v;
 	}
 	}
 
 
 	override function set_path(p:String) {
 	override function set_path(p:String) {
@@ -14,6 +24,14 @@ class TextureSelect extends FileSelect {
 			value = null;
 			value = null;
 		else if( value == null || value.name != p )
 		else if( value == null || value.name != p )
 			value = Scene.getNearest(root).loadTextureFile("", p);
 			value = Scene.getNearest(root).loadTextureFile("", p);
+		if( p == null )
+			preview.hide();
+		else {
+			preview.show();
+			preview.css("background-image", "url(file://" + ide.getPath(p) + ")");
+			preview.css("background-size", area == null ? "" : area.width + "px " + area.height + "px");
+			preview.css("background-position", area == null ? "" : area.x + "px " + area.y + "px");
+		}
 		return p;
 		return p;
 	}
 	}
 
 

+ 5 - 3
hide/view/Particles2D.hx

@@ -105,6 +105,7 @@ class Particles2D extends FileView {
 							<dt>Initial</dt><dd><input type="range" field="rotInit" min="0" max="1"/></dd>
 							<dt>Initial</dt><dd><input type="range" field="rotInit" min="0" max="1"/></dd>
 							<dt>Speed</dt><dd><input type="range" field="rotSpeed" min="0" max="5"/></dd>
 							<dt>Speed</dt><dd><input type="range" field="rotSpeed" min="0" max="5"/></dd>
 							<dt>Randomness</dt><dd><input type="range" field="rotSpeedRand" min="0" max="1"/></dd>
 							<dt>Randomness</dt><dd><input type="range" field="rotSpeedRand" min="0" max="1"/></dd>
+							<dt>Auto orient</dt><dd><input type="checkbox" field="rotAuto"/></dd>
 						</dl>
 						</dl>
 					</div>
 					</div>
 
 
@@ -145,7 +146,8 @@ class Particles2D extends FileView {
 	}
 	}
 
 
 	function init() {
 	function init() {
-		parts = new Particles(this,scene.s2d);
+		parts = new Particles(this, scene.s2d);
+		parts.smooth = true;
 		parts.load(haxe.Json.parse(sys.io.File.getContent(getPath())));
 		parts.load(haxe.Json.parse(sys.io.File.getContent(getPath())));
 		initProperties();
 		initProperties();
 		scene.init(props);
 		scene.init(props);
@@ -154,8 +156,8 @@ class Particles2D extends FileView {
 
 
 	override function onResize() {
 	override function onResize() {
 		if( parts == null ) return;
 		if( parts == null ) return;
-		parts.x = scene.s2d.width >> 1;
-		parts.y = scene.s2d.height >> 1;
+		parts.x = scene.width >> 1;
+		parts.y = scene.height >> 1;
 	}
 	}
 
 
 	function initProperties() {
 	function initProperties() {