This commit is contained in:
sharlotte
2021-08-22 13:32:01 +09:00
parent 254afa91b9
commit ac8aa3072c
2 changed files with 54 additions and 51 deletions

View File

@@ -39,6 +39,7 @@ import mindustry.world.blocks.power.PowerNode;
import static UnitInfo.SVars.*; import static UnitInfo.SVars.*;
import static arc.Core.*; import static arc.Core.*;
import static mindustry.Vars.*; import static mindustry.Vars.*;
import static mindustry.gen.Tex.scrollKnobVerticalThin;
public class HudUi { public class HudUi {
Seq<Element> bars = new Seq<>(); Seq<Element> bars = new Seq<>();
@@ -268,7 +269,7 @@ public class HudUi {
}); });
Events.run(EventType.Trigger.update, ()->{ Events.run(EventType.Trigger.update, ()->{
if(modUiScale != settings.getInt("infoUiScale") / 100f && settings.getInt("infoUiScale") / 100f != 0){ if(modUiScale != settings.getInt("infoUiScale") / 100f){
modUiScale = settings.getInt("infoUiScale") / 100f; modUiScale = settings.getInt("infoUiScale") / 100f;
mainTable.clearChildren(); mainTable.clearChildren();
addTable(); addTable();
@@ -367,7 +368,7 @@ public class HudUi {
ttt.top().right(); ttt.top().right();
Image image = new Image(Icon.warning.getRegion()).setScaling(Scaling.fit); Image image = new Image(Icon.warning.getRegion()).setScaling(Scaling.fit);
image.update(() -> image.setColor(Tmp.c2.set(Color.orange).lerp(Color.scarlet, Mathf.absin(Time.time, 2f, 1f)))); image.update(() -> image.setColor(Tmp.c2.set(Color.orange).lerp(Color.scarlet, Mathf.absin(Time.time, 2f, 1f))));
ttt.add(image).size(scaledScale * 12f); ttt.add(image).size(modUiScale * 12f);
ttt.pack(); ttt.pack();
})); }));
}}).pad(6); }}).pad(6);
@@ -448,7 +449,7 @@ public class HudUi {
fontColor = Color.white; fontColor = Color.white;
background = Styles.black8; background = Styles.black8;
}}); }});
label.setFontScale(scaledScale); label.setFontScale(modUiScale);
Table labelTable = new Table(t -> t.add(label).left().padRight(Scl.scl(modUiScale) * 40 * 8f)); Table labelTable = new Table(t -> t.add(label).left().padRight(Scl.scl(modUiScale) * 40 * 8f));
table.table(t -> { table.table(t -> {
@@ -457,7 +458,7 @@ public class HudUi {
Seq<TextureRegionDrawable> icons = Seq.with(Icon.units, Icon.fileText, Icon.copy, Icon.cancel); Seq<TextureRegionDrawable> icons = Seq.with(Icon.units, Icon.fileText, Icon.copy, Icon.cancel);
for(int i = 0; i < buttons.size; i++){ for(int i = 0; i < buttons.size; i++){
int finalI = i; int finalI = i;
buttons.set(i, t.button(icons.get(i), Styles.clearToggleTransi, () -> buttons.set(i, t.button(new ScaledNinePatchDrawable(new NinePatch(icons.get(i).getRegion()), modUiScale), Styles.clearToggleTransi, () ->
reset(finalI, buttons, label, table, labelTable, strs.get(finalI))).size(Scl.scl(modUiScale) * 5 * 8f).get()); reset(finalI, buttons, label, table, labelTable, strs.get(finalI))).size(Scl.scl(modUiScale) * 5 * 8f).get());
t.row(); t.row();
} }
@@ -747,7 +748,7 @@ public class HudUi {
public void addUnitTable(){ public void addUnitTable(){
if(uiIndex != 0) return; if(uiIndex != 0) return;
unitTable = new Table(table -> { unitTable = new Table(table -> {
table.left().defaults().width(scaledScale * 27 * 8f).maxHeight(scaledScale * 35 * 8f); table.left().defaults().width(modUiScale * 27 * 8f).maxHeight(modUiScale * 35 * 8f);
addBars(); addBars();
Table table1 = new Table(Tex.button, t -> { Table table1 = new Table(Tex.button, t -> {
t.left(); t.left();
@@ -793,7 +794,7 @@ public class HudUi {
} }
return "[accent]" + (name.length() > 9 ? name.substring(0, 9) + "..." : name) + "[]"; return "[accent]" + (name.length() > 9 ? name.substring(0, 9) + "..." : name) + "[]";
}); });
label.setFontScale(scaledScale); label.setFontScale(modUiScale);
TextButton button = Elem.newButton("?", Styles.clearPartialt, () -> { TextButton button = Elem.newButton("?", Styles.clearPartialt, () -> {
if(getTarget() instanceof Unit u && u.type != null) if(getTarget() instanceof Unit u && u.type != null)
@@ -835,12 +836,12 @@ public class HudUi {
else if(getTarget() instanceof Building b) return b.block.localizedName; else if(getTarget() instanceof Building b) return b.block.localizedName;
return ""; return "";
}); });
label2.setFontScale(scaledScale); label2.setFontScale(modUiScale);
tool2.add(label2); tool2.add(label2);
}); });
to.row(); to.row();
Label label2 = new Label(()->getTarget() == null ? "(" + 0 + ", " + 0 + ")" : "(" + Strings.fixed(getTarget().x() / tilesize, 2) + ", " + Strings.fixed(getTarget().y() / tilesize, 2) + ")"); Label label2 = new Label(()->getTarget() == null ? "(" + 0 + ", " + 0 + ")" : "(" + Strings.fixed(getTarget().x() / tilesize, 2) + ", " + Strings.fixed(getTarget().y() / tilesize, 2) + ")");
label2.setFontScale(scaledScale); label2.setFontScale(modUiScale);
to.add(label2); to.add(label2);
}))); })));
tt.update(()->tt.setBackground(((NinePatchDrawable)Tex.underline2).tint(getTarget().isNull() ? Color.gray : getTarget().team().color))); tt.update(()->tt.setBackground(((NinePatchDrawable)Tex.underline2).tint(getTarget().isNull() ? Color.gray : getTarget().team().color)));
@@ -897,7 +898,7 @@ public class HudUi {
table.table(t -> { table.table(t -> {
table.center(); table.center();
Label label = new Label(() -> "[#" + (state.wave == j+1 ? Color.red.toString() : Pal.accent.toString()) + "]" + (j+1) + "[]"); Label label = new Label(() -> "[#" + (state.wave == j+1 ? Color.red.toString() : Pal.accent.toString()) + "]" + (j+1) + "[]");
label.setFontScale(scaledScale); label.setFontScale(modUiScale);
t.add(label); t.add(label);
}).size(Scl.scl(modUiScale) * 4 * 8f); }).size(Scl.scl(modUiScale) * 4 * 8f);
@@ -934,14 +935,14 @@ public class HudUi {
tt.stack( tt.stack(
new Table(ttt -> { new Table(ttt -> {
ttt.center(); ttt.center();
ttt.add(image).size(iconMed * scaledScale); ttt.add(image).size(iconMed * modUiScale);
ttt.pack(); ttt.pack();
}), }),
new Table(ttt -> { new Table(ttt -> {
ttt.bottom().left(); ttt.bottom().left();
Label label = new Label(() -> amount + ""); Label label = new Label(() -> amount + "");
label.setFontScale(scaledScale * 0.85f); label.setFontScale(modUiScale * 0.85f);
ttt.add(label); ttt.add(label);
ttt.pack(); ttt.pack();
}), }),
@@ -950,7 +951,7 @@ public class HudUi {
ttt.top().right(); ttt.top().right();
Image image1 = new Image(Icon.warning.getRegion()).setScaling(Scaling.fit); Image image1 = new Image(Icon.warning.getRegion()).setScaling(Scaling.fit);
image1.update(() -> image1.setColor(Tmp.c2.set(Color.orange).lerp(Color.scarlet, Mathf.absin(Time.time, 2f, 1f)))); image1.update(() -> image1.setColor(Tmp.c2.set(Color.orange).lerp(Color.scarlet, Mathf.absin(Time.time, 2f, 1f))));
ttt.add(image1).size(scaledScale * 12f); ttt.add(image1).size(modUiScale * 12f);
ttt.visible(() -> group.effect == StatusEffects.boss); ttt.visible(() -> group.effect == StatusEffects.boss);
ttt.pack(); ttt.pack();
}) })
@@ -1021,7 +1022,10 @@ public class HudUi {
public void addWaveTable(){ public void addWaveTable(){
if(uiIndex != 1) return; if(uiIndex != 1) return;
ScrollPane wavePane = new ScrollPane(new Image(clear).setScaling(Scaling.fit), Styles.smallPane); ScrollPane wavePane = new ScrollPane(new Image(clear).setScaling(Scaling.fit), new ScrollPane.ScrollPaneStyle(){{
vScroll = Tex.clear;
vScrollKnob = new ScaledNinePatchDrawable(new NinePatch(((TextureRegionDrawable) scrollKnobVerticalThin).getRegion()), modUiScale);
}});
wavePane.setScrollingDisabled(true, false); wavePane.setScrollingDisabled(true, false);
wavePane.setScrollYForce(waveScrollPos); wavePane.setScrollYForce(waveScrollPos);
wavePane.update(() -> { wavePane.update(() -> {
@@ -1039,14 +1043,14 @@ public class HudUi {
wavePane.setWidget(new Table(tx -> tx.table(this::setWave).left())); wavePane.setWidget(new Table(tx -> tx.table(this::setWave).left()));
waveTable = new Table(table -> { waveTable = new Table(table -> {
table.left().defaults().width(scaledScale * 32 * 8f).maxHeight(scaledScale * 32 * 8f).align(Align.left); table.left().defaults().width(modUiScale * 32 * 8f).maxHeight(modUiScale * 32 * 8f).align(Align.left);
table.add(new Table(Tex.button, t -> { table.add(new Table(Tex.button, t -> {
t.add(wavePane); t.add(wavePane);
t.update(() -> { t.update(() -> {
NinePatchDrawable patch = (NinePatchDrawable)Tex.button; NinePatchDrawable patch = (NinePatchDrawable)Tex.button;
t.setBackground(patch.tint(Tmp.c1.set(patch.getPatch().getColor()).a(settings.getInt("uiopacity") / 100f))); t.setBackground(patch.tint(Tmp.c1.set(patch.getPatch().getColor()).a(settings.getInt("uiopacity") / 100f)));
}); });
})).padRight(scaledScale * 39 * 8f); })).padRight(modUiScale * 39 * 8f);
table.fillParent = true; table.fillParent = true;
table.visibility = () -> uiIndex == 1; table.visibility = () -> uiIndex == 1;
@@ -1060,10 +1064,10 @@ public class HudUi {
if((state.rules.pvp && coreItems.teams[i] != player.team()) || coreItems.teams[i].cores().isEmpty()) continue; if((state.rules.pvp && coreItems.teams[i] != player.team()) || coreItems.teams[i].cores().isEmpty()) continue;
int finalI = i; int finalI = i;
Label label = new Label(() -> "[#" + coreItems.teams[finalI].color.toString() + "]" + coreItems.teams[finalI].name + "[]"); Label label = new Label(() -> "[#" + coreItems.teams[finalI].color.toString() + "]" + coreItems.teams[finalI].name + "[]");
label.setFontScale(scaledScale); label.setFontScale(modUiScale);
t.background(Tex.underline2).add(label).center(); t.background(Tex.underline2).add(label).center();
t.row(); t.row();
t.add(coreItems.tables.get(finalI)).left(); t.add(coreItems.tables.get(i)).left();
t.row(); t.row();
} }
}); });
@@ -1071,7 +1075,10 @@ public class HudUi {
public void addItemTable(){ public void addItemTable(){
if(uiIndex != 2) return; if(uiIndex != 2) return;
ScrollPane itemPane = new ScrollPane(new Table(this::setItem).left(), Styles.smallPane); ScrollPane itemPane = new ScrollPane(new Table(this::setItem).left(), new ScrollPane.ScrollPaneStyle(){{
vScroll = Tex.clear;
vScrollKnob = new ScaledNinePatchDrawable(new NinePatch(((TextureRegionDrawable) scrollKnobVerticalThin).getRegion()), modUiScale);
}});
itemPane.setScrollingDisabled(true, false); itemPane.setScrollingDisabled(true, false);
itemPane.setScrollYForce(itemScrollPos); itemPane.setScrollYForce(itemScrollPos);
itemPane.setOverscroll(false, false); itemPane.setOverscroll(false, false);
@@ -1086,14 +1093,14 @@ public class HudUi {
}); });
itemTable = new Table(table -> { itemTable = new Table(table -> {
table.left().defaults().width(scaledScale * 50 * 8f).height(scaledScale * 32 * 8f).align(Align.left); table.left().defaults().width(modUiScale * 54 * 8f).height(modUiScale * 32 * 8f).align(Align.left);
table.table(Tex.button, t -> { table.table(Tex.button, t -> {
t.add(itemPane); t.add(itemPane);
t.update(() -> { t.update(() -> {
NinePatchDrawable patch = (NinePatchDrawable)Tex.button; NinePatchDrawable patch = (NinePatchDrawable)Tex.button;
t.setBackground(patch.tint(Tmp.c1.set(patch.getPatch().getColor()).a(settings.getInt("uiopacity") / 100f))); t.setBackground(patch.tint(Tmp.c1.set(patch.getPatch().getColor()).a(settings.getInt("uiopacity") / 100f)));
}); });
}).padRight(scaledScale * 39 * 8f); }).padRight(modUiScale * 39 * 8f);
table.fillParent = true; table.fillParent = true;
table.visibility = () -> uiIndex == 2; table.visibility = () -> uiIndex == 2;

View File

@@ -78,7 +78,6 @@ public class CoresItemsDisplay {
public Table setTable(Team team){ public Table setTable(Team team){
return new Table(t -> { return new Table(t -> {
t.clear(); t.clear();
t.background(Styles.black6).margin(2).defaults().width(scaledScale * 48 * 8f);
t.update(() -> { t.update(() -> {
core = team.core(); core = team.core();
@@ -117,7 +116,7 @@ public class CoresItemsDisplay {
if (modUiScale < 1) label.setFontScale(Scl.scl(modUiScale)); if (modUiScale < 1) label.setFontScale(Scl.scl(modUiScale));
tttt.background(Tex.button).add(label); tttt.background(Tex.button).add(label);
})); }));
s.add(image).size(iconLarge * scaledScale); s.add(image).size(iconLarge * modUiScale);
}), }),
new Table(h -> { new Table(h -> {
h.bottom().defaults().height(Scl.scl(modUiScale) * 9f).width(Scl.scl(modUiScale) * iconLarge * 1.5f).growX(); h.bottom().defaults().height(Scl.scl(modUiScale) * 9f).width(Scl.scl(modUiScale) * iconLarge * 1.5f).growX();
@@ -127,9 +126,9 @@ public class CoresItemsDisplay {
); );
tt.row(); tt.row();
Label label = new Label(() -> "(" + (int) core.x / 8 + ", " + (int) core.y / 8 + ")"); Label label = new Label(() -> "(" + (int) core.x / 8 + ", " + (int) core.y / 8 + ")");
label.setFontScale(scaledScale * 0.75f); label.setFontScale(modUiScale * 0.75f);
tt.add(label); tt.add(label);
}).padTop(scaledScale * 2).padLeft(scaledScale * 4).padRight(scaledScale * 4); }).padTop(modUiScale * 2).padLeft(modUiScale * 4).padRight(modUiScale * 4);
if(++i[0] % 5 == 0) coretable.row(); if(++i[0] % 5 == 0) coretable.row();
} }
}); });
@@ -138,30 +137,27 @@ public class CoresItemsDisplay {
itemTable.clear(); itemTable.clear();
final int[] i = {0}; final int[] i = {0};
for(Item item : content.items()){ for(Item item : content.items()){
itemTable.table(tt -> { if(team.core() != null && team.core().items.has(item)) {
tt.center(); itemTable.stack(
if(team.core() != null && team.core().items.has(item)) { new Table(ttt -> {
tt.stack( ttt.image(item.uiIcon).size(iconSmall * modUiScale).tooltip(tttt -> tttt.background(Styles.black6).margin(2f * modUiScale).add(item.localizedName).style(Styles.outlineLabel));
new Table(ttt -> { Label label = new Label(() -> core == null ? "0" : UI.formatAmount(core.items.get(item)));
ttt.image(item.uiIcon).size(iconSmall * scaledScale).tooltip(tttt -> tttt.background(Styles.black6).margin(2f * scaledScale).add(item.localizedName).style(Styles.outlineLabel)); label.setFontScale(modUiScale);
Label label = new Label(() -> core == null ? "0" : UI.formatAmount(core.items.get(item))); ttt.add(label).minWidth(5 * 8f * modUiScale).left();
label.setFontScale(scaledScale); }),
ttt.add(label).minWidth(5 * 8f * scaledScale).left(); new Table(ttt -> {
}), ttt.bottom().right();
new Table(ttt -> { Label label = new Label(() -> {
ttt.bottom().right(); int amount = updateItems.get(team).get(item.id).amount;
Label label = new Label(() -> { return (amount > 0 ? "[green]+" : amount == 0 ? "[orange]" : "[red]") + amount + "[]";
int amount = updateItems.get(team).get(item.id).amount; });
return (amount > 0 ? "[green]+" : amount == 0 ? "[orange]" : "[red]") + amount + "[]"; label.setFontScale(0.65f * modUiScale);
}); ttt.add(label).bottom().right().padTop(16f * modUiScale);
label.setFontScale(0.65f * scaledScale); ttt.pack();
ttt.add(label).bottom().right().padTop(16f * scaledScale); })
ttt.pack(); ).padRight(3 * modUiScale).left();
}) if(++i[0] % 5 == 0) itemTable.row();
).padRight(3 * scaledScale).left(); }
if(++i[0] % 5 == 0) itemTable.row();
};
});
} }
}); });
t.row(); t.row();
@@ -172,10 +168,10 @@ public class CoresItemsDisplay {
unitTable.table(tt -> { unitTable.table(tt -> {
tt.center(); tt.center();
if(unit != UnitTypes.block && Groups.unit.contains(u -> u.type == unit && u.team == team)){ if(unit != UnitTypes.block && Groups.unit.contains(u -> u.type == unit && u.team == team)){
tt.image(unit.uiIcon).size(iconSmall * scaledScale).padRight(3 * scaledScale).tooltip(ttt -> ttt.background(Styles.black6).margin(2f * scaledScale).add(unit.localizedName).style(Styles.outlineLabel)); tt.image(unit.uiIcon).size(iconSmall * modUiScale).padRight(3 * modUiScale).tooltip(ttt -> ttt.background(Styles.black6).margin(2f * modUiScale).add(unit.localizedName).style(Styles.outlineLabel));
Label label = new Label(() -> core == null ? "0" : UI.formatAmount(Groups.unit.count(u -> u.team == team && u.type == unit))); Label label = new Label(() -> core == null ? "0" : UI.formatAmount(Groups.unit.count(u -> u.team == team && u.type == unit)));
label.setFontScale(scaledScale); label.setFontScale(modUiScale);
tt.add(label).padRight(3 * scaledScale).minWidth(5 * 8f * scaledScale).left(); tt.add(label).padRight(3 * modUiScale).minWidth(5 * 8f * modUiScale).left();
if(++i[0] % 5 == 0) unitTable.row(); if(++i[0] % 5 == 0) unitTable.row();
} }
}); });