Fixed empty admin menu
This commit is contained in:
@@ -75,6 +75,8 @@ public class PlayerListFragment{
|
||||
}
|
||||
|
||||
public void rebuild(){
|
||||
boolean allowTeamSwitch = !state.isCampaign() && (state.rules.pvp || state.rules.infiniteResources);
|
||||
|
||||
content.clear();
|
||||
|
||||
float h = 50f;
|
||||
@@ -141,15 +143,6 @@ public class PlayerListFragment{
|
||||
|
||||
button.image(Icon.admin).visible(() -> user.admin && !(!user.isLocal() && net.server())).padRight(5).get().updateVisibility();
|
||||
|
||||
var style = new ImageButtonStyle(){{
|
||||
down = Styles.none;
|
||||
up = Styles.none;
|
||||
imageCheckedColor = Pal.accent;
|
||||
imageDownColor = Pal.accent;
|
||||
imageUpColor = Color.white;
|
||||
imageOverColor = Color.lightGray;
|
||||
}};
|
||||
|
||||
var ustyle = new ImageButtonStyle(){{
|
||||
down = Styles.none;
|
||||
up = Styles.none;
|
||||
@@ -161,96 +154,98 @@ public class PlayerListFragment{
|
||||
if(net.server() || (player.admin && (!user.admin || user == player))){
|
||||
button.add().growY();
|
||||
|
||||
button.button(Icon.menu, ustyle, () -> {
|
||||
var dialog = new BaseDialog(user.coloredName());
|
||||
if(allowTeamSwitch || user != player){
|
||||
button.button(Icon.menu, ustyle, () -> {
|
||||
var dialog = new BaseDialog(user.coloredName());
|
||||
|
||||
dialog.title.setColor(Color.white);
|
||||
dialog.titleTable.remove();
|
||||
dialog.title.setColor(Color.white);
|
||||
dialog.titleTable.remove();
|
||||
|
||||
dialog.closeOnBack();
|
||||
dialog.closeOnBack();
|
||||
|
||||
var bstyle = Styles.defaultt;
|
||||
var bstyle = Styles.defaultt;
|
||||
|
||||
dialog.cont.add(user.coloredName()).row();
|
||||
dialog.cont.image(Tex.whiteui, Pal.accent).fillX().height(3f).pad(4f).row();
|
||||
dialog.cont.add(user.coloredName()).row();
|
||||
dialog.cont.image(Tex.whiteui, Pal.accent).fillX().height(3f).pad(4f).row();
|
||||
|
||||
dialog.cont.pane(t -> {
|
||||
t.defaults().size(220f, 55f).pad(3f);
|
||||
dialog.cont.pane(t -> {
|
||||
t.defaults().size(220f, 55f).pad(3f);
|
||||
|
||||
if(user != player){
|
||||
t.button("@player.ban", Icon.hammer, bstyle, () -> {
|
||||
ui.showConfirm("@confirm", Core.bundle.format("confirmban", user.name()), () -> Call.adminRequest(user, AdminAction.ban, null));
|
||||
dialog.hide();
|
||||
}).row();
|
||||
if(user != player){
|
||||
t.button("@player.ban", Icon.hammer, bstyle, () -> {
|
||||
ui.showConfirm("@confirm", Core.bundle.format("confirmban", user.name()), () -> Call.adminRequest(user, AdminAction.ban, null));
|
||||
dialog.hide();
|
||||
}).row();
|
||||
|
||||
t.button("@player.kick", Icon.cancel, bstyle, () -> {
|
||||
ui.showConfirm("@confirm", Core.bundle.format("confirmkick", user.name()), () -> Call.adminRequest(user, AdminAction.kick, null));
|
||||
dialog.hide();
|
||||
}).row();
|
||||
t.button("@player.kick", Icon.cancel, bstyle, () -> {
|
||||
ui.showConfirm("@confirm", Core.bundle.format("confirmkick", user.name()), () -> Call.adminRequest(user, AdminAction.kick, null));
|
||||
dialog.hide();
|
||||
}).row();
|
||||
|
||||
t.button("@player.trace", Icon.zoom, bstyle, () -> {
|
||||
Call.adminRequest(user, AdminAction.trace, null);
|
||||
dialog.hide();
|
||||
}).row();
|
||||
}
|
||||
t.button("@player.trace", Icon.zoom, bstyle, () -> {
|
||||
Call.adminRequest(user, AdminAction.trace, null);
|
||||
dialog.hide();
|
||||
}).row();
|
||||
}
|
||||
|
||||
//there's generally no reason to team switch outside PvP or sandbox, and it's basically an easy way to cheat
|
||||
if(!state.isCampaign() && (state.rules.pvp || state.rules.infiniteResources)){
|
||||
t.button("@player.team", Icon.redo, bstyle, () -> {
|
||||
var teamSelect = new BaseDialog(Core.bundle.get("player.team") + ": " + user.name);
|
||||
teamSelect.setFillParent(false);
|
||||
//there's generally no reason to team switch outside PvP or sandbox, and it's basically an easy way to cheat
|
||||
if(allowTeamSwitch){
|
||||
t.button("@player.team", Icon.redo, bstyle, () -> {
|
||||
var teamSelect = new BaseDialog(Core.bundle.get("player.team") + ": " + user.name);
|
||||
teamSelect.setFillParent(false);
|
||||
|
||||
var group = new ButtonGroup<>();
|
||||
var group = new ButtonGroup<>();
|
||||
|
||||
int i = 0;
|
||||
int i = 0;
|
||||
|
||||
for(Team team : Team.baseTeams){
|
||||
var b = new ImageButton(Tex.whiteui, Styles.clearNoneTogglei);
|
||||
b.margin(4f);
|
||||
b.getImageCell().grow();
|
||||
b.getStyle().imageUpColor = team.color;
|
||||
b.clicked(() -> {
|
||||
Call.adminRequest(user, AdminAction.switchTeam, team);
|
||||
teamSelect.hide();
|
||||
});
|
||||
teamSelect.cont.add(b).size(50f).checked(a -> user.team() == team).group(group);
|
||||
for(Team team : Team.baseTeams){
|
||||
var b = new ImageButton(Tex.whiteui, Styles.clearNoneTogglei);
|
||||
b.margin(4f);
|
||||
b.getImageCell().grow();
|
||||
b.getStyle().imageUpColor = team.color;
|
||||
b.clicked(() -> {
|
||||
Call.adminRequest(user, AdminAction.switchTeam, team);
|
||||
teamSelect.hide();
|
||||
});
|
||||
teamSelect.cont.add(b).size(50f).checked(a -> user.team() == team).group(group);
|
||||
|
||||
if(i++ % 3 == 2) teamSelect.cont.row();
|
||||
}
|
||||
if(i++ % 3 == 2) teamSelect.cont.row();
|
||||
}
|
||||
|
||||
teamSelect.addCloseButton();
|
||||
teamSelect.show();
|
||||
teamSelect.addCloseButton();
|
||||
teamSelect.show();
|
||||
|
||||
dialog.hide();
|
||||
}).row();
|
||||
}
|
||||
dialog.hide();
|
||||
}).row();
|
||||
}
|
||||
|
||||
if(!net.client() && !user.isLocal()){
|
||||
t.button("@player.admin", Icon.admin, Styles.togglet, () -> {
|
||||
dialog.hide();
|
||||
String id = user.uuid();
|
||||
if(!net.client() && !user.isLocal()){
|
||||
t.button("@player.admin", Icon.admin, Styles.togglet, () -> {
|
||||
dialog.hide();
|
||||
String id = user.uuid();
|
||||
|
||||
if(user.admin){
|
||||
ui.showConfirm("@confirm", Core.bundle.format("confirmunadmin", user.name()), () -> {
|
||||
netServer.admins.unAdminPlayer(id);
|
||||
user.admin = false;
|
||||
});
|
||||
}else{
|
||||
ui.showConfirm("@confirm", Core.bundle.format("confirmadmin", user.name()), () -> {
|
||||
netServer.admins.adminPlayer(id, user.usid());
|
||||
user.admin = true;
|
||||
});
|
||||
}
|
||||
}).checked(b -> user.admin).row();
|
||||
}
|
||||
}).row();
|
||||
if(user.admin){
|
||||
ui.showConfirm("@confirm", Core.bundle.format("confirmunadmin", user.name()), () -> {
|
||||
netServer.admins.unAdminPlayer(id);
|
||||
user.admin = false;
|
||||
});
|
||||
}else{
|
||||
ui.showConfirm("@confirm", Core.bundle.format("confirmadmin", user.name()), () -> {
|
||||
netServer.admins.adminPlayer(id, user.usid());
|
||||
user.admin = true;
|
||||
});
|
||||
}
|
||||
}).checked(b -> user.admin).row();
|
||||
}
|
||||
}).row();
|
||||
|
||||
dialog.cont.button("@back", Icon.left, dialog::hide).padTop(-1f).size(220f, 55f);
|
||||
dialog.cont.button("@back", Icon.left, dialog::hide).padTop(-1f).size(220f, 55f);
|
||||
|
||||
dialog.show();
|
||||
dialog.show();
|
||||
|
||||
|
||||
}).size(h);
|
||||
}).size(h);
|
||||
}
|
||||
}else if(!user.isLocal() && !user.admin && net.client() && Groups.player.size() >= 3 && player.team() == user.team()){ //votekick
|
||||
button.add().growY();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user