Update nodes on texture delete

This commit is contained in:
luboslenco
2020-04-26 19:42:31 +02:00
parent a41aca6fc9
commit 06ec0577e1
2 changed files with 22 additions and 5 deletions
+1 -1
View File
@@ -420,4 +420,4 @@ class ImportArm {
}
}
}
}
}
+21 -4
View File
@@ -1,6 +1,7 @@
package arm.ui;
import zui.Zui;
import zui.Nodes;
import iron.data.Data;
import iron.system.Time;
import iron.system.Input;
@@ -116,12 +117,15 @@ class TabTextures {
Project.assets.splice(i, 1);
Project.assetNames.splice(i, 1);
function _parse(g: kha.graphics4.Graphics) {
arm.node.MaterialParser.parsePaintMaterial();
arm.util.RenderUtil.makeMaterialPreview();
UISidebar.inst.hwnd1.redraws = 2;
iron.App.removeRender(_parse);
arm.node.MaterialParser.parsePaintMaterial();
arm.util.RenderUtil.makeMaterialPreview();
UISidebar.inst.hwnd1.redraws = 2;
iron.App.removeRender(_parse);
}
iron.App.notifyOnRender(_parse);
for (m in Project.materials) updateTexturePointers(m.canvas.nodes, i);
for (b in Project.brushes) updateTexturePointers(b.canvas.nodes, i);
}
}, 4);
}
@@ -136,4 +140,17 @@ class TabTextures {
}
}
}
static function updateTexturePointers(nodes: Array<TNode>, i: Int) {
for (n in nodes) {
if (n.type == "TEX_IMAGE") {
if (n.buttons[0].default_value == i) {
n.buttons[0].default_value = 9999; // Texture deleted, use pink now
}
else if (n.buttons[0].default_value > i) {
n.buttons[0].default_value--; // Offset by deleted texture
}
}
}
}
}