Compact player list

This commit is contained in:
Anuken
2022-08-11 12:06:14 -04:00
parent e28dbfad69
commit 06e08c1074
4 changed files with 51 additions and 30 deletions

View File

@@ -232,6 +232,7 @@ servers.showhidden = Show Hidden Servers
server.shown = Shown server.shown = Shown
server.hidden = Hidden server.hidden = Hidden
viewplayer = Viewing Player: [accent]{0}
trace = Trace Player trace = Trace Player
trace.playername = Player name: [accent]{0} trace.playername = Player name: [accent]{0}
trace.ip = IP: [accent]{0} trace.ip = IP: [accent]{0}

View File

@@ -305,12 +305,16 @@ public class UI implements ApplicationListener, Loadable{
} }
public void showInfoFade(String info){ public void showInfoFade(String info){
showInfoFade(info, 7f);
}
public void showInfoFade(String info, float duration){
var cinfo = Core.scene.find("coreinfo"); var cinfo = Core.scene.find("coreinfo");
Table table = new Table(); Table table = new Table();
table.touchable = Touchable.disabled; table.touchable = Touchable.disabled;
table.setFillParent(true); table.setFillParent(true);
if(cinfo.visible && !state.isMenu()) table.marginTop(cinfo.getPrefHeight() / Scl.scl() / 2); if(cinfo.visible && !state.isMenu()) table.marginTop(cinfo.getPrefHeight() / Scl.scl() / 2);
table.actions(Actions.fadeOut(7f, Interp.fade), Actions.remove()); table.actions(Actions.fadeOut(duration, Interp.fade), Actions.remove());
table.top().add(info).style(Styles.outlineLabel).padTop(10); table.top().add(info).style(Styles.outlineLabel).padTop(10);
Core.scene.add(table); Core.scene.add(table);
} }

View File

@@ -402,7 +402,7 @@ public class JoinDialog extends BaseDialog{
t.add("@search").padRight(10); t.add("@search").padRight(10);
t.field(serverSearch, text -> t.field(serverSearch, text ->
serverSearch = text.trim().replaceAll(" +", " ").toLowerCase() serverSearch = text.trim().replaceAll(" +", " ").toLowerCase()
).grow().pad(8); ).grow().pad(8).get().keyDown(KeyCode.enter, this::refreshCommunity);
t.button(Icon.zoom, Styles.emptyi, this::refreshCommunity).size(54f); t.button(Icon.zoom, Styles.emptyi, this::refreshCommunity).size(54f);
}).width(targetWidth()).height(70f).pad(4).row(); }).width(targetWidth()).height(70f).pad(4).row();
@@ -422,14 +422,11 @@ public class JoinDialog extends BaseDialog{
net.pingHost(resaddress, resport, res -> { net.pingHost(resaddress, resport, res -> {
if(refreshes != cur) return; if(refreshes != cur) return;
if(!serverSearch.isEmpty()){ if(!serverSearch.isEmpty() && !(group.name.toLowerCase().contains(serverSearch)
if(!(group.name.toLowerCase().contains(serverSearch) || res.name.toLowerCase().contains(serverSearch)
|| res.name.toLowerCase().contains(serverSearch) || res.description.toLowerCase().contains(serverSearch)
|| res.description.toLowerCase().contains(serverSearch) || res.mapname.toLowerCase().contains(serverSearch)
|| res.mapname.toLowerCase().contains(serverSearch) || (res.modeName != null && res.modeName.toLowerCase().contains(serverSearch)))) return;
|| (res.modeName != null && res.modeName.toLowerCase().contains(serverSearch))))
return;
}
//add header //add header
if(groupTable[0] == null){ if(groupTable[0] == null){

View File

@@ -12,6 +12,7 @@ import arc.struct.*;
import arc.util.*; import arc.util.*;
import mindustry.gen.*; import mindustry.gen.*;
import mindustry.graphics.*; import mindustry.graphics.*;
import mindustry.input.*;
import mindustry.net.*; import mindustry.net.*;
import mindustry.net.Packets.*; import mindustry.net.Packets.*;
import mindustry.ui.*; import mindustry.ui.*;
@@ -74,7 +75,7 @@ public class PlayerListFragment{
public void rebuild(){ public void rebuild(){
content.clear(); content.clear();
float h = 74f; float h = 50f;
boolean found = false; boolean found = false;
players.clear(); players.clear();
@@ -95,25 +96,47 @@ public class PlayerListFragment{
button.left(); button.left();
button.margin(5).marginBottom(10); button.margin(5).marginBottom(10);
Table table = new Table(){ ClickListener listener = new ClickListener();
Table iconTable = new Table(){
@Override @Override
public void draw(){ public void draw(){
super.draw(); super.draw();
Draw.color(Pal.gray); Draw.colorMul(user.team().color, listener.isOver() ? 1.3f : 1f);
Draw.alpha(parentAlpha); Draw.alpha(parentAlpha);
Lines.stroke(Scl.scl(4f)); Lines.stroke(Scl.scl(4f));
Lines.rect(x, y, width, height); Lines.rect(x, y, width, height);
Draw.reset(); Draw.reset();
} }
}; };
table.margin(8);
table.add(new Image(user.icon()).setScaling(Scaling.bounded)).grow();
table.name = user.name();
button.add(table).size(h); boolean clickable = !(state.rules.fog && state.rules.pvp && user.team() != player.team());
button.labelWrap("[#" + user.color().toString().toUpperCase() + "]" + user.name()).width(170f).pad(10);
if(clickable){
iconTable.addListener(listener);
iconTable.addListener(new HandCursorListener());
}
iconTable.margin(8);
iconTable.add(new Image(user.icon()).setScaling(Scaling.bounded)).grow();
iconTable.name = user.name();
iconTable.touchable = Touchable.enabled;
iconTable.tapped(() -> {
if(!user.dead() && clickable){
Core.camera.position.set(user.unit());
ui.showInfoFade(Core.bundle.format("viewplayer", user.name), 1f);
if(control.input instanceof DesktopInput input){
input.panning = true;
}
}
});
button.add(iconTable).size(h);
button.labelWrap("[#" + user.color().toString().toUpperCase() + "]" + user.name()).style(Styles.outlineLabel).width(170f).pad(10);
button.add().grow(); button.add().grow();
button.background(Tex.underline);
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(){{ var style = new ImageButtonStyle(){{
@@ -141,14 +164,14 @@ public class PlayerListFragment{
button.table(t -> { button.table(t -> {
t.defaults().size(bs); t.defaults().size(bs);
t.button(Icon.hammer, ustyle, t.button(Icon.hammerSmall, ustyle,
() -> ui.showConfirm("@confirm", Core.bundle.format("confirmban", user.name()), () -> Call.adminRequest(user, AdminAction.ban))); () -> ui.showConfirm("@confirm", Core.bundle.format("confirmban", user.name()), () -> Call.adminRequest(user, AdminAction.ban)));
t.button(Icon.cancel, ustyle, t.button(Icon.cancelSmall, ustyle,
() -> ui.showConfirm("@confirm", Core.bundle.format("confirmkick", user.name()), () -> Call.adminRequest(user, AdminAction.kick))); () -> ui.showConfirm("@confirm", Core.bundle.format("confirmkick", user.name()), () -> Call.adminRequest(user, AdminAction.kick)));
t.row(); t.row();
t.button(Icon.admin, style, () -> { t.button(Icon.adminSmall, style, () -> {
if(net.client()) return; if(net.client()) return;
String id = user.uuid(); String id = user.uuid();
@@ -169,23 +192,19 @@ public class PlayerListFragment{
.touchable(() -> net.client() ? Touchable.disabled : Touchable.enabled) .touchable(() -> net.client() ? Touchable.disabled : Touchable.enabled)
.checked(user.admin); .checked(user.admin);
t.button(Icon.zoom, ustyle, () -> Call.adminRequest(user, AdminAction.trace)); t.button(Icon.zoomSmall, ustyle, () -> Call.adminRequest(user, AdminAction.trace));
}).padRight(12).size(bs + 10f, bs); }).padRight(12).size(bs + 10f, bs);
}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();
button.button(Icon.hammer, ustyle, button.button(Icon.hammer, ustyle,
() -> { () -> ui.showConfirm("@confirm", Core.bundle.format("confirmvotekick", user.name()),
ui.showConfirm("@confirm", Core.bundle.format("confirmvotekick", user.name()), () -> { () -> Call.sendChatMessage("/votekick " + user.name())))
Call.sendChatMessage("/votekick " + user.name()); .size(h);
});
}).size(h);
} }
content.add(button).padBottom(-6).width(350f).maxHeight(h + 14); content.add(button).width(350f).height(h + 14);
content.row();
content.image().height(4f).color(state.rules.pvp ? user.team().color : Pal.gray).growX();
content.row(); content.row();
} }