mirror of
https://github.com/yawaflua/Informatis.git
synced 2025-12-10 03:59:26 +02:00
fixed core bar
This commit is contained in:
BIN
assets/sprites/ui/1dotbar-top.png
Normal file
BIN
assets/sprites/ui/1dotbar-top.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 119 B |
BIN
assets/sprites/ui/1dotbar.png
Normal file
BIN
assets/sprites/ui/1dotbar.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 119 B |
@@ -173,15 +173,7 @@ public class BarInfo {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if(target instanceof Turret.TurretBuild t){
|
if(target instanceof Unit unit && unit.type != null) {
|
||||||
Turret turret = (Turret)t.block;
|
|
||||||
if(turret.chargeTime > 0f) {
|
|
||||||
strings.set(3, Core.bundle.format("shar-stat.charge", floatFormat((SVars.hud.charge / turret.chargeTime) * 100)));
|
|
||||||
colors.set(3, Pal.surge.cpy().lerp(Pal.accent, SVars.hud.charge / turret.chargeTime));
|
|
||||||
numbers.set(3, SVars.hud.charge / turret.chargeTime);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if(target instanceof Unit unit && unit.type != null) {
|
|
||||||
strings.set(3, Core.bundle.format("shar-stat.commandUnits", floatFormat(Groups.unit.count(u -> u.controller() instanceof FormationAI && ((FormationAI)u.controller()).leader == target)), floatFormat(unit.type().commandLimit)));
|
strings.set(3, Core.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)));
|
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));
|
numbers.set(3, Groups.unit.count(u -> u.controller() instanceof FormationAI && ((FormationAI)u.controller()).leader == target) / (unit.type().commandLimit * 1f));
|
||||||
|
|||||||
@@ -37,6 +37,8 @@ import mindustry.world.blocks.payloads.PayloadMassDriver;
|
|||||||
import mindustry.world.blocks.power.PowerNode;
|
import mindustry.world.blocks.power.PowerNode;
|
||||||
import mindustry.world.blocks.storage.*;
|
import mindustry.world.blocks.storage.*;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
import static UnitInfo.SVars.*;
|
import static UnitInfo.SVars.*;
|
||||||
import static arc.Core.*;
|
import static arc.Core.*;
|
||||||
import static mindustry.Vars.*;
|
import static mindustry.Vars.*;
|
||||||
@@ -65,7 +67,7 @@ public class HudUi {
|
|||||||
|
|
||||||
//to update tables
|
//to update tables
|
||||||
int waveamount;
|
int waveamount;
|
||||||
int coreamount;
|
int coreamounts;
|
||||||
int enemyamount;
|
int enemyamount;
|
||||||
|
|
||||||
//is this rly good idea?
|
//is this rly good idea?
|
||||||
@@ -409,8 +411,8 @@ public class HudUi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void addWaveInfoTable() {
|
public void addWaveInfoTable() {
|
||||||
waveInfoTable = new Table(Tex.wavepane, t -> {
|
waveInfoTable = new Table(Tex.buttonEdge4, t -> {
|
||||||
t.defaults().width(35 * 8f).center();
|
t.defaults().width(34 * 8f).center();
|
||||||
setTile(t);
|
setTile(t);
|
||||||
t.row();
|
t.row();
|
||||||
setLeftUnitTable(t);
|
setLeftUnitTable(t);
|
||||||
@@ -678,11 +680,12 @@ public class HudUi {
|
|||||||
, new Table(h -> {
|
, new Table(h -> {
|
||||||
h.defaults().growX().height(Scl.scl(modUiScale) * 9f).width(Scl.scl(modUiScale) * iconLarge).padTop(Scl.scl(modUiScale) * 18f);
|
h.defaults().growX().height(Scl.scl(modUiScale) * 9f).width(Scl.scl(modUiScale) * iconLarge).padTop(Scl.scl(modUiScale) * 18f);
|
||||||
h.add(new Bar(
|
h.add(new Bar(
|
||||||
() -> "",
|
() -> "",
|
||||||
() -> Pal.accent.cpy().lerp(Color.orange, mount.reload / weapon.reload),
|
() -> Pal.accent.cpy().lerp(Color.orange, mount.reload / weapon.reload),
|
||||||
() -> mount.reload / weapon.reload));
|
() -> mount.reload / weapon.reload));
|
||||||
h.pack();
|
h.pack();
|
||||||
}));
|
})
|
||||||
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1074,33 +1077,33 @@ public class HudUi {
|
|||||||
|
|
||||||
public void setCore(Table table){
|
public void setCore(Table table){
|
||||||
table.table(t -> {
|
table.table(t -> {
|
||||||
|
coreamounts = Groups.build.count(b -> b instanceof CoreBlock.CoreBuild);
|
||||||
if(Vars.player.unit() == null) return;
|
if(Vars.player.unit() == null) return;
|
||||||
|
|
||||||
for(int i = 0; i < coreItems.tables.size; i++){
|
for(int i = 0; i < coreItems.tables.size; i++){
|
||||||
coreamount = coreItems.teams[i].cores().size;
|
|
||||||
if(coreItems.teams[i].cores().isEmpty()) continue;
|
if(coreItems.teams[i].cores().isEmpty()) continue;
|
||||||
if(state.rules.pvp && coreItems.teams[i] != player.team()) continue;
|
if(state.rules.pvp && coreItems.teams[i] != player.team()) continue;
|
||||||
int finalI = i;
|
int finalI = i;
|
||||||
t.table(Tex.underline2, head -> {
|
t.table(Tex.underline2, head -> {
|
||||||
head.center();
|
t.center();
|
||||||
Label label = new Label(() -> "[#" + coreItems.teams[finalI].color.toString() + "]" + coreItems.teams[finalI].name + "[]");
|
Label label = new Label(() -> "[#" + coreItems.teams[finalI].color.toString() + "]" + coreItems.teams[finalI].name + "[]");
|
||||||
if(modUiScale < 1) label.setFontScale(Scl.scl(modUiScale));
|
label.setFontScale(Scl.scl(modUiScale < 1 ? modUiScale : 1));
|
||||||
head.add(label);
|
head.add(label);
|
||||||
});
|
});
|
||||||
t.row();
|
t.row();
|
||||||
for(int r = 0; r < coreamount; r++) {
|
for(int r = 0, n = coreItems.teams[i].cores().size; r < n; r++) {
|
||||||
CoreBlock.CoreBuild core = coreItems.teams[i].cores().get(r);
|
CoreBlock.CoreBuild core = coreItems.teams[i].cores().get(r);
|
||||||
|
|
||||||
if(coreamount > 1 && r % 3 == 0) t.row();
|
if(n > 1 && r % 3 == 0) t.row();
|
||||||
else if(r % 3 == 0) t.row();
|
else if(r % 3 == 0) t.row();
|
||||||
|
|
||||||
t.table(tt -> {
|
t.table(tt -> {
|
||||||
tt.add(new Stack(){{
|
tt.stack(
|
||||||
add(new Table(s -> {
|
new Table(s -> {
|
||||||
s.left();
|
s.center();
|
||||||
Image image = new Image(core.block.uiIcon);
|
Image image = new Image(core.block.uiIcon);
|
||||||
image.clicked(() -> {
|
image.clicked(() -> {
|
||||||
if (control.input instanceof DesktopInput)
|
if(control.input instanceof DesktopInput)
|
||||||
((DesktopInput) control.input).panning = true;
|
((DesktopInput) control.input).panning = true;
|
||||||
Core.camera.position.set(core.x, core.y);
|
Core.camera.position.set(core.x, core.y);
|
||||||
});
|
});
|
||||||
@@ -1109,24 +1112,25 @@ public class HudUi {
|
|||||||
image.addListener(listener1);
|
image.addListener(listener1);
|
||||||
image.update(() -> image.color.lerp(!listener1.isOver() ? Color.lightGray : Color.white, Mathf.clamp(0.4f * Time.delta)));
|
image.update(() -> image.color.lerp(!listener1.isOver() ? Color.lightGray : Color.white, Mathf.clamp(0.4f * Time.delta)));
|
||||||
}
|
}
|
||||||
image.addListener(new Tooltip(t -> {
|
image.addListener(new Tooltip(ttt -> {
|
||||||
|
|
||||||
Label label = new Label(() -> "([#" + Tmp.c1.set(Color.green).lerp(Color.red, 1 - core.healthf()).toString() + "]" + Strings.fixed(core.health, 2) + "[]/" + Strings.fixed(core.block.health, 2) + ")");
|
Label label = new Label(() -> "([#" + Tmp.c1.set(Color.green).lerp(Color.red, 1 - core.healthf()).toString() + "]" + Strings.fixed(core.health, 2) + "[]/" + Strings.fixed(core.block.health, 2) + ")");
|
||||||
if(modUiScale < 1) label.setFontScale(Scl.scl(modUiScale));
|
if (modUiScale < 1) label.setFontScale(Scl.scl(modUiScale));
|
||||||
t.background(Tex.button).add(label);
|
ttt.background(Tex.button).add(label);
|
||||||
}));
|
}));
|
||||||
s.add(image).size(iconLarge * Scl.scl(modUiScale < 1 ? modUiScale : 1));
|
s.add(image).size(iconLarge * Scl.scl(modUiScale < 1 ? modUiScale : 1));
|
||||||
}));
|
}),
|
||||||
|
new Table(h -> {
|
||||||
add(new Table(s -> {
|
h.bottom().defaults().height(Scl.scl(modUiScale) * 9f).width(Scl.scl(modUiScale) * iconLarge * 1.5f).growX();
|
||||||
s.bottom().defaults().growX().height(Scl.scl(modUiScale) * 9f).pad(4 * Scl.scl(modUiScale));
|
SBar bar = new SBar(() -> "", () -> Pal.health, () -> core.health / core.block.health);
|
||||||
s.add(new Bar(() -> "", () -> Pal.health, core::healthf));
|
bar.onedot = true;
|
||||||
s.pack();
|
bar.init();
|
||||||
}));
|
h.add(bar);
|
||||||
}});
|
h.pack();
|
||||||
|
})
|
||||||
|
);
|
||||||
tt.row();
|
tt.row();
|
||||||
Label label = new Label(() -> "(" + (int) core.x / 8 + ", " + (int) core.y / 8 + ")");
|
Label label = new Label(() -> "(" + (int) core.x / 8 + ", " + (int) core.y / 8 + ")");
|
||||||
if(modUiScale < 1) label.setFontScale(Scl.scl(modUiScale));
|
label.setFontScale(Scl.scl(modUiScale < 1 ? modUiScale : 1) * 0.75f);
|
||||||
tt.add(label);
|
tt.add(label);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -1140,6 +1144,8 @@ public class HudUi {
|
|||||||
ScrollPane corePane = new ScrollPane(new Table(tx -> tx.table(this::setCore).left()), Styles.smallPane);
|
ScrollPane corePane = new ScrollPane(new Table(tx -> tx.table(this::setCore).left()), Styles.smallPane);
|
||||||
corePane.setScrollingDisabled(true, false);
|
corePane.setScrollingDisabled(true, false);
|
||||||
corePane.setScrollYForce(coreScrollPos);
|
corePane.setScrollYForce(coreScrollPos);
|
||||||
|
corePane.setOverscroll(false, false);
|
||||||
|
|
||||||
corePane.update(() -> {
|
corePane.update(() -> {
|
||||||
if(corePane.hasScroll()){
|
if(corePane.hasScroll()){
|
||||||
Element result = scene.hit(input.mouseX(), input.mouseY(), true);
|
Element result = scene.hit(input.mouseX(), input.mouseY(), true);
|
||||||
@@ -1148,9 +1154,10 @@ public class HudUi {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
coreScrollPos = corePane.getScrollY();
|
coreScrollPos = corePane.getScrollY();
|
||||||
|
|
||||||
|
if(coreamounts != Groups.build.count(b -> b instanceof CoreBlock.CoreBuild))
|
||||||
|
corePane.setWidget(new Table(tx -> tx.table(this::setCore).left()));
|
||||||
});
|
});
|
||||||
corePane.setWidget(new Table(tx -> tx.table(this::setCore).left()));
|
|
||||||
corePane.setOverscroll(false, false);
|
|
||||||
|
|
||||||
coreTable = new Table(table -> {
|
coreTable = new Table(table -> {
|
||||||
table.left();
|
table.left();
|
||||||
|
|||||||
@@ -27,6 +27,8 @@ public class SBar extends Element{
|
|||||||
NinePatchDrawable bar, top;
|
NinePatchDrawable bar, top;
|
||||||
float spriteWidth;
|
float spriteWidth;
|
||||||
|
|
||||||
|
public boolean onedot = false;
|
||||||
|
|
||||||
public SBar(Prov<String> name, Prov<Color> color, Floatp fraction){
|
public SBar(Prov<String> name, Prov<Color> color, Floatp fraction){
|
||||||
this.fraction = fraction;
|
this.fraction = fraction;
|
||||||
try{
|
try{
|
||||||
@@ -53,10 +55,16 @@ public class SBar extends Element{
|
|||||||
boolean shar2 = Core.settings.getBool("shar2");
|
boolean shar2 = Core.settings.getBool("shar2");
|
||||||
boolean shar3 = Core.settings.getBool("shar3");
|
boolean shar3 = Core.settings.getBool("shar3");
|
||||||
|
|
||||||
|
|
||||||
bar = (NinePatchDrawable) SUtils.getDrawable(Core.atlas.find("unitinfo-barS"), 10, 10, 9, 9);
|
bar = (NinePatchDrawable) SUtils.getDrawable(Core.atlas.find("unitinfo-barS"), 10, 10, 9, 9);
|
||||||
top = (NinePatchDrawable) SUtils.getDrawable(Core.atlas.find("unitinfo-barS-top"), 10, 10, 9, 9);
|
top = (NinePatchDrawable) SUtils.getDrawable(Core.atlas.find("unitinfo-barS-top"), 10, 10, 9, 9);
|
||||||
spriteWidth = Core.atlas.find("unitinfo-barS").width;
|
spriteWidth = Core.atlas.find("unitinfo-barS").width;
|
||||||
if(ssim){
|
if(onedot){
|
||||||
|
bar = (NinePatchDrawable) SUtils.getDrawable(Core.atlas.find("unitinfo-1dotbar"), 0,0,0,0);
|
||||||
|
top = (NinePatchDrawable) SUtils.getDrawable(Core.atlas.find("unitinfo-1dotbar-top"),0,0,0,0);
|
||||||
|
spriteWidth = Core.atlas.find("unitinfo-1dotbar").width;
|
||||||
|
}
|
||||||
|
else if(ssim){
|
||||||
bar = (NinePatchDrawable) SUtils.getDrawable(Core.atlas.find("unitinfo-barSS"), 14, 14, 19, 19);
|
bar = (NinePatchDrawable) SUtils.getDrawable(Core.atlas.find("unitinfo-barSS"), 14, 14, 19, 19);
|
||||||
top = (NinePatchDrawable) SUtils.getDrawable(Core.atlas.find("unitinfo-barSS-top"), 14, 14, 19, 19);
|
top = (NinePatchDrawable) SUtils.getDrawable(Core.atlas.find("unitinfo-barSS-top"), 14, 14, 19, 19);
|
||||||
spriteWidth = Core.atlas.find("unitinfo-barSS").width;
|
spriteWidth = Core.atlas.find("unitinfo-barSS").width;
|
||||||
@@ -122,7 +130,7 @@ public class SBar extends Element{
|
|||||||
}
|
}
|
||||||
|
|
||||||
Draw.color(color, blinkColor, blink);
|
Draw.color(color, blinkColor, blink);
|
||||||
float topWidthReal = width * (Math.min(value, computed));
|
float topWidthReal = width * Math.min(value, computed);
|
||||||
if(topWidthReal > spriteWidth){
|
if(topWidthReal > spriteWidth){
|
||||||
top.draw(x, y, topWidthReal, height);
|
top.draw(x, y, topWidthReal, height);
|
||||||
} else if(ScissorStack.push(scissor.set(x, y, topWidthReal, height))){
|
} else if(ScissorStack.push(scissor.set(x, y, topWidthReal, height))){
|
||||||
|
|||||||
Reference in New Issue
Block a user