From 55dfc630f9f94d03b6efc0611f7c1e67ade1fe05 Mon Sep 17 00:00:00 2001 From: luboslenco Date: Mon, 17 Jun 2019 21:05:15 +0200 Subject: [PATCH] Init strings --- Sources/arm/App.hx | 2 +- Sources/arm/Importer.hx | 16 ++++++++-------- Sources/arm/Project.hx | 4 ++-- Sources/arm/Strings.hx | 11 +++++++++++ 4 files changed, 22 insertions(+), 11 deletions(-) create mode 100644 Sources/arm/Strings.hx diff --git a/Sources/arm/App.hx b/Sources/arm/App.hx index b3209f15..54d3d660 100644 --- a/Sources/arm/App.hx +++ b/Sources/arm/App.hx @@ -409,7 +409,7 @@ class App extends iron.Trait { for (i in 0...s.length) { if (s.charCodeAt(i) > 127) { // Bail out for now :( - UITrait.inst.showError("Error: accented / special characters in file path"); + UITrait.inst.showError(Strings.error0); return false; } } diff --git a/Sources/arm/Importer.hx b/Sources/arm/Importer.hx index 7aa17732..b5338529 100644 --- a/Sources/arm/Importer.hx +++ b/Sources/arm/Importer.hx @@ -51,7 +51,7 @@ class Importer { importFolder(path); } else { - UITrait.inst.showError("Error: Unknown asset format"); + UITrait.inst.showError(Strings.error1); } } @@ -237,11 +237,11 @@ class Importer { public static function importTexture(path:String) { if (!Format.checkTextureFormat(path)) { - UITrait.inst.showError("Error: Unknown asset format"); + UITrait.inst.showError(Strings.error1); return; } - for (a in UITrait.inst.assets) if (a.file == path) { UITrait.inst.showMessage("Info: Asset already imported"); return; } + for (a in UITrait.inst.assets) if (a.file == path) { UITrait.inst.showMessage(Strings.info0); return; } iron.data.Data.getImage(path, function(image:kha.Image) { var ar = path.split("/"); @@ -367,7 +367,7 @@ class Importer { public static function importMesh(path:String) { if (!Format.checkMeshFormat(path)) { - UITrait.inst.showError("Error: Unknown mesh format"); + UITrait.inst.showError(Strings.error1); return; } @@ -476,7 +476,7 @@ class Importer { // { test -e file && echo 1 || echo 0 } #end if (exists == 0) { - trace("Could not locate texture " + abs); + UITrait.inst.showError(Strings.error2 + abs); var b = haxe.io.Bytes.alloc(4); b.set(0, 255); b.set(1, 0); @@ -889,7 +889,7 @@ class Importer { static function makeMesh(mesh:Dynamic, path:String) { if (mesh == null || mesh.posa == null || mesh.nora == null || mesh.inda == null) { - UITrait.inst.showError("Error: Failed to read mesh data"); + UITrait.inst.showError(Strings.error3); return; } @@ -912,7 +912,7 @@ class Importer { else { if (mesh.texa == null) { - UITrait.inst.showError("Error: Mesh has no UVs, generating defaults"); + UITrait.inst.showError(Strings.error4); var verts = Std.int(mesh.posa.length / 4); mesh.texa = new kha.arrays.Int16Array(verts * 2); var n = new iron.math.Vec4(); @@ -1015,7 +1015,7 @@ class Importer { static function addMesh(mesh:Dynamic) { if (mesh.texa == null) { - UITrait.inst.showError("Error: Mesh has no UVs, generating defaults"); + UITrait.inst.showError(Strings.error4); var verts = Std.int(mesh.posa.length / 4); mesh.texa = new kha.arrays.Int16Array(verts * 2); var n = new iron.math.Vec4(); diff --git a/Sources/arm/Project.hx b/Sources/arm/Project.hx index c315f211..2eda0671 100644 --- a/Sources/arm/Project.hx +++ b/Sources/arm/Project.hx @@ -22,7 +22,7 @@ class Project { UIFiles.filters = "arm"; arm.App.filesDone = function(path:String) { if (!StringTools.endsWith(path, ".arm")) { - UITrait.inst.showError("Error: .arm file expected"); + UITrait.inst.showError(Strings.error5); return; } @@ -282,7 +282,7 @@ class Project { // { test -e file && echo 1 || echo 0 } #end if (exists == 0) { - trace("Could not locate texture " + abs); + UITrait.inst.showError(Strings.error2 + abs); var b = haxe.io.Bytes.alloc(4); b.set(0, 255); b.set(1, 0); diff --git a/Sources/arm/Strings.hx b/Sources/arm/Strings.hx new file mode 100644 index 00000000..c53780ed --- /dev/null +++ b/Sources/arm/Strings.hx @@ -0,0 +1,11 @@ +package arm; + +class Strings { + public static var error0 = "Error: Accented / special characters in file path"; + public static var error1 = "Error: Unknown asset format"; + public static var error2 = "Error: Could not locate texture "; + public static var error3 = "Error: Failed to read mesh data"; + public static var error4 = "Error: Mesh has no UVs, generating defaults"; + public static var error5 = "Error: .arm file expected"; + public static var info0 = "Info: Asset already imported"; +}