use of de.gg.game.input.BackInputProcessor in project ProjektGG by eskalon.
the class CreditsScreen method create.
@Override
protected void create() {
super.create();
String text = "PROJEKT GG\n" + "\n" + "This Game Was Produced by eskalon\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "ESKALON\n" + "\n" + "\n" + creditsText.getString() + "\n" + "\n" + "\n" + "\n" + "\nAnd a Special Thanks to You!";
creditsTextSplitted = text.replaceAll("\\[(.+)\\]\\(([^ ]+?)( \"(.+)\")?\\)", "$1").replaceAll("\\\\", "").replaceAll("- ", "").replace(" ", " ").split("\n");
boldFont = app.getUISkin().getFont("ui-element-21");
h2Font = app.getUISkin().getFont("ui-title-29");
h3Font = app.getUISkin().getFont("ui-title-24");
textFont = app.getUISkin().getFont("ui-text-20");
eskalonLogo = app.getAssetManager().get(EskalonCommonsAssets.LOGO_TEXTURE_PATH);
titleLogo = app.getAssetManager().get(AssetLoadingScreen.TITLE_PATH);
addInputProcessor(new BackInputProcessor() {
@Override
public void onBackAction() {
app.getScreenManager().pushScreen("main_menu", "longBlendingTransition");
}
});
}
use of de.gg.game.input.BackInputProcessor in project ProjektGG by eskalon.
the class ServerBrowserScreen method create.
@Override
protected void create() {
super.create();
setImage(backgroundTexture);
BackInputProcessor backInput = new BackInputProcessor() {
@Override
public void onBackAction() {
application.getScreenManager().pushScreen("main_menu", "blendingTransition");
}
};
addInputProcessor(backInput);
mainTable.addListener(new BackInputActorListener() {
@Override
public void onBackAction() {
backInput.onBackAction();
}
});
this.connectionCallback = new ISuccessCallback() {
@Override
public void onSuccess(Object param) {
}
@Override
public void onFailure(Object param) {
connectingDialog.setVisible(false);
application.setClient(null);
SimpleTextDialog.createAndShow(stage, skin, Lang.get("ui.generic.error"), (String) param);
}
};
ImageTextButton backButton = new ImageTextButton(Lang.get("ui.generic.back"), skin);
backButton.addListener(new ButtonClickListener(application.getSoundManager()) {
@Override
protected void onClick() {
application.getScreenManager().pushScreen("main_menu", "blendingTransition");
}
});
ImageTextButton createLobbyButton = new ImageTextButton(Lang.get("screen.server_browser.create_game"), skin);
createLobbyButton.addListener(new ButtonClickListener(application.getSoundManager()) {
@Override
protected void onClick() {
application.getScreenManager().pushScreen("lobby_creation", "shortBlendingTransition");
}
});
ImageTextButton directConnectButton = new ImageTextButton(Lang.get("screen.server_browser.connect_directly"), skin);
directConnectButton.addListener(new ButtonClickListener(application.getSoundManager()) {
@Override
protected void onClick() {
OffsettableTextField portInputField = new OffsettableTextField(String.valueOf(BaseGameServer.DEFAULT_PORT), skin, 5);
portInputField.setTextFieldFilter(new TextField.TextFieldFilter.DigitsOnlyFilter());
OffsettableTextField ipInputField = new OffsettableTextField("127.0.0.1", skin, 5);
BasicDialog dialog = new BasicDialog(Lang.get("screen.server_browser.connect_directly"), skin) {
@Override
public void result(Object obj) {
if ((Boolean) obj) {
// Connect to client
application.setClient(new GameClient(application.getEventBus()));
application.getClient().connect(connectionCallback, application.VERSION, ipInputField.getText(), Integer.valueOf(portInputField.getText()));
connectingDialog = SimpleTextDialog.createAndShow(stage, skin, Lang.get("ui.generic.connecting"), Lang.get("screen.server_browser.joining"), false, null);
}
}
};
dialog.text(Lang.get("screen.server_browser.ip")).button(Lang.get("ui.generic.back"), false).button(Lang.get("ui.generic.connect"), true).key(Keys.ENTER, true).key(Keys.ESCAPE, false);
dialog.getContentTable().add(ipInputField).width(170).row();
dialog.getContentTable().add(new Label(Lang.get("screen.server_browser.port"), skin, "dark_text"));
dialog.getContentTable().add(portInputField).width(150).left();
dialog.show(stage);
}
});
ImageButton refreshButton = new ImageButton(skin, "refresh");
refreshButton.addListener(new ButtonClickListener(application.getSoundManager()) {
@Override
protected void onClick() {
discoverServers();
}
});
Table titleTable = new Table();
titleTable.add(new Label(Lang.get("screen.server_browser.title"), skin, "title")).padTop(25);
Table serverHeaderTable = new Table();
serverHeaderTable.add(new Label(Lang.get("screen.server_browser.header_status"), skin)).left().padLeft(10).padRight(158);
serverHeaderTable.add(new Label(Lang.get("screen.server_browser.header_name"), skin)).left().expandX();
serverHeaderTable.add(refreshButton).padLeft(15).padRight(10).row();
serverTable = new Table();
ScrollPane pane = new ScrollPane(serverTable);
Table buttonTable = new Table();
buttonTable.add(backButton);
buttonTable.add(directConnectButton).width(158).padLeft(45);
buttonTable.add(createLobbyButton).width(136).padLeft(45);
Table mTable = new Table();
mTable.setWidth(615);
mTable.setHeight(475);
mTable.setBackground(skin.getDrawable("parchment2"));
mTable.add(titleTable).row();
mTable.add(serverHeaderTable).width(580).padTop(25).row();
mTable.add(new Image(skin.getDrawable("white_bar"))).padTop(2).center().expandX().row();
mTable.add(pane).width(580).height(265).padTop(10).row();
mTable.add(buttonTable).height(50).bottom();
mainTable.add(mTable);
}
use of de.gg.game.input.BackInputProcessor in project ProjektGG by eskalon.
the class LobbyCreationScreen method create.
@Override
protected void create() {
super.create();
setImage(backgroundTexture);
BackInputProcessor backInput = new BackInputProcessor() {
@Override
public void onBackAction() {
application.getScreenManager().pushScreen("server_browser", "shortBlendingTransition");
}
};
addInputProcessor(backInput);
mainTable.addListener(new BackInputActorListener() {
@Override
public void onBackAction() {
backInput.onBackAction();
}
});
this.playerStubs = playerStubsJson.getData(new TypeToken<ArrayList<PlayerStub>>() {
}.getType());
Label nameLabel = new Label(Lang.get("screen.lobby_creation.name"), skin);
Label portLabel = new Label(Lang.get("screen.lobby_creation.port"), skin);
nameField = new OffsettableTextField("", skin, 6);
portField = new OffsettableTextField(String.valueOf(BaseGameServer.DEFAULT_PORT), skin, 6);
portField.setTextFieldFilter(new TextField.TextFieldFilter.DigitsOnlyFilter());
Label difficultyLabel = new Label(Lang.get("screen.lobby_creation.difficulty"), skin);
CheckBox easyDifficultyCheckbox = new CheckBox(Lang.get(GameDifficulty.EASY), skin);
normalDifficultyCheckbox = new CheckBox(Lang.get(GameDifficulty.NORMAL), skin);
CheckBox hardDifficultyCheckbox = new CheckBox(Lang.get(GameDifficulty.HARD), skin);
ButtonGroup<CheckBox> speedGroup = new ButtonGroup<>();
speedGroup.add(easyDifficultyCheckbox);
speedGroup.add(normalDifficultyCheckbox);
speedGroup.add(hardDifficultyCheckbox);
ImageTextButton backButton = new ImageTextButton(Lang.get("ui.generic.back"), skin);
backButton.addListener(new ButtonClickListener(application.getSoundManager()) {
@Override
protected void onClick() {
application.getScreenManager().pushScreen("server_browser", "shortBlendingTransition");
}
});
ImageTextButton createButton = new ImageTextButton(Lang.get("screen.lobby_creation.create"), skin);
createButton.addListener(new ButtonClickListener(application.getSoundManager()) {
@Override
protected void onClick() {
if (!nameField.getText().isEmpty() && !portField.getText().isEmpty()) {
GameDifficulty difficulty = GameDifficulty.NORMAL;
if (speedGroup.getChecked().equals(easyDifficultyCheckbox)) {
difficulty = GameDifficulty.EASY;
} else if (speedGroup.getChecked().equals(normalDifficultyCheckbox)) {
difficulty = GameDifficulty.NORMAL;
} else if (speedGroup.getChecked().equals(hardDifficultyCheckbox)) {
difficulty = GameDifficulty.HARD;
}
// Start Sever & Client
ServerSetup serverSetup = new ServerSetup(nameField.getText(), 7, Integer.valueOf(portField.getText()), true, application.VERSION, true);
GameSessionSetup sessionSetup = new GameSessionSetup(difficulty, GameMap.BAMBERG, System.currentTimeMillis());
application.setServer(new GameServer(serverSetup, sessionSetup, null, playerStubs));
application.getServer().start(new ISuccessCallback() {
@Override
public void onSuccess(Object param) {
// Connect client to server
application.setClient(new GameClient(application.getEventBus()));
application.getClient().connect(new ISuccessCallback() {
public void onSuccess(Object param) {
// wait for
// LobbyDataReceivedEvent
}
public void onFailure(Object param) {
onHostStartingFailed(((Exception) param).getMessage());
}
}, application.VERSION, "localhost", serverSetup.getPort());
}
public void onFailure(Object param) {
onHostStartingFailed(((Exception) param).getMessage());
}
});
connectingDialog = SimpleTextDialog.createAndShow(stage, skin, Lang.get("screen.lobby_creation.starting_server.title"), Lang.get("screen.lobby_creation.starting_server.text"), false, null);
connectingDialog.show(stage);
} else {
SimpleTextDialog.createAndShow(stage, skin, Lang.get("screen.lobby_creation.fields_empty.title"), Lang.get("screen.lobby_creation.fields_empty.text"));
}
}
});
Table titleTable = new Table();
Table settingsTable = new Table();
Table settings2ColTable = new Table();
Table settings3ColTable = new Table();
Table buttonTable = new Table();
titleTable.add(new Label(Lang.get("screen.lobby_creation.title"), skin, "title")).padTop(25);
settings2ColTable.add(nameLabel).padLeft(100).padBottom(20).padRight(10).padTop(30);
settings2ColTable.add(nameField).row();
settings2ColTable.add(portLabel).padLeft(100).padRight(10);
settings2ColTable.add(portField).row();
settings3ColTable.add(difficultyLabel).colspan(3).padLeft(150).row();
settings3ColTable.add(easyDifficultyCheckbox).padLeft(150).padRight(12);
settings3ColTable.add(normalDifficultyCheckbox).padRight(12);
settings3ColTable.add(hardDifficultyCheckbox);
settingsTable.left().top().add(settings2ColTable).padBottom(27).row();
settingsTable.add(settings3ColTable).row();
buttonTable.add(backButton);
buttonTable.add(createButton).padLeft(65);
Table mTable = new Table();
mTable.setWidth(615);
mTable.setHeight(475);
mTable.setBackground(skin.getDrawable("parchment2"));
mTable.add(titleTable).row();
mTable.add(settingsTable).width(580).height(215).row();
mTable.add(buttonTable).height(50).bottom().padBottom(50);
mainTable.add(mTable);
}
use of de.gg.game.input.BackInputProcessor in project ProjektGG by eskalon.
the class GameTownHallInteriorScreen method create.
@Override
protected void create() {
super.create();
addInputProcessor(new BackInputProcessor() {
@Override
public void onBackAction() {
application.getScreenManager().pushScreen("map", "circle_crop");
}
});
// Buy citizenship
applyForCitizenshipButton = new ImageTextButton(Lang.get("screen.house.town_hall.apply_for_citizenship"), skin);
applyForCitizenshipButton.addListener(new ButtonClickListener(application.getSoundManager()) {
@Override
protected void onClick() {
// TODO inform server; after that disable the button;
// then set a flag in the player to disable it
// permanently (as there is no point in applying twice)
}
});
mainTable.add(applyForCitizenshipButton).padBottom(7).row();
// Apply for position
applyForPositionButton = new ImageTextButton(Lang.get("screen.house.town_hall.apply_for_position"), skin);
applyForPositionButton.addListener(new ButtonClickListener(application.getSoundManager()) {
@Override
protected void onClick() {
// TODO show dialog with all available positions
}
});
mainTable.add(applyForPositionButton);
}
use of de.gg.game.input.BackInputProcessor in project ProjektGG by eskalon.
the class SettingsScreen method create.
@Override
protected void create() {
super.create();
BackInputProcessor backInput = new BackInputProcessor() {
@Override
public void onBackAction() {
if (application.getScreenManager().getLastScreen() instanceof GameMapScreen)
application.getScreenManager().pushScreen("map", "blendingTransition");
else
application.getScreenManager().pushScreen("main_menu", "blendingTransition");
}
};
addInputProcessor(backInput);
mainTable.addListener(new BackInputActorListener() {
@Override
public void onBackAction() {
backInput.onBackAction();
}
});
EskalonSettings settings = application.getSettings();
// VOLUME
Label masterVolume = new Label(Lang.get("screen.settings.master_volume"), skin);
LeftClickSlider masterSlider = new LeftClickSlider(0, 1, 0.05F, false, skin);
masterSlider.setValue(settings.getMasterVolume());
masterSlider.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
settings.setMasterVolume(masterSlider.getValue());
application.getSoundManager().setMasterVolume(masterSlider.getValue());
}
});
Label effectVolume = new Label(Lang.get("screen.settings.effect_volume"), skin);
LeftClickSlider effectSlider = new LeftClickSlider(0, 1, 0.05F, false, skin);
effectSlider.setValue(settings.getEffectVolume());
effectSlider.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
settings.setEffectVolume(effectSlider.getValue());
application.getSoundManager().setEffectVolume(effectSlider.getValue());
}
});
Label musicVolume = new Label(Lang.get("screen.settings.music_volume"), skin);
LeftClickSlider musicSlider = new LeftClickSlider(0, 1, 0.05F, false, skin);
musicSlider.setValue(settings.getMusicVolume());
musicSlider.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
settings.setMusicVolume(musicSlider.getValue());
application.getSoundManager().setMusicVolume(musicSlider.getValue());
}
});
// KEYS
Label forwardLabel = new Label(Lang.get("screen.settings.forward_key"), skin);
KeySelectionInputField forwardButton = new KeySelectionInputField(settings, "cameraForward", skin, stage, application.getSoundManager());
Label leftLabel = new Label(Lang.get("screen.settings.left_key"), skin);
KeySelectionInputField leftButton = new KeySelectionInputField(settings, "cameraLeft", skin, stage, application.getSoundManager());
Label backwardLabel = new Label(Lang.get("screen.settings.backwards_key"), skin);
KeySelectionInputField backwardButton = new KeySelectionInputField(settings, "cameraBackward", skin, stage, application.getSoundManager());
Label rightLabel = new Label(Lang.get("screen.settings.right_key"), skin);
KeySelectionInputField rightButton = new KeySelectionInputField(settings, "cameraRight", skin, stage, application.getSoundManager());
Label speedUpLabel = new Label(Lang.get("screen.settings.speed_up_key"), skin);
KeySelectionInputField speedUpButton = new KeySelectionInputField(settings, "speedUpTime", skin, stage, application.getSoundManager());
Label speedDownLabel = new Label(Lang.get("screen.settings.speed_down_key"), skin);
KeySelectionInputField speedDownButton = new KeySelectionInputField(settings, "speedDownTime", skin, stage, application.getSoundManager());
ImageTextButton backButton = new ImageTextButton(Lang.get("ui.generic.done"), skin);
backButton.addListener(new ButtonClickListener(application.getSoundManager()) {
@Override
protected void onClick() {
if (application.getScreenManager().getLastScreen() instanceof GameMapScreen)
application.getScreenManager().pushScreen("map", "blendingTransition");
else
application.getScreenManager().pushScreen("main_menu", "blendingTransition");
}
});
Table settingsTable = new Table();
Table settings2ColTable = new Table();
settings2ColTable.padTop(20);
Table buttonTable = new Table();
settings2ColTable.add(forwardLabel).padBottom(22).left();
settings2ColTable.add(forwardButton).padBottom(22);
settings2ColTable.add(masterVolume).padBottom(28).padLeft(75).padRight(10);
settings2ColTable.add(masterSlider).padBottom(22).row();
settings2ColTable.add(leftLabel).padBottom(22).left();
settings2ColTable.add(leftButton).padBottom(22);
settings2ColTable.add(effectVolume).padBottom(28).padLeft(75).padRight(10);
settings2ColTable.add(effectSlider).padBottom(22).row();
settings2ColTable.add(backwardLabel).padBottom(22).left();
settings2ColTable.add(backwardButton).padBottom(22);
settings2ColTable.add(musicVolume).padBottom(28).padLeft(75).padRight(10);
settings2ColTable.add(musicSlider).padBottom(22).row();
settings2ColTable.add(rightLabel).padBottom(55).left();
settings2ColTable.add(rightButton).padBottom(55).row();
settings2ColTable.add(speedUpLabel).padBottom(22).padRight(13).left();
settings2ColTable.add(speedUpButton).padBottom(22).row();
settings2ColTable.add(speedDownLabel).padBottom(22).padRight(13).left();
settings2ColTable.add(speedDownButton).padBottom(22);
settingsTable.left().top().add(settings2ColTable).row();
buttonTable.add(backButton);
Table mTable = new Table();
mTable.setWidth(615);
mTable.setHeight(475);
mTable.setBackground(skin.getDrawable("parchment2"));
mTable.add(settingsTable).width(580).height(405).padRight(90).row();
mTable.add(buttonTable).height(50).bottom();
mainTable.add(mTable);
}
Aggregations