mirror of
https://github.com/yawaflua/Informatis.git
synced 2025-12-10 12:09:27 +02:00
clean up
This commit is contained in:
@@ -5,7 +5,7 @@
|
|||||||
"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": "1.2",
|
"version": "1.2",
|
||||||
"main": "UnitInfo.core.Main",
|
"main": "UnitInfo.core.Main",
|
||||||
"minGameVersion": "126",
|
"minGameVersion": "128",
|
||||||
"dependencies": [],
|
"dependencies": [],
|
||||||
"hidden": true,
|
"hidden": true,
|
||||||
"java": true
|
"java": true
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ public class HudUi {
|
|||||||
Seq<Color> colors = new Seq<>(new Color[]{Color.clear,Color.clear,Color.clear,Color.clear,Color.clear,Color.clear});
|
Seq<Color> colors = new Seq<>(new Color[]{Color.clear,Color.clear,Color.clear,Color.clear,Color.clear,Color.clear});
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public <T extends Teamc> T getUnit(){
|
public <T extends Teamc> T getTarget(){
|
||||||
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);
|
||||||
if(units.size > 0) return (T) units.peek();
|
if(units.size > 0) return (T) units.peek();
|
||||||
if(getTile() != null && getTile().build != null) return (T) getTile().build;
|
if(getTile() != null && getTile().build != null) return (T) getTile().build;
|
||||||
@@ -78,9 +78,9 @@ public class HudUi {
|
|||||||
|
|
||||||
public void setEvent(){
|
public void setEvent(){
|
||||||
Events.run(EventType.Trigger.draw, () -> {
|
Events.run(EventType.Trigger.draw, () -> {
|
||||||
if(getUnit() == null || !Core.settings.getBool("select")) return;
|
if(getTarget() == null || !Core.settings.getBool("select")) return;
|
||||||
|
|
||||||
Posc entity = getUnit();
|
Posc entity = getTarget();
|
||||||
for(int i = 0; i < 4; i++){
|
for(int i = 0; i < 4; i++){
|
||||||
float rot = i * 90f + 45f + (-Time.time) % 360f;
|
float rot = i * 90f + 45f + (-Time.time) % 360f;
|
||||||
float length = (entity instanceof Unit ? ((Unit)entity).hitSize : entity instanceof Building ? ((Building)entity).block.size * tilesize : 0) * 1.5f + 2.5f;
|
float length = (entity instanceof Unit ? ((Unit)entity).hitSize : entity instanceof Building ? ((Building)entity).block.size * tilesize : 0) * 1.5f + 2.5f;
|
||||||
@@ -247,18 +247,18 @@ public class HudUi {
|
|||||||
add(new Table(){{
|
add(new Table(){{
|
||||||
left();
|
left();
|
||||||
update(() -> {
|
update(() -> {
|
||||||
if(!(getUnit() instanceof Turret.TurretBuild) || (
|
if(!(getTarget() instanceof Turret.TurretBuild) || (
|
||||||
!(getUnit() instanceof ItemTurret.ItemTurretBuild)
|
!(getTarget() instanceof ItemTurret.ItemTurretBuild)
|
||||||
&& !(getUnit() instanceof LiquidTurret.LiquidTurretBuild)
|
&& !(getTarget() instanceof LiquidTurret.LiquidTurretBuild)
|
||||||
&& !(getUnit() instanceof PowerTurret.PowerTurretBuild))){
|
&& !(getTarget() instanceof PowerTurret.PowerTurretBuild))){
|
||||||
clearChildren();
|
clearChildren();
|
||||||
image = null;
|
image = null;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(getUnit() instanceof Turret.TurretBuild){
|
if(getTarget() instanceof Turret.TurretBuild){
|
||||||
Element imaget = new Element();
|
Element imaget = new Element();
|
||||||
if(getUnit() instanceof ItemTurret.ItemTurretBuild){
|
if(getTarget() instanceof ItemTurret.ItemTurretBuild){
|
||||||
ItemTurret.ItemTurretBuild turretBuild = getUnit();
|
ItemTurret.ItemTurretBuild turretBuild = getTarget();
|
||||||
if(turretBuild.hasAmmo()) imaget = new Image(((ItemTurret)turretBuild.block).ammoTypes.findKey(turretBuild.peekAmmo(), true).uiIcon);
|
if(turretBuild.hasAmmo()) imaget = new Image(((ItemTurret)turretBuild.block).ammoTypes.findKey(turretBuild.peekAmmo(), true).uiIcon);
|
||||||
else {MultiReqImage itemReq = new MultiReqImage();
|
else {MultiReqImage itemReq = new MultiReqImage();
|
||||||
for(Item item : ((ItemTurret) turretBuild.block).ammoTypes.keys())
|
for(Item item : ((ItemTurret) turretBuild.block).ammoTypes.keys())
|
||||||
@@ -266,23 +266,23 @@ public class HudUi {
|
|||||||
imaget = itemReq;
|
imaget = itemReq;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(getUnit() instanceof LiquidTurret.LiquidTurretBuild){
|
else if(getTarget() instanceof LiquidTurret.LiquidTurretBuild){
|
||||||
LiquidTurret.LiquidTurretBuild entity = getUnit();
|
LiquidTurret.LiquidTurretBuild entity = getTarget();
|
||||||
MultiReqImage liquidReq = new MultiReqImage();
|
MultiReqImage liquidReq = new MultiReqImage();
|
||||||
for(Liquid liquid : ((LiquidTurret) ((LiquidTurret.LiquidTurretBuild) getUnit()).block).ammoTypes.keys())
|
for(Liquid liquid : ((LiquidTurret) ((LiquidTurret.LiquidTurretBuild) getTarget()).block).ammoTypes.keys())
|
||||||
liquidReq.add(new ReqImage(liquid.uiIcon, () -> ((LiquidTurret.LiquidTurretBuild) getUnit()).hasAmmo()));
|
liquidReq.add(new ReqImage(liquid.uiIcon, () -> ((LiquidTurret.LiquidTurretBuild) getTarget()).hasAmmo()));
|
||||||
imaget = liquidReq;
|
imaget = liquidReq;
|
||||||
|
|
||||||
if(((LiquidTurret.LiquidTurretBuild) getUnit()).hasAmmo())
|
if(((LiquidTurret.LiquidTurretBuild) getTarget()).hasAmmo())
|
||||||
imaget = new Image(entity.liquids.current().uiIcon).setScaling(Scaling.fit);
|
imaget = new Image(entity.liquids.current().uiIcon).setScaling(Scaling.fit);
|
||||||
}
|
}
|
||||||
else if(getUnit() instanceof PowerTurret.PowerTurretBuild){
|
else if(getTarget() instanceof PowerTurret.PowerTurretBuild){
|
||||||
imaget = new ReqImage(Icon.power.getRegion(), () -> ((PowerTurret.PowerTurretBuild)getUnit()).power.status * ((PowerTurret.PowerTurretBuild)getUnit()).power.graph.getLastScaledPowerIn() > 0f){{
|
imaget = new ReqImage(Icon.power.getRegion(), () -> ((PowerTurret.PowerTurretBuild) getTarget()).power.status * ((PowerTurret.PowerTurretBuild) getTarget()).power.graph.getLastScaledPowerIn() > 0f){{
|
||||||
add(new Image(Icon.power.getRegion()));
|
add(new Image(Icon.power.getRegion()));
|
||||||
add(new Element(){
|
add(new Element(){
|
||||||
@Override
|
@Override
|
||||||
public void draw(){
|
public void draw(){
|
||||||
Building entity = getUnit();
|
Building entity = getTarget();
|
||||||
float max = entity.block.consumes.getPower().usage;
|
float max = entity.block.consumes.getPower().usage;
|
||||||
float v = entity.power.status * entity.power.graph.getLastScaledPowerIn();
|
float v = entity.power.status * entity.power.graph.getLastScaledPowerIn();
|
||||||
|
|
||||||
@@ -318,14 +318,14 @@ public class HudUi {
|
|||||||
t.add(new Image(){
|
t.add(new Image(){
|
||||||
{
|
{
|
||||||
update(() -> {
|
update(() -> {
|
||||||
if(getUnit() instanceof Unit && ((Unit)getUnit()).stack().item != null && ((Unit)getUnit()).stack.amount > 0)
|
if(getTarget() instanceof Unit && ((Unit) getTarget()).stack().item != null && ((Unit) getTarget()).stack.amount > 0)
|
||||||
setDrawable(((Unit)getUnit()).stack().item.uiIcon);
|
setDrawable(((Unit) getTarget()).stack().item.uiIcon);
|
||||||
else setDrawable(Core.atlas.find("clear"));
|
else setDrawable(Core.atlas.find("clear"));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public void draw() {
|
public void draw() {
|
||||||
if(getUnit() instanceof Building) return;
|
if(getTarget() instanceof Building) return;
|
||||||
super.draw();
|
super.draw();
|
||||||
}
|
}
|
||||||
}.setScaling(Scaling.fit)).size(Scl.scl(30f)).padBottom(Scl.scl(4 * 8f)).padRight(Scl.scl(6 * 8f));
|
}.setScaling(Scaling.fit)).size(Scl.scl(30f)).padBottom(Scl.scl(4 * 8f)).padRight(Scl.scl(6 * 8f));
|
||||||
@@ -364,9 +364,9 @@ public class HudUi {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
TextureRegion region = Items.copper.uiIcon;
|
TextureRegion region = Items.copper.uiIcon;
|
||||||
if(getUnit() instanceof Unit && ((Unit)getUnit()).type() != null){
|
if(getTarget() instanceof Unit && ((Unit) getTarget()).type() != null){
|
||||||
if(((Unit)getUnit()).type().ammoType == AmmoTypes.thorium) region = Items.thorium.uiIcon;
|
if(((Unit) getTarget()).type().ammoType == AmmoTypes.thorium) region = Items.thorium.uiIcon;
|
||||||
if(((Unit)getUnit()).type().ammoType == AmmoTypes.power || ((Unit)getUnit()).type().ammoType == AmmoTypes.powerLow || ((Unit)getUnit()).type().ammoType == AmmoTypes.powerHigh) region = Icon.powerSmall.getRegion();
|
if(((Unit) getTarget()).type().ammoType == AmmoTypes.power || ((Unit) getTarget()).type().ammoType == AmmoTypes.powerLow || ((Unit) getTarget()).type().ammoType == AmmoTypes.powerHigh) region = Icon.powerSmall.getRegion();
|
||||||
}
|
}
|
||||||
setDrawable(region);
|
setDrawable(region);
|
||||||
});
|
});
|
||||||
@@ -379,15 +379,15 @@ public class HudUi {
|
|||||||
public void addWeapon(){
|
public void addWeapon(){
|
||||||
weapon = new Table(tx -> {
|
weapon = new Table(tx -> {
|
||||||
tx.left().defaults().minSize(Scl.scl(12 * 8f));
|
tx.left().defaults().minSize(Scl.scl(12 * 8f));
|
||||||
weaponamount = ((Unit)getUnit()).type.weapons.size;
|
weaponamount = ((Unit) getTarget()).type.weapons.size;
|
||||||
tx.add(new Table(scene.getStyle(Button.ButtonStyle.class).up, tt -> {
|
tx.add(new Table(scene.getStyle(Button.ButtonStyle.class).up, tt -> {
|
||||||
tt.left().top().defaults().width(Scl.scl(24/3f * 8f)).minHeight(Scl.scl(12/3f * 8f));
|
tt.left().top().defaults().width(Scl.scl(24/3f * 8f)).minHeight(Scl.scl(12/3f * 8f));
|
||||||
|
|
||||||
for(int r = 0; r < ((Unit)getUnit()).type.weapons.size; r++){
|
for(int r = 0; r < ((Unit) getTarget()).type.weapons.size; r++){
|
||||||
Weapon weapon = ((Unit)getUnit()).type.weapons.get(r);
|
Weapon weapon = ((Unit) getTarget()).type.weapons.get(r);
|
||||||
WeaponMount mount = ((Unit)getUnit()).mounts[r];
|
WeaponMount mount = ((Unit) getTarget()).mounts[r];
|
||||||
TextureRegion region = !weapon.name.equals("") && weapon.outlineRegion.found() ? weapon.outlineRegion : ((Unit)getUnit()).type.uiIcon;
|
TextureRegion region = !weapon.name.equals("") && weapon.outlineRegion.found() ? weapon.outlineRegion : ((Unit) getTarget()).type.uiIcon;
|
||||||
if(((Unit)getUnit()).type.weapons.size > 1 && r % 3 == 0) tt.row();
|
if(((Unit) getTarget()).type.weapons.size > 1 && r % 3 == 0) tt.row();
|
||||||
else if(r % 3 == 0) tt.row();
|
else if(r % 3 == 0) tt.row();
|
||||||
tt.table(weapontable -> {
|
tt.table(weapontable -> {
|
||||||
weapontable.left();
|
weapontable.left();
|
||||||
@@ -466,10 +466,10 @@ public class HudUi {
|
|||||||
add(new Table(ttt -> ttt.add(new Image(){{
|
add(new Table(ttt -> ttt.add(new Image(){{
|
||||||
update(() -> {
|
update(() -> {
|
||||||
TextureRegion region = Core.atlas.find("clear");
|
TextureRegion region = Core.atlas.find("clear");
|
||||||
if(getUnit() instanceof Unit && ((Unit)getUnit()).type() != null) region = ((Unit)getUnit()).type().uiIcon;
|
if(getTarget() instanceof Unit && ((Unit) getTarget()).type() != null) region = ((Unit) getTarget()).type().uiIcon;
|
||||||
else if(getUnit() instanceof Building && ((Building)getUnit()).block() != null) {
|
else if(getTarget() instanceof Building && ((Building) getTarget()).block() != null) {
|
||||||
if(getUnit() instanceof ConstructBlock.ConstructBuild) region = ((ConstructBlock.ConstructBuild) getUnit()).current.uiIcon;
|
if(getTarget() instanceof ConstructBlock.ConstructBuild) region = ((ConstructBlock.ConstructBuild) getTarget()).current.uiIcon;
|
||||||
else region = ((Building) getUnit()).block.uiIcon;
|
else region = ((Building) getTarget()).block.uiIcon;
|
||||||
}
|
}
|
||||||
setDrawable(region);
|
setDrawable(region);
|
||||||
});
|
});
|
||||||
@@ -482,12 +482,12 @@ public class HudUi {
|
|||||||
}){
|
}){
|
||||||
@Override
|
@Override
|
||||||
public void draw() {
|
public void draw() {
|
||||||
if(getUnit() instanceof Building) return;
|
if(getTarget() instanceof Building) return;
|
||||||
super.draw();
|
super.draw();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
add(new Table(temp -> {
|
add(new Table(temp -> {
|
||||||
Label label = new Label(() -> (getUnit() instanceof Unit && ((Unit)getUnit()).type() != null ? (int)((Unit)getUnit()).type().armor+"" : ""));
|
Label label = new Label(() -> (getTarget() instanceof Unit && ((Unit) getTarget()).type() != null ? (int)((Unit) getTarget()).type().armor+"" : ""));
|
||||||
label.setColor(Pal.surge);
|
label.setColor(Pal.surge);
|
||||||
label.setFontScale(0.5f);
|
label.setFontScale(0.5f);
|
||||||
temp.add(label).center();
|
temp.add(label).center();
|
||||||
@@ -495,7 +495,7 @@ public class HudUi {
|
|||||||
}){
|
}){
|
||||||
@Override
|
@Override
|
||||||
public void draw() {
|
public void draw() {
|
||||||
if(getUnit() instanceof Building) return;
|
if(getTarget() instanceof Building) return;
|
||||||
super.draw();
|
super.draw();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -504,21 +504,21 @@ public class HudUi {
|
|||||||
}};
|
}};
|
||||||
|
|
||||||
Label label = new Label(() -> {
|
Label label = new Label(() -> {
|
||||||
String name = "";if (getUnit() instanceof Unit && ((Unit) getUnit()).type() != null)
|
String name = "";if (getTarget() instanceof Unit && ((Unit) getTarget()).type() != null)
|
||||||
name = "[accent]" + ((Unit) getUnit()).type().localizedName + "[]";
|
name = "[accent]" + ((Unit) getTarget()).type().localizedName + "[]";
|
||||||
else if (getUnit() instanceof Building && ((Building) getUnit()).block() != null) {
|
else if (getTarget() instanceof Building && ((Building) getTarget()).block() != null) {
|
||||||
if(getUnit() instanceof ConstructBlock.ConstructBuild) name = "[accent]" + ((ConstructBlock.ConstructBuild) getUnit()).current.localizedName + "[]";
|
if(getTarget() instanceof ConstructBlock.ConstructBuild) name = "[accent]" + ((ConstructBlock.ConstructBuild) getTarget()).current.localizedName + "[]";
|
||||||
else name = "[accent]" + ((Building) getUnit()).block.localizedName + "[]";
|
else name = "[accent]" + ((Building) getTarget()).block.localizedName + "[]";
|
||||||
}
|
}
|
||||||
return name;
|
return name;
|
||||||
});
|
});
|
||||||
|
|
||||||
label.setFontScale(Scl.scl());
|
label.setFontScale(Scl.scl());
|
||||||
TextButton button = Elem.newButton("?", Styles.clearPartialt, () -> {
|
TextButton button = Elem.newButton("?", Styles.clearPartialt, () -> {
|
||||||
if (getUnit() instanceof Unit && ((Unit) getUnit()).type() != null)
|
if (getTarget() instanceof Unit && ((Unit) getTarget()).type() != null)
|
||||||
ui.content.show(((Unit) getUnit()).type());
|
ui.content.show(((Unit) getTarget()).type());
|
||||||
else if (getUnit() instanceof Buildingc && ((Buildingc) getUnit()).block() != null) {
|
else if (getTarget() instanceof Buildingc && ((Buildingc) getTarget()).block() != null) {
|
||||||
ui.content.show(((Buildingc) getUnit()).block());
|
ui.content.show(((Buildingc) getTarget()).block());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -549,17 +549,17 @@ public class HudUi {
|
|||||||
}).padRight(Scl.scl(24 * 8f));
|
}).padRight(Scl.scl(24 * 8f));
|
||||||
table.row();
|
table.row();
|
||||||
table.update(() -> {
|
table.update(() -> {
|
||||||
strings = info.returnStrings(getUnit());
|
strings = info.returnStrings(getTarget());
|
||||||
numbers = info.returnNumbers(getUnit());
|
numbers = info.returnNumbers(getTarget());
|
||||||
colors = info.returnColors(getUnit());
|
colors = info.returnColors(getTarget());
|
||||||
if(getUnit() instanceof Turret.TurretBuild){
|
if(getTarget() instanceof Turret.TurretBuild){
|
||||||
if(((Turret.TurretBuild)getUnit()).charging) charge += Time.delta;
|
if(((Turret.TurretBuild) getTarget()).charging) charge += Time.delta;
|
||||||
else charge = 0f;
|
else charge = 0f;
|
||||||
}
|
}
|
||||||
if (settings.getBool("weaponui")
|
if (settings.getBool("weaponui")
|
||||||
&& getUnit() instanceof Unit
|
&& getTarget() instanceof Unit
|
||||||
&& ((Unit)getUnit()).type != null
|
&& ((Unit) getTarget()).type != null
|
||||||
&& weaponamount != ((Unit)getUnit()).type.weapons.size) {
|
&& weaponamount != ((Unit) getTarget()).type.weapons.size) {
|
||||||
table.removeChild(weapon);
|
table.removeChild(weapon);
|
||||||
addWeapon();
|
addWeapon();
|
||||||
table.row();
|
table.row();
|
||||||
|
|||||||
Reference in New Issue
Block a user