diff --git a/Sources/arm/App.hx b/Sources/arm/App.hx index 9358048b..35a460ae 100644 --- a/Sources/arm/App.hx +++ b/Sources/arm/App.hx @@ -369,7 +369,7 @@ class App { } else if (inViewport) { if (dragAsset.file.toLowerCase().endsWith(".hdr")) { - var image = UISidebar.inst.getImage(dragAsset); + var image = Project.getImage(dragAsset); arm.io.ImportEnvmap.run(dragAsset.file, image); } } @@ -472,7 +472,7 @@ class App { static function getDragImage(): kha.Image { dragTint = 0xffffffff; dragRect = null; - if (dragAsset != null) return UISidebar.inst.getImage(dragAsset); + if (dragAsset != null) return Project.getImage(dragAsset); if (dragMaterial != null) return dragMaterial.imageIcon; if (dragLayer != null && Context.layerIsMask) return dragLayer.texpaint_mask_preview; if (dragLayer != null && dragLayer.getChildren() != null) { diff --git a/Sources/arm/Layers.hx b/Sources/arm/Layers.hx index 2a0f5379..ece7c81f 100644 --- a/Sources/arm/Layers.hx +++ b/Sources/arm/Layers.hx @@ -569,7 +569,7 @@ class Layers { var l = Context.layer; if (l != Project.layers[0]) { History.newMask(); - l.createMask(0x00000000, true, UISidebar.inst.getImage(asset)); + l.createMask(0x00000000, true, Project.getImage(asset)); Context.setLayer(l, true); Context.layerPreviewDirty = true; } diff --git a/Sources/arm/Project.hx b/Sources/arm/Project.hx index dc448864..40bc0aba 100644 --- a/Sources/arm/Project.hx +++ b/Sources/arm/Project.hx @@ -2,6 +2,7 @@ package arm; import kha.System; import kha.Window; +import kha.Image; import zui.Zui; import zui.Id; import zui.Nodes; @@ -421,4 +422,8 @@ class Project { }); } } + + public static function getImage(asset: TAsset): Image { + return asset != null ? Project.assetMap.get(asset.id) : null; + } } diff --git a/Sources/arm/node/brush/BrushOutputNode.hx b/Sources/arm/node/brush/BrushOutputNode.hx index a6b0c519..e5d411a8 100644 --- a/Sources/arm/node/brush/BrushOutputNode.hx +++ b/Sources/arm/node/brush/BrushOutputNode.hx @@ -30,7 +30,7 @@ class BrushOutputNode extends LogicNode { Context.brushNodesOpacity = 1.0; var index = Project.assetNames.indexOf(opac); var asset = Project.assets[index]; - Context.brushMaskImage = UISidebar.inst.getImage(asset); + Context.brushMaskImage = Project.getImage(asset); } else { Context.brushNodesOpacity = opac; @@ -44,7 +44,7 @@ class BrushOutputNode extends LogicNode { if (Std.is(stencil, String)) { var index = Project.assetNames.indexOf(stencil); var asset = Project.assets[index]; - Context.brushStencilImage = UISidebar.inst.getImage(asset); + Context.brushStencilImage = Project.getImage(asset); } else { Context.brushStencilImage = null; diff --git a/Sources/arm/render/Uniforms.hx b/Sources/arm/render/Uniforms.hx index 4b9b3324..2384f51b 100644 --- a/Sources/arm/render/Uniforms.hx +++ b/Sources/arm/render/Uniforms.hx @@ -389,7 +389,7 @@ class Uniforms { #if arm_painter case "_texcolorid": { if (Project.assets.length == 0) return RenderPath.active.renderTargets.get("empty_white").image; - else return UISidebar.inst.getImage(Project.assets[Context.colorIdHandle.position]); + else return Project.getImage(Project.assets[Context.colorIdHandle.position]); } case "_texuvmap": { if (!UVUtil.uvmapCached) { diff --git a/Sources/arm/ui/TabTextures.hx b/Sources/arm/ui/TabTextures.hx index f60af487..20143a27 100644 --- a/Sources/arm/ui/TabTextures.hx +++ b/Sources/arm/ui/TabTextures.hx @@ -50,7 +50,7 @@ class TabTextures { } var asset = Project.assets[i]; - var img = UISidebar.inst.getImage(asset); + var img = Project.getImage(asset); var uix = ui._x; var uiy = ui._y; var sw = img.height < img.width ? img.height : 0; diff --git a/Sources/arm/ui/UIHeader.hx b/Sources/arm/ui/UIHeader.hx index a6982aee..4ef77994 100644 --- a/Sources/arm/ui/UIHeader.hx +++ b/Sources/arm/ui/UIHeader.hx @@ -41,7 +41,7 @@ class UIHeader { ui.text(tr("Color ID Map")); var cid = ui.combo(Context.colorIdHandle, App.enumTexts("TEX_IMAGE"), tr("Color ID")); if (Context.colorIdHandle.changed) Context.ddirty = 2; - if (Project.assets.length > 0) ui.image(UISidebar.inst.getImage(Project.assets[cid])); + if (Project.assets.length > 0) ui.image(Project.getImage(Project.assets[cid])); } else if (Context.tool == ToolPicker) { Context.baseRPicked = Math.round(Context.baseRPicked * 10) / 10; diff --git a/Sources/arm/ui/UINodes.hx b/Sources/arm/ui/UINodes.hx index 62b77ce1..d909ab1e 100644 --- a/Sources/arm/ui/UINodes.hx +++ b/Sources/arm/ui/UINodes.hx @@ -364,7 +364,7 @@ class UINodes { if (sel.type == "TEX_IMAGE") { var id = sel.buttons[0].default_value; if (id < Project.assets.length) { - img = UISidebar.inst.getImage(Project.assets[id]); + img = Project.getImage(Project.assets[id]); } } else if (sel.type == "LAYER") { diff --git a/Sources/arm/ui/UISidebar.hx b/Sources/arm/ui/UISidebar.hx index d15f3029..05350c1c 100644 --- a/Sources/arm/ui/UISidebar.hx +++ b/Sources/arm/ui/UISidebar.hx @@ -829,10 +829,6 @@ class UISidebar { Config.raw.layout[LayoutStatusH] = Std.int(Config.raw.layout[LayoutStatusH] * Config.raw.window_scale); } - public function getImage(asset: TAsset): Image { - return asset != null ? Project.assetMap.get(asset.id) : null; - } - public function setIconScale() { if (ui.SCALE() > 1) { Res.load(["icons2x.k"], function() { diff --git a/Sources/arm/ui/UIView2D.hx b/Sources/arm/ui/UIView2D.hx index 1384e65a..90c23509 100644 --- a/Sources/arm/ui/UIView2D.hx +++ b/Sources/arm/ui/UIView2D.hx @@ -121,7 +121,7 @@ class UIView2D { 0; } else if (type == View2DAsset) { - tex = UISidebar.inst.getImage(Context.texture); + tex = Project.getImage(Context.texture); } else { // View2DFont tex = Context.font.image;