mirror of
https://github.com/yawaflua/Informatis.git
synced 2025-12-09 19:49:27 +02:00
refactoring
This commit is contained in:
@@ -110,7 +110,6 @@ public class SettingS {
|
||||
Seq<SharSetting> drawSeq = new Seq<>();
|
||||
addGraphicSlideSetting("selectopacity", 50, 0, 100, 5, s -> s + "%", drawSeq);
|
||||
addGraphicSlideSetting("baropacity", 50, 0, 100, 5, s -> s + "%", drawSeq);
|
||||
addGraphicCheckSetting("aliceRange", false, drawSeq);
|
||||
addGraphicCheckSetting("RangeShader", false, drawSeq);
|
||||
addGraphicCheckSetting("select", false, drawSeq);
|
||||
addGraphicCheckSetting("distanceLine", false, drawSeq);
|
||||
|
||||
@@ -24,6 +24,8 @@ public class RangeDraw extends OverDraw {
|
||||
|
||||
RangeDraw(String name, TextureRegionDrawable icon) {
|
||||
super(name, icon);
|
||||
registerOption("unitRange");
|
||||
registerOption("aliceRange");
|
||||
registerOption("airRange");
|
||||
registerOption("groundRange");
|
||||
}
|
||||
@@ -47,34 +49,28 @@ public class RangeDraw extends OverDraw {
|
||||
Groups.build.each(b-> settings.getBool("aliceRange") || player.team() != b.team, b -> {
|
||||
if(b instanceof BaseTurret.BaseTurretBuild turret) {
|
||||
float range = turret.range();
|
||||
if (isInCamera(b.x, b.y, range)) {
|
||||
int index = b.team.id;
|
||||
Draw.color(b.team.color);
|
||||
if (!isInCamera(b.x, b.y, range)) return;
|
||||
|
||||
boolean air = settings.getBool("airRange") && enabled;
|
||||
boolean ground = settings.getBool("groundRange") && enabled;
|
||||
boolean valid = false;
|
||||
if (unit == null) valid = true;
|
||||
else if (b instanceof Turret.TurretBuild build) {
|
||||
Turret t = (Turret) build.block;
|
||||
if(t.targetAir&&!air||t.targetGround&&!ground) return;
|
||||
if((unit.isFlying() ? t.targetAir : t.targetGround) && build.hasAmmo() && build.canConsume()) valid = true;
|
||||
} else if (b instanceof TractorBeamTurret.TractorBeamBuild build) {
|
||||
TractorBeamTurret t = (TractorBeamTurret) build.block;
|
||||
if(t.targetAir&&!air||t.targetGround&&!ground) return;
|
||||
if((unit.isFlying() ? t.targetAir : t.targetGround) && build.canConsume()) valid = true;
|
||||
}
|
||||
|
||||
if(!valid) index = 0;
|
||||
|
||||
if(b.team==player.team()) index = b.team.id;
|
||||
|
||||
Draw.color(Team.baseTeams[index].color);
|
||||
if (settings.getBool("RangeShader")) {
|
||||
Draw.z(166+(Team.baseTeams.length-index)*3);
|
||||
Fill.poly(b.x, b.y, Lines.circleVertices(range), range);
|
||||
} else Drawf.dashCircle(b.x, b.y, range, b.team.color);
|
||||
boolean air = settings.getBool("airRange") && enabled;
|
||||
boolean ground = settings.getBool("groundRange") && enabled;
|
||||
boolean valid = false;
|
||||
if (unit == null) valid = true;
|
||||
else if (b instanceof Turret.TurretBuild build) {
|
||||
Turret t = (Turret) build.block;
|
||||
if(t.targetAir&&!air||t.targetGround&&!ground) return;
|
||||
if((unit.isFlying() ? t.targetAir : t.targetGround) && build.hasAmmo() && build.canConsume()) valid = true;
|
||||
} else if (b instanceof TractorBeamTurret.TractorBeamBuild build) {
|
||||
TractorBeamTurret t = (TractorBeamTurret) build.block;
|
||||
if(t.targetAir&&!air||t.targetGround&&!ground) return;
|
||||
if((unit.isFlying() ? t.targetAir : t.targetGround) && build.canConsume()) valid = true;
|
||||
}
|
||||
|
||||
int index = valid ? b.team.id : 0;
|
||||
Draw.color(Team.baseTeams[index].color);
|
||||
if (settings.getBool("RangeShader")) {
|
||||
Draw.z(166+(Team.baseTeams.length-index)*3);
|
||||
Fill.poly(b.x, b.y, Lines.circleVertices(range), range);
|
||||
} else Drawf.dashCircle(b.x, b.y, range, b.team.color);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -16,10 +16,8 @@ public class FragmentManager {
|
||||
ui.planet, ui.research, ui.mods, ui.schematics, ui.logic
|
||||
).each(dialog-> dialog.addChild(new ElementViewFragment(dialog)));
|
||||
|
||||
//schem quick-slot
|
||||
Table table = ((Table) scene.find("minimap/position")).row();
|
||||
table.add(new QuickSchemFragment());
|
||||
new WaveInfoFragment().addWaveInfoTable();
|
||||
new QuickSchemFragment();
|
||||
new TileInfoFragment();
|
||||
new ServerSearchFragment();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,6 +36,8 @@ public class QuickSchemFragment extends Table implements Updatable {
|
||||
|
||||
public QuickSchemFragment() {
|
||||
setSchemTable();
|
||||
Table table = ((Table) scene.find("minimap/position")).row();
|
||||
table.add(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
67
src/informatis/ui/fragments/TileInfoFragment.java
Normal file
67
src/informatis/ui/fragments/TileInfoFragment.java
Normal file
@@ -0,0 +1,67 @@
|
||||
package informatis.ui.fragments;
|
||||
|
||||
import arc.scene.ui.layout.*;
|
||||
import arc.util.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.ui.*;
|
||||
import mindustry.world.Block;
|
||||
import mindustry.world.Tile;
|
||||
import mindustry.world.blocks.environment.Floor;
|
||||
|
||||
import static informatis.SUtils.*;
|
||||
import static informatis.SVars.*;
|
||||
import static arc.Core.*;
|
||||
import static mindustry.Vars.*;
|
||||
|
||||
public class TileInfoFragment {
|
||||
private boolean waveShown;
|
||||
|
||||
public TileInfoFragment() {
|
||||
Table waveInfoTable = new Table(Tex.buttonEdge4, table -> {
|
||||
table.center();
|
||||
table.table(head -> {
|
||||
head.table(image -> {
|
||||
image.left();
|
||||
image.image(() -> {
|
||||
Tile tile = getTile();
|
||||
if(tile == null) return clear;
|
||||
Floor floor = tile.floor();
|
||||
if(floor.uiIcon == error) return clear;
|
||||
return floor.uiIcon;
|
||||
}).size(iconSmall);
|
||||
image.image(() -> {
|
||||
Tile tile = getTile();
|
||||
if(tile == null) return clear;
|
||||
Floor floor = tile.overlay();
|
||||
if(floor.uiIcon == error) return clear;
|
||||
return floor.uiIcon;
|
||||
}).size(iconSmall);
|
||||
image.image(() -> {
|
||||
Tile tile = getTile();
|
||||
if(tile == null) return clear;
|
||||
Block floor = tile.block();
|
||||
if(floor.uiIcon == error) return clear;
|
||||
return floor.uiIcon;
|
||||
}).size(iconSmall);
|
||||
});
|
||||
head.label(() -> {
|
||||
Tile tile = getTile();
|
||||
if(tile == null) return "(NaN, NaN)";
|
||||
return Strings.format("(@, @)", tile.x, tile.y);
|
||||
}).center();
|
||||
});
|
||||
});
|
||||
|
||||
Table waveTable = (Table) scene.find("waves");
|
||||
Table infoTable = (Table) scene.find("infotable");
|
||||
waveTable.removeChild(infoTable);
|
||||
waveTable.row();
|
||||
waveTable.stack(
|
||||
new Table(tt -> tt.collapser(t -> t.stack(waveInfoTable, infoTable).growX(), true, () -> waveShown).growX()).top(),
|
||||
new Table(tt -> tt.button(Icon.downOpen, Styles.clearTogglei, () -> waveShown = !waveShown).size(4 * 8f).checked(b -> {
|
||||
b.getImage().setDrawable(waveShown ? Icon.upOpen : Icon.downOpen);
|
||||
return waveShown;
|
||||
})).left().top()
|
||||
).fillX();
|
||||
}
|
||||
}
|
||||
@@ -1,115 +0,0 @@
|
||||
package informatis.ui.fragments;
|
||||
|
||||
import arc.scene.ui.layout.*;
|
||||
import arc.util.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.graphics.Pal;
|
||||
import mindustry.ui.*;
|
||||
import mindustry.world.Block;
|
||||
import mindustry.world.Tile;
|
||||
import mindustry.world.blocks.environment.Floor;
|
||||
|
||||
import static informatis.SUtils.*;
|
||||
import static informatis.SVars.*;
|
||||
import static arc.Core.*;
|
||||
import static mindustry.Vars.*;
|
||||
|
||||
public class WaveInfoFragment {
|
||||
private boolean waveShown;
|
||||
|
||||
public void addWaveInfoTable() {
|
||||
Table waveInfoTable = new Table(Tex.buttonEdge4, table -> {
|
||||
table.center();
|
||||
table.table(head -> {
|
||||
head.table(image -> {
|
||||
image.left();
|
||||
image.image(() -> {
|
||||
Tile tile = getTile();
|
||||
if(tile == null) return clear;
|
||||
Floor floor = tile.floor();
|
||||
if(floor.uiIcon == error) return clear;
|
||||
return floor.uiIcon;
|
||||
}).size(iconSmall);
|
||||
image.image(() -> {
|
||||
Tile tile = getTile();
|
||||
if(tile == null) return clear;
|
||||
Floor floor = tile.overlay();
|
||||
if(floor.uiIcon == error) return clear;
|
||||
return floor.uiIcon;
|
||||
}).size(iconSmall);
|
||||
image.image(() -> {
|
||||
Tile tile = getTile();
|
||||
if(tile == null) return clear;
|
||||
Block floor = tile.block();
|
||||
if(floor.uiIcon == error) return clear;
|
||||
return floor.uiIcon;
|
||||
}).size(iconSmall);
|
||||
});
|
||||
head.label(() -> {
|
||||
Tile tile = getTile();
|
||||
if(tile == null) return "(NaN, NaN)";
|
||||
return Strings.format("(@, @)", tile.x, tile.y);
|
||||
}).center();
|
||||
});
|
||||
table.row();
|
||||
table.image().height(4f).color(Pal.gray).growX().row();
|
||||
/*
|
||||
table.table(tttt -> {
|
||||
tttt.center();
|
||||
int[] i = {0};
|
||||
|
||||
content.units().each(type -> Groups.unit.contains(u -> u.type == type && (state.rules.pvp ? (u.team != player.team()) : (u.team == state.rules.waveTeam)) && u.isBoss()), type -> {
|
||||
tttt.table(stt ->
|
||||
stt.stack(
|
||||
new Table(ttt -> ttt.image(type.uiIcon).size(iconSmall)),
|
||||
new Table(ttt -> {
|
||||
ttt.right().bottom();
|
||||
Label label = new Label(() -> Groups.unit.count(u -> u.type == type && (state.rules.pvp ? (u.team != player.team()) : (u.team == state.rules.waveTeam)) && u.isBoss()) + "");
|
||||
label.setFontScale(0.75f);
|
||||
ttt.add(label);
|
||||
ttt.pack();
|
||||
}),
|
||||
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(12f);
|
||||
ttt.pack();
|
||||
})
|
||||
).pad(6)
|
||||
);
|
||||
if(++i[0] % 6 == 0) tttt.row();
|
||||
});
|
||||
tttt.row();
|
||||
i[0] = 0;
|
||||
content.units().each(type -> Groups.unit.contains(u -> u.type == type && (state.rules.pvp ? (u.team != player.team()) : (u.team == state.rules.waveTeam)) && !u.isBoss()), type -> {
|
||||
tttt.table(ttt ->
|
||||
ttt.add(new Stack() {{
|
||||
add(new Table(ttt -> ttt.add(new Image(type.uiIcon)).size(iconSmall)));
|
||||
add(new Table(ttt -> {
|
||||
ttt.right().bottom();
|
||||
Label label = new Label(() -> Groups.unit.count(u -> u.type == type &&(state.rules.pvp ? (u.team != player.team()) : (u.team == state.rules.waveTeam)) && !u.isBoss()) + "");
|
||||
label.setFontScale(0.75f);
|
||||
ttt.add(label);
|
||||
ttt.pack();
|
||||
}));
|
||||
}}).pad(6)
|
||||
);
|
||||
if(++i[0] % 6 == 0) tttt.row();
|
||||
});
|
||||
});
|
||||
*/
|
||||
});
|
||||
|
||||
Table waveTable = (Table) scene.find("waves");
|
||||
Table infoTable = (Table) scene.find("infotable");
|
||||
waveTable.removeChild(infoTable);
|
||||
waveTable.row();
|
||||
waveTable.stack(
|
||||
new Table(tt -> tt.collapser(t -> t.stack(waveInfoTable, infoTable).growX(), true, () -> waveShown).growX()).top(),
|
||||
new Table(tt -> tt.button(Icon.downOpen, Styles.clearTogglei, () -> waveShown = !waveShown).size(4 * 8f).checked(b -> {
|
||||
b.getImage().setDrawable(waveShown ? Icon.upOpen : Icon.downOpen);
|
||||
return waveShown;
|
||||
})).left().top()).fillX();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user