bleh >:P
This commit is contained in:
@@ -143,7 +143,7 @@ class CharacterPropertiesWindow extends UISliceSprite {
|
||||
}
|
||||
|
||||
public function editCharacterSpriteUI() {
|
||||
CharacterEditor.instance.openSubState(new CharacterSpriteScreen(character.sprite, (sprite:String) -> {
|
||||
CharacterEditor.instance.openSubState(new CharacterSpriteScreen('characters/${character.sprite}', (sprite:String) -> {
|
||||
trace(sprite);
|
||||
}));
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ class CharacterSpriteScreen extends UISubstateWindow {
|
||||
|
||||
super.create();
|
||||
|
||||
imageExplorer = new UIImageExplorer(20, windowSpr.y + 30 + 16 + 20, 320, 58, (_, _) -> {refreshWindowSize();});
|
||||
imageExplorer = new UIImageExplorer(20, windowSpr.y + 30 + 16 + 20, imagePath, 320, 58, (_, _) -> {refreshWindowSize();});
|
||||
add(imageExplorer);
|
||||
addLabelOn(imageExplorer, "Character Image File").applyMarkup(
|
||||
"Character Image File $* Required$",
|
||||
@@ -55,6 +55,7 @@ class CharacterSpriteScreen extends UISubstateWindow {
|
||||
}
|
||||
|
||||
public function refreshWindowSize() {
|
||||
if (imageExplorer == null) return;
|
||||
windowSpr.bWidth = 20 + imageExplorer.bWidth + 20;
|
||||
windowSpr.bHeight = 30 + 16 + 20 + imageExplorer.bHeight + 14 + saveButton.bHeight + 14;
|
||||
|
||||
|
||||
@@ -23,13 +23,7 @@ class UIFileExplorer extends UISliceSprite {
|
||||
|
||||
uploadButton = new UIButton(x + 8, y+ 8, null, function () {
|
||||
var fileDialog = new FileDialog();
|
||||
fileDialog.onSelect.add(function(path) {
|
||||
filePath = path;
|
||||
file = cast sys.io.File.getBytes(path);
|
||||
deleteButton.visible = deleteButton.selectable = deleteIcon.visible = !(uploadButton.visible = uploadButton.selectable = false);
|
||||
|
||||
if (this.onFile != null) this.onFile(filePath, file);
|
||||
});
|
||||
fileDialog.onSelect.add(loadFile);
|
||||
fileDialog.browse(OPEN, fileType);
|
||||
}, bWidth - 16, bHeight - 16);
|
||||
members.push(uploadButton);
|
||||
@@ -64,6 +58,13 @@ class UIFileExplorer extends UISliceSprite {
|
||||
}
|
||||
}
|
||||
|
||||
public function loadFile(path:String) {
|
||||
file = cast sys.io.File.getBytes(filePath = path);
|
||||
deleteButton.visible = deleteButton.selectable = deleteIcon.visible = !(uploadButton.visible = uploadButton.selectable = false);
|
||||
|
||||
if (this.onFile != null) this.onFile(filePath, file);
|
||||
}
|
||||
|
||||
public function removeFile() {
|
||||
if (uiElement != null) {
|
||||
members.remove(uiElement);
|
||||
|
||||
@@ -15,7 +15,7 @@ using funkin.backend.utils.BitmapUtil;
|
||||
|
||||
// TODO: make this limited if on web
|
||||
class UIImageExplorer extends UIFileExplorer {
|
||||
public function new(x:Float, y:Float, ?w:Int, ?h:Int, ?onFile:(String, Bytes)->Void) {
|
||||
public function new(x:Float, y:Float, image:String, ?w:Int, ?h:Int, ?onFile:(String, Bytes)->Void) {
|
||||
super(x, y, w, h, "png, jpg", function (filePath, file) {
|
||||
if (filePath != null && file != null) uploadImage(filePath, file);
|
||||
if (onFile != null) onFile(filePath, file);
|
||||
@@ -24,10 +24,16 @@ class UIImageExplorer extends UIFileExplorer {
|
||||
deleteButton.bWidth = 26;
|
||||
deleteButton.bHeight = 26;
|
||||
|
||||
this.allowAtlases = true; //allowAtlases;
|
||||
var fullImagePath:String = '${Path.normalize(Sys.getCwd())}/${Paths.image(image)}'.replace('/', '\\');
|
||||
var noExt = Path.withoutExtension(fullImagePath);
|
||||
if (FileSystem.exists('$noExt\\spritemap1.png'))
|
||||
fullImagePath = '$noExt\\spritemap1.png';
|
||||
|
||||
if (FileSystem.exists(fullImagePath))
|
||||
loadFile(fullImagePath);
|
||||
}
|
||||
|
||||
private var allowAtlases:Bool;
|
||||
private var allowAtlases:Bool = true;
|
||||
|
||||
public var fileText:UIText;
|
||||
|
||||
@@ -119,7 +125,8 @@ class UIImageExplorer extends UIFileExplorer {
|
||||
var image = null;
|
||||
if (isAtlas && spritemapImages.length > 0) {
|
||||
var spritemapPath:String = Path.join([directoryPath, spritemapImages[0]]);
|
||||
trace("Loading spritemap: " + spritemapImages[0]);
|
||||
trace("Loading spritemap: " + spritemapImages, spritemaps);
|
||||
trace(directoryPath);
|
||||
|
||||
imagePath = Path.normalize(spritemapPath);
|
||||
directoryPath = Path.directory(imagePath);
|
||||
|
||||
Reference in New Issue
Block a user