fixed scaling 1

This commit is contained in:
sharlotte
2021-08-22 12:29:09 +09:00
parent 8590799f76
commit 2464f02ada
3 changed files with 108 additions and 119 deletions

View File

@@ -3,6 +3,7 @@ package UnitInfo;
import UnitInfo.core.*;
import arc.files.*;
import arc.graphics.g2d.TextureRegion;
import arc.scene.ui.layout.Scl;
import arc.struct.*;
import mindustry.world.Tile;
@@ -19,7 +20,7 @@ public class SVars {
public static TextureRegion clear = atlas.find("clear");
public static TextureRegion error = atlas.find("error");
public static float modUiScale = settings.getInt("infoUiScale") / 100f == 0 ? 1 : settings.getInt("infoUiScale") / 100f;
public static float scaledScale = Scl.scl(Math.min(modUiScale, 1));
public static Seq<Tile> pathTiles = new Seq<>();
}

View File

@@ -367,7 +367,7 @@ public class HudUi {
ttt.top().right();
Image image = new Image(Icon.warning.getRegion()).setScaling(Scaling.fit);
image.update(() -> image.setColor(Tmp.c2.set(Color.orange).lerp(Color.scarlet, Mathf.absin(Time.time, 2f, 1f))));
ttt.add(image).size(Scl.scl(Math.min(modUiScale, 1)) * 12f);
ttt.add(image).size(scaledScale * 12f);
ttt.pack();
}));
}}).pad(6);
@@ -448,7 +448,7 @@ public class HudUi {
fontColor = Color.white;
background = Styles.black8;
}});
if(modUiScale < 1) label.setFontScale(Scl.scl(modUiScale));
label.setFontScale(scaledScale);
Table labelTable = new Table(t -> t.add(label).left().padRight(Scl.scl(modUiScale) * 40 * 8f));
table.table(t -> {
@@ -755,7 +755,7 @@ public class HudUi {
public void addUnitTable(){
if(uiIndex != 0) return;
unitTable = new Table(table -> {
table.left().defaults().width(Scl.scl(Math.min(modUiScale, 1)) * 27 * 8f).maxHeight(Scl.scl(Math.min(modUiScale, 1)) * 35 * 8f).align(Align.left);
table.left().defaults().width(scaledScale * 27 * 8f).maxHeight(scaledScale * 35 * 8f).align(Align.left);
addBars();
Table table1 = new Table(Tex.button, t -> {
t.table(Tex.underline2, tt -> {
@@ -802,7 +802,7 @@ public class HudUi {
if(name.length() > 12) return name.substring(0, 12) + "...";
return name;
});
if(modUiScale < 1) label.setFontScale(Scl.scl(modUiScale));
label.setFontScale(scaledScale);
TextButton button = Elem.newButton("?", Styles.clearPartialt, () -> {
if(getTarget() instanceof Unit u && u.type != null)
@@ -845,12 +845,12 @@ public class HudUi {
else if(getTarget() instanceof Building b) return b.block.localizedName;
return "";
});
if(modUiScale < 1) label2.setFontScale(Scl.scl(modUiScale));
label2.setFontScale(scaledScale);
tool2.add(label2);
});
to.row();
Label label2 = new Label(()->getTarget() == null ? "(" + 0 + ", " + 0 + ")" : "(" + Strings.fixed(getTarget().x() / tilesize, 2) + ", " + Strings.fixed(getTarget().y() / tilesize, 2) + ")");
if(modUiScale < 1) label2.setFontScale(Scl.scl(modUiScale));
label2.setFontScale(scaledScale);
to.add(label2);
})));
tt.update(()->tt.setBackground(((NinePatchDrawable)Tex.underline2).tint(getTarget().isNull() ? Color.gray : getTarget().team().color)));
@@ -909,10 +909,8 @@ public class HudUi {
if(!settings.getBool("emptywave") && state.rules.spawns.find(g -> g.getSpawned(j) > 0) == null) continue;
table.table(t -> {
table.center();
final int jj = j+1;
Label label = new Label(() -> "[#" + (state.wave == j+1 ? Color.red.toString() : Pal.accent.toString()) + "]" + jj + "[]");
if(modUiScale < 1) label.setFontScale(Scl.scl(modUiScale));
Label label = new Label(() -> "[#" + (state.wave == j+1 ? Color.red.toString() : Pal.accent.toString()) + "]" + (j+1) + "[]");
label.setFontScale(scaledScale);
t.add(label);
}).size(Scl.scl(modUiScale) * 4 * 8f);
@@ -922,9 +920,8 @@ public class HudUi {
tx.add("[lightgray]<Empty>[]");
return;
}
int row = 0;
ObjectIntMap<SpawnGroup> groups = new ObjectIntMap<>();
ObjectIntMap<SpawnGroup> groups = new ObjectIntMap<>();
for(SpawnGroup group : state.rules.spawns) {
if(group.getSpawned(j) <= 0) continue;
SpawnGroup sameTypeKey = groups.keys().toArray().find(g -> g.type == group.type && g.effect != StatusEffects.boss);
@@ -941,37 +938,36 @@ public class HudUi {
ObjectIntMap<SpawnGroup> groupsTmp = new ObjectIntMap<>();
groupSorted.each(g -> groupsTmp.put(g, groups.get(g)));
int row = 0;
for(SpawnGroup group : groupsTmp.keys()){
int amount = groupsTmp.get(group);
row ++;
tx.table(tt -> {
tt.right();
Image image = new Image(group.type.uiIcon).setScaling(Scaling.fit);
tt.add(new Stack(){{
add(new Table(ttt -> {
tt.stack(
new Table(ttt -> {
ttt.center();
ttt.add(image).size(iconLarge * Scl.scl(Math.min(modUiScale, 1)));
ttt.add(image).size(iconMed * scaledScale);
ttt.pack();
}));
}),
add(new Table(ttt -> {
new Table(ttt -> {
ttt.bottom().left();
Label label = new Label(() -> amount + "");
if(modUiScale < 1) label.setFontScale(Scl.scl(modUiScale));
label.setFontScale(scaledScale * 0.85f);
ttt.add(label);
ttt.pack();
}));
}),
add(new Table(ttt -> {
new Table(ttt -> {
ttt.top().right();
Image image = new Image(Icon.warning.getRegion()).setScaling(Scaling.fit);
image.update(() -> image.setColor(Tmp.c2.set(Color.orange).lerp(Color.scarlet, Mathf.absin(Time.time, 2f, 1f))));
ttt.add(image).size(Scl.scl(Math.min(modUiScale, 1)) * 12f);
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))));
ttt.add(image1).size(scaledScale * 12f);
ttt.visible(() -> group.effect == StatusEffects.boss);
ttt.pack();
}));
}}).pad(2f * Scl.scl(modUiScale));
})
).pad(2f * Scl.scl(modUiScale));
tt.clicked(() -> {
if(input.keyDown(KeyCode.shiftLeft) && Fonts.getUnicode(group.type.name) != 0){
app.setClipboardText((char)Fonts.getUnicode(group.type.name) + "");
@@ -1029,7 +1025,7 @@ public class HudUi {
}
})));
});
if(row % 4 == 0) tx.row();
if(++row % 4 == 0) tx.row();
}
});
table.row();
@@ -1056,7 +1052,7 @@ public class HudUi {
wavePane.setWidget(new Table(tx -> tx.table(this::setWave).left()));
waveTable = new Table(table -> {
table.left().defaults().width(Scl.scl(Math.min(modUiScale, 1)) * 32 * 8f).maxHeight(Scl.scl(Math.min(modUiScale, 1)) * 32 * 8f).align(Align.left);
table.left().defaults().width(scaledScale * 32 * 8f).maxHeight(scaledScale * 32 * 8f).align(Align.left);
table.add(new Table(Tex.button, t -> t.add(wavePane)){
@Override
protected void drawBackground(float x, float y) {
@@ -1065,7 +1061,7 @@ public class HudUi {
getBackground().draw(x, y, width, height);
Draw.reset();
}
}).padRight(Scl.scl(Math.min(modUiScale, 1)) * 39 * 8f);
}).padRight(scaledScale * 39 * 8f);
table.fillParent = true;
table.visibility = () -> uiIndex == 1;
@@ -1078,7 +1074,7 @@ public class HudUi {
if((state.rules.pvp && coreItems.teams[i] != player.team()) || coreItems.teams[i].cores().isEmpty()) continue;
int finalI = i;
Label label = new Label(() -> "[#" + coreItems.teams[finalI].color.toString() + "]" + coreItems.teams[finalI].name + "[]");
if(modUiScale < 1) label.setFontScale(Scl.scl(modUiScale));
label.setFontScale(scaledScale);
t.background(Tex.underline2).add(label).center();
t.row();
t.add(coreItems.tables.get(finalI)).left();
@@ -1104,14 +1100,14 @@ public class HudUi {
});
itemTable = new Table(table -> {
table.left().defaults().width(Scl.scl(Math.min(modUiScale, 1)) * 50 * 8f).height(Scl.scl(Math.min(modUiScale, 1)) * 32 * 8f).align(Align.left);
table.left().defaults().width(scaledScale * 50 * 8f).height(scaledScale * 32 * 8f).align(Align.left);
table.table(Tex.button, t -> {
t.add(itemPane);
t.update(() -> {
NinePatchDrawable patch = (NinePatchDrawable)Tex.button;
t.setBackground(patch.tint(Tmp.c1.set(patch.getPatch().getColor()).a(settings.getInt("uiopacity") / 100f)));
});
}).padRight(Scl.scl(Math.min(modUiScale, 1)) * 39 * 8f);
}).padRight(scaledScale * 39 * 8f);
table.fillParent = true;
table.visibility = () -> uiIndex == 2;

View File

@@ -3,12 +3,8 @@ package UnitInfo.ui;
import arc.Core;
import arc.graphics.Color;
import arc.math.Mathf;
import arc.scene.Element;
import arc.scene.event.HandCursorListener;
import arc.scene.ui.Image;
import arc.scene.ui.Label;
import arc.scene.ui.ScrollPane;
import arc.scene.ui.Tooltip;
import arc.scene.ui.*;
import arc.scene.ui.layout.*;
import arc.struct.*;
import arc.util.Strings;
@@ -24,9 +20,7 @@ import mindustry.type.*;
import mindustry.ui.*;
import mindustry.world.blocks.storage.*;
import java.util.Arrays;
import static UnitInfo.SVars.modUiScale;
import static UnitInfo.SVars.*;
import static arc.Core.*;
import static mindustry.Vars.*;
@@ -39,7 +33,9 @@ public class CoresItemsDisplay {
private CoreBlock.CoreBuild core;
public Team[] teams;
public Seq<Table> tables = new Seq<>();
float heat;
boolean once;
public CoresItemsDisplay(Team[] teams) {
this.teams = teams;
@@ -82,7 +78,7 @@ public class CoresItemsDisplay {
public Table setTable(Team team){
return new Table(t -> {
t.clear();
t.background(Styles.black6).margin(2).defaults().width(Scl.scl(Math.min(modUiScale, 1)) * 48 * 8f);
t.background(Styles.black6).margin(2).defaults().width(scaledScale * 48 * 8f);
t.update(() -> {
core = team.core();
@@ -92,98 +88,94 @@ public class CoresItemsDisplay {
heat = 0;
updateItem(team);
}
if(coreAmount.get(team) != team.cores().size ||
content.items().contains(item -> core != null && core.items.get(item) > 0 && usedItems.get(team).add(item)) ||
content.units().contains(unit -> Groups.unit.count(u -> u.type == unit && u.team == team) > 0 && usedUnits.get(team).add(unit))){
if(coreAmount.get(team) != team.cores().size){
coreAmount.put(team, team.cores().size);
rebuild();
}
});
final int[] i = {0};
t.table(coretable -> {
final int[] i = {0};
for(CoreBlock.CoreBuild core : team.cores()) {
coretable.table().update(tt -> {
tt.clear();
tt.table(ttt -> {
ttt.stack(
new Table(s -> {
s.center();
Image image = new Image(core.block.uiIcon);
image.clicked(() -> {
if(control.input instanceof DesktopInput)
((DesktopInput) control.input).panning = true;
Core.camera.position.set(core.x, core.y);
});
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.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) + ")");
if (modUiScale < 1) label.setFontScale(Scl.scl(modUiScale));
tttt.background(Tex.button).add(label);
}));
s.add(image).size(iconLarge * Scl.scl(Math.min(modUiScale, 1)));
}),
new Table(h -> {
h.bottom().defaults().height(Scl.scl(modUiScale) * 9f).width(Scl.scl(modUiScale) * iconLarge * 1.5f).growX();
h.add(new SBar(() -> "", () -> Pal.health, () -> core.health / core.block.health).rect().init());
h.pack();
})
);
ttt.row();
Label label = new Label(() -> "(" + (int) core.x / 8 + ", " + (int) core.y / 8 + ")");
label.setFontScale(Scl.scl(Math.min(modUiScale, 1)) * 0.75f);
ttt.add(label);
});
if(++i[0] % 5 == 0) coretable.row();
}).padLeft(4).padRight(4);
coretable.table(tt -> {
tt.stack(
new Table(s -> {
s.center();
Image image = new Image(core.block.uiIcon);
image.clicked(() -> {
if(control.input instanceof DesktopInput)
((DesktopInput) control.input).panning = true;
Core.camera.position.set(core.x, core.y);
});
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.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) + ")");
if (modUiScale < 1) label.setFontScale(Scl.scl(modUiScale));
tttt.background(Tex.button).add(label);
}));
s.add(image).size(iconLarge * scaledScale);
}),
new Table(h -> {
h.bottom().defaults().height(Scl.scl(modUiScale) * 9f).width(Scl.scl(modUiScale) * iconLarge * 1.5f).growX();
h.add(new SBar(() -> "", () -> Pal.health, () -> core.health / core.block.health).rect().init());
h.pack();
})
);
tt.row();
Label label = new Label(() -> "(" + (int) core.x / 8 + ", " + (int) core.y / 8 + ")");
label.setFontScale(scaledScale * 0.75f);
tt.add(label);
}).padTop(scaledScale * 2).padLeft(scaledScale * 4).padRight(scaledScale * 4);
if(++i[0] % 5 == 0) coretable.row();
}
});
t.row();
i[0] = 0;
t.table(itemTable -> {
itemTable.center();
t.table().update(itemTable -> {
itemTable.clear();
final int[] i = {0};
for(Item item : content.items()){
itemTable.table().update(tt -> {
tt.clear();
if(team.core() != null && team.core().items.has(item)) {
tt.stack(
new Table(ttt -> {
ttt.image(item.uiIcon).size(iconSmall * Scl.scl(Math.min(modUiScale, 1))).tooltip(tttt -> tttt.background(Styles.black6).margin(2f * Scl.scl(Math.min(modUiScale, 1))).add(item.localizedName).style(Styles.outlineLabel));
Label label = new Label(() -> core == null ? "0" : UI.formatAmount(core.items.get(item)));
label.setFontScale(Scl.scl(Math.min(modUiScale, 1)));
ttt.add(label).minWidth(5 * 8f * Scl.scl(Math.min(modUiScale, 1))).left();
}),
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 + "[]";
});
label.setFontScale(0.65f * Scl.scl(Math.min(modUiScale, 1)));
ttt.add(label).bottom().right().padTop(16f * Scl.scl(Math.min(modUiScale, 1)));
ttt.pack();
})
).padRight(3 * Scl.scl(Math.min(modUiScale, 1))).left();
if(++i[0] % 5 == 0) itemTable.row();
};
});
itemTable.table(tt -> {
tt.center();
if(team.core() != null && team.core().items.has(item)) {
tt.stack(
new Table(ttt -> {
ttt.image(item.uiIcon).size(iconSmall * scaledScale).tooltip(tttt -> tttt.background(Styles.black6).margin(2f * scaledScale).add(item.localizedName).style(Styles.outlineLabel));
Label label = new Label(() -> core == null ? "0" : UI.formatAmount(core.items.get(item)));
label.setFontScale(scaledScale);
ttt.add(label).minWidth(5 * 8f * scaledScale).left();
}),
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 + "[]";
});
label.setFontScale(0.65f * scaledScale);
ttt.add(label).bottom().right().padTop(16f * scaledScale);
ttt.pack();
})
).padRight(3 * scaledScale).left();
if(++i[0] % 5 == 0) itemTable.row();
};
});
}
});
t.row();
i[0] = 0;
t.table(unitTable -> {
unitTable.center();
t.table().update(unitTable -> {
unitTable.clear();
final int[] i = {0};
for(UnitType unit : content.units()){
unitTable.table().update(tt -> {
tt.clear();
unitTable.table(tt -> {
tt.center();
if(unit != UnitTypes.block && Groups.unit.contains(u -> u.type == unit && u.team == team)){
tt.image(unit.uiIcon).size(iconSmall * Scl.scl(Math.min(modUiScale, 1))).padRight(3 * Scl.scl(Math.min(modUiScale, 1))).tooltip(ttt -> ttt.background(Styles.black6).margin(2f * Scl.scl(Math.min(modUiScale, 1))).add(unit.localizedName).style(Styles.outlineLabel));
tt.image(unit.uiIcon).size(iconSmall * scaledScale).padRight(3 * scaledScale).tooltip(ttt -> ttt.background(Styles.black6).margin(2f * scaledScale).add(unit.localizedName).style(Styles.outlineLabel));
Label label = new Label(() -> core == null ? "0" : UI.formatAmount(Groups.unit.count(u -> u.team == team && u.type == unit)));
label.setFontScale(Scl.scl(Math.min(modUiScale, 1)));
tt.add(label).padRight(3 * Scl.scl(Math.min(modUiScale, 1))).minWidth(5 * 8f * Scl.scl(Math.min(modUiScale, 1))).left();
label.setFontScale(scaledScale);
tt.add(label).padRight(3 * scaledScale).minWidth(5 * 8f * scaledScale).left();
if(++i[0] % 5 == 0) unitTable.row();
}
});