Merge branch 'master' into patch-1

This commit is contained in:
Sharlotte
2021-07-22 19:23:53 +09:00
committed by GitHub
7 changed files with 338 additions and 154 deletions

View File

@@ -39,8 +39,10 @@ setting.uiopacity.description = Use the slider to set opacity of ui background.
setting.scan.name = Enable Block Scanner
setting.scan.description = Enable scanner that shows nearly turret and wall hp.
setting.range.name = Display Turret Range
setting.range.description = Enable scanner can show turret range too.
setting.rangeNearby.name = Display near range
setting.rangeNearby.description = display range circle when you approached enemy ranges.
setting.rangeRadius.name = Near range margin
setting.rangeRadius.description = set additional distances to show range.
setting.rangemax.name = Block Scanner Range
setting.rangemax.description = Set scan radius of scanner.\nSelect the pencil and enter a number.
@@ -54,6 +56,7 @@ setting.shar1.name = Change Bar Style [lightgray](made by shar)[]
setting.shar2.name = Change Bar Style [lightgray](made by shar)[]
setting.shar3.name = Change Bar Style [lightgray](made by shar)[]
setting.gaycursor.name = Enable Mouse Trail Effect [lightgray](only for desktop)[]
setting.allTeam.name = Display all teams' item
#Dialog
editmaxwave = Edit Waves(int)
@@ -67,4 +70,5 @@ hud.unit = Unit Info
hud.wave = Wave Info
hud.core = Core Info
hud.tile = Tile Info
hud.item = Item Info
hud.cancel = Hidden

View File

@@ -33,8 +33,10 @@ setting.wavemax.description = 연필 아이콘을 눌러서 인게임 단계 탭
setting.scan.name = 블록 스캐너 활성화
setting.scan.description = 주변 포탑과 벽의 체력을 표시하는 스캐터를 활성화합니다.
setting.range.name = 포탑 사거리 표시
setting.range.description = 스캐터가 포탑 사거리 표시하게 만듭니다.
setting.rangeNearby.name = 주변 사거리 표시
setting.rangeNearby.description = 적 사거리에 접근했을 경우 사거리 표시니다.
setting.rangeRadius.name = 사거리 접근 거리
setting.rangeRadius.description = 사거리를 표시할 추가 거리를 설정합니다.
setting.rangemax.name = 블록 스캐너 사거리
setting.rangemax.description = 연필 아이콘을 눌러서 스캐너 사거리를 설정합니다.
@@ -56,6 +58,7 @@ setting.shar1.name = 바 스타일 변경 [lightgray](shar 만듬)[]
setting.shar2.name = 바 스타일 변경 [lightgray](shar 만듬)[]
setting.shar3.name = 바 스타일 변경 [lightgray](shar 만듬)[]
setting.gaycursor.name = 마우스 꼬리효과 [lightgray](PC 전용)[]
setting.allTeam.name = 모든 팀 자원 표시
#Dialog
editmaxwave = 최대 단계 수정하기(정수)
@@ -69,4 +72,5 @@ hud.unit = 유닛 정보
hud.wave = 단계 정보
hud.core = 코어 정보
hud.tile = 타일 정보
hud.item = 자원 정보
hud.cancel = 닫음

View File

@@ -40,9 +40,11 @@ public class HudUi {
Table waveTable = new Table();
Table coreTable = new Table();
Table tileTable = new Table();
Table itemTable = new Table();
float waveScrollPos;
float coreScrollPos;
float tileScrollPos;
float itemScrollPos;
Element image;
Color lastItemColor = Pal.items;
@@ -54,13 +56,16 @@ public class HudUi {
//to update tables
int waveamount;
int coreamount;
int weaponamount;
Teamc target;
BarInfo info = new BarInfo();
Seq<String> strings = new Seq<>(new String[]{"","","","","",""});
Seq<Float> numbers = new Seq<>(new Float[]{0f,0f,0f,0f,0f,0f});
Seq<Color> colors = new Seq<>(new Color[]{Color.clear,Color.clear,Color.clear,Color.clear,Color.clear,Color.clear});
CoresItemsDisplay coreItems = new CoresItemsDisplay(Team.baseTeams);
@SuppressWarnings("unchecked")
public <T extends Teamc> T getTarget(){
Seq<Unit> units = Groups.unit.intersect(Core.input.mouseWorldX(), Core.input.mouseWorldY(), 4, 4);
@@ -89,6 +94,11 @@ public class HudUi {
Draw.reset();
}
});
Events.on(EventType.ResetEvent.class, e -> {
if(settings.getBool("allTeam")) coreItems.teams = Team.all;
coreItems.resetUsed();
coreItems.tables.each(Group::clear);
});
}
public void addTable(){
@@ -111,7 +121,7 @@ public class HudUi {
Table labelTable = new Table(t -> t.add(label).scaling(Scaling.fit).left().padRight(40 * 8f));
table.table(t -> {
Seq<Button> buttons = Seq.with(null, null, null, null, null);
Seq<Button> buttons = Seq.with(null, null, null, null, null, null);
buttons.items[0] = t.button(Icon.units, Styles.clearToggleTransi, () -> {
uiIndex = 0;
buttons.items[0].setChecked(true);
@@ -119,6 +129,7 @@ public class HudUi {
buttons.items[2].setChecked(false);
buttons.items[3].setChecked(false);
buttons.items[4].setChecked(false);
buttons.items[5].setChecked(false);
label.setText(Core.bundle.get("hud.unit"));
addBars();
addWeapon();
@@ -126,9 +137,10 @@ public class HudUi {
addWaveTable();
addCoreTable();
addTileTable();
addItemTable();
table.removeChild(baseTable);
labelTable.setPosition(buttons.items[uiIndex].x, buttons.items[uiIndex].y);
baseTable = table.table(tt -> tt.stack(unitTable, coreTable, waveTable, tileTable, labelTable).align(Align.left).left().visible(() -> settings.getBool("infoui"))).get();
baseTable = table.table(tt -> tt.stack(unitTable, coreTable, waveTable, tileTable, itemTable, labelTable).align(Align.left).left().visible(() -> settings.getBool("infoui"))).get();
a = 1f;
}).size(5*8f).get();
t.row();
@@ -139,6 +151,7 @@ public class HudUi {
buttons.items[2].setChecked(false);
buttons.items[3].setChecked(false);
buttons.items[4].setChecked(false);
buttons.items[5].setChecked(false);
label.setText(Core.bundle.get("hud.wave"));
addBars();
addWeapon();
@@ -146,9 +159,10 @@ public class HudUi {
addWaveTable();
addCoreTable();
addTileTable();
addItemTable();
table.removeChild(baseTable);
labelTable.setPosition(buttons.items[uiIndex].x, buttons.items[uiIndex].y);
baseTable = table.table(tt -> tt.stack(unitTable, coreTable, waveTable, tileTable, labelTable).align(Align.left).left().visible(() -> settings.getBool("infoui"))).get();
baseTable = table.table(tt -> tt.stack(unitTable, coreTable, waveTable, tileTable, itemTable, labelTable).align(Align.left).left().visible(() -> settings.getBool("infoui"))).get();
a = 1f;
}).size(5*8f).get();
t.row();
@@ -159,6 +173,7 @@ public class HudUi {
buttons.items[2].setChecked(true);
buttons.items[3].setChecked(false);
buttons.items[4].setChecked(false);
buttons.items[5].setChecked(false);
label.setText(Core.bundle.get("hud.core"));
addBars();
addWeapon();
@@ -166,9 +181,10 @@ public class HudUi {
addWaveTable();
addCoreTable();
addTileTable();
addItemTable();
table.removeChild(baseTable);
labelTable.setPosition(buttons.items[uiIndex].x, buttons.items[uiIndex].y);
baseTable = table.table(tt -> tt.stack(unitTable, coreTable, waveTable, tileTable, labelTable).align(Align.left).left().visible(() -> settings.getBool("infoui"))).get();
baseTable = table.table(tt -> tt.stack(unitTable, coreTable, waveTable, tileTable, itemTable, labelTable).align(Align.left).left().visible(() -> settings.getBool("infoui"))).get();
a = 1f;
}).size(5*8f).get();
t.row();
@@ -179,6 +195,7 @@ public class HudUi {
buttons.items[2].setChecked(false);
buttons.items[3].setChecked(true);
buttons.items[4].setChecked(false);
buttons.items[5].setChecked(false);
label.setText(Core.bundle.get("hud.tile"));
addBars();
addWeapon();
@@ -186,19 +203,44 @@ public class HudUi {
addWaveTable();
addCoreTable();
addTileTable();
addItemTable();
table.removeChild(baseTable);
labelTable.setPosition(buttons.items[uiIndex].x, buttons.items[uiIndex].y);
baseTable = table.table(tt -> tt.stack(unitTable, coreTable, waveTable, tileTable, labelTable).align(Align.left).left().visible(() -> settings.getBool("infoui"))).get();
baseTable = table.table(tt -> tt.stack(unitTable, coreTable, waveTable, tileTable, itemTable, labelTable).align(Align.left).left().visible(() -> settings.getBool("infoui"))).get();
a = 1f;
}).size(5*8f).get();
t.row();
buttons.items[4] = t.button(Icon.cancel, Styles.clearToggleTransi, () -> {
buttons.items[4] = t.button(Icon.copy, Styles.clearToggleTransi, () -> {
uiIndex = 4;
buttons.items[0].setChecked(false);
buttons.items[1].setChecked(false);
buttons.items[2].setChecked(false);
buttons.items[3].setChecked(false);
buttons.items[4].setChecked(true);
buttons.items[5].setChecked(false);
label.setText(Core.bundle.get("hud.item"));
addBars();
addWeapon();
addUnitTable();
addWaveTable();
addCoreTable();
addTileTable();
addItemTable();
table.removeChild(baseTable);
labelTable.setPosition(buttons.items[uiIndex].x, buttons.items[uiIndex].y);
baseTable = table.table(tt -> tt.stack(unitTable, coreTable, waveTable, tileTable, itemTable, labelTable).align(Align.left).left().visible(() -> settings.getBool("infoui"))).get();
a = 1f;
}).size(5*8f).get();
t.row();
buttons.items[5] = t.button(Icon.cancel, Styles.clearToggleTransi, () -> {
uiIndex = 5;
buttons.items[0].setChecked(false);
buttons.items[1].setChecked(false);
buttons.items[2].setChecked(false);
buttons.items[3].setChecked(false);
buttons.items[4].setChecked(false);
buttons.items[5].setChecked(true);
label.setText(Core.bundle.get("hud.cancel"));
addBars();
addWeapon();
@@ -208,7 +250,7 @@ public class HudUi {
addTileTable();
table.removeChild(baseTable);
labelTable.setPosition(buttons.items[uiIndex].x, buttons.items[uiIndex].y);
baseTable = table.table(tt -> tt.stack(unitTable, coreTable, waveTable, tileTable, labelTable).align(Align.left).left().visible(() -> settings.getBool("infoui"))).get();
baseTable = table.table(tt -> tt.stack(unitTable, coreTable, waveTable, tileTable, itemTable, labelTable).align(Align.left).left().visible(() -> settings.getBool("infoui"))).get();
a = 1f;
}).size(5*8f).get();
});
@@ -379,11 +421,11 @@ public class HudUi {
public void addWeapon(){
weapon = new Table(tx -> {
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 -> {
tt.left().top().defaults().width(Scl.scl(24/3f * 8f)).minHeight(Scl.scl(12/3f * 8f));
for(int r = 0; r < ((Unit) getTarget()).type.weapons.size; r++){
if(getTarget() instanceof Unit && ((Unit) getTarget()).type != null) for(int r = 0; r < ((Unit) getTarget()).type.weapons.size; r++){
Weapon weapon = ((Unit) getTarget()).type.weapons.get(r);
WeaponMount mount = ((Unit) getTarget()).mounts[r];
TextureRegion region = !weapon.name.equals("") && weapon.outlineRegion.found() ? weapon.outlineRegion : ((Unit) getTarget()).type.uiIcon;
@@ -409,8 +451,10 @@ public class HudUi {
if(getDrawable() instanceof TransformDrawable){
float rotation = getRotation();
if(scaleX != 1 || scaleY != 1 || rotation != 0){
getDrawable().draw(x + imageX, y + imageY, originX - imageX, originY - imageY,
imageWidth, imageHeight, scaleX, scaleY, rotation);
getDrawable().draw(x + imageX, y + imageY,
originX - imageX, originY - imageY,
imageWidth, imageHeight,
scaleX, scaleY, rotation);
return;
}
}
@@ -465,7 +509,7 @@ public class HudUi {
Stack stack = new Stack(){{
add(new Table(ttt -> ttt.add(new Image(){{
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;
else if(getTarget() instanceof Building && ((Building) getTarget()).block() != null) {
if(getTarget() instanceof ConstructBlock.ConstructBuild) region = ((ConstructBlock.ConstructBuild) getTarget()).current.uiIcon;
@@ -479,29 +523,19 @@ public class HudUi {
add(new Table(temp -> {
Image image = new Image(Icon.defenseSmall);
temp.add(image).center();
}){
@Override
public void draw() {
if(getTarget() instanceof Building) return;
super.draw();
}
});
}));
add(new Table(temp -> {
Label label = new Label(() -> (getTarget() instanceof Unit && ((Unit) getTarget()).type() != null ? (int)((Unit) getTarget()).type().armor+"" : ""));
label.setColor(Pal.surge);
label.setFontScale(0.5f);
temp.add(label).center();
temp.pack();
}){
@Override
public void draw() {
if(getTarget() instanceof Building) return;
super.draw();
}
});
}));
}}).padLeft(Scl.scl(2 * 8f)).padBottom(Scl.scl(2 * 8f));
}));
}};
stack.visibility = () -> !(getTarget() == null || getTarget() instanceof Building);
Label label = new Label(() -> {
String name = "";if (getTarget() instanceof Unit && ((Unit) getTarget()).type() != null)
@@ -521,6 +555,7 @@ public class HudUi {
ui.content.show(((Buildingc) getTarget()).block());
}
});
button.visibility = () -> getTarget() != null;
tt.top();
tt.add(stack);
@@ -559,7 +594,7 @@ public class HudUi {
if (settings.getBool("weaponui")
&& getTarget() instanceof Unit
&& ((Unit) getTarget()).type != null
&& weaponamount != ((Unit) getTarget()).type.weapons.size) {
&& target != getTarget()) {
table.removeChild(weapon);
addWeapon();
table.row();
@@ -747,49 +782,62 @@ public class HudUi {
}
public void setCore(Table table){
table.add(new Table(t -> {
if(Vars.player.unit() == null) return;
coreamount = Vars.player.unit().team().cores().size;
for(int r = 0; r < coreamount; r++){
CoreBlock.CoreBuild core = Vars.player.unit().team().cores().get(r);
table.table(t -> {
if (Vars.player.unit() == null) return;
if(coreamount > 1 && r % 3 == 0) t.row();
else if(r % 3 == 0) t.row();
t.table(tt -> {
tt.add(new Stack(){{
add(new Table(s -> {
s.left();
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(t -> t.background(Tex.button).add(new Label(() -> {
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);
}));
add(new Table(s -> {
s.bottom().defaults().growX().height(Scl.scl(9)).pad(4);
s.add(new Bar(() -> "", () -> Pal.health, core::healthf));
s.pack();
}));
}});
tt.row();
Label label = new Label(() -> "(" + (int)core.x / 8 + ", " + (int)core.y / 8 + ")");
label.setFontScale(Scl.scl());
tt.add(label);
for(int i = 0; i < coreItems.tables.size; i++){
int finalI = i;
t.table(Tex.underline2, head -> {
head.table(label -> {
label.center();
label.label(() -> "[#" + coreItems.teams[finalI].color.toString() + "]" + coreItems.teams[finalI].name + "[]");
});
});
t.row();
coreamount = coreItems.teams[i].cores().size;
for (int r = 0; r < coreamount; r++) {
CoreBlock.CoreBuild core = coreItems.teams[i].cores().get(r);
if (coreamount > 1 && r % 3 == 0) t.row();
else if (r % 3 == 0) t.row();
t.table(tt -> {
tt.add(new Stack() {{
add(new Table(s -> {
s.left();
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(t -> t.background(Tex.button).add(new Label(() -> {
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);
}));
add(new Table(s -> {
s.bottom().defaults().growX().height(Scl.scl(9)).pad(4);
s.add(new Bar(() -> "", () -> Pal.health, core::healthf));
s.pack();
}));
}});
tt.row();
Label label = new Label(() -> "(" + (int) core.x / 8 + ", " + (int) core.y / 8 + ")");
label.setFontScale(Scl.scl());
tt.add(label);
});
}
t.row();
}
}));
});
}
public void addCoreTable(){
@@ -805,8 +853,8 @@ public class HudUi {
}
}
coreScrollPos = corePane.getScrollY();
if(coreamount != Vars.player.unit().team().cores().size && Vars.player != null) corePane.setWidget(new Table(tx -> tx.table(this::setCore).left()));
});
corePane.setWidget(new Table(tx -> tx.table(this::setCore).left()));
corePane.setOverscroll(false, false);
if(Vars.player != null) corePane.setWidget(new Table(tx -> tx.table(this::setCore).left()));
coreTable = new Table(table -> {
@@ -882,4 +930,60 @@ public class HudUi {
table.visibility = () -> uiIndex == 3;
});
}
public void setItem(Table table){
table.table(t -> {
for(int i = 0; i < coreItems.tables.size; i++){
int finalI = i;
t.table(Tex.underline2, head -> {
head.table(label -> {
label.center();
label.label(() -> "[#" + coreItems.teams[finalI].color.toString() + "]" + coreItems.teams[finalI].name + "[]");
});
});
t.row();
t.table(tt -> {
tt.left();
tt.add(coreItems.tables.get(finalI));
});
t.row();
}
});
}
public void addItemTable(){
if(uiIndex != 4) return;
ScrollPane tilePane = new ScrollPane(new Image(Core.atlas.find("clear")).setScaling(Scaling.fit), Styles.smallPane);
tilePane.setScrollingDisabled(true, false);
tilePane.setScrollYForce(tileScrollPos);
tilePane.update(() -> {
if(tilePane.hasScroll()){
Element result = Core.scene.hit(Core.input.mouseX(), Core.input.mouseY(), true);
if(result == null || !result.isDescendantOf(tilePane)){
Core.scene.setScrollFocus(null);
}
}
itemScrollPos = tilePane.getScrollY();
});
tilePane.setWidget(new Table(this::setItem).left());
tilePane.setOverscroll(false, false);
itemTable = new Table(table -> {
table.add(new Table(scene.getStyle(Button.ButtonStyle.class).up, t -> {
t.defaults().minWidth(Scl.scl(25 * 8f)).scaling(Scaling.fit).left();
t.add(tilePane).maxHeight(Scl.scl(32 * 8f));
}){
@Override
protected void drawBackground(float x, float y) {
if(getBackground() == null) return;
Draw.color(color.r, color.g, color.b, (settings.getInt("uiopacity") / 100f) * this.parentAlpha);
getBackground().draw(x, y, width, height);
Draw.reset();
}
}).padRight(Scl.scl(39 * 8f));
table.fillParent = true;
table.visibility = () -> uiIndex == 4;
});
}
}

View File

@@ -9,20 +9,29 @@ import arc.graphics.g2d.Fill;
import arc.graphics.g2d.Lines;
import arc.math.Angles;
import arc.math.Mathf;
import arc.math.geom.Position;
import arc.scene.ui.layout.Scl;
import arc.util.Align;
import arc.util.Log;
import arc.util.Time;
import arc.util.Tmp;
import mindustry.Vars;
import mindustry.content.Fx;
import mindustry.game.EventType.*;
import mindustry.game.Team;
import mindustry.gen.Building;
import mindustry.gen.Groups;
import mindustry.gen.Teamc;
import mindustry.gen.Unit;
import mindustry.graphics.Drawf;
import mindustry.graphics.Layer;
import mindustry.graphics.Pal;
import mindustry.logic.Ranged;
import mindustry.mod.Mod;
import mindustry.ui.Fonts;
import mindustry.world.Block;
import mindustry.world.blocks.defense.turrets.BaseTurret;
import mindustry.world.blocks.defense.turrets.Turret;
import static arc.Core.*;
import static mindustry.Vars.*;
@@ -90,45 +99,29 @@ public class Main extends Mod {
Lines.swirl(Core.input.mouseWorldX(), Core.input.mouseWorldY(), range, 0.15f, 90 + Time.time % 360);
Lines.swirl(Core.input.mouseWorldX(), Core.input.mouseWorldY(), range, 0.15f, 180 + Time.time % 360);
Lines.swirl(Core.input.mouseWorldX(), Core.input.mouseWorldY(), range, 0.15f, 270 + Time.time % 360);
Draw.reset();
}
if(!mobile && !Vars.state.isPaused() && settings.getBool("gaycursor"))
Fx.mine.at(Core.input.mouseWorldX(), Core.input.mouseWorldY(), Tmp.c2.set(Color.red).shiftHue(Time.time * 1.5f));
Groups.unit.each(unit -> {
Draw.color();
Tmp.c1.set(Color.white).lerp(Pal.heal, Mathf.clamp(unit.healTime - unit.hitTime));
Draw.mixcol(Tmp.c1, Math.max(unit.hitTime, Mathf.clamp(unit.healTime)));
if(unit.drownTime > 0 && unit.floorOn().isDeep())
Draw.mixcol(unit.floorOn().mapColor, unit.drownTime * 0.8f);
if(!renderer.pixelator.enabled()) Groups.unit.each(unit -> unit.item() != null && unit.itemTime > 0.01f, unit -> {
Fonts.outline.draw(unit.stack.amount + "",
unit.x + Angles.trnsx(unit.rotation + 180f, unit.type.itemOffsetY),
unit.y + Angles.trnsy(unit.rotation + 180f, unit.type.itemOffsetY) - 3,
Pal.accent, 0.25f * unit.itemTime / Scl.scl(1f), false, Align.center);
Draw.reset();
});
//draw back items
if(unit.item() != null && unit.itemTime > 0.01f){
float size = (itemSize + Mathf.absin(Time.time, 5f, 1f)) * unit.itemTime;
Draw.mixcol(Pal.accent, Mathf.absin(Time.time, 5f, 0.1f));
Draw.rect(unit.item().fullIcon,
unit.x + Angles.trnsx(unit.rotation + 180f, unit.type.itemOffsetY),
unit.y + Angles.trnsy(unit.rotation + 180f, unit.type.itemOffsetY),
size, size, unit.rotation);
Draw.mixcol();
Lines.stroke(1f, Pal.accent);
Lines.circle(
unit.x + Angles.trnsx(unit.rotation + 180f, unit.type.itemOffsetY),
unit.y + Angles.trnsy(unit.rotation + 180f, unit.type.itemOffsetY),
(3f + Mathf.absin(Time.time, 5f, 1f)) * unit.itemTime);
if(!renderer.pixelator.enabled()){
Fonts.outline.draw(unit.stack.amount + "",
unit.x + Angles.trnsx(unit.rotation + 180f, unit.type.itemOffsetY),
unit.y + Angles.trnsy(unit.rotation + 180f, unit.type.itemOffsetY) - 3,
Pal.accent, 0.25f * unit.itemTime / Scl.scl(1f), false, Align.center);
}
Draw.reset();
}
if(settings.getBool("rangeNearby")) Groups.all.each(entityc ->
(entityc instanceof BaseTurret.BaseTurretBuild || entityc instanceof Unit)
&& player != null && player.team() != ((Ranged) entityc).team(), entityc -> {
if(entityc instanceof Turret.TurretBuild
&& !(player.unit().isFlying() && ((Turret)((Turret.TurretBuild) entityc).block).targetAir || !(player.unit().isFlying()) && ((Turret)((Turret.TurretBuild) entityc).block).targetGround)) return;
float range = ((Ranged) entityc).range();
float margin = settings.getInt("rangeRadius") * tilesize;
if(Vars.player.dst((Position) entityc) <= range + margin)
Drawf.dashCircle(((Ranged) entityc).x(), ((Ranged) entityc).y(), range, ((Ranged) entityc).team().color);
});
});
}

View File

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

View File

@@ -0,0 +1,76 @@
package UnitInfo.ui;
import arc.scene.ui.layout.Table;
import arc.struct.ObjectSet;
import arc.struct.Seq;
import mindustry.content.UnitTypes;
import mindustry.core.UI;
import mindustry.game.Team;
import mindustry.gen.Groups;
import mindustry.type.Item;
import mindustry.type.UnitType;
import mindustry.ui.Styles;
import mindustry.world.blocks.storage.CoreBlock;
import static mindustry.Vars.content;
import static mindustry.Vars.iconSmall;
public class CoresItemsDisplay {
private final ObjectSet<Item> usedItems = new ObjectSet<>();
private final ObjectSet<UnitType> usedUnits = new ObjectSet<>();
private CoreBlock.CoreBuild core;
public Team[] teams;
public Seq<Table> tables = new Seq<>();
public CoresItemsDisplay(Team[] teams) {
this.teams = teams;
rebuild();
}
public void resetUsed(){
usedItems.clear();
usedUnits.clear();
tables.each(t->t.background(null));
}
void rebuild(){
tables.clear();
for(Team team : teams) {
tables.add(new Table(t -> {
t.clear();
if(usedItems.size > 0 || usedUnits.size > 0){
t.background(Styles.black6);
t.margin(2);
}
t.update(() -> {
core = team.core();
if(content.items().contains(item -> core != null && core.items.get(item) > 0 && usedItems.add(item)) || content.units().contains(unit -> core != null && Groups.unit.count(u -> u.team == team) > 0 && usedUnits.add(unit))){
rebuild();
}
});
int i = 0;
for(Item item : content.items()){
if(usedItems.contains(item)){
t.image(item.uiIcon).size(iconSmall).padRight(3).tooltip(tt -> tt.background(Styles.black6).margin(2f).add(item.localizedName).style(Styles.outlineLabel));
t.label(() -> core == null ? "0" : UI.formatAmount(core.items.get(item))).padRight(3).minWidth(5 * 8f).left();
if(++i % 5 == 0) t.row();
}
}
t.row();
i = 0;
for(UnitType unit : content.units()){
if(unit == UnitTypes.block) continue;
if(usedUnits.contains(unit)){
t.image(unit.uiIcon).size(iconSmall).padRight(3).tooltip(tt -> tt.background(Styles.black6).margin(2f).add(unit.localizedName).style(Styles.outlineLabel));
t.label(() -> core == null ? "0" : UI.formatAmount(Groups.unit.count(u -> u.team == team && u.type == unit))).padRight(3).minWidth(5 * 8f).left();
if(++i % 5 == 0) t.row();
}
}
}));
}
}
}

View File

@@ -20,6 +20,9 @@ public class SBar extends Element{
private String name = "";
private float value, lastValue, blink;
private final Color blinkColor = new Color();
NinePatchDrawable bar;
NinePatchDrawable top;
float spriteWidth;
public SBar(Prov<String> name, Prov<Color> color, Floatp fraction){
this.fraction = fraction;
@@ -37,55 +40,15 @@ public class SBar extends Element{
this.name = "";
}
});
}
public Drawable drawable(String name, int left, int right, int top, int bottom){
Drawable out;
TextureAtlas.AtlasRegion region = Core.atlas.find(name);
int[] splits = {left, right, top, bottom};
NinePatch patch = new NinePatch(region, splits[0], splits[1], splits[2], splits[3]);
int[] pads = region.pads;
if(pads != null) patch.setPadding(pads[0], pads[1], pads[2], pads[3]);
out = new ScaledNinePatchDrawable(patch, 1f);
return out;
}
@Override
public void draw(){
if(fraction == null) return;
boolean ssim = Core.settings.getBool("ssim");
boolean shar = Core.settings.getBool("shar");
boolean shar1 = Core.settings.getBool("shar1");
boolean shar2 = Core.settings.getBool("shar2");
boolean shar3 = Core.settings.getBool("shar3");
float computed;
try{
computed = Mathf.clamp(fraction.get());
}catch(Exception e){ //getting the fraction may involve referring to invalid data
computed = 0f;
}
if(lastValue > computed){
blink = 1f;
lastValue = computed;
}
if(Float.isNaN(lastValue)) lastValue = 0;
if(Float.isInfinite(lastValue)) lastValue = 1f;
if(Float.isNaN(value)) value = 0;
if(Float.isInfinite(value)) value = 1f;
if(Float.isNaN(computed)) computed = 0;
if(Float.isInfinite(computed)) computed = 1f;
blink = Mathf.lerpDelta(blink, 0f, 0.2f);
value = Mathf.lerpDelta(value, computed, 0.05f);
NinePatchDrawable bar = (NinePatchDrawable) drawable("unitinfo-barS", 10, 10, 9, 9);
NinePatchDrawable top = (NinePatchDrawable) drawable("unitinfo-barS-top", 10, 10, 9, 9);
float spriteWidth = Core.atlas.find("unitinfo-barS").width;
bar = (NinePatchDrawable) drawable("unitinfo-barS", 10, 10, 9, 9);
top = (NinePatchDrawable) drawable("unitinfo-barS-top", 10, 10, 9, 9);
spriteWidth = Core.atlas.find("unitinfo-barS").width;
if(ssim){
bar = (NinePatchDrawable) drawable("unitinfo-barSS", 14, 14, 19, 19);
top = (NinePatchDrawable) drawable("unitinfo-barSS-top", 14, 14, 19, 19);
@@ -112,13 +75,53 @@ public class SBar extends Element{
spriteWidth = Core.atlas.find("unitinfo-barSSSSSS").width;
}
}
public Drawable drawable(String name, int left, int right, int top, int bottom){
Drawable out;
TextureAtlas.AtlasRegion region = Core.atlas.find(name);
int[] splits = {left, right, top, bottom};
NinePatch patch = new NinePatch(region, splits[0], splits[1], splits[2], splits[3]);
int[] pads = region.pads;
if(pads != null) patch.setPadding(pads[0], pads[1], pads[2], pads[3]);
out = new ScaledNinePatchDrawable(patch, 1f);
return out;
}
@Override
public void draw(){
if(fraction == null) return;
float computed;
try{
computed = Mathf.clamp(fraction.get());
}catch(Exception e){ //getting the fraction may involve referring to invalid data
computed = 0f;
}
if(lastValue > computed){
blink = 1f;
lastValue = computed;
}
if(Float.isNaN(lastValue)) lastValue = 0;
if(Float.isInfinite(lastValue)) lastValue = 1f;
if(Float.isNaN(value)) value = 0;
if(Float.isInfinite(value)) value = 1f;
if(Float.isNaN(computed)) computed = 0;
if(Float.isInfinite(computed)) computed = 1f;
blink = Mathf.lerpDelta(blink, 0f, 0.2f);
value = Mathf.lerpDelta(value, computed, 0.05f);
Draw.colorl(0.1f);
bar.draw(x, y, width, height);
Draw.color(color.cpy().mul(Pal.lightishGray), blinkColor, blink);
float topWidth = width * value;
if(topWidth > spriteWidth){
top.draw(x, y, topWidth, height);
}else{
@@ -130,7 +133,6 @@ public class SBar extends Element{
Draw.color(color, blinkColor, blink);
float topWidthReal = width * (Math.min(value, computed));
if(topWidthReal > spriteWidth){
top.draw(x, y, topWidthReal, height);
}else{
@@ -141,7 +143,6 @@ public class SBar extends Element{
}
Draw.color();
Font font = Fonts.outline;
GlyphLayout lay = Pools.obtain(GlyphLayout.class, GlyphLayout::new);
font.getData().setScale(Scl.scl());