Improve ios and android support
This commit is contained in:
+4
-3
@@ -92,10 +92,10 @@ class App {
|
||||
dropPath = dropPath.rtrim();
|
||||
dropPaths.push(dropPath);
|
||||
#end
|
||||
#if krom_ios
|
||||
// #if krom_ios
|
||||
// Import immediately while access to resource is unlocked
|
||||
handleDropPaths();
|
||||
#end
|
||||
// handleDropPaths();
|
||||
// #end
|
||||
});
|
||||
|
||||
System.notifyOnApplicationState(
|
||||
@@ -350,6 +350,7 @@ class App {
|
||||
UIMenubar.inst.workspaceHandle.redraws = 2;
|
||||
UINodes.inst.hwnd.redraws = 2;
|
||||
UIView2D.inst.hwnd.redraws = 2;
|
||||
UIBox.hwnd.redraws = 2;
|
||||
if (Context.ddirty < 0) Context.ddirty = 0; // Redraw viewport
|
||||
if (Context.splitView) Context.ddirty = 1;
|
||||
}
|
||||
|
||||
@@ -403,8 +403,10 @@ class History {
|
||||
}
|
||||
|
||||
static function push(name: String): TStep {
|
||||
#if (krom_windows || krom_linux || krom_darwin)
|
||||
var filename = Project.filepath == "" ? UIFiles.filename : Project.filepath.substring(Project.filepath.lastIndexOf(Path.sep) + 1, Project.filepath.length - 4);
|
||||
kha.Window.get(0).title = filename + "* - " + Main.title;
|
||||
#end
|
||||
|
||||
if (undos < Config.raw.undo_steps) undos++;
|
||||
if (redos > 0) {
|
||||
|
||||
@@ -105,16 +105,19 @@ class Project {
|
||||
#if krom_ios
|
||||
var documentDirectory = Krom.saveDialog("", "");
|
||||
documentDirectory = documentDirectory.substr(0, documentDirectory.length - 8); // Strip /'untitled'
|
||||
filepath = documentDirectory + "/" + UIFiles.filename + ".arm";
|
||||
filepath = documentDirectory + "/" + kha.Window.get(0).title + ".arm";
|
||||
#elseif krom_android
|
||||
filepath = Krom.savePath() + "/" + UIFiles.filename + ".arm";
|
||||
filepath = Krom.savePath() + "/" + kha.Window.get(0).title + ".arm";
|
||||
#else
|
||||
projectSaveAs();
|
||||
return;
|
||||
#end
|
||||
}
|
||||
|
||||
#if (krom_windows || krom_linux || krom_darwin)
|
||||
var filename = Project.filepath.substring(Project.filepath.lastIndexOf(Path.sep) + 1, Project.filepath.length - 4);
|
||||
Window.get(0).title = filename + " - " + Main.title;
|
||||
#end
|
||||
|
||||
function _init() {
|
||||
ExportArm.runProject();
|
||||
@@ -164,7 +167,9 @@ class Project {
|
||||
}
|
||||
|
||||
public static function projectNew(resetLayers = true) {
|
||||
#if (krom_windows || krom_linux || krom_darwin)
|
||||
Window.get(0).title = Main.title;
|
||||
#end
|
||||
filepath = "";
|
||||
if (Context.mergedObject != null) {
|
||||
Context.mergedObject.remove();
|
||||
|
||||
@@ -94,6 +94,7 @@ class ExportTexture {
|
||||
#else
|
||||
Console.info(tr("Textures exported."));
|
||||
#end
|
||||
@:privateAccess UIFiles.lastPath = "";
|
||||
}
|
||||
|
||||
static function runBakeMaterial(path: String) {
|
||||
@@ -128,7 +129,11 @@ class ExportTexture {
|
||||
var textureSizeX = Config.getTextureResX();
|
||||
var textureSizeY = Config.getTextureResY();
|
||||
var formatQuality = Context.formatQuality;
|
||||
#if (krom_android || krom_ios)
|
||||
var f = kha.Window.get(0).title;
|
||||
#else
|
||||
var f = UIFiles.filename;
|
||||
#end
|
||||
if (f == "") f = tr("untitled");
|
||||
var formatType = Context.formatType;
|
||||
var bits = App.bitsHandle.position == Bits8 ? 8 : 16;
|
||||
|
||||
@@ -90,7 +90,11 @@ class ImportArm {
|
||||
Project.projectNew(importAsMesh);
|
||||
Project.filepath = path;
|
||||
UIFiles.filename = path.substring(path.lastIndexOf(Path.sep) + 1, path.lastIndexOf("."));
|
||||
#if (krom_android || krom_ios)
|
||||
Window.get(0).title = UIFiles.filename;
|
||||
#else
|
||||
Window.get(0).title = UIFiles.filename + " - " + Main.title;
|
||||
#end
|
||||
|
||||
// Import as mesh instead
|
||||
if (importAsMesh) {
|
||||
|
||||
@@ -88,7 +88,7 @@ class ImportMesh {
|
||||
#end
|
||||
|
||||
#if (krom_android || krom_ios)
|
||||
arm.ui.UIFiles.filename = path.substring(path.lastIndexOf(Path.sep) + 1, path.lastIndexOf("."));
|
||||
kha.Window.get(0).title = path.substring(path.lastIndexOf(Path.sep) + 1, path.lastIndexOf("."));
|
||||
#end
|
||||
}
|
||||
|
||||
|
||||
@@ -30,6 +30,10 @@ class BoxPreferences {
|
||||
public static function show() {
|
||||
|
||||
UIBox.showCustom(function(ui: Zui) {
|
||||
#if arm_touchui
|
||||
alignToLeftSide();
|
||||
#end
|
||||
|
||||
if (ui.tab(htab, tr("Interface"), true)) {
|
||||
|
||||
if (locales == null) {
|
||||
@@ -51,9 +55,6 @@ class BoxPreferences {
|
||||
if (hscale.value == null || Math.isNaN(hscale.value)) hscale.value = 1.0;
|
||||
Config.raw.window_scale = hscale.value;
|
||||
setScale();
|
||||
#if arm_touchui
|
||||
alignToLeftSide();
|
||||
#end
|
||||
}
|
||||
Context.hscaleWasChanged = hscale.changed;
|
||||
|
||||
@@ -578,10 +579,6 @@ plugin.drawUI = function(ui) {
|
||||
}
|
||||
}
|
||||
}, 600, 400, function() { Config.save(); });
|
||||
|
||||
#if arm_touchui
|
||||
alignToLeftSide();
|
||||
#end
|
||||
}
|
||||
|
||||
#if arm_touchui
|
||||
|
||||
@@ -21,8 +21,9 @@ class BoxProjects {
|
||||
}
|
||||
|
||||
UIBox.showCustom(function(ui: Zui) {
|
||||
if (ui.tab(htab, tr("Projects"), true)) {
|
||||
alignToFullScreen();
|
||||
|
||||
if (ui.tab(htab, tr("Projects"), true)) {
|
||||
ui.beginSticky();
|
||||
if (ui.button(tr("New"))) {
|
||||
Project.projectNew();
|
||||
@@ -43,7 +44,7 @@ class BoxProjects {
|
||||
j = 0;
|
||||
}
|
||||
}
|
||||
UIFiles.filename = title;
|
||||
kha.Window.get(0).title = title;
|
||||
}
|
||||
ui.endSticky();
|
||||
ui.separator(3, false);
|
||||
@@ -88,12 +89,16 @@ class BoxProjects {
|
||||
});
|
||||
}
|
||||
|
||||
ui.fill(0, 0, 128, 128, ui.t.SEPARATOR_COL);
|
||||
|
||||
var uix = ui._x;
|
||||
if (icon != null) {
|
||||
var uix = ui._x;
|
||||
ui.fill(0, 0, 128, 128, ui.t.SEPARATOR_COL);
|
||||
|
||||
var state = ui.image(icon, 0xffffffff, 128 * ui.SCALE());
|
||||
if (state == Released) {
|
||||
var _uix = ui._x;
|
||||
ui._x = uix;
|
||||
ui.fill(0, 0, 128, 128, 0x66000000);
|
||||
ui._x = _uix;
|
||||
iron.App.notifyOnInit(function() {
|
||||
ImportArm.runProject(path);
|
||||
});
|
||||
@@ -109,6 +114,8 @@ class BoxProjects {
|
||||
iron.App.notifyOnInit(function() {
|
||||
arm.sys.File.delete(path);
|
||||
arm.sys.File.delete(iconPath);
|
||||
var dataPath = path.substr(0, path.length - 4);
|
||||
arm.sys.File.delete(dataPath);
|
||||
recent_projects.splice(i, 1);
|
||||
});
|
||||
}
|
||||
@@ -126,14 +133,17 @@ class BoxProjects {
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
@:privateAccess ui.endElement(0);
|
||||
if (show_asset_names) @:privateAccess ui.endElement(0);
|
||||
ui._x = uix;
|
||||
}
|
||||
}
|
||||
|
||||
ui._y += 150;
|
||||
}
|
||||
}
|
||||
}, 600, 400, null, false);
|
||||
|
||||
@:privateAccess alignToFullScreen();
|
||||
}
|
||||
|
||||
static function alignToFullScreen() {
|
||||
|
||||
@@ -22,6 +22,8 @@ class TabConsole {
|
||||
ui.beginSticky();
|
||||
#if (krom_windows || krom_linux || krom_darwin)
|
||||
ui.row([1 / 14, 1 / 14, 1 / 14]); // Copy
|
||||
#elseif arm_touchui
|
||||
ui.row([1 / 4, 1 / 4]);
|
||||
#else
|
||||
ui.row([1 / 14, 1 / 14]);
|
||||
#end
|
||||
|
||||
@@ -15,7 +15,11 @@ class TabFonts {
|
||||
if (ui.tab(UIStatus.inst.statustab, tr("Fonts")) && statush > UIStatus.defaultStatusH * ui.SCALE()) {
|
||||
|
||||
ui.beginSticky();
|
||||
#if arm_touchui
|
||||
ui.row([1 / 4, 1 / 4]);
|
||||
#else
|
||||
ui.row([1 / 14, 1 / 14]);
|
||||
#end
|
||||
|
||||
if (ui.button(tr("Import"))) Project.importAsset("ttf,ttc,otf");
|
||||
if (ui.isHovered) ui.tooltip(tr("Import font file"));
|
||||
|
||||
@@ -15,7 +15,11 @@ class TabMeshes {
|
||||
if (ui.tab(UIStatus.inst.statustab, tr("Meshes")) && statush > UIStatus.defaultStatusH * ui.SCALE()) {
|
||||
|
||||
ui.beginSticky();
|
||||
#if arm_touchui
|
||||
ui.row([1 / 8, 1 / 8, 1 / 8, 1 / 8, 1 / 8, 1 / 8, 1 / 8, 1 / 8]);
|
||||
#else
|
||||
ui.row([1 / 14, 1 / 9, 1 / 9, 1 / 9, 1 / 9, 1 / 14, 1 / 14, 1 / 14]);
|
||||
#end
|
||||
|
||||
if (ui.button(tr("Import"))) {
|
||||
UIMenu.draw(function(ui: Zui) {
|
||||
|
||||
@@ -21,7 +21,11 @@ class TabScript {
|
||||
if (ui.tab(UIStatus.inst.statustab, tr("Script")) && statush > UIStatus.defaultStatusH * ui.SCALE()) {
|
||||
|
||||
ui.beginSticky();
|
||||
#if arm_touchui
|
||||
ui.row([1 / 4, 1 / 4, 1 / 4, 1 / 4]);
|
||||
#else
|
||||
ui.row([1 / 14, 1 / 14, 1 / 14, 1 / 14]);
|
||||
#end
|
||||
if (ui.button(tr("Run"))) {
|
||||
try {
|
||||
js.Lib.eval(hscript.text);
|
||||
|
||||
@@ -17,7 +17,11 @@ class TabSwatches {
|
||||
if (ui.tab(UIStatus.inst.statustab, tr("Swatches")) && statush > UIStatus.defaultStatusH * ui.SCALE()) {
|
||||
|
||||
ui.beginSticky();
|
||||
#if arm_touchui
|
||||
ui.row([1 / 4, 1 / 4, 1 / 4, 1 / 4]);
|
||||
#else
|
||||
ui.row([1 / 14, 1 / 14, 1 / 14, 1 / 14]);
|
||||
#end
|
||||
|
||||
if (ui.button(tr("New"))) {
|
||||
Context.setSwatch(Project.makeSwatch());
|
||||
|
||||
@@ -20,7 +20,11 @@ class TabTextures {
|
||||
if (ui.tab(UIStatus.inst.statustab, tr("Textures")) && statush > UIStatus.defaultStatusH * ui.SCALE()) {
|
||||
|
||||
ui.beginSticky();
|
||||
#if arm_touchui
|
||||
ui.row([1 / 4, 1 / 4]);
|
||||
#else
|
||||
ui.row([1 / 14, 1 / 14]);
|
||||
#end
|
||||
|
||||
if (ui.button(tr("Import"))) {
|
||||
UIFiles.show(Path.textureFormats.join(","), false, true, function(path: String) {
|
||||
|
||||
@@ -104,7 +104,7 @@ class UIFiles {
|
||||
var file = Res.tile50(icons, 3, 1);
|
||||
var isCloud = handle.text.startsWith("cloud");
|
||||
|
||||
if (isCloud && File.cloud == null) File.initCloud();
|
||||
if (isCloud && File.cloud == null) File.initCloud(function() { UIStatus.inst.statusHandle.redraws = 3; });
|
||||
if (isCloud && File.readDirectory("cloud", false).length == 0) return handle.text;
|
||||
|
||||
#if krom_ios
|
||||
@@ -127,7 +127,7 @@ class UIFiles {
|
||||
|
||||
var dirPath = handle.text;
|
||||
#if krom_ios
|
||||
if (!isCloud) dirPath = documentDirectory;
|
||||
if (!isCloud) dirPath = documentDirectory + dirPath;
|
||||
#end
|
||||
var filesAll = File.readDirectory(dirPath, foldersOnly);
|
||||
|
||||
@@ -203,7 +203,7 @@ class UIFiles {
|
||||
icon.g2.pipeline = null;
|
||||
icon.g2.end();
|
||||
iconMap.set(handle.text + Path.sep + f, icon);
|
||||
ui.currentWindow.redraws = 3;
|
||||
UIStatus.inst.statusHandle.redraws = 3;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -35,10 +35,13 @@ class UIMenubar {
|
||||
ui._w = Std.int(UIToolbar.defaultToolbarW * ui.SCALE());
|
||||
if (iconButton(ui, 0, 2)) BoxPreferences.show();
|
||||
if (iconButton(ui, 0, 3)) {
|
||||
ui.fill(0, 2, -(32 + 4), 32, 0x66000000);
|
||||
#if (krom_android || krom_ios)
|
||||
Project.projectSave();
|
||||
#end
|
||||
BoxProjects.show();
|
||||
App.notifyOnNextFrame(function() {
|
||||
BoxProjects.show();
|
||||
});
|
||||
}
|
||||
if (iconButton(ui, 4, 2)) Project.importAsset();
|
||||
if (iconButton(ui, 5, 2)) BoxExport.showTextures();
|
||||
|
||||
Reference in New Issue
Block a user