diff --git a/core/assets/bundles/bundle.properties b/core/assets/bundles/bundle.properties index 261e094248..58112b3bc5 100644 --- a/core/assets/bundles/bundle.properties +++ b/core/assets/bundles/bundle.properties @@ -232,6 +232,7 @@ servers.showhidden = Show Hidden Servers server.shown = Shown server.hidden = Hidden +viewplayer = Viewing Player: [accent]{0} trace = Trace Player trace.playername = Player name: [accent]{0} trace.ip = IP: [accent]{0} diff --git a/core/src/mindustry/core/UI.java b/core/src/mindustry/core/UI.java index 5904aed9be..6c90c9f6b3 100644 --- a/core/src/mindustry/core/UI.java +++ b/core/src/mindustry/core/UI.java @@ -305,12 +305,16 @@ public class UI implements ApplicationListener, Loadable{ } public void showInfoFade(String info){ + showInfoFade(info, 7f); + } + + public void showInfoFade(String info, float duration){ var cinfo = Core.scene.find("coreinfo"); Table table = new Table(); table.touchable = Touchable.disabled; table.setFillParent(true); 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); Core.scene.add(table); } diff --git a/core/src/mindustry/ui/dialogs/JoinDialog.java b/core/src/mindustry/ui/dialogs/JoinDialog.java index 9b0ce4947a..6d343e56ad 100644 --- a/core/src/mindustry/ui/dialogs/JoinDialog.java +++ b/core/src/mindustry/ui/dialogs/JoinDialog.java @@ -402,7 +402,7 @@ public class JoinDialog extends BaseDialog{ t.add("@search").padRight(10); t.field(serverSearch, text -> 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); }).width(targetWidth()).height(70f).pad(4).row(); @@ -422,14 +422,11 @@ public class JoinDialog extends BaseDialog{ net.pingHost(resaddress, resport, res -> { if(refreshes != cur) return; - if(!serverSearch.isEmpty()){ - if(!(group.name.toLowerCase().contains(serverSearch) - || res.name.toLowerCase().contains(serverSearch) - || res.description.toLowerCase().contains(serverSearch) - || res.mapname.toLowerCase().contains(serverSearch) - || (res.modeName != null && res.modeName.toLowerCase().contains(serverSearch)))) - return; - } + if(!serverSearch.isEmpty() && !(group.name.toLowerCase().contains(serverSearch) + || res.name.toLowerCase().contains(serverSearch) + || res.description.toLowerCase().contains(serverSearch) + || res.mapname.toLowerCase().contains(serverSearch) + || (res.modeName != null && res.modeName.toLowerCase().contains(serverSearch)))) return; //add header if(groupTable[0] == null){ diff --git a/core/src/mindustry/ui/fragments/PlayerListFragment.java b/core/src/mindustry/ui/fragments/PlayerListFragment.java index 1b749004f3..c805057bf3 100644 --- a/core/src/mindustry/ui/fragments/PlayerListFragment.java +++ b/core/src/mindustry/ui/fragments/PlayerListFragment.java @@ -12,6 +12,7 @@ import arc.struct.*; import arc.util.*; import mindustry.gen.*; import mindustry.graphics.*; +import mindustry.input.*; import mindustry.net.*; import mindustry.net.Packets.*; import mindustry.ui.*; @@ -74,7 +75,7 @@ public class PlayerListFragment{ public void rebuild(){ content.clear(); - float h = 74f; + float h = 50f; boolean found = false; players.clear(); @@ -95,25 +96,47 @@ public class PlayerListFragment{ button.left(); button.margin(5).marginBottom(10); - Table table = new Table(){ + ClickListener listener = new ClickListener(); + + Table iconTable = new Table(){ @Override public void draw(){ super.draw(); - Draw.color(Pal.gray); + Draw.colorMul(user.team().color, listener.isOver() ? 1.3f : 1f); Draw.alpha(parentAlpha); Lines.stroke(Scl.scl(4f)); Lines.rect(x, y, width, height); Draw.reset(); } }; - table.margin(8); - table.add(new Image(user.icon()).setScaling(Scaling.bounded)).grow(); - table.name = user.name(); - button.add(table).size(h); - button.labelWrap("[#" + user.color().toString().toUpperCase() + "]" + user.name()).width(170f).pad(10); + boolean clickable = !(state.rules.fog && state.rules.pvp && user.team() != player.team()); + + 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.background(Tex.underline); + button.image(Icon.admin).visible(() -> user.admin && !(!user.isLocal() && net.server())).padRight(5).get().updateVisibility(); var style = new ImageButtonStyle(){{ @@ -141,14 +164,14 @@ public class PlayerListFragment{ button.table(t -> { 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))); - t.button(Icon.cancel, ustyle, + t.button(Icon.cancelSmall, ustyle, () -> ui.showConfirm("@confirm", Core.bundle.format("confirmkick", user.name()), () -> Call.adminRequest(user, AdminAction.kick))); t.row(); - t.button(Icon.admin, style, () -> { + t.button(Icon.adminSmall, style, () -> { if(net.client()) return; String id = user.uuid(); @@ -169,23 +192,19 @@ public class PlayerListFragment{ .touchable(() -> net.client() ? Touchable.disabled : Touchable.enabled) .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); }else if(!user.isLocal() && !user.admin && net.client() && Groups.player.size() >= 3 && player.team() == user.team()){ //votekick button.add().growY(); button.button(Icon.hammer, ustyle, - () -> { - ui.showConfirm("@confirm", Core.bundle.format("confirmvotekick", user.name()), () -> { - Call.sendChatMessage("/votekick " + user.name()); - }); - }).size(h); + () -> ui.showConfirm("@confirm", Core.bundle.format("confirmvotekick", user.name()), + () -> Call.sendChatMessage("/votekick " + user.name()))) + .size(h); } - content.add(button).padBottom(-6).width(350f).maxHeight(h + 14); - content.row(); - content.image().height(4f).color(state.rules.pvp ? user.team().color : Pal.gray).growX(); + content.add(button).width(350f).height(h + 14); content.row(); }