This commit is contained in:
Sharlotte
2021-07-24 00:24:16 +09:00
parent 94d8aa6b07
commit 6ff1c67fb7
3 changed files with 97 additions and 137 deletions

View File

@@ -1,9 +1,9 @@
@rem put this project path into PATH_FROM @rem put this project path into PATH_FROM
setlocal setlocal
set PATH_FROM=C:\Users\Administrator\Documents\GitHub\UnitInfo set PATH_FROM=C:\Users\user\Documents\GitHub\UnitInfo
@rem put your mindustry local path into PATH_TO @rem put your mindustry local path into PATH_TO
setlocal setlocal
set PATH_TO=C:\Users\Administrator\AppData\Roaming\Mindustry set PATH_TO=C:\Users\user\AppData\Roaming\Mindustry
if exist %PATH_TO%\mods\UnitInfo.jar del %PATH_TO%\mods\UnitInfo.jar if exist %PATH_TO%\mods\UnitInfo.jar del %PATH_TO%\mods\UnitInfo.jar
xcopy %PATH_FROM%\build\libs\UnitInfo.jar %PATH_TO%\mods\ /k xcopy %PATH_FROM%\build\libs\UnitInfo.jar %PATH_TO%\mods\ /k

View File

@@ -16,7 +16,6 @@ import arc.struct.*;
import arc.util.*; import arc.util.*;
import mindustry.*; import mindustry.*;
import mindustry.content.*; import mindustry.content.*;
import mindustry.core.Renderer;
import mindustry.entities.units.*; import mindustry.entities.units.*;
import mindustry.game.*; import mindustry.game.*;
import mindustry.gen.*; import mindustry.gen.*;
@@ -71,14 +70,12 @@ public class HudUi {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public <T extends Teamc> T getTarget(){ public <T extends Teamc> T getTarget(){
if(locked && lockedTarget != null) return (T) lockedTarget; if(locked && lockedTarget != null) return (T) lockedTarget; //if there is locked target, return it first.
Seq<Unit> units = Groups.unit.intersect(Core.input.mouseWorldX(), Core.input.mouseWorldY(), 4, 4); Seq<Unit> units = Groups.unit.intersect(Core.input.mouseWorldX(), Core.input.mouseWorldY(), 4, 4);
if(units.size > 0) return (T) units.peek(); if(units.size > 0) return (T) units.peek(); //if there is unit, return it.
if(getTile() != null && getTile().build != null) return (T) getTile().build; else if(getTile() != null && getTile().build != null) return (T) getTile().build; //if there isn't unit but there is build, return it.
else { else if(player.unit() instanceof BlockUnitUnit && ((BlockUnitUnit)player.unit()).tile() != null) return (T)((BlockUnitUnit)player.unit()).tile();
if(player.unit() instanceof BlockUnitUnit && ((BlockUnitUnit)player.unit()).tile() != null) return (T)((BlockUnitUnit)player.unit()).tile(); return (T) player.unit(); //if there are not unit and not build, return player.
return (T) player.unit();
}
} }
public @Nullable Tile getTile(){ public @Nullable Tile getTile(){
@@ -105,7 +102,6 @@ public class HudUi {
}); });
Events.run(EventType.Trigger.update, ()->{ Events.run(EventType.Trigger.update, ()->{
if((Core.input.keyDown(KeyCode.shiftRight) || Core.input.keyDown(KeyCode.shiftLeft)) && Core.input.keyTap(KeyCode.r)){ if((Core.input.keyDown(KeyCode.shiftRight) || Core.input.keyDown(KeyCode.shiftLeft)) && Core.input.keyTap(KeyCode.r)){
Log.info("locked");
lockButton.change(); lockButton.change();
} }
}); });
@@ -193,10 +189,7 @@ public class HudUi {
add(new Table(){{ add(new Table(){{
left(); left();
update(() -> { update(() -> {
if(!(getTarget() instanceof Turret.TurretBuild) || ( if(!(getTarget() instanceof ItemTurret.ItemTurretBuild) && !(getTarget() instanceof LiquidTurret.LiquidTurretBuild) && !(getTarget() instanceof PowerTurret.PowerTurretBuild)){
!(getTarget() instanceof ItemTurret.ItemTurretBuild)
&& !(getTarget() instanceof LiquidTurret.LiquidTurretBuild)
&& !(getTarget() instanceof PowerTurret.PowerTurretBuild))){
clearChildren(); clearChildren();
image = null; image = null;
return; return;
@@ -244,37 +237,24 @@ public class HudUi {
}}; }};
} }
if(image != null){ if(image != null && (imaget.getClass() != image.getClass() || imaget.getClass() == Image.class))
if(imaget.getClass() != image.getClass() || imaget.getClass() == Image.class){
clearChildren(); clearChildren();
add(imaget).size(iconSmall).padBottom(2 * 8f).padRight(3 * 8f); add(imaget).size(iconSmall).padBottom(2 * 8f).padRight(3 * 8f);
image = imaget; image = imaget;
} }
}
else {
add(imaget).size(iconSmall).padBottom(2 * 8f).padRight(3 * 8f);
image = imaget;
}
}
}); });
pack(); pack();
}}); }});
add(new Table(t -> { add(new Table(t -> {
t.left(); t.left();
t.add(new Image(){ t.add(new Image(){{
{
update(() -> { update(() -> {
if(getTarget() instanceof Unit && ((Unit) getTarget()).stack().item != null && ((Unit) getTarget()).stack.amount > 0) if(getTarget() instanceof Unit && ((Unit) getTarget()).stack().item != null && ((Unit) getTarget()).stack.amount > 0)
setDrawable(((Unit) getTarget()).stack().item.uiIcon); setDrawable(((Unit) getTarget()).stack().item.uiIcon);
else setDrawable(Core.atlas.find("clear")); else setDrawable(Core.atlas.find("clear"));
}); });
} visibility = () -> getTarget() instanceof Unit;
@Override }}.setScaling(Scaling.fit)).size(Scl.scl(30f)).padBottom(Scl.scl(4 * 8f)).padRight(Scl.scl(6 * 8f));
public void draw() {
if(getTarget() instanceof Building) return;
super.draw();
}
}.setScaling(Scaling.fit)).size(Scl.scl(30f)).padBottom(Scl.scl(4 * 8f)).padRight(Scl.scl(6 * 8f));
t.pack(); t.pack();
})); }));
}}); }});
@@ -305,18 +285,17 @@ public class HudUi {
t.left(); t.left();
t.add(new Image(){{ t.add(new Image(){{
update(() -> { update(() -> {
if(!Vars.state.rules.unitAmmo){ TextureRegion region = Core.atlas.find("clear");
setDrawable(Core.atlas.find("clear"));
return; if(Vars.state.rules.unitAmmo && getTarget() instanceof Unit && ((Unit) getTarget()).type() != null){
} UnitType type = ((Unit) getTarget()).type();
TextureRegion region = Items.copper.uiIcon; if(type.ammoType == AmmoTypes.copper) region = Items.copper.uiIcon;
if(getTarget() instanceof Unit && ((Unit) getTarget()).type() != null){ else if(type.ammoType == AmmoTypes.thorium) region = Items.thorium.uiIcon;
if(((Unit) getTarget()).type().ammoType == AmmoTypes.thorium) region = Items.thorium.uiIcon; else if(type.ammoType == AmmoTypes.power || type.ammoType == AmmoTypes.powerLow || type.ammoType == AmmoTypes.powerHigh) region = Icon.powerSmall.getRegion();
if(((Unit) getTarget()).type().ammoType == AmmoTypes.power || ((Unit) getTarget()).type().ammoType == AmmoTypes.powerLow || ((Unit) getTarget()).type().ammoType == AmmoTypes.powerHigh) region = Icon.powerSmall.getRegion();
} }
setDrawable(region); setDrawable(region);
}); });
}}.setScaling(Scaling.fit)).size(Scl.scl(30f)).scaling(Scaling.fit).padBottom(Scl.scl(4 * 8f)).padRight(Scl.scl(6 * 8f)); }}.setScaling(Scaling.fit)).size(Scl.scl(30f)).padBottom(Scl.scl(4 * 8f)).padRight(Scl.scl(6 * 8f));
t.pack(); t.pack();
})); }));
}}); }});
@@ -329,11 +308,13 @@ public class HudUi {
tx.add(new Table(scene.getStyle(Button.ButtonStyle.class).up, tt -> { tx.add(new Table(scene.getStyle(Button.ButtonStyle.class).up, tt -> {
tt.left().top().defaults().width(Scl.scl(24/3f * 8f)).minHeight(Scl.scl(12/3f * 8f)); tt.left().top().defaults().width(Scl.scl(24/3f * 8f)).minHeight(Scl.scl(12/3f * 8f));
if(getTarget() instanceof Unit && ((Unit) getTarget()).type != null) for(int r = 0; r < ((Unit) getTarget()).type.weapons.size; r++){ if(getTarget() instanceof Unit && ((Unit) getTarget()).type != null) {
Weapon weapon = ((Unit) getTarget()).type.weapons.get(r); UnitType type = ((Unit) getTarget()).type;
for(int r = 0; r < type.weapons.size; r++){
Weapon weapon = type.weapons.get(r);
WeaponMount mount = ((Unit) getTarget()).mounts[r]; WeaponMount mount = ((Unit) getTarget()).mounts[r];
TextureRegion region = !weapon.name.equals("") && weapon.outlineRegion.found() ? weapon.outlineRegion : ((Unit) getTarget()).type.uiIcon; TextureRegion region = !weapon.name.equals("") && weapon.outlineRegion.found() ? weapon.outlineRegion : type.uiIcon;
if(((Unit) getTarget()).type.weapons.size > 1 && r % 3 == 0) tt.row(); if(type.weapons.size > 1 && r % 3 == 0) tt.row();
else if(r % 3 == 0) tt.row(); else if(r % 3 == 0) tt.row();
tt.table(weapontable -> { tt.table(weapontable -> {
weapontable.left(); weapontable.left();
@@ -344,7 +325,6 @@ public class HudUi {
@Override @Override
public void draw(){ public void draw(){
validate(); validate();
float x = this.x; float x = this.x;
float y = this.y; float y = this.y;
float scaleX = this.scaleX; float scaleX = this.scaleX;
@@ -371,23 +351,19 @@ public class HudUi {
})); }));
add(new Table(h -> { add(new Table(h -> {
h.add(new Stack(){{ h.defaults().growX().height(Scl.scl(9)).width(Scl.scl(31.5f)).padTop(Scl.scl(9*2f));
add(new Table(e -> {
e.defaults().growX().height(Scl.scl(9)).width(Scl.scl(31.5f)).padTop(Scl.scl(9*2f));
Bar reloadBar = new Bar( Bar reloadBar = 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);
e.add(reloadBar); h.add(reloadBar).padLeft(Scl.scl(8f));
e.pack();
}));
}}).padLeft(Scl.scl(8f));
h.pack(); h.pack();
})); }));
}}).left(); }}).left();
}).left(); }).left();
tt.center(); tt.center();
} }
}
}){ }){
@Override @Override
protected void drawBackground(float x, float y) { protected void drawBackground(float x, float y) {
@@ -415,7 +391,7 @@ public class HudUi {
update(() -> { update(() -> {
TextureRegion region = atlas.find("clear"); TextureRegion region = atlas.find("clear");
if(getTarget() instanceof Unit && ((Unit) getTarget()).type() != null) region = ((Unit) getTarget()).type().uiIcon; if(getTarget() instanceof Unit && ((Unit) getTarget()).type() != null) region = ((Unit) getTarget()).type().uiIcon;
else if(getTarget() instanceof Building && ((Building) getTarget()).block() != null) { if(getTarget() instanceof Building && ((Building) getTarget()).block != null) {
if(getTarget() instanceof ConstructBlock.ConstructBuild) region = ((ConstructBlock.ConstructBuild) getTarget()).current.uiIcon; if(getTarget() instanceof ConstructBlock.ConstructBuild) region = ((ConstructBlock.ConstructBuild) getTarget()).current.uiIcon;
else region = ((Building) getTarget()).block.uiIcon; else region = ((Building) getTarget()).block.uiIcon;
} }
@@ -449,7 +425,7 @@ public class HudUi {
String name = ""; String name = "";
if(getTarget() instanceof Unit && ((Unit) getTarget()).type() != null) if(getTarget() instanceof Unit && ((Unit) getTarget()).type() != null)
name = "[accent]" + ((Unit) getTarget()).type().localizedName + "[]"; name = "[accent]" + ((Unit) getTarget()).type().localizedName + "[]";
else if(getTarget() instanceof Building && ((Building) getTarget()).block() != null) { if(getTarget() instanceof Building && ((Building) getTarget()).block() != null) {
if(getTarget() instanceof ConstructBlock.ConstructBuild) name = "[accent]" + ((ConstructBlock.ConstructBuild) getTarget()).current.localizedName + "[]"; if(getTarget() instanceof ConstructBlock.ConstructBuild) name = "[accent]" + ((ConstructBlock.ConstructBuild) getTarget()).current.localizedName + "[]";
else name = "[accent]" + ((Building) getTarget()).block.localizedName + "[]"; else name = "[accent]" + ((Building) getTarget()).block.localizedName + "[]";
} }
@@ -459,9 +435,9 @@ public class HudUi {
label.setFontScale(Scl.scl()); label.setFontScale(Scl.scl());
TextButton button = Elem.newButton("?", Styles.clearPartialt, () -> { TextButton button = Elem.newButton("?", Styles.clearPartialt, () -> {
if(getTarget() instanceof Unit && ((Unit) getTarget()).type() != null) if(getTarget() instanceof Unit && ((Unit) getTarget()).type() != null)
ui.content.show(((Unit) getTarget()).type()); ui.content.show(((Unit) getTarget()).type);
else if (getTarget() instanceof Buildingc && ((Buildingc) getTarget()).block() != null) { if(getTarget() instanceof Building && ((Building) getTarget()).block != null) {
ui.content.show(((Buildingc) getTarget()).block()); ui.content.show(((Building) getTarget()).block);
} }
}); });
button.visibility = () -> getTarget() != null; button.visibility = () -> getTarget() != null;
@@ -734,10 +710,7 @@ 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 -> t.background(Tex.button).add(new Label(() -> { image.addListener(new Tooltip(t -> t.background(Tex.button).label(() -> "([#" + Tmp.c1.set(Color.green).lerp(Color.red, 1 - core.healthf()).toString() + "]" + Strings.fixed(core.health, 2) + "[]/" + Strings.fixed(core.block.health, 2) + ")")));
String color = Tmp.c1.set(Color.green).lerp(Color.red, 1 - core.healthf()).toString();
return "([#" + color + "]" + Strings.fixed(core.health, 2) + "[]/" + Strings.fixed(core.block.health, 2) + ")";
}))));
s.add(image).size(iconLarge).scaling(Scaling.fit); s.add(image).size(iconLarge).scaling(Scaling.fit);
})); }));
@@ -748,9 +721,7 @@ public class HudUi {
})); }));
}}); }});
tt.row(); tt.row();
Label label = new Label(() -> "(" + (int) core.x / 8 + ", " + (int) core.y / 8 + ")"); tt.label(() -> "(" + (int) core.x / 8 + ", " + (int) core.y / 8 + ")");
label.setFontScale(Scl.scl());
tt.add(label);
}); });
} }
t.row(); t.row();
@@ -774,7 +745,7 @@ public class HudUi {
}); });
corePane.setWidget(new Table(tx -> tx.table(this::setCore).left())); corePane.setWidget(new Table(tx -> tx.table(this::setCore).left()));
corePane.setOverscroll(false, false); corePane.setOverscroll(false, false);
if(Vars.player != null) corePane.setWidget(new Table(tx -> tx.table(this::setCore).left()));
coreTable = new Table(table -> { coreTable = new Table(table -> {
table.add(new Table(scene.getStyle(Button.ButtonStyle.class).up, t -> { table.add(new Table(scene.getStyle(Button.ButtonStyle.class).up, t -> {
t.defaults().minWidth(Scl.scl(25 * 8f)).scaling(Scaling.fit).left(); t.defaults().minWidth(Scl.scl(25 * 8f)).scaling(Scaling.fit).left();
@@ -805,10 +776,7 @@ public class HudUi {
if(tile.overlay().uiIcon != Core.atlas.find("error")) image.image(tile.overlay().uiIcon); if(tile.overlay().uiIcon != Core.atlas.find("error")) image.image(tile.overlay().uiIcon);
if(tile.block().uiIcon != Core.atlas.find("error")) image.image(tile.block().uiIcon); if(tile.block().uiIcon != Core.atlas.find("error")) image.image(tile.block().uiIcon);
}); });
head.table(label -> { head.label(() -> tile == null ? "(null, null)" : "(" + tile.x + ", " + tile.y + ")").center();
label.center();
label.label(() -> tile == null ? "(null, null)" : "(" + tile.x + ", " + tile.y + ")");
});
}); });
}); });
} }
@@ -853,17 +821,9 @@ public class HudUi {
table.table(t -> { table.table(t -> {
for(int i = 0; i < coreItems.tables.size; i++){ for(int i = 0; i < coreItems.tables.size; i++){
int finalI = i; int finalI = i;
t.table(Tex.underline2, head -> { t.background(Tex.underline2).label(() -> "[#" + coreItems.teams[finalI].color.toString() + "]" + coreItems.teams[finalI].name + "[]").center();
head.table(label -> {
label.center();
label.label(() -> "[#" + coreItems.teams[finalI].color.toString() + "]" + coreItems.teams[finalI].name + "[]");
});
});
t.row(); t.row();
t.table(tt -> { t.add(coreItems.tables.get(finalI)).left();
tt.left();
tt.add(coreItems.tables.get(finalI));
});
t.row(); t.row();
} }
}); });

View File

@@ -280,14 +280,14 @@ public class Setting {
addGraphicDialogSetting("wavesetting", scanSeq, scanTable); addGraphicDialogSetting("wavesetting", scanSeq, scanTable);
Seq<SettingsMenuDialog.SettingsTable.Setting> opacitySeq = new Seq<>(); Seq<SettingsMenuDialog.SettingsTable.Setting> opacitySeq = new Seq<>();
addGraphicSlideSetting("selectopacity", 25, 0, 100, 5, s -> s + "%", opacitySeq); addGraphicSlideSetting("selectopacity", 50, 0, 100, 5, s -> s + "%", opacitySeq);
addGraphicSlideSetting("baropacity", 100, 0, 100, 5, s -> s + "%", opacitySeq); addGraphicSlideSetting("baropacity", 50, 0, 100, 5, s -> s + "%", opacitySeq);
addGraphicSlideSetting("uiopacity", 50, 0, 100, 5, s -> s + "%", opacitySeq); addGraphicSlideSetting("uiopacity", 50, 0, 100, 5, s -> s + "%", opacitySeq);
addGraphicDialogSetting("opacitysetting", opacitySeq, opacityTable); addGraphicDialogSetting("opacitysetting", opacitySeq, opacityTable);
addGraphicCheckSetting("infoui", true); addGraphicCheckSetting("infoui", true);
addGraphicCheckSetting("weaponui", true); addGraphicCheckSetting("weaponui", true);
addGraphicCheckSetting("select", false); addGraphicCheckSetting("select", true);
addGraphicCheckSetting("unithealthui", true); addGraphicCheckSetting("unithealthui", true);
addGraphicCheckSetting("ssim", false); addGraphicCheckSetting("ssim", false);
addGraphicCheckSetting("shar", false); addGraphicCheckSetting("shar", false);