use of com.badlogic.gdx.scenes.scene2d.InputEvent in project commons-gdx by gemserk.
the class Actors method threeOptionsDialog.
public static Actor threeOptionsDialog(String[] texts, final DialogListener dialogListener, String titleText, String firstOption, String secondOption, String thirdOption, Skin skin) {
Window window = new Window(titleText, skin);
window.setMovable(false);
TextButton firstOptionButton = new TextButton(firstOption, skin);
TextButton secondOptionButton = new TextButton(secondOption, skin);
TextButton thirdOptionButton = new TextButton(thirdOption, skin);
firstOptionButton.addListener(new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
dialogListener.optionSelected(0);
}
});
secondOptionButton.addListener(new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
dialogListener.optionSelected(1);
}
});
thirdOptionButton.addListener(new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
dialogListener.optionSelected(2);
}
});
window.defaults().spaceBottom(10);
window.row().fill().expandX();
for (int i = 0; i < texts.length; i++) {
window.row().padLeft(20);
Label label = new Label(texts[i], skin);
label.setWrap(true);
window.add(label).align(Align.left).colspan(2).fillX();
}
window.row().fill().expandX().padTop(10);
window.add(firstOptionButton).align(Align.center).padLeft(30).padRight(30);
window.row().fill().expandX();
window.add(secondOptionButton).align(Align.center).padLeft(30).padRight(30);
window.row().fill().expandX();
window.add(thirdOptionButton).align(Align.center).padLeft(30).padRight(30);
ScrollPane scrollPane = new ScrollPane(window);
scrollPane.setWidth(Gdx.graphics.getWidth() * 0.95f);
scrollPane.setHeight(Gdx.graphics.getHeight() * 0.95f);
scrollPane.setX(Gdx.graphics.getWidth() * 0.5f - scrollPane.getWidth() * 0.5f);
scrollPane.setY(Gdx.graphics.getHeight() * 0.5f - scrollPane.getHeight() * 0.5f);
return scrollPane;
}
use of com.badlogic.gdx.scenes.scene2d.InputEvent in project AmazingMaze by TheVirtualMachine.
the class FishMiniGame method dialog.
/**
* Displays the results dialog.
*/
public void dialog() {
message = formatString(answerField.getText());
Label.LabelStyle labelStyle = new Label.LabelStyle(game.assets.getFont(Assets.MONO_REGULAR, Assets.SMALL_FONT_SIZE), Color.WHITE);
final Dialog dialog = new Dialog("Results", game.assets.skin);
final TextButton okButton = new TextButton("OK", game.assets.skin);
dialog.getButtonTable().bottom();
if (checkAnswer() == -1) {
Label label = new Label("Invalid answer. Please try again.", labelStyle);
label.setScale(.5f);
label.setWrap(true);
label.setAlignment(Align.center);
dialog.add(label).width(500).pad(50);
dialog.add(okButton).bottom();
okButton.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
if (okButton.isPressed()) {
dialog.hide();
canvas.setColor(drawColor);
}
}
});
dialog.addListener(new InputListener() {
@Override
public boolean keyDown(InputEvent event, int keycode) {
if (keycode == Keys.ENTER) {
dialog.hide();
return true;
}
return false;
}
});
} else {
Label label = new Label("Your answer was: " + message + ". " + "The correct answer was: " + answer + ". " + "You get " + checkAnswer() + " back!", labelStyle);
game.save.addScore(checkAnswer());
game.save.setLives(player.getLives());
label.setScale(.5f);
label.setWrap(true);
label.setAlignment(Align.center);
dialog.add(label).width(500).pad(50);
dialog.add(okButton).bottom();
okButton.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
if (okButton.isPressed()) {
dialog.cancel();
if ((game.save.getLevel() - 1) % 5 == 0) {
game.setScreen(new ContinueScreen(game, true));
} else {
game.setScreen(new MazeScreen(game, false));
}
}
}
});
dialog.addListener(new InputListener() {
@Override
public boolean keyDown(InputEvent event, int keycode) {
if (keycode == Keys.ENTER) {
if ((game.save.getLevel() - 1) % 5 == 0) {
game.setScreen(new ContinueScreen(game, true));
} else {
game.setScreen(new MazeScreen(game, false));
}
return true;
}
return false;
}
});
}
dialog.show(stage);
}
use of com.badlogic.gdx.scenes.scene2d.InputEvent in project AmazingMaze by TheVirtualMachine.
the class ContinueScreen method highScoreDialog.
/**
* Displays the high score dialog.
*/
public void highScoreDialog() {
Label.LabelStyle labelStyle = new Label.LabelStyle(game.assets.getFont(Assets.MONO_REGULAR, Assets.SMALL_FONT_SIZE), Color.WHITE);
final Dialog dialog = new Dialog("High Score", game.assets.skin);
final TextButton okButton = new TextButton("OK", game.assets.skin);
dialog.getButtonTable().bottom();
Label label = new Label("Enter your name:", labelStyle);
label.setScale(.5f);
label.setWrap(true);
label.setAlignment(Align.center);
final TextField nameField = new TextField("", game.assets.skin);
dialog.add(label).width(500).pad(50);
dialog.add(nameField);
dialog.add(okButton).bottom();
nameField.setTextFieldListener(new TextFieldListener() {
@Override
public void keyTyped(TextField textField, char key) {
name = formatString(nameField.getText());
if (!name.equals("")) {
if (key == (char) 13) {
displayHighScores(name);
}
}
}
});
okButton.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
name = formatString(nameField.getText());
if (!name.equals("")) {
if (okButton.isPressed()) {
dialog.hide();
displayHighScores(name);
}
}
}
});
dialog.addListener(new InputListener() {
@Override
public boolean keyDown(InputEvent event, int keycode) {
name = formatString(nameField.getText());
if (!name.equals("")) {
if (keycode == Keys.ENTER) {
displayHighScores(name);
return true;
}
}
return false;
}
});
dialog.show(stage);
}
use of com.badlogic.gdx.scenes.scene2d.InputEvent in project Catacomb-Snatch by Catacomb-Snatch.
the class Scene method addTextButton.
/**
* Adds a new text button
*
* @param text The text it contains
* @param x The x-position
* @param y The y-position
* @return The created {@link TextButton}
*/
public TextButton addTextButton(String text, int x, int y) {
final TextButton button = new TextButton(text, Art.skin);
button.setPosition(x, y);
button.addListener(new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
button.act(Gdx.graphics.getDeltaTime());
}
});
addActor(button);
return button;
}
use of com.badlogic.gdx.scenes.scene2d.InputEvent in project gdx-skineditor by cobolfoo.
the class WidgetsBar method initializeButtons.
/**
*
*/
public void initializeButtons() {
group = new ButtonGroup();
Tooltips.TooltipStyle styleTooltip = new Tooltips.TooltipStyle(game.skin.getFont("default-font"), game.skin.getDrawable("default-round"), game.skin.getColor("white"));
String[] widgets = SkinEditorGame.widgets;
for (String widget : widgets) {
ImageButtonStyle style = new ImageButtonStyle();
style.checked = game.skin.getDrawable("default-round-down");
style.down = game.skin.getDrawable("default-round-down");
style.up = game.skin.getDrawable("default-round");
style.imageUp = game.skin.getDrawable("widgets/" + widget);
ImageButton button = new ImageButton(style);
button.setUserObject(widget);
Tooltips tooltip = new Tooltips(styleTooltip, getStage());
tooltip.registerTooltip(button, (String) button.getUserObject());
button.addListener(new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
game.screenMain.panePreview.refresh();
game.screenMain.paneOptions.refresh();
}
});
group.add(button);
add(button).pad(5);
}
}
Aggregations