mirror of
https://github.com/yawaflua/Informatis.git
synced 2025-12-10 12:09:27 +02:00
updated weapon table
This commit is contained in:
@@ -625,79 +625,73 @@ public class HudUi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void addWeapon(){
|
public void addWeapon(){
|
||||||
weapon = new Table(tx -> {
|
weapon = new Table(Tex.button, tt -> {
|
||||||
tx.left().defaults().minSize(Scl.scl(modUiScale) * 12 * 8f);
|
tt.left().defaults().minSize(Scl.scl(modUiScale) * 12 * 8f);
|
||||||
|
tt.defaults().width(Scl.scl(modUiScale) * 8 * 8f).minHeight(Scl.scl(modUiScale) * 4 * 8f);
|
||||||
|
|
||||||
tx.add(new Table(Tex.button, tt -> {
|
if(getTarget() instanceof Unit u && u.type != null) {
|
||||||
tt.left().top().defaults().width(Scl.scl(modUiScale) * 8 * 8f).minHeight(Scl.scl(modUiScale) * 4 * 8f);
|
UnitType type = u.type;
|
||||||
|
for(int r = 0; r < type.weapons.size; r++){
|
||||||
|
Weapon weapon = type.weapons.get(r);
|
||||||
|
WeaponMount mount = u.mounts[r];
|
||||||
|
TextureRegion region = !weapon.name.equals("") && weapon.outlineRegion.found() ? weapon.outlineRegion : type.uiIcon;
|
||||||
|
if(type.weapons.size > 1 && r % 3 == 0) tt.row();
|
||||||
|
else if(r % 3 == 0) tt.row();
|
||||||
|
tt.table(weapontable -> {
|
||||||
|
weapontable.add(new Stack(){{
|
||||||
|
add(new Table(o -> {
|
||||||
|
o.left();
|
||||||
|
o.add(new Image(region){
|
||||||
|
@Override
|
||||||
|
public void draw(){
|
||||||
|
validate();
|
||||||
|
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(getTarget() instanceof Unit u && u.type != null) {
|
if(getDrawable() instanceof TransformDrawable){
|
||||||
UnitType type = u.type;
|
float rotation = getRotation();
|
||||||
for(int r = 0; r < type.weapons.size; r++){
|
if(scaleX != 1 || scaleY != 1 || rotation != 0){
|
||||||
Weapon weapon = type.weapons.get(r);
|
getDrawable().draw(x + imageX, y + imageY,
|
||||||
WeaponMount mount = u.mounts[r];
|
originX - imageX, originY - imageY,
|
||||||
TextureRegion region = !weapon.name.equals("") && weapon.outlineRegion.found() ? weapon.outlineRegion : type.uiIcon;
|
imageWidth, imageHeight,
|
||||||
if(type.weapons.size > 1 && r % 3 == 0) tt.row();
|
scaleX, scaleY, rotation);
|
||||||
else if(r % 3 == 0) tt.row();
|
return;
|
||||||
tt.table(weapontable -> {
|
|
||||||
weapontable.left();
|
|
||||||
weapontable.add(new Stack(){{
|
|
||||||
add(new Table(o -> {
|
|
||||||
o.left();
|
|
||||||
o.add(new Image(region){
|
|
||||||
@Override
|
|
||||||
public void draw(){
|
|
||||||
validate();
|
|
||||||
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){
|
|
||||||
float rotation = getRotation();
|
|
||||||
if(scaleX != 1 || scaleY != 1 || rotation != 0){
|
|
||||||
getDrawable().draw(x + imageX, y + imageY,
|
|
||||||
originX - imageX, originY - imageY,
|
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
}.setScaling(Scaling.fit)).size(Scl.scl(modUiScale) * 6 * 8f);
|
|
||||||
}));
|
|
||||||
|
|
||||||
add(new Table(h -> {
|
float recoil = -((mount.reload) / weapon.reload * weapon.recoil);
|
||||||
h.defaults().growX().height(Scl.scl(modUiScale) * 9f).width(Scl.scl(modUiScale) * 31.5f).padTop(Scl.scl(modUiScale) * 18f);
|
y += recoil;
|
||||||
h.add(new Bar(
|
if(getDrawable() != null)
|
||||||
() -> "",
|
getDrawable().draw(x + imageX, y + imageY, imageWidth * scaleX, imageHeight * scaleY);
|
||||||
() -> Pal.accent.cpy().lerp(Color.orange, mount.reload / weapon.reload),
|
}
|
||||||
() -> mount.reload / weapon.reload)).padLeft(Scl.scl(modUiScale) * 8f);
|
}).scaling(Scaling.fill).size(Scl.scl(modUiScale) * iconLarge);
|
||||||
h.pack();
|
}));
|
||||||
}));
|
|
||||||
}}).left();
|
add(new Table(h -> {
|
||||||
}).left();
|
h.defaults().growX().height(Scl.scl(modUiScale) * 9f).width(Scl.scl(modUiScale) * iconLarge).padTop(Scl.scl(modUiScale) * 18f);
|
||||||
tt.center();
|
h.add(new Bar(
|
||||||
}
|
() -> "",
|
||||||
|
() -> Pal.accent.cpy().lerp(Color.orange, mount.reload / weapon.reload),
|
||||||
|
() -> mount.reload / weapon.reload));
|
||||||
|
h.pack();
|
||||||
|
}));
|
||||||
|
}});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}){
|
}
|
||||||
@Override
|
}){
|
||||||
protected void drawBackground(float x, float y) {
|
@Override
|
||||||
if(getBackground() == null) return;
|
protected void drawBackground(float x, float y) {
|
||||||
Color color = this.color;
|
if(getBackground() == null) return;
|
||||||
Draw.color(color.r, color.g, color.b, (settings.getInt("uiopacity") / 100f) * this.parentAlpha);
|
Color color = this.color;
|
||||||
getBackground().draw(x, y, width, height);
|
Draw.color(color.r, color.g, color.b, (settings.getInt("uiopacity") / 100f) * this.parentAlpha);
|
||||||
}
|
getBackground().draw(x, y, width, height);
|
||||||
}).padRight(Scl.scl(modUiScale) * 24 * 8f);
|
}
|
||||||
tx.setColor(tx.color.cpy().a(1f));
|
};
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addUnitTable(){
|
public void addUnitTable(){
|
||||||
@@ -823,7 +817,7 @@ public class HudUi {
|
|||||||
Draw.color(color.r, color.g, color.b, (settings.getInt("uiopacity") / 100f) * this.parentAlpha);
|
Draw.color(color.r, color.g, color.b, (settings.getInt("uiopacity") / 100f) * this.parentAlpha);
|
||||||
getBackground().draw(x, y, width, height);
|
getBackground().draw(x, y, width, height);
|
||||||
}
|
}
|
||||||
}).padRight(Scl.scl(modUiScale) * 24 * 8f);
|
});
|
||||||
table.row();
|
table.row();
|
||||||
table.update(() -> {
|
table.update(() -> {
|
||||||
try {
|
try {
|
||||||
@@ -839,8 +833,9 @@ public class HudUi {
|
|||||||
if(((Turret.TurretBuild) getTarget()).charging) charge += Time.delta;
|
if(((Turret.TurretBuild) getTarget()).charging) charge += Time.delta;
|
||||||
else charge = 0f;
|
else charge = 0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
table.removeChild(weapon);
|
table.removeChild(weapon);
|
||||||
if(settings.getBool("weaponui") && getTarget() instanceof Unit && ((Unit) getTarget()).type != null) {
|
if(settings.getBool("weaponui") && getTarget() instanceof Unit u && u.type != null) {
|
||||||
addWeapon();
|
addWeapon();
|
||||||
table.row();
|
table.row();
|
||||||
table.add(weapon);
|
table.add(weapon);
|
||||||
|
|||||||
Reference in New Issue
Block a user