From e8186f55681a3e7f1d23d77dc17f531b725512ea Mon Sep 17 00:00:00 2001 From: luboslenco Date: Wed, 20 Nov 2019 22:43:17 +0100 Subject: [PATCH] Export cleanup --- Sources/arm/App.hx | 6 +----- Sources/arm/Project.hx | 12 ++++++++++-- Sources/arm/ui/BoxExport.hx | 6 +++++- Sources/arm/ui/UITrait.hx | 30 ++++++++++-------------------- 4 files changed, 26 insertions(+), 28 deletions(-) diff --git a/Sources/arm/App.hx b/Sources/arm/App.hx index a3708637..4f0b5a73 100644 --- a/Sources/arm/App.hx +++ b/Sources/arm/App.hx @@ -52,7 +52,6 @@ class App { public static var uibox:Zui; public static var uimenu:Zui; public static var fileArg = ""; - public static var saveAndQuit = false; public static var ELEMENT_H = 28; public function new() { @@ -181,10 +180,7 @@ class App { static function saveAndQuitCallback(save:Bool) { saveWindowRect(); - if (save) { - saveAndQuit = true; - Project.projectSave(); - } + if (save) Project.projectSave(true); else System.stop(); } diff --git a/Sources/arm/Project.hx b/Sources/arm/Project.hx index 1fb19130..baa25841 100644 --- a/Sources/arm/Project.hx +++ b/Sources/arm/Project.hx @@ -1,5 +1,6 @@ package arm; +import kha.System; import kha.Window; import zui.Zui; import zui.Id; @@ -24,6 +25,7 @@ import arm.io.ImportAsset; import arm.io.ImportArm; import arm.io.ImportBlend; import arm.io.ImportMesh; +import arm.io.ExportArm; using StringTools; class Project { @@ -60,13 +62,19 @@ class Project { }); } - public static function projectSave() { + public static function projectSave(saveAndQuit = false) { if (filepath == "") { projectSaveAs(); return; } Window.get(0).title = UIFiles.filename + " - ArmorPaint"; - UITrait.inst.projectExport = true; + + function export(_) { + ExportArm.runProject(); + iron.App.removeRender(export); + if (saveAndQuit) System.stop(); + } + iron.App.notifyOnRender(export); } public static function projectSaveAs() { diff --git a/Sources/arm/ui/BoxExport.hx b/Sources/arm/ui/BoxExport.hx index 13872f37..dd5d328f 100644 --- a/Sources/arm/ui/BoxExport.hx +++ b/Sources/arm/ui/BoxExport.hx @@ -69,8 +69,12 @@ class BoxExport { UIBox.show = false; var filters = UITrait.inst.bitsHandle.position > 0 ? "exr" : UITrait.inst.formatType == 0 ? "png" : "jpg"; UIFiles.show(filters, true, function(path:String) { - UITrait.inst.textureExport = true; UITrait.inst.textureExportPath = path; + function export(_) { + ExportTexture.run(path); + iron.App.removeRender(export); + } + iron.App.notifyOnRender(export); }); } if (ui.isHovered) ui.tooltip("Export texture files (" + Config.keymap.file_export_textures + ")"); diff --git a/Sources/arm/ui/UITrait.hx b/Sources/arm/ui/UITrait.hx index 3a051c6f..7e78842c 100644 --- a/Sources/arm/ui/UITrait.hx +++ b/Sources/arm/ui/UITrait.hx @@ -245,9 +245,7 @@ class UITrait { public var vxaoOffset = 1.5; public var vxaoAperture = 1.2; public var vignetteStrength = 0.4; - public var textureExport = false; public var textureExportPath = ""; - public var projectExport = false; public var headerHandle = new Handle({layout:Horizontal}); public var toolbarHandle = new Handle(); public var statusHandle = new Handle({layout:Horizontal}); @@ -406,16 +404,6 @@ class UITrait { } public function update() { - if (textureExport) { - textureExport = false; - ExportTexture.run(textureExportPath); - } - if (projectExport) { - projectExport = false; - ExportArm.runProject(); - if (App.saveAndQuit) System.stop(); - } - isScrolling = ui.isScrolling; updateUI(); @@ -443,13 +431,15 @@ class UITrait { else if (Operator.shortcut(Config.keymap.file_new)) Project.projectNewBox(); else if (Operator.shortcut(Config.keymap.file_export_textures)) { if (textureExportPath == "") { // First export, ask for path - var filters = bitsHandle.position > 0 ? "exr" : formatType == 0 ? "png" : "jpg"; - UIFiles.show(filters, true, function(path:String) { - textureExport = true; - textureExportPath = path; - }); + BoxExport.showTextures(); + } + else { + function export(_) { + ExportTexture.run(textureExportPath); + iron.App.removeRender(export); + } + iron.App.notifyOnRender(export); } - else textureExport = true; } else if (Operator.shortcut(Config.keymap.file_export_textures_as)) BoxExport.showTextures(); else if (Operator.shortcut(Config.keymap.file_import_assets)) Project.importAsset(); @@ -579,7 +569,7 @@ class UITrait { if (borderStarted == 0) { UINodes.inst.defaultWindowW -= Std.int(mouse.movementX); if (UINodes.inst.defaultWindowW < 32) UINodes.inst.defaultWindowW = 32; - else if (UINodes.inst.defaultWindowW > kha.System.windowWidth() * 0.7) UINodes.inst.defaultWindowW = Std.int(kha.System.windowWidth() * 0.7); + else if (UINodes.inst.defaultWindowW > System.windowWidth() * 0.7) UINodes.inst.defaultWindowW = Std.int(System.windowWidth() * 0.7); } else { // UINodes / UIView2D ratio UINodes.inst.defaultWindowH -= Std.int(mouse.movementY); @@ -591,7 +581,7 @@ class UITrait { if (borderStarted == 0) { defaultWindowW -= Std.int(mouse.movementX); if (defaultWindowW < 32) defaultWindowW = 32; - else if (defaultWindowW > kha.System.windowWidth() - 32) defaultWindowW = kha.System.windowWidth() - 32; + else if (defaultWindowW > System.windowWidth() - 32) defaultWindowW = System.windowWidth() - 32; windowW = Std.int(defaultWindowW * Config.raw.window_scale); } else {