mirror of
https://github.com/yawaflua/Informatis.git
synced 2025-12-10 20:19:26 +02:00
clean up, fixed color bar
This commit is contained in:
@@ -10,13 +10,17 @@ import arc.util.Time;
|
||||
import mindustry.ai.types.FormationAI;
|
||||
import mindustry.core.UI;
|
||||
import mindustry.ctype.UnlockableContent;
|
||||
import mindustry.entities.Units;
|
||||
import mindustry.entities.abilities.ForceFieldAbility;
|
||||
import mindustry.entities.abilities.ShieldRegenFieldAbility;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.graphics.Pal;
|
||||
import mindustry.ui.Fonts;
|
||||
import mindustry.world.blocks.ConstructBlock;
|
||||
import mindustry.world.blocks.defense.turrets.*;
|
||||
import mindustry.world.blocks.storage.*;
|
||||
import mindustry.world.blocks.units.Reconstructor;
|
||||
import mindustry.world.blocks.units.UnitFactory;
|
||||
import mindustry.world.consumers.ConsumePower;
|
||||
|
||||
|
||||
@@ -77,7 +81,18 @@ public class BarInfo {
|
||||
colors.set(1, Pal.darkerMetal);
|
||||
numbers.set(1, construct.progress);
|
||||
}
|
||||
|
||||
else if(target instanceof UnitFactory.UnitFactoryBuild){
|
||||
UnitFactory.UnitFactoryBuild factory = (UnitFactory.UnitFactoryBuild) target;
|
||||
strings.set(1, Core.bundle.format("shar-stat.progress", Strings.fixed(factory.fraction() * 100f, 1)));
|
||||
colors.set(1, Pal.darkerMetal);
|
||||
numbers.set(1, factory.fraction());
|
||||
}
|
||||
else if(target instanceof Reconstructor.ReconstructorBuild){
|
||||
Reconstructor.ReconstructorBuild reconstruct = (Reconstructor.ReconstructorBuild) target;
|
||||
strings.set(1, Core.bundle.format("shar-stat.progress", Strings.fixed(reconstruct.fraction() * 100, 1)));
|
||||
colors.set(1, Pal.darkerMetal);
|
||||
numbers.set(1, reconstruct.fraction());
|
||||
}
|
||||
|
||||
if(target instanceof ItemTurret.ItemTurretBuild) {
|
||||
ItemTurret.ItemTurretBuild turretBuild = (ItemTurret.ItemTurretBuild) target;
|
||||
@@ -123,7 +138,7 @@ public class BarInfo {
|
||||
}
|
||||
else if(target instanceof Unit && ((Unit)target).type() != null) {
|
||||
strings.set(2, bundle.format("shar-stat.itemCapacity", UI.formatAmount(((Unit)target).stack().amount), UI.formatAmount(((Unit)target).type().itemCapacity)));
|
||||
colors.set(2, ((Unit)target).stack().item.color.cpy().lerp(Color.white, 0.15f));
|
||||
if(((Unit)target).stack().amount > 0 && ((Unit)target).stack().item != null) colors.set(2, ((Unit)target).stack().item.color.cpy().lerp(Color.white, 0.15f));
|
||||
numbers.set(2, ((Unit)target).stack().amount / (((Unit)target).type().itemCapacity * 1f));
|
||||
}
|
||||
|
||||
@@ -142,7 +157,13 @@ public class BarInfo {
|
||||
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)target).type().commandLimit * 1f))), 1f)));
|
||||
numbers.set(3, Groups.unit.count(u -> u.controller() instanceof FormationAI && ((FormationAI)u.controller()).leader == target) / (((Unit)target).type().commandLimit * 1f));
|
||||
}
|
||||
|
||||
else if(target instanceof UnitFactory.UnitFactoryBuild){
|
||||
UnitFactory.UnitFactoryBuild factory = (UnitFactory.UnitFactoryBuild) target;
|
||||
strings.set(3, factory.unit() == null ? "[lightgray]" + Iconc.cancel :
|
||||
Core.bundle.format("bar.unitcap", Fonts.getUnicodeStr(factory.unit().name), factory.team.data().countType(factory.unit()), 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));
|
||||
}
|
||||
|
||||
if(target instanceof Unit && target instanceof Payloadc && ((Unit) target).type != null){
|
||||
strings.set(4, Core.bundle.format("shar-stat.payloadCapacity", Mathf.round(Mathf.sqrt(((Payloadc)target).payloadUsed())), Mathf.round(Mathf.sqrt(((Unit)target).type().payloadCapacity))));
|
||||
|
||||
@@ -7,7 +7,6 @@ import arc.graphics.g2d.*;
|
||||
import arc.input.KeyCode;
|
||||
import arc.math.*;
|
||||
import arc.math.geom.Geometry;
|
||||
import arc.math.geom.Vec2;
|
||||
import arc.scene.*;
|
||||
import arc.scene.event.HandCursorListener;
|
||||
import arc.scene.style.*;
|
||||
@@ -18,7 +17,6 @@ import arc.struct.*;
|
||||
import arc.util.*;
|
||||
import mindustry.*;
|
||||
import mindustry.content.*;
|
||||
import mindustry.entities.Predict;
|
||||
import mindustry.entities.Units;
|
||||
import mindustry.entities.units.*;
|
||||
import mindustry.game.*;
|
||||
@@ -52,8 +50,6 @@ public class HudUi {
|
||||
float tileScrollPos;
|
||||
float itemScrollPos;
|
||||
|
||||
Color lastItemColor = Pal.items;
|
||||
Color lastAmmoColor = Pal.ammo;
|
||||
Teamc lockedTarget;
|
||||
ImageButton lockButton;
|
||||
boolean locked = false;
|
||||
@@ -69,7 +65,7 @@ public class HudUi {
|
||||
Seq<String> strings = new Seq<>(new String[]{"","","","","",""});
|
||||
Seq<Float> numbers = new Seq<>(new Float[]{0f,0f,0f,0f,0f,0f});
|
||||
Seq<Color> colors = new Seq<>(new Color[]{Color.clear,Color.clear,Color.clear,Color.clear,Color.clear,Color.clear});
|
||||
|
||||
Seq<Color> lastColors = new Seq<>(new Color[]{Color.clear,Color.clear,Color.clear,Color.clear,Color.clear,Color.clear});
|
||||
CoresItemsDisplay coreItems = new CoresItemsDisplay(Team.baseTeams);
|
||||
|
||||
|
||||
@@ -229,23 +225,40 @@ public class HudUi {
|
||||
|
||||
public void addBars(){
|
||||
bars.clear();
|
||||
bars.add(new SBar(
|
||||
() -> strings.get(0),
|
||||
() -> colors.get(0),
|
||||
() -> numbers.get(0)
|
||||
));
|
||||
bars.add(new SBar(
|
||||
() -> strings.get(1),
|
||||
() -> colors.get(1),
|
||||
() -> numbers.get(1)
|
||||
));
|
||||
lastColors.set(2, colors.get(2));
|
||||
{
|
||||
int i = 0;
|
||||
bars.add(new SBar(
|
||||
() -> strings.get(i),
|
||||
() -> {
|
||||
if (colors.get(i) != Color.clear) lastColors.set(i, colors.get(i));
|
||||
return lastColors.get(i);
|
||||
},
|
||||
() -> numbers.get(i)
|
||||
));
|
||||
}
|
||||
{
|
||||
int i = 1;
|
||||
bars.add(new SBar(
|
||||
() -> strings.get(i),
|
||||
() -> {
|
||||
if (colors.get(i) != Color.clear) lastColors.set(i, colors.get(i));
|
||||
return lastColors.get(i);
|
||||
},
|
||||
() -> numbers.get(i)
|
||||
));
|
||||
}
|
||||
bars.add(new Stack(){{
|
||||
add(new Table(t -> {
|
||||
t.top().defaults().width(Scl.scl(23 * 8f)).height(Scl.scl(4f * 8f));
|
||||
int i = 2;
|
||||
t.add(new SBar(
|
||||
() -> strings.get(2),
|
||||
() -> lastItemColor = colors.get(2),
|
||||
() -> numbers.get(2)
|
||||
() -> strings.get(i),
|
||||
() -> {
|
||||
if(colors.get(i) != Color.clear) lastColors.set(i, colors.get(i));
|
||||
return lastColors.get(i);
|
||||
},
|
||||
() -> numbers.get(i)
|
||||
)).growX().left();
|
||||
}));
|
||||
add(new Table(){{
|
||||
@@ -316,26 +329,44 @@ public class HudUi {
|
||||
}));
|
||||
}});
|
||||
|
||||
bars.add(new SBar(
|
||||
() -> strings.get(3),
|
||||
() -> colors.get(3),
|
||||
() -> numbers.get(3)
|
||||
));
|
||||
|
||||
bars.add(new SBar(
|
||||
() -> strings.get(4),
|
||||
() -> colors.get(4),
|
||||
() -> numbers.get(4)
|
||||
));
|
||||
{
|
||||
int i = 3;
|
||||
bars.add(new SBar(
|
||||
() -> strings.get(i),
|
||||
() -> {
|
||||
if (colors.get(i) != Color.clear) lastColors.set(i, colors.get(i));
|
||||
return lastColors.get(i);
|
||||
},
|
||||
() -> numbers.get(i)
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
{
|
||||
int i = 4;
|
||||
bars.add(new SBar(
|
||||
() -> strings.get(i),
|
||||
() -> {
|
||||
if (colors.get(i) != Color.clear) lastColors.set(i, colors.get(i));
|
||||
return lastColors.get(i);
|
||||
},
|
||||
() -> numbers.get(i)
|
||||
));
|
||||
}
|
||||
|
||||
bars.add(new Stack(){{
|
||||
add(new Table(t -> {
|
||||
t.top().defaults().width(Scl.scl(23 * 8f)).height(Scl.scl(4f * 8f));
|
||||
|
||||
int i = 5;
|
||||
t.add(new SBar(
|
||||
() -> strings.get(5),
|
||||
() -> lastAmmoColor = colors.get(5),
|
||||
() -> numbers.get(5)
|
||||
() -> strings.get(i),
|
||||
() -> {
|
||||
if (colors.get(i) != Color.clear) lastColors.set(i, colors.get(i));
|
||||
return lastColors.get(i);
|
||||
},
|
||||
() -> numbers.get(i)
|
||||
)).growX().left();
|
||||
}));
|
||||
add(new Table(t -> {
|
||||
|
||||
@@ -3,7 +3,6 @@ package UnitInfo.core;
|
||||
import UnitInfo.ui.FreeBar;
|
||||
import arc.Core;
|
||||
import arc.Events;
|
||||
import arc.files.Fi;
|
||||
import arc.graphics.Color;
|
||||
import arc.graphics.g2d.Draw;
|
||||
import arc.graphics.g2d.Fill;
|
||||
|
||||
Reference in New Issue
Block a user