mirror of
https://github.com/yawaflua/Informatis.git
synced 2025-12-10 20:19:26 +02:00
marge done
This commit is contained in:
@@ -4,7 +4,9 @@ import UnitInfo.SVars;
|
||||
import arc.Core;
|
||||
import arc.graphics.Color;
|
||||
import arc.math.Mathf;
|
||||
import arc.struct.FloatSeq;
|
||||
import arc.struct.Seq;
|
||||
import arc.util.Log;
|
||||
import arc.util.Strings;
|
||||
import arc.util.Time;
|
||||
import mindustry.ai.types.FormationAI;
|
||||
@@ -15,9 +17,13 @@ import mindustry.entities.abilities.ForceFieldAbility;
|
||||
import mindustry.entities.abilities.ShieldRegenFieldAbility;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.graphics.Pal;
|
||||
import mindustry.logic.LAccess;
|
||||
import mindustry.type.Item;
|
||||
import mindustry.ui.Fonts;
|
||||
import mindustry.world.blocks.ConstructBlock;
|
||||
import mindustry.world.blocks.defense.ForceProjector;
|
||||
import mindustry.world.blocks.defense.MendProjector;
|
||||
import mindustry.world.blocks.defense.OverdriveProjector;
|
||||
import mindustry.world.blocks.defense.turrets.*;
|
||||
import mindustry.world.blocks.storage.*;
|
||||
import mindustry.world.blocks.units.Reconstructor;
|
||||
@@ -31,7 +37,7 @@ import static mindustry.Vars.state;
|
||||
|
||||
public class BarInfo {
|
||||
static Seq<String> strings = Seq.with("","","","","","");
|
||||
static Seq<Float> numbers = Seq.with(0f,0f,0f,0f,0f,0f);
|
||||
static FloatSeq numbers = FloatSeq.with(0f,0f,0f,0f,0f,0f);
|
||||
static Seq<Color> colors = Seq.with(Color.clear,Color.clear,Color.clear,Color.clear,Color.clear,Color.clear);
|
||||
|
||||
public static String format(float number){
|
||||
@@ -70,10 +76,9 @@ public class BarInfo {
|
||||
numbers.set(1, unit.shield() / Math.max(max1, max2));
|
||||
}
|
||||
else if(target instanceof ConstructBlock.ConstructBuild build){
|
||||
ConstructBlock.ConstructBuild construct = build;
|
||||
strings.set(1, Core.bundle.format("shar-stat.progress", Strings.fixed(construct.progress * 100, 1)));
|
||||
strings.set(1, Core.bundle.format("shar-stat.progress", Strings.fixed(build.progress * 100, 1)));
|
||||
colors.set(1, Pal.darkerMetal);
|
||||
numbers.set(1, construct.progress);
|
||||
numbers.set(1, build.progress);
|
||||
}
|
||||
else if(target instanceof UnitFactory.UnitFactoryBuild build){
|
||||
strings.set(1, Core.bundle.format("shar-stat.progress", Strings.fixed(build.fraction() * 100f, 1)));
|
||||
@@ -88,10 +93,19 @@ public class BarInfo {
|
||||
else if(target instanceof ForceProjector.ForceBuild force){
|
||||
ForceProjector forceBlock = (ForceProjector) force.block;
|
||||
float max = forceBlock.shieldHealth + forceBlock.phaseShieldBoost * force.phaseHeat;
|
||||
strings.set(1, Core.bundle.format("shar-stat.shield", format(max-force.buildup), max));
|
||||
strings.set(1, Core.bundle.format("shar-stat.shield", format(max-force.buildup), format(max)));
|
||||
colors.set(1, Pal.shield);
|
||||
numbers.set(1, (max-force.buildup)/max);
|
||||
|
||||
}
|
||||
else if(target instanceof MendProjector.MendBuild mend){
|
||||
strings.set(1, Core.bundle.format("shar-stat.progress", Strings.fixed((float) mend.sense(LAccess.progress), 1)));
|
||||
colors.set(1, Pal.heal);
|
||||
numbers.set(1, (float) mend.sense(LAccess.progress));
|
||||
}
|
||||
else if(target instanceof OverdriveProjector.OverdriveBuild over){
|
||||
strings.set(1, Core.bundle.format("shar-stat.progress", Strings.fixed((float) over.sense(LAccess.progress), 1)));
|
||||
colors.set(1, Pal.heal);
|
||||
numbers.set(1, (float) over.sense(LAccess.progress));
|
||||
}
|
||||
|
||||
if(target instanceof ItemTurret.ItemTurretBuild turretBuild) {
|
||||
@@ -118,6 +132,7 @@ public class BarInfo {
|
||||
}
|
||||
else if(target instanceof StorageBlock.StorageBuild sb && !sb.canPickup()){
|
||||
for(int i = 0; i < 4; i++) {
|
||||
// Building build = i == 0 ? ((Building) target).front() : i == 1 ? ((Building) target).back() : i == 2 ? ((Building) target).left() : ((Building) target).right();
|
||||
Building build = sb.nearby(i);
|
||||
if(build instanceof CoreBlock.CoreBuild cb){
|
||||
strings.set(2, bundle.format("shar-stat.itemCapacity", format(sb.items.total()), format(cb.storageCapacity * content.items().count(UnlockableContent::unlockedNow))));
|
||||
|
||||
@@ -2,6 +2,8 @@ package UnitInfo.core;
|
||||
|
||||
import UnitInfo.ui.*;
|
||||
import arc.*;
|
||||
import arc.func.Floatp;
|
||||
import arc.func.Prov;
|
||||
import arc.graphics.*;
|
||||
import arc.graphics.g2d.*;
|
||||
import arc.input.KeyCode;
|
||||
@@ -62,9 +64,14 @@ public class HudUi {
|
||||
int waveamount;
|
||||
int coreamount;
|
||||
|
||||
Seq<Color> lastColors = new Seq<>(new Color[]{Color.clear,Color.clear,Color.clear,Color.clear,Color.clear,Color.clear});
|
||||
//is this rly good idea?
|
||||
Seq<String> strings = Seq.with("","","","","","");
|
||||
FloatSeq numbers = FloatSeq.with(0f,0f,0f,0f,0f,0f);
|
||||
Seq<Color> colors = Seq.with(Color.clear,Color.clear,Color.clear,Color.clear,Color.clear,Color.clear);
|
||||
Seq<Color> lastColors = Seq.with(Color.clear,Color.clear,Color.clear,Color.clear,Color.clear,Color.clear);
|
||||
CoresItemsDisplay coreItems = new CoresItemsDisplay(Team.baseTeams);
|
||||
|
||||
|
||||
@Nullable Teamc target;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@@ -232,27 +239,27 @@ public class HudUi {
|
||||
|
||||
public void addBars(){
|
||||
bars.clear();
|
||||
|
||||
lastColors.set(2, colors.get(2));
|
||||
{
|
||||
int i = 0;
|
||||
bars.add(new SBar(
|
||||
() -> BarInfo.strings.get(i),
|
||||
() -> strings.get(i),
|
||||
() -> {
|
||||
if (BarInfo.colors.get(i) != Color.clear) lastColors.set(i, BarInfo.colors.get(i));
|
||||
if (colors.get(i) != Color.clear) lastColors.set(i, colors.get(i));
|
||||
return lastColors.get(i);
|
||||
},
|
||||
() -> BarInfo.numbers.get(i)
|
||||
() -> numbers.get(i)
|
||||
));
|
||||
}
|
||||
{
|
||||
int i = 1;
|
||||
bars.add(new SBar(
|
||||
() -> BarInfo.strings.get(i),
|
||||
() -> strings.get(i),
|
||||
() -> {
|
||||
if (BarInfo.colors.get(i) != Color.clear) lastColors.set(i, BarInfo.colors.get(i));
|
||||
if (colors.get(i) != Color.clear) lastColors.set(i, colors.get(i));
|
||||
return lastColors.get(i);
|
||||
},
|
||||
() -> BarInfo.numbers.get(i)
|
||||
() -> numbers.get(i)
|
||||
));
|
||||
}
|
||||
bars.add(new Stack(){{
|
||||
@@ -340,12 +347,12 @@ public class HudUi {
|
||||
{
|
||||
int i = 3;
|
||||
bars.add(new SBar(
|
||||
() -> BarInfo.strings.get(i),
|
||||
() -> strings.get(i),
|
||||
() -> {
|
||||
if (BarInfo.colors.get(i) != Color.clear) lastColors.set(i, BarInfo.colors.get(i));
|
||||
if (colors.get(i) != Color.clear) lastColors.set(i, colors.get(i));
|
||||
return lastColors.get(i);
|
||||
},
|
||||
() -> BarInfo.numbers.get(i)
|
||||
() -> numbers.get(i)
|
||||
));
|
||||
}
|
||||
|
||||
@@ -353,12 +360,12 @@ public class HudUi {
|
||||
{
|
||||
int i = 4;
|
||||
bars.add(new SBar(
|
||||
() -> BarInfo.strings.get(i),
|
||||
() -> strings.get(i),
|
||||
() -> {
|
||||
if (BarInfo.colors.get(i) != Color.clear) lastColors.set(i, BarInfo.colors.get(i));
|
||||
if (colors.get(i) != Color.clear) lastColors.set(i, colors.get(i));
|
||||
return lastColors.get(i);
|
||||
},
|
||||
() -> BarInfo.numbers.get(i)
|
||||
() -> numbers.get(i)
|
||||
));
|
||||
}
|
||||
|
||||
@@ -368,12 +375,12 @@ public class HudUi {
|
||||
|
||||
int i = 5;
|
||||
t.add(new SBar(
|
||||
() -> BarInfo.strings.get(i),
|
||||
() -> strings.get(i),
|
||||
() -> {
|
||||
if (BarInfo.colors.get(i) != Color.clear) lastColors.set(i, BarInfo.colors.get(i));
|
||||
if (colors.get(i) != Color.clear) lastColors.set(i, colors.get(i));
|
||||
return lastColors.get(i);
|
||||
},
|
||||
() -> BarInfo.numbers.get(i)
|
||||
() -> numbers.get(i)
|
||||
)).growX().left();
|
||||
}));
|
||||
add(new Table(t -> {
|
||||
@@ -576,7 +583,11 @@ public class HudUi {
|
||||
}).padRight(Scl.scl(24 * 8f));
|
||||
table.row();
|
||||
table.update(() -> {
|
||||
BarInfo.getInfo(target);
|
||||
BarInfo.getInfo(getTarget());
|
||||
strings = BarInfo.strings;
|
||||
numbers = BarInfo.numbers;
|
||||
colors = BarInfo.colors;
|
||||
|
||||
if(getTarget() instanceof Turret.TurretBuild){
|
||||
if(((Turret.TurretBuild) getTarget()).charging) charge += Time.delta;
|
||||
else charge = 0f;
|
||||
|
||||
@@ -73,15 +73,11 @@ public class Main extends Mod {
|
||||
|
||||
if(Core.settings.getBool("scan")){
|
||||
float range = settings.getInt("rangemax") * 8f;
|
||||
|
||||
for(Team team : Team.all)
|
||||
indexer.eachBlock(team, Core.input.mouseWorldX(), Core.input.mouseWorldY(), range, b -> true, b -> new FreeBar().draw(b));
|
||||
|
||||
Draw.color(Tmp.c1.set(Pal.accent).a(0.75f + Mathf.absin(3, 0.25f)));
|
||||
Lines.swirl(Core.input.mouseWorldX(), Core.input.mouseWorldY(), range, 0.15f, Time.time % 360);
|
||||
Lines.swirl(Core.input.mouseWorldX(), Core.input.mouseWorldY(), range, 0.15f, 90 + Time.time % 360);
|
||||
Lines.swirl(Core.input.mouseWorldX(), Core.input.mouseWorldY(), range, 0.15f, 180 + Time.time % 360);
|
||||
Lines.swirl(Core.input.mouseWorldX(), Core.input.mouseWorldY(), range, 0.15f, 270 + Time.time % 360);
|
||||
for(int i = 0; i < 4; i++)
|
||||
Lines.swirl(Core.input.mouseWorldX(), Core.input.mouseWorldY(), range, 0.15f, 90 * i + Time.time % 360);
|
||||
Draw.reset();
|
||||
}
|
||||
|
||||
|
||||
@@ -9,19 +9,21 @@ import arc.math.geom.*;
|
||||
import arc.scene.*;
|
||||
import arc.scene.style.*;
|
||||
import arc.scene.ui.layout.*;
|
||||
import arc.struct.FloatSeq;
|
||||
import arc.struct.Seq;
|
||||
import arc.util.Log;
|
||||
import arc.util.pooling.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.ui.*;
|
||||
|
||||
public class SBar extends Element{
|
||||
private static final Rect scissor = new Rect();
|
||||
static final Rect scissor = new Rect();
|
||||
|
||||
private final Floatp fraction;
|
||||
private String name = "";
|
||||
private float value, lastValue, blink;
|
||||
private final Color blinkColor = new Color();
|
||||
NinePatchDrawable bar;
|
||||
NinePatchDrawable top;
|
||||
Floatp fraction;
|
||||
String name = "";
|
||||
float value, lastValue, blink;
|
||||
final Color blinkColor = new Color();
|
||||
NinePatchDrawable bar, top;
|
||||
float spriteWidth;
|
||||
|
||||
public SBar(Prov<String> name, Prov<Color> color, Floatp fraction){
|
||||
@@ -40,6 +42,25 @@ public class SBar extends Element{
|
||||
this.name = "";
|
||||
}
|
||||
});
|
||||
init();
|
||||
}
|
||||
|
||||
|
||||
public Drawable drawable(String name, int left, int right, int top, int bottom){
|
||||
Drawable out;
|
||||
|
||||
TextureAtlas.AtlasRegion region = Core.atlas.find(name);
|
||||
|
||||
int[] splits = {left, right, top, bottom};
|
||||
NinePatch patch = new NinePatch(region, splits[0], splits[1], splits[2], splits[3]);
|
||||
int[] pads = region.pads;
|
||||
if(pads != null) patch.setPadding(pads[0], pads[1], pads[2], pads[3]);
|
||||
out = new ScaledNinePatchDrawable(patch, 1f);
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
public void init(){
|
||||
boolean ssim = Core.settings.getBool("ssim");
|
||||
boolean shar = Core.settings.getBool("shar");
|
||||
boolean shar1 = Core.settings.getBool("shar1");
|
||||
@@ -74,21 +95,6 @@ public class SBar extends Element{
|
||||
top = (NinePatchDrawable) drawable("unitinfo-barSSSSSS-top", 32, 32, 16, 16);
|
||||
spriteWidth = Core.atlas.find("unitinfo-barSSSSSS").width;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public Drawable drawable(String name, int left, int right, int top, int bottom){
|
||||
Drawable out;
|
||||
|
||||
TextureAtlas.AtlasRegion region = Core.atlas.find(name);
|
||||
|
||||
int[] splits = {left, right, top, bottom};
|
||||
NinePatch patch = new NinePatch(region, splits[0], splits[1], splits[2], splits[3]);
|
||||
int[] pads = region.pads;
|
||||
if(pads != null) patch.setPadding(pads[0], pads[1], pads[2], pads[3]);
|
||||
out = new ScaledNinePatchDrawable(patch, 1f);
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -141,8 +147,8 @@ public class SBar extends Element{
|
||||
ScissorStack.pop();
|
||||
}
|
||||
}
|
||||
|
||||
Draw.color();
|
||||
|
||||
Font font = Fonts.outline;
|
||||
GlyphLayout lay = Pools.obtain(GlyphLayout.class, GlyphLayout::new);
|
||||
font.getData().setScale(Scl.scl());
|
||||
|
||||
Reference in New Issue
Block a user