Added scroll pane for server menu (#6451)

* Added scroll pane for server menu

* Fixed title problems in menus

* Removed useless import
This commit is contained in:
Zelaux
2022-10-01 17:48:33 -04:00
committed by GitHub
parent 2e98abc86e
commit 5863f2f353
+10 -4
View File
@@ -562,15 +562,20 @@ public class UI implements ApplicationListener, Loadable{
/** Shows a menu that fires a callback when an option is selected. If nothing is selected, -1 is returned. */ /** Shows a menu that fires a callback when an option is selected. If nothing is selected, -1 is returned. */
public void showMenu(String title, String message, String[][] options, Intc callback){ public void showMenu(String title, String message, String[][] options, Intc callback){
new Dialog(title){{ new Dialog(title){{
setFillParent(true);
removeChild(titleTable);
cont.add(titleTable).width(400f);
cont.row(); cont.row();
cont.image().width(400f).pad(2).colspan(2).height(4f).color(Pal.accent); cont.image().width(400f).pad(2).colspan(2).height(4f).color(Pal.accent).bottom();
cont.row();
cont.add(message).width(400f).wrap().get().setAlignment(Align.center);
cont.row(); cont.row();
cont.pane(table -> {
table.add(message).width(400f).wrap().get().setAlignment(Align.center);
table.row();
int option = 0; int option = 0;
for(var optionsRow : options){ for(var optionsRow : options){
Table buttonRow = buttons.row().table().get().row(); Table buttonRow = table.row().table().get().row();
int fullWidth = 400 - (optionsRow.length - 1) * 8; // adjust to count padding as well int fullWidth = 400 - (optionsRow.length - 1) * 8; // adjust to count padding as well
int width = fullWidth / optionsRow.length; int width = fullWidth / optionsRow.length;
int lastWidth = fullWidth - width * (optionsRow.length - 1); // take the rest of space for uneven table int lastWidth = fullWidth - width * (optionsRow.length - 1); // take the rest of space for uneven table
@@ -587,6 +592,7 @@ public class UI implements ApplicationListener, Loadable{
option++; option++;
} }
} }
}).growX();
closeOnBack(() -> callback.get(-1)); closeOnBack(() -> callback.get(-1));
}}.show(); }}.show();
} }