Update log interface
This commit is contained in:
@@ -14,7 +14,7 @@ plugin.drawUI = function(ui) {
|
||||
ui.text("Label");
|
||||
ui.textInput(h7, "Text Input");
|
||||
if (ui.button("Button")) {
|
||||
arm.Log.showError("Hello");
|
||||
arm.Log.error("Hello");
|
||||
}
|
||||
ui.row([1/2, 1/2]);
|
||||
ui.button("Button A");
|
||||
|
||||
+2
-2
@@ -9,14 +9,14 @@ class Log {
|
||||
public static var lastTraces:Array<String> = [''];
|
||||
static var haxeTrace:Dynamic->haxe.PosInfos->Void = null;
|
||||
|
||||
public static function showMessage(s:String) {
|
||||
public static function info(s:String) {
|
||||
messageTimer = 5.0;
|
||||
message = s;
|
||||
messageColor = 0x00000000;
|
||||
arm.ui.UITrait.inst.statusHandle.redraws = 2;
|
||||
}
|
||||
|
||||
public static function showError(s:String) {
|
||||
public static function error(s:String) {
|
||||
messageTimer = 8.0;
|
||||
message = s;
|
||||
messageColor = 0xffff0000;
|
||||
|
||||
@@ -49,7 +49,7 @@ class Project {
|
||||
public static function projectOpen() {
|
||||
UIFiles.show("arm", false, function(path:String) {
|
||||
if (!path.endsWith(".arm")) {
|
||||
Log.showError(Strings.error5);
|
||||
Log.error(Strings.error5);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -277,7 +277,7 @@ class Project {
|
||||
public static function reimportMesh() {
|
||||
if (Project.meshAssets != null && Project.meshAssets.length > 0) {
|
||||
ImportMesh.run(Project.meshAssets[0], false);
|
||||
Log.showMessage("Mesh reimported.");
|
||||
Log.info("Mesh reimported.");
|
||||
}
|
||||
else importAsset();
|
||||
}
|
||||
|
||||
@@ -97,7 +97,7 @@ class ExportArm {
|
||||
var bytes = ArmPack.encode(Project.raw);
|
||||
Krom.fileSaveBytes(Project.filepath, bytes.getData());
|
||||
|
||||
Log.showMessage("Project saved.");
|
||||
Log.info("Project saved.");
|
||||
}
|
||||
|
||||
public static function runMaterial(path:String) {
|
||||
|
||||
@@ -41,7 +41,7 @@ class ExportTexture {
|
||||
trace("Textures exported in " + (iron.system.Time.realTime() - timer));
|
||||
#end
|
||||
|
||||
Log.showMessage("Textures exported.");
|
||||
Log.info("Textures exported.");
|
||||
}
|
||||
|
||||
static function runLayers(path:String, udimTile = "") {
|
||||
|
||||
@@ -72,7 +72,7 @@ class ImportArm {
|
||||
var isAbsolute = file.charAt(0) == "/" || file.charAt(1) == ":";
|
||||
var abs = isAbsolute ? file : base + file;
|
||||
if (!File.exists(abs)) {
|
||||
Log.showError(Strings.error2 + abs);
|
||||
Log.error(Strings.error2 + abs);
|
||||
var b = Bytes.alloc(4);
|
||||
b.set(0, 255);
|
||||
b.set(1, 0);
|
||||
@@ -251,7 +251,7 @@ class ImportArm {
|
||||
var isAbsolute = file.charAt(0) == "/" || file.charAt(1) == ":";
|
||||
var abs = isAbsolute ? file : base + file;
|
||||
if (!File.exists(abs)) {
|
||||
Log.showError(Strings.error2 + abs);
|
||||
Log.error(Strings.error2 + abs);
|
||||
var b = Bytes.alloc(4);
|
||||
b.set(0, 255);
|
||||
b.set(1, 0);
|
||||
|
||||
@@ -56,7 +56,7 @@ class ImportAsset {
|
||||
ImportFolder.run(path);
|
||||
}
|
||||
else {
|
||||
Log.showError(Strings.error1);
|
||||
Log.error(Strings.error1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ class ImportBlend {
|
||||
Data.getBlob(path, function(b:Blob) {
|
||||
var bl = new BlendParser(b);
|
||||
if (bl.dna == null) {
|
||||
Log.showError(Strings.error3);
|
||||
Log.error(Strings.error3);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -217,13 +217,13 @@ class ImportBlend {
|
||||
Data.getBlob(path, function(b:Blob) {
|
||||
var bl = new BlendParser(b);
|
||||
if (bl.dna == null) {
|
||||
Log.showError(Strings.error3);
|
||||
Log.error(Strings.error3);
|
||||
return;
|
||||
}
|
||||
|
||||
var mats = bl.get("Material");
|
||||
if (mats.length == 0) {
|
||||
Log.showError("Error: No materials found");
|
||||
Log.error("Error: No materials found");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -256,7 +256,7 @@ class ImportBlend {
|
||||
node = node.get("next");
|
||||
}
|
||||
if (node.get("idname") != "ShaderNodeBsdfPrincipled") {
|
||||
Log.showError("Error: No Principled BSDF node found");
|
||||
Log.error("Error: No Principled BSDF node found");
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ class ImportMesh {
|
||||
|
||||
public static function run(path:String, _clearLayers = true) {
|
||||
if (!Path.isMesh(path)) {
|
||||
Log.showError(Strings.error1);
|
||||
Log.error(Strings.error1);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -88,7 +88,7 @@ class ImportMesh {
|
||||
|
||||
public static function makeMesh(mesh:Dynamic, path:String) {
|
||||
if (mesh == null || mesh.posa == null || mesh.nora == null || mesh.inda == null) {
|
||||
Log.showError(Strings.error3);
|
||||
Log.error(Strings.error3);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -111,7 +111,7 @@ class ImportMesh {
|
||||
else {
|
||||
|
||||
if (mesh.texa == null) {
|
||||
Log.showError(Strings.error4);
|
||||
Log.error(Strings.error4);
|
||||
var verts = Std.int(mesh.posa.length / 4);
|
||||
mesh.texa = new Int16Array(verts * 2);
|
||||
var n = new Vec4();
|
||||
@@ -216,7 +216,7 @@ class ImportMesh {
|
||||
public static function addMesh(mesh:Dynamic) {
|
||||
|
||||
if (mesh.texa == null) {
|
||||
Log.showError(Strings.error4);
|
||||
Log.error(Strings.error4);
|
||||
var verts = Std.int(mesh.posa.length / 4);
|
||||
mesh.texa = new Int16Array(verts * 2);
|
||||
var n = new Vec4();
|
||||
|
||||
@@ -7,7 +7,7 @@ class ImportPlugin {
|
||||
|
||||
public static function run(path:String) {
|
||||
if (!Path.isPlugin(path)) {
|
||||
Log.showError(Strings.error1);
|
||||
Log.error(Strings.error1);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -15,6 +15,6 @@ class ImportPlugin {
|
||||
var dstPath = Path.data() + Path.sep + "plugins" + Path.sep + filename;
|
||||
File.copy(path, dstPath); // Copy to plugin folder
|
||||
arm.ui.BoxPreferences.files = null; // Refresh file list
|
||||
Log.showMessage("Plugin '" + filename + "' imported.");
|
||||
Log.info("Plugin '" + filename + "' imported.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,11 +11,11 @@ class ImportTexture {
|
||||
|
||||
public static function run(path:String) {
|
||||
if (!Path.isTexture(path)) {
|
||||
Log.showError(Strings.error1);
|
||||
Log.error(Strings.error1);
|
||||
return;
|
||||
}
|
||||
|
||||
for (a in Project.assets) if (a.file == path) { Log.showMessage(Strings.info0); return; }
|
||||
for (a in Project.assets) if (a.file == path) { Log.info(Strings.info0); return; }
|
||||
|
||||
var ext = path.substr(path.lastIndexOf(".") + 1);
|
||||
var importer = Path.textureImporters.get(ext);
|
||||
|
||||
@@ -606,16 +606,27 @@ class Material {
|
||||
}
|
||||
|
||||
else if (node.type == 'BLUR') {
|
||||
// Image nodes only for now
|
||||
var out_col = parse_vector_input(node.inputs[0]);
|
||||
out_col = parsedMap.get(out_col);
|
||||
if (out_col == null) return 'vec3(0.0, 0.0, 0.0)';
|
||||
out_col = textureMap.get(out_col.split(".")[0]);
|
||||
if (out_col == null) return 'vec3(0.0, 0.0, 0.0)';
|
||||
out_col += '.rgb';
|
||||
var strength = parse_value_input(node.inputs[1]);
|
||||
curshader.write('vec3 res1 = vec3(0, 0, 0);');
|
||||
curshader.write('for (int i = -6; i <= 6; ++i) {');
|
||||
curshader.write('for (int j = -6; j <= 6; ++j) {');
|
||||
curshader.write('texCoord += vec2(i, j) / 100;');
|
||||
if (strength == '0.0') return 'vec3(0.0, 0.0, 0.0)';
|
||||
var steps = 'int($strength * 10 + 1)';
|
||||
var texture = out_col.substring(out_col.indexOf("(") + 1, out_col.indexOf(","));
|
||||
curshader.write('vec2 _texCoord = texCoord;');
|
||||
curshader.write('vec3 res1 = vec3(0.0, 0.0, 0.0);');
|
||||
curshader.write('for (int i = -$steps; i <= $steps; ++i) {');
|
||||
curshader.write('for (int j = -$steps; j <= $steps; ++j) {');
|
||||
curshader.write('texCoord = _texCoord + vec2(i, j) / textureSize($texture, 0);');
|
||||
curshader.write('res1 += $out_col;');
|
||||
curshader.write('}');
|
||||
curshader.write('}');
|
||||
curshader.write('res1 /= 13 * 13;');
|
||||
curshader.write('texCoord = _texCoord;');
|
||||
curshader.write('res1 /= ($steps * 2 + 1) * ($steps * 2 + 1);');
|
||||
return 'res1';
|
||||
}
|
||||
|
||||
@@ -1673,6 +1684,9 @@ class Material {
|
||||
return node_name(node) + '_' + safesrc(socket.name) + '_res';
|
||||
}
|
||||
|
||||
static var parsedMap = new Map<String, String>();
|
||||
static var textureMap = new Map<String, String>();
|
||||
|
||||
static function write_result(l:TNodeLink):String {
|
||||
var from_node = getNode(l.from_id);
|
||||
var from_socket = from_node.outputs[l.from_socket];
|
||||
@@ -1684,12 +1698,14 @@ class Material {
|
||||
var res = parse_vector(from_node, from_socket);
|
||||
if (res == null)
|
||||
return null;
|
||||
parsedMap.set(res_var, res);
|
||||
curshader.write('vec3 $res_var = $res;');
|
||||
}
|
||||
else if (st == 'VALUE') {
|
||||
var res = parse_value(from_node, from_socket);
|
||||
if (res == null)
|
||||
return null;
|
||||
parsedMap.set(res_var, res);
|
||||
curshader.write('float $res_var = $res;');
|
||||
}
|
||||
}
|
||||
@@ -1720,6 +1736,7 @@ class Material {
|
||||
curshader.write('if (texCoordBlend.z > 0) $tex_store += texture($tex_name, ${uv_name}2.xy) * texCoordBlend.z;');
|
||||
}
|
||||
else {
|
||||
textureMap.set(tex_store, 'texture($tex_name, $uv_name.xy)');
|
||||
curshader.write('vec4 $tex_store = texture($tex_name, $uv_name.xy);');
|
||||
}
|
||||
|
||||
|
||||
@@ -300,6 +300,8 @@ class MaterialShader {
|
||||
s += '#define textureLod(tex, coord, lod) tex.SampleLevel(tex ## _sampler, coord, lod)\n';
|
||||
s += '#define textureLodShared(tex, coord, lod) tex.SampleLevel($sharedSampler, coord, lod)\n';
|
||||
s += '#define texelFetch(tex, coord, lod) tex.Load(float3(coord.xy, lod))\n';
|
||||
s += 'uint2 _GetDimensions(Texture2D tex, uint lod) { uint x, y; tex.GetDimensions(x, y); return uint2(x, y); }\n';
|
||||
s += '#define textureSize _GetDimensions\n';
|
||||
s += '#define mod(a, b) (a % b)\n';
|
||||
s += '#define vec2 float2\n';
|
||||
s += '#define vec3 float3\n';
|
||||
|
||||
@@ -1198,7 +1198,7 @@ class NodesMaterial {
|
||||
},
|
||||
{
|
||||
id: 0,
|
||||
name: "Blur",
|
||||
name: "Blur (Image)",
|
||||
type: "BLUR", // extension
|
||||
x: 0,
|
||||
y: 0,
|
||||
|
||||
@@ -114,9 +114,9 @@ class BoxExport {
|
||||
fetchPresets();
|
||||
preset = null;
|
||||
hpreset.position = files.indexOf(filename.substr(0, filename.length - 5)); // Strip .json
|
||||
Log.showMessage("Preset '" + filename + "' imported.");
|
||||
Log.info("Preset '" + filename + "' imported.");
|
||||
}
|
||||
else Log.showError(Strings.error1);
|
||||
else Log.error(Strings.error1);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -232,7 +232,7 @@ let h1 = new zui.Handle();
|
||||
plugin.drawUI = function(ui) {
|
||||
if (ui.panel(h1, 'New Plugin')) {
|
||||
if (ui.button('Button')) {
|
||||
arm.Log.showError('Hello');
|
||||
arm.Log.error('Hello');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -99,7 +99,7 @@ class UIMenu {
|
||||
if (ui.button("Import Envmap...", Left)) {
|
||||
UIFiles.show("hdr", false, function(path:String) {
|
||||
if (!path.endsWith(".hdr")) {
|
||||
Log.showError("Error: .hdr file expected");
|
||||
Log.error("Error: .hdr file expected");
|
||||
return;
|
||||
}
|
||||
ImportAsset.run(path);
|
||||
|
||||
Reference in New Issue
Block a user