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