|
@@ -49,7 +49,7 @@ class Editor extends h2d.Sprite {
|
|
var cedit : h2d.Interactive;
|
|
var cedit : h2d.Interactive;
|
|
var undo : Array<History>;
|
|
var undo : Array<History>;
|
|
var redo : Array<History>;
|
|
var redo : Array<History>;
|
|
- var currentFilePath : String;
|
|
|
|
|
|
+ public var currentFilePath : String;
|
|
public var autoLoop : Bool = true;
|
|
public var autoLoop : Bool = true;
|
|
|
|
|
|
static var CURVES : Array<{ name : String, f : Curve -> Data.Value }> = [
|
|
static var CURVES : Array<{ name : String, f : Curve -> Data.Value }> = [
|
|
@@ -92,13 +92,7 @@ class Editor extends h2d.Sprite {
|
|
public dynamic function onTextureSelect() {
|
|
public dynamic function onTextureSelect() {
|
|
hxd.File.browse(function(sel) {
|
|
hxd.File.browse(function(sel) {
|
|
sel.load(function(bytes) {
|
|
sel.load(function(bytes) {
|
|
- var bmp = hxd.res.Any.fromBytes(sel.fileName, bytes).toBitmap();
|
|
|
|
- var t = h2d.Tile.fromBitmap(bmp);
|
|
|
|
- bmp.dispose();
|
|
|
|
- state.textureName = sel.fileName;
|
|
|
|
- curState = null; // force reload (if texture was changed)
|
|
|
|
- setTexture(t);
|
|
|
|
- buildUI();
|
|
|
|
|
|
+ changeTexture(sel.fileName, hxd.res.Any.fromBytes(sel.fileName, bytes).toTile());
|
|
});
|
|
});
|
|
},{
|
|
},{
|
|
defaultPath : currentFilePath,
|
|
defaultPath : currentFilePath,
|
|
@@ -108,6 +102,13 @@ class Editor extends h2d.Sprite {
|
|
});
|
|
});
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ public function changeTexture( name : String, t : h2d.Tile ) {
|
|
|
|
+ state.textureName = name;
|
|
|
|
+ curState = null; // force reload (if texture was changed)
|
|
|
|
+ setTexture(t);
|
|
|
|
+ buildUI();
|
|
|
|
+ }
|
|
|
|
+
|
|
public dynamic function loadTexture( textureName : String ) : h2d.Tile {
|
|
public dynamic function loadTexture( textureName : String ) : h2d.Tile {
|
|
var bytes = null;
|
|
var bytes = null;
|
|
try {
|
|
try {
|
|
@@ -145,6 +146,12 @@ class Editor extends h2d.Sprite {
|
|
}
|
|
}
|
|
|
|
|
|
public dynamic function onSave( saveData ) {
|
|
public dynamic function onSave( saveData ) {
|
|
|
|
+ if( currentFilePath != null )
|
|
|
|
+ try {
|
|
|
|
+ hxd.File.saveBytes(currentFilePath, saveData);
|
|
|
|
+ return;
|
|
|
|
+ } catch( e : Dynamic ) {
|
|
|
|
+ }
|
|
if( currentFilePath == null ) currentFilePath = "default.p";
|
|
if( currentFilePath == null ) currentFilePath = "default.p";
|
|
hxd.File.saveAs(saveData, {
|
|
hxd.File.saveAs(saveData, {
|
|
defaultPath : currentFilePath,
|
|
defaultPath : currentFilePath,
|
|
@@ -429,6 +436,9 @@ class Editor extends h2d.Sprite {
|
|
<button class="ic" value="Angle" onclick="api.editCurve(\'angle\',true)"/>
|
|
<button class="ic" value="Angle" onclick="api.editCurve(\'angle\',true)"/>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
+ <div class="line">
|
|
|
|
+ <checkbox checked="${state.emitLocal}" onchange="api.s.emitLocal = this.checked"/> <span>Emit Local</span>
|
|
|
|
+ </div>
|
|
<div class="line">
|
|
<div class="line">
|
|
<checkbox checked="${state.emitFromShell}" onchange="api.s.emitFromShell = this.checked"/> <span>Emit from Shell</span>
|
|
<checkbox checked="${state.emitFromShell}" onchange="api.s.emitFromShell = this.checked"/> <span>Emit from Shell</span>
|
|
</div>
|
|
</div>
|
|
@@ -884,7 +894,7 @@ class Editor extends h2d.Sprite {
|
|
rebuildCurve();
|
|
rebuildCurve();
|
|
}
|
|
}
|
|
|
|
|
|
- public function setTexture( t : h2d.Tile ) {
|
|
|
|
|
|
+ function setTexture( t : h2d.Tile ) {
|
|
state.frames = [t];
|
|
state.frames = [t];
|
|
curTile = t;
|
|
curTile = t;
|
|
state.initFrames();
|
|
state.initFrames();
|