This commit is contained in:
sharlotte
2021-08-25 16:08:06 +09:00
parent 02573f677c
commit 24cd31776f
2 changed files with 53 additions and 79 deletions

View File

@@ -59,7 +59,6 @@ public class HudUi {
Table baseTable = new Table(); Table baseTable = new Table();
Table unitTable = new Table(); Table unitTable = new Table();
Table waveTable = new Table(); Table waveTable = new Table();
Table coreTable = new Table();
Table itemTable = new Table(); Table itemTable = new Table();
Table waveInfoTable = new Table(); Table waveInfoTable = new Table();
float waveScrollPos; float waveScrollPos;
@@ -357,7 +356,7 @@ public class HudUi {
addItemTable(); addItemTable();
table.removeChild(baseTable); table.removeChild(baseTable);
labelTable.setPosition(buttons.items[uiIndex].x, buttons.items[uiIndex].y); labelTable.setPosition(buttons.items[uiIndex].x, buttons.items[uiIndex].y);
baseTable = table.table(tt -> tt.stack(unitTable, coreTable, waveTable, itemTable, labelTable).align(Align.left).left().visible(() -> settings.getBool("infoui"))).get(); baseTable = table.table(tt -> tt.stack(unitTable, waveTable, itemTable, labelTable).align(Align.left).left().visible(() -> settings.getBool("infoui"))).get();
a = 1f; a = 1f;
} }
@@ -512,7 +511,7 @@ public class HudUi {
t.row(); t.row();
} }
}); });
baseTable = table.table(tt -> tt.stack(unitTable, coreTable, waveTable, itemTable, labelTable).align(Align.left).left().visible(() -> settings.getBool("infoui"))).get(); baseTable = table.table(tt -> tt.stack(unitTable, waveTable, itemTable, labelTable).align(Align.left).left().visible(() -> settings.getBool("infoui"))).get();
table.fillParent = true; table.fillParent = true;
table.visibility = () -> ui.hudfrag.shown && !ui.minimapfrag.shown(); table.visibility = () -> ui.hudfrag.shown && !ui.minimapfrag.shown();
@@ -638,77 +637,59 @@ public class HudUi {
} }
public void addBars(){ public void addBars(){
bars.clear(); bars.clear();
for(int i = 0; i < 6; i++) bars.add(addBar(i));
bars.add(addBar(0));
bars.add(addBar(1));
bars.add(addBar(2));
bars.add(addBar(3));
bars.add(addBar(4));
bars.add(addBar(5));
} }
public void addWeaponTable(Table table){ public void addWeaponTable(Table table){
table.table().update(t -> { table.table().update(tt -> {
if(!Core.settings.getBool("infoui")) return; tt.clear();
t.clear(); if(getTarget() instanceof Unit u && u.type != null) {
t.add(new Table(((NinePatchDrawable)Tex.button).tint(Tmp.c1.set(((NinePatchDrawable)Tex.button).getPatch().getColor()).a(settings.getInt("uiopacity") / 100f)), tt -> { for(int r = 0; r < u.type.weapons.size; r++){
tt.defaults().width(Scl.scl(modUiScale) * 8 * 8f).minHeight(Scl.scl(modUiScale) * 4 * 8f).align(Align.left); Weapon weapon = u.type.weapons.get(r);
tt.visibility = () -> getTarget() instanceof Unit u && u.type != null && u.type.weapons.size > 0; WeaponMount mount = u.mounts[r];
if(getTarget() instanceof Unit u && u.type != null) { int finalR = r;
UnitType type = u.type; tt.table(ttt -> {
for(int r = 0; r < type.weapons.size; r++){ ttt.left();
Weapon weapon = type.weapons.get(r); if((1 + finalR) % 4 == 0) ttt.row();
WeaponMount mount = u.mounts[r]; ttt.stack(
TextureRegion region = !weapon.name.equals("") && weapon.outlineRegion.found() ? weapon.outlineRegion : type.uiIcon; new Table(o -> {
int finalR = r; o.left();
tt.table(ttt -> { o.add(new Image(!weapon.name.equals("") && weapon.outlineRegion.found() ? weapon.outlineRegion : u.type.uiIcon){
if(type.weapons.size > 1 && finalR % 3 == 0) tt.row(); @Override
else if(finalR % 3 == 0) tt.row(); public void draw(){
ttt.stack( validate();
new Table(o -> { float x = this.x;
o.left(); float y = this.y;
o.add(new Image(region){ float scaleX = this.scaleX;
@Override float scaleY = this.scaleY;
public void draw(){ Draw.color(color);
validate(); Draw.alpha(parentAlpha * color.a);
float x = this.x;
float y = this.y;
float scaleX = this.scaleX;
float scaleY = this.scaleY;
Draw.color(color);
Draw.alpha(parentAlpha * color.a);
if(getDrawable() instanceof TransformDrawable){ if(getDrawable() instanceof TransformDrawable){
float rotation = getRotation(); float rotation = getRotation();
if(scaleX != 1 || scaleY != 1 || rotation != 0){ if(scaleX != 1 || scaleY != 1 || rotation != 0){
getDrawable().draw(x + imageX, y + imageY, getDrawable().draw(x + imageX, y + imageY, originX - imageX, originY - imageY, imageWidth, imageHeight, scaleX, scaleY, rotation);
originX - imageX, originY - imageY, return;
imageWidth, imageHeight,
scaleX, scaleY, rotation);
return;
}
} }
float recoil = -((mount.reload) / weapon.reload * weapon.recoil);
y += recoil;
if(getDrawable() != null)
getDrawable().draw(x + imageX, y + imageY, imageWidth * scaleX, imageHeight * scaleY);
} }
}).scaling(Scaling.fill).size(Scl.scl(modUiScale) * iconLarge); y -= (mount.reload) / weapon.reload * weapon.recoil;
}) if(getDrawable() != null)
, new Table(h -> { getDrawable().draw(x + imageX, y + imageY, imageWidth * scaleX, imageHeight * scaleY);
h.defaults().growX().height(Scl.scl(modUiScale) * 9f).width(Scl.scl(modUiScale) * iconLarge).padTop(Scl.scl(modUiScale) * 18f); }
h.add(new SBar( }).size(Scl.scl(modUiScale) * iconLarge);
() -> "", }),
() -> Pal.accent.cpy().lerp(Color.orange, mount.reload / weapon.reload), new Table(h -> {
() -> mount.reload / weapon.reload).rect().init()); h.defaults().growX().height(Scl.scl(modUiScale) * 9f).width(Scl.scl(modUiScale) * iconLarge).padTop(Scl.scl(modUiScale) * 18f);
h.pack(); h.add(new SBar(
}) () -> "",
); () -> Pal.accent.cpy().lerp(Color.orange, mount.reload / weapon.reload),
}); () -> mount.reload / weapon.reload).rect().init());
} h.pack();
})
);
}).pad(4);
} }
})); }
}); });
} }
@@ -774,7 +755,6 @@ public class HudUi {
table.left().defaults().width(Scl.scl(modUiScale) * 27 * 8f).maxHeight(Scl.scl(modUiScale) * 35 * 8f); table.left().defaults().width(Scl.scl(modUiScale) * 27 * 8f).maxHeight(Scl.scl(modUiScale) * 35 * 8f);
addBars(); addBars();
Table table1 = new Table(Tex.button, t -> { Table table1 = new Table(Tex.button, t -> {
t.left();
t.table(Tex.underline2, tt -> { t.table(Tex.underline2, tt -> {
Stack stack = new Stack(){{ Stack stack = new Stack(){{
add(new Table(ttt -> { add(new Table(ttt -> {
@@ -847,8 +827,7 @@ public class HudUi {
tt.clicked(()->{ tt.clicked(()->{
if(getTarget() == null) return; if(getTarget() == null) return;
if(control.input instanceof DesktopInput) if(control.input instanceof DesktopInput d) d.panning = true;
((DesktopInput) control.input).panning = true;
Core.camera.position.set(getTarget().x(), getTarget().y()); Core.camera.position.set(getTarget().x(), getTarget().y());
}); });
tt.addListener(new Tooltip(tool -> tool.background(Tex.button).table(to -> { tt.addListener(new Tooltip(tool -> tool.background(Tex.button).table(to -> {
@@ -883,16 +862,15 @@ public class HudUi {
tt.row(); tt.row();
} }
}); });
t.setColor(t.color.cpy().a(1f)); t.row();
t.background(Tex.button); addWeaponTable(t);
t.update(() -> { t.update(() -> {
if(!Core.settings.getBool("infoui")) return; if(!Core.settings.getBool("infoui")) return;
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)));
}); });
}); });
table.table(t -> t.stack(table1, addInfoTable(t))).row(); table.table(t -> t.stack(table1, addInfoTable(t))).padLeft(3.5f * 8f);
table.table(this::addWeaponTable);
table.update(() -> { table.update(() -> {
if(!Core.settings.getBool("infoui")) return; if(!Core.settings.getBool("infoui")) return;
@@ -906,7 +884,6 @@ public class HudUi {
colors = BarInfo.colors; colors = BarInfo.colors;
}); });
table.fillParent = true;
table.visibility = () -> uiIndex == 0; table.visibility = () -> uiIndex == 0;
}); });
} }
@@ -1096,7 +1073,6 @@ public class HudUi {
public void setItem(Table table){ public void setItem(Table table){
table.table().update(t -> { table.table().update(t -> {
if(!Core.settings.getBool("infoui")) return;
t.clear(); t.clear();
for(int i = 0; i < coreItems.tables.size; i++){ for(int i = 0; i < coreItems.tables.size; i++){
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;
@@ -1121,7 +1097,6 @@ public class HudUi {
itemPane.setScrollYForce(itemScrollPos); itemPane.setScrollYForce(itemScrollPos);
itemPane.setOverscroll(false, false); itemPane.setOverscroll(false, false);
itemPane.update(() -> { itemPane.update(() -> {
if(!Core.settings.getBool("infoui")) return;
if(itemPane.hasScroll()){ if(itemPane.hasScroll()){
Element result = scene.hit(input.mouseX(), input.mouseY(), true); Element result = scene.hit(input.mouseX(), input.mouseY(), true);
if(result == null || !result.isDescendantOf(itemPane)){ if(result == null || !result.isDescendantOf(itemPane)){
@@ -1136,7 +1111,6 @@ public class HudUi {
table.table(Tex.button, t -> { table.table(Tex.button, t -> {
t.add(itemPane); t.add(itemPane);
t.update(() -> { t.update(() -> {
if(!Core.settings.getBool("infoui")) return;
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)));
}); });

View File

@@ -47,7 +47,7 @@ public class CoresItemsDisplay {
updateItems.clear(); updateItems.clear();
prevItems.clear(); prevItems.clear();
coreAmount.clear(); coreAmount.clear();
teams = new Seq<Team>(Team.all).filter(t -> !t.cores().isEmpty()).toArray(); teams = new Seq<Team>(Team.all).addAll(Team.baseTeams).filter(t -> t.cores().any()).toArray();
for(Team team : teams) { for(Team team : teams) {
usedItems.put(team, new ObjectSet<>()); usedItems.put(team, new ObjectSet<>());
usedUnits.put(team, new ObjectSet<>()); usedUnits.put(team, new ObjectSet<>());