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:
@@ -3,10 +3,15 @@ shar-stat.health = Health: {0}
|
|||||||
shar-stat.shield = Shield: {0}
|
shar-stat.shield = Shield: {0}
|
||||||
shar-stat.payloadCapacity = Payloads: {0} / {1}
|
shar-stat.payloadCapacity = Payloads: {0} / {1}
|
||||||
shar-stat.itemCapacity = Items: {0} / {1}
|
shar-stat.itemCapacity = Items: {0} / {1}
|
||||||
shar-stat.ammos = Ammos: {0} / {1}
|
shar-stat.ammos = Ammo: {0} / {1}
|
||||||
shar-stat.infinityAmmos = Ammos: Infinity
|
|
||||||
shar-stat.commandUnits = Commands: {0} / {1}
|
shar-stat.commandUnits = Commands: {0} / {1}
|
||||||
|
shar-stat.reload = Reload: {0}%
|
||||||
|
shar-stat.charge = Charge: {0}%
|
||||||
|
shar-stat.itemAmmo = Ammo : {0} / {1}
|
||||||
|
shar-stat.liquidAmmo = Liquid: {0}
|
||||||
|
shar-stat.power = Power: {0} / {1}
|
||||||
|
|
||||||
# Settings
|
# Settings
|
||||||
setting.weaponui.name = Display weapon UI
|
setting.weaponui.name = Display weapon UI
|
||||||
setting.commandedunitui.name = Display commandUnits UI
|
setting.commandedunitui.name = Display commandUnits UI
|
||||||
|
setting.uiopacity.name = UnitInfo UI background Opacity
|
||||||
@@ -4,9 +4,14 @@ shar-stat.shield = 방어막: {0}
|
|||||||
shar-stat.payloadCapacity = 화물: {0} / {1}
|
shar-stat.payloadCapacity = 화물: {0} / {1}
|
||||||
shar-stat.itemCapacity = 아이템: {0} / {1}
|
shar-stat.itemCapacity = 아이템: {0} / {1}
|
||||||
shar-stat.ammos = 탄약: {0} / {1}
|
shar-stat.ammos = 탄약: {0} / {1}
|
||||||
shar-stat.infinityAmmos = 탄약: 무한
|
|
||||||
shar-stat.commandUnits = 지휘 유닛: {0} / {1}
|
shar-stat.commandUnits = 지휘 유닛: {0} / {1}
|
||||||
|
shar-stat.reload = 재장전: {0}%
|
||||||
|
shar-stat.charge = 충전: {0}%
|
||||||
|
shar-stat.itemAmmo = 탄약 : {0} / {1}
|
||||||
|
shar-stat.liquidAmmo = 액체: {0}
|
||||||
|
shar-stat.power = 전력: {0} / {1}
|
||||||
|
|
||||||
# Settings
|
# Settings
|
||||||
setting.weaponui.name = 무기 UI 표시
|
setting.weaponui.name = 무기 UI 표시
|
||||||
setting.commandedunitui.name = 지휘 유닛 UI 표시
|
setting.commandedunitui.name = 지휘 유닛 UI 표시
|
||||||
|
setting.uiopacity.name = UnitInfo UI 배경 투명도
|
||||||
@@ -3,7 +3,7 @@
|
|||||||
"displayName": "Unit Infomation",
|
"displayName": "Unit Infomation",
|
||||||
"author": "Sharlotte",
|
"author": "Sharlotte",
|
||||||
"description": "The mod displays more information for unit, such as health, armor, shield, weapon/weapon reload etc",
|
"description": "The mod displays more information for unit, such as health, armor, shield, weapon/weapon reload etc",
|
||||||
"version": "0",
|
"version": "1.2",
|
||||||
"main": "UnitInfo.core.Main",
|
"main": "UnitInfo.core.Main",
|
||||||
"minGameVersion": "126",
|
"minGameVersion": "126",
|
||||||
"dependencies": [],
|
"dependencies": [],
|
||||||
|
|||||||
@@ -2,38 +2,39 @@ package UnitInfo.core;
|
|||||||
|
|
||||||
import UnitInfo.ui.SBar;
|
import UnitInfo.ui.SBar;
|
||||||
import arc.Core;
|
import arc.Core;
|
||||||
import arc.Events;
|
import arc.func.Func;
|
||||||
import arc.graphics.Color;
|
import arc.graphics.Color;
|
||||||
|
import arc.graphics.g2d.Draw;
|
||||||
import arc.graphics.g2d.TextureRegion;
|
import arc.graphics.g2d.TextureRegion;
|
||||||
import arc.math.Mathf;
|
import arc.math.Mathf;
|
||||||
import arc.scene.Element;
|
import arc.scene.Element;
|
||||||
import arc.scene.style.TextureRegionDrawable;
|
import arc.scene.style.TransformDrawable;
|
||||||
import arc.scene.ui.*;
|
import arc.scene.ui.*;
|
||||||
import arc.scene.ui.layout.Stack;
|
import arc.scene.ui.layout.Stack;
|
||||||
import arc.scene.ui.layout.Table;
|
import arc.scene.ui.layout.Table;
|
||||||
import arc.scene.utils.Elem;
|
|
||||||
import arc.struct.Seq;
|
import arc.struct.Seq;
|
||||||
import arc.util.Log;
|
import arc.util.*;
|
||||||
import arc.util.Nullable;
|
|
||||||
import arc.util.Scaling;
|
|
||||||
import arc.util.Time;
|
|
||||||
import mindustry.Vars;
|
import mindustry.Vars;
|
||||||
import mindustry.ai.types.FormationAI;
|
import mindustry.ai.types.FormationAI;
|
||||||
import mindustry.content.Items;
|
import mindustry.content.Items;
|
||||||
|
import mindustry.content.Liquids;
|
||||||
import mindustry.entities.abilities.ForceFieldAbility;
|
import mindustry.entities.abilities.ForceFieldAbility;
|
||||||
import mindustry.entities.abilities.ShieldRegenFieldAbility;
|
import mindustry.entities.abilities.ShieldRegenFieldAbility;
|
||||||
import mindustry.entities.units.WeaponMount;
|
import mindustry.entities.units.WeaponMount;
|
||||||
import mindustry.game.EventType;
|
|
||||||
import mindustry.gen.*;
|
import mindustry.gen.*;
|
||||||
import mindustry.graphics.Pal;
|
import mindustry.graphics.Pal;
|
||||||
import mindustry.type.AmmoTypes;
|
import mindustry.type.*;
|
||||||
import mindustry.type.UnitType;
|
import mindustry.ui.*;
|
||||||
import mindustry.type.Weapon;
|
import mindustry.world.blocks.defense.turrets.ItemTurret;
|
||||||
import mindustry.ui.Bar;
|
import mindustry.world.blocks.defense.turrets.LiquidTurret;
|
||||||
import mindustry.ui.Cicon;
|
import mindustry.world.blocks.defense.turrets.PowerTurret;
|
||||||
import mindustry.ui.Styles;
|
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.scene;
|
||||||
|
import static arc.Core.settings;
|
||||||
import static mindustry.Vars.*;
|
import static mindustry.Vars.*;
|
||||||
|
|
||||||
public class HudUi {
|
public class HudUi {
|
||||||
@@ -41,8 +42,10 @@ public class HudUi {
|
|||||||
Table weapon = new Table();
|
Table weapon = new Table();
|
||||||
@Nullable UnitType type;
|
@Nullable UnitType type;
|
||||||
@Nullable Unit unit;
|
@Nullable Unit unit;
|
||||||
|
Element image;
|
||||||
|
|
||||||
float heat;
|
float heat;
|
||||||
|
float heat2;
|
||||||
|
|
||||||
public Unit getUnit(){
|
public Unit getUnit(){
|
||||||
Seq<Unit> units = Groups.unit.intersect(Core.input.mouseWorldX(), Core.input.mouseWorldY(), 4, 4);
|
Seq<Unit> units = Groups.unit.intersect(Core.input.mouseWorldX(), Core.input.mouseWorldY(), 4, 4);
|
||||||
@@ -65,44 +68,226 @@ public class HudUi {
|
|||||||
bars.clear();
|
bars.clear();
|
||||||
bars.add(
|
bars.add(
|
||||||
new SBar(
|
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,
|
() -> Pal.health,
|
||||||
() -> Mathf.clamp(getUnit().health / getUnit().type.health)
|
() -> Mathf.clamp(getUnit().health / getUnit().type.health)
|
||||||
),
|
)
|
||||||
new SBar(
|
);
|
||||||
() -> Core.bundle.format("shar-stat.shield", Mathf.round(getUnit().shield,1)),
|
SBar secondBar = new SBar(
|
||||||
() -> Pal.surge,
|
|
||||||
() -> {
|
() -> {
|
||||||
|
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 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;
|
float max2 = 0f;
|
||||||
if(getUnit().type.abilities.find(abil -> abil instanceof ForceFieldAbility) != null) max2 = ((ForceFieldAbility) getUnit().type.abilities.find(abil -> abil instanceof ForceFieldAbility)).max;
|
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));
|
return Mathf.clamp(getUnit().shield / Math.max(max1, max2));
|
||||||
}
|
}
|
||||||
)
|
|
||||||
);
|
);
|
||||||
|
bars.add(secondBar);
|
||||||
|
|
||||||
bars.add(new Stack(){{
|
bars.add(new Stack(){{
|
||||||
add(new Table(t -> {
|
add(new Table(t -> {
|
||||||
t.defaults().width(23 * 8f);
|
t.defaults().width(23 * 8f);
|
||||||
t.defaults().height(4f * 8f);
|
t.defaults().height(4f * 8f);
|
||||||
t.top();
|
t.top();
|
||||||
t.add(new SBar(
|
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),
|
if(getUnit() instanceof BlockUnitUnit){
|
||||||
() -> Mathf.clamp(getUnit().stack.amount / (getUnit().type.itemCapacity * 1f))
|
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();
|
)).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 -> {
|
add(new Table(t -> {
|
||||||
t.left();
|
t.left();
|
||||||
|
|
||||||
t.add(new Image(){{
|
t.add(new Image(){{
|
||||||
update(() -> setDrawable(getUnit().stack.item == null || getUnit().stack.amount <= 0 ? Core.atlas.find("clear") : getUnit().stack.item.icon(Cicon.small)));
|
update(() -> {
|
||||||
}}).size(30f).scaling(Scaling.bounded).padBottom(4 * 8f).padRight(6 * 8f);
|
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();
|
t.pack();
|
||||||
}));
|
}));
|
||||||
}});
|
}});
|
||||||
bars.add(new SBar(
|
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)),
|
if(getUnit() instanceof BlockUnitUnit && ((BlockUnitUnit) getUnit()).tile() instanceof Turret.TurretBuild){
|
||||||
() -> Mathf.clamp(Groups.unit.count(u -> u.controller() instanceof FormationAI && ((FormationAI)u.controller()).leader == getUnit()) / (getUnit().type().commandLimit * 1f))
|
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(
|
bars.add(new SBar(
|
||||||
() -> Core.bundle.format("shar-stat.payloadCapacity", Mathf.round(Mathf.sqrt(((Payloadc)getUnit()).payloadUsed())) + "²", Mathf.round(Mathf.sqrt(getUnit().type().payloadCapacity)) + "²"),
|
() -> Core.bundle.format("shar-stat.payloadCapacity", Mathf.round(Mathf.sqrt(((Payloadc)getUnit()).payloadUsed())) + "²", Mathf.round(Mathf.sqrt(getUnit().type().payloadCapacity)) + "²"),
|
||||||
@@ -148,12 +333,13 @@ public class HudUi {
|
|||||||
tx.defaults().minSize(12 * 8f);
|
tx.defaults().minSize(12 * 8f);
|
||||||
tx.left();
|
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 -> {
|
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().width(24/3f * 8f);
|
||||||
tt.defaults().minHeight(12/3f * 8f);
|
tt.defaults().minHeight(12/3f * 8f);
|
||||||
//tt.defaults().minSize(4 * 8f);
|
|
||||||
tt.left();
|
tt.left();
|
||||||
tt.top();
|
tt.top();
|
||||||
|
|
||||||
int amount = 0;
|
int amount = 0;
|
||||||
if(type != null) amount = Groups.unit.count(u -> u.controller() instanceof FormationAI && ((FormationAI)u.controller()).leader == getUnit());
|
if(type != null) amount = Groups.unit.count(u -> u.controller() instanceof FormationAI && ((FormationAI)u.controller()).leader == getUnit());
|
||||||
Seq<Unit> units = new Seq<>();
|
Seq<Unit> units = new Seq<>();
|
||||||
@@ -219,15 +405,23 @@ public class HudUi {
|
|||||||
}).left();
|
}).left();
|
||||||
tt.center();
|
tt.center();
|
||||||
}
|
}
|
||||||
})).padRight(24 * 8f);
|
})){
|
||||||
|
@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();
|
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().width(24/3f * 8f);
|
||||||
tt.defaults().minHeight(12/3f * 8f);
|
tt.defaults().minHeight(12/3f * 8f);
|
||||||
//tt.defaults().minSize(4 * 8f);
|
|
||||||
tt.left();
|
tt.left();
|
||||||
tt.top();
|
tt.top();
|
||||||
|
|
||||||
int amount = 0;
|
int amount = 0;
|
||||||
if(type != null) amount = type.weapons.size;
|
if(type != null) amount = type.weapons.size;
|
||||||
|
|
||||||
@@ -242,7 +436,32 @@ public class HudUi {
|
|||||||
weapontable.add(new Stack(){{
|
weapontable.add(new Stack(){{
|
||||||
add(new Table(o -> {
|
add(new Table(o -> {
|
||||||
o.left();
|
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 -> {
|
add(new Table(h -> {
|
||||||
@@ -263,20 +482,34 @@ public class HudUi {
|
|||||||
}).left();
|
}).left();
|
||||||
tt.center();
|
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);
|
}).padRight(24 * 8f);
|
||||||
|
tx.setColor(tx.color.cpy().a(1f));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
public void addTable(){
|
public void addTable(){
|
||||||
ui.hudGroup.addChild(new Table(table -> {
|
ui.hudGroup.addChild(new Table(table -> {
|
||||||
table.left();
|
table.left();
|
||||||
addBars();
|
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 -> {
|
t.table(Tex.underline2, tt -> {
|
||||||
tt.top();
|
tt.top();
|
||||||
tt.add(new Stack(){{
|
tt.add(new Stack(){{
|
||||||
add(new Table(ttt -> {
|
add(new Table(ttt -> {
|
||||||
ttt.add(new Image(){{
|
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 -> {
|
add(new Table(ttt -> {
|
||||||
@@ -285,7 +518,13 @@ public class HudUi {
|
|||||||
add(new Table(temp -> {
|
add(new Table(temp -> {
|
||||||
temp.left();
|
temp.left();
|
||||||
temp.add(new Image(Icon.defense)).center();
|
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 -> {
|
add(new Table(temp -> {
|
||||||
temp.left();
|
temp.left();
|
||||||
Label label = new Label(() -> (int)(getUnit().type == null ? 0 : getUnit().type.armor) + "");
|
Label label = new Label(() -> (int)(getUnit().type == null ? 0 : getUnit().type.armor) + "");
|
||||||
@@ -293,17 +532,27 @@ public class HudUi {
|
|||||||
label.setSize(0.6f);
|
label.setSize(0.6f);
|
||||||
temp.add(label).center().padLeft(getUnit().type == null ? 8f : getUnit().type.armor < 10 ? 8f : 0f);
|
temp.add(label).center().padLeft(getUnit().type == null ? 8f : getUnit().type.armor < 10 ? 8f : 0f);
|
||||||
temp.pack();
|
temp.pack();
|
||||||
}));
|
}){
|
||||||
|
@Override
|
||||||
|
public void draw() {
|
||||||
|
if(getUnit() instanceof BlockUnitUnit && ((BlockUnitUnit)getUnit()).tile() instanceof Turret.TurretBuild) return;
|
||||||
|
super.draw();
|
||||||
|
}
|
||||||
|
});
|
||||||
}}).growX().left().padLeft(5 * 8f);
|
}}).growX().left().padLeft(5 * 8f);
|
||||||
}));
|
}));
|
||||||
}}).left();
|
}}).left();
|
||||||
tt.add(new Label(() ->{
|
tt.add(new Label(() ->{
|
||||||
if(getUnit() != null && getUnit().type != null) return "[accent]" + getUnit().type.localizedName + "[]";
|
String name = "";
|
||||||
return "";
|
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();
|
})).center();
|
||||||
tt.button("?", Styles.clearPartialt, () -> {
|
tt.button("?", Styles.clearPartialt, () -> {
|
||||||
if(getUnit().type != null) ui.content.show(getUnit().type);
|
if(getUnit().type != null && getUnit() instanceof BlockUnitUnit && ((BlockUnitUnit)getUnit()).tile() instanceof Turret.TurretBuild) ui.content.show(((BlockUnitUnit)getUnit()).tile().block);
|
||||||
}).right().size(8 * 5).padTop(-5).padRight(-5).grow().name("unitinfo");
|
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.defaults().size(25 * 8f);
|
||||||
t.row();
|
t.row();
|
||||||
@@ -316,10 +565,24 @@ public class HudUi {
|
|||||||
tt.row();
|
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);
|
}).padRight(24 * 8f);
|
||||||
table.row();
|
table.row();
|
||||||
Unit unittemp = getUnit();
|
Unit unittemp = getUnit();
|
||||||
table.update(() -> {
|
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;
|
heat += Time.delta;
|
||||||
if (heat >= 16 && unittemp != getUnit()) {
|
if (heat >= 16 && unittemp != getUnit()) {
|
||||||
heat = 0f;
|
heat = 0f;
|
||||||
@@ -341,6 +604,11 @@ public class HudUi {
|
|||||||
&& (!Vars.mobile ||
|
&& (!Vars.mobile ||
|
||||||
!(getUnit().isBuilding() || Vars.control.input.block != null || !Vars.control.input.selectRequests.isEmpty()
|
!(getUnit().isBuilding() || Vars.control.input.block != null || !Vars.control.input.selectRequests.isEmpty()
|
||||||
&& !(Vars.control.input.lastSchematic != 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("weaponui");
|
||||||
addGraphicSetting("commandedunitui");
|
addGraphicSetting("commandedunitui");
|
||||||
|
Vars.ui.settings.graphics.sliderPref("uiopacity", 50, 0, 100, 5, s -> s + "%");
|
||||||
|
|
||||||
Core.settings.defaults("weaponui", true);
|
Core.settings.defaults("weaponui", true);
|
||||||
Core.settings.defaults("commandedunitui", true);
|
Core.settings.defaults("commandedunitui", true);
|
||||||
|
|
||||||
|
|
||||||
Core.settings.put("uiscalechanged", tmp);
|
Core.settings.put("uiscalechanged", tmp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user