bundle typotypo

This commit is contained in:
sharlotte
2021-08-25 09:42:26 +09:00
parent 775b402077
commit 2c98adde28
8 changed files with 189 additions and 210 deletions

View File

@@ -1,6 +1,7 @@
package UnitInfo;
import UnitInfo.core.*;
import arc.Core;
import arc.files.*;
import arc.graphics.g2d.TextureRegion;
import arc.scene.ui.TextButton;

View File

@@ -281,8 +281,8 @@ public class BarInfo {
}
else if(build.block.consumes.hasPower()){
ConsumePower cons = build.block.consumes.getPower();
if(cons.buffered) strings.set(5, bundle.format("shar-stat.powerCapacity", floatFormat(build.power.status * cons.capacity * 60f), floatFormat(cons.capacity * 60f)));
else strings.set(5, bundle.format("shar-stat.powerUsage", floatFormat(build.power.status * cons.usage * 60f), floatFormat(cons.usage * 60f)));
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);
}

View File

@@ -57,13 +57,11 @@ public class HudUi {
ImageButton lockButton;
boolean locked = false;
float charge;
float a;
int uiIndex = 0;
//to update tables
int waveamount;
int coreamounts;
int enemyamount;
//is this rly good idea?
@@ -551,6 +549,7 @@ public class HudUi {
add(new Table(){{
left();
update(() -> {
if(!Core.settings.getBool("infoui")) return;
Element image = new Element();
if(getTarget() instanceof ItemTurret.ItemTurretBuild turret){
if(turret.hasAmmo()) image = new Image(((ItemTurret)turret.block).ammoTypes.findKey(turret.peekAmmo(), true).uiIcon);
@@ -597,6 +596,7 @@ public class HudUi {
t.left();
t.add(new Image(){{
update(() -> {
if(!Core.settings.getBool("infoui")) return;
if(getTarget() instanceof Unit u && u.stack.item != null && u.stack.amount > 0)
setDrawable(u.stack.item.uiIcon);
else setDrawable(clear);
@@ -651,6 +651,7 @@ public class HudUi {
t.left();
t.add(new Image(){{
update(() -> {
if(!Core.settings.getBool("infoui")) return;
TextureRegion region = clear;
if(Vars.state.rules.unitAmmo && getTarget() instanceof Unit u && u.type != null){
@@ -668,11 +669,12 @@ public class HudUi {
public void addWeaponTable(Table table){
table.table().update(t -> {
if(!Core.settings.getBool("infoui")) return;
t.clear();
t.add(new Table(((NinePatchDrawable)Tex.button).tint(Tmp.c1.set(((NinePatchDrawable)Tex.button).getPatch().getColor()).a(settings.getInt("uiopacity") / 100f)), tt -> {
tt.defaults().width(Scl.scl(modUiScale) * 8 * 8f).minHeight(Scl.scl(modUiScale) * 4 * 8f).align(Align.left);
tt.visibility = () -> settings.getBool("weaponui") && getTarget() instanceof Unit u && u.type != null && u.type.weapons.size > 0;
if(settings.getBool("weaponui") && getTarget() instanceof Unit u && u.type != null) {
tt.visibility = () -> getTarget() instanceof Unit u && u.type != null && u.type.weapons.size > 0;
if(getTarget() instanceof Unit u && u.type != null) {
UnitType type = u.type;
for(int r = 0; r < type.weapons.size; r++){
Weapon weapon = type.weapons.get(r);
@@ -736,6 +738,7 @@ public class HudUi {
float[] count = new float[]{-1};
table1.table().update(t -> {
if(!Core.settings.getBool("infoui")) return;
if(getTarget() instanceof Payloadc payload){
if(count[0] != payload.payloadUsed()){
t.clear();
@@ -763,6 +766,7 @@ public class HudUi {
Bits statuses = new Bits();
table1.table().update(t -> {
if(!Core.settings.getBool("infoui")) return;
t.left();
if(getTarget() instanceof Statusc st){
Bits applied = st.statusBits();
@@ -843,7 +847,10 @@ public class HudUi {
}
});
button.visibility = () -> getTarget() != null;
button.update(()->lockButton.getStyle().imageUp = Icon.lock.tint(locked ? Pal.accent : Color.white));
button.update(() -> {
if(!Core.settings.getBool("infoui")) return;
lockButton.getStyle().imageUp = Icon.lock.tint(locked ? Pal.accent : Color.white);
});
button.getLabel().setFontScale(Scl.scl(modUiScale));
lockButton = Elem.newImageButton(Styles.clearPartiali, Icon.lock.tint(locked ? Pal.accent : Color.white), 3 * 8f * Scl.scl(modUiScale), () -> {
@@ -882,7 +889,10 @@ public class HudUi {
label2.setFontScale(modUiScale);
to.add(label2);
})));
tt.update(()->tt.setBackground(((NinePatchDrawable)Tex.underline2).tint(getTarget().isNull() ? Color.gray : getTarget().team().color)));
tt.update(() -> {
if(!Core.settings.getBool("infoui")) return;
tt.setBackground(((NinePatchDrawable)Tex.underline2).tint(getTarget().isNull() ? Color.gray : getTarget().team().color));
});
});
t.row();
t.table(tt -> {
@@ -894,19 +904,18 @@ public class HudUi {
}
});
t.setColor(t.color.cpy().a(1f));
t.background(Tex.button);
t.update(() -> {
if(!Core.settings.getBool("infoui")) return;
NinePatchDrawable patch = (NinePatchDrawable)Tex.button;
t.setBackground(patch.tint(Tmp.c1.set(patch.getPatch().getColor()).a(settings.getInt("uiopacity") / 100f)));
});
});
table.table(t -> t.stack(table1, addInfoTable(t)));
table.row();
table.table(t -> t.stack(table1, addInfoTable(t))).row();
table.table(this::addWeaponTable);
table.update(() -> {
if(!Core.settings.getBool("infoui")) return;
try {
BarInfo.getInfo(getTarget());
} catch (IllegalAccessException | NoSuchFieldException e) {
@@ -915,11 +924,6 @@ public class HudUi {
strings = BarInfo.strings;
numbers = BarInfo.numbers;
colors = BarInfo.colors;
if(getTarget() instanceof Turret.TurretBuild tb){
if(tb.charging) charge += Time.delta;
else charge = 0f;
}
});
table.fillParent = true;
@@ -990,7 +994,10 @@ public class HudUi {
new Table(ttt -> {
ttt.top().right();
Image image1 = new Image(Icon.warning.getRegion()).setScaling(Scaling.fit);
image1.update(() -> image1.setColor(Tmp.c2.set(Color.orange).lerp(Color.scarlet, Mathf.absin(Time.time, 2f, 1f))));
image1.update(() -> {
if(!Core.settings.getBool("infoui")) return;
image1.setColor(Tmp.c2.set(Color.orange).lerp(Color.scarlet, Mathf.absin(Time.time, 2f, 1f)));
});
ttt.add(image1).size(Scl.scl(modUiScale) * 12f);
ttt.visible(() -> group.effect == StatusEffects.boss);
ttt.pack();
@@ -1007,7 +1014,10 @@ public class HudUi {
if(!mobile){
HandCursorListener listener1 = new HandCursorListener();
tt.addListener(listener1);
tt.update(() -> image.color.lerp(!listener1.isOver() ? Color.lightGray : Color.white, Mathf.clamp(0.4f * Time.delta)));
tt.update(() -> {
if(!Core.settings.getBool("infoui")) return;
image.color.lerp(!listener1.isOver() ? Color.lightGray : Color.white, Mathf.clamp(0.4f * Time.delta));
});
}
tt.addListener(new Tooltip(t -> t.background(Tex.button).table(to -> {
to.left();
@@ -1020,7 +1030,10 @@ public class HudUi {
if(group.effect == StatusEffects.boss){
status = new Image(Icon.warning.getRegion()).setScaling(Scaling.fit);
Image finalStatus = status;
status.update(() -> finalStatus.setColor(Tmp.c2.set(Color.orange).lerp(Color.scarlet, Mathf.absin(Time.time, 2f, 1f))));
status.update(() -> {
if(!Core.settings.getBool("infoui")) return;
finalStatus.setColor(Tmp.c2.set(Color.orange).lerp(Color.scarlet, Mathf.absin(Time.time, 2f, 1f)));
});
}
Image finalStatus = status;
to.table(tot -> {
@@ -1030,7 +1043,10 @@ public class HudUi {
if(!mobile){
HandCursorListener listener = new HandCursorListener();
finalStatus.addListener(listener);
finalStatus.update(() -> finalStatus.color.lerp(!listener.isOver() ? Color.lightGray : Color.white, Mathf.clamp(0.4f * Time.delta)));
finalStatus.update(() -> {
if(!Core.settings.getBool("infoui")) return;
finalStatus.color.lerp(!listener.isOver() ? Color.lightGray : Color.white, Mathf.clamp(0.4f * Time.delta));
});
}
tot.add("[stat]" + group.effect.localizedName);
}).size(iconMed * Scl.scl(modUiScale));
@@ -1069,6 +1085,7 @@ public class HudUi {
wavePane.setScrollingDisabled(true, false);
wavePane.setScrollYForce(waveScrollPos);
wavePane.update(() -> {
if(!Core.settings.getBool("infoui")) return;
if(wavePane.hasScroll()){
Element result = scene.hit(input.mouseX(), input.mouseY(), true);
if(result == null || !result.isDescendantOf(wavePane)){
@@ -1099,6 +1116,7 @@ public class HudUi {
public void setItem(Table table){
table.table().update(t -> {
if(!Core.settings.getBool("infoui")) return;
t.clear();
for(int i = 0; i < coreItems.tables.size; i++){
if((state.rules.pvp && coreItems.teams[i] != player.team()) || coreItems.teams[i].cores().isEmpty()) continue;
@@ -1123,6 +1141,7 @@ public class HudUi {
itemPane.setScrollYForce(itemScrollPos);
itemPane.setOverscroll(false, false);
itemPane.update(() -> {
if(!Core.settings.getBool("infoui")) return;
if(itemPane.hasScroll()){
Element result = scene.hit(input.mouseX(), input.mouseY(), true);
if(result == null || !result.isDescendantOf(itemPane)){
@@ -1137,6 +1156,7 @@ public class HudUi {
table.table(Tex.button, t -> {
t.add(itemPane);
t.update(() -> {
if(!Core.settings.getBool("infoui")) return;
NinePatchDrawable patch = (NinePatchDrawable)Tex.button;
t.setBackground(patch.tint(Tmp.c1.set(patch.getPatch().getColor()).a(settings.getInt("uiopacity") / 100f)));
});

View File

@@ -19,30 +19,6 @@ import static mindustry.Vars.*;
public class SettingS {
public SettingsMenuDialog.SettingsTable sharset;
public void addGraphicSlideSetting(String key, int def, int min, int max, int step, SettingsMenuDialog.StringProcessor s, Seq<SharSetting> list){
list.add(new SharSetting(key, def) {
@Override
public void add(Table table){
Label value = new Label("");
value.setStyle(Styles.outlineLabel);
value.touchable = Touchable.disabled;
value.setAlignment(Align.center);
value.setWrap(true);
Slider slider = new Slider(min, max, step, false);
slider.setValue(settings.getInt(name));
slider.changed(() -> {
settings.put(name, (int)slider.getValue());
value.setText(title + ": " + s.get((int)slider.getValue()));
});
slider.change();
table.stack(slider, value).width(Math.min(Core.graphics.getWidth() / 1.2f, 460f)).row();
}
});
}
public void addGraphicCheckSetting(String key, boolean def, Seq<SharSetting> list){
list.add(new SharSetting(key, def) {
@@ -52,7 +28,38 @@ public class SettingS {
box.update(() -> box.setChecked(settings.getBool(name)));
box.changed(() -> settings.put(name, box.isChecked()));
table.add(box).row();
box.left();
addDesc(table.add(box).left().padTop(3f).get());
table.row();
}
});
}
public void addGraphicSlideSetting(String key, int def, int min, int max, int step, SettingsMenuDialog.StringProcessor sp, Seq<SharSetting> list){
list.add(new SharSetting(key, def) {
@Override
public void add(Table table){
Slider slider = new Slider(min, max, step, false);
slider.setValue(settings.getInt(name));
Label value = new Label("", Styles.outlineLabel);
Table content = new Table();
content.add(title, Styles.outlineLabel).left().growX().wrap();
content.add(value).padLeft(10f).right();
content.margin(3f, 33f, 3f, 33f);
content.touchable = Touchable.disabled;
slider.changed(() -> {
settings.put(name, (int)slider.getValue());
value.setText(sp.get((int)slider.getValue()));
});
slider.change();
addDesc(table.stack(slider, content).width(Math.min(Core.graphics.getWidth() / 1.2f, 460f)).left().padTop(4f).get());
table.row();
}
});
}
@@ -61,19 +68,21 @@ public class SettingS {
list.add(new SharSetting(key, def) {
@Override
public void add(Table settingsTable) {
public void add(Table table) {
final String[] str = {""};
settingsTable.table(t -> {
Table table1 = new Table(t -> {
t.add(new Label(title + ": ")).left().padRight(5)
.update(a -> a.setColor(condition.get() ? Color.white : Color.gray));
.update(a -> a.setColor(condition.get() ? Color.white : Color.gray));
t.field((integer ? settings.getInt(key) : settings.getFloat(key)) + str[0], s -> {
settings.put(key, integer ? Strings.parseInt(s) : Strings.parseFloat(s));
str[0] = h.get(s);
}).update(a -> a.setDisabled(!condition.get()))
.valid(f -> Strings.canParsePositiveFloat(f) && Strings.parseFloat(f) >= min && Strings.parseFloat(f) <= max).width(120f).left();
settings.put(key, integer ? Strings.parseInt(s) : Strings.parseFloat(s));
str[0] = h.get(s);
}).update(a -> a.setDisabled(!condition.get()))
.valid(f -> Strings.canParsePositiveFloat(f) && Strings.parseFloat(f) >= min && Strings.parseFloat(f) <= max).width(120f).left();
});
settingsTable.row();
addDesc(table.add(table1).left().padTop(4f).get());
table.row();
}
});
}
@@ -92,15 +101,13 @@ public class SettingS {
Seq<Seq<SharSetting>> settingSeq = new Seq<>();
Seq<SharSetting> tapSeq = new Seq<>();
addGraphicCheckSetting("infoui", true, tapSeq);
addGraphicCheckSetting("weaponui", true, tapSeq);
addGraphicTypeSetting("wavemax", 0, 100,200, true, () -> true, s -> s + "waves", tapSeq);
addGraphicCheckSetting("pastwave", false, tapSeq);
addGraphicCheckSetting("emptywave", true, tapSeq);
addGraphicSlideSetting("barstyle", 0, 0, 5, 1, s -> s == 0 ? "default bar" : s + "th bar", tapSeq);
addGraphicSlideSetting("infoUiScale", 100, 50, 100, 5, s -> s + "%", tapSeq);
addGraphicSlideSetting("coreItemCheckRate", 60, 6, 180, 6, s -> Strings.fixed(s/60f,1) + "sec", tapSeq);
addGraphicCheckSetting("allTeam", false, tapSeq);
addGraphicTypeSetting("wavemax", 0, 100,200, true, () -> true, s -> s + "waves", tapSeq);
addGraphicCheckSetting("infoui", true, tapSeq);
addGraphicCheckSetting("pastwave", false, tapSeq);
addGraphicCheckSetting("emptywave", true, tapSeq);
Seq<SharSetting> rangeSeq = new Seq<>();
addGraphicTypeSetting("rangeRadius", 0, 50, 20, true, () -> true, s -> s + "tiles", rangeSeq);
@@ -118,6 +125,7 @@ public class SettingS {
addGraphicSlideSetting("softRangeOpacity", 10, 0, 25, 1, s -> s + "%", opacitySeq);
Seq<SharSetting> drawSeq = new Seq<>();
addGraphicTypeSetting("unitlinelimit", 0, 500, 50, true, () -> true, s -> s + "units", drawSeq);
addGraphicCheckSetting("gaycursor", false, drawSeq);
addGraphicCheckSetting("unithealthui", true, drawSeq);
addGraphicCheckSetting("linkedMass", true, drawSeq);
@@ -125,10 +133,10 @@ public class SettingS {
addGraphicCheckSetting("select", true, drawSeq);
addGraphicCheckSetting("deadTarget", false, drawSeq);
addGraphicCheckSetting("distanceLine", true, drawSeq);
addGraphicSlideSetting("unitlinelimit", 50, 50, 250, 10, s -> s + "units", drawSeq);
Seq<SharSetting> etcSeq = new Seq<>();
addGraphicCheckSetting("autoShooting", false, etcSeq);
settingSeq.add(tapSeq, rangeSeq, opacitySeq);
settingSeq.add(drawSeq, etcSeq);
@@ -151,26 +159,12 @@ public class SettingS {
for(int i = 0; i < settingSeq.size; i++){
int finalI = i;
stack.add(new Table(st -> {
st.center();
for(SharSetting setting : settingSeq.get(finalI)) {
Label label = new Label(setting.description);
label.setColor(Color.gray);
label.setFontScale(0.75f);
st.table(stt -> {
stt.center();
setting.add(stt);
stt.add(label);
}).row();
}
for(SharSetting setting : settingSeq.get(finalI))
st.table(setting::add).left().row();
st.button(Core.bundle.get("settings.reset", "Reset to Defaults"), () -> {
for(SharSetting setting : settingSeq.get(finalI)) {
if(setting.name != null && setting.title != null) {
Core.settings.put(setting.name, Core.settings.getDefault(setting.name));
}
}
}).margin(14.0F).width(240.0F).pad(6.0F);
settingSeq.get(finalI).each(s -> Core.settings.put(s.name, Core.settings.getDefault(s.name)));
}).margin(14.0f).width(240.0f).pad(6.0f);
st.visibility = () -> buttons.get(finalI).isChecked();
st.pack();
}));

View File

@@ -35,7 +35,6 @@ public class CoresItemsDisplay {
public Seq<Table> tables = new Seq<>();
float heat;
boolean once;
public CoresItemsDisplay(Team[] teams) {
this.teams = teams;
@@ -48,8 +47,7 @@ public class CoresItemsDisplay {
updateItems.clear();
prevItems.clear();
coreAmount.clear();
if(settings.getBool("allTeam")) teams = Team.all;
else teams = Team.baseTeams;
teams = new Seq<Team>(Team.all).filter(t -> !t.cores().isEmpty()).toArray();
for(Team team : teams) {
usedItems.put(team, new ObjectSet<>());
usedUnits.put(team, new ObjectSet<>());
@@ -80,6 +78,7 @@ public class CoresItemsDisplay {
t.clear();
t.update(() -> {
if(!Core.settings.getBool("infoui")) return;
core = team.core();
heat += Time.delta;
@@ -109,7 +108,10 @@ public class CoresItemsDisplay {
if(!mobile) {
HandCursorListener listener1 = new HandCursorListener();
image.addListener(listener1);
image.update(() -> image.color.lerp(!listener1.isOver() ? Color.lightGray : Color.white, Mathf.clamp(0.4f * Time.delta)));
image.update(() -> {
if(!Core.settings.getBool("infoui")) return;
image.color.lerp(!listener1.isOver() ? Color.lightGray : Color.white, Mathf.clamp(0.4f * Time.delta));
});
}
image.addListener(new Tooltip(tttt -> {
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) + ")");
@@ -134,6 +136,7 @@ public class CoresItemsDisplay {
});
t.row();
t.table().update(itemTable -> {
if(!Core.settings.getBool("infoui")) return;
itemTable.clear();
final int[] i = {0};
for(Item item : content.items()){
@@ -148,8 +151,8 @@ public class CoresItemsDisplay {
new Table(ttt -> {
ttt.bottom().right();
Label label = new Label(() -> {
int amount = updateItems.get(team).get(item.id).amount;
return (amount > 0 ? "[green]+" : amount == 0 ? "[orange]" : "[red]") + amount + "[]";
int amount = updateItems.get(team).get(item.id).amount / (settings.getInt("coreItemCheckRate") / 60);
return (amount > 0 ? "[green]+" : amount == 0 ? "[orange]" : "[red]") + amount + "/s[]";
});
label.setFontScale(0.65f * modUiScale);
ttt.add(label).bottom().right().padTop(16f * modUiScale);
@@ -162,6 +165,7 @@ public class CoresItemsDisplay {
});
t.row();
t.table().update(unitTable -> {
if(!Core.settings.getBool("infoui")) return;
unitTable.clear();
final int[] i = {0};
for(UnitType unit : content.units()){