mirror of
https://github.com/yawaflua/Informatis.git
synced 2025-12-10 03:59:26 +02:00
h
This commit is contained in:
@@ -54,14 +54,12 @@ public class SUtils {
|
|||||||
return new ScaledNinePatchDrawable(patch, 1);
|
return new ScaledNinePatchDrawable(patch, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String floatFormat(float number){
|
public static <T extends Number> String formatNumber(T number){
|
||||||
if(number >= 1000) return UI.formatAmount((long)number);
|
return formatNumber(number, 1);
|
||||||
return Strings.fixed(number, 1);
|
|
||||||
}
|
}
|
||||||
|
public static <T extends Number> String formatNumber(T number, int step){
|
||||||
public static String floatFormat(int number){
|
if(number.intValue() >= 1000) return UI.formatAmount(number.longValue());
|
||||||
if(number >= 1000) return UI.formatAmount(number);
|
return Strings.fixed(number.floatValue(), step);
|
||||||
return String.valueOf(number);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static float bulletRange(BulletType b) {
|
public static float bulletRange(BulletType b) {
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package unitinfo.core;
|
package unitinfo.core;
|
||||||
|
|
||||||
import arc.graphics.*;
|
import arc.graphics.*;
|
||||||
|
import arc.graphics.g2d.TextureRegion;
|
||||||
import arc.math.*;
|
import arc.math.*;
|
||||||
import arc.struct.*;
|
import arc.struct.*;
|
||||||
import arc.util.*;
|
import arc.util.*;
|
||||||
@@ -25,250 +26,203 @@ import mindustry.world.consumers.*;
|
|||||||
|
|
||||||
import java.lang.reflect.*;
|
import java.lang.reflect.*;
|
||||||
|
|
||||||
import static unitinfo.SUtils.floatFormat;
|
import static unitinfo.SUtils.*;
|
||||||
import static arc.Core.*;
|
import static arc.Core.*;
|
||||||
import static mindustry.Vars.*;
|
import static mindustry.Vars.*;
|
||||||
|
import static unitinfo.SVars.*;
|
||||||
|
import static unitinfo.ui.SIcons.*;
|
||||||
|
|
||||||
public class BarInfo {
|
public class BarInfo {
|
||||||
public static Seq<String> strings = Seq.with("","","","","","");
|
public static Seq<BarData> data = new Seq<>();
|
||||||
public static FloatSeq numbers = FloatSeq.with(0f,0f,0f,0f,0f,0f);
|
|
||||||
public static Seq<Color> colors = Seq.with(Color.clear,Color.clear,Color.clear,Color.clear,Color.clear,Color.clear);
|
|
||||||
|
|
||||||
public static <T extends Teamc> void getInfo(T target) throws IllegalAccessException, NoSuchFieldException {
|
public static <T extends Teamc> void getInfo(T target) throws IllegalAccessException, NoSuchFieldException {
|
||||||
for(int i = 0; i < 6; i++) { //init
|
data.clear();
|
||||||
strings.set(i, bundle.get("empty"));
|
|
||||||
colors.set(i, Color.clear);
|
|
||||||
numbers.set(i, 0f);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if(target instanceof Healthc healthc){
|
if(target instanceof Healthc healthc){
|
||||||
strings.set(0, bundle.format("shar-stat.health", floatFormat(healthc.health())));
|
float pro = healthc.health();
|
||||||
colors.set(0, Pal.health);
|
data.add(new BarData(bundle.format("shar-stat.health", formatNumber(pro)), Pal.health, pro, health));
|
||||||
numbers.set(0, healthc.healthf());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(target instanceof Unit unit){
|
||||||
|
float max = ((ShieldRegenFieldAbility) content.units().copy().max(ut -> {
|
||||||
|
ShieldRegenFieldAbility ability = (ShieldRegenFieldAbility) ut.abilities.find(ab -> ab instanceof ShieldRegenFieldAbility);
|
||||||
|
if(ability == null) return 0;
|
||||||
|
return ability.max;
|
||||||
|
}).abilities.find(abil -> abil instanceof ShieldRegenFieldAbility)).max;
|
||||||
|
float commands = Groups.unit.count(u -> u.controller() instanceof FormationAI && ((FormationAI)u.controller()).leader == target);
|
||||||
|
|
||||||
if(target instanceof Turret.TurretBuild turret){
|
data.add(new BarData(bundle.format("shar-stat.shield", formatNumber(unit.shield())), Pal.surge, unit.shield() / max, shield));
|
||||||
strings.set(1, bundle.format("shar-stat.reload", floatFormat((turret.reload / ((Turret)turret.block).reloadTime) * 100f)));
|
data.add(new BarData(bundle.format("shar-stat.capacity", unit.stack.item.localizedName, formatNumber(unit.stack.amount), formatNumber(unit.type.itemCapacity)), unit.stack.amount > 0 && unit.stack().item != null ? unit.stack.item.color.cpy().lerp(Color.white, 0.15f) : Color.white, unit.stack.amount / (unit.type.itemCapacity * 1f), item));
|
||||||
colors.set(1, Pal.accent.cpy().lerp(Color.orange, Mathf.clamp((turret.reload / ((Turret)turret.block).reloadTime))));
|
data.add(new BarData(bundle.format("shar-stat.commandUnits", formatNumber(commands), formatNumber(unit.type().commandLimit)), Pal.powerBar.cpy().lerp(Pal.surge.cpy().mul(Pal.lighterOrange), Mathf.absin(Time.time, 7f / (1f + Mathf.clamp(commands / (unit.type().commandLimit * 1f))), 1f)), commands / (unit.type().commandLimit * 1f)));
|
||||||
numbers.set(1, turret.reload / ((Turret)turret.block).reloadTime);
|
if(target instanceof Payloadc pay) data.add(new BarData(bundle.format("shar-stat.payloadCapacity", formatNumber(Mathf.round(Mathf.sqrt(pay.payloadUsed()))), formatNumber(Mathf.round(Mathf.sqrt(unit.type().payloadCapacity)))), Pal.items, pay.payloadUsed() / unit.type().payloadCapacity));
|
||||||
|
if(state.rules.unitAmmo) data.add(new BarData(bundle.format("shar-stat.ammos", formatNumber(unit.ammo()), formatNumber(unit.type().ammoCapacity)), unit.type().ammoType.color(), unit.ammof()));
|
||||||
}
|
}
|
||||||
else if(target instanceof MassDriver.MassDriverBuild mass){
|
|
||||||
strings.set(1, bundle.format("shar-stat.reload", floatFormat(mass.reload * 100f)));
|
else if(target instanceof Building build){
|
||||||
colors.set(1, Pal.accent.cpy().lerp(Color.orange, mass.reload));
|
if(build.block.hasLiquids) data.add(new BarData(bundle.format("shar-stat.capacity", build.liquids.currentAmount() < 0.01f ? build.liquids.current().localizedName : bundle.get("bar.liquid"), formatNumber(build.liquids.currentAmount()), formatNumber(build.block.liquidCapacity)), build.liquids.current().color, build.liquids.currentAmount() / build.block.liquidCapacity, liquid));
|
||||||
numbers.set(1, mass.reload);
|
|
||||||
|
if(build.block.hasPower && build.block.consumes.hasPower()){
|
||||||
|
ConsumePower cons = build.block.consumes.getPower();
|
||||||
|
data.add(new BarData(bundle.format("shar-stat.power", formatNumber(build.power.status * 60f * (cons.buffered ? cons.capacity : cons.usage)), formatNumber(60f * (cons.buffered ? cons.capacity : cons.usage))), Pal.powerBar, Mathf.zero(cons.requestedPower(build)) && build.power.graph.getPowerProduced() + build.power.graph.getBatteryStored() > 0f ? 1f : build.power.status, power));
|
||||||
}
|
}
|
||||||
else if(target instanceof Unit unit && unit.type != null){
|
if(build.block.hasItems) {
|
||||||
float max1 = ((ShieldRegenFieldAbility)content.units().copy().filter(ut -> ut.abilities.contains(abil -> abil instanceof ShieldRegenFieldAbility)).sort(ut -> ((ShieldRegenFieldAbility)ut.abilities.find(abil -> abil instanceof ShieldRegenFieldAbility)).max).peek().abilities.find(abil -> abil instanceof ShieldRegenFieldAbility)).max;
|
float value;
|
||||||
float max2 = 0f;
|
if (target instanceof CoreBlock.CoreBuild cb) value = cb.storageCapacity * content.items().count(UnlockableContent::unlockedNow);
|
||||||
ForceFieldAbility ffa;
|
else if(target instanceof StorageBlock.StorageBuild sb && !sb.canPickup() && sb.linkedCore instanceof CoreBlock.CoreBuild cb) value = cb.storageCapacity * content.items().count(UnlockableContent::unlockedNow);
|
||||||
if((ffa = (ForceFieldAbility) unit.type().abilities.find(abil -> abil instanceof ForceFieldAbility)) != null) max2 = ffa.max;
|
else value = build.block.itemCapacity;
|
||||||
strings.set(1, bundle.format("shar-stat.shield", floatFormat(unit.shield())));
|
data.add(new BarData(bundle.format("shar-stat.capacity", bundle.get("category.items"), formatNumber(build.items.total()), value), Pal.items, build.items.total() / value, item));
|
||||||
colors.set(1, Pal.surge);
|
|
||||||
numbers.set(1, unit.shield() / Math.max(max1, max2));
|
|
||||||
}
|
}
|
||||||
else if(target instanceof ForceProjector.ForceBuild force){
|
}
|
||||||
|
|
||||||
|
if(target instanceof ReloadTurret.ReloadTurretBuild || target instanceof MassDriver.MassDriverBuild){
|
||||||
|
float pro;
|
||||||
|
if(target instanceof ReloadTurret.ReloadTurretBuild turret) pro = turret.reload / ((Turret)turret.block).reloadTime;
|
||||||
|
else {
|
||||||
|
MassDriver.MassDriverBuild mass = (MassDriver.MassDriverBuild) target;
|
||||||
|
pro = mass.reload;
|
||||||
|
}
|
||||||
|
data.add(new BarData(bundle.format("shar-stat.reload", formatNumber(pro * 100f)), Pal.accent.cpy().lerp(Color.orange, pro), pro, reload));
|
||||||
|
}
|
||||||
|
|
||||||
|
if(target instanceof ForceProjector.ForceBuild force){
|
||||||
ForceProjector forceBlock = (ForceProjector) force.block;
|
ForceProjector forceBlock = (ForceProjector) force.block;
|
||||||
float max = forceBlock.shieldHealth + forceBlock.phaseShieldBoost * force.phaseHeat;
|
float max = forceBlock.shieldHealth + forceBlock.phaseShieldBoost * force.phaseHeat;
|
||||||
strings.set(1, bundle.format("shar-stat.shield", floatFormat(max-force.buildup), floatFormat(max)));
|
data.add(new BarData(bundle.format("shar-stat.shield", formatNumber(max-force.buildup), formatNumber(max)), Pal.shield, (max-force.buildup)/max, shield));
|
||||||
colors.set(1, Pal.shield);
|
|
||||||
numbers.set(1, (max-force.buildup)/max);
|
|
||||||
}
|
}
|
||||||
else if(target instanceof MendProjector.MendBuild mend){
|
|
||||||
strings.set(1, bundle.format("shar-stat.progress", floatFormat((float) mend.sense(LAccess.progress) * 100f)));
|
if(target instanceof MendProjector.MendBuild || target instanceof OverdriveProjector.OverdriveBuild || target instanceof ConstructBlock.ConstructBuild || target instanceof Reconstructor.ReconstructorBuild || target instanceof UnitFactory.UnitFactoryBuild || target instanceof Drill.DrillBuild || target instanceof GenericCrafter.GenericCrafterBuild) {
|
||||||
colors.set(1, Pal.heal);
|
float pro;
|
||||||
numbers.set(1, (float) mend.sense(LAccess.progress));
|
if(target instanceof MendProjector.MendBuild mend){
|
||||||
|
pro = (float) mend.sense(LAccess.progress);
|
||||||
|
Tmp.c1.set(Pal.heal);
|
||||||
}
|
}
|
||||||
else if(target instanceof OverdriveProjector.OverdriveBuild over){
|
else if(target instanceof OverdriveProjector.OverdriveBuild over){
|
||||||
|
OverdriveProjector block = (OverdriveProjector)over.block;
|
||||||
Field ohno = OverdriveProjector.OverdriveBuild.class.getDeclaredField("charge");
|
Field ohno = OverdriveProjector.OverdriveBuild.class.getDeclaredField("charge");
|
||||||
ohno.setAccessible(true);
|
ohno.setAccessible(true);
|
||||||
float charge = (float) ohno.get(over);
|
pro = (float) ohno.get(over)/((OverdriveProjector)over.block).reload;
|
||||||
strings.set(1, bundle.format("shar-stat.progress", floatFormat(Mathf.clamp(charge/((OverdriveProjector)over.block).reload) * 100f)));
|
Tmp.c1.set(Color.valueOf("feb380"));
|
||||||
colors.set(1, Color.valueOf("feb380"));
|
|
||||||
numbers.set(1, Mathf.clamp(charge/((OverdriveProjector)over.block).reload));
|
data.add(new BarData(bundle.format("bar.boost", (int)(over.realBoost() * 100)), Pal.accent, over.realBoost() / (block.hasBoost ? block.speedBoost + block.speedBoostPhase : block.speedBoost)));
|
||||||
}
|
}
|
||||||
else if(target instanceof ConstructBlock.ConstructBuild build){
|
else if(target instanceof ConstructBlock.ConstructBuild construct){
|
||||||
strings.set(1, bundle.format("shar-stat.progress", floatFormat(build.progress * 100)));
|
pro = construct.progress;
|
||||||
colors.set(1, Pal.darkerMetal);
|
Tmp.c1.set(Pal.darkerMetal);
|
||||||
numbers.set(1, build.progress);
|
}
|
||||||
|
else if(target instanceof UnitFactory.UnitFactoryBuild factory){
|
||||||
|
pro = factory.fraction();
|
||||||
|
Tmp.c1.set(Pal.darkerMetal);
|
||||||
|
|
||||||
|
if(factory.unit() == null) data.add(new BarData("[lightgray]" + Iconc.cancel, Pal.power, 0f));
|
||||||
|
else {
|
||||||
|
float value = factory.team.data().countType(factory.unit());
|
||||||
|
data.add(new BarData(bundle.format("bar.unitcap", Fonts.getUnicodeStr(factory.unit().name), formatNumber(value), formatNumber(Units.getCap(factory.team))), Pal.power, value / Units.getCap(factory.team)));
|
||||||
}
|
}
|
||||||
else if(target instanceof UnitFactory.UnitFactoryBuild build){
|
|
||||||
strings.set(1, bundle.format("shar-stat.progress", floatFormat(build.fraction() * 100f)));
|
|
||||||
colors.set(1, Pal.darkerMetal);
|
|
||||||
numbers.set(1, build.fraction());
|
|
||||||
}
|
}
|
||||||
else if(target instanceof Reconstructor.ReconstructorBuild reconstruct){
|
else if(target instanceof Reconstructor.ReconstructorBuild reconstruct){
|
||||||
strings.set(1, bundle.format("shar-stat.progress", floatFormat(reconstruct.fraction() * 100)));
|
pro = reconstruct.fraction();
|
||||||
colors.set(1, Pal.darkerMetal);
|
Tmp.c1.set(Pal.darkerMetal);
|
||||||
numbers.set(1, reconstruct.fraction());
|
|
||||||
|
if(reconstruct.unit() == null) data.add(new BarData("[lightgray]" + Iconc.cancel, Pal.power, 0f));
|
||||||
|
else {
|
||||||
|
float value = reconstruct.team.data().countType(reconstruct.unit());
|
||||||
|
data.add(new BarData(bundle.format("bar.unitcap", Fonts.getUnicodeStr(reconstruct.unit().name), formatNumber(value), formatNumber(Units.getCap(reconstruct.team))), Pal.power, value / Units.getCap(reconstruct.team)));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else if(target instanceof Drill.DrillBuild drill){
|
else if(target instanceof Drill.DrillBuild drill){
|
||||||
strings.set(1, bundle.format("shar-stat.progress", floatFormat((float) drill.sense(LAccess.progress) * 100f)));
|
pro = (float) drill.sense(LAccess.progress);
|
||||||
colors.set(1, drill.dominantItem == null ? Pal.items : drill.dominantItem.color);
|
Tmp.c1.set(drill.dominantItem == null ? Pal.items : drill.dominantItem.color);
|
||||||
numbers.set(1, (float) drill.sense(LAccess.progress));
|
|
||||||
|
data.add(new BarData(bundle.format("bar.drillspeed", formatNumber(drill.lastDrillSpeed * 60 * drill.timeScale)), Pal.ammo, drill.warmup));
|
||||||
}
|
}
|
||||||
else if(target instanceof GenericCrafter.GenericCrafterBuild crafter){
|
else {
|
||||||
|
GenericCrafter.GenericCrafterBuild crafter = (GenericCrafter.GenericCrafterBuild) target;
|
||||||
GenericCrafter block = (GenericCrafter) crafter.block;
|
GenericCrafter block = (GenericCrafter) crafter.block;
|
||||||
|
|
||||||
|
pro = (float) crafter.sense(LAccess.progress);
|
||||||
if(block.outputItem != null) Tmp.c1.set(block.outputItem.item.color);
|
if(block.outputItem != null) Tmp.c1.set(block.outputItem.item.color);
|
||||||
else if(block.outputLiquid != null) Tmp.c1.set(block.outputLiquid.liquid.color);
|
else if(block.outputLiquid != null) Tmp.c1.set(block.outputLiquid.liquid.color);
|
||||||
else Tmp.c1.set(Pal.items);
|
else Tmp.c1.set(Pal.items);
|
||||||
strings.set(1, bundle.format("shar-stat.progress", floatFormat((float) crafter.sense(LAccess.progress) * 100f)));
|
|
||||||
colors.set(1, Tmp.c1);
|
|
||||||
numbers.set(1, (float) crafter.sense(LAccess.progress));
|
|
||||||
}
|
}
|
||||||
else if(target instanceof PowerNode.PowerNodeBuild node){
|
|
||||||
strings.set(1, bundle.format("shar-stat.power", floatFormat(node.power.graph.getLastPowerStored()), floatFormat(node.power.graph.getLastCapacity())));
|
data.add(new BarData(bundle.format("shar-stat.progress", formatNumber(pro * 100f)), Tmp.c1, pro));
|
||||||
colors.set(1, Pal.powerBar);
|
|
||||||
numbers.set(1, node.power.graph.getLastPowerStored() / node.power.graph.getLastCapacity());
|
|
||||||
}
|
}
|
||||||
else if(target instanceof PowerGenerator.GeneratorBuild generator){
|
|
||||||
strings.set(1, bundle.format("shar-stat.powerIn", floatFormat(generator.getPowerProduction() * generator.timeScale() * 60f)));
|
if(target instanceof PowerGenerator.GeneratorBuild generator){
|
||||||
colors.set(1, Pal.powerBar);
|
data.add(new BarData(bundle.format("shar-stat.powerIn", formatNumber(generator.getPowerProduction() * generator.timeScale() * 60f)), Pal.powerBar, generator.productionEfficiency, power));
|
||||||
numbers.set(1, generator.productionEfficiency);
|
}
|
||||||
|
|
||||||
|
if(target instanceof PowerNode.PowerNodeBuild || target instanceof PowerTurret.PowerTurretBuild) {
|
||||||
|
float value, max;
|
||||||
|
if(target instanceof PowerNode.PowerNodeBuild node){
|
||||||
|
max = node.power.graph.getLastPowerStored();
|
||||||
|
value = node.power.graph.getLastCapacity();
|
||||||
|
|
||||||
|
data.add(new BarData(bundle.format("bar.powerlines", node.power.links.size, ((PowerNode)node.block).maxNodes), Pal.items, (float)node.power.links.size / (float)((PowerNode)node.block).maxNodes));
|
||||||
|
data.add(new BarData(bundle.format("shar-stat.powerOut", "-" + formatNumber(node.power.graph.getLastScaledPowerOut() * 60f)), Pal.powerBar, node.power.graph.getLastScaledPowerOut() / node.power.graph.getLastScaledPowerIn(), power));
|
||||||
|
data.add(new BarData(bundle.format("shar-stat.powerIn", formatNumber(node.power.graph.getLastScaledPowerIn() * 60f)), Pal.powerBar, node.power.graph.getLastScaledPowerIn() / node.power.graph.getLastScaledPowerOut(), power));
|
||||||
|
data.add(new BarData(bundle.format("bar.powerbalance", (node.power.graph.getPowerBalance() >= 0 ? "+" : "") + formatNumber(node.power.graph.getPowerBalance() * 60)), Pal.powerBar, node.power.graph.getLastPowerProduced() / node.power.graph.getLastPowerNeeded(), power));
|
||||||
|
}
|
||||||
|
else { //TODO: why is this different
|
||||||
|
PowerTurret.PowerTurretBuild turret = (PowerTurret.PowerTurretBuild) target;
|
||||||
|
max = turret.block.consumes.getPower().usage;
|
||||||
|
value = turret.power.status * turret.power.graph.getLastScaledPowerIn();
|
||||||
|
}
|
||||||
|
|
||||||
|
data.add(new BarData(bundle.format("shar-stat.power", formatNumber(Math.max(value, max) * 60), formatNumber(max * 60)), Pal.power, value / max));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(target instanceof ItemTurret.ItemTurretBuild turret) {
|
if(target instanceof ItemTurret.ItemTurretBuild turret) {
|
||||||
ItemTurret block = (ItemTurret)turret.block;
|
ItemTurret block = (ItemTurret)turret.block;
|
||||||
strings.set(2, bundle.format("shar-stat.capacity", turret.hasAmmo() ? block.ammoTypes.findKey(turret.peekAmmo(), true).localizedName : bundle.get("stat.ammo"), floatFormat(turret.totalAmmo), floatFormat(block.maxAmmo)));
|
data.add(new BarData(bundle.format("shar-stat.capacity", turret.hasAmmo() ? block.ammoTypes.findKey(turret.peekAmmo(), true).localizedName : bundle.get("stat.ammo"), formatNumber(turret.totalAmmo), formatNumber(block.maxAmmo)), turret.hasAmmo() ? block.ammoTypes.findKey(turret.peekAmmo(), true).color : Pal.ammo, turret.totalAmmo / (float)block.maxAmmo, ammo));
|
||||||
colors.set(2, turret.hasAmmo() ? block.ammoTypes.findKey(turret.peekAmmo(), true).color : Pal.ammo);
|
|
||||||
numbers.set(2, turret.totalAmmo / (float)block.maxAmmo);
|
|
||||||
}
|
}
|
||||||
else if(target instanceof LiquidTurret.LiquidTurretBuild turret){
|
|
||||||
strings.set(2, bundle.format("shar-stat.capacity", turret.liquids.currentAmount() < 0.01f ? turret.liquids.current().localizedName : bundle.get("stat.ammo"), floatFormat(turret.liquids.get(turret.liquids.current())), floatFormat(turret.block.liquidCapacity)));
|
if(target instanceof LiquidTurret.LiquidTurretBuild turret){
|
||||||
colors.set(2, turret.liquids.current().color);
|
data.add(new BarData(bundle.format("shar-stat.capacity", turret.liquids.currentAmount() < 0.01f ? turret.liquids.current().localizedName : bundle.get("stat.ammo"), formatNumber(turret.liquids.get(turret.liquids.current())), formatNumber(turret.block.liquidCapacity)), turret.liquids.current().color, turret.liquids.get(turret.liquids.current()) / turret.block.liquidCapacity, liquid));
|
||||||
numbers.set(2, turret.liquids.get(turret.liquids.current()) / turret.block.liquidCapacity);
|
|
||||||
}
|
}
|
||||||
else if(target instanceof PowerTurret.PowerTurretBuild turret){
|
|
||||||
float max = turret.block.consumes.getPower().usage;
|
if(target instanceof AttributeCrafter.AttributeCrafterBuild || target instanceof ThermalGenerator.ThermalGeneratorBuild || (target instanceof SolidPump.SolidPumpBuild crafter && ((SolidPump)crafter.block).attribute != null)) {
|
||||||
float v = turret.power.status * turret.power.graph.getLastScaledPowerIn();
|
float display, pro;
|
||||||
strings.set(2, bundle.format("shar-stat.power", floatFormat(Math.min(v,max) * 60), floatFormat(max * 60)));
|
if (target instanceof AttributeCrafter.AttributeCrafterBuild crafter) {
|
||||||
colors.set(2, Pal.powerBar);
|
AttributeCrafter block = (AttributeCrafter) crafter.block;
|
||||||
numbers.set(2, v/max);
|
display = (block.baseEfficiency + Math.min(block.maxBoost, block.boostScale * block.sumAttribute(block.attribute, crafter.tileX(), crafter.tileY()))) * 100f;
|
||||||
|
pro = block.boostScale * crafter.attrsum / block.maxBoost;
|
||||||
}
|
}
|
||||||
else if(target instanceof Building b && b.block.hasItems) {
|
else if (target instanceof ThermalGenerator.ThermalGeneratorBuild thermal) {
|
||||||
if(target instanceof CoreBlock.CoreBuild cb){
|
ThermalGenerator block = (ThermalGenerator) thermal.block;
|
||||||
strings.set(2, bundle.format("shar-stat.capacity", bundle.get("category.items"), floatFormat(b.items.total()), floatFormat(cb.storageCapacity * content.items().count(UnlockableContent::unlockedNow))));
|
float max = content.blocks().max(b -> b instanceof Floor f && f.attributes != null ? f.attributes.get(block.attribute) : 0).asFloor().attributes.get(block.attribute);
|
||||||
numbers.set(2, cb.items.total() / (cb.storageCapacity * content.items().count(UnlockableContent::unlockedNow) * 1f));
|
display = block.sumAttribute(block.attribute, thermal.tileX(), thermal.tileY()) * 100;
|
||||||
}
|
pro = block.sumAttribute(block.attribute, thermal.tileX(), thermal.tileY()) / block.size / block.size / max;
|
||||||
else if(target instanceof StorageBlock.StorageBuild sb && !sb.canPickup() && sb.linkedCore instanceof CoreBlock.CoreBuild cb){
|
|
||||||
strings.set(2, bundle.format("shar-stat.capacity", bundle.get("category.items"), floatFormat(sb.items.total()), floatFormat(cb.storageCapacity * content.items().count(UnlockableContent::unlockedNow))));
|
|
||||||
numbers.set(2, sb.items.total() / (cb.storageCapacity * content.items().count(UnlockableContent::unlockedNow) * 1f));
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
strings.set(2, bundle.format("shar-stat.capacity", bundle.get("category.items"), floatFormat(b.items.total()), floatFormat(b.block.itemCapacity)));
|
SolidPump.SolidPumpBuild crafter = (SolidPump.SolidPumpBuild) target;
|
||||||
numbers.set(2, b.items.total() / (float) b.block.itemCapacity);
|
|
||||||
}
|
|
||||||
colors.set(2, Pal.items);
|
|
||||||
}
|
|
||||||
else if(target instanceof Unit unit && unit.type != null) {
|
|
||||||
strings.set(2, bundle.format("shar-stat.capacity", unit.stack.item.localizedName, floatFormat(unit.stack.amount), floatFormat(unit.type.itemCapacity)));
|
|
||||||
if(unit.stack.amount > 0 && unit.stack().item != null) colors.set(2, unit.stack.item.color.cpy().lerp(Color.white, 0.15f));
|
|
||||||
numbers.set(2, unit.stack.amount / (unit.type.itemCapacity * 1f));
|
|
||||||
}
|
|
||||||
else if(target instanceof PowerNode.PowerNodeBuild node){
|
|
||||||
strings.set(2, bundle.format("bar.powerlines", node.power.links.size, ((PowerNode)node.block).maxNodes));
|
|
||||||
colors.set(2, Pal.items);
|
|
||||||
numbers.set(2, (float)node.power.links.size / (float)((PowerNode)node.block).maxNodes);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if(target instanceof Unit unit && unit.type != null) {
|
|
||||||
strings.set(3, bundle.format("shar-stat.commandUnits", floatFormat(Groups.unit.count(u -> u.controller() instanceof FormationAI && ((FormationAI)u.controller()).leader == target)), floatFormat(unit.type().commandLimit)));
|
|
||||||
colors.set(3, 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 == target) / (unit.type().commandLimit * 1f))), 1f)));
|
|
||||||
numbers.set(3, Groups.unit.count(u -> u.controller() instanceof FormationAI && ((FormationAI)u.controller()).leader == target) / (unit.type().commandLimit * 1f));
|
|
||||||
}
|
|
||||||
else if(target instanceof UnitFactory.UnitFactoryBuild factory){
|
|
||||||
strings.set(3, factory.unit() == null ? "[lightgray]" + Iconc.cancel :
|
|
||||||
bundle.format("bar.unitcap", Fonts.getUnicodeStr(factory.unit().name), floatFormat(factory.team.data().countType(factory.unit())), floatFormat(Units.getCap(factory.team))));
|
|
||||||
colors.set(3, Pal.power);
|
|
||||||
numbers.set(3, factory.unit() == null ? 0f : (float)factory.team.data().countType(factory.unit()) / Units.getCap(factory.team));
|
|
||||||
}
|
|
||||||
else if(target instanceof Reconstructor.ReconstructorBuild reconstruct){
|
|
||||||
strings.set(3, reconstruct.unit() == null ? "[lightgray]" + Iconc.cancel :
|
|
||||||
bundle.format("bar.unitcap", Fonts.getUnicodeStr(reconstruct.unit().name), floatFormat(reconstruct.team.data().countType(reconstruct.unit())), floatFormat(Units.getCap(reconstruct.team))));
|
|
||||||
colors.set(3, Pal.power);
|
|
||||||
numbers.set(3, reconstruct.unit() == null ? 0f : (float)reconstruct.team.data().countType(reconstruct.unit()) / Units.getCap(reconstruct.team));
|
|
||||||
|
|
||||||
}
|
|
||||||
else if(target instanceof Drill.DrillBuild e){
|
|
||||||
strings.set(3, bundle.format("bar.drillspeed", floatFormat(e.lastDrillSpeed * 60 * e.timeScale)));
|
|
||||||
colors.set(3, Pal.ammo);
|
|
||||||
numbers.set(3, e.warmup);
|
|
||||||
}
|
|
||||||
else if(target instanceof AttributeCrafter.AttributeCrafterBuild crafter){
|
|
||||||
AttributeCrafter block = (AttributeCrafter) crafter.block;
|
|
||||||
strings.set(3, bundle.format("shar-stat.attr", (int)((block.baseEfficiency + Math.min(block.maxBoost, block.boostScale * block.sumAttribute(block.attribute, crafter.tileX(), crafter.tileY()))) * 100f)));
|
|
||||||
colors.set(3, Pal.ammo);
|
|
||||||
numbers.set(3, block.boostScale * crafter.attrsum / block.maxBoost);
|
|
||||||
}
|
|
||||||
else if(target instanceof SolidPump.SolidPumpBuild crafter && ((SolidPump)crafter.block).attribute != null){
|
|
||||||
SolidPump block = (SolidPump) crafter.block;
|
SolidPump block = (SolidPump) crafter.block;
|
||||||
float fraction = Math.max(crafter.validTiles + crafter.boost + (block.attribute == null ? 0 : block.attribute.env()), 0);
|
float fraction = Math.max(crafter.validTiles + crafter.boost + (block.attribute == null ? 0 : block.attribute.env()), 0);
|
||||||
float max = content.blocks().max(b -> b instanceof Floor f && f.attributes != null ? f.attributes.get(block.attribute) : 0).asFloor().attributes.get(block.attribute);
|
float max = content.blocks().max(b -> b instanceof Floor f && f.attributes != null ? f.attributes.get(block.attribute) : 0).asFloor().attributes.get(block.attribute);
|
||||||
int h = (int)(Math.max(block.sumAttribute(block.attribute, crafter.tileX(), crafter.tileY()) / block.size / block.size + block.baseEfficiency, 0f) * 100 * block.percentSolid(crafter.tileX(), crafter.tileY()));
|
display = Math.max(block.sumAttribute(block.attribute, crafter.tileX(), crafter.tileY()) / block.size / block.size + block.baseEfficiency, 0f) * 100 * block.percentSolid(crafter.tileX(), crafter.tileY());
|
||||||
strings.set(3, bundle.format("shar-stat.attr", h));
|
pro = fraction / max;
|
||||||
colors.set(3, Pal.ammo);
|
|
||||||
numbers.set(3, fraction / max);
|
|
||||||
}
|
|
||||||
else if(target instanceof ThermalGenerator.ThermalGeneratorBuild thermal){
|
|
||||||
ThermalGenerator block = (ThermalGenerator) thermal.block;
|
|
||||||
float max = content.blocks().max(b -> b instanceof Floor f && f.attributes != null ? f.attributes.get(block.attribute) : 0).asFloor().attributes.get(block.attribute);
|
|
||||||
strings.set(3, bundle.format("shar-stat.attr", block.sumAttribute(block.attribute, thermal.tileX(), thermal.tileY()) * 100));
|
|
||||||
colors.set(3, Pal.ammo);
|
|
||||||
numbers.set(3, block.sumAttribute(block.attribute, thermal.tileX(), thermal.tileY()) / block.size / block.size / max);
|
|
||||||
}
|
|
||||||
else if(target instanceof PowerNode.PowerNodeBuild node){
|
|
||||||
strings.set(3, bundle.format("bar.powerbalance", (node.power.graph.getPowerBalance() >= 0 ? "+" : "") + floatFormat(node.power.graph.getPowerBalance() * 60)));
|
|
||||||
colors.set(3, Pal.powerBar);
|
|
||||||
numbers.set(3, node.power.graph.getLastPowerProduced() / node.power.graph.getLastPowerNeeded());
|
|
||||||
}
|
|
||||||
else if(target instanceof OverdriveProjector.OverdriveBuild over){
|
|
||||||
OverdriveProjector block = (OverdriveProjector)over.block;
|
|
||||||
strings.set(3, bundle.format("bar.boost", (int)(over.realBoost() * 100)));
|
|
||||||
colors.set(3, Pal.accent);
|
|
||||||
numbers.set(3, over.realBoost() / (block.hasBoost ? block.speedBoost + block.speedBoostPhase : block.speedBoost));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
data.add(new BarData(bundle.format("shar-stat.attr", Mathf.round(display)), Pal.ammo, pro));
|
||||||
if(target instanceof Unit unit && unit.type != null && target instanceof Payloadc pay){
|
|
||||||
strings.set(4, bundle.format("shar-stat.payloadCapacity", floatFormat(Mathf.round(Mathf.sqrt(pay.payloadUsed()))), floatFormat(Mathf.round(Mathf.sqrt(unit.type().payloadCapacity)))));
|
|
||||||
colors.set(4, Pal.items);
|
|
||||||
numbers.set(4, pay.payloadUsed() / unit.type().payloadCapacity);
|
|
||||||
}
|
|
||||||
else if(target instanceof Building build){
|
|
||||||
if(target instanceof PowerNode.PowerNodeBuild node){
|
|
||||||
strings.set(4, bundle.format("shar-stat.powerOut", "-" + floatFormat(node.power.graph.getLastScaledPowerOut() * 60f)));
|
|
||||||
colors.set(4, Pal.powerBar);
|
|
||||||
numbers.set(4, node.power.graph.getLastScaledPowerOut() / node.power.graph.getLastScaledPowerIn());
|
|
||||||
}
|
|
||||||
else if(build.block.hasLiquids) {
|
|
||||||
strings.set(4, bundle.format("shar-stat.capacity", build.liquids.currentAmount() < 0.01f ? build.liquids.current().localizedName : bundle.get("bar.liquid"), floatFormat(build.liquids.currentAmount()), floatFormat(build.block.liquidCapacity)));
|
|
||||||
colors.set(4, build.liquids.current().color);
|
|
||||||
numbers.set(4, build.liquids.currentAmount() / build.block.liquidCapacity);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static class BarData {
|
||||||
|
public String name;
|
||||||
|
public Color color;
|
||||||
|
public float number;
|
||||||
|
public TextureRegion icon = clear;
|
||||||
|
|
||||||
if(target instanceof Unit unit && state.rules.unitAmmo && unit.type != null){
|
BarData(String name, Color color, float number) {
|
||||||
strings.set(5, bundle.format("shar-stat.ammos", floatFormat(unit.ammo()), floatFormat(unit.type().ammoCapacity)));
|
this.name = name;
|
||||||
colors.set(5, unit.type().ammoType.color());
|
this.color = color;
|
||||||
numbers.set(5, unit.ammof());
|
this.number = number;
|
||||||
}
|
|
||||||
else if(target instanceof Building build && build.block.hasPower){
|
|
||||||
if(target instanceof PowerNode.PowerNodeBuild node){
|
|
||||||
strings.set(5, bundle.format("shar-stat.powerIn", floatFormat(node.power.graph.getLastScaledPowerIn() * 60f)));
|
|
||||||
colors.set(5, Pal.powerBar);
|
|
||||||
numbers.set(5, node.power.graph.getLastScaledPowerIn() / node.power.graph.getLastScaledPowerOut());
|
|
||||||
}
|
|
||||||
else if(build.block.consumes.hasPower()){
|
|
||||||
ConsumePower cons = build.block.consumes.getPower();
|
|
||||||
if(cons.buffered) strings.set(5, bundle.format("shar-stat.power", floatFormat(build.power.status * cons.capacity * 60f), floatFormat(cons.capacity * 60f)));
|
|
||||||
else strings.set(5, bundle.format("shar-stat.power", floatFormat(build.power.status * cons.usage * 60f), floatFormat(cons.usage * 60f)));
|
|
||||||
colors.set(5, Pal.powerBar);
|
|
||||||
numbers.set(5, Mathf.zero(cons.requestedPower(build)) && build.power.graph.getPowerProduced() + build.power.graph.getBatteryStored() > 0f ? 1f : build.power.status);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BarData(String name, Color color, float number, TextureRegion icon) {
|
||||||
|
this(name, color, number);
|
||||||
|
this.icon = icon;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,9 +40,6 @@ public class SettingS {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void add(Table table){
|
public void add(Table table){
|
||||||
Slider slider = new Slider(min, max, step, false);
|
|
||||||
|
|
||||||
slider.setValue(settings.getInt(name));
|
|
||||||
|
|
||||||
Label value = new Label("", Styles.outlineLabel);
|
Label value = new Label("", Styles.outlineLabel);
|
||||||
Table content = new Table();
|
Table content = new Table();
|
||||||
@@ -51,11 +48,12 @@ public class SettingS {
|
|||||||
content.margin(3f, 33f, 3f, 33f);
|
content.margin(3f, 33f, 3f, 33f);
|
||||||
content.touchable = Touchable.disabled;
|
content.touchable = Touchable.disabled;
|
||||||
|
|
||||||
|
Slider slider = new Slider(min, max, step, false);
|
||||||
|
slider.setValue(settings.getInt(name));
|
||||||
slider.changed(() -> {
|
slider.changed(() -> {
|
||||||
settings.put(name, (int)slider.getValue());
|
settings.put(name, (int)slider.getValue());
|
||||||
value.setText(sp.get((int)slider.getValue()));
|
value.setText(sp.get((int)slider.getValue()));
|
||||||
});
|
});
|
||||||
|
|
||||||
slider.change();
|
slider.change();
|
||||||
|
|
||||||
addDesc(table.stack(slider, content).width(Math.min(Core.graphics.getWidth() / 1.2f, 460f)).left().padTop(4f).get());
|
addDesc(table.stack(slider, content).width(Math.min(Core.graphics.getWidth() / 1.2f, 460f)).left().padTop(4f).get());
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package unitinfo.ui;
|
|||||||
import arc.math.geom.Vec2;
|
import arc.math.geom.Vec2;
|
||||||
import arc.scene.Element;
|
import arc.scene.Element;
|
||||||
import arc.scene.ui.ScrollPane;
|
import arc.scene.ui.ScrollPane;
|
||||||
|
import mindustry.ui.Styles;
|
||||||
|
|
||||||
import static arc.Core.input;
|
import static arc.Core.input;
|
||||||
import static arc.Core.scene;
|
import static arc.Core.scene;
|
||||||
|
|||||||
@@ -3,6 +3,9 @@ package unitinfo.ui.window;
|
|||||||
import arc.Events;
|
import arc.Events;
|
||||||
import arc.graphics.g2d.*;
|
import arc.graphics.g2d.*;
|
||||||
import arc.math.geom.Geometry;
|
import arc.math.geom.Geometry;
|
||||||
|
import arc.scene.Element;
|
||||||
|
import arc.scene.style.Drawable;
|
||||||
|
import arc.struct.ObjectMap;
|
||||||
import mindustry.editor.MapEditor;
|
import mindustry.editor.MapEditor;
|
||||||
import mindustry.game.EventType;
|
import mindustry.game.EventType;
|
||||||
import mindustry.graphics.Layer;
|
import mindustry.graphics.Layer;
|
||||||
@@ -29,6 +32,7 @@ import mindustry.graphics.Pal;
|
|||||||
import mindustry.ui.Styles;
|
import mindustry.ui.Styles;
|
||||||
import mindustry.world.*;
|
import mindustry.world.*;
|
||||||
|
|
||||||
|
import static arc.Core.settings;
|
||||||
import static mindustry.Vars.*;
|
import static mindustry.Vars.*;
|
||||||
|
|
||||||
public class MapEditorWindow extends Window implements Updatable {
|
public class MapEditorWindow extends Window implements Updatable {
|
||||||
@@ -42,6 +46,7 @@ public class MapEditorWindow extends Window implements Updatable {
|
|||||||
|
|
||||||
boolean drawing;
|
boolean drawing;
|
||||||
int lastx, lasty;
|
int lastx, lasty;
|
||||||
|
float lastw, lasth;
|
||||||
|
|
||||||
public static Team drawTeam = Team.sharded;
|
public static Team drawTeam = Team.sharded;
|
||||||
public static Block drawBlock = Blocks.router;
|
public static Block drawBlock = Blocks.router;
|
||||||
@@ -54,6 +59,7 @@ public class MapEditorWindow extends Window implements Updatable {
|
|||||||
float mod = size % 1f;
|
float mod = size % 1f;
|
||||||
brushPolygons[i] = Geometry.pixelCircle(size, (index, x, y) -> Mathf.dst(x, y, index - mod, index - mod) <= size - 0.5f);
|
brushPolygons[i] = Geometry.pixelCircle(size, (index, x, y) -> Mathf.dst(x, y, index - mod, index - mod) <= size - 0.5f);
|
||||||
}
|
}
|
||||||
|
|
||||||
Events.run(EventType.Trigger.draw, ()->{
|
Events.run(EventType.Trigger.draw, ()->{
|
||||||
float cx = Core.camera.position.x, cy = Core.camera.position.y;
|
float cx = Core.camera.position.x, cy = Core.camera.position.y;
|
||||||
float scaling = 8;
|
float scaling = 8;
|
||||||
@@ -116,13 +122,33 @@ public class MapEditorWindow extends Window implements Updatable {
|
|||||||
search.setMessageText(Core.bundle.get("players.search")+"...");
|
search.setMessageText(Core.bundle.get("players.search")+"...");
|
||||||
window = table;
|
window = table;
|
||||||
|
|
||||||
|
table.left();
|
||||||
table.top().background(Styles.black8);
|
table.top().background(Styles.black8);
|
||||||
table.table(t->{
|
|
||||||
|
ObjectMap<Drawable, Element> displays = new ObjectMap<>();
|
||||||
|
displays.put(Icon.map, new Table(display -> {
|
||||||
|
display.table(t->{
|
||||||
t.left().background(Tex.underline2);
|
t.left().background(Tex.underline2);
|
||||||
t.label(()-> drawBlock ==null?"[gray]None[]":"[accent]"+ drawBlock.localizedName+"[] "+ drawBlock.emoji());
|
t.label(()-> drawBlock == null ? "[gray]None[]" : "[accent]" + drawBlock.localizedName + "[] "+ drawBlock.emoji());
|
||||||
t.add(search).growX().pad(8).name("search");
|
t.add(search).growX().pad(8).name("search");
|
||||||
}).growX().row();
|
}).growX().row();
|
||||||
table.add(new OverScrollPane(rebuild(), Styles.nonePane, scrollPos).disableScroll(true, false)).grow().name("editor-pane").row();
|
display.add(new OverScrollPane(rebuildEditor(), Styles.nonePane, scrollPos).disableScroll(true, false)).grow().name("editor-pane").row();
|
||||||
|
}));
|
||||||
|
displays.put(Icon.settings, new Table(display -> {
|
||||||
|
display.add(new OverScrollPane(rebuildRule(), Styles.nonePane, scrollPos).disableScroll(true, false)).grow().name("rule-pane").row();
|
||||||
|
}));
|
||||||
|
|
||||||
|
table.table(buttons -> {
|
||||||
|
buttons.top().left();
|
||||||
|
|
||||||
|
displays.each((icon, display) -> {
|
||||||
|
buttons.button(icon, Styles.clearTogglei, ()->{
|
||||||
|
Log.info(table.getChildren().get(table.getChildren().size-1));
|
||||||
|
if(table.getChildren().size > 1) table.getChildren().get(table.getChildren().size-1).remove();
|
||||||
|
table.add(display).grow();
|
||||||
|
}).row();
|
||||||
|
});
|
||||||
|
}).growY();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -130,7 +156,10 @@ public class MapEditorWindow extends Window implements Updatable {
|
|||||||
heat += Time.delta;
|
heat += Time.delta;
|
||||||
if(heat >= 60f) {
|
if(heat >= 60f) {
|
||||||
heat = 0f;
|
heat = 0f;
|
||||||
resetPane();
|
|
||||||
|
if(lastw != window.getWidth() || lasth != window.getHeight()) resetPane();
|
||||||
|
lastw = width;
|
||||||
|
lasth = height;
|
||||||
}
|
}
|
||||||
|
|
||||||
Tile tile = world.tileWorld(Core.input.mouseWorldX(), Core.input.mouseWorldY());
|
Tile tile = world.tileWorld(Core.input.mouseWorldX(), Core.input.mouseWorldY());
|
||||||
@@ -151,11 +180,31 @@ public class MapEditorWindow extends Window implements Updatable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void resetPane() {
|
void resetPane() {
|
||||||
|
Log.info("reseted");
|
||||||
ScrollPane pane = find("editor-pane");
|
ScrollPane pane = find("editor-pane");
|
||||||
pane.setWidget(rebuild());
|
if(pane != null) pane.setWidget(rebuildEditor());
|
||||||
}
|
}
|
||||||
|
|
||||||
Table rebuild() {
|
Table rebuildRule() {
|
||||||
|
return new Table(table -> {
|
||||||
|
table.top().left();
|
||||||
|
|
||||||
|
table.table(rules -> {
|
||||||
|
rules.top().left();
|
||||||
|
|
||||||
|
Label label = rules.add("Block Health: ").get();
|
||||||
|
Slider slider = new Slider(0, 100, 1, false);
|
||||||
|
slider.changed(() -> {
|
||||||
|
label.setText("Block Health: "+(int)slider.getValue()+"%");
|
||||||
|
});
|
||||||
|
slider.change();
|
||||||
|
slider.moved(hp->Groups.build.each(b->b.health(b.block.health*hp/100)));
|
||||||
|
rules.add(slider);
|
||||||
|
}).grow();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
Table rebuildEditor() {
|
||||||
return new Table(table-> {
|
return new Table(table-> {
|
||||||
table.top();
|
table.top();
|
||||||
Seq<Block> blocks = Vars.content.blocks().copy();
|
Seq<Block> blocks = Vars.content.blocks().copy();
|
||||||
@@ -214,8 +263,8 @@ public class MapEditorWindow extends Window implements Updatable {
|
|||||||
}
|
}
|
||||||
Label label = new Label("Brush: "+brushSize);
|
Label label = new Label("Brush: "+brushSize);
|
||||||
label.touchable = Touchable.disabled;
|
label.touchable = Touchable.disabled;
|
||||||
tools.stack(slider, label).width(window.getWidth()/5).center();
|
tools.stack(slider, label).width(getDisplayWidth()/5).center();
|
||||||
}).left().width(window.getWidth() / 2).margin(8f).growY();
|
}).left().width(getDisplayWidth() / 2).margin(8f).growY();
|
||||||
body.image().width(4f).height(body.getHeight()).color(Pal.gray).growY();
|
body.image().width(4f).height(body.getHeight()).color(Pal.gray).growY();
|
||||||
body.table(options -> {
|
body.table(options -> {
|
||||||
options.top().left();
|
options.top().left();
|
||||||
@@ -236,7 +285,7 @@ public class MapEditorWindow extends Window implements Updatable {
|
|||||||
}, () -> tool.mode = (tool.mode == mode ? -1 : mode)).update(b -> b.setChecked(tool.mode == mode)).margin(12f).growX().row();
|
}, () -> tool.mode = (tool.mode == mode ? -1 : mode)).update(b -> b.setChecked(tool.mode == mode)).margin(12f).growX().row();
|
||||||
}
|
}
|
||||||
}).grow();
|
}).grow();
|
||||||
}).left().width(window.getWidth() / 2).margin(8f).growY();
|
}).left().width(getDisplayWidth() / 2).margin(8f).growY();
|
||||||
}).grow();
|
}).grow();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -249,7 +298,7 @@ public class MapEditorWindow extends Window implements Updatable {
|
|||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
int row = 4;
|
int row = 4;
|
||||||
int max = Math.max(row, Math.round(window.getWidth()/2/8/row));
|
int max = Math.max(row, Math.round(getDisplayWidth()/2/8/row));
|
||||||
|
|
||||||
for(T item : items){
|
for(T item : items){
|
||||||
if(!item.unlockedNow()) continue;
|
if(!item.unlockedNow()) continue;
|
||||||
@@ -291,7 +340,7 @@ public class MapEditorWindow extends Window implements Updatable {
|
|||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
int row = 2;
|
int row = 2;
|
||||||
int max = Math.max(row, Math.round(window.getWidth()/2/8/row/2));
|
int max = Math.max(row, Math.round(getDisplayWidth()/2/8/row/2));
|
||||||
|
|
||||||
for(T item : items){
|
for(T item : items){
|
||||||
ImageButton button = cont.button(Tex.whiteui, Styles.clearToggleTransi, 24, () -> {
|
ImageButton button = cont.button(Tex.whiteui, Styles.clearToggleTransi, 24, () -> {
|
||||||
@@ -322,6 +371,10 @@ public class MapEditorWindow extends Window implements Updatable {
|
|||||||
}
|
}
|
||||||
float teamScroll;
|
float teamScroll;
|
||||||
|
|
||||||
|
float getDisplayWidth() {
|
||||||
|
return window.getWidth() - (window.find("buttons") == null ? 1 : window.find("buttons").getWidth());
|
||||||
|
}
|
||||||
|
|
||||||
public void drawBlocksReplace(int x, int y){
|
public void drawBlocksReplace(int x, int y){
|
||||||
drawBlocks(x, y, tile -> tile.block() != Blocks.air || drawBlock.isFloor());
|
drawBlocks(x, y, tile -> tile.block() != Blocks.air || drawBlock.isFloor());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package unitinfo.ui.window;
|
package unitinfo.ui.window;
|
||||||
|
|
||||||
|
import arc.Core;
|
||||||
import unitinfo.core.*;
|
import unitinfo.core.*;
|
||||||
import unitinfo.ui.*;
|
import unitinfo.ui.*;
|
||||||
import arc.graphics.Color;
|
import arc.graphics.Color;
|
||||||
@@ -20,11 +21,7 @@ import mindustry.type.StatusEffect;
|
|||||||
import mindustry.type.Weapon;
|
import mindustry.type.Weapon;
|
||||||
import mindustry.ui.Styles;
|
import mindustry.ui.Styles;
|
||||||
import mindustry.world.blocks.ConstructBlock;
|
import mindustry.world.blocks.ConstructBlock;
|
||||||
import mindustry.world.blocks.defense.ForceProjector;
|
|
||||||
import mindustry.world.blocks.defense.turrets.*;
|
|
||||||
import mindustry.world.blocks.distribution.MassDriver;
|
|
||||||
import mindustry.world.blocks.payloads.Payload;
|
import mindustry.world.blocks.payloads.Payload;
|
||||||
import mindustry.world.blocks.power.*;
|
|
||||||
|
|
||||||
import static unitinfo.SVars.*;
|
import static unitinfo.SVars.*;
|
||||||
import static unitinfo.SUtils.*;
|
import static unitinfo.SUtils.*;
|
||||||
@@ -33,7 +30,8 @@ import static mindustry.Vars.*;
|
|||||||
class UnitWindow extends Window {
|
class UnitWindow extends Window {
|
||||||
final Seq<Color> lastColors = Seq.with(Color.clear,Color.clear,Color.clear,Color.clear,Color.clear,Color.clear);
|
final Seq<Color> lastColors = Seq.with(Color.clear,Color.clear,Color.clear,Color.clear,Color.clear,Color.clear);
|
||||||
final Rect scissor = new Rect();
|
final Rect scissor = new Rect();
|
||||||
Vec2 scrollPos;
|
int bars = 6; //temp
|
||||||
|
Vec2 scrollPos = new Vec2(0, 0);
|
||||||
|
|
||||||
public UnitWindow() {
|
public UnitWindow() {
|
||||||
super(Icon.units, "unit");
|
super(Icon.units, "unit");
|
||||||
@@ -42,8 +40,7 @@ class UnitWindow extends Window {
|
|||||||
//TODO: add new UnitInfoDisplay(), new WeaponDisplay();
|
//TODO: add new UnitInfoDisplay(), new WeaponDisplay();
|
||||||
@Override
|
@Override
|
||||||
protected void build(Table table) {
|
protected void build(Table table) {
|
||||||
scrollPos = new Vec2(0,0);
|
scrollPos = new Vec2(0, 0);
|
||||||
|
|
||||||
table.top().background(Styles.black8);
|
table.top().background(Styles.black8);
|
||||||
table.table(tt -> {
|
table.table(tt -> {
|
||||||
tt.center();
|
tt.center();
|
||||||
@@ -92,28 +89,42 @@ class UnitWindow extends Window {
|
|||||||
table.image().height(4f).color((target==null?player.unit():target).team().color).growX().row();
|
table.image().height(4f).color((target==null?player.unit():target).team().color).growX().row();
|
||||||
table.add(new OverScrollPane(new Table(bars -> {
|
table.add(new OverScrollPane(new Table(bars -> {
|
||||||
bars.top();
|
bars.top();
|
||||||
for (int i = 0; i < 6; i++) {
|
for (int i = 0; i < this.bars; i++) {
|
||||||
int index = i;
|
int index = i;
|
||||||
bars.table(bar -> {
|
bars.table(bar -> {
|
||||||
bar.add(new SBar(
|
bar.add(new SBar(
|
||||||
() -> BarInfo.strings.get(index),
|
|
||||||
() -> {
|
() -> {
|
||||||
if (BarInfo.colors.get(index) != Color.clear) lastColors.set(index, BarInfo.colors.get(index));
|
BarInfo.BarData data = index >= BarInfo.data.size ? null : BarInfo.data.get(index);
|
||||||
|
return data == null ? "[lightgray]<Empty>[]" : data.name;
|
||||||
|
},
|
||||||
|
() -> {
|
||||||
|
BarInfo.BarData data = index >= BarInfo.data.size ? null : BarInfo.data.get(index);
|
||||||
|
if (index >= lastColors.size) lastColors.size = index+1;
|
||||||
|
if (data == null) return lastColors.get(index);
|
||||||
|
if (data.color != Color.clear) lastColors.set(index, data.color);
|
||||||
return lastColors.get(index);
|
return lastColors.get(index);
|
||||||
},
|
},
|
||||||
() -> BarInfo.numbers.get(index)
|
() -> {
|
||||||
|
BarInfo.BarData data = index >= BarInfo.data.size ? null : BarInfo.data.get(index);
|
||||||
|
return data == null ? 0 : data.number;
|
||||||
|
}
|
||||||
)).height(4 * 8f).growX();
|
)).height(4 * 8f).growX();
|
||||||
bar.add(new Image(){
|
bar.add(new Image(){
|
||||||
@Override
|
@Override
|
||||||
public void draw() {
|
public void draw() {
|
||||||
validate();
|
validate();
|
||||||
|
|
||||||
|
BarInfo.BarData data = index >= BarInfo.data.size ? null : BarInfo.data.get(index);
|
||||||
Draw.color(Color.white);
|
Draw.color(Color.white);
|
||||||
Draw.alpha(parentAlpha * color.a);
|
Draw.alpha(parentAlpha * color.a);
|
||||||
TextureRegionDrawable region = new TextureRegionDrawable(getRegions(index));
|
if(data == null) {
|
||||||
|
new TextureRegionDrawable(clear).draw(x + imageX, y + imageY, imageWidth * scaleX, imageHeight * scaleY);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
TextureRegionDrawable region = new TextureRegionDrawable(data.icon);
|
||||||
region.draw(x + imageX, y + imageY, imageWidth * scaleX, imageHeight * scaleY);
|
region.draw(x + imageX, y + imageY, imageWidth * scaleX, imageHeight * scaleY);
|
||||||
Draw.color(BarInfo.colors.get(index));
|
Draw.color(data.color);
|
||||||
if(ScissorStack.push(scissor.set(x, y, imageWidth * scaleX, imageHeight * scaleY * BarInfo.numbers.get(index)))){
|
if(ScissorStack.push(scissor.set(x, y, imageWidth * scaleX, imageHeight * scaleY * data.number))){
|
||||||
region.draw(x, y, imageWidth * scaleX, imageHeight * scaleY);
|
region.draw(x, y, imageWidth * scaleX, imageHeight * scaleY);
|
||||||
ScissorStack.pop();
|
ScissorStack.pop();
|
||||||
}
|
}
|
||||||
@@ -124,57 +135,6 @@ class UnitWindow extends Window {
|
|||||||
}), Styles.nonePane, scrollPos).disableScroll(true, false)).growX().padTop(12f);
|
}), Styles.nonePane, scrollPos).disableScroll(true, false)).growX().padTop(12f);
|
||||||
}
|
}
|
||||||
|
|
||||||
//do not ask me WHAT THE FUCK IS THIS
|
|
||||||
TextureRegion getRegions(int i){
|
|
||||||
TextureRegion region = clear;
|
|
||||||
|
|
||||||
if(i == 0){
|
|
||||||
if(target instanceof Healthc) region = SIcons.health;
|
|
||||||
} else if(i == 1){
|
|
||||||
if(target instanceof Turret.TurretBuild ||
|
|
||||||
target instanceof MassDriver.MassDriverBuild){
|
|
||||||
region = SIcons.reload;
|
|
||||||
} else if((target instanceof Unit unit && unit.type != null) ||
|
|
||||||
target instanceof ForceProjector.ForceBuild){
|
|
||||||
region = SIcons.shield;
|
|
||||||
} else if(target instanceof PowerNode.PowerNodeBuild ||
|
|
||||||
target instanceof PowerGenerator.GeneratorBuild){
|
|
||||||
region = SIcons.power;
|
|
||||||
}
|
|
||||||
} else if(i == 2){
|
|
||||||
if(target instanceof ItemTurret.ItemTurretBuild){
|
|
||||||
region = SIcons.ammo;
|
|
||||||
} else if(target instanceof LiquidTurret.LiquidTurretBuild){
|
|
||||||
region = SIcons.liquid;
|
|
||||||
} else if(target instanceof PowerTurret.PowerTurretBuild ||
|
|
||||||
target instanceof PowerNode.PowerNodeBuild){
|
|
||||||
region = SIcons.power;
|
|
||||||
} else if((target instanceof Building b && b.block.hasItems) ||
|
|
||||||
(target instanceof Unit unit && unit.type != null)){
|
|
||||||
region = SIcons.item;
|
|
||||||
}
|
|
||||||
} else if(i == 3){
|
|
||||||
if(target instanceof PowerNode.PowerNodeBuild){
|
|
||||||
region = SIcons.power;
|
|
||||||
}
|
|
||||||
} else if(i == 4){
|
|
||||||
if(target instanceof PowerNode.PowerNodeBuild){
|
|
||||||
region = SIcons.power;
|
|
||||||
} else if(target instanceof Building b && b.block.hasLiquids){
|
|
||||||
region = SIcons.liquid;
|
|
||||||
}
|
|
||||||
} else if(i == 5){
|
|
||||||
if(target instanceof Unit unit && state.rules.unitAmmo && unit.type != null){
|
|
||||||
region = SIcons.ammo;
|
|
||||||
}else if(target instanceof PowerNode.PowerNodeBuild ||
|
|
||||||
(target instanceof Building b && b.block.consumes.hasPower())){
|
|
||||||
region = SIcons.power;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return region;
|
|
||||||
}
|
|
||||||
|
|
||||||
static class WeaponDisplay extends Table {
|
static class WeaponDisplay extends Table {
|
||||||
WeaponDisplay() {
|
WeaponDisplay() {
|
||||||
table().update(tt -> {
|
table().update(tt -> {
|
||||||
|
|||||||
Reference in New Issue
Block a user