This commit is contained in:
sharlotte
2021-08-08 15:23:12 +09:00
parent 06f020ceb9
commit 16a4a699ca
8 changed files with 122 additions and 81 deletions

View File

@@ -37,6 +37,7 @@ import mindustry.world.blocks.power.PowerNode;
import mindustry.world.blocks.storage.*;
import static UnitInfo.SVars.clear;
import static UnitInfo.SVars.modUiScale;
import static arc.Core.*;
import static mindustry.Vars.*;
@@ -271,6 +272,11 @@ public class HudUi {
});
Events.run(EventType.Trigger.update, ()->{
if(modUiScale != settings.getInt("infoUiScale") / 100f && settings.getInt("infoUiScale") / 100f != 0){
modUiScale = settings.getInt("infoUiScale") / 100f;
mainTable.clearChildren();
addTable();
}
if((input.keyDown(KeyCode.shiftRight) || input.keyDown(KeyCode.shiftLeft))){
if(input.keyTap(KeyCode.r)) lockButton.change();
}
@@ -365,8 +371,8 @@ public class HudUi {
fontColor = Color.white;
background = Styles.black8;
}});
Table labelTable = new Table(t -> t.add(label).scaling(Scaling.fit).left().padRight(40 * 8f));
if(modUiScale < 1) label.setFontScale(Scl.scl(modUiScale));
Table labelTable = new Table(t -> t.add(label).left().padRight(Scl.scl(modUiScale) * 40 * 8f));
table.table(t -> {
Seq<Button> buttons = Seq.with(null, null, null, null, null, null);
@@ -375,17 +381,14 @@ public class HudUi {
for(int i = 0; i < buttons.size; i++){
int finalI = i;
buttons.set(i, t.button(icons.get(i), Styles.clearToggleTransi, () ->
reset(finalI, buttons, label, table, labelTable, strs.get(finalI))).size(5*8f).get());
reset(finalI, buttons, label, table, labelTable, strs.get(finalI))).size(Scl.scl(modUiScale) * 5 * 8f).get());
t.row();
}
});
baseTable = table.table(tt -> tt.stack(unitTable, coreTable, waveTable, tileTable, itemTable, labelTable).align(Align.left).left().visible(() -> settings.getBool("infoui"))).get();
table.fillParent = true;
table.visibility = () -> (ui.hudfrag.shown && !ui.minimapfrag.shown()
&& (!Vars.mobile ||
!(Vars.control.input.block != null || !Vars.control.input.selectRequests.isEmpty()
&& !(Vars.control.input.lastSchematic != null && !Vars.control.input.selectRequests.isEmpty()))));
table.visibility = () -> ui.hudfrag.shown && !ui.minimapfrag.shown();
});
ui.hudGroup.addChild(mainTable);
}
@@ -417,7 +420,7 @@ public class HudUi {
}
bars.add(new Stack(){{
add(new Table(t -> {
t.top().defaults().width(Scl.scl(23 * 8f)).height(Scl.scl(4f * 8f));
t.top().defaults().width(Scl.scl(modUiScale) * 23 * 8f).height(Scl.scl(modUiScale) * 4f * 8f);
int i = 2;
t.add(new SBar(
() -> BarInfo.strings.get(i),
@@ -458,7 +461,7 @@ public class HudUi {
float v = entity.power.status * entity.power.graph.getLastScaledPowerIn();
super.draw();
Lines.stroke(Scl.scl(2f), Pal.removeBack);
Lines.stroke(2f, Pal.removeBack);
Draw.alpha(1 - v/max);
Lines.line(x, y - 2f + height, x + width, y - 2f);
Draw.color(Pal.remove);
@@ -469,7 +472,7 @@ public class HudUi {
};
}
clearChildren();
add(image).size(iconSmall).padBottom(2 * 8f).padRight(3 * 8f);
add(image).size(iconSmall * Scl.scl(modUiScale)).padBottom(2 * 8f).padRight(3 * 8f);
});
pack();
}});
@@ -482,7 +485,7 @@ public class HudUi {
else setDrawable(clear);
});
visibility = () -> getTarget() instanceof Unit;
}}.setScaling(Scaling.fit)).size(Scl.scl(30f)).padBottom(Scl.scl(4 * 8f)).padRight(Scl.scl(6 * 8f));
}}.setScaling(Scaling.fit)).size(Scl.scl(modUiScale) * 30f).padBottom(Scl.scl(modUiScale) * 4 * 8f).padRight(Scl.scl(modUiScale) * 6 * 8f);
t.pack();
}));
}});
@@ -493,7 +496,7 @@ public class HudUi {
bars.add(new SBar(
() -> strings.get(i),
() -> {
if (colors.get(i) != Color.clear) lastColors.set(i, colors.get(i));
if(colors.get(i) != Color.clear) lastColors.set(i, colors.get(i));
return lastColors.get(i);
},
() -> numbers.get(i)
@@ -506,7 +509,7 @@ public class HudUi {
bars.add(new SBar(
() -> strings.get(i),
() -> {
if (colors.get(i) != Color.clear) lastColors.set(i, colors.get(i));
if(colors.get(i) != Color.clear) lastColors.set(i, colors.get(i));
return lastColors.get(i);
},
() -> numbers.get(i)
@@ -515,13 +518,13 @@ public class HudUi {
bars.add(new Stack(){{
add(new Table(t -> {
t.top().defaults().width(Scl.scl(23 * 8f)).height(Scl.scl(4f * 8f));
t.top().defaults().width(Scl.scl(modUiScale) * 23 * 8f).height(Scl.scl(modUiScale) * 4 * 8f);
int i = 5;
t.add(new SBar(
() -> strings.get(i),
() -> {
if (colors.get(i) != Color.clear) lastColors.set(i, colors.get(i));
if(colors.get(i) != Color.clear) lastColors.set(i, colors.get(i));
return lastColors.get(i);
},
() -> numbers.get(i)
@@ -540,7 +543,7 @@ public class HudUi {
}
setDrawable(region);
});
}}.setScaling(Scaling.fit)).size(Scl.scl(30f)).padBottom(Scl.scl(4 * 8f)).padRight(Scl.scl(6 * 8f));
}}.setScaling(Scaling.fit)).size(Scl.scl(modUiScale) * 30f).padBottom(Scl.scl(modUiScale) * 4 * 8f).padRight(Scl.scl(modUiScale) * 6 * 8f);
t.pack();
}));
}});
@@ -548,10 +551,10 @@ public class HudUi {
public void addWeapon(){
weapon = new Table(tx -> {
tx.left().defaults().minSize(Scl.scl(12 * 8f));
tx.left().defaults().minSize(Scl.scl(modUiScale) * 12 * 8f);
tx.add(new Table(Tex.button, tt -> {
tt.left().top().defaults().width(Scl.scl(24/3f * 8f)).minHeight(Scl.scl(12/3f * 8f));
tt.left().top().defaults().width(Scl.scl(modUiScale) * 8 * 8f).minHeight(Scl.scl(modUiScale) * 4 * 8f);
if(getTarget() instanceof Unit u && u.type != null) {
UnitType type = u.type;
@@ -593,15 +596,15 @@ public class HudUi {
if(getDrawable() != null)
getDrawable().draw(x + imageX, y + imageY, imageWidth * scaleX, imageHeight * scaleY);
}
}.setScaling(Scaling.fit)).size(Scl.scl(6 * 8f)).scaling(Scaling.fit);
}.setScaling(Scaling.fit)).size(Scl.scl(modUiScale) * 6 * 8f);
}));
add(new Table(h -> {
h.defaults().growX().height(Scl.scl(9)).width(Scl.scl(31.5f)).padTop(Scl.scl(9*2f));
h.defaults().growX().height(Scl.scl(modUiScale) * 9f).width(Scl.scl(modUiScale) * 31.5f).padTop(Scl.scl(modUiScale) * 18f);
h.add(new Bar(
() -> "",
() -> Pal.accent.cpy().lerp(Color.orange, mount.reload / weapon.reload),
() -> mount.reload / weapon.reload)).padLeft(Scl.scl(8f));
() -> mount.reload / weapon.reload)).padLeft(Scl.scl(modUiScale) * 8f);
h.pack();
}));
}}).left();
@@ -617,7 +620,7 @@ public class HudUi {
Draw.color(color.r, color.g, color.b, (settings.getInt("uiopacity") / 100f) * this.parentAlpha);
getBackground().draw(x, y, width, height);
}
}).padRight(Scl.scl(24 * 8f));
}).padRight(Scl.scl(modUiScale) * 24 * 8f);
tx.setColor(tx.color.cpy().a(1f));
});
}
@@ -628,21 +631,21 @@ public class HudUi {
table.left();
addBars();
table.add(new Table(Tex.button, t -> {
t.defaults().width(Scl.scl(25 * 8f)).scaling(Scaling.bounded);
t.defaults().width(Scl.scl(modUiScale) * 25 * 8f);
t.table(Tex.underline2, tt -> {
Stack stack = new Stack(){{
add(new Table(ttt -> ttt.add(new Image(){{
update(() -> {
TextureRegion region = clear;
if(getTarget() instanceof Unit && ((Unit) getTarget()).type() != null) region = ((Unit) getTarget()).type().uiIcon;
else if(getTarget() instanceof Building && ((Building) getTarget()).block != null) {
if(getTarget() instanceof ConstructBlock.ConstructBuild) region = ((ConstructBlock.ConstructBuild) getTarget()).current.uiIcon;
else region = ((Building) getTarget()).block.uiIcon;
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 ConstructBlock.ConstructBuild cb) region = cb.current.uiIcon;
else region = b.block.uiIcon;
}
setDrawable(region);
});
}}.setScaling(Scaling.fit)).size(Scl.scl(4f * 8f))));
}}.setScaling(Scaling.fit)).size(Scl.scl(modUiScale) * 4f * 8f)));
add(new Table(ttt -> {
ttt.add(new Stack(){{
add(new Table(temp -> temp.add(new Image(){{
@@ -651,14 +654,14 @@ public class HudUi {
add(new Table(temp -> {
if(getTarget() instanceof Unit) {
Label label = new Label(() -> (getTarget() instanceof Unit && ((Unit) getTarget()).type() != null ? (int) ((Unit) getTarget()).type().armor + "" : ""));
Label label = new Label(() -> (getTarget() instanceof Unit u && u.type != null ? (int) u.type.armor + "" : ""));
label.setColor(Pal.surge);
label.setFontScale(0.5f);
label.setFontScale(Scl.scl(modUiScale) * 0.5f);
temp.add(label).center();
}
temp.pack();
}));
}}).padLeft(Scl.scl(2 * 8f)).padBottom(Scl.scl(2 * 8f));
}}).padLeft(Scl.scl(modUiScale) * 2 * 8f).padBottom(Scl.scl(modUiScale) * 2 * 8f);
}));
}};
@@ -672,6 +675,7 @@ public class HudUi {
}
return name;
});
if(modUiScale < 1) label.setFontScale(Scl.scl(modUiScale));
TextButton button = Elem.newButton("?", Styles.clearPartialt, () -> {
if(getTarget() instanceof Unit && ((Unit) getTarget()).type() != null)
@@ -696,8 +700,8 @@ public class HudUi {
tt.top();
tt.add(stack);
tt.add(label);
tt.add(button).size(Scl.scl(5 * 8f));
tt.add(lockButton).size(Scl.scl(3 * 8f));
tt.add(button).size(Scl.scl(modUiScale) * 5 * 8f);
tt.add(lockButton).size(Scl.scl(modUiScale) * 3 * 8f);
tt.clicked(()->{
if(getTarget() == null) return;
@@ -707,7 +711,7 @@ public class HudUi {
});
tt.addListener(new Tooltip(tool -> tool.background(Tex.button).table(to -> {
to.table(Tex.underline2, tool2 -> {
tool2.label(()->{
Label label2 = new Label(()->{
if(getTarget() instanceof Unit u){
if(u.getPlayer() != null) return u.getPlayer().name;
else if(u.type != null) return u.type.localizedName;
@@ -716,17 +720,21 @@ public class HudUi {
return "";
});
if(modUiScale < 1) label2.setFontScale(Scl.scl(modUiScale));
tool2.add(label2);
});
to.row();
to.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) + ")");
if(modUiScale < 1) label2.setFontScale(Scl.scl(modUiScale));
to.add(label2);
})));
});
t.row();
t.table(tt -> {
tt.defaults().width(Scl.scl(23 * 8f)).height(Scl.scl(4f * 8f)).top();
tt.defaults().width(Scl.scl(modUiScale) * 23 * 8f).height(Scl.scl(modUiScale) * 4f * 8f).top();
for(Element bar : bars){
bar.setWidth(bar.getWidth());
bar.setHeight(bar.getHeight());
bar.setScale(Scl.scl(modUiScale));
tt.add(bar).growX().left();
tt.row();
}
@@ -740,7 +748,7 @@ public class HudUi {
Draw.color(color.r, color.g, color.b, (settings.getInt("uiopacity") / 100f) * this.parentAlpha);
getBackground().draw(x, y, width, height);
}
}).padRight(Scl.scl(24 * 8f));
}).padRight(Scl.scl(modUiScale) * 24 * 8f);
table.row();
table.update(() -> {
try {
@@ -779,9 +787,10 @@ public class HudUi {
table.center();
final int jj = j+1;
Label label = new Label(() -> "[#" + (state.wave == j+1 ? Color.red.toString() : Pal.accent.toString()) + "]" + jj + "[]");
if(modUiScale < 1) label.setFontScale(Scl.scl(modUiScale));
t.add(label);
}).size(Scl.scl(32f));
}).size(Scl.scl(modUiScale) * 4 * 8f);
table.table(Tex.underline, tx -> {
if(settings.getBool("emptywave") && state.rules.spawns.find(g -> g.getSpawned(j) > 0) == null) {
@@ -818,13 +827,14 @@ public class HudUi {
tt.add(new Stack(){{
add(new Table(ttt -> {
ttt.center();
ttt.add(image).size(iconLarge);
ttt.add(image).size(iconLarge * Scl.scl(modUiScale < 1 ? modUiScale : 1));
ttt.pack();
}));
add(new Table(ttt -> {
ttt.bottom().left();
Label label = new Label(() -> amount + "");
if(modUiScale < 1) label.setFontScale(Scl.scl(modUiScale));
ttt.add(label);
ttt.pack();
}));
@@ -833,11 +843,11 @@ public class HudUi {
ttt.top().right();
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))));
ttt.add(image).size(Scl.scl(12f));
ttt.add(image).size(Scl.scl(modUiScale < 1 ? modUiScale : 1) * 12f);
ttt.visible(() -> group.effect == StatusEffects.boss);
ttt.pack();
}));
}}).pad(2f);
}}).pad(2f * Scl.scl(modUiScale));
tt.clicked(() -> {
if(input.keyDown(KeyCode.shiftLeft) && Fonts.getUnicode(group.type.name) != 0){
app.setClipboardText((char)Fonts.getUnicode(group.type.name) + "");
@@ -868,14 +878,14 @@ public class HudUi {
to.table(tot -> {
tot.left();
tot.add(bundle.get("shar-stat.waveStatus"));
tot.add(finalStatus).size(8 * 3);
tot.add(finalStatus).size(Scl.scl(modUiScale) * 3 * 8f);
if(!mobile){
HandCursorListener listener = new HandCursorListener();
finalStatus.addListener(listener);
finalStatus.update(() -> finalStatus.color.lerp(!listener.isOver() ? Color.lightGray : Color.white, Mathf.clamp(0.4f * Time.delta)));
}
tot.add("[stat]" + group.effect.localizedName);
}).size(iconMed);
}).size(iconMed * Scl.scl(modUiScale));
to.row();
}
if(group.items != null) {
@@ -883,14 +893,14 @@ public class HudUi {
tot.left();
ItemStack stack = group.items;
tot.add(bundle.get("shar-stat.waveItem"));
tot.add(new ItemImage(stack)).size(8 * 3);
tot.add(new ItemImage(stack)).size(Scl.scl(modUiScale) * 3 * 8f);
if(!mobile){
HandCursorListener listener = new HandCursorListener();
tot.addListener(listener);
tot.update(() -> tot.color.lerp(!listener.isOver() ? Color.lightGray : Color.white, Mathf.clamp(0.4f * Time.delta)));
}
tot.add("[stat]" + stack.item.localizedName);
}).size(iconMed);
}).size(iconMed * Scl.scl(modUiScale));
to.row();
}
})));
@@ -922,8 +932,8 @@ public class HudUi {
wavePane.setWidget(new Table(tx -> tx.table(this::setWave).left()));
waveTable = new Table(table -> {
table.add(new Table(Tex.button, t -> {
t.defaults().minWidth(Scl.scl(25 * 8f)).scaling(Scaling.fit).left();
t.add(wavePane).maxHeight(Scl.scl(32 * 8f));
t.defaults().minWidth(Scl.scl(modUiScale) * 25 * 8f).left();
t.add(wavePane).maxHeight(Scl.scl(modUiScale) * 32 * 8f).align(Align.left);
}){
@Override
protected void drawBackground(float x, float y) {
@@ -932,7 +942,7 @@ public class HudUi {
getBackground().draw(x, y, width, height);
Draw.reset();
}
}).padRight(Scl.scl(39 * 8f));
}).padRight(Scl.scl(modUiScale) * 39 * 8f);
table.fillParent = true;
table.visibility = () -> uiIndex == 1;
@@ -950,7 +960,9 @@ public class HudUi {
int finalI = i;
t.table(Tex.underline2, head -> {
head.center();
head.label(() -> "[#" + coreItems.teams[finalI].color.toString() + "]" + coreItems.teams[finalI].name + "[]");
Label label = new Label(() -> "[#" + coreItems.teams[finalI].color.toString() + "]" + coreItems.teams[finalI].name + "[]");
if(modUiScale < 1) label.setFontScale(Scl.scl(modUiScale));
head.add(label);
});
t.row();
for(int r = 0; r < coreamount; r++) {
@@ -974,18 +986,25 @@ public class HudUi {
image.addListener(listener1);
image.update(() -> image.color.lerp(!listener1.isOver() ? Color.lightGray : Color.white, Mathf.clamp(0.4f * Time.delta)));
}
image.addListener(new Tooltip(t -> t.background(Tex.button).label(() -> "([#" + Tmp.c1.set(Color.green).lerp(Color.red, 1 - core.healthf()).toString() + "]" + Strings.fixed(core.health, 2) + "[]/" + Strings.fixed(core.block.health, 2) + ")")));
s.add(image).size(iconLarge).scaling(Scaling.fit);
image.addListener(new Tooltip(t -> {
Label label = new Label(() -> "([#" + Tmp.c1.set(Color.green).lerp(Color.red, 1 - core.healthf()).toString() + "]" + Strings.fixed(core.health, 2) + "[]/" + Strings.fixed(core.block.health, 2) + ")");
if(modUiScale < 1) label.setFontScale(Scl.scl(modUiScale));
t.background(Tex.button).add(label);
}));
s.add(image).size(iconLarge * Scl.scl(modUiScale < 1 ? modUiScale : 1));
}));
add(new Table(s -> {
s.bottom().defaults().growX().height(Scl.scl(9)).pad(4);
s.bottom().defaults().growX().height(Scl.scl(modUiScale) * 9f).pad(4 * Scl.scl(modUiScale));
s.add(new Bar(() -> "", () -> Pal.health, core::healthf));
s.pack();
}));
}});
tt.row();
tt.label(() -> "(" + (int) core.x / 8 + ", " + (int) core.y / 8 + ")");
Label label = new Label(() -> "(" + (int) core.x / 8 + ", " + (int) core.y / 8 + ")");
if(modUiScale < 1) label.setFontScale(Scl.scl(modUiScale));
tt.add(label);
});
}
t.row();
@@ -1012,8 +1031,8 @@ public class HudUi {
coreTable = new Table(table -> {
table.add(new Table(Tex.button, t -> {
t.defaults().minWidth(Scl.scl(25 * 8f)).scaling(Scaling.fit).left();
t.add(corePane).maxHeight(Scl.scl(32 * 8f));
t.defaults().minWidth(Scl.scl(modUiScale) * 25 * 8f).left();
t.add(corePane).maxHeight(Scl.scl(modUiScale) * 32 * 8f).align(Align.left);
}){
@Override
protected void drawBackground(float x, float y) {
@@ -1022,7 +1041,7 @@ public class HudUi {
getBackground().draw(x, y, width, height);
Draw.reset();
}
}).padRight(Scl.scl(39 * 8f));
}).padRight(Scl.scl(modUiScale) * 39 * 8f);
table.fillParent = true;
table.visibility = () -> uiIndex == 2;
@@ -1040,7 +1059,9 @@ public class HudUi {
if(tile.overlay().uiIcon != atlas.find("error")) image.image(tile.overlay().uiIcon);
if(tile.block().uiIcon != atlas.find("error")) image.image(tile.block().uiIcon);
});
head.label(() -> tile == null ? "(null, null)" : "(" + tile.x + ", " + tile.y + ")").center();
Label label = new Label(() -> tile == null ? "(null, null)" : "(" + tile.x + ", " + tile.y + ")");
if(modUiScale < 1) label.setFontScale(Scl.scl(modUiScale));
head.add(label).center();
});
});
}
@@ -1064,8 +1085,8 @@ public class HudUi {
tilePane.setOverscroll(false, false);
tileTable = new Table(table -> {
table.add(new Table(Tex.button, t -> {
t.defaults().minWidth(Scl.scl(25 * 8f)).scaling(Scaling.fit).left();
t.add(tilePane).maxHeight(Scl.scl(32 * 8f));
t.defaults().minWidth(Scl.scl(modUiScale) * 25 * 8f).left();
t.add(tilePane).maxHeight(Scl.scl(modUiScale) * 32 * 8f).align(Align.left);
}){
@Override
protected void drawBackground(float x, float y) {
@@ -1074,7 +1095,7 @@ public class HudUi {
getBackground().draw(x, y, width, height);
Draw.reset();
}
}).padRight(Scl.scl(39 * 8f));
}).padRight(Scl.scl(modUiScale) * 39 * 8f);
table.fillParent = true;
table.visibility = () -> uiIndex == 3;
@@ -1086,7 +1107,9 @@ public class HudUi {
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;
t.background(Tex.underline2).label(() -> "[#" + coreItems.teams[finalI].color.toString() + "]" + coreItems.teams[finalI].name + "[]").center();
Label label = new Label(() -> "[#" + coreItems.teams[finalI].color.toString() + "]" + coreItems.teams[finalI].name + "[]");
if(modUiScale < 1) label.setFontScale(Scl.scl(modUiScale));
t.background(Tex.underline2).add(label).center();
t.row();
t.add(coreItems.tables.get(finalI)).left();
t.row();
@@ -1113,8 +1136,8 @@ public class HudUi {
tilePane.setOverscroll(false, false);
itemTable = new Table(table -> {
table.add(new Table(Tex.button, t -> {
t.defaults().minWidth(Scl.scl(25 * 8f)).scaling(Scaling.fit).left();
t.add(tilePane).maxHeight(Scl.scl(32 * 8f));
t.defaults().minWidth(Scl.scl(modUiScale) * 25 * 8f).left();
t.add(tilePane).maxHeight(Scl.scl(modUiScale) * 32 * 8f).align(Align.left);
}){
@Override
protected void drawBackground(float x, float y) {
@@ -1123,7 +1146,7 @@ public class HudUi {
getBackground().draw(x, y, width, height);
Draw.reset();
}
}).padRight(Scl.scl(39 * 8f));
}).padRight(Scl.scl(modUiScale) * 39 * 8f);
table.fillParent = true;
table.visibility = () -> uiIndex == 4;