Add 'Preferences - Native File Browser' option
This commit is contained in:
@@ -52,6 +52,8 @@ class BoxPreferences {
|
||||
UITrait.inst.hwnd2.redraws = 2;
|
||||
}
|
||||
|
||||
UITrait.inst.nativeBrowser = ui.check(Id.handle({selected: UITrait.inst.nativeBrowser}), "Native File Browser");
|
||||
|
||||
UITrait.inst.cacheDraws = ui.check(Id.handle({selected: UITrait.inst.cacheDraws}), "Cache Draws");
|
||||
if (ui.isHovered) ui.tooltip("Enabling may reduce GPU usage");
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ package arm.ui;
|
||||
import zui.Zui;
|
||||
import zui.Id;
|
||||
import iron.system.Input;
|
||||
import arm.util.Path;
|
||||
using StringTools;
|
||||
|
||||
class UIFiles {
|
||||
@@ -14,9 +15,14 @@ class UIFiles {
|
||||
public static var filters = "";
|
||||
public static var path = '/';
|
||||
|
||||
@:access(zui.Zui)
|
||||
public static function render(g:kha.graphics2.Graphics) {
|
||||
show = false;
|
||||
|
||||
if (!UITrait.inst.nativeBrowser) {
|
||||
renderCustom(g);
|
||||
return;
|
||||
}
|
||||
|
||||
path = isSave ? Krom.saveDialog(filters, "") : Krom.openDialog(filters, "");
|
||||
if (path != null) {
|
||||
#if krom_windows
|
||||
@@ -36,6 +42,32 @@ class UIFiles {
|
||||
releaseKeys();
|
||||
}
|
||||
|
||||
@:access(zui.Zui)
|
||||
static function renderCustom(g:kha.graphics2.Graphics) {
|
||||
UIBox.showCustom(function(ui:Zui) {
|
||||
if (ui.tab(Id.handle(), "File Browser")) {
|
||||
var pathHandle = Id.handle();
|
||||
var fileHandle = Id.handle();
|
||||
ui.row([6/10, 2/10, 2/10]);
|
||||
filename = ui.textInput(fileHandle, "File");
|
||||
ui.text('*.' + filters, Center);
|
||||
var known = Path.checkTextureFormat(path) || Path.checkMeshFormat(path) || Path.checkProjectFormat(path);
|
||||
if (ui.button(isSave ? "Save" : "Open") || known) {
|
||||
UIBox.show = false;
|
||||
#if krom_windows
|
||||
var sep = "\\";
|
||||
#else
|
||||
var sep = "/";
|
||||
#end
|
||||
filesDone((known || isSave) ? path : path + sep + filename);
|
||||
if (known) pathHandle.text = pathHandle.text.substr(0, pathHandle.text.lastIndexOf(sep));
|
||||
}
|
||||
path = zui.Ext.fileBrowser(ui, pathHandle, false);
|
||||
if (pathHandle.changed) ui.currentWindow.redraws = 3;
|
||||
}
|
||||
}, 600, 500);
|
||||
}
|
||||
|
||||
static function releaseKeys() {
|
||||
// File dialog may prevent firing key up events
|
||||
var kb = Input.getKeyboard();
|
||||
|
||||
@@ -132,6 +132,7 @@ class UITrait {
|
||||
public var viewportMode = 0;
|
||||
public var hscaleWasChanged = false;
|
||||
public var exportMeshFormat = 0;
|
||||
public var nativeBrowser = true;
|
||||
public var cacheDraws = false;
|
||||
|
||||
public var textToolImage:Image = null;
|
||||
|
||||
Reference in New Issue
Block a user