Better utilization of JoinDialog UI space
This commit is contained in:
@@ -42,6 +42,14 @@ public class BaseDialog extends Dialog{
|
|||||||
this(title, Core.scene.getStyle(DialogStyle.class));
|
this(title, Core.scene.getStyle(DialogStyle.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Places the buttons as an overlay on top of the content. Used when the content can be scrolled through.*/
|
||||||
|
protected void makeButtonOverlay(){
|
||||||
|
clearChildren();
|
||||||
|
add(titleTable).growX().row();
|
||||||
|
stack(cont, buttons).grow();
|
||||||
|
buttons.bottom();
|
||||||
|
}
|
||||||
|
|
||||||
protected void onResize(Runnable run){
|
protected void onResize(Runnable run){
|
||||||
Events.on(ResizeEvent.class, event -> {
|
Events.on(ResizeEvent.class, event -> {
|
||||||
if(isShown() && Core.scene.getDialog() == this){
|
if(isShown() && Core.scene.getDialog() == this){
|
||||||
@@ -55,11 +63,15 @@ public class BaseDialog extends Dialog{
|
|||||||
closeOnBack();
|
closeOnBack();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public void addCloseButton(float width){
|
||||||
public void addCloseButton(){
|
buttons.defaults().size(width, 64f);
|
||||||
buttons.defaults().size(210f, 64f);
|
buttons.button("@back", Icon.left, this::hide).size(width, 64f);
|
||||||
buttons.button("@back", Icon.left, this::hide).size(210f, 64f);
|
|
||||||
|
|
||||||
addCloseListener();
|
addCloseListener();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addCloseButton(){
|
||||||
|
addCloseButton(210f);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,6 +45,8 @@ public class JoinDialog extends BaseDialog{
|
|||||||
public JoinDialog(){
|
public JoinDialog(){
|
||||||
super("@joingame");
|
super("@joingame");
|
||||||
|
|
||||||
|
makeButtonOverlay();
|
||||||
|
|
||||||
style = new TextButtonStyle(){{
|
style = new TextButtonStyle(){{
|
||||||
over = Styles.flatOver;
|
over = Styles.flatOver;
|
||||||
font = Fonts.def;
|
font = Fonts.def;
|
||||||
@@ -56,13 +58,21 @@ public class JoinDialog extends BaseDialog{
|
|||||||
|
|
||||||
loadServers();
|
loadServers();
|
||||||
|
|
||||||
if(!steam) buttons.add().width(60f);
|
//mobile players don't get information >:(
|
||||||
|
boolean infoButton = !steam && !Core.app.isMobile();
|
||||||
|
|
||||||
|
if(infoButton) buttons.add().width(60f);
|
||||||
buttons.add().growX().width(-1);
|
buttons.add().growX().width(-1);
|
||||||
|
|
||||||
addCloseButton();
|
addCloseButton(Core.app.isMobile() ? 190f : 210f);
|
||||||
|
|
||||||
|
buttons.button("@server.add", Icon.add, () -> {
|
||||||
|
renaming = null;
|
||||||
|
add.show();
|
||||||
|
});
|
||||||
|
|
||||||
buttons.add().growX().width(-1);
|
buttons.add().growX().width(-1);
|
||||||
if(!steam) buttons.button("?", () -> ui.showInfo("@join.info")).size(60f, 64f);
|
if(infoButton) buttons.button("?", () -> ui.showInfo("@join.info")).size(60f, 64f);
|
||||||
|
|
||||||
add = new BaseDialog("@joingame.title");
|
add = new BaseDialog("@joingame.title");
|
||||||
add.cont.add("@joingame.ip").padRight(5f).left();
|
add.cont.add("@joingame.ip").padRight(5f).left();
|
||||||
@@ -314,6 +324,8 @@ public class JoinDialog extends BaseDialog{
|
|||||||
float w = targetWidth();
|
float w = targetWidth();
|
||||||
|
|
||||||
hosts.clear();
|
hosts.clear();
|
||||||
|
//since the buttons are an overlay, make room for that
|
||||||
|
hosts.marginBottom(70f);
|
||||||
|
|
||||||
section(steam ? "@servers.local.steam" : "@servers.local", local, false);
|
section(steam ? "@servers.local.steam" : "@servers.local", local, false);
|
||||||
section("@servers.remote", remote, false);
|
section("@servers.remote", remote, false);
|
||||||
@@ -344,25 +356,6 @@ public class JoinDialog extends BaseDialog{
|
|||||||
cont.row();
|
cont.row();
|
||||||
cont.add(pane).width((w + 5) * columns() + 33).pad(0);
|
cont.add(pane).width((w + 5) * columns() + 33).pad(0);
|
||||||
cont.row();
|
cont.row();
|
||||||
cont.buttonCenter("@server.add", Icon.add, () -> {
|
|
||||||
renaming = null;
|
|
||||||
add.show();
|
|
||||||
}).marginLeft(10).width(w).height(80f).update(button -> {
|
|
||||||
float pw = w;
|
|
||||||
float pad = 0f;
|
|
||||||
if(pane.getChildren().first().getPrefHeight() > pane.getHeight()){
|
|
||||||
pw = w + 30;
|
|
||||||
pad = 6;
|
|
||||||
}
|
|
||||||
|
|
||||||
var cell = ((Table)pane.parent).getCell(button);
|
|
||||||
|
|
||||||
if(!Mathf.equal(cell.minWidth(), pw)){
|
|
||||||
cell.width(pw);
|
|
||||||
cell.padLeft(pad);
|
|
||||||
pane.parent.invalidateHierarchy();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void section(String label, Table servers, boolean eye){
|
void section(String label, Table servers, boolean eye){
|
||||||
|
|||||||
@@ -54,6 +54,8 @@ public abstract class MapListDialog extends BaseDialog{
|
|||||||
abstract void showMap(Map map);
|
abstract void showMap(Map map);
|
||||||
|
|
||||||
void setup(){
|
void setup(){
|
||||||
|
makeButtonOverlay();
|
||||||
|
|
||||||
buttons.clearChildren();
|
buttons.clearChildren();
|
||||||
|
|
||||||
searchString = null;
|
searchString = null;
|
||||||
@@ -86,15 +88,13 @@ public abstract class MapListDialog extends BaseDialog{
|
|||||||
|
|
||||||
cont.add(search).growX();
|
cont.add(search).growX();
|
||||||
cont.row();
|
cont.row();
|
||||||
cont.add(pane).uniformX().growY();
|
cont.add(pane).padLeft(36f).uniformX().growY();
|
||||||
cont.row();
|
|
||||||
cont.add(buttons).growX();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void rebuildMaps(){
|
void rebuildMaps(){
|
||||||
mapTable.clear();
|
mapTable.clear();
|
||||||
|
|
||||||
mapTable.marginRight(24);
|
mapTable.marginRight(18f);
|
||||||
|
|
||||||
int maxwidth = Math.max((int)(Core.graphics.getWidth() / Scl.scl(230)), 1);
|
int maxwidth = Math.max((int)(Core.graphics.getWidth() / Scl.scl(230)), 1);
|
||||||
float mapsize = 200f;
|
float mapsize = 200f;
|
||||||
|
|||||||
Reference in New Issue
Block a user