mirror of
https://github.com/yawaflua/Informatis.git
synced 2025-12-10 12:09:27 +02:00
clean up
This commit is contained in:
25
src/UnitInfo/SUtils.java
Normal file
25
src/UnitInfo/SUtils.java
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
package UnitInfo;
|
||||||
|
|
||||||
|
import arc.graphics.g2d.NinePatch;
|
||||||
|
import arc.graphics.g2d.TextureAtlas;
|
||||||
|
import arc.scene.style.Drawable;
|
||||||
|
import arc.scene.style.ScaledNinePatchDrawable;
|
||||||
|
import arc.util.Strings;
|
||||||
|
import mindustry.core.UI;
|
||||||
|
|
||||||
|
public class SUtils {
|
||||||
|
public static Drawable getDrawable(TextureAtlas.AtlasRegion region, int left, int right, int top, int bottom){
|
||||||
|
int[] splits = {left, right, top, bottom};
|
||||||
|
int[] pads = region.pads;
|
||||||
|
NinePatch patch = new NinePatch(region, splits[0], splits[1], splits[2], splits[3]);
|
||||||
|
if(pads != null) patch.setPadding(pads[0], pads[1], pads[2], pads[3]);
|
||||||
|
|
||||||
|
return new ScaledNinePatchDrawable(patch, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String floatFormat(float number){
|
||||||
|
if(number >= 10000) return UI.formatAmount((long)number);
|
||||||
|
if(String.valueOf(number).split("[.]")[1].matches("0")) return String.valueOf(number).split("[.]")[0];
|
||||||
|
return Strings.fixed(number, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -12,12 +12,9 @@ import static mindustry.Vars.*;
|
|||||||
public class SVars {
|
public class SVars {
|
||||||
public static Fi modRoot = modDirectory.child("UnitInfo");
|
public static Fi modRoot = modDirectory.child("UnitInfo");
|
||||||
public static Seq<PlayerParser.PlayerInfo> playerInfos = new Seq<>();
|
public static Seq<PlayerParser.PlayerInfo> playerInfos = new Seq<>();
|
||||||
|
|
||||||
public static SettingS settingAdder = new SettingS();
|
public static SettingS settingAdder = new SettingS();
|
||||||
public static HudUi hud = new HudUi();
|
public static HudUi hud = new HudUi();
|
||||||
public static PlayerParser playerinfo = new PlayerParser();
|
public static PlayerParser playerinfo = new PlayerParser();
|
||||||
|
|
||||||
public static TextureRegion clear = atlas.find("clear");
|
public static TextureRegion clear = atlas.find("clear");
|
||||||
|
public static float modUiScale = settings.getInt("infoUiScale") / 100f == 0 ? 1 : settings.getInt("infoUiScale") / 100f;
|
||||||
public static float modUiScale = (settings.getInt("infoUiScale") / 100f == 0 ? 1 : settings.getInt("infoUiScale") / 100f);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ import mindustry.world.consumers.*;
|
|||||||
|
|
||||||
import java.lang.reflect.*;
|
import java.lang.reflect.*;
|
||||||
|
|
||||||
|
import static UnitInfo.SUtils.floatFormat;
|
||||||
import static arc.Core.*;
|
import static arc.Core.*;
|
||||||
import static mindustry.Vars.*;
|
import static mindustry.Vars.*;
|
||||||
|
|
||||||
@@ -46,12 +47,6 @@ public class BarInfo {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String format(float number){
|
|
||||||
if(number >= 10000) return UI.formatAmount((long)number);
|
|
||||||
if(String.valueOf(number).split("[.]")[1].matches("0")) return String.valueOf(number).split("[.]")[0];
|
|
||||||
return Strings.fixed(number, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
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
|
for(int i = 0; i < 6; i++) { //init
|
||||||
strings.set(i, "[lightgray]<Empty>[]");
|
strings.set(i, "[lightgray]<Empty>[]");
|
||||||
@@ -77,14 +72,14 @@ public class BarInfo {
|
|||||||
float max2 = 0f;
|
float max2 = 0f;
|
||||||
ForceFieldAbility ffa;
|
ForceFieldAbility ffa;
|
||||||
if((ffa = (ForceFieldAbility) unit.type().abilities.find(abil -> abil instanceof ForceFieldAbility)) != null) max2 = ffa.max;
|
if((ffa = (ForceFieldAbility) unit.type().abilities.find(abil -> abil instanceof ForceFieldAbility)) != null) max2 = ffa.max;
|
||||||
strings.set(1, Core.bundle.format("shar-stat.shield", format(unit.shield())));
|
strings.set(1, Core.bundle.format("shar-stat.shield", floatFormat(unit.shield())));
|
||||||
colors.set(1, Pal.surge);
|
colors.set(1, Pal.surge);
|
||||||
numbers.set(1, unit.shield() / Math.max(max1, max2));
|
numbers.set(1, unit.shield() / Math.max(max1, max2));
|
||||||
}
|
}
|
||||||
else if(target instanceof ForceProjector.ForceBuild force){
|
else 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, Core.bundle.format("shar-stat.shield", format(max-force.buildup), format(max)));
|
strings.set(1, Core.bundle.format("shar-stat.shield", floatFormat(max-force.buildup), floatFormat(max)));
|
||||||
colors.set(1, Pal.shield);
|
colors.set(1, Pal.shield);
|
||||||
numbers.set(1, (max-force.buildup)/max);
|
numbers.set(1, (max-force.buildup)/max);
|
||||||
}
|
}
|
||||||
@@ -134,25 +129,25 @@ public class BarInfo {
|
|||||||
|
|
||||||
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.itemAmmo", format(turret.totalAmmo), format(block.maxAmmo)));
|
strings.set(2, bundle.format("shar-stat.itemAmmo", floatFormat(turret.totalAmmo), floatFormat(block.maxAmmo)));
|
||||||
colors.set(2, turret.hasAmmo() ? block.ammoTypes.findKey(turret.peekAmmo(), true).color : Pal.ammo);
|
colors.set(2, turret.hasAmmo() ? block.ammoTypes.findKey(turret.peekAmmo(), true).color : Pal.ammo);
|
||||||
numbers.set(2, turret.totalAmmo / (float)block.maxAmmo);
|
numbers.set(2, turret.totalAmmo / (float)block.maxAmmo);
|
||||||
}
|
}
|
||||||
else if(target instanceof LiquidTurret.LiquidTurretBuild turret){
|
else if(target instanceof LiquidTurret.LiquidTurretBuild turret){
|
||||||
strings.set(2, bundle.format("shar-stat.liquidAmmo", format(turret.liquids.get(turret.liquids.current())), format(turret.block.liquidCapacity)));
|
strings.set(2, bundle.format("shar-stat.liquidAmmo", floatFormat(turret.liquids.get(turret.liquids.current())), floatFormat(turret.block.liquidCapacity)));
|
||||||
colors.set(2, turret.liquids.current().color);
|
colors.set(2, turret.liquids.current().color);
|
||||||
numbers.set(2, turret.liquids.get(turret.liquids.current()) / turret.block.liquidCapacity);
|
numbers.set(2, turret.liquids.get(turret.liquids.current()) / turret.block.liquidCapacity);
|
||||||
}
|
}
|
||||||
else if(target instanceof PowerTurret.PowerTurretBuild turret){
|
else if(target instanceof PowerTurret.PowerTurretBuild turret){
|
||||||
float max = turret.block.consumes.getPower().usage;
|
float max = turret.block.consumes.getPower().usage;
|
||||||
float v = turret.power.status * turret.power.graph.getLastScaledPowerIn();
|
float v = turret.power.status * turret.power.graph.getLastScaledPowerIn();
|
||||||
strings.set(2, bundle.format("shar-stat.power", format(Math.min(v,max) * 60), format(max * 60)));
|
strings.set(2, bundle.format("shar-stat.power", floatFormat(Math.min(v,max) * 60), floatFormat(max * 60)));
|
||||||
colors.set(2, Pal.powerBar);
|
colors.set(2, Pal.powerBar);
|
||||||
numbers.set(2, v/max);
|
numbers.set(2, v/max);
|
||||||
}
|
}
|
||||||
else if(target instanceof Building b && b.block.hasItems) {
|
else if(target instanceof Building b && b.block.hasItems) {
|
||||||
if(target instanceof CoreBlock.CoreBuild cb){
|
if(target instanceof CoreBlock.CoreBuild cb){
|
||||||
strings.set(2, bundle.format("shar-stat.itemCapacity", format(b.items.total()), format(cb.storageCapacity * content.items().count(UnlockableContent::unlockedNow))));
|
strings.set(2, bundle.format("shar-stat.itemCapacity", floatFormat(b.items.total()), floatFormat(cb.storageCapacity * content.items().count(UnlockableContent::unlockedNow))));
|
||||||
numbers.set(2, cb.items.total() / (cb.storageCapacity * content.items().count(UnlockableContent::unlockedNow) * 1f));
|
numbers.set(2, cb.items.total() / (cb.storageCapacity * content.items().count(UnlockableContent::unlockedNow) * 1f));
|
||||||
}
|
}
|
||||||
else if(target instanceof StorageBlock.StorageBuild sb && !sb.canPickup()){
|
else if(target instanceof StorageBlock.StorageBuild sb && !sb.canPickup()){
|
||||||
@@ -162,17 +157,17 @@ public class BarInfo {
|
|||||||
} catch (IllegalAccessException e) {
|
} catch (IllegalAccessException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
strings.set(2, bundle.format("shar-stat.itemCapacity", format(sb.items.total()), format(cb.storageCapacity * content.items().count(UnlockableContent::unlockedNow))));
|
strings.set(2, bundle.format("shar-stat.itemCapacity", 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));
|
numbers.set(2, sb.items.total() / (cb.storageCapacity * content.items().count(UnlockableContent::unlockedNow) * 1f));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
strings.set(2, bundle.format("shar-stat.itemCapacity", format(b.items.total()), format(b.block.itemCapacity)));
|
strings.set(2, bundle.format("shar-stat.itemCapacity", floatFormat(b.items.total()), floatFormat(b.block.itemCapacity)));
|
||||||
numbers.set(2, b.items.total() / (float) b.block.itemCapacity);
|
numbers.set(2, b.items.total() / (float) b.block.itemCapacity);
|
||||||
}
|
}
|
||||||
colors.set(2, Pal.items);
|
colors.set(2, Pal.items);
|
||||||
}
|
}
|
||||||
else if(target instanceof Unit unit && unit.type != null) {
|
else if(target instanceof Unit unit && unit.type != null) {
|
||||||
strings.set(2, bundle.format("shar-stat.itemCapacity", format(unit.stack.amount), format(unit.type.itemCapacity)));
|
strings.set(2, bundle.format("shar-stat.itemCapacity", 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));
|
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));
|
numbers.set(2, unit.stack.amount / (unit.type.itemCapacity * 1f));
|
||||||
}
|
}
|
||||||
@@ -181,25 +176,25 @@ public class BarInfo {
|
|||||||
if(target instanceof Turret.TurretBuild t){
|
if(target instanceof Turret.TurretBuild t){
|
||||||
Turret turret = (Turret)t.block;
|
Turret turret = (Turret)t.block;
|
||||||
if(turret.chargeTime > 0f) {
|
if(turret.chargeTime > 0f) {
|
||||||
strings.set(3, Core.bundle.format("shar-stat.charge", format((SVars.hud.charge / turret.chargeTime) * 100)));
|
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));
|
colors.set(3, Pal.surge.cpy().lerp(Pal.accent, SVars.hud.charge / turret.chargeTime));
|
||||||
numbers.set(3, SVars.hud.charge / turret.chargeTime);
|
numbers.set(3, SVars.hud.charge / turret.chargeTime);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(target instanceof Unit unit && unit.type != null) {
|
else if(target instanceof Unit unit && unit.type != null) {
|
||||||
strings.set(3, Core.bundle.format("shar-stat.commandUnits", format(Groups.unit.count(u -> u.controller() instanceof FormationAI && ((FormationAI)u.controller()).leader == target)), format(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));
|
||||||
}
|
}
|
||||||
else if(target instanceof UnitFactory.UnitFactoryBuild factory){
|
else if(target instanceof UnitFactory.UnitFactoryBuild factory){
|
||||||
strings.set(3, factory.unit() == null ? "[lightgray]" + Iconc.cancel :
|
strings.set(3, factory.unit() == null ? "[lightgray]" + Iconc.cancel :
|
||||||
Core.bundle.format("bar.unitcap", Fonts.getUnicodeStr(factory.unit().name), format(factory.team.data().countType(factory.unit())), format(Units.getCap(factory.team))));
|
Core.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);
|
colors.set(3, Pal.power);
|
||||||
numbers.set(3, factory.unit() == null ? 0f : (float)factory.team.data().countType(factory.unit()) / Units.getCap(factory.team));
|
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){
|
else if(target instanceof Reconstructor.ReconstructorBuild reconstruct){
|
||||||
strings.set(3, reconstruct.unit() == null ? "[lightgray]" + Iconc.cancel :
|
strings.set(3, reconstruct.unit() == null ? "[lightgray]" + Iconc.cancel :
|
||||||
Core.bundle.format("bar.unitcap", Fonts.getUnicodeStr(reconstruct.unit().name), format(reconstruct.team.data().countType(reconstruct.unit())), format(Units.getCap(reconstruct.team))));
|
Core.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);
|
colors.set(3, Pal.power);
|
||||||
numbers.set(3, reconstruct.unit() == null ? 0f : (float)reconstruct.team.data().countType(reconstruct.unit()) / Units.getCap(reconstruct.team));
|
numbers.set(3, reconstruct.unit() == null ? 0f : (float)reconstruct.team.data().countType(reconstruct.unit()) / Units.getCap(reconstruct.team));
|
||||||
|
|
||||||
@@ -227,26 +222,26 @@ public class BarInfo {
|
|||||||
|
|
||||||
|
|
||||||
if(target instanceof Unit unit && target instanceof Payloadc pay && unit.type != null){
|
if(target instanceof Unit unit && target instanceof Payloadc pay && unit.type != null){
|
||||||
strings.set(4, Core.bundle.format("shar-stat.payloadCapacity", format(Mathf.round(Mathf.sqrt(pay.payloadUsed()))), format(Mathf.round(Mathf.sqrt(unit.type().payloadCapacity)))));
|
strings.set(4, Core.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);
|
colors.set(4, Pal.items);
|
||||||
numbers.set(4, pay.payloadUsed() / unit.type().payloadCapacity);
|
numbers.set(4, pay.payloadUsed() / unit.type().payloadCapacity);
|
||||||
}
|
}
|
||||||
else if(target instanceof Building build && build.block.hasLiquids){
|
else if(target instanceof Building build && build.block.hasLiquids){
|
||||||
strings.set(4, Core.bundle.format("shar-stat.liquidCapacity", format(build.liquids.currentAmount()), format(build.block.liquidCapacity)));
|
strings.set(4, Core.bundle.format("shar-stat.liquidCapacity", floatFormat(build.liquids.currentAmount()), floatFormat(build.block.liquidCapacity)));
|
||||||
colors.set(4, build.liquids.current().color);
|
colors.set(4, build.liquids.current().color);
|
||||||
numbers.set(4, build.liquids.currentAmount()/build.block.liquidCapacity);
|
numbers.set(4, build.liquids.currentAmount()/build.block.liquidCapacity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if(target instanceof Unit unit && state.rules.unitAmmo && unit.type != null){
|
if(target instanceof Unit unit && state.rules.unitAmmo && unit.type != null){
|
||||||
strings.set(5, Core.bundle.format("shar-stat.ammos", format(unit.ammo()), format(unit.type().ammoCapacity)));
|
strings.set(5, Core.bundle.format("shar-stat.ammos", floatFormat(unit.ammo()), floatFormat(unit.type().ammoCapacity)));
|
||||||
colors.set(5, unit.type().ammoType.color());
|
colors.set(5, unit.type().ammoType.color());
|
||||||
numbers.set(5, unit.ammof());
|
numbers.set(5, unit.ammof());
|
||||||
}
|
}
|
||||||
else if(target instanceof Building build && build.block.hasPower && build.block.consumes.hasPower()){
|
else if(target instanceof Building build && build.block.hasPower && build.block.consumes.hasPower()){
|
||||||
ConsumePower cons = build.block.consumes.getPower();
|
ConsumePower cons = build.block.consumes.getPower();
|
||||||
if(cons.buffered) strings.set(5, Core.bundle.format("shar-stat.powerCapacity", format(build.power.status * cons.capacity * 60f), format(cons.capacity * 60f)));
|
if(cons.buffered) strings.set(5, Core.bundle.format("shar-stat.powerCapacity", floatFormat(build.power.status * cons.capacity * 60f), floatFormat(cons.capacity * 60f)));
|
||||||
else strings.set(5, Core.bundle.format("shar-stat.powerUsage", format(build.power.status * cons.usage * 60f), format(cons.usage * 60f)));
|
else strings.set(5, Core.bundle.format("shar-stat.powerUsage", floatFormat(build.power.status * cons.usage * 60f), floatFormat(cons.usage * 60f)));
|
||||||
colors.set(5,Pal.powerBar);
|
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);
|
numbers.set(5, Mathf.zero(cons.requestedPower(build)) && build.power.graph.getPowerProduced() + build.power.graph.getBatteryStored() > 0f ? 1f : build.power.status);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package UnitInfo.ui;
|
package UnitInfo.ui;
|
||||||
|
|
||||||
|
import UnitInfo.SUtils;
|
||||||
import arc.*;
|
import arc.*;
|
||||||
import arc.func.*;
|
import arc.func.*;
|
||||||
import arc.graphics.*;
|
import arc.graphics.*;
|
||||||
@@ -8,16 +9,12 @@ import arc.math.*;
|
|||||||
import arc.math.geom.*;
|
import arc.math.geom.*;
|
||||||
import arc.scene.*;
|
import arc.scene.*;
|
||||||
import arc.scene.style.*;
|
import arc.scene.style.*;
|
||||||
import arc.scene.ui.Label;
|
|
||||||
import arc.scene.ui.layout.*;
|
import arc.scene.ui.layout.*;
|
||||||
import arc.util.Align;
|
import arc.util.Align;
|
||||||
import arc.util.Strings;
|
|
||||||
import arc.util.pooling.*;
|
|
||||||
import mindustry.graphics.*;
|
import mindustry.graphics.*;
|
||||||
import mindustry.ui.*;
|
import mindustry.ui.*;
|
||||||
|
|
||||||
import static UnitInfo.SVars.modUiScale;
|
import static UnitInfo.SVars.modUiScale;
|
||||||
import static mindustry.Vars.player;
|
|
||||||
|
|
||||||
public class SBar extends Element{
|
public class SBar extends Element{
|
||||||
static final Rect scissor = new Rect();
|
static final Rect scissor = new Rect();
|
||||||
@@ -48,21 +45,6 @@ public class SBar extends Element{
|
|||||||
init();
|
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, 1);
|
|
||||||
|
|
||||||
return out;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void init(){
|
public void init(){
|
||||||
boolean ssim = Core.settings.getBool("ssim");
|
boolean ssim = Core.settings.getBool("ssim");
|
||||||
boolean shar = Core.settings.getBool("shar");
|
boolean shar = Core.settings.getBool("shar");
|
||||||
@@ -70,32 +52,32 @@ 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) drawable("unitinfo-barS", 10, 10, 9, 9);
|
bar = (NinePatchDrawable) SUtils.getDrawable(Core.atlas.find("unitinfo-barS"), 10, 10, 9, 9);
|
||||||
top = (NinePatchDrawable) drawable("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(ssim){
|
||||||
bar = (NinePatchDrawable) drawable("unitinfo-barSS", 14, 14, 19, 19);
|
bar = (NinePatchDrawable) SUtils.getDrawable(Core.atlas.find("unitinfo-barSS"), 14, 14, 19, 19);
|
||||||
top = (NinePatchDrawable) drawable("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;
|
||||||
}
|
}
|
||||||
else if(shar){
|
else if(shar){
|
||||||
bar = (NinePatchDrawable) drawable("unitinfo-barSSS", 25, 25, 17, 17);
|
bar = (NinePatchDrawable) SUtils.getDrawable(Core.atlas.find("unitinfo-barSSS"), 25, 25, 17, 17);
|
||||||
top = (NinePatchDrawable) drawable("unitinfo-barSSS-top", 25, 25, 17, 17);
|
top = (NinePatchDrawable) SUtils.getDrawable(Core.atlas.find("unitinfo-barSSS-top"), 25, 25, 17, 17);
|
||||||
spriteWidth = Core.atlas.find("unitinfo-barSSS").width;
|
spriteWidth = Core.atlas.find("unitinfo-barSSS").width;
|
||||||
}
|
}
|
||||||
else if(shar1){
|
else if(shar1){
|
||||||
bar = (NinePatchDrawable) drawable("unitinfo-barSSSS", 25, 25, 17, 17);
|
bar = (NinePatchDrawable) SUtils.getDrawable(Core.atlas.find("unitinfo-barSSSS"), 25, 25, 17, 17);
|
||||||
top = (NinePatchDrawable) drawable("unitinfo-barSSSS-top", 25, 25, 17, 17);
|
top = (NinePatchDrawable) SUtils.getDrawable(Core.atlas.find("unitinfo-barSSSS-top"), 25, 25, 17, 17);
|
||||||
spriteWidth = Core.atlas.find("unitinfo-barSSSS").width;
|
spriteWidth = Core.atlas.find("unitinfo-barSSSS").width;
|
||||||
}
|
}
|
||||||
else if(shar2){
|
else if(shar2){
|
||||||
bar = (NinePatchDrawable) drawable("unitinfo-barSSSSS", 27, 27, 16, 16);
|
bar = (NinePatchDrawable) SUtils.getDrawable(Core.atlas.find("unitinfo-barSSSSS"), 27, 27, 16, 16);
|
||||||
top = (NinePatchDrawable) drawable("unitinfo-barSSSSS-top", 27, 27, 16, 16);
|
top = (NinePatchDrawable) SUtils.getDrawable(Core.atlas.find("unitinfo-barSSSSS-top"), 27, 27, 16, 16);
|
||||||
spriteWidth = Core.atlas.find("unitinfo-barSSSSS").width;
|
spriteWidth = Core.atlas.find("unitinfo-barSSSSS").width;
|
||||||
}
|
}
|
||||||
else if(shar3){
|
else if(shar3){
|
||||||
bar = (NinePatchDrawable) drawable("unitinfo-barSSSSSS", 32, 32, 16, 16);
|
bar = (NinePatchDrawable) SUtils.getDrawable(Core.atlas.find("unitinfo-barSSSSSS"), 32, 32, 16, 16);
|
||||||
top = (NinePatchDrawable) drawable("unitinfo-barSSSSSS-top", 32, 32, 16, 16);
|
top = (NinePatchDrawable) SUtils.getDrawable(Core.atlas.find("unitinfo-barSSSSSS-top"), 32, 32, 16, 16);
|
||||||
spriteWidth = Core.atlas.find("unitinfo-barSSSSSS").width;
|
spriteWidth = Core.atlas.find("unitinfo-barSSSSSS").width;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -103,6 +85,7 @@ public class SBar extends Element{
|
|||||||
@Override
|
@Override
|
||||||
public void draw(){
|
public void draw(){
|
||||||
if(fraction == null) return;
|
if(fraction == null) return;
|
||||||
|
|
||||||
float computed;
|
float computed;
|
||||||
try{
|
try{
|
||||||
computed = Mathf.clamp(fraction.get());
|
computed = Mathf.clamp(fraction.get());
|
||||||
@@ -128,7 +111,6 @@ public class SBar extends Element{
|
|||||||
Draw.colorl(0.1f);
|
Draw.colorl(0.1f);
|
||||||
bar.draw(x, y, width, height);
|
bar.draw(x, y, width, height);
|
||||||
|
|
||||||
|
|
||||||
Draw.color(color.cpy().mul(Pal.lightishGray), blinkColor, blink);
|
Draw.color(color.cpy().mul(Pal.lightishGray), blinkColor, blink);
|
||||||
float topWidth = width * value;
|
float topWidth = width * value;
|
||||||
if(topWidth > spriteWidth){
|
if(topWidth > spriteWidth){
|
||||||
@@ -150,8 +132,6 @@ public class SBar extends Element{
|
|||||||
ScissorStack.pop();
|
ScissorStack.pop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Draw.color();
|
|
||||||
|
|
||||||
Fonts.outline.draw(name, x + width / 2f, y + height * 0.75f, Color.white, Scl.scl(modUiScale < 1 ? modUiScale : 1), false, Align.center);
|
Fonts.outline.draw(name, x + width / 2f, y + height * 0.75f, Color.white, Scl.scl(modUiScale < 1 ? modUiScale : 1), false, Align.center);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user