mirror of
https://github.com/yawaflua/Informatis.git
synced 2025-12-10 12:09:27 +02:00
unit-block info!
This commit is contained in:
@@ -2,38 +2,39 @@ package UnitInfo.core;
|
||||
|
||||
import UnitInfo.ui.SBar;
|
||||
import arc.Core;
|
||||
import arc.Events;
|
||||
import arc.func.Func;
|
||||
import arc.graphics.Color;
|
||||
import arc.graphics.g2d.Draw;
|
||||
import arc.graphics.g2d.TextureRegion;
|
||||
import arc.math.Mathf;
|
||||
import arc.scene.Element;
|
||||
import arc.scene.style.TextureRegionDrawable;
|
||||
import arc.scene.style.TransformDrawable;
|
||||
import arc.scene.ui.*;
|
||||
import arc.scene.ui.layout.Stack;
|
||||
import arc.scene.ui.layout.Table;
|
||||
import arc.scene.utils.Elem;
|
||||
import arc.struct.Seq;
|
||||
import arc.util.Log;
|
||||
import arc.util.Nullable;
|
||||
import arc.util.Scaling;
|
||||
import arc.util.Time;
|
||||
import arc.util.*;
|
||||
import mindustry.Vars;
|
||||
import mindustry.ai.types.FormationAI;
|
||||
import mindustry.content.Items;
|
||||
import mindustry.content.Liquids;
|
||||
import mindustry.entities.abilities.ForceFieldAbility;
|
||||
import mindustry.entities.abilities.ShieldRegenFieldAbility;
|
||||
import mindustry.entities.units.WeaponMount;
|
||||
import mindustry.game.EventType;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.graphics.Pal;
|
||||
import mindustry.type.AmmoTypes;
|
||||
import mindustry.type.UnitType;
|
||||
import mindustry.type.Weapon;
|
||||
import mindustry.ui.Bar;
|
||||
import mindustry.ui.Cicon;
|
||||
import mindustry.ui.Styles;
|
||||
import mindustry.type.*;
|
||||
import mindustry.ui.*;
|
||||
import mindustry.world.blocks.defense.turrets.ItemTurret;
|
||||
import mindustry.world.blocks.defense.turrets.LiquidTurret;
|
||||
import mindustry.world.blocks.defense.turrets.PowerTurret;
|
||||
import mindustry.world.blocks.defense.turrets.Turret;
|
||||
import mindustry.world.blocks.power.ConditionalConsumePower;
|
||||
import mindustry.world.consumers.ConsumePower;
|
||||
import mindustry.world.consumers.ConsumeType;
|
||||
|
||||
import static arc.Core.scene;
|
||||
import static arc.Core.settings;
|
||||
import static mindustry.Vars.*;
|
||||
|
||||
public class HudUi {
|
||||
@@ -41,8 +42,10 @@ public class HudUi {
|
||||
Table weapon = new Table();
|
||||
@Nullable UnitType type;
|
||||
@Nullable Unit unit;
|
||||
Element image;
|
||||
|
||||
float heat;
|
||||
float heat2;
|
||||
|
||||
public Unit getUnit(){
|
||||
Seq<Unit> units = Groups.unit.intersect(Core.input.mouseWorldX(), Core.input.mouseWorldY(), 4, 4);
|
||||
@@ -65,44 +68,226 @@ public class HudUi {
|
||||
bars.clear();
|
||||
bars.add(
|
||||
new SBar(
|
||||
() -> Core.bundle.format("shar-stat.health", Mathf.round(getUnit().health,1)),
|
||||
() -> Core.bundle.format("shar-stat.health", Mathf.round(getUnit().health, 1)),
|
||||
() -> Pal.health,
|
||||
() -> Mathf.clamp(getUnit().health / getUnit().type.health)
|
||||
),
|
||||
new SBar(
|
||||
() -> Core.bundle.format("shar-stat.shield", Mathf.round(getUnit().shield,1)),
|
||||
() -> Pal.surge,
|
||||
)
|
||||
);
|
||||
SBar secondBar = new SBar(
|
||||
() -> {
|
||||
if(getUnit() instanceof BlockUnitUnit && ((BlockUnitUnit)getUnit()).tile() instanceof Turret.TurretBuild) {
|
||||
float value = Mathf.clamp(((Turret.TurretBuild)((BlockUnitUnit)getUnit()).tile()).reload / ((Turret)((BlockUnitUnit)getUnit()).tile().block).reloadTime) * 100f;
|
||||
return Core.bundle.format("shar-stat.reload", Strings.fixed(value, (Math.abs((int)value - value) <= 0.001f ? 0 : Math.abs((int)(value * 10) - value * 10) <= 0.001f ? 1 : 2)));
|
||||
}
|
||||
return Core.bundle.format("shar-stat.shield", Mathf.round(getUnit().shield,1));
|
||||
},
|
||||
() ->{
|
||||
if(getUnit() instanceof BlockUnitUnit && ((BlockUnitUnit)getUnit()).tile() instanceof Turret.TurretBuild) {
|
||||
return Pal.accent.cpy().lerp(Color.orange, Mathf.clamp(((Turret.TurretBuild)((BlockUnitUnit)getUnit()).tile()).reload / ((Turret)((BlockUnitUnit)getUnit()).tile().block).reloadTime));
|
||||
}
|
||||
return Pal.surge;
|
||||
},
|
||||
() -> {
|
||||
if(getUnit() instanceof BlockUnitUnit && ((BlockUnitUnit)getUnit()).tile() instanceof Turret.TurretBuild) {
|
||||
return Mathf.clamp(((Turret.TurretBuild)((BlockUnitUnit)getUnit()).tile()).reload / ((Turret)((BlockUnitUnit)getUnit()).tile().block).reloadTime);
|
||||
}
|
||||
float max1 = ((ShieldRegenFieldAbility)content.units().copy().filter(ut -> ut.abilities.find(abil -> abil instanceof ShieldRegenFieldAbility) != null).sort(ut -> ((ShieldRegenFieldAbility)ut.abilities.find(abil -> abil instanceof ShieldRegenFieldAbility)).max).peek().abilities.find(abil -> abil instanceof ShieldRegenFieldAbility)).max;
|
||||
float max2 = 0f;
|
||||
if(getUnit().type.abilities.find(abil -> abil instanceof ForceFieldAbility) != null) max2 = ((ForceFieldAbility) getUnit().type.abilities.find(abil -> abil instanceof ForceFieldAbility)).max;
|
||||
return Mathf.clamp(getUnit().shield / Math.max(max1, max2));
|
||||
}
|
||||
)
|
||||
);
|
||||
bars.add(secondBar);
|
||||
|
||||
bars.add(new Stack(){{
|
||||
add(new Table(t -> {
|
||||
t.defaults().width(23 * 8f);
|
||||
t.defaults().height(4f * 8f);
|
||||
t.top();
|
||||
t.add(new SBar(
|
||||
() -> Core.bundle.format("shar-stat.itemCapacity", getUnit().stack.amount, getUnit().type.itemCapacity),
|
||||
() -> getUnit().stack.item == null || getUnit().stack.amount <= 0 ? Pal.items : getUnit().stack.item.color.cpy().lerp(Color.white, 0.15f),
|
||||
() -> Mathf.clamp(getUnit().stack.amount / (getUnit().type.itemCapacity * 1f))
|
||||
() -> {
|
||||
if(getUnit() instanceof BlockUnitUnit){
|
||||
if(((BlockUnitUnit)getUnit()).tile() instanceof ItemTurret.ItemTurretBuild) {
|
||||
return Core.bundle.format("shar-stat.itemAmmo", ((ItemTurret.ItemTurretBuild) ((BlockUnitUnit)getUnit()).tile()).totalAmmo, ((ItemTurret)((BlockUnitUnit)getUnit()).tile().block).maxAmmo);
|
||||
|
||||
}
|
||||
else if(((BlockUnitUnit)getUnit()).tile() instanceof LiquidTurret.LiquidTurretBuild){
|
||||
LiquidTurret.LiquidTurretBuild entity = ((LiquidTurret.LiquidTurretBuild)((BlockUnitUnit)getUnit()).tile());
|
||||
Func<Building, Liquid> current;
|
||||
current = entity1 -> entity1.liquids == null ? Liquids.water : entity1.liquids.current();
|
||||
|
||||
return Core.bundle.format("shar-stat.liquidAmmo", entity == null || entity.liquids == null ? 0 : Mathf.round(entity.liquids.get(current.get(entity)) * 10) / 10.0 + " / " + Mathf.round(entity.block.liquidCapacity));
|
||||
}
|
||||
else if(((BlockUnitUnit)getUnit()).tile() instanceof PowerTurret.PowerTurretBuild){
|
||||
|
||||
PowerTurret.PowerTurretBuild entity = ((PowerTurret.PowerTurretBuild)((BlockUnitUnit)getUnit()).tile());
|
||||
ConsumePower cons = entity.block.consumes.getPower();
|
||||
double max = (Math.round(cons.usage * 10) / 10.0) * 60;
|
||||
double v = (Math.round(((ConditionalConsumePower)entity.block.consumes.get(ConsumeType.power)).requestedPower(entity) * 10) / 10.0);
|
||||
return Core.bundle.format("shar-stat.power", (Math.round(entity.power.status * v * 10) / 10.0) * 60, max);
|
||||
}
|
||||
}
|
||||
|
||||
return Core.bundle.format("shar-stat.itemCapacity", getUnit().stack.amount, getUnit().type.itemCapacity);
|
||||
},
|
||||
() -> {
|
||||
if(getUnit() instanceof BlockUnitUnit){
|
||||
if(((BlockUnitUnit)getUnit()).tile() instanceof ItemTurret.ItemTurretBuild) {
|
||||
if(((ItemTurret.ItemTurretBuild)((BlockUnitUnit) getUnit()).tile()).hasAmmo()) return ((ItemTurret) ((BlockUnitUnit) getUnit()).tile().block).ammoTypes.findKey(((ItemTurret.ItemTurretBuild)((BlockUnitUnit) getUnit()).tile()).peekAmmo(), true).color;
|
||||
else return Pal.ammo;
|
||||
}
|
||||
else if(((BlockUnitUnit)getUnit()).tile() instanceof LiquidTurret.LiquidTurretBuild){
|
||||
LiquidTurret.LiquidTurretBuild entity = ((LiquidTurret.LiquidTurretBuild)((BlockUnitUnit)getUnit()).tile());
|
||||
Func<Building, Liquid> current;
|
||||
current = entity1 -> entity1.liquids == null ? Liquids.water : entity1.liquids.current();
|
||||
|
||||
return current.get(entity).color;
|
||||
}
|
||||
else if(((BlockUnitUnit)getUnit()).tile() instanceof PowerTurret.PowerTurretBuild){
|
||||
return Pal.powerBar;
|
||||
}
|
||||
}
|
||||
else if(getUnit().stack.item == null || getUnit().stack.amount <= 0) return Pal.items;
|
||||
|
||||
return getUnit().stack.item.color.cpy().lerp(Color.white, 0.15f);
|
||||
},
|
||||
() -> {
|
||||
if(getUnit() instanceof BlockUnitUnit) {
|
||||
if(((BlockUnitUnit)getUnit()).tile() instanceof ItemTurret.ItemTurretBuild) {
|
||||
return ((ItemTurret.ItemTurretBuild) ((BlockUnitUnit) getUnit()).tile()).totalAmmo / (((ItemTurret) ((BlockUnitUnit) getUnit()).tile().block).maxAmmo * 1f);
|
||||
}
|
||||
else if(((BlockUnitUnit)getUnit()).tile() instanceof LiquidTurret.LiquidTurretBuild){
|
||||
LiquidTurret.LiquidTurretBuild entity = ((LiquidTurret.LiquidTurretBuild)((BlockUnitUnit)getUnit()).tile());
|
||||
Func<Building, Liquid> current;
|
||||
current = entity1 -> entity1.liquids == null ? Liquids.water : entity1.liquids.current();
|
||||
|
||||
return entity == null || entity.liquids == null ? 0f : entity.liquids.get(current.get(entity)) / entity.block.liquidCapacity;
|
||||
}
|
||||
else if(((BlockUnitUnit)getUnit()).tile() instanceof PowerTurret.PowerTurretBuild){
|
||||
PowerTurret.PowerTurretBuild entity = ((PowerTurret.PowerTurretBuild)((BlockUnitUnit)getUnit()).tile());
|
||||
ConsumePower cons = entity.block.consumes.getPower();
|
||||
|
||||
double max = (Math.round(cons.usage * 10) / 10.0) * 60;
|
||||
double v = (Math.round(((ConditionalConsumePower)entity.block.consumes.get(ConsumeType.power)).requestedPower(entity) * 10) / 10.0);
|
||||
return (float) (((Math.round(entity.power.status * v * 10) / 10.0) * 60) / max);
|
||||
}
|
||||
}
|
||||
return Mathf.clamp(getUnit().stack.amount / (getUnit().type.itemCapacity * 1f));
|
||||
}
|
||||
)).growX().left();
|
||||
}));
|
||||
add(new Table()
|
||||
{{
|
||||
left();
|
||||
update(() -> {
|
||||
if(!(getUnit() instanceof BlockUnitUnit) || (
|
||||
!(((BlockUnitUnit)getUnit()).tile() instanceof ItemTurret.ItemTurretBuild)
|
||||
&& !(((BlockUnitUnit)getUnit()).tile() instanceof LiquidTurret.LiquidTurretBuild)
|
||||
&& !(((BlockUnitUnit)getUnit()).tile() instanceof PowerTurret.PowerTurretBuild)
|
||||
)){
|
||||
clearChildren();
|
||||
image = null;
|
||||
return;
|
||||
}
|
||||
|
||||
if(getUnit() instanceof BlockUnitUnit){
|
||||
Element imaget = new Element();
|
||||
if(((BlockUnitUnit)getUnit()).tile() instanceof ItemTurret.ItemTurretBuild){
|
||||
MultiReqImage itemReq = new MultiReqImage();
|
||||
for(Item item : ((ItemTurret) ((BlockUnitUnit) getUnit()).tile().block).ammoTypes.keys())
|
||||
itemReq.add(new ReqImage(item.icon(Cicon.tiny), () -> ((ItemTurret.ItemTurretBuild)((BlockUnitUnit) getUnit()).tile()).hasAmmo()));
|
||||
imaget = itemReq;
|
||||
|
||||
if(((ItemTurret.ItemTurretBuild)((BlockUnitUnit) getUnit()).tile()).hasAmmo())
|
||||
imaget = new Image(((ItemTurret) ((BlockUnitUnit) getUnit()).tile().block).ammoTypes.findKey(((ItemTurret.ItemTurretBuild)((BlockUnitUnit) getUnit()).tile()).peekAmmo(), true).icon(Cicon.small));
|
||||
|
||||
}
|
||||
else if(((BlockUnitUnit)getUnit()).tile() instanceof LiquidTurret.LiquidTurretBuild){
|
||||
LiquidTurret.LiquidTurretBuild entity = ((LiquidTurret.LiquidTurretBuild)((BlockUnitUnit)getUnit()).tile());
|
||||
Func<Building, Liquid> current;
|
||||
current = entity1 -> entity1.liquids == null ? Liquids.water : entity1.liquids.current();
|
||||
|
||||
MultiReqImage liquidReq = new MultiReqImage();
|
||||
for(Liquid liquid : ((LiquidTurret) ((BlockUnitUnit) getUnit()).tile().block).ammoTypes.keys())
|
||||
liquidReq.add(new ReqImage(liquid.icon(Cicon.tiny), () -> ((LiquidTurret.LiquidTurretBuild)((BlockUnitUnit) getUnit()).tile()).hasAmmo()));
|
||||
imaget = liquidReq;
|
||||
|
||||
if(((LiquidTurret.LiquidTurretBuild)((BlockUnitUnit) getUnit()).tile()).hasAmmo())
|
||||
imaget = new Image(current.get(entity).icon(Cicon.small));
|
||||
}
|
||||
else if(((BlockUnitUnit)getUnit()).tile() instanceof PowerTurret.PowerTurretBuild){
|
||||
PowerTurret.PowerTurretBuild entity = ((PowerTurret.PowerTurretBuild)((BlockUnitUnit)getUnit()).tile());
|
||||
ConsumePower cons = entity.block.consumes.getPower();
|
||||
|
||||
|
||||
|
||||
double max = (Math.round(cons.usage * 10) / 10.0) * 60;
|
||||
double v = (Math.round(((ConditionalConsumePower)entity.block.consumes.get(ConsumeType.power)).requestedPower(entity) * 10) / 10.0);
|
||||
float amount = (float) (((Math.round(entity.power.status * v * 10) / 10.0) * 60) / max);
|
||||
//float amount = Mathf.zero(cons.requestedPower(entity)) && entity.power.graph.getPowerProduced() + entity.power.graph.getBatteryStored() > 0f ? 1f : entity.power.status;
|
||||
|
||||
float finalAmount = amount;
|
||||
imaget = new PrograssedReqImage(Icon.power.getRegion(), () -> finalAmount >= 0.99f, amount);
|
||||
if(amount >= 0.999f) imaget = new Image(Icon.power.getRegion());
|
||||
}
|
||||
|
||||
if(image != null){
|
||||
if(imaget.getClass() != image.getClass() || imaget.getClass() == Image.class){
|
||||
clearChildren();
|
||||
add(imaget).size(Cicon.small.size).padBottom(2 * 8f).padRight(3 * 8f);
|
||||
image = imaget;
|
||||
}
|
||||
}
|
||||
else {
|
||||
add(imaget).size(Cicon.small.size).padBottom(2 * 8f).padRight(3 * 8f);
|
||||
image = imaget;
|
||||
}
|
||||
}
|
||||
});
|
||||
pack();
|
||||
}});
|
||||
add(new Table(t -> {
|
||||
t.left();
|
||||
|
||||
t.add(new Image(){{
|
||||
update(() -> setDrawable(getUnit().stack.item == null || getUnit().stack.amount <= 0 ? Core.atlas.find("clear") : getUnit().stack.item.icon(Cicon.small)));
|
||||
}}).size(30f).scaling(Scaling.bounded).padBottom(4 * 8f).padRight(6 * 8f);
|
||||
update(() -> {
|
||||
setDrawable(getUnit().stack.item == null || getUnit().stack.amount <= 0 ? Core.atlas.find("clear") : getUnit().stack.item.icon(Cicon.small));
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw() {
|
||||
if(getUnit() instanceof BlockUnitUnit && ((BlockUnitUnit)getUnit()).tile() instanceof ItemTurret.ItemTurretBuild) return;
|
||||
super.draw();
|
||||
}
|
||||
}).size(30f).scaling(Scaling.bounded).padBottom(4 * 8f).padRight(6 * 8f);
|
||||
t.pack();
|
||||
}));
|
||||
}});
|
||||
bars.add(new SBar(
|
||||
() -> Core.bundle.format("shar-stat.commandUnits", Groups.unit.count(u -> u.controller() instanceof FormationAI && ((FormationAI)u.controller()).leader == getUnit()), getUnit().type().commandLimit),
|
||||
() -> Pal.powerBar.cpy().lerp(Pal.surge.cpy().mul(Pal.lighterOrange), Mathf.absin(Time.time, 7f / (1f + Mathf.clamp(Groups.unit.count(u -> u.controller() instanceof FormationAI && ((FormationAI)u.controller()).leader == getUnit()) / (getUnit().type().commandLimit * 1f))), 1f)),
|
||||
() -> Mathf.clamp(Groups.unit.count(u -> u.controller() instanceof FormationAI && ((FormationAI)u.controller()).leader == getUnit()) / (getUnit().type().commandLimit * 1f))
|
||||
() -> {
|
||||
if(getUnit() instanceof BlockUnitUnit && ((BlockUnitUnit) getUnit()).tile() instanceof Turret.TurretBuild){
|
||||
Turret.TurretBuild entity = ((Turret.TurretBuild)((BlockUnitUnit) getUnit()).tile());
|
||||
float value = Mathf.clamp(heat2 / ((Turret)entity.block).chargeTime) * 100f;
|
||||
return Core.bundle.format("shar-stat.charge", Strings.fixed(value, (Math.abs((int)value - value) <= 0.001f ? 0 : Math.abs((int)(value * 10) - value * 10) <= 0.001f ? 1 : 2)));
|
||||
}
|
||||
return Core.bundle.format("shar-stat.commandUnits", Groups.unit.count(u -> u.controller() instanceof FormationAI && ((FormationAI)u.controller()).leader == getUnit()), getUnit().type().commandLimit);
|
||||
},
|
||||
() -> {
|
||||
if(getUnit() instanceof BlockUnitUnit && ((BlockUnitUnit) getUnit()).tile() instanceof Turret.TurretBuild){
|
||||
Turret.TurretBuild entity = ((Turret.TurretBuild)((BlockUnitUnit) getUnit()).tile());
|
||||
return Pal.surge.cpy().lerp(Pal.accent, heat2 / ((Turret)entity.block).chargeTime);
|
||||
}
|
||||
return Pal.powerBar.cpy().lerp(Pal.surge.cpy().mul(Pal.lighterOrange), Mathf.absin(Time.time, 7f / (1f + Mathf.clamp(Groups.unit.count(u -> u.controller() instanceof FormationAI && ((FormationAI)u.controller()).leader == getUnit()) / (getUnit().type().commandLimit * 1f))), 1f));
|
||||
},
|
||||
() -> {
|
||||
if(getUnit() instanceof BlockUnitUnit && ((BlockUnitUnit) getUnit()).tile() instanceof Turret.TurretBuild){
|
||||
Turret.TurretBuild entity = ((Turret.TurretBuild)((BlockUnitUnit) getUnit()).tile());
|
||||
return heat2 / ((Turret)entity.block).chargeTime;
|
||||
}
|
||||
return Mathf.clamp(Groups.unit.count(u -> u.controller() instanceof FormationAI && ((FormationAI)u.controller()).leader == getUnit()) / (getUnit().type().commandLimit * 1f));
|
||||
}
|
||||
|
||||
));
|
||||
bars.add(new SBar(
|
||||
() -> Core.bundle.format("shar-stat.payloadCapacity", Mathf.round(Mathf.sqrt(((Payloadc)getUnit()).payloadUsed())) + "²", Mathf.round(Mathf.sqrt(getUnit().type().payloadCapacity)) + "²"),
|
||||
@@ -148,86 +333,95 @@ public class HudUi {
|
||||
tx.defaults().minSize(12 * 8f);
|
||||
tx.left();
|
||||
|
||||
if(Core.settings.getBool("commandedunitui") && Groups.unit.count(u -> u.controller() instanceof FormationAI && ((FormationAI)u.controller()).leader == getUnit()) != 0) tx.table(scene.getStyle(Button.ButtonStyle.class).up, t1 -> t1.table(tt -> {
|
||||
tt.defaults().width(24/3f * 8f);
|
||||
tt.defaults().minHeight(12/3f * 8f);
|
||||
//tt.defaults().minSize(4 * 8f);
|
||||
tt.left();
|
||||
tt.top();
|
||||
int amount = 0;
|
||||
if(type != null) amount = Groups.unit.count(u -> u.controller() instanceof FormationAI && ((FormationAI)u.controller()).leader == getUnit());
|
||||
Seq<Unit> units = new Seq<>();
|
||||
units = Groups.unit.copy(units).filter(u -> u.controller() instanceof FormationAI && ((FormationAI)u.controller()).leader == getUnit());
|
||||
for(int r = 0; r < amount; r++){
|
||||
Unit unit = units.get(r);
|
||||
TextureRegion region = unit.type.icon(Cicon.full);
|
||||
if(type.weapons.size > 1 && r % 3 == 0) tt.row();
|
||||
else if(r % 3 == 0) tt.row();
|
||||
tt.table(unittable -> {
|
||||
unittable.left();
|
||||
unittable.add(new Stack(){{
|
||||
add(new Table(o -> {
|
||||
o.left();
|
||||
o.image(region).size(30).scaling(Scaling.bounded);
|
||||
}));
|
||||
if(settings.getBool("commandedunitui") && Groups.unit.count(u -> u.controller() instanceof FormationAI && ((FormationAI)u.controller()).leader == getUnit()) != 0)
|
||||
tx.add(new Table(scene.getStyle(Button.ButtonStyle.class).up, t1 -> t1.table(tt -> {
|
||||
tt.defaults().width(24/3f * 8f);
|
||||
tt.defaults().minHeight(12/3f * 8f);
|
||||
tt.left();
|
||||
tt.top();
|
||||
|
||||
add(new Table(h -> {
|
||||
h.add(new Stack(){{
|
||||
add(new Table(e -> {
|
||||
e.defaults().growX().height(9).width(42f).padRight(2*8).padTop(8*2f);
|
||||
e.left();
|
||||
Bar healthBar = new Bar(
|
||||
() -> "",
|
||||
() -> Pal.health,
|
||||
unit::healthf);
|
||||
e.add(healthBar).left();
|
||||
e.pack();
|
||||
}));
|
||||
add(new Table(e -> e.add(new Stack(){{
|
||||
add(new Table(t -> {
|
||||
t.defaults().growX().height(9).width(42f).padRight(2*8).padTop(8*5f);
|
||||
t.left();
|
||||
t.add(new Bar(
|
||||
int amount = 0;
|
||||
if(type != null) amount = Groups.unit.count(u -> u.controller() instanceof FormationAI && ((FormationAI)u.controller()).leader == getUnit());
|
||||
Seq<Unit> units = new Seq<>();
|
||||
units = Groups.unit.copy(units).filter(u -> u.controller() instanceof FormationAI && ((FormationAI)u.controller()).leader == getUnit());
|
||||
for(int r = 0; r < amount; r++){
|
||||
Unit unit = units.get(r);
|
||||
TextureRegion region = unit.type.icon(Cicon.full);
|
||||
if(type.weapons.size > 1 && r % 3 == 0) tt.row();
|
||||
else if(r % 3 == 0) tt.row();
|
||||
tt.table(unittable -> {
|
||||
unittable.left();
|
||||
unittable.add(new Stack(){{
|
||||
add(new Table(o -> {
|
||||
o.left();
|
||||
o.image(region).size(30).scaling(Scaling.bounded);
|
||||
}));
|
||||
|
||||
add(new Table(h -> {
|
||||
h.add(new Stack(){{
|
||||
add(new Table(e -> {
|
||||
e.defaults().growX().height(9).width(42f).padRight(2*8).padTop(8*2f);
|
||||
e.left();
|
||||
Bar healthBar = new Bar(
|
||||
() -> "",
|
||||
() -> unit.stack.item == null || unit.stack.amount <= 0 ? Pal.items : unit.stack.item.color.cpy().lerp(Color.white, 0.15f),
|
||||
() -> Mathf.clamp(unit.stack.amount / (unit.type.itemCapacity * 1f))
|
||||
)).growX().left();
|
||||
() -> Pal.health,
|
||||
unit::healthf);
|
||||
e.add(healthBar).left();
|
||||
e.pack();
|
||||
}));
|
||||
add(new Table(t -> {
|
||||
t.left();
|
||||
t.add(new Stack(){{
|
||||
add(new Table(tt -> {
|
||||
tt.add(new Image(){{
|
||||
update(() -> setDrawable(unit.stack.item == null || unit.stack.amount <= 0 ? Core.atlas.find("clear") : unit.stack.item.icon(Cicon.small)));
|
||||
}}).size(2.5f * 8f).scaling(Scaling.bounded).padBottom(4 * 8f).padLeft(2 * 8f);
|
||||
}));
|
||||
Table table = new Table(tt -> {
|
||||
Label label = new Label(() -> unit.stack.item == null || unit.stack.amount <= 0 ? "" : unit.stack.amount + "");
|
||||
add(new Table(e -> e.add(new Stack(){{
|
||||
add(new Table(t -> {
|
||||
t.defaults().growX().height(9).width(42f).padRight(2*8).padTop(8*5f);
|
||||
t.left();
|
||||
t.add(new Bar(
|
||||
() -> "",
|
||||
() -> unit.stack.item == null || unit.stack.amount <= 0 ? Pal.items : unit.stack.item.color.cpy().lerp(Color.white, 0.15f),
|
||||
() -> Mathf.clamp(unit.stack.amount / (unit.type.itemCapacity * 1f))
|
||||
)).growX().left();
|
||||
}));
|
||||
add(new Table(t -> {
|
||||
t.left();
|
||||
t.add(new Stack(){{
|
||||
add(new Table(tt -> {
|
||||
tt.add(new Image(){{
|
||||
update(() -> setDrawable(unit.stack.item == null || unit.stack.amount <= 0 ? Core.atlas.find("clear") : unit.stack.item.icon(Cicon.small)));
|
||||
}}).size(2.5f * 8f).scaling(Scaling.bounded).padBottom(4 * 8f).padLeft(2 * 8f);
|
||||
}));
|
||||
Table table = new Table(tt -> {
|
||||
Label label = new Label(() -> unit.stack.item == null || unit.stack.amount <= 0 ? "" : unit.stack.amount + "");
|
||||
|
||||
tt.add(label).padBottom(1 * 8f).padLeft(2 * 8f);
|
||||
tt.pack();
|
||||
});
|
||||
add(table);
|
||||
}});
|
||||
t.pack();
|
||||
}));
|
||||
}})));
|
||||
}}).padTop(2*8).padRight(2*8);
|
||||
h.pack();
|
||||
}));
|
||||
}}).left();
|
||||
}).left();
|
||||
tt.center();
|
||||
}
|
||||
})).padRight(24 * 8f);
|
||||
tt.add(label).padBottom(1 * 8f).padLeft(2 * 8f);
|
||||
tt.pack();
|
||||
});
|
||||
add(table);
|
||||
}});
|
||||
t.pack();
|
||||
}));
|
||||
}})));
|
||||
}}).padTop(2*8).padRight(2*8);
|
||||
h.pack();
|
||||
}));
|
||||
}}).left();
|
||||
}).left();
|
||||
tt.center();
|
||||
}
|
||||
})){
|
||||
@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);
|
||||
}
|
||||
}).padRight(24 * 8f);
|
||||
tx.row();
|
||||
if(Core.settings.getBool("weaponui") && type != null && type.weapons.size != 0) tx.table(scene.getStyle(Button.ButtonStyle.class).up, tt -> {
|
||||
if(settings.getBool("weaponui") && type != null && type.weapons.size != 0) tx.add(new Table(scene.getStyle(Button.ButtonStyle.class).up, tt -> {
|
||||
|
||||
tt.defaults().width(24/3f * 8f);
|
||||
tt.defaults().minHeight(12/3f * 8f);
|
||||
//tt.defaults().minSize(4 * 8f);
|
||||
tt.left();
|
||||
tt.top();
|
||||
|
||||
int amount = 0;
|
||||
if(type != null) amount = type.weapons.size;
|
||||
|
||||
@@ -242,7 +436,32 @@ public class HudUi {
|
||||
weapontable.add(new Stack(){{
|
||||
add(new Table(o -> {
|
||||
o.left();
|
||||
o.image(region).size(6 * 8f).scaling(Scaling.bounded);
|
||||
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);
|
||||
}
|
||||
}).size(6 * 8f).scaling(Scaling.bounded);
|
||||
}));
|
||||
|
||||
add(new Table(h -> {
|
||||
@@ -263,20 +482,34 @@ public class HudUi {
|
||||
}).left();
|
||||
tt.center();
|
||||
}
|
||||
}){
|
||||
@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);
|
||||
}
|
||||
}).padRight(24 * 8f);
|
||||
tx.setColor(tx.color.cpy().a(1f));
|
||||
});
|
||||
}
|
||||
public void addTable(){
|
||||
ui.hudGroup.addChild(new Table(table -> {
|
||||
table.left();
|
||||
addBars();
|
||||
table.table(scene.getStyle(Button.ButtonStyle.class).up, t -> {
|
||||
table.add(new Table(scene.getStyle(Button.ButtonStyle.class).up, t -> {
|
||||
t.table(Tex.underline2, tt -> {
|
||||
tt.top();
|
||||
tt.add(new Stack(){{
|
||||
add(new Table(ttt -> {
|
||||
ttt.add(new Image(){{
|
||||
update(() -> setDrawable(getUnit().type == null ? Core.atlas.find("clear") : getUnit().type.icon(Cicon.large)));
|
||||
update(() -> {
|
||||
TextureRegion region = Core.atlas.find("clear");
|
||||
if(getUnit() instanceof BlockUnitUnit && getUnit().type != null && ((BlockUnitUnit)getUnit()).tile() instanceof Turret.TurretBuild) region = ((BlockUnitUnit)getUnit()).tile().block.icon(Cicon.large);
|
||||
else if(getUnit() != null && getUnit().type != null) region = getUnit().type.icon(Cicon.large);
|
||||
setDrawable(region);
|
||||
});
|
||||
}});
|
||||
}));
|
||||
add(new Table(ttt -> {
|
||||
@@ -285,7 +518,13 @@ public class HudUi {
|
||||
add(new Table(temp -> {
|
||||
temp.left();
|
||||
temp.add(new Image(Icon.defense)).center();
|
||||
}));
|
||||
}){
|
||||
@Override
|
||||
public void draw() {
|
||||
if(getUnit() instanceof BlockUnitUnit && ((BlockUnitUnit)getUnit()).tile() instanceof Turret.TurretBuild) return;
|
||||
super.draw();
|
||||
}
|
||||
});
|
||||
add(new Table(temp -> {
|
||||
temp.left();
|
||||
Label label = new Label(() -> (int)(getUnit().type == null ? 0 : getUnit().type.armor) + "");
|
||||
@@ -293,17 +532,27 @@ public class HudUi {
|
||||
label.setSize(0.6f);
|
||||
temp.add(label).center().padLeft(getUnit().type == null ? 8f : getUnit().type.armor < 10 ? 8f : 0f);
|
||||
temp.pack();
|
||||
}));
|
||||
}){
|
||||
@Override
|
||||
public void draw() {
|
||||
if(getUnit() instanceof BlockUnitUnit && ((BlockUnitUnit)getUnit()).tile() instanceof Turret.TurretBuild) return;
|
||||
super.draw();
|
||||
}
|
||||
});
|
||||
}}).growX().left().padLeft(5 * 8f);
|
||||
}));
|
||||
}}).left();
|
||||
tt.add(new Label(() ->{
|
||||
if(getUnit() != null && getUnit().type != null) return "[accent]" + getUnit().type.localizedName + "[]";
|
||||
return "";
|
||||
String name = "";
|
||||
if(getUnit() instanceof BlockUnitUnit && ((BlockUnitUnit)getUnit()).tile() instanceof Turret.TurretBuild) name = "[accent]" + ((BlockUnitUnit)getUnit()).tile().block.localizedName + "[]";
|
||||
else if(getUnit() != null && getUnit().type != null) name = "[accent]" + getUnit().type.localizedName + "[]";
|
||||
|
||||
return name;
|
||||
})).center();
|
||||
tt.button("?", Styles.clearPartialt, () -> {
|
||||
if(getUnit().type != null) ui.content.show(getUnit().type);
|
||||
}).right().size(8 * 5).padTop(-5).padRight(-5).grow().name("unitinfo");
|
||||
if(getUnit().type != null && getUnit() instanceof BlockUnitUnit && ((BlockUnitUnit)getUnit()).tile() instanceof Turret.TurretBuild) ui.content.show(((BlockUnitUnit)getUnit()).tile().block);
|
||||
else if(getUnit().type != null) ui.content.show(getUnit().type);
|
||||
}).right().size(8 * 5).padTop(-5).padRight(-5).grow().name("info");
|
||||
});
|
||||
t.defaults().size(25 * 8f);
|
||||
t.row();
|
||||
@@ -316,10 +565,24 @@ public class HudUi {
|
||||
tt.row();
|
||||
}
|
||||
});
|
||||
t.setColor(t.color.cpy().a(1f));
|
||||
}){
|
||||
@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);
|
||||
}
|
||||
}).padRight(24 * 8f);
|
||||
table.row();
|
||||
Unit unittemp = getUnit();
|
||||
table.update(() -> {
|
||||
if(getUnit() instanceof BlockUnitUnit && ((BlockUnitUnit) getUnit()).tile() instanceof Turret.TurretBuild){
|
||||
Turret.TurretBuild entity = ((Turret.TurretBuild)((BlockUnitUnit) getUnit()).tile());
|
||||
if(entity.charging) heat2 += Time.delta;
|
||||
else heat2 = 0f;
|
||||
}
|
||||
heat += Time.delta;
|
||||
if (heat >= 16 && unittemp != getUnit()) {
|
||||
heat = 0f;
|
||||
@@ -341,6 +604,11 @@ public class HudUi {
|
||||
&& (!Vars.mobile ||
|
||||
!(getUnit().isBuilding() || Vars.control.input.block != null || !Vars.control.input.selectRequests.isEmpty()
|
||||
&& !(Vars.control.input.lastSchematic != null && !Vars.control.input.selectRequests.isEmpty())));
|
||||
}));
|
||||
}){
|
||||
@Override
|
||||
public void draw() {
|
||||
super.draw();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
45
src/UnitInfo/core/PrograssedReqImage.java
Normal file
45
src/UnitInfo/core/PrograssedReqImage.java
Normal file
@@ -0,0 +1,45 @@
|
||||
package UnitInfo.core;
|
||||
|
||||
import arc.func.Boolp;
|
||||
import arc.graphics.g2d.Draw;
|
||||
import arc.graphics.g2d.Lines;
|
||||
import arc.graphics.g2d.TextureRegion;
|
||||
import arc.scene.Element;
|
||||
import arc.scene.ui.Image;
|
||||
import arc.scene.ui.layout.Scl;
|
||||
import arc.scene.ui.layout.Stack;
|
||||
import mindustry.graphics.Pal;
|
||||
|
||||
public class PrograssedReqImage extends Stack {
|
||||
private final Boolp valid;
|
||||
|
||||
public PrograssedReqImage(Element image, Boolp valid, float prograss){
|
||||
this.valid = valid;
|
||||
add(image);
|
||||
add(new Element(){
|
||||
{
|
||||
visible(() -> !valid.get());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(){
|
||||
Lines.stroke(Scl.scl(2f), Pal.removeBack);
|
||||
Draw.alpha(1 - prograss);
|
||||
Lines.line(x, y - 2f + height, x + width, y - 2f);
|
||||
Draw.color(Pal.remove);
|
||||
Draw.alpha(1 - prograss);
|
||||
Lines.line(x, y + height, x + width, y);
|
||||
Draw.reset();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public PrograssedReqImage(TextureRegion region, Boolp valid, float prograss){
|
||||
this(new Image(region), valid, prograss);
|
||||
}
|
||||
|
||||
public boolean valid(){
|
||||
return valid.get();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,9 +14,12 @@ public class Setting {
|
||||
|
||||
addGraphicSetting("weaponui");
|
||||
addGraphicSetting("commandedunitui");
|
||||
Vars.ui.settings.graphics.sliderPref("uiopacity", 50, 0, 100, 5, s -> s + "%");
|
||||
|
||||
Core.settings.defaults("weaponui", true);
|
||||
Core.settings.defaults("commandedunitui", true);
|
||||
|
||||
|
||||
Core.settings.put("uiscalechanged", tmp);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user