From 254afa91b9514502aaea8ff0c5c6c0e40c3f55ef Mon Sep 17 00:00:00 2001 From: sharlotte Date: Sun, 22 Aug 2021 12:56:13 +0900 Subject: [PATCH] remove overrided drawBackground() --- src/UnitInfo/SUtils.java | 12 +----- src/UnitInfo/core/HudUi.java | 68 +++++++++++++-------------------- src/UnitInfo/core/SettingS.java | 2 +- 3 files changed, 29 insertions(+), 53 deletions(-) diff --git a/src/UnitInfo/SUtils.java b/src/UnitInfo/SUtils.java index 7b154e2..bc40e79 100644 --- a/src/UnitInfo/SUtils.java +++ b/src/UnitInfo/SUtils.java @@ -18,18 +18,8 @@ public class SUtils { } public static String floatFormat(float number){ - if(number >= 10000) return UI.formatAmount((long)number); + if(number >= 1000) return UI.formatAmount((long)number); if(String.valueOf(number).split("[.]")[1].matches("0")) return String.valueOf(number).split("[.]")[0]; return Strings.fixed(number, 1); } - - public static Object getFinalStatic(Field field) throws Exception { - field.setAccessible(true); - - Field modifiersField = Field.class.getDeclaredField("modifiers"); - modifiersField.setAccessible(true); - modifiersField.setInt(field, field.getModifiers() & ~Modifier.FINAL); - - return field.get(null); - } } diff --git a/src/UnitInfo/core/HudUi.java b/src/UnitInfo/core/HudUi.java index 003571a..bea8046 100644 --- a/src/UnitInfo/core/HudUi.java +++ b/src/UnitInfo/core/HudUi.java @@ -629,7 +629,7 @@ public class HudUi { public void addWeaponTable(Table table){ table.table().update(t -> { t.clear(); - t.add(new Table(Tex.button, tt -> { + t.add(new Table(((NinePatchDrawable)Tex.button).tint(Tmp.c1.set(((NinePatchDrawable)Tex.button).getPatch().getColor()).a(settings.getInt("uiopacity") / 100f)), tt -> { tt.defaults().width(Scl.scl(modUiScale) * 8 * 8f).minHeight(Scl.scl(modUiScale) * 4 * 8f).align(Align.left); tt.visibility = () -> settings.getBool("weaponui") && getTarget() instanceof Unit u && u.type != null && u.type.weapons.size > 0; if(settings.getBool("weaponui") && getTarget() instanceof Unit u && u.type != null) { @@ -686,15 +686,7 @@ public class HudUi { }); } } - }){ - @Override - protected void drawBackground(float x, float y) { - if(getBackground() == null) return; - Color color = this.color; - Draw.color(color.r, color.g, color.b, (settings.getInt("uiopacity") / 100f) * this.parentAlpha); - getBackground().draw(x, y, width, height); - } - }); + })); }); } @@ -755,22 +747,22 @@ public class HudUi { public void addUnitTable(){ if(uiIndex != 0) return; unitTable = new Table(table -> { - table.left().defaults().width(scaledScale * 27 * 8f).maxHeight(scaledScale * 35 * 8f).align(Align.left); + table.left().defaults().width(scaledScale * 27 * 8f).maxHeight(scaledScale * 35 * 8f); addBars(); Table table1 = new Table(Tex.button, t -> { + t.left(); t.table(Tex.underline2, tt -> { Stack stack = new Stack(){{ add(new Table(ttt -> { - ttt.setSize(Scl.scl(modUiScale) * 4f * 8f); ttt.image(() -> { TextureRegion region = clear; - if(getTarget() instanceof Unit u && u.type != null) region = ((Unit) getTarget()).type().uiIcon; - else if(getTarget() instanceof Building b && b.block != null) { + if(getTarget() instanceof Unit u && u.type != null) region = u.type.uiIcon; + else if(getTarget() instanceof Building b) { if(getTarget() instanceof ConstructBlock.ConstructBuild cb) region = cb.current.uiIcon; - else region = b.block.uiIcon; + else if(b.block != null) region = b.block.uiIcon; } return region; - }); + }).size(Scl.scl(modUiScale) * 4 * 8f); })); add(new Table(ttt -> { @@ -794,13 +786,12 @@ public class HudUi { Label label = new Label(() -> { String name = ""; if(getTarget() instanceof Unit u && u.type != null) - name = "[accent]" + u.type.localizedName + "[]"; + name = u.type.localizedName; if(getTarget() instanceof Building b && b.block != null) { - if(getTarget() instanceof ConstructBlock.ConstructBuild cb) name = "[accent]" + cb.current.localizedName + "[]"; - else name = "[accent]" + b.block.localizedName + "[]"; + if(getTarget() instanceof ConstructBlock.ConstructBuild cb) name = cb.current.localizedName; + else name = b.block.localizedName; } - if(name.length() > 12) return name.substring(0, 12) + "..."; - return name; + return "[accent]" + (name.length() > 9 ? name.substring(0, 9) + "..." : name) + "[]"; }); label.setFontScale(scaledScale); @@ -814,7 +805,6 @@ public class HudUi { button.visibility = () -> getTarget() != null; button.update(()->{ lockButton.getStyle().imageUp = Icon.lock.tint(locked ? Pal.accent : Color.white); - lockButton.getStyle().imageDown = Icon.lock.tint(locked ? Pal.accent : Color.white); }); lockButton = Elem.newImageButton(Styles.clearPartiali, Icon.lock.tint(locked ? Pal.accent : Color.white), 3 * 8f * Scl.scl(modUiScale), () -> { @@ -867,15 +857,12 @@ public class HudUi { t.setColor(t.color.cpy().a(1f)); t.background(Tex.button); - }){ - @Override - protected void drawBackground(float x, float y) { - if(getBackground() == null) return; - Color color = this.color; - Draw.color(color.r, color.g, color.b, (settings.getInt("uiopacity") / 100f) * this.parentAlpha); - getBackground().draw(x, y, width, height); - } - }; + + t.update(() -> { + NinePatchDrawable patch = (NinePatchDrawable)Tex.button; + t.setBackground(patch.tint(Tmp.c1.set(patch.getPatch().getColor()).a(settings.getInt("uiopacity") / 100f))); + }); + }); table.table(t -> t.stack(table1, addInfoTable(t))); table.row(); table.table(this::addWeaponTable); @@ -1053,15 +1040,13 @@ public class HudUi { waveTable = new Table(table -> { table.left().defaults().width(scaledScale * 32 * 8f).maxHeight(scaledScale * 32 * 8f).align(Align.left); - table.add(new Table(Tex.button, t -> t.add(wavePane)){ - @Override - protected void drawBackground(float x, float y) { - if(getBackground() == null) return; - Draw.color(color.r, color.g, color.b, (settings.getInt("uiopacity") / 100f) * this.parentAlpha); - getBackground().draw(x, y, width, height); - Draw.reset(); - } - }).padRight(scaledScale * 39 * 8f); + table.add(new Table(Tex.button, t -> { + t.add(wavePane); + t.update(() -> { + NinePatchDrawable patch = (NinePatchDrawable)Tex.button; + t.setBackground(patch.tint(Tmp.c1.set(patch.getPatch().getColor()).a(settings.getInt("uiopacity") / 100f))); + }); + })).padRight(scaledScale * 39 * 8f); table.fillParent = true; table.visibility = () -> uiIndex == 1; @@ -1069,7 +1054,8 @@ public class HudUi { } public void setItem(Table table){ - table.table(t -> { + table.table().update(t -> { + t.clear(); for(int i = 0; i < coreItems.tables.size; i++){ if((state.rules.pvp && coreItems.teams[i] != player.team()) || coreItems.teams[i].cores().isEmpty()) continue; int finalI = i; diff --git a/src/UnitInfo/core/SettingS.java b/src/UnitInfo/core/SettingS.java index 2445636..b14887d 100644 --- a/src/UnitInfo/core/SettingS.java +++ b/src/UnitInfo/core/SettingS.java @@ -290,7 +290,7 @@ public class SettingS { */ addGraphicCheckSetting("spathfinder", true); - addGraphicSlideSetting("infoUiScale", 100, 50, 200, 10, s -> s + "%"); + addGraphicSlideSetting("infoUiScale", 100, 50, 100, 5, s -> s + "%"); addGraphicSlideSetting("coreItemCheckRate", 60, 6, 180, 6, s -> Strings.fixed(s/60f,1) + "sec"); addGraphicCheckSetting("pastwave", false); addGraphicCheckSetting("emptywave", true);