UI: better dialog support and scaling
parent
48b5585c61
commit
c22cd66661
|
@ -5,29 +5,34 @@ import com.badlogic.gdx.Screen;
|
|||
import com.badlogic.gdx.graphics.GL20;
|
||||
import com.badlogic.gdx.scenes.scene2d.Stage;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Container;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Dialog;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Table;
|
||||
import com.badlogic.gdx.utils.viewport.ScreenViewport;
|
||||
import com.emamaker.amazeing.ui.UIManager;
|
||||
|
||||
public class MyScreen implements Screen{
|
||||
public class MyScreen implements Screen {
|
||||
|
||||
//This method makes the UI super easy to scale and resize with just a little effort in code
|
||||
|
||||
//Main stage. Must only contain tableContainer
|
||||
// This method makes the UI super easy to scale and resize with just a little
|
||||
// effort in code
|
||||
|
||||
// Main stage. Must only contain tableContainer
|
||||
Stage stage;
|
||||
//Container for main stage table. This must only contain table
|
||||
// Container for main stage table. This must only contain table
|
||||
Container<Table> tableContainer = new Container<Table>();
|
||||
//Table that contains all the stage. Must be cleared any time the window is resize. Look at buildTable1()
|
||||
// Table that contains all the stage. Must be cleared any time the window is
|
||||
// resize. Look at buildTable1()
|
||||
Table table = new Table();
|
||||
|
||||
Container<Dialog> dialogContainer = new Container<Dialog>();
|
||||
|
||||
UIManager uiManager;
|
||||
UIManager uiManager;
|
||||
MyScreen prevScreen;
|
||||
|
||||
float width = Gdx.graphics.getWidth(), height = Gdx.graphics.getHeight();
|
||||
static float sw, sh;
|
||||
float cw, ch;
|
||||
float cwmult = 0.8f, chmult = 1f;
|
||||
|
||||
|
||||
public MyScreen(UIManager uiManager_) {
|
||||
this.uiManager = uiManager_;
|
||||
stage = new Stage(new ScreenViewport());
|
||||
|
@ -35,22 +40,25 @@ public class MyScreen implements Screen{
|
|||
stage = new Stage(new ScreenViewport());
|
||||
tableContainer.setActor(table);
|
||||
stage.addActor(tableContainer);
|
||||
|
||||
|
||||
// table.setDebug(true);
|
||||
|
||||
sw = width;
|
||||
sh = height;
|
||||
cw = sw * cwmult;
|
||||
ch = sh * chmult;
|
||||
|
||||
|
||||
createTable();
|
||||
buildTable();
|
||||
}
|
||||
|
||||
//Classes that inherit from this must use createTable to prepare the stage (create actors and listeners) and buildTable() to layout them
|
||||
//buildTable1 make sure the table is cleared before it's layout, since position and sizes have to recalculated each time the window is resized
|
||||
public void createTable() {}
|
||||
|
||||
|
||||
// Classes that inherit from this must use createTable to prepare the stage
|
||||
// (create actors and listeners) and buildTable() to layout them
|
||||
// buildTable1 make sure the table is cleared before it's layout, since position
|
||||
// and sizes have to recalculated each time the window is resized
|
||||
public void createTable() {
|
||||
}
|
||||
|
||||
public void buildTable() {
|
||||
table.clear();
|
||||
|
||||
|
@ -63,8 +71,9 @@ public class MyScreen implements Screen{
|
|||
tableContainer.setPosition((sw - cw) / 2.0f, (sh - ch) / 2.0f);
|
||||
tableContainer.fill();
|
||||
}
|
||||
|
||||
public void update() {}
|
||||
|
||||
public void update() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void show() {
|
||||
|
@ -80,10 +89,10 @@ public class MyScreen implements Screen{
|
|||
public void render(float delta) {
|
||||
Gdx.gl.glClearColor(0, 0, 0, 0);
|
||||
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
|
||||
|
||||
|
||||
update();
|
||||
|
||||
stage.act(Math.min(Gdx.graphics.getDeltaTime(), 1 / 30f));
|
||||
|
||||
stage.act(Math.min(Gdx.graphics.getDeltaTime(), 1 / 30f));
|
||||
stage.draw();
|
||||
}
|
||||
|
||||
|
@ -109,15 +118,30 @@ public class MyScreen implements Screen{
|
|||
}
|
||||
|
||||
public float containerDiagonal() {
|
||||
return (float) Math.sqrt( cw*cw + ch*ch );
|
||||
return (float) Math.sqrt(cw * cw + ch * ch);
|
||||
}
|
||||
|
||||
|
||||
public static float screenDiagonal() {
|
||||
return (float) Math.sqrt( sw*sw + sh*sh );
|
||||
return (float) Math.sqrt(sw * sw + sh * sh);
|
||||
}
|
||||
|
||||
|
||||
public void setPrevScreen(MyScreen s) {
|
||||
this.prevScreen = s;
|
||||
}
|
||||
|
||||
public void showDialog(Dialog d) {
|
||||
dialogContainer.setActor(d);
|
||||
d.setScale(containerDiagonal()*0.0005f);
|
||||
|
||||
dialogContainer.setSize(cw, ch);
|
||||
dialogContainer.setPosition((sw - dialogContainer.getWidth()) / 2.0f, (sh - dialogContainer.getHeight()) / 2.0f);
|
||||
dialogContainer.fill();
|
||||
|
||||
// d.show(s);
|
||||
stage.addActor(dialogContainer);
|
||||
}
|
||||
|
||||
public void hideDialog() {
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -29,8 +29,8 @@ public class PlayerChooseScreen extends MyScreen {
|
|||
Container<Table> firstRowContainer;
|
||||
Table firstRowTable;
|
||||
|
||||
Label instLab;
|
||||
TextButton backBtn, setBtn, helpBtn, playBtn;
|
||||
Label instLab, helpDlgText;
|
||||
TextButton backBtn, setBtn, helpBtn, playBtn, helpDlgOkBtn;
|
||||
Dialog helpDlg;
|
||||
|
||||
public PlayerChooseScreen(UIManager uiManager_) {
|
||||
|
@ -56,18 +56,21 @@ public class PlayerChooseScreen extends MyScreen {
|
|||
playBtn = new TextButton("Play!", uiManager.skin);
|
||||
/* HELP DIALOG */
|
||||
helpDlg = new Dialog("Help", uiManager.skin);
|
||||
helpDlg.text("Here you can start a singleplayer or multiplayer game on the local machine:\n"
|
||||
// helpDlg.setResizable(true);
|
||||
helpDlgText = new Label("Here you can start a singleplayer or multiplayer game on the local machine:\n"
|
||||
+ "For keyboard players, pressing W,A,S,D or the directional arrows will toggle two different players.\n"
|
||||
+ "Pressing a button on a controller will toggle a player.\n"
|
||||
+ "You can edit game settings from the \"Settings\" menu or use the \"<\" button to go back to the main menu\n"
|
||||
+ "Press the \"Play!\" button to start the game with the players that have currently joined.\n"
|
||||
+ "Once a game is finished you will go back to this menu");
|
||||
TextButton helpDlgOkBtn = new TextButton("OK", uiManager.skin);
|
||||
+ "Once a game is finished you will go back to this menu", uiManager.skin);
|
||||
helpDlg.text(helpDlgText);
|
||||
helpDlgOkBtn = new TextButton("OK", uiManager.skin);
|
||||
helpDlg.button(helpDlgOkBtn);
|
||||
helpDlgOkBtn.addListener(new InputListener() {
|
||||
@Override
|
||||
public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
|
||||
helpDlg.hide();
|
||||
// hideDialog();
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
@ -104,6 +107,7 @@ public class PlayerChooseScreen extends MyScreen {
|
|||
@Override
|
||||
public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
|
||||
helpDlg.show(stage);
|
||||
buildTable();
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
@ -112,7 +116,7 @@ public class PlayerChooseScreen extends MyScreen {
|
|||
|
||||
@Override
|
||||
public void buildTable() {
|
||||
super.buildTable();
|
||||
super.buildTable();
|
||||
firstRowTable.clear();
|
||||
|
||||
labels = new Label[MazeSettings.MAXPLAYERS];
|
||||
|
@ -129,6 +133,10 @@ public class PlayerChooseScreen extends MyScreen {
|
|||
firstRowContainer.setPosition(tableContainer.getX(), ch * 0.1f);
|
||||
firstRowContainer.fill();
|
||||
|
||||
helpDlg.setSize(cw*0.7f, ch*0.3f);
|
||||
helpDlg.setPosition((sw-helpDlg.getWidth())/2, (sh-helpDlg.getHeight())/2);
|
||||
helpDlgText.setFontScale(labScale*0.8f);
|
||||
helpDlgOkBtn.getLabel().setFontScale(labScale*0.8f);
|
||||
instLab.setFontScale(labScale);
|
||||
backBtn.getLabel().setFontScale(labScale);
|
||||
setBtn.getLabel().setFontScale(labScale);
|
||||
|
@ -139,7 +147,7 @@ public class PlayerChooseScreen extends MyScreen {
|
|||
firstRowTable.add(instLab).space(cw * 0.25f).width(cw / 2);
|
||||
firstRowTable.add(setBtn).fillX().expandX().space(cw * 0.005f).height(buttonDim);
|
||||
firstRowTable.add(helpBtn).fillX().expandX().space(cw * 0.005f).width(buttonDim).height(buttonDim);
|
||||
|
||||
|
||||
table.row().colspan(MazeSettings.MAXPLAYERS == 2 ? 2 : 4);
|
||||
|
||||
table.add(firstRowContainer);
|
||||
|
@ -156,6 +164,7 @@ public class PlayerChooseScreen extends MyScreen {
|
|||
}
|
||||
|
||||
MazePlayerLocal p;
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
// Consantly search for new players to be added
|
||||
|
|
|
@ -26,8 +26,8 @@ public class PreGameScreen extends MyScreen {
|
|||
Container<Table> firstRowContainer;
|
||||
Table firstRowTable;
|
||||
|
||||
Label instLab;
|
||||
TextButton backBtn, setBtn, helpBtn, playBtn;
|
||||
Label instLab, helpDlgText;
|
||||
TextButton backBtn, setBtn, helpBtn, playBtn, helpDlgOkBtn;
|
||||
Dialog helpDlg;
|
||||
|
||||
public PreGameScreen(UIManager uiManager_) {
|
||||
|
@ -56,13 +56,14 @@ public class PreGameScreen extends MyScreen {
|
|||
|
||||
/* HELP DIALOG */
|
||||
helpDlg = new Dialog("Help", uiManager.skin);
|
||||
helpDlg.text("An online game is about to start!\n"
|
||||
helpDlgText = new Label("An online game is about to start!\n"
|
||||
+ "If you're a client, just wait for the server to start the game.\n"
|
||||
+ "If you're a server, wait for players and start the game pressing the \"Start the match!\" button.\n"
|
||||
+ "How to join (for both client and server):\n"
|
||||
+ "On a computer players can join or leave the game pressing WASD, Arrow buttons or\n"
|
||||
+ "a button on the controller\n" + "On mobile players can be toggled using the buttons below.");
|
||||
TextButton helpDlgOkBtn = new TextButton("OK", uiManager.skin);
|
||||
+ "a button on the controller\n" + "On mobile players can be toggled using the buttons below.", uiManager.skin);
|
||||
helpDlg.text(helpDlgText);
|
||||
helpDlgOkBtn = new TextButton("OK", uiManager.skin);
|
||||
helpDlg.button(helpDlgOkBtn);
|
||||
helpDlgOkBtn.addListener(new InputListener() {
|
||||
@Override
|
||||
|
@ -120,6 +121,7 @@ public class PreGameScreen extends MyScreen {
|
|||
@Override
|
||||
public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
|
||||
helpDlg.show(stage);
|
||||
buildTable();
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
@ -141,6 +143,11 @@ public class PreGameScreen extends MyScreen {
|
|||
firstRowContainer.setSize(cw, ch * 0.2f);
|
||||
firstRowContainer.setPosition(tableContainer.getX(), ch * 0.1f);
|
||||
firstRowContainer.fill();
|
||||
|
||||
helpDlg.setSize(cw*0.65f, ch*0.4f);
|
||||
helpDlg.setPosition((sw-helpDlg.getWidth())/2, (sh-helpDlg.getHeight())/2);
|
||||
helpDlgText.setFontScale(labScale*0.9f);
|
||||
helpDlgOkBtn.getLabel().setFontScale(labScale*0.9f);
|
||||
|
||||
instLab.setFontScale(labScale);
|
||||
backBtn.getLabel().setFontScale(labScale);
|
||||
|
@ -155,7 +162,6 @@ public class PreGameScreen extends MyScreen {
|
|||
firstRowTable.add(helpBtn).fillX().expandX().space(cw * 0.005f).width(buttonDim).height(buttonDim);
|
||||
|
||||
table.row().colspan(MazeSettings.MAXPLAYERS == 2 ? 2 : 4);
|
||||
|
||||
table.add(firstRowContainer);
|
||||
|
||||
for (int i = 0; i < labels.length; i++) {
|
||||
|
@ -167,7 +173,7 @@ public class PreGameScreen extends MyScreen {
|
|||
|
||||
if (type == GameType.SERVER) {
|
||||
table.row().colspan(4);
|
||||
table.add(playBtn).fillX().width(buttonDim * 2f).height(buttonDim);
|
||||
table.add(playBtn).fillX().height(buttonDim);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -13,13 +13,15 @@ import com.emamaker.amazeing.ui.UIManager;
|
|||
|
||||
public class ServerJoinScreen extends MyScreen {
|
||||
|
||||
Label instLab, srvIpL;
|
||||
TextButton backBtn, connectBtn, helpBtn;
|
||||
Label instLab, srvIpL, helpDlgText, failDlgText;
|
||||
TextButton backBtn, connectBtn, helpBtn, helpDlgOkBtn, failDlgOkBtn;
|
||||
TextArea srvIp;
|
||||
|
||||
Container<Table> firstRowContainer;
|
||||
Table firstRowTable;
|
||||
|
||||
Dialog helpDlg, failDlg;
|
||||
|
||||
public ServerJoinScreen(UIManager uiManager_) {
|
||||
super(uiManager_);
|
||||
chmult=.8f;
|
||||
|
@ -40,11 +42,14 @@ public class ServerJoinScreen extends MyScreen {
|
|||
srvIpL = new Label("Server IP: ", uiManager.skin);
|
||||
srvIp = new TextArea("", uiManager.skin);
|
||||
|
||||
final Dialog helpDlg = new Dialog("Help", uiManager.skin);
|
||||
helpDlg = new Dialog("Help", uiManager.skin);
|
||||
/* HELP DIALOG */
|
||||
helpDlg.text("Here you can connect to a server to play with your friends over the network.\n"
|
||||
+ "The server host should provide you with address and port info to connect to the server");
|
||||
TextButton helpDlgOkBtn = new TextButton("OK", uiManager.skin);
|
||||
helpDlgText = new Label("Here you can connect to a server to play with your friends over the network.\n"
|
||||
+ "The server host should provide you with address and port info to connect to the server", uiManager.skin);
|
||||
|
||||
helpDlg.text(helpDlgText);
|
||||
helpDlgOkBtn = new TextButton("OK", uiManager.skin);
|
||||
|
||||
helpDlg.button(helpDlgOkBtn);
|
||||
helpDlgOkBtn.addListener(new InputListener() {
|
||||
@Override
|
||||
|
@ -54,11 +59,12 @@ public class ServerJoinScreen extends MyScreen {
|
|||
}
|
||||
});
|
||||
|
||||
final Dialog failDlg = new Dialog("Server start-up failed", uiManager.skin);
|
||||
failDlg = new Dialog("Server start-up failed", uiManager.skin);
|
||||
/* HELP DIALOG */
|
||||
failDlg.text("Connection to the server failed. Check your internet connection and address/port combination.\n"
|
||||
+ "Or Pheraps there's no server running there?");
|
||||
TextButton failDlgOkBtn = new TextButton("OK", uiManager.skin);
|
||||
failDlgText = new Label("Connection to the server failed. Check your internet connection and address/port combination.\n"
|
||||
+ "Or Pheraps there's no server running there?", uiManager.skin);
|
||||
failDlg.text(failDlgText);
|
||||
failDlgOkBtn = new TextButton("OK", uiManager.skin);
|
||||
failDlg.button(failDlgOkBtn);
|
||||
failDlg.addListener(new InputListener() {
|
||||
@Override
|
||||
|
@ -82,6 +88,7 @@ public class ServerJoinScreen extends MyScreen {
|
|||
@Override
|
||||
public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
|
||||
helpDlg.show(stage);
|
||||
buildTable();
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
@ -98,9 +105,11 @@ public class ServerJoinScreen extends MyScreen {
|
|||
uiManager.main.setScreen(uiManager.preGameScreen);
|
||||
} else {
|
||||
failDlg.show(stage);
|
||||
buildTable();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
failDlg.show(stage);
|
||||
buildTable();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -122,6 +131,16 @@ public class ServerJoinScreen extends MyScreen {
|
|||
firstRowContainer.setPosition(tableContainer.getX(), ch * 0.1f);
|
||||
firstRowContainer.fill();
|
||||
|
||||
helpDlg.setSize(cw*0.7f, ch*0.2f);
|
||||
helpDlg.setPosition((sw-helpDlg.getWidth())/2, (sh-helpDlg.getHeight())/2);
|
||||
helpDlgText.setFontScale(labScale*0.9f);
|
||||
helpDlgOkBtn.getLabel().setFontScale(labScale*0.9f);
|
||||
|
||||
failDlg.setSize(cw*0.7f, ch*0.2f);
|
||||
failDlg.setPosition((sw-failDlg.getWidth())/2, (sh-failDlg.getHeight())/2);
|
||||
failDlgText.setFontScale(labScale*0.9f);
|
||||
failDlgOkBtn.getLabel().setFontScale(labScale*0.9f);
|
||||
|
||||
instLab.setFontScale(labScale);
|
||||
backBtn.getLabel().setFontScale(labScale);
|
||||
helpBtn.getLabel().setFontScale(labScale);
|
||||
|
|
|
@ -14,9 +14,11 @@ import com.emamaker.amazeing.ui.UIManager;
|
|||
public class ServerLaunchScreen extends MyScreen {
|
||||
|
||||
MyScreen thisScreen;
|
||||
Label instLab, srvPortL;
|
||||
TextButton backBtn, connectBtn, setBtn, helpBtn;
|
||||
Label instLab, srvPortL, helpDlgText, failDlgText;
|
||||
TextButton backBtn, connectBtn, setBtn, helpBtn, helpDlgOkBtn, failDlgOkBtn;
|
||||
TextArea srvPort;
|
||||
Dialog helpDlg, failDlg;
|
||||
|
||||
|
||||
Table firstRowTable;
|
||||
Container<Table> firstRowContainer;
|
||||
|
@ -42,13 +44,14 @@ public class ServerLaunchScreen extends MyScreen {
|
|||
srvPortL = new Label("Port: ", uiManager.skin);
|
||||
srvPort = new TextArea("", uiManager.skin);
|
||||
|
||||
final Dialog helpDlg = new Dialog("Help", uiManager.skin);
|
||||
helpDlg = new Dialog("Help", uiManager.skin);
|
||||
/* HELP DIALOG */
|
||||
helpDlg.text("Here you can start a server to play with your friends over the network.\n"
|
||||
helpDlgText = new Label("Here you can start a server to play with your friends over the network.\n"
|
||||
+ "Choose a network port to start the server on and start the server.\n"
|
||||
+ "In the next screen you will be given the address and port other players have to connect to play on this server.\n"
|
||||
+ "The port must not being used by another program at the same time, or the server start-up will fail");
|
||||
TextButton helpDlgOkBtn = new TextButton("OK", uiManager.skin);
|
||||
+ "The port must not being used by another program at the same time, or the server start-up will fail", uiManager.skin);
|
||||
helpDlg.text(helpDlgText);
|
||||
helpDlgOkBtn = new TextButton("OK", uiManager.skin);
|
||||
helpDlg.button(helpDlgOkBtn);
|
||||
helpDlgOkBtn.addListener(new InputListener() {
|
||||
@Override
|
||||
|
@ -58,10 +61,11 @@ public class ServerLaunchScreen extends MyScreen {
|
|||
}
|
||||
});
|
||||
|
||||
final Dialog failDlg = new Dialog("Server start-up failed", uiManager.skin);
|
||||
failDlg = new Dialog("Server start-up failed", uiManager.skin);
|
||||
/* HELP DIALOG */
|
||||
failDlg.text("Server start-up failed. Pheraps the port is already being used?");
|
||||
TextButton failDlgOkBtn = new TextButton("OK", uiManager.skin);
|
||||
failDlgText = new Label("Server start-up failed. Pheraps the port is already being used?", uiManager.skin);
|
||||
failDlg.text(failDlgText);
|
||||
failDlgOkBtn = new TextButton("OK", uiManager.skin);
|
||||
failDlg.button(failDlgOkBtn);
|
||||
failDlg.addListener(new InputListener() {
|
||||
@Override
|
||||
|
@ -85,6 +89,7 @@ public class ServerLaunchScreen extends MyScreen {
|
|||
@Override
|
||||
public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
|
||||
helpDlg.show(stage);
|
||||
buildTable();
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
@ -100,14 +105,21 @@ public class ServerLaunchScreen extends MyScreen {
|
|||
connectBtn.addListener(new InputListener() {
|
||||
@Override
|
||||
public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
|
||||
try {
|
||||
if(uiManager.main.server.startServer(Integer.valueOf(srvPort.getText()))) {
|
||||
// If the server and the client have been started successfully, we can show the
|
||||
// joining screen
|
||||
uiManager.preGameScreen.setGameType(GameType.SERVER);
|
||||
uiManager.main.setScreen(uiManager.preGameScreen);
|
||||
}else {
|
||||
//Show the dialog to say there's was something wrong
|
||||
//Show the dialog to say there was something wrong
|
||||
failDlg.show(stage);
|
||||
buildTable();
|
||||
}
|
||||
}catch(Exception e) {
|
||||
//Show the dialog to say there was something wrong
|
||||
failDlg.show(stage);
|
||||
buildTable();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -130,6 +142,16 @@ public class ServerLaunchScreen extends MyScreen {
|
|||
firstRowContainer.setPosition(tableContainer.getX(), ch * 0.1f);
|
||||
firstRowContainer.fill();
|
||||
|
||||
helpDlg.setSize(cw*0.8f, ch*0.3f);
|
||||
helpDlg.setPosition((sw-helpDlg.getWidth())/2, (sh-helpDlg.getHeight())/2);
|
||||
helpDlgText.setFontScale(labScale*0.9f);
|
||||
helpDlgOkBtn.getLabel().setFontScale(labScale*0.9f);
|
||||
|
||||
failDlg.setSize(cw*0.45f, ch*0.2f);
|
||||
failDlg.setPosition((sw-failDlg.getWidth())/2, (sh-failDlg.getHeight())/2);
|
||||
failDlgText.setFontScale(labScale*0.9f);
|
||||
failDlgOkBtn.getLabel().setFontScale(labScale*0.9f);
|
||||
|
||||
instLab.setFontScale(labScale);
|
||||
backBtn.getLabel().setFontScale(labScale);
|
||||
helpBtn.getLabel().setFontScale(labScale);
|
||||
|
@ -145,7 +167,7 @@ public class ServerLaunchScreen extends MyScreen {
|
|||
table.add(srvPortL).space(buttonDim).width(buttonDim*4f).height(buttonDim*0.5f).fillY().expandY();
|
||||
table.add(srvPort).space(buttonDim).width(buttonDim*4f).height(buttonDim*0.5f).fillY().expandY();
|
||||
table.row().colspan(4);
|
||||
table.add(connectBtn).fillX().width(buttonDim*3f).height(buttonDim);
|
||||
table.add(connectBtn).fillX().height(buttonDim);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -14,9 +14,11 @@ import com.emamaker.amazeing.ui.UIManager;
|
|||
|
||||
public class SettingsScreen extends MyScreen {
|
||||
|
||||
Label instLab;
|
||||
TextButton backBtn, resetBtn, saveBtn, helpBtn;
|
||||
Label instLab, helpDlgText, resetDlgText, backDlgText;
|
||||
TextButton backBtn, resetBtn, saveBtn, helpBtn, backDlgOkBtn, backDlgCancelBtn, helpDlgOkBtn, resetDlgOkBtn, resetDlgCancelBtn;
|
||||
ScrollPane scrollPane;
|
||||
|
||||
Dialog helpDlg, resetDlg, backDlg;
|
||||
|
||||
Container<Table> firstRowContainer;
|
||||
Table firstRowTable;
|
||||
|
@ -40,12 +42,14 @@ public class SettingsScreen extends MyScreen {
|
|||
saveBtn = new TextButton("Save", uiManager.skin);
|
||||
helpBtn = new TextButton("?", uiManager.skin);
|
||||
scrollPane = new ScrollPane(setSettings(), uiManager.skin);
|
||||
final Dialog helpDlg = new Dialog("Help", uiManager.skin);
|
||||
helpDlg = new Dialog("Help", uiManager.skin);
|
||||
/* HELP DIALOG */
|
||||
helpDlg.text("Here you can customize game settings:\n"
|
||||
helpDlgText = new Label("Here you can customize game settings:\n"
|
||||
+ "Maze Size: changes the size of the maze. Mazes are always squares. This affects both local and online games.\n"
|
||||
+ "Max. Players: changes the max number of players that can join the game. This affects both local and online games.");
|
||||
TextButton helpDlgOkBtn = new TextButton("OK", uiManager.skin);
|
||||
+ "Max. Players: changes the max number of players that can join the game. This affects both local and online games.", uiManager.skin);
|
||||
helpDlg.text(helpDlgText);
|
||||
|
||||
helpDlgOkBtn = new TextButton("OK", uiManager.skin);
|
||||
helpDlg.button(helpDlgOkBtn);
|
||||
helpDlgOkBtn.addListener(new InputListener() {
|
||||
@Override
|
||||
|
@ -54,11 +58,13 @@ public class SettingsScreen extends MyScreen {
|
|||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
/* BACK DIALOG */
|
||||
final Dialog backDlg = new Dialog("Go Back", uiManager.skin);
|
||||
backDlg.text("Are you sure you want to go back without saving changes?\nThis cannot be reverted");
|
||||
TextButton backDlgCancelBtn = new TextButton("Cancel", uiManager.skin);
|
||||
TextButton backDlgOkBtn = new TextButton("OK", uiManager.skin);
|
||||
backDlg = new Dialog("Go Back", uiManager.skin);
|
||||
backDlgText = new Label("Are you sure you want to go back without saving changes?\nThis cannot be reverted", uiManager.skin);
|
||||
backDlg.text(backDlgText);
|
||||
backDlgCancelBtn = new TextButton("Cancel", uiManager.skin);
|
||||
backDlgOkBtn = new TextButton("OK", uiManager.skin);
|
||||
backDlg.button(backDlgCancelBtn);
|
||||
backDlg.button(backDlgOkBtn);
|
||||
backDlgOkBtn.addListener(new InputListener() {
|
||||
|
@ -77,13 +83,15 @@ public class SettingsScreen extends MyScreen {
|
|||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
/* RESET DIALOG */
|
||||
final Dialog resetDlg = new Dialog("Reset All Settings", uiManager.skin);
|
||||
resetDlg.text("Are you sure you want to reset all settings?\nThis cannot be reverted");
|
||||
TextButton resetDlgCancelBtn = new TextButton("Cancel", uiManager.skin);
|
||||
TextButton resetDlgOkBtn = new TextButton("OK", uiManager.skin);
|
||||
resetDlg.button(resetDlgOkBtn);
|
||||
resetDlg = new Dialog("Reset All Settings", uiManager.skin);
|
||||
resetDlgText = new Label("Are you sure you want to reset all settings?\nThis cannot be reverted", uiManager.skin);
|
||||
resetDlg.text(resetDlgText);
|
||||
resetDlgCancelBtn = new TextButton("Cancel", uiManager.skin);
|
||||
resetDlgOkBtn = new TextButton("OK", uiManager.skin);
|
||||
resetDlg.button(resetDlgCancelBtn);
|
||||
resetDlg.button(resetDlgOkBtn);
|
||||
resetDlgOkBtn.addListener(new InputListener() {
|
||||
@Override
|
||||
public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
|
||||
|
@ -105,6 +113,7 @@ public class SettingsScreen extends MyScreen {
|
|||
@Override
|
||||
public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
|
||||
backDlg.show(stage);
|
||||
buildTable();
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
@ -112,6 +121,7 @@ public class SettingsScreen extends MyScreen {
|
|||
@Override
|
||||
public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
|
||||
helpDlg.show(stage);
|
||||
buildTable();
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
@ -119,6 +129,7 @@ public class SettingsScreen extends MyScreen {
|
|||
@Override
|
||||
public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
|
||||
resetDlg.show(stage);
|
||||
buildTable();
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
@ -148,6 +159,23 @@ public class SettingsScreen extends MyScreen {
|
|||
firstRowContainer.setPosition(tableContainer.getX(), ch * 0.1f);
|
||||
firstRowContainer.fill();
|
||||
|
||||
helpDlg.setSize(cw*0.8f, ch*0.3f);
|
||||
helpDlg.setPosition((sw-helpDlg.getWidth())/2, (sh-helpDlg.getHeight())/2);
|
||||
helpDlgText.setFontScale(labScale*0.9f);
|
||||
helpDlgOkBtn.getLabel().setFontScale(labScale*0.9f);
|
||||
|
||||
resetDlg.setSize(cw*0.45f, ch*0.25f);
|
||||
resetDlg.setPosition((sw-resetDlg.getWidth())/2, (sh-resetDlg.getHeight())/2);
|
||||
resetDlgText.setFontScale(labScale*0.9f);
|
||||
resetDlgOkBtn.getLabel().setFontScale(labScale*0.9f);
|
||||
resetDlgCancelBtn.getLabel().setFontScale(labScale*0.9f);
|
||||
|
||||
backDlg.setSize(cw*0.45f, ch*0.25f);
|
||||
backDlg.setPosition((sw-backDlg.getWidth())/2, (sh-backDlg.getHeight())/2);
|
||||
backDlgText.setFontScale(labScale*0.9f);
|
||||
backDlgOkBtn.getLabel().setFontScale(labScale*0.9f);
|
||||
backDlgCancelBtn.getLabel().setFontScale(labScale*0.9f);
|
||||
|
||||
instLab.setFontScale(labScale);
|
||||
backBtn.getLabel().setFontScale(labScale);
|
||||
helpBtn.getLabel().setFontScale(labScale);
|
||||
|
|
Loading…
Reference in New Issue