List of usage examples for com.badlogic.gdx.scenes.scene2d.ui Dialog Dialog
public Dialog(String title, Skin skin, String windowStyleName)
From source file:be.ac.ucl.lfsab1509.bouboule.game.screen.GlobalScreen.java
License:Open Source License
private void showTutorialDialog() { if (!tutorialCheckBox.isChecked()) return;//from ww w. ja v a 2 s.co m Dialog dialog = new Dialog(" Tutorial ", getSkin(), "default") { protected void result(Object object) { if ((Boolean) object == true) { EndGameListener.resetGame(); GlobalSettings.PROFILE.setNeedTutorial(tutorialCheckBox.isChecked()); } else tutorialCheckBox.setChecked(false); } }.text("\n It will restart the game to level 1. \n" + " Do you want to continue? \n ") .button(" Yes ", true).button(" No ", false).show(stage); dialog.setX((GlobalSettings.APPWIDTH - dialog.getWidth()) / 2); }
From source file:be.ac.ucl.lfsab1509.bouboule.game.screen.MenuScreen.java
License:Open Source License
@Override public void show() { super.show(); // Set Background addBackGroundShift("GdxMenus/main/mainmenubg.jpg"); // Add Button image addBackGround("GdxMenus/main/mainmenubuttons.png"); // Create the 2 Bouboules out of the screen final Image imgBoubouleR = addImage("GdxMenus/main/boubouleright.png", GlobalSettings.APPWIDTH, 1f); final Image imgBoubouleL = addImage("GdxMenus/main/boubouleleft.png", -GlobalSettings.APPWIDTH, 1f); // add action on the bouboule final ActionBouboul actionbouL = new ActionBouboul(false); this.stage.addAction(actionbouL); actionbouL.setActor(imgBoubouleL);//from ww w. java2s. co m final ActionBouboul actionbouR = new ActionBouboul(true); this.stage.addAction(actionbouR); actionbouR.setActor(imgBoubouleR); // add the title title = new Label("BOUBOULE", getSkin(), "darktimes-font", new Color(.388f, .733f, .984f, 1f)); title.setAlignment(Align.center); // center title.setWidth(GlobalSettings.APPWIDTH); // title.setColor(.2f, .7098f, .898f, 1f); // android color // add the title in a table in order to rotate it. Table tableTitle = new Table(); tableTitle.add(title); tableTitle.setTransform(true); tableTitle.setWidth(GlobalSettings.APPWIDTH); // all the width tableTitle.setX(0); tableTitle.setY((int) (1050 * GlobalSettings.HD) - GlobalSettings.SHIFT_BG_HEIGHT / 2); tableTitle.setOrigin(GlobalSettings.APPWIDTH / 2, tableTitle.getHeight() / 2); // at the center stage.addActor(tableTitle); // add action on the title final ActionTitle actiontitle = new ActionTitle(); this.stage.addAction(actiontitle); actiontitle.setActor(tableTitle); // Add 5 button transparent Button playButton, paramButton, scoreButton, boubouleButton, titleButton; if (GlobalSettings.ISHD) { playButton = createButton("transparent", 690, 250, 312, 1150); paramButton = createButton("transparent", 690, 250, 312, 887); scoreButton = createButton("transparent", 690, 250, 312, 615); boubouleButton = createButton("transparent", 1000, 600, 200, 0); titleButton = createButton("transparent", 1000, 1000, 200, 1450); } else { playButton = createButton("transparent", 430, 160, 200, 725); paramButton = createButton("transparent", 430, 160, 200, 555); scoreButton = createButton("transparent", 430, 160, 200, 385); boubouleButton = createButton("transparent", 500, 350, 200, 0); titleButton = createButton("transparent", 500, 500, 200, 885); } // Listener for the button playButton.addListener(new ClickListener() { public void clicked(InputEvent event, float x, float y) { if (GlobalSettings.GAME.isPlayingGame()) setScreenWithFading(null); else setScreenWithFading(new WorldScreen()); } }); paramButton.addListener(new ClickListener() { public void clicked(InputEvent event, float x, float y) { setScreenWithFading(new ParamScreen()); } }); scoreButton.addListener(new ClickListener() { public void clicked(InputEvent event, float x, float y) { if (GlobalSettings.GAMECENTER != null) { GlobalSettings.GAMECENTER.showLeaderboard(); } else { Dialog dialog = new Dialog(" HighScore ", getSkin(), "default") { // improved default skin? // protected void result(Object object) {} // Just hide the dialog }.text("\n" + getHighScoreText() + " ").button(" Close ", null).show(stage); dialog.setX((GlobalSettings.APPWIDTH - dialog.getWidth()) / 2); } } }); boubouleButton.addListener(new ClickListener() { public void clicked(InputEvent event, float x, float y) { final ActionBouboul actionbouL = new ActionBouboul(false); actionbouL.init(); stage.addAction(actionbouL); actionbouL.setActor(imgBoubouleL); final ActionBouboul actionbouR = new ActionBouboul(true); actionbouR.init(); stage.addAction(actionbouR); actionbouR.setActor(imgBoubouleR); } }); titleButton.addListener(new ClickListener() { public void clicked(InputEvent event, float x, float y) { actiontitle.switchName(); } }); }
From source file:be.ac.ucl.lfsab1509.bouboule.game.screen.UserScreen.java
License:Open Source License
private void addNewUser() { String error = checkNewUser(); Dialog dialog;//from w w w . java 2 s .co m if (error == null) { GlobalSettings.PROFILE_MGR.createAndLoadNewProfile(newUserTextField.getText()); refreshScreen(); dialog = new Dialog(" New User Created ", getSkin(), "default") { } // close the dialogue .text("\n New user created with succes! \n ").button(" Close ", null).show(stage); } else dialog = new Dialog(" Error ", getSkin(), "default") { protected void result(Object object) { refreshScreen(); } }.text("\n " + error + " \n "); dialog.button(" Close ", null).show(stage); dialog.setX((GlobalSettings.APPWIDTH - dialog.getWidth()) / 2); }
From source file:be.ac.ucl.lfsab1509.bouboule.game.screen.UserScreen.java
License:Open Source License
private void displayDialogOneImage() { Dialog dialog = new Dialog(" No other skin available ", getSkin(), "default") { } // close the dialogue .text("\n You've to win against other bouboules! \n ").button(" Close ", null) .show(stage);//from w w w . j a va 2s . c om dialog.setX((GlobalSettings.APPWIDTH - dialog.getWidth()) / 2); }
From source file:com.badlogic.gdx.spriter.demo.SpriterDemoApp.java
private void popup(String title, String content) { new Dialog(title, skin, "dialog").text(content).button("I understand", true).key(Keys.ENTER, true) .key(Keys.ESCAPE, true).show(stage); }
From source file:com.ray3k.skincomposer.dialog.DialogColors.java
License:Open Source License
private void showColorPicker() { dialogFactory.showDialogColorPicker(new DialogColorPicker.ColorListener() { @Override/*from w ww.j a v a2 s . c o m*/ public void selected(Color color) { if (color != null) { final TextField field = new TextField("RGBA_" + (int) (color.r * 255) + "_" + (int) (color.g * 255) + "_" + (int) (color.b * 255) + "_" + (int) (color.a * 255), skin); final Dialog dialog = new Dialog("Color name...", skin, "bg") { @Override protected void result(Object object) { if ((Boolean) object == true) { newColor(field.getText(), color); } } }; dialog.getTitleTable().padLeft(5.0f); dialog.button("Ok", true).button("Cancel", false).key(Keys.ESCAPE, false); final TextButton button = (TextButton) dialog.getButtonTable().getCells().first().getActor(); button.addListener(main.getHandListener()); dialog.getButtonTable().getCells().get(1).getActor().addListener(main.getHandListener()); dialog.getButtonTable().pad(15.0f); field.setTextFieldListener(new TextField.TextFieldListener() { @Override public void keyTyped(TextField textField, char c) { if (c == '\n') { if (!button.isDisabled()) { String name = field.getText(); if (newColor(name, color)) { dialog.hide(); } } main.getStage().setKeyboardFocus(textField); } } }); field.addListener(main.getIbeamListener()); dialog.getContentTable().padLeft(10.0f).padRight(10.0f).padTop(5.0f); dialog.text("Please enter a name for the new color: "); dialog.getContentTable().row(); dialog.getContentTable().add(field).growX(); dialog.getContentTable().row(); dialog.text("Preview:"); dialog.getContentTable().row(); Table table = new Table(skin); table.setBackground("white"); table.setColor(color); dialog.getContentTable().add(table).minSize(50.0f); button.setDisabled(!ColorData.validate(field.getText())); field.addListener(new ChangeListener() { @Override public void changed(ChangeListener.ChangeEvent event, Actor actor) { boolean disable = !ColorData.validate(field.getText()); if (!disable) { for (ColorData data : jsonData.getColors()) { if (data.getName().equals(field.getText())) { disable = true; break; } } } button.setDisabled(disable); } }); dialog.show(getStage()); getStage().setKeyboardFocus(field); field.selectAll(); field.setFocusTraversal(false); } } }); }
From source file:com.ray3k.skincomposer.dialog.DialogColors.java
License:Open Source License
private void renameDialog(ColorData color) { TextField textField = new TextField("", skin); TextButton okButton;//from ww w.ja v a 2s. c o m Dialog dialog = new Dialog("Rename Color?", skin, "bg") { @Override protected void result(Object object) { if ((boolean) object) { renameColor(color, textField.getText()); } } @Override public Dialog show(Stage stage) { Dialog dialog = super.show(stage); main.getStage().setKeyboardFocus(textField); return dialog; } }; dialog.getTitleTable().padLeft(5.0f); float brightness = Utils.brightness(color.color); Color borderColor; if (brightness > .35f) { borderColor = Color.BLACK; } else { borderColor = Color.WHITE; } Table bg = new Table(skin); bg.setBackground("white"); bg.setColor(borderColor); dialog.getContentTable().add(bg); Label label = new Label(color.getName(), skin, "white"); label.setColor(color.color); bg.add(label).pad(10); dialog.getContentTable().row(); label = new Label("What do you want to rename the color to?", skin); dialog.getContentTable().add(label); dialog.getContentTable().row(); textField.setText(color.getName()); textField.selectAll(); textField.addListener(main.getIbeamListener()); dialog.getContentTable().add(textField); dialog.getCell(dialog.getContentTable()).pad(15.0f); dialog.button("OK", true); dialog.button("Cancel", false).key(Keys.ESCAPE, false); okButton = (TextButton) dialog.getButtonTable().getCells().first().getActor(); okButton.setDisabled(true); okButton.addListener(main.getHandListener()); dialog.getButtonTable().getCells().get(1).getActor().addListener(main.getHandListener()); dialog.getButtonTable().padBottom(15.0f); textField.addListener(new ChangeListener() { @Override public void changed(ChangeListener.ChangeEvent event, Actor actor) { boolean disable = !ColorData.validate(textField.getText()); if (!disable) { for (ColorData data : jsonData.getColors()) { if (data.getName().equals(textField.getText())) { disable = true; break; } } } okButton.setDisabled(disable); } }); textField.setTextFieldListener(new TextField.TextFieldListener() { @Override public void keyTyped(TextField textField, char c) { if (c == '\n') { if (!okButton.isDisabled()) { renameColor(color, textField.getText()); dialog.hide(); } } } }); textField.setFocusTraversal(false); dialog.show(getStage()); }
From source file:com.ray3k.skincomposer.dialog.DialogDrawables.java
License:Open Source License
private void colorSwatchesDialog(DrawableData drawableData) { DialogColors dialog = new DialogColors(getSkin(), "dialog", null, true, dialogFactory, jsonData, projectData, atlasData, main, (ColorData colorData) -> { if (colorData != null) { final DrawableData tintedDrawable = new DrawableData(drawableData.file); tintedDrawable.tintName = colorData.getName(); //Fix background color for new, tinted drawable Color temp = Utils.averageEdgeColor(tintedDrawable.file, colorData.color); if (Utils.brightness(temp) > .5f) { tintedDrawable.bgColor = Color.BLACK; } else { tintedDrawable.bgColor = Color.WHITE; }//from w w w .jav a2 s. c o m final TextField textField = new TextField(drawableData.name, getSkin()); final TextButton button = new TextButton("OK", getSkin()); button.setDisabled(!DrawableData.validate(textField.getText()) || checkIfNameExists(textField.getText())); button.addListener(main.getHandListener()); textField.addListener(new ChangeListener() { @Override public void changed(ChangeListener.ChangeEvent event, Actor actor) { button.setDisabled(!DrawableData.validate(textField.getText()) || checkIfNameExists(textField.getText())); } }); textField.addListener(main.getIbeamListener()); Dialog approveDialog = new Dialog("TintedDrawable...", getSkin(), "bg") { @Override protected void result(Object object) { if (object instanceof Boolean && (boolean) object) { tintedDrawable.name = textField.getText(); atlasData.getDrawables().add(tintedDrawable); projectData.setChangesSaved(false); } } @Override public boolean remove() { gatherDrawables(); produceAtlas(); sortBySelectedMode(); getStage().setScrollFocus(scrollPane); return super.remove(); } }; approveDialog.addCaptureListener(new InputListener() { @Override public boolean keyDown(InputEvent event, int keycode2) { if (keycode2 == Input.Keys.ENTER) { if (!button.isDisabled()) { tintedDrawable.name = textField.getText(); atlasData.getDrawables().add(tintedDrawable); projectData.setChangesSaved(false); approveDialog.hide(); } } return false; } }); approveDialog.getTitleTable().padLeft(5.0f); approveDialog.getContentTable().padLeft(10.0f).padRight(10.0f).padTop(5.0f); approveDialog.getButtonTable().padBottom(15.0f); approveDialog.text("What is the name of the new tinted drawable?"); Drawable drawable = drawablePairs.get(drawableData); Drawable preview = null; if (drawable instanceof SpriteDrawable) { preview = ((SpriteDrawable) drawable).tint(colorData.color); } else if (drawable instanceof NinePatchDrawable) { preview = ((NinePatchDrawable) drawable).tint(colorData.color); } if (preview != null) { approveDialog.getContentTable().row(); Table table = new Table(); table.setBackground(preview); approveDialog.getContentTable().add(table); } approveDialog.getContentTable().row(); approveDialog.getContentTable().add(textField).growX(); approveDialog.button(button, true); approveDialog.button("Cancel", false); approveDialog.getButtonTable().getCells().get(1).getActor() .addListener(main.getHandListener()); approveDialog.key(Input.Keys.ESCAPE, false); approveDialog.show(getStage()); getStage().setKeyboardFocus(textField); textField.selectAll(); textField.setFocusTraversal(false); } }); dialog.setFillParent(true); dialog.show(getStage()); dialog.populate(); }
From source file:com.ray3k.skincomposer.dialog.DialogDrawables.java
License:Open Source License
private void renameDrawableDialog(DrawableData drawable) { TextField textField = new TextField("", getSkin()); Dialog dialog = new Dialog("Rename drawable?", getSkin(), "bg") { @Override/*from w w w. j a va 2 s.c o m*/ protected void result(Object object) { super.result(object); if (object instanceof Boolean && (boolean) object == true) { renameDrawable(drawable, textField.getText()); } getStage().setScrollFocus(scrollPane); } @Override public Dialog show(Stage stage) { Dialog dialog = super.show(stage); stage.setKeyboardFocus(textField); return dialog; } }; dialog.getTitleTable().padLeft(5.0f); dialog.getContentTable().padLeft(10.0f).padRight(10.0f).padTop(5.0f); dialog.getButtonTable().padBottom(15.0f); dialog.getContentTable().add(new Label("Please enter a new name for the drawable: ", getSkin())); dialog.button("OK", true); dialog.button("Cancel", false).key(Keys.ESCAPE, false); TextButton okButton = (TextButton) dialog.getButtonTable().getCells().first().getActor(); okButton.setDisabled(true); okButton.addListener(main.getHandListener()); dialog.getButtonTable().getCells().get(1).getActor().addListener(main.getHandListener()); dialog.getContentTable().row(); textField.setText(drawable.name); textField.selectAll(); textField.addListener(new ChangeListener() { @Override public void changed(ChangeListener.ChangeEvent event, Actor actor) { boolean disable = !DrawableData.validate(textField.getText()); if (!disable) { for (DrawableData data : atlasData.getDrawables()) { if (data.name.equals(textField.getText())) { disable = true; break; } } } okButton.setDisabled(disable); } }); textField.setTextFieldListener(new TextField.TextFieldListener() { @Override public void keyTyped(TextField textField, char c) { if (c == '\n') { if (!okButton.isDisabled()) { renameDrawable(drawable, textField.getText()); dialog.hide(); } } } }); textField.addListener(main.getIbeamListener()); dialog.getContentTable().add(textField); textField.setFocusTraversal(false); dialog.show(getStage()); }
From source file:com.ray3k.skincomposer.dialog.DialogDrawables.java
License:Open Source License
/** * Shows a dialog to confirm deletion of all TintedDrawables based on the * provided drawable data. This is called when the delete button is pressed * on a drawable in the drawable list.// w ww . j av a2s . co m * @param drawable */ private void showConfirmDeleteDialog(DrawableData drawable) { Dialog dialog = new Dialog("Delete duplicates?", getSkin(), "bg") { @Override protected void result(Object object) { if ((boolean) object) { removeDuplicateDrawables(drawable.file); gatherDrawables(); sortBySelectedMode(); } } }; dialog.getTitleTable().padLeft(5.0f); dialog.getContentTable().padLeft(10.0f).padRight(10.0f).padTop(5.0f); dialog.getButtonTable().padBottom(15.0f); dialog.text( "Deleting this drawable will also delete one or more tinted drawables.\n" + "Delete duplicates?"); dialog.button("OK", true); dialog.button("Cancel", false); dialog.getButtonTable().getCells().first().getActor().addListener(main.getHandListener()); dialog.getButtonTable().getCells().get(1).getActor().addListener(main.getHandListener()); dialog.key(Input.Keys.ENTER, true); dialog.key(Input.Keys.ESCAPE, false); dialog.show(getStage()); }