List of usage examples for com.badlogic.gdx.scenes.scene2d.ui Table add
public Cell add()
From source file:com.flaiker.reaktio.screens.MenuScreen.java
License:Open Source License
@Override public void show() { super.show(); if (demoGame == null) demoGame = new Game(GameSettings.newDemoGameSettings(), SCREEN_WIDTH, SCREEN_HEIGHT, camera); Table table = new Table(skin); table.setFillParent(true);/*from w ww.jav a 2 s . c o m*/ uiStage.addActor(table); table.add().padBottom(50).row(); Label titleLabel = new Label("Reaktio", skin, "digital7-92", Color.WHITE); //titleLabel.setFontScale(2); table.add(titleLabel).spaceBottom(5).align(1); table.row(); table.add("A reaction test game").align(1).spaceBottom(20); table.row(); // register the button "Start" TextButton startGameButton = new TextButton("START", skin); startGameButton.setColor(1, 1, 1, 0.9f); startGameButton.addListener(new DefaultActorListener() { @Override public void touchUp(InputEvent event, float x, float y, int pointer, int button) { super.touchUp(event, x, y, pointer, button); reaktio.setScreen(new ModeSelectionScreen(reaktio, demoGame, skin)); } }); table.add(startGameButton).expand().fill().pad(100, 100, 100, 100); table.row(); // register the button "Highscore" TextButton highscoreButton = new TextButton("HIGHSCORE", skin); highscoreButton.setColor(1, 1, 1, 0.9f); highscoreButton.addListener(new DefaultActorListener() { @Override public void touchUp(InputEvent event, float x, float y, int pointer, int button) { super.touchUp(event, x, y, pointer, button); //reaktio.setScreen(new HighscoreScreen(reaktio, demoGame, skin)); } }); table.add(highscoreButton).expand().fill().pad(0, 100, 100, 100); table.row(); // register the button "Options" TextButton optionsButton = new TextButton("OPTIONS", skin); optionsButton.setColor(1, 1, 1, 0.9f); optionsButton.addListener(new DefaultActorListener() { @Override public void touchUp(InputEvent event, float x, float y, int pointer, int button) { super.touchUp(event, x, y, pointer, button); reaktio.setScreen(new OptionsScreen(reaktio, demoGame, skin)); } }); table.add(optionsButton).expand().fill().pad(0, 100, 100, 100).row(); table.add(new Label("www.flaiker.com", skin)); Gdx.input.setInputProcessor(uiStage); }
From source file:com.flaiker.reaktio.screens.ModeSelectionScreen.java
License:Open Source License
@Override public void show() { super.show(); if (demoGame == null) demoGame = new Game(GameSettings.newDemoGameSettings(), SCREEN_WIDTH, SCREEN_HEIGHT, camera); Table table = new Table(skin); table.setFillParent(true);//from www . j a va 2 s.c om uiStage.addActor(table); table.add().padBottom(50).row(); Label titleLabel = new Label("Reaktio", skin, "digital7-92", Color.WHITE); //titleLabel.setFontScale(2); table.add(titleLabel).spaceBottom(5).align(1); table.row(); table.add("Select a Gamemode").align(1).spaceBottom(20); table.row(); // register the button "Timelimit" TextButton timelimitButton = new TextButton("Timelimit", skin); timelimitButton.setColor(1, 1, 1, 0.9f); timelimitButton.addListener(new DefaultActorListener() { @Override public void touchUp(InputEvent event, float x, float y, int pointer, int button) { super.touchUp(event, x, y, pointer, button); reaktio.setScreen(new GameScreen(reaktio, GameSettings.newTimeLimitGameSettings(30, 2, 2), skin)); } }); table.add(timelimitButton).expand().fill().pad(0, 100, 100, 100); table.row(); // register the button "Continuous" TextButton continuousButton = new TextButton("Continuous", skin); continuousButton.setColor(1, 1, 1, 0.9f); continuousButton.addListener(new DefaultActorListener() { @Override public void touchUp(InputEvent event, float x, float y, int pointer, int button) { super.touchUp(event, x, y, pointer, button); reaktio.setScreen(new GameScreen(reaktio, GameSettings.newContinuousGameSettings(2, 2), skin)); } }); table.add(continuousButton).expand().fill().pad(100, 100, 100, 100); table.row(); table.add(new Label("www.flaiker.com", skin)); Gdx.input.setInputProcessor(uiStage); }
From source file:com.forerunnergames.peril.client.ui.screens.loading.AbstractLoadingScreen.java
License:Open Source License
public AbstractLoadingScreen(final LoadingScreenWidgetFactory widgetFactory, final ScreenChanger screenChanger, final ScreenSize screenSize, final MouseInput mouseInput, final Batch batch, final MBassador<Event> eventBus, final AssetManager assetManager, final LoadingScreenStyle style) { super(widgetFactory, screenChanger, screenSize, mouseInput, batch, eventBus); Arguments.checkIsNotNull(widgetFactory, "widgetFactory"); Arguments.checkIsNotNull(assetManager, "assetManager"); Arguments.checkIsNotNull(style, "style"); this.assetManager = assetManager; this.style = style; progressBar = widgetFactory.createProgressBar(style); final Label loadingTitleTextLabel = widgetFactory.createLoadingTitleLabel(style); final int loadingTitleTextLabelWidth = style.getLoadingTitleTextLabelWidth(); final int loadingTitleTextLabelHeight = style.getLoadingTitleTextLabelHeight(); loadingStatusTextLabel = widgetFactory.createLoadingStatusLabel(style); final Stack rootStack = new Stack(); rootStack.setFillParent(true);// ww w . ja va 2 s. c o m rootStack.add(widgetFactory.createBackground()); // @formatter:off final Table foregroundTable = new Table().top(); foregroundTable.add().height(style.getLoadingTitleTextVerticalSpacer()); foregroundTable.row(); foregroundTable.add(loadingTitleTextLabel).size(loadingTitleTextLabelWidth, loadingTitleTextLabelHeight); foregroundTable.row().bottom(); foregroundTable.add(progressBar).size(style.getProgressBarWidth(), style.getProgressBarHeight()) .padBottom(style.getProgressBarStatusTextSpacer()); foregroundTable.row(); foregroundTable.add(loadingStatusTextLabel); // @formatter:on rootStack.add(foregroundTable); addRootActor(rootStack); quitDialog = createQuitDialog(style.getQuitDialogMessageText(), new QuitDialogListener()); errorDialog = createErrorDialog(new ErrorDialogListener()); }
From source file:com.forerunnergames.peril.client.ui.screens.menus.modes.classic.creategame.ClassicGameModeCreateGameMenuScreen.java
License:Open Source License
public ClassicGameModeCreateGameMenuScreen(final MenuScreenWidgetFactory widgetFactory, final ScreenChanger screenChanger, final ScreenSize screenSize, final MouseInput mouseInput, final Batch batch, final CountryCounter countryCounter, final MBassador<Event> eventBus) { super(widgetFactory, screenChanger, screenSize, mouseInput, batch, eventBus); Arguments.checkIsNotNull(widgetFactory, "widgetFactory"); Arguments.checkIsNotNull(countryCounter, "countryCounter"); this.widgetFactory = widgetFactory; this.countryCounter = countryCounter; errorDialog = createErrorDialog();//from w w w. j a v a2 s.c o m addTitle(TITLE_TEXT, Align.bottomLeft, 40); addSubTitle(SUBTITLE_TEXT); playerNameTextField = widgetFactory.createPlayerNameTextField(); clanAcronymTextField = widgetFactory.createClanAcronymTextField(); serverNameTextField = widgetFactory.createServerNameTextField(); clanAcronymCheckBox = widgetFactory.createClanAcronymCheckBox(new ChangeListener() { @Override public void changed(final ChangeEvent event, final Actor actor) { clanAcronymTextField.setText(clanAcronymCheckBox.isChecked() ? clanAcronymTextField.getText() : ""); clanAcronymTextField.setDisabled(!clanAcronymCheckBox.isChecked()); } }); clanAcronymCheckBox.setChecked(!clanAcronymTextField.getText().isEmpty()); clanAcronymTextField.setDisabled(!clanAcronymCheckBox.isChecked()); // @formatter:off humanPlayerLimitLabel = widgetFactory .createPlayerLimitLabel(String.valueOf(InputSettings.INITIAL_CLASSIC_MODE_HUMAN_PLAYER_LIMIT)); aiPlayerLimitLabel = widgetFactory .createPlayerLimitLabel(String.valueOf(InputSettings.INITIAL_CLASSIC_MODE_AI_PLAYER_LIMIT)); playMapNameLabel = widgetFactory.createPlayMapNameLabel(); totalCountryCount = calculateCurrentPlayMapTotalCountryCount(); // @formatter:on customizeHumanPlayersButton = widgetFactory .createCustomizePlayersButton(new ClickListener(Input.Buttons.LEFT) { @Override public void clicked(final InputEvent event, final float x, final float y) { // TODO Show Players Dialog. updateHumanPlayerLimit(); updateWinPercentSelectBoxItems(); } }); customizeAiPlayersButton = widgetFactory .createCustomizePlayersButton(new ClickListener(Input.Buttons.LEFT) { @Override public void clicked(final InputEvent event, final float x, final float y) { // TODO Show Players Dialog. updateAiPlayerLimit(); updateWinPercentSelectBoxItems(); } }); customizePlayMapButton = widgetFactory.createCustomizePlayMapButton(new ClickListener(Input.Buttons.LEFT) { @Override public void clicked(final InputEvent event, final float x, final float y) { // TODO Show Play Map Dialog. // TODO Add refresh button to Play Map Dialog to re-load play maps. playMaps = loadPlayMaps(); currentPlayMap = nextPlayMap(); playMapNameLabel.setText(currentPlayMap.getName()); totalCountryCount = calculateCurrentPlayMapTotalCountryCount(); updateWinPercentSelectBoxItems(); } }); // @formatter:off spectatorLimitSelectBox = widgetFactory.createSpectatorsSelectBox(); final Array<Integer> spectatorLimits = new Array<>( ClassicGameRules.MAX_SPECTATORS - ClassicGameRules.MIN_SPECTATORS + 1); for (int i = ClassicGameRules.MIN_SPECTATORS; i <= ClassicGameRules.MAX_SPECTATORS; ++i) { spectatorLimits.add(i); } spectatorLimitSelectBox.setItems(spectatorLimits); spectatorLimitSelectBox.setSelected(InputSettings.INITIAL_SPECTATOR_LIMIT); // @formatter:off // @formatter:on initialCountryAssignmentSelectBox = widgetFactory.createInitialCountryAssignmentSelectBox(); final Array<String> initialCountryAssignments = new Array<>(InitialCountryAssignment.count()); for (final InitialCountryAssignment initialCountryAssignment : InitialCountryAssignment.values()) { initialCountryAssignments.add(Strings.toProperCase(initialCountryAssignment.name())); } initialCountryAssignmentSelectBox.setItems(initialCountryAssignments); initialCountryAssignmentSelectBox .setSelected(Strings.toProperCase(InputSettings.INITIAL_CLASSIC_MODE_COUNTRY_ASSIGNMENT.name())); // @formatter:on winPercentSelectBox = widgetFactory.createWinPercentSelectBox(); updateWinPercentSelectBoxItems(); selectInitialWinPercentItem(); // @formatter:off playerSettingsSectionTitleLabel = widgetFactory.createPlayerSettingsSectionTitleLabel(); playerNameSettingLabel = widgetFactory.createPlayerNameSettingLabel(); clanTagSettingLabel = widgetFactory.createClanTagSettingLabel(); gameSettingsSectionTitleLabel = widgetFactory.createGameSettingsSectionTitleLabel(); serverNameSettingLabel = widgetFactory.createMenuSettingLabel(SERVER_NAME_SETTING_LABEL_TEXT); humanPlayerLimitSettingLabel = widgetFactory.createMenuSettingLabel(HUMAN_PLAYERS_SETTING_LABEL_TEXT); aiPlayerLimitSettingLabel = widgetFactory.createMenuSettingLabel(AI_PLAYERS_SETTING_LABEL_TEXT); spectatorLimitSettingLabel = widgetFactory.createMenuSettingLabel(SPECTATORS_SETTING_SETTING_LABEL_TEXT); playMapSettingLabel = widgetFactory.createMenuSettingLabel(PLAY_MAP_SETTING_LABEL_TEXT); winPercentSettingLabel = widgetFactory.createMenuSettingLabel(WIN_PERCENT_SETTING_LABEL_TEXT); initialCountryAssignmentSettingLabel = widgetFactory .createMenuSettingLabel(INITIAL_COUNTRY_ASSIGNMENT_SETTING_LABEL_TEXT); // @formatter:on final VerticalGroup verticalGroup = new VerticalGroup(); verticalGroup.align(Align.topLeft); final Table playerSettingsTable = new Table().top().left(); playerSettingsTable.add().height(23); playerSettingsTable.row(); playerSettingsTable.add(playerSettingsSectionTitleLabel).size(540, 40).fill().padLeft(60).left(); playerSettingsTable.row(); final Table playerNameTable = new Table(); playerNameTable.add(playerNameSettingLabel).size(150, 40).fill().padLeft(90).left().spaceRight(10); playerNameTable.add(playerNameTextField).size(270, 28).fill().left().spaceLeft(10); playerSettingsTable.add(playerNameTable).left(); playerSettingsTable.row(); final Table clanTable = new Table(); clanTable.add(clanTagSettingLabel).size(150, 40).fill().padLeft(90).left().spaceRight(10); clanTable.add(clanAcronymCheckBox).size(20, 20).fill().left().spaceLeft(10).spaceRight(8); clanTable.add(clanAcronymTextField).size(80, 28).fill().left().spaceLeft(8); playerSettingsTable.add(clanTable).left(); verticalGroup.addActor(playerSettingsTable); final Table gameSettingsTable = new Table().top().left(); gameSettingsTable.row(); gameSettingsTable.add().height(20); gameSettingsTable.row(); gameSettingsTable.add(gameSettingsSectionTitleLabel).size(540, 40).fill().padLeft(60).left(); gameSettingsTable.row(); final Table serverNameTable = new Table(); serverNameTable.add(serverNameSettingLabel).size(150, 40).fill().padLeft(90).left().spaceRight(10); serverNameTable.add(serverNameTextField).size(270, 28).fill().left().spaceLeft(10); gameSettingsTable.add(serverNameTable).left(); gameSettingsTable.row(); final Table playMapTable = new Table(); playMapTable.add(playMapSettingLabel).size(150, 40).fill().padLeft(90).left().spaceRight(10); playMapTable.add(playMapNameLabel).size(238, 28).fill().left().spaceLeft(10).spaceRight(4); playMapTable.add(customizePlayMapButton).size(28, 28).fill().left().spaceLeft(4); gameSettingsTable.add(playMapTable).left(); gameSettingsTable.row(); final Table humanPlayersTable = new Table(); humanPlayersTable.add(humanPlayerLimitSettingLabel).size(150, 40).fill().padLeft(90).left().spaceRight(10); humanPlayersTable.add(humanPlayerLimitLabel).size(76, 28).fill().left().spaceLeft(10).spaceRight(4); humanPlayersTable.add(customizeHumanPlayersButton).size(28, 28).fill().left().spaceLeft(4); gameSettingsTable.add(humanPlayersTable).left(); gameSettingsTable.row(); final Table aiPlayersTable = new Table(); aiPlayersTable.add(aiPlayerLimitSettingLabel).size(150, 40).fill().padLeft(90).left().spaceRight(10); aiPlayersTable.add(aiPlayerLimitLabel).size(76, 28).fill().left().spaceLeft(10).spaceRight(4); aiPlayersTable.add(customizeAiPlayersButton).size(28, 28).fill().left().spaceLeft(4); gameSettingsTable.add(aiPlayersTable).left(); gameSettingsTable.row(); final Table spectatorsTable = new Table(); spectatorsTable.add(spectatorLimitSettingLabel).size(150, 40).fill().padLeft(90).left().spaceRight(10); spectatorsTable.add(spectatorLimitSelectBox).size(108, 28).fill().left().spaceLeft(10); gameSettingsTable.add(spectatorsTable).left(); gameSettingsTable.row(); final Table winPercentTable = new Table(); winPercentTable.add(winPercentSettingLabel).size(150, 40).fill().padLeft(90).left().spaceRight(10); winPercentTable.add(winPercentSelectBox).size(108, 28).fill().left().spaceLeft(10); gameSettingsTable.add(winPercentTable).left(); gameSettingsTable.row(); // @formatter:off final Table initialCountryAssignmentTable = new Table(); initialCountryAssignmentTable.add(initialCountryAssignmentSettingLabel).size(150, 40).fill().padLeft(90) .left().spaceRight(10); initialCountryAssignmentTable.add(initialCountryAssignmentSelectBox).size(108, 28).fill().left() .spaceLeft(10); gameSettingsTable.add(initialCountryAssignmentTable).left(); // @formatter:on verticalGroup.addActor(gameSettingsTable); addContent(verticalGroup); addBackButton(new ClickListener(Input.Buttons.LEFT) { @Override public void clicked(final InputEvent event, final float x, final float y) { contractMenuBar(new Runnable() { @Override public void run() { toScreen(ScreenId.CLASSIC_GAME_MODE_MENU); } }); } }); forwardButton = addForwardButton(FORWARD_BUTTON_TEXT, new ChangeListener() { @Override public void changed(final ChangeEvent event, final Actor actor) { if (currentPlayMap.equals(PlayMapMetadata.NULL)) { errorDialog.setMessage(new DefaultMessage("Please select a valid map before continuing.")); errorDialog.show(); return; } final String playerName = playerNameTextField.getText(); if (!GameSettings.isValidPlayerNameWithoutClanTag(playerName)) { errorDialog.setMessage(new DefaultMessage( Strings.format("Invalid player name: \'{}\'\n\nValid player name rules:\n\n{}", playerName, GameSettings.VALID_PLAYER_NAME_DESCRIPTION))); errorDialog.show(); return; } final String clanAcronym = clanAcronymTextField.getText(); if (!clanAcronymTextField.isDisabled() && !GameSettings.isValidHumanClanAcronym(clanAcronym)) { errorDialog.setMessage(new DefaultMessage( Strings.format("Invalid clan tag: \'{}\'\n\nValid clan tag rules:\n\n{}", clanAcronym, GameSettings.VALID_CLAN_ACRONYM_DESCRIPTION))); errorDialog.show(); return; } final String playerNameWithOptionalClanTag = GameSettings .getHumanPlayerNameWithOptionalClanTag(playerName, clanAcronym); final int humanPlayerLimit = getHumanPlayerLimit(); final int aiPlayerLimit = getAiPlayerLimit(); final int spectatorLimit = getSpectatorLimit(); final int winPercent = winPercentSelectBox.getSelected(); final InitialCountryAssignment initialCountryAssignment = InitialCountryAssignment .valueOf(Strings.toCase(initialCountryAssignmentSelectBox.getSelected(), LetterCase.UPPER)); final PersonLimits personLimits = PersonLimits.builder().humanPlayers(humanPlayerLimit) .aiPlayers(aiPlayerLimit).spectators(spectatorLimit).build(); final GameRules gameRules = GameRulesFactory.create(GameMode.CLASSIC, personLimits, winPercent, totalCountryCount, initialCountryAssignment); final GameConfiguration gameConfig = new DefaultGameConfiguration(GameMode.CLASSIC, currentPlayMap, gameRules); final String serverName = serverNameTextField.getText(); if (!NetworkSettings.isValidServerName(serverName)) { errorDialog.setMessage(new DefaultMessage( Strings.format("Invalid server name: \'{}\'\n\nValid server name rules:\n\n{}", serverName, NetworkSettings.VALID_SERVER_NAME_DESCRIPTION))); errorDialog.show(); return; } toScreen(ScreenId.MENU_TO_PLAY_LOADING); // The menu-to-play loading screen is now active & can therefore receive events. publishAsync(new CreateGameEvent(serverName, gameConfig, playerNameWithOptionalClanTag)); } }); }
From source file:com.forerunnergames.peril.client.ui.screens.menus.modes.classic.joingame.ClassicGameModeJoinGameMenuScreen.java
License:Open Source License
public ClassicGameModeJoinGameMenuScreen(final MenuScreenWidgetFactory widgetFactory, final ScreenChanger screenChanger, final ScreenSize screenSize, final MouseInput mouseInput, final Batch batch, final MBassador<Event> eventBus) { super(widgetFactory, screenChanger, screenSize, mouseInput, batch, eventBus); Arguments.checkIsNotNull(widgetFactory, "widgetFactory"); this.widgetFactory = widgetFactory; errorDialog = createErrorDialog();//from w w w .j a va 2 s . c o m addTitle("JOIN GAME", Align.bottomLeft, 40); addSubTitle("CLASSIC MODE"); playerNameTextField = widgetFactory.createPlayerNameTextField(); clanAcronymTextField = widgetFactory.createClanAcronymTextField(); serverAddressTextField = widgetFactory.createServerAddressTextField(); clanAcronymCheckBox = widgetFactory.createClanAcronymCheckBox(new ChangeListener() { @Override public void changed(final ChangeEvent event, final Actor actor) { clanAcronymTextField.setText(clanAcronymCheckBox.isChecked() ? clanAcronymTextField.getText() : ""); clanAcronymTextField.setDisabled(!clanAcronymCheckBox.isChecked()); } }); clanAcronymCheckBox.setChecked(!clanAcronymTextField.getText().isEmpty()); clanAcronymTextField.setDisabled(!clanAcronymCheckBox.isChecked()); playerSettingsSectionTitleLabel = widgetFactory.createPlayerSettingsSectionTitleLabel(); playerNameSettingLabel = widgetFactory.createPlayerNameSettingLabel(); clanTagSettingLabel = widgetFactory.createClanTagSettingLabel(); gameSettingsSectionTitleLabel = widgetFactory.createGameSettingsSectionTitleLabel(); serverAddressSettingLabel = widgetFactory.createMenuSettingLabel("Server Address"); final VerticalGroup verticalGroup = new VerticalGroup(); verticalGroup.align(Align.topLeft); // @formatter:off final Table playerSettingsTable = new Table().top().left(); playerSettingsTable.add().height(23).colspan(5); playerSettingsTable.row(); playerSettingsTable.add(playerSettingsSectionTitleLabel).size(538, 42).fill().padLeft(60).padRight(60) .left().colspan(5); playerSettingsTable.row(); playerSettingsTable.add(playerNameSettingLabel).size(150, 40).fill().padLeft(90).left().spaceRight(10); playerSettingsTable.add(playerNameTextField).size(204, 28).fill().left().colspan(3).spaceLeft(10); playerSettingsTable.add().expandX().fill(); playerSettingsTable.row(); playerSettingsTable.add(clanTagSettingLabel).size(150, 40).fill().padLeft(90).left().spaceRight(10); playerSettingsTable.add(clanAcronymCheckBox).size(18, 18).fill().left().spaceLeft(10).spaceRight(10); playerSettingsTable.add(clanAcronymTextField).size(74, 28).fill().left().spaceLeft(10); playerSettingsTable.add().width(102).fill(); playerSettingsTable.add().expandX().fill(); verticalGroup.addActor(playerSettingsTable); // @formatter:on // @formatter:off final Table gameSettingsTable = new Table().top().left(); gameSettingsTable.row(); gameSettingsTable.add().height(18).colspan(3); gameSettingsTable.row(); gameSettingsTable.add(gameSettingsSectionTitleLabel).size(538, 42).fill().padLeft(60).padRight(60).left() .colspan(3); gameSettingsTable.row(); gameSettingsTable.add(serverAddressSettingLabel).size(150, 40).fill().padLeft(90).left().spaceRight(10); gameSettingsTable.add(serverAddressTextField).size(204, 28).fill().left().spaceLeft(10); gameSettingsTable.add().expandX().fill(); verticalGroup.addActor(gameSettingsTable); // @formatter:on addContent(verticalGroup); addBackButton(new ClickListener(Input.Buttons.LEFT) { @Override public void clicked(final InputEvent event, final float x, final float y) { contractMenuBar(new Runnable() { @Override public void run() { toScreen(ScreenId.CLASSIC_GAME_MODE_MENU); } }); } }); forwardButton = addForwardButton("JOIN GAME", new ChangeListener() { @Override public void changed(final ChangeEvent event, final Actor actor) { final String playerName = playerNameTextField.getText(); if (!GameSettings.isValidPlayerNameWithoutClanTag(playerName)) { errorDialog.setMessage(new DefaultMessage( Strings.format("Invalid player name: \'{}\'\n\nValid player name rules:\n\n{}", playerName, GameSettings.VALID_PLAYER_NAME_DESCRIPTION))); errorDialog.show(); return; } final String clanAcronym = clanAcronymTextField.getText(); if (!clanAcronymTextField.isDisabled() && !GameSettings.isValidHumanClanAcronym(clanAcronym)) { errorDialog.setMessage(new DefaultMessage( Strings.format("Invalid clan tag: \'{}\'\n\nValid clan tag rules:\n\n{}", clanAcronym, GameSettings.VALID_CLAN_ACRONYM_DESCRIPTION))); errorDialog.show(); return; } final String playerNameWithOptionalClanTag = GameSettings .getHumanPlayerNameWithOptionalClanTag(playerName, clanAcronym); final String serverAddress = serverAddressTextField.getText(); if (!NetworkSettings.isValidServerAddress(serverAddress)) { errorDialog.setMessage(new DefaultMessage( Strings.format("Invalid server address: \'{}\'\n\nValid server address rules:\n\n{}", serverAddress, NetworkSettings.VALID_SERVER_ADDRESS_DESCRIPTION))); errorDialog.show(); return; } toScreen(ScreenId.MENU_TO_PLAY_LOADING); // The menu-to-play loading screen is now active & can therefore receive events. publishAsync(new JoinGameEvent(playerNameWithOptionalClanTag, serverAddress)); } }); }
From source file:it.alcacoop.backgammon.layers.GeneralStatsScreen.java
License:Open Source License
public void initTable() { StatManager mgr = StatManager.getInstance(); table.clear();/*from ww w . j a va 2 s . co m*/ table.setWidth(stage.getWidth() * 0.9f); table.setHeight(stage.getHeight() * 0.9f); table.setX((stage.getWidth() - table.getWidth()) / 2); table.setY((stage.getHeight() - table.getHeight()) / 2); table.add(new Label("WON GAMES STATISTICS", GnuBackgammon.skin)).colspan(6); table.row(); table.add().fill().expand().colspan(6); Table data_table = new Table(); data_table.add(); data_table.add(new Label("YOU", GnuBackgammon.skin)).expand(); data_table.add(new Label("CPU", GnuBackgammon.skin)).expand(); for (int i = 0; i < levels.length; i++) { data_table.row(); data_table.add(new Label(levels[i], GnuBackgammon.skin)).right(); data_table.add(new Label("" + mgr.getGameStat(i, 0), GnuBackgammon.skin)); data_table.add(new Label("" + mgr.getGameStat(i, 1), GnuBackgammon.skin)); } data_table.row(); data_table.add().expand().fill().colspan(3); data_table.row(); data_table.add(new Label("TOTALS", GnuBackgammon.skin)).right(); data_table.add(new Label("" + mgr.getGameStat(8, 0), GnuBackgammon.skin)); data_table.add(new Label("" + mgr.getGameStat(8, 1), GnuBackgammon.skin)); // DIRTY LAYOUT HACK Table wrapper = new Table(); wrapper.setBackground(GnuBackgammon.skin.getDrawable("list")); wrapper.add().expand().fill(); wrapper.add(data_table).expand().fill(); wrapper.add().expand().fill(); wrapper.addActor(resetBtn); resetBtn.setPosition(table.getWidth() - 1.8f * resetBtn.getWidth(), resetBtn.getHeight() / 2); table.row(); table.add(wrapper).colspan(6).expand().fill(); table.row(); table.add().fill().expand().colspan(6); table.row(); table.add(backBtn).colspan(3).width(stage.getWidth() / 4).fill().expand().height(stage.getHeight() / 8); table.add(diceStatsBtn).colspan(3).width(stage.getWidth() / 4).fill().expand() .height(stage.getHeight() / 8); }
From source file:it.alcacoop.backgammon.ui.UIDialog.java
License:Open Source License
public static void getEndGameDialog(BaseFSM.Events evt, String text, String text1, String score1, String score2) {// w ww . j a va2 s . c o m Stage stage = GnuBackgammon.Instance.currentScreen.getStage(); instance.visible = true; instance.quitWindow = false; instance.optionsWindow = false; instance.leaveWindow = false; instance.dicesWindow = false; instance.evt = evt; instance.remove(); float height = stage.getHeight() * 0.6f; float width = stage.getWidth() * 0.6f; instance.clear(); instance.setWidth(width); instance.setHeight(height); instance.setX((stage.getWidth() - width) / 2); instance.setY((stage.getHeight() - height) / 2); instance.row().padTop(width / 25); instance.add().expand(); instance.add(text1).colspan(2).expand().align(Align.center); instance.add().expand(); instance.row(); instance.add().expand(); instance.add("Overall Score " + text).colspan(2).expand().align(Align.center); instance.add().expand(); instance.row(); instance.add().expand(); instance.add(score1).expand().align(Align.center); instance.add(score2).expand().align(Align.center); instance.add().expand(); Table t1 = new Table(); t1.row().expand().fill(); t1.add(); t1.add(instance.bContinue).colspan(2).fill().expand().height(height * 0.15f).width(width / 3); if ((MatchState.anScore[0] >= MatchState.nMatchTo || MatchState.anScore[1] >= MatchState.nMatchTo) && (MatchState.matchType == 0)) { t1.add(); t1.add(instance.bExport).colspan(2).fill().expand().height(height * 0.15f).width(width / 3); } t1.add(); instance.row(); instance.add(t1).colspan(4).fill().padBottom(width / 25); stage.addActor(instance); instance.setY(stage.getHeight()); instance.addAction(MyActions.sequence(Actions.parallel(Actions.color(new Color(1, 1, 1, alpha), 0.2f), Actions.moveTo((stage.getWidth() - width) / 2, (stage.getHeight() - height) / 2, 0.2f)))); }
From source file:it.alcacoop.backgammon.ui.UIDialog.java
License:Open Source License
public static void getDicesDialog(Boolean cb) { Stage stage = GnuBackgammon.Instance.currentScreen.getStage(); instance.visible = true;//from ww w. jav a 2 s. c om instance.evt = Events.NOOP; instance.quitWindow = false; instance.leaveWindow = false; instance.optionsWindow = false; instance.dicesWindow = true; instance.remove(); float height = stage.getHeight() * 0.94f; float width = stage.getWidth() * 0.92f; instance.setWidth(width); instance.setHeight(height); instance.setX((stage.getWidth() - width) / 2); instance.setY((stage.getHeight() - height) / 2); instance.clear(); Table t = new Table(); instance.add(t).fill().expand(); float cellWidth = width / 7.2f; float cellHeight = height / 7.5f; for (int i = 1; i < 7; i++) { t.row().space(cellHeight * 0.125f); for (int j = 1; j < 7; j++) { if ((i == 2) && (j == 5)) { t.add().width(cellWidth).height(cellHeight).fill(); t.add().width(cellWidth).height(cellHeight).fill(); t.add(instance.randomDicesButton).width(cellWidth * 2).colspan(2).right().fill() .height(cellHeight); } if (j <= i) { t.add(instance.diceButtonMap.get(i + "x" + j)).width(cellWidth).height(cellHeight).fill(); } } if (i == 1) { instance.diceLabel .setText("Choose " + GnuBackgammon.Instance.gameScreen.getCurrentPinfo() + " dices"); t.add(instance.diceLabel).right().top().colspan(5); } } stage.addActor(instance); instance.addAction(MyActions.sequence(Actions.run(new Runnable() { @Override public void run() { // MANUAL DICES OPEN GnuBackgammon.Instance.nativeFunctions.showAds(false); } }), Actions.alpha(alpha, 0.3f))); }
From source file:it.alcacoop.fourinaline.actors.UIDialog.java
License:Open Source License
public static void getEndGameDialog(FSM.Events evt, String text, String text1, String score1, String score2) { Stage stage = FourInALine.Instance.currentScreen.getStage(); instance.visible = true;/* www. j a v a 2s . c o m*/ instance.quitWindow = false; instance.leaveWindow = false; instance.evt = evt; instance.remove(); float height = stage.getHeight() * 0.6f; float width = stage.getWidth() * 0.6f; instance.clear(); instance.setWidth(width); instance.setHeight(height); instance.setX((stage.getWidth() - width) / 2); instance.setY((stage.getHeight() - height) / 2); instance.row().padTop(width / 25); instance.add().expand(); instance.add(text1).colspan(2).expand().align(Align.center); instance.add().expand(); instance.row(); instance.add().expand(); instance.add("Overall Score " + text).colspan(2).expand().align(Align.center); instance.add().expand(); instance.row(); instance.add().expand(); instance.add(score1).expand().align(Align.center); instance.add(score2).expand().align(Align.center); instance.add().expand(); Table t1 = new Table(); t1.row().expand().fill(); t1.add(); t1.add(instance.bContinue).colspan(2).fill().expand().height(height * 0.15f).width(width / 3); if ((MatchState.anScore[0] >= MatchState.nMatchTo || MatchState.anScore[1] >= MatchState.nMatchTo) && (MatchState.matchType == 0)) { t1.add(); t1.add(instance.bExport).colspan(2).fill().expand().height(height * 0.15f).width(width / 3); } t1.add(); instance.row(); instance.add(t1).colspan(4).fill().padBottom(width / 25); stage.addActor(instance); instance.setY(stage.getHeight()); instance.addAction(Actions.sequence(Actions.parallel(Actions.color(new Color(1, 1, 1, alpha), 0.2f), Actions.moveTo((stage.getWidth() - width) / 2, (stage.getHeight() - height) / 2, 0.2f)))); }
From source file:it.alcacoop.fourinaline.layers.MatchOptionsScreen.java
License:Open Source License
public void initTable() { table.clear();/*from ww w.j av a 2 s . c o m*/ table.setHeight(stage.getHeight() * 0.9f); table.setWidth(stage.getWidth() * 0.85f); table.setPosition(-stage.getWidth(), (stage.getHeight() - table.getHeight()) / 2); float height = table.getHeight() / 7; float width = table.getWidth() / 5; float pad = width / 45; table.add(titleLabel).colspan(5); table.row().pad(pad); table.add().width(width).expand().fill(); table.add().expand().fill().colspan(4); if (MatchState.matchType == 0) { table.row().pad(pad); table.add(difficultyLabel).right(); table.add(levelButtons[0]).height(height).width(width).fill().expandX(); table.add(levelButtons[1]).height(height).width(width).fill().expandX(); table.add(levelButtons[2]).height(height).width(width).fill().expandX(); table.add(levelButtons[3]).height(height).width(width).fill().expandX(); table.row().pad(pad).padTop(0); table.add(); table.add(levelButtons[4]).height(height).width(width).fill().expandX(); table.add().colspan(3); table.row().pad(pad); table.add().expand().fill().colspan(5); } table.row().pad(pad); table.add(playToLabel).right(); table.add(matchToButtons[0]).expandX().fill().width(width).height(height); table.add(matchToButtons[1]).expandX().fill().width(width).height(height); table.add(matchToButtons[2]).expandX().fill().width(width).height(height); table.add(matchToButtons[3]).expandX().fill().width(width).height(height); table.row().pad(pad); table.add(gameTypeLabel).right(); table.add(gameTypeButtons[0]).expandX().fill().colspan(2).height(height).width(2 * width + 2 * pad); table.add(gameTypeButtons[1]).expandX().fill().colspan(2).height(height).width(2 * width + 2 * pad); table.row().pad(pad); table.add().expand().fill().colspan(5); table.row().pad(pad); Table tbl = new Table(); tbl.add().width(width / 3); tbl.add(back).width(width * 3 / 2).fill().expand(); tbl.add().width(width / 3); tbl.add(play).width(width * 3 / 2).fill().expand(); tbl.add().width(width / 3); table.add(tbl).fill().expand().height(height).colspan(5); }