From c97a6b2f397889995728ac619b2faf2c391e45ae Mon Sep 17 00:00:00 2001 From: Anuken Date: Sat, 20 Aug 2022 11:54:49 -0400 Subject: [PATCH] Fixed #7403 --- core/src/mindustry/logic/LogicDialog.java | 58 ++++++++++++++--------- 1 file changed, 35 insertions(+), 23 deletions(-) diff --git a/core/src/mindustry/logic/LogicDialog.java b/core/src/mindustry/logic/LogicDialog.java index 5ebee62c05..d6c755a9ca 100644 --- a/core/src/mindustry/logic/LogicDialog.java +++ b/core/src/mindustry/logic/LogicDialog.java @@ -10,6 +10,7 @@ import arc.scene.ui.layout.*; import arc.util.*; import mindustry.core.GameState.*; import mindustry.ctype.*; +import mindustry.game.*; import mindustry.gen.*; import mindustry.graphics.*; import mindustry.logic.LExecutor.*; @@ -50,6 +51,33 @@ public class LogicDialog extends BaseDialog{ add(buttons).growX().name("canvas"); } + private Color typeColor(Var s, Color color){ + return color.set( + !s.isobj ? Pal.place : + s.objval == null ? Color.darkGray : + s.objval instanceof String ? Pal.ammo : + s.objval instanceof Content ? Pal.logicOperations : + s.objval instanceof Building ? Pal.logicBlocks : + s.objval instanceof Unit ? Pal.logicUnits : + s.objval instanceof Team ? Pal.logicUnits : + s.objval instanceof Enum ? Pal.logicIo : + Color.white + ); + } + + private String typeName(Var s){ + return + !s.isobj ? "number" : + s.objval == null ? "null" : + s.objval instanceof String ? "string" : + s.objval instanceof Content ? "content" : + s.objval instanceof Building ? "building" : + s.objval instanceof Team ? "team" : + s.objval instanceof Unit ? "unit" : + s.objval instanceof Enum ? "enum" : + "unknown"; + } + private void setup(){ buttons.clearChildren(); buttons.defaults().size(160f, 64f); @@ -109,26 +137,6 @@ public class LogicDialog extends BaseDialog{ Color varColor = Pal.gray; float stub = 8f, mul = 0.5f, pad = 4; - Color color = - !s.isobj ? Pal.place : - s.objval == null ? Color.darkGray : - s.objval instanceof String ? Pal.ammo : - s.objval instanceof Content ? Pal.logicOperations : - s.objval instanceof Building ? Pal.logicBlocks : - s.objval instanceof Unit ? Pal.logicUnits : - s.objval instanceof Enum ? Pal.logicIo : - Color.white; - - String typeName = - !s.isobj ? "number" : - s.objval == null ? "null" : - s.objval instanceof String ? "string" : - s.objval instanceof Content ? "content" : - s.objval instanceof Building ? "building" : - s.objval instanceof Unit ? "unit" : - s.objval instanceof Enum ? "enum" : - "unknown"; - t.add(new Image(Tex.whiteui, varColor.cpy().mul(mul))).width(stub); t.stack(new Image(Tex.whiteui, varColor), new Label(" " + s.name + " ", Styles.outlineLabel){{ setColor(Pal.accent); @@ -154,9 +162,13 @@ public class LogicDialog extends BaseDialog{ label.act(1f); }).padRight(pad); - //TODO type name does not update, is this important? - t.add(new Image(Tex.whiteui, color.cpy().mul(mul))).width(stub); - t.stack(new Image(Tex.whiteui, color), new Label(" " + typeName + " ", Styles.outlineLabel)); + t.add(new Image(Tex.whiteui, typeColor(s, new Color()).mul(mul))).update(i -> i.setColor(typeColor(s, i.color).mul(mul))).width(stub); + + t.stack(new Image(Tex.whiteui, typeColor(s, new Color())){{ + update(() -> setColor(typeColor(s, color))); + }}, new Label(() -> " " + typeName(s) + " "){{ + setStyle(Styles.outlineLabel); + }}); t.row();