mirror of
https://github.com/yawaflua/Informatis.git
synced 2025-12-10 20:19:26 +02:00
player window
This commit is contained in:
@@ -17,13 +17,15 @@ public class HUDFragment extends Fragment{
|
||||
t.add(new TaskbarTable(
|
||||
unitTable,
|
||||
waveTable,
|
||||
coreTable
|
||||
coreTable,
|
||||
playerTable
|
||||
)).visible(TaskbarTable.visibility);
|
||||
|
||||
// windows (totally not a copyright violation)
|
||||
t.add(unitTable).size(250f).visible(false);
|
||||
t.add(waveTable).size(250f).visible(false);
|
||||
t.add(coreTable).size(250f).visible(false);
|
||||
t.add(playerTable).size(250f).visible(false);
|
||||
|
||||
t.update(()->{
|
||||
for (Element child : t.getChildren()) {
|
||||
|
||||
114
src/UnitInfo/ui/windows/PlayerDisplay.java
Normal file
114
src/UnitInfo/ui/windows/PlayerDisplay.java
Normal file
@@ -0,0 +1,114 @@
|
||||
package UnitInfo.ui.windows;
|
||||
|
||||
import UnitInfo.ui.OverScrollPane;
|
||||
import UnitInfo.ui.Updatable;
|
||||
import arc.Core;
|
||||
import arc.graphics.Color;
|
||||
import arc.graphics.g2d.Draw;
|
||||
import arc.graphics.g2d.Lines;
|
||||
import arc.math.geom.Vec2;
|
||||
import arc.scene.ui.*;
|
||||
import arc.scene.ui.layout.*;
|
||||
import arc.scene.utils.Elem;
|
||||
import arc.struct.*;
|
||||
import arc.util.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.graphics.Pal;
|
||||
import mindustry.ui.*;
|
||||
|
||||
import static mindustry.Vars.*;
|
||||
|
||||
|
||||
public class PlayerDisplay extends WindowTable implements Updatable {
|
||||
Vec2 scrollPos = new Vec2(0, 0);
|
||||
TextField search;
|
||||
float heat;
|
||||
|
||||
public PlayerDisplay() {
|
||||
super("Player Display", Icon.players, t -> {});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void build() {
|
||||
scrollPos = new Vec2(0, 0);
|
||||
search = Elem.newField(null, f->{});
|
||||
search.setMessageText(Core.bundle.get("players.search"));
|
||||
|
||||
top();
|
||||
topBar();
|
||||
|
||||
table(Styles.black8, table -> {
|
||||
table.label(()-> Core.bundle.format(Groups.player.size() == 1 ? "players.single" : "players", Groups.player.size())).row();
|
||||
table.add(search).growX().pad(8).name("search").maxTextLength(maxNameLength).row();
|
||||
table.add(new OverScrollPane(rebuild(), Styles.nonePane, scrollPos).disableScroll(true, false)).grow().name("player-pane");
|
||||
}).top().right().grow().get().parent = null;
|
||||
|
||||
resizeButton();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
heat += Time.delta;
|
||||
if(heat >= 60f) {
|
||||
heat = 0f;
|
||||
ScrollPane pane = find("player-pane");
|
||||
pane.setWidget(rebuild());
|
||||
}
|
||||
}
|
||||
|
||||
public Table rebuild(){
|
||||
return new Table(table -> {
|
||||
float h = 74f;
|
||||
ImageButton.ImageButtonStyle ustyle = new ImageButton.ImageButtonStyle(){{
|
||||
down = Styles.none;
|
||||
up = Styles.none;
|
||||
imageDownColor = Pal.accent;
|
||||
imageUpColor = Color.white;
|
||||
imageOverColor = Color.lightGray;
|
||||
}};
|
||||
|
||||
Seq<Player> players = Groups.player.copy(new Seq<>());
|
||||
|
||||
players.sort(Structs.comps(Structs.comparing(Player::team), Structs.comparingBool(p -> !p.admin)));
|
||||
if(search.getText().length() > 0){
|
||||
players.filter(p -> Strings.stripColors(p.name().toLowerCase()).contains(search.getText().toLowerCase()));
|
||||
}
|
||||
|
||||
if(players.isEmpty()){
|
||||
table.add(Core.bundle.format("players.notfound")).center();
|
||||
return;
|
||||
}
|
||||
|
||||
for(Player user : players){
|
||||
table.table(userTable-> {
|
||||
userTable.left().margin(5).marginBottom(10);
|
||||
|
||||
Table table1 = new Table(){
|
||||
@Override
|
||||
public void draw(){
|
||||
super.draw();
|
||||
|
||||
Draw.color(Pal.gray);
|
||||
Draw.alpha(parentAlpha);
|
||||
Lines.stroke(Scl.scl(4f));
|
||||
Lines.rect(x, y, width, height);
|
||||
Draw.reset();
|
||||
}
|
||||
};
|
||||
table1.margin(8);
|
||||
table1.add(new Image(user.icon()).setScaling(Scaling.bounded)).grow();
|
||||
|
||||
userTable.add(table1).size(h).name(user.name()); //unit icon
|
||||
userTable.labelWrap(user.name()).color(user.color()).width(170f).pad(10); //name
|
||||
userTable.image(Icon.admin).padRight(5).visible(()->user.admin);; //admin
|
||||
userTable.button(Icon.hammer, ustyle, () -> { //vote kick
|
||||
ui.showConfirm("@confirm", Core.bundle.format("confirmvotekick", user.name()), () -> {
|
||||
Call.sendChatMessage("/votekick " + user.name());
|
||||
});
|
||||
}).right().visible(()->user.team()==player.team()&&user!=player&&!user.admin);
|
||||
}).padBottom(-6).maxHeight(h + 14).row();
|
||||
table.image().height(4f).color(state.rules.pvp ? user.team().color : Pal.gray).growX().row();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -2,11 +2,12 @@ package UnitInfo.ui.windows;
|
||||
|
||||
public class WindowTables {
|
||||
public static WindowTable
|
||||
unitTable, waveTable, coreTable;
|
||||
unitTable, waveTable, coreTable, playerTable;
|
||||
|
||||
public static void init() {
|
||||
unitTable = new UnitDisplay();
|
||||
waveTable = new WaveDisplay();
|
||||
coreTable = new CoreDisplay();
|
||||
playerTable = new PlayerDisplay();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user