use of com.badlogic.gdx.scenes.scene2d.ui.ImageTextButton in project ProjektGG by eskalon.
the class GameRoundendScreen method create.
@Override
protected void create() {
super.create();
setImage(backgroundTexture);
lastYearTitle = new Label("", skin, "ink_title");
lastYearTitle.setAlignment(Align.topLeft);
comingYearTitle = new Label("", skin, "ink_title");
comingYearTitle.setAlignment(Align.topLeft);
lastYearData = new Label("", skin, "ink_text");
lastYearData.setAlignment(Align.topLeft);
lastYearData.setWrap(true);
comingYearData = new Label("", skin, "ink_text");
comingYearData.setAlignment(Align.topLeft);
comingYearData.setWrap(true);
nextButton = new ImageTextButton("", skin, "medium");
nextButton.addListener(new InputListener() {
@Override
public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
application.getSoundManager().playSoundEffect("page_flip");
nextButton.setText(Lang.get("ui.generic.waiting"));
Log.debug("Client", "Client ist ready for next round");
application.getClient().getActionHandler().readyUp();
return true;
}
});
Table dataTable = new Table();
// ScrollPane pane = new ScrollPane(dataTable);
dataTable.add(lastYearTitle).top().left().width(310).padLeft(20).padRight(0);
dataTable.add(comingYearTitle).padLeft(100).width(295).padBottom(10).row();
dataTable.add(lastYearData).padRight(20).width(310).height(395);
dataTable.add(comingYearData).padLeft(55).width(295).height(395);
Table buttonTable = new Table();
buttonTable.add(nextButton).width(200).padLeft(405);
Table mTable = new Table();
mTable.setBackground(skin.getDrawable("book"));
mTable.add(dataTable).top().left().width(660).height(425).row();
mTable.add(buttonTable).height(50).bottom();
mainTable.add(mTable);
}
use of com.badlogic.gdx.scenes.scene2d.ui.ImageTextButton 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 com.badlogic.gdx.scenes.scene2d.ui.ImageTextButton in project ProjektGG by eskalon.
the class MainMenuScreen method create.
@Override
protected void create() {
super.create();
setImage(backgroundImage);
ImageTextButton multiplayerButton = new ImageTextButton(Lang.get("screen.main_menu.multiplayer"), skin, "large");
multiplayerButton.addListener(new FadeOutUIClickListener(application.getSoundManager(), stage, "server_browser", "blendingTransition"));
ImageTextButton settingsButton = new ImageTextButton(Lang.get("screen.main_menu.settings"), skin, "large");
settingsButton.addListener(new FadeOutUIClickListener(application.getSoundManager(), stage, "settings", "blendingTransition"));
ImageTextButton creditsButton = new ImageTextButton(Lang.get("screen.main_menu.credits"), skin, "large");
creditsButton.addListener(new FadeOutUIClickListener(application.getSoundManager(), stage, "credits", "longBlendingTransition"));
ImageTextButton exitButton = new ImageTextButton(Lang.get("screen.main_menu.quit"), skin, "large");
exitButton.addListener(new ButtonClickListener(application.getSoundManager()) {
@Override
protected void onClick() {
Gdx.app.exit();
}
});
Image logoImage = new Image(skin.getDrawable("logo"));
ImageButton githubRepoButton = new ImageButton(skin.getDrawable("icon_github"));
githubRepoButton.addListener(new InputListener() {
@Override
public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
Gdx.net.openURI("https://github.com/eskalon/ProjektGG");
return true;
}
});
mainTable.add(logoImage).padBottom(25f).padTop(-80f).row();
mainTable.add(multiplayerButton).padBottom(11f).row();
mainTable.add(settingsButton).padBottom(11f).row();
mainTable.add(creditsButton).padBottom(11f).row();
mainTable.add(exitButton).row();
githubRepoButton.padLeft(3).padBottom(3).bottom().left();
stage.addActor(githubRepoButton);
stageInputWrapper.setEnabled(false);
}
use of com.badlogic.gdx.scenes.scene2d.ui.ImageTextButton in project libgdx by libgdx.
the class Scene2dTest method create.
public void create() {
stage = new Stage();
Gdx.input.setInputProcessor(stage);
final TextureRegion region = new TextureRegion(new Texture("data/badlogic.jpg"));
final Actor actor = new Actor() {
public void draw(Batch batch, float parentAlpha) {
Color color = getColor();
batch.setColor(color.r, color.g, color.b, parentAlpha);
batch.draw(region, getX(), getY(), getOriginX(), getOriginY(), getWidth(), getHeight(), getScaleX(), getScaleY(), getRotation());
}
};
actor.setBounds(15, 15, 100, 100);
actor.setOrigin(50, 50);
stage.addActor(actor);
actor.addListener(new InputListener() {
public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
System.out.println("down");
return true;
}
public void touchUp(InputEvent event, float x, float y, int pointer, int button) {
System.out.println("up " + event.getTarget());
}
});
Skin skin = new Skin(Gdx.files.internal("data/uiskin.json"));
VerticalGroup g = new VerticalGroup().space(5).reverse().pad(5).fill();
for (int i = 0; i < 10; i++) g.addActor(new TextButton("button " + i, skin));
g.addActor(new TextButton("longer button", skin));
Table table = new Table().debug();
table.add(g);
table.pack();
table.setPosition(5, 100);
stage.addActor(table);
HorizontalGroup h = new HorizontalGroup().space(5).reverse().pad(5).fill();
for (int i = 0; i < 5; i++) h.addActor(new TextButton("button " + i, skin));
h.addActor(new TextButton("some taller\nbutton", skin));
table = new Table().debug();
table.add(h);
table.pack();
table.setPosition(130, 100);
stage.addActor(table);
table.toFront();
final TextButton button = new TextButton("Fancy Background", skin);
// button.addListener(new ClickListener() {
// public void clicked (InputEvent event, float x, float y) {
// System.out.println("click! " + x + " " + y);
// }
// });
button.addListener(new ActorGestureListener() {
public boolean longPress(Actor actor, float x, float y) {
System.out.println("long press " + x + ", " + y);
return true;
}
public void fling(InputEvent event, float velocityX, float velocityY, int button) {
System.out.println("fling " + velocityX + ", " + velocityY);
}
public void zoom(InputEvent event, float initialDistance, float distance) {
System.out.println("zoom " + initialDistance + ", " + distance);
}
public void pan(InputEvent event, float x, float y, float deltaX, float deltaY) {
event.getListenerActor().moveBy(deltaX, deltaY);
if (deltaX < 0)
System.out.println("panning " + deltaX + ", " + deltaY + " " + event.getTarget());
}
});
// button.addListener(new ChangeListener() {
// public void changed (ChangeEvent event, Actor actor) {
// // event.cancel();
// }
// });
button.setPosition(50, 50);
stage.addActor(button);
// List select = new List(skin);
// select.setBounds(200, 200, 100, 100);
// select.setItems(new Object[] {1, 2, 3, 4, 5});
// stage.addActor(select);
// stage.addListener(new ChangeListener() {
// public void changed (ChangeEvent event, Actor actor) {
// System.out.println(actor);
// }
// });
meow.setDuration(2);
actor.addAction(forever(sequence(moveBy(50, 0, 2), moveBy(-50, 0, 2), run(new Runnable() {
public void run() {
actor.setZIndex(0);
}
}))));
// actor.addAction(parallel(rotateBy(90, 2), rotateBy(90, 2)));
// actor.addAction(parallel(moveTo(250, 250, 2, elasticOut), color(RED, 6), delay(0.5f), rotateTo(180, 5, swing)));
// actor.addAction(forever(sequence(scaleTo(2, 2, 0.5f), scaleTo(1, 1, 0.5f), delay(0.5f))));
patch = new TiledDrawable(skin.getRegion("default-round"));
Window window = new Window("Moo", skin);
Label lbl = new Label("ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJ", skin);
lbl.setWrap(true);
window.row();
window.add(lbl).width(400);
window.pack();
window.pack();
stage.addActor(window);
ImageTextButtonStyle style = new ImageTextButtonStyle(skin.get("default", TextButtonStyle.class));
style.imageUp = skin.getDrawable("default-round");
ImageTextButton buttonLeft = new ImageTextButton("HI IM LEFT", style);
ImageTextButton buttonRight = new ImageTextButton("HI IM RIGHT", style) {
{
clearChildren();
add(getLabel());
add(getImage());
}
};
CheckBox checkBoxLeft = new CheckBox("HI IM LEFT", skin, "default");
CheckBox checkBoxRight = new CheckBox("HI IM RIGHT", skin, "default") {
{
clearChildren();
add(getLabel());
add(getImage());
}
};
buttonLeft.setPosition(300, 400);
buttonRight.setPosition(300, 370);
checkBoxLeft.setPosition(150, 400);
checkBoxRight.setPosition(150, 370);
stage.addActor(buttonLeft);
stage.addActor(buttonRight);
stage.addActor(checkBoxLeft);
stage.addActor(checkBoxRight);
buttonLeft.debug();
buttonRight.debug();
checkBoxLeft.debug();
checkBoxRight.debug();
}
use of com.badlogic.gdx.scenes.scene2d.ui.ImageTextButton in project skin-composer by raeleus.
the class DialogSettings method populate.
public void populate() {
Table t = getContentTable();
getButtonTable().padBottom(15.0f);
Label label = new Label("Settings", main.getSkin(), "title");
t.add(label).colspan(2);
t.row();
TextButton textButton = new TextButton("Open temp/log directory", main.getSkin());
textButton.addListener(new ChangeListener() {
@Override
public void changed(ChangeListener.ChangeEvent event, Actor actor) {
try {
Utils.openFileExplorer(Gdx.files.local("temp/"));
} catch (Exception e) {
Gdx.app.error(getClass().getName(), "Error opening temp folder", e);
main.getDialogFactory().showDialogError("Folder Error...", "Error opening temp folder.\n\nOpen log?");
}
}
});
textButton.addListener(main.getHandListener());
t.add(textButton).colspan(2).padTop(15.0f);
t.row();
textButton = new TextButton("Open preferences directory", main.getSkin());
textButton.addListener(new ChangeListener() {
@Override
public void changed(ChangeListener.ChangeEvent event, Actor actor) {
try {
Utils.openFileExplorer(Gdx.files.external(".prefs/"));
} catch (Exception e) {
Gdx.app.error(getClass().getName(), "Error opening preferences folder", e);
main.getDialogFactory().showDialogError("Folder Error...", "Error opening preferences folder.\n\nOpen log?");
}
}
});
textButton.addListener(main.getHandListener());
t.add(textButton).colspan(2);
if (main.getProjectData().areChangesSaved() && main.getProjectData().getSaveFile().exists()) {
t.row();
textButton = new TextButton("Open project/import directory", main.getSkin());
textButton.addListener(new ChangeListener() {
@Override
public void changed(ChangeListener.ChangeEvent event, Actor actor) {
try {
Utils.openFileExplorer(main.getProjectData().getSaveFile().sibling(main.getProjectData().getSaveFile().nameWithoutExtension() + "_data"));
} catch (Exception e) {
Gdx.app.error(getClass().getName(), "Error opening project folder", e);
main.getDialogFactory().showDialogError("Folder Error...", "Error opening project folder\n\nOpen log?");
}
}
});
textButton.addListener(main.getHandListener());
t.add(textButton).colspan(2);
}
t.row();
textButton = new TextButton("Open texture packer settings file", main.getSkin());
textButton.addListener(new ChangeListener() {
@Override
public void changed(ChangeListener.ChangeEvent event, Actor actor) {
try {
Utils.openFileExplorer(Gdx.files.local("texturepacker/defaults.json"));
} catch (Exception e) {
Gdx.app.error(getClass().getName(), "Error opening defaults.json", e);
main.getDialogFactory().showDialogError("File Error...", "Error opening defaults.json\n\nOpen log?");
}
}
});
textButton.addListener(main.getHandListener());
t.add(textButton).colspan(2);
t.row();
label = new Label("Max Number of Undos: ", main.getSkin());
t.add(label).right().padTop(10.0f);
Spinner spinner3 = new Spinner(main.getProjectData().getMaxUndos(), 1.0, true, Orientation.HORIZONTAL, getSkin());
spinner3.setMinimum(1.0);
spinner3.setMaximum(100.0);
spinner3.addListener(new ChangeListener() {
@Override
public void changed(ChangeListener.ChangeEvent event, Actor actor) {
maxUndos = (int) spinner3.getValue();
}
});
spinner3.addListener(new FocusListener() {
@Override
public void keyboardFocusChanged(FocusListener.FocusEvent event, Actor actor, boolean focused) {
maxUndos = (int) spinner3.getValue();
}
});
spinner3.getTextField().addListener(main.getIbeamListener());
spinner3.getButtonMinus().addListener(main.getHandListener());
spinner3.getButtonPlus().addListener(main.getHandListener());
t.add(spinner3).minWidth(150.0f).left().padTop(10.0f);
t.row();
final ImageTextButton checkBox = new ImageTextButton("Keep resources relative?", getSkin(), "checkbox");
checkBox.setChecked(resourcesRelative);
checkBox.addListener(new ChangeListener() {
@Override
public void changed(ChangeListener.ChangeEvent event, Actor actor) {
resourcesRelative = checkBox.isChecked();
}
});
t.add(checkBox).padTop(10.0f).colspan(2);
t.row();
final ImageTextButton welcomeCheckBox = new ImageTextButton("Show welcome screen?", getSkin(), "checkbox");
welcomeCheckBox.setChecked(allowingWelcome);
welcomeCheckBox.addListener(new ChangeListener() {
@Override
public void changed(ChangeListener.ChangeEvent event, Actor actor) {
allowingWelcome = welcomeCheckBox.isChecked();
}
});
t.add(welcomeCheckBox).padTop(10.0f).colspan(2);
t.row();
label = new Label("Exported JSON Format:", getSkin());
t.add(label).right().padTop(10.0f);
final SelectBox<ExportFormat> exportFormatSelectBox = new SelectBox(getSkin());
exportFormatSelectBox.setItems(ExportFormat.MINIMAL, ExportFormat.JAVASCRIPT, ExportFormat.JSON);
exportFormatSelectBox.setSelected(exportFormat);
exportFormatSelectBox.addListener(new ChangeListener() {
@Override
public void changed(ChangeListener.ChangeEvent event, Actor actor) {
exportFormat = exportFormatSelectBox.getSelected();
}
});
t.add(exportFormatSelectBox).left().padTop(10.0f);
;
button("OK", true);
button("Cancel", false);
getButtonTable().getCells().first().getActor().addListener(main.getHandListener());
getButtonTable().getCells().get(1).getActor().addListener(main.getHandListener());
key(Keys.ESCAPE, false);
}
Aggregations