clean and up

This commit is contained in:
Sharlotte
2021-07-22 17:52:14 +09:00
parent 7856672eea
commit 4eec3508a4
3 changed files with 18 additions and 22 deletions

View File

@@ -54,7 +54,7 @@ public class HudUi {
//to update tables //to update tables
int waveamount; int waveamount;
int coreamount; int coreamount;
int weaponamount; Teamc target;
BarInfo info = new BarInfo(); BarInfo info = new BarInfo();
Seq<String> strings = new Seq<>(new String[]{"","","","","",""}); Seq<String> strings = new Seq<>(new String[]{"","","","","",""});
@@ -379,7 +379,7 @@ public class HudUi {
public void addWeapon(){ public void addWeapon(){
weapon = new Table(tx -> { weapon = new Table(tx -> {
tx.left().defaults().minSize(Scl.scl(12 * 8f)); tx.left().defaults().minSize(Scl.scl(12 * 8f));
weaponamount = ((Unit) getTarget()).type.weapons.size; target = getTarget();
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));
@@ -409,8 +409,10 @@ public class HudUi {
if(getDrawable() instanceof TransformDrawable){ if(getDrawable() instanceof TransformDrawable){
float rotation = getRotation(); float rotation = getRotation();
if(scaleX != 1 || scaleY != 1 || rotation != 0){ if(scaleX != 1 || scaleY != 1 || rotation != 0){
getDrawable().draw(x + imageX, y + imageY, originX - imageX, originY - imageY, getDrawable().draw(x + imageX, y + imageY,
imageWidth, imageHeight, scaleX, scaleY, rotation); originX - imageX, originY - imageY,
imageWidth, imageHeight,
scaleX, scaleY, rotation);
return; return;
} }
} }
@@ -465,7 +467,7 @@ public class HudUi {
Stack stack = new Stack(){{ Stack stack = new Stack(){{
add(new Table(ttt -> ttt.add(new Image(){{ add(new Table(ttt -> ttt.add(new Image(){{
update(() -> { update(() -> {
TextureRegion region = Core.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) { else 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;
@@ -479,29 +481,19 @@ public class HudUi {
add(new Table(temp -> { add(new Table(temp -> {
Image image = new Image(Icon.defenseSmall); Image image = new Image(Icon.defenseSmall);
temp.add(image).center(); temp.add(image).center();
}){ }));
@Override
public void draw() {
if(getTarget() instanceof Building) return;
super.draw();
}
});
add(new Table(temp -> { add(new Table(temp -> {
Label label = new Label(() -> (getTarget() instanceof Unit && ((Unit) getTarget()).type() != null ? (int)((Unit) getTarget()).type().armor+"" : "")); Label label = new Label(() -> (getTarget() instanceof Unit && ((Unit) getTarget()).type() != null ? (int)((Unit) getTarget()).type().armor+"" : ""));
label.setColor(Pal.surge); label.setColor(Pal.surge);
label.setFontScale(0.5f); label.setFontScale(0.5f);
temp.add(label).center(); temp.add(label).center();
temp.pack(); temp.pack();
}){ }));
@Override
public void draw() {
if(getTarget() instanceof Building) return;
super.draw();
}
});
}}).padLeft(Scl.scl(2 * 8f)).padBottom(Scl.scl(2 * 8f)); }}).padLeft(Scl.scl(2 * 8f)).padBottom(Scl.scl(2 * 8f));
})); }));
}}; }};
stack.visibility = () -> !(getTarget() == null || getTarget() instanceof Building);
Label label = new Label(() -> { Label label = new Label(() -> {
String name = "";if (getTarget() instanceof Unit && ((Unit) getTarget()).type() != null) String name = "";if (getTarget() instanceof Unit && ((Unit) getTarget()).type() != null)
@@ -521,6 +513,7 @@ public class HudUi {
ui.content.show(((Buildingc) getTarget()).block()); ui.content.show(((Buildingc) getTarget()).block());
} }
}); });
button.visibility = () -> getTarget() != null;
tt.top(); tt.top();
tt.add(stack); tt.add(stack);
@@ -559,7 +552,7 @@ public class HudUi {
if (settings.getBool("weaponui") if (settings.getBool("weaponui")
&& getTarget() instanceof Unit && getTarget() instanceof Unit
&& ((Unit) getTarget()).type != null && ((Unit) getTarget()).type != null
&& weaponamount != ((Unit) getTarget()).type.weapons.size) { && target != getTarget()) {
table.removeChild(weapon); table.removeChild(weapon);
addWeapon(); addWeapon();
table.row(); table.row();

View File

@@ -19,6 +19,7 @@ import mindustry.Vars;
import mindustry.content.Fx; import mindustry.content.Fx;
import mindustry.game.EventType.*; import mindustry.game.EventType.*;
import mindustry.game.Team; import mindustry.game.Team;
import mindustry.gen.Building;
import mindustry.gen.Groups; import mindustry.gen.Groups;
import mindustry.gen.Teamc; import mindustry.gen.Teamc;
import mindustry.graphics.Drawf; import mindustry.graphics.Drawf;
@@ -28,6 +29,7 @@ import mindustry.logic.Ranged;
import mindustry.mod.Mod; import mindustry.mod.Mod;
import mindustry.ui.Fonts; import mindustry.ui.Fonts;
import mindustry.world.Block; import mindustry.world.Block;
import mindustry.world.blocks.defense.turrets.BaseTurret;
import static arc.Core.*; import static arc.Core.*;
import static mindustry.Vars.*; import static mindustry.Vars.*;
@@ -109,7 +111,8 @@ public class Main extends Mod {
Draw.reset(); Draw.reset();
}); });
if(settings.getBool("rangeNearby")) Groups.all.each(entityc -> entityc instanceof Ranged && player != null && player.team() != ((Ranged) entityc).team(), entityc -> { if(settings.getBool("rangeNearby")) Groups.all.each(entityc -> entityc instanceof BaseTurret.BaseTurretBuild ||
(!(entityc instanceof Building) && entityc instanceof Ranged && player != null && player.team() != ((Ranged) entityc).team()), entityc -> {
float range = ((Ranged) entityc).range(); float range = ((Ranged) entityc).range();
float margin = settings.getInt("rangeRadius") * tilesize; float margin = settings.getInt("rangeRadius") * tilesize;
if(Vars.player.dst((Position) entityc) <= range + margin) if(Vars.player.dst((Position) entityc) <= range + margin)

View File

@@ -274,7 +274,7 @@ public class Setting {
Seq<SettingsMenuDialog.SettingsTable.Setting> scanSeq = new Seq<>(); Seq<SettingsMenuDialog.SettingsTable.Setting> scanSeq = new Seq<>();
addGraphicCheckSetting("scan", false, scanSeq); addGraphicCheckSetting("scan", false, scanSeq);
addGraphicCheckSetting("rangeNearby", true, scanSeq); addGraphicCheckSetting("rangeNearby", false, scanSeq);
addGraphicSlideSetting("rangeRadius", 5, 0, 20, 1, s -> s + "tiles", scanSeq); addGraphicSlideSetting("rangeRadius", 5, 0, 20, 1, s -> s + "tiles", scanSeq);
addGraphicTypeSetting("rangemax", 10, "@editrange","@invalid", 100, scanSeq); addGraphicTypeSetting("rangemax", 10, "@editrange","@invalid", 100, scanSeq);
addGraphicDialogSetting("wavesetting", scanSeq, scanTable); addGraphicDialogSetting("wavesetting", scanSeq, scanTable);