fixed smth

This commit is contained in:
sharlotte
2021-08-23 11:11:53 +09:00
parent ac8aa3072c
commit 0333fe4d87
5 changed files with 72 additions and 37 deletions

View File

@@ -22,4 +22,11 @@ public class SUtils {
if(String.valueOf(number).split("[.]")[1].matches("0")) return String.valueOf(number).split("[.]")[0]; if(String.valueOf(number).split("[.]")[1].matches("0")) return String.valueOf(number).split("[.]")[0];
return Strings.fixed(number, 1); return Strings.fixed(number, 1);
} }
public static Object invoke(Object ut, String fieldName) throws IllegalAccessException, NoSuchFieldException {
Field field = ut.getClass().getDeclaredField(fieldName);
field.setAccessible(true);
return field.get(ut);
}
} }

View File

@@ -20,7 +20,6 @@ public class SVars {
public static TextureRegion clear = atlas.find("clear"); public static TextureRegion clear = atlas.find("clear");
public static TextureRegion error = atlas.find("error"); public static TextureRegion error = atlas.find("error");
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;
public static float scaledScale = Scl.scl(Math.min(modUiScale, 1));
public static Seq<Tile> pathTiles = new Seq<>(); public static Seq<Tile> pathTiles = new Seq<>();
} }

View File

@@ -269,7 +269,7 @@ public class HudUi {
}); });
Events.run(EventType.Trigger.update, ()->{ Events.run(EventType.Trigger.update, ()->{
if(modUiScale != settings.getInt("infoUiScale") / 100f){ if(Scl.scl(modUiScale) != settings.getInt("infoUiScale") / 100f){
modUiScale = settings.getInt("infoUiScale") / 100f; modUiScale = settings.getInt("infoUiScale") / 100f;
mainTable.clearChildren(); mainTable.clearChildren();
addTable(); addTable();
@@ -368,7 +368,7 @@ public class HudUi {
ttt.top().right(); ttt.top().right();
Image image = new Image(Icon.warning.getRegion()).setScaling(Scaling.fit); 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)))); image.update(() -> image.setColor(Tmp.c2.set(Color.orange).lerp(Color.scarlet, Mathf.absin(Time.time, 2f, 1f))));
ttt.add(image).size(modUiScale * 12f); ttt.add(image).size(Scl.scl(modUiScale) * 12f);
ttt.pack(); ttt.pack();
})); }));
}}).pad(6); }}).pad(6);
@@ -376,6 +376,7 @@ public class HudUi {
}); });
}); });
t.row(); t.row();
i[0] = 0;
content.units().each(type -> Groups.unit.contains(u -> u.type == type && u.team == state.rules.waveTeam && !u.isBoss()), type -> { content.units().each(type -> Groups.unit.contains(u -> u.type == type && u.team == state.rules.waveTeam && !u.isBoss()), type -> {
t.table(tt -> { t.table(tt -> {
tt.add(new Stack() {{ tt.add(new Stack() {{
@@ -677,10 +678,10 @@ 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 SBar(
() -> "", () -> "",
() -> 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).rect().init());
h.pack(); h.pack();
}) })
); );
@@ -748,7 +749,7 @@ public class HudUi {
public void addUnitTable(){ public void addUnitTable(){
if(uiIndex != 0) return; if(uiIndex != 0) return;
unitTable = new Table(table -> { unitTable = new Table(table -> {
table.left().defaults().width(modUiScale * 27 * 8f).maxHeight(modUiScale * 35 * 8f); table.left().defaults().width(Scl.scl(modUiScale) * 27 * 8f).maxHeight(Scl.scl(modUiScale) * 35 * 8f);
addBars(); addBars();
Table table1 = new Table(Tex.button, t -> { Table table1 = new Table(Tex.button, t -> {
t.left(); t.left();
@@ -804,9 +805,8 @@ public class HudUi {
} }
}); });
button.visibility = () -> getTarget() != null; button.visibility = () -> getTarget() != null;
button.update(()->{ button.update(()->lockButton.getStyle().imageUp = Icon.lock.tint(locked ? Pal.accent : Color.white));
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), () -> { lockButton = Elem.newImageButton(Styles.clearPartiali, Icon.lock.tint(locked ? Pal.accent : Color.white), 3 * 8f * Scl.scl(modUiScale), () -> {
locked = !locked; locked = !locked;
@@ -935,14 +935,14 @@ public class HudUi {
tt.stack( tt.stack(
new Table(ttt -> { new Table(ttt -> {
ttt.center(); ttt.center();
ttt.add(image).size(iconMed * modUiScale); ttt.add(image).size(iconMed * Scl.scl(modUiScale));
ttt.pack(); ttt.pack();
}), }),
new Table(ttt -> { new Table(ttt -> {
ttt.bottom().left(); ttt.bottom().left();
Label label = new Label(() -> amount + ""); Label label = new Label(() -> amount + "");
label.setFontScale(modUiScale * 0.85f); label.setFontScale(Scl.scl(modUiScale) * 0.85f);
ttt.add(label); ttt.add(label);
ttt.pack(); ttt.pack();
}), }),
@@ -951,7 +951,7 @@ public class HudUi {
ttt.top().right(); ttt.top().right();
Image image1 = new Image(Icon.warning.getRegion()).setScaling(Scaling.fit); 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(() -> image1.setColor(Tmp.c2.set(Color.orange).lerp(Color.scarlet, Mathf.absin(Time.time, 2f, 1f))));
ttt.add(image1).size(modUiScale * 12f); ttt.add(image1).size(Scl.scl(modUiScale) * 12f);
ttt.visible(() -> group.effect == StatusEffects.boss); ttt.visible(() -> group.effect == StatusEffects.boss);
ttt.pack(); ttt.pack();
}) })
@@ -1043,14 +1043,14 @@ public class HudUi {
wavePane.setWidget(new Table(tx -> tx.table(this::setWave).left())); wavePane.setWidget(new Table(tx -> tx.table(this::setWave).left()));
waveTable = new Table(table -> { waveTable = new Table(table -> {
table.left().defaults().width(modUiScale * 32 * 8f).maxHeight(modUiScale * 32 * 8f).align(Align.left); table.left().defaults().width(Scl.scl(modUiScale) * 35 * 8f).maxHeight(Scl.scl(modUiScale) * 32 * 8f).align(Align.left);
table.add(new Table(Tex.button, t -> { table.add(new Table(Tex.button, t -> {
t.add(wavePane); t.add(wavePane);
t.update(() -> { t.update(() -> {
NinePatchDrawable patch = (NinePatchDrawable)Tex.button; NinePatchDrawable patch = (NinePatchDrawable)Tex.button;
t.setBackground(patch.tint(Tmp.c1.set(patch.getPatch().getColor()).a(settings.getInt("uiopacity") / 100f))); t.setBackground(patch.tint(Tmp.c1.set(patch.getPatch().getColor()).a(settings.getInt("uiopacity") / 100f)));
}); });
})).padRight(modUiScale * 39 * 8f); })).padRight(Scl.scl(modUiScale) * 39 * 8f);
table.fillParent = true; table.fillParent = true;
table.visibility = () -> uiIndex == 1; table.visibility = () -> uiIndex == 1;
@@ -1093,14 +1093,14 @@ public class HudUi {
}); });
itemTable = new Table(table -> { itemTable = new Table(table -> {
table.left().defaults().width(modUiScale * 54 * 8f).height(modUiScale * 32 * 8f).align(Align.left); table.left().defaults().width(Scl.scl(modUiScale) * 54 * 8f).height(Scl.scl(modUiScale) * 32 * 8f).align(Align.left);
table.table(Tex.button, t -> { table.table(Tex.button, t -> {
t.add(itemPane); t.add(itemPane);
t.update(() -> { t.update(() -> {
NinePatchDrawable patch = (NinePatchDrawable)Tex.button; NinePatchDrawable patch = (NinePatchDrawable)Tex.button;
t.setBackground(patch.tint(Tmp.c1.set(patch.getPatch().getColor()).a(settings.getInt("uiopacity") / 100f))); t.setBackground(patch.tint(Tmp.c1.set(patch.getPatch().getColor()).a(settings.getInt("uiopacity") / 100f)));
}); });
}).padRight(modUiScale * 39 * 8f); }).padRight(Scl.scl(modUiScale) * 39 * 8f);
table.fillParent = true; table.fillParent = true;
table.visibility = () -> uiIndex == 2; table.visibility = () -> uiIndex == 2;

View File

@@ -10,10 +10,11 @@ import arc.scene.ui.layout.*;
import arc.util.*; import arc.util.*;
import mindustry.*; import mindustry.*;
import mindustry.ai.Pathfinder; import mindustry.ai.Pathfinder;
import mindustry.ai.types.BuilderAI; import mindustry.ai.types.*;
import mindustry.ai.types.MinerAI;
import mindustry.content.*; import mindustry.content.*;
import mindustry.entities.units.AIController; import mindustry.entities.units.AIController;
import mindustry.entities.units.UnitCommand;
import mindustry.entities.units.UnitController;
import mindustry.game.EventType.*; import mindustry.game.EventType.*;
import mindustry.game.*; import mindustry.game.*;
import mindustry.gen.*; import mindustry.gen.*;
@@ -33,17 +34,14 @@ public class Main extends Mod {
int otherCores; int otherCores;
boolean groundValid = false, legValid = false, navalValid = false; boolean groundValid = false, legValid = false, navalValid = false;
public Tile getNextTile(Tile tile, int finder){ public Tile getNextTile(Tile tile, int cost, Team team, int finder) {
Team team = state.rules.waveTeam; Pathfinder.Flowfield field = pathfinder.getField(team, cost, finder);
Pathfinder.Flowfield field = pathfinder.getField(team, finder, Pathfinder.fieldCore);
Tile tile1 = pathfinder.getTargetTile(tile, field); Tile tile1 = pathfinder.getTargetTile(tile, field);
pathTiles.add(tile1); pathTiles.add(tile1);
if(otherCores != Groups.build.count(b -> b instanceof CoreBlock.CoreBuild && b.team != team) if(otherCores != Groups.build.count(b -> b instanceof CoreBlock.CoreBuild && b.team != team)
|| tile1 == tile || tile1 == null || || tile1 == tile || tile1 == null || tile1.build instanceof CoreBlock.CoreBuild) //so many ififififififif.
tile1.build instanceof CoreBlock.CoreBuild ||
!Groups.build.contains(b -> b instanceof CoreBlock.CoreBuild && b.team != team)) //so many ififififififif.
return tile1; return tile1;
return getNextTile(tile1, finder); return getNextTile(tile1, cost, team, finder);
} }
@Override @Override
@@ -86,27 +84,57 @@ public class Main extends Mod {
if(input.keyTap(KeyCode.num3)) navalValid = !navalValid; if(input.keyTap(KeyCode.num3)) navalValid = !navalValid;
} }
if(settings.getBool("spathfinder") || (input.keyDown(KeyCode.shiftRight) || input.keyDown(KeyCode.shiftLeft)) && input.keyTap(KeyCode.q)) { if(settings.getBool("spathfinder")) {
spawner.getSpawns().each(t -> { Groups.unit.each(u -> {
Team enemyTeam = state.rules.waveTeam; Team enemyTeam = u.team;
for (int p = 0; p < 3; p++) {
if(p == 0 && !groundValid && !mobile) continue;
if(p == 1 && !legValid && !mobile) continue;
if(p == 2 && !navalValid && !mobile) continue;
otherCores = Groups.build.count(b -> b instanceof CoreBlock.CoreBuild && b.team != enemyTeam); otherCores = Groups.build.count(b -> b instanceof CoreBlock.CoreBuild && b.team != enemyTeam);
getNextTile(t, p); if(otherCores == 0) return; //must have target core
UnitController c = u.controller();
UnitCommand com = enemyTeam.data().command;
if(u.type.flying || //not flying
c instanceof MinerAI || //not mono
c instanceof BuilderAI || //not poly
c instanceof RepairAI || //not mega
c instanceof DefenderAI || //not oct
c instanceof FormationAI || //not commanded unit by player
c instanceof LogicAI || //not controlled unit by logic
c instanceof FlyingAI ||
com == UnitCommand.idle) return;
getNextTile(u.tileOn(), u.pathType(), enemyTeam, com == UnitCommand.attack ? Pathfinder.fieldCore : Pathfinder.fieldRally);
pathTiles.filter(Objects::nonNull); pathTiles.filter(Objects::nonNull);
for (int i = 1; i < pathTiles.size; i++) { for(int i = 1; i < pathTiles.size; i++) {
if (i + 1 >= pathTiles.size) continue; //prevent IndexOutException if(i + 1 >= pathTiles.size) continue; //prevent IndexOutException
Tile tile1 = pathTiles.get(i); Tile tile1 = pathTiles.get(i);
Tile tile2 = pathTiles.get(i + 1); Tile tile2 = pathTiles.get(i + 1);
Draw.z(Layer.overlayUI);
Lines.stroke(1, enemyTeam.color);
Lines.line(tile1.worldx(), tile1.worldy(), tile2.worldx(), tile2.worldy());
}
pathTiles.clear();
});
spawner.getSpawns().each(t -> {
Team enemyTeam = state.rules.waveTeam;
for(int p = 0; p < 3; p++) {
otherCores = Groups.build.count(b -> b instanceof CoreBlock.CoreBuild && b.team != enemyTeam);
if(otherCores == 0) return; //must have target core
getNextTile(t, p, enemyTeam, Pathfinder.fieldCore);
pathTiles.filter(Objects::nonNull);
for(int i = 1; i < pathTiles.size; i++) {
if(i + 1 >= pathTiles.size) continue; //prevent IndexOutException
Tile tile1 = pathTiles.get(i);
Tile tile2 = pathTiles.get(i + 1);
Draw.z(Layer.overlayUI);
Lines.stroke(1, enemyTeam.color); Lines.stroke(1, enemyTeam.color);
Lines.line(tile1.worldx(), tile1.worldy(), tile2.worldx(), tile2.worldy()); Lines.line(tile1.worldx(), tile1.worldy(), tile2.worldx(), tile2.worldy());
} }
pathTiles.clear(); pathTiles.clear();
} }
}); });
Draw.reset();
} }
if(settings.getBool("blockstatus")) Groups.build.each(build -> { if(settings.getBool("blockstatus")) Groups.build.each(build -> {
@@ -126,6 +154,7 @@ public class Main extends Mod {
Draw.color(); Draw.color();
} }
}); });
if(Core.settings.getBool("unithealthui")) if(Core.settings.getBool("unithealthui"))
Groups.unit.each(unit -> new FreeBar().draw(unit)); Groups.unit.each(unit -> new FreeBar().draw(unit));

View File

@@ -113,7 +113,7 @@ public class CoresItemsDisplay {
} }
image.addListener(new Tooltip(tttt -> { 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) + ")"); 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)); label.setFontScale(Scl.scl(modUiScale));
tttt.background(Tex.button).add(label); tttt.background(Tex.button).add(label);
})); }));
s.add(image).size(iconLarge * modUiScale); s.add(image).size(iconLarge * modUiScale);
@@ -126,9 +126,9 @@ public class CoresItemsDisplay {
); );
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 + ")");
label.setFontScale(modUiScale * 0.75f); label.setFontScale(Scl.scl(modUiScale) * 0.75f);
tt.add(label); tt.add(label);
}).padTop(modUiScale * 2).padLeft(modUiScale * 4).padRight(modUiScale * 4); }).padTop(Scl.scl(modUiScale) * 2).padLeft(Scl.scl(modUiScale) * 4).padRight(Scl.scl(modUiScale) * 4);
if(++i[0] % 5 == 0) coretable.row(); if(++i[0] % 5 == 0) coretable.row();
} }
}); });