Java Code Examples for com.badlogic.gdx.scenes.scene2d.ui.Dialog#key()
The following examples show how to use
com.badlogic.gdx.scenes.scene2d.ui.Dialog#key() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HudRenderer.java From xibalba with MIT License | 6 votes |
private void setupDeathDialog() { deathDialog = new Dialog("", Main.skin) { public void result(Object obj) { if (obj.equals(true)) { Main.playScreen.dispose(); main.setScreen(new MainMenuScreen(main)); } else { Gdx.app.exit(); } } }; deathDialog.button("[DARK_GRAY][[[CYAN] ENTER [DARK_GRAY]][WHITE] Return to Main Menu", true); deathDialog.key(Input.Keys.ENTER, true); deathDialog.button("[DARK_GRAY][[[CYAN] Q [DARK_GRAY]][WHITE] Quit", false); deathDialog.key(Input.Keys.Q, false); deathDialog.pad(10); }
Example 2
Source File: OptionsPane.java From gdx-skineditor with Apache License 2.0 | 5 votes |
/** * */ protected void showDeleteDialog() { // Check if it used by other style prior to delete it // FIXME: TODO Dialog dlgStyle = new Dialog("Delete Style", game.skin) { @Override protected void result(Object object) { if ((Boolean) object == false) { return; } // Now we really add it! game.skinProject.remove((String) listStyles.getSelected(), currentStyle.getClass()); refresh(); game.screenMain.saveToSkin(); game.screenMain.panePreview.refresh(); } }; dlgStyle.pad(20); dlgStyle.getContentTable().add("You are sure you want to delete this style?"); dlgStyle.button("OK", true); dlgStyle.button("Cancel", false); dlgStyle.key(com.badlogic.gdx.Input.Keys.ENTER, true); dlgStyle.key(com.badlogic.gdx.Input.Keys.ESCAPE, false); dlgStyle.show(getStage()); }
Example 3
Source File: WelcomeScreen.java From gdx-skineditor with Apache License 2.0 | 5 votes |
/** * */ private void showNewProjectDialog() { final TextField textProject = new TextField("", game.skin); Dialog dlg = new Dialog("New Project", game.skin) { @Override protected void result(Object object) { if ((Boolean) object == false) { return; } String projectName = textProject.getText(); projectName = projectName.replace(".", "_"); projectName = projectName.replace("/", "_"); projectName = projectName.replace("\\", "_"); projectName = projectName.replace("-", "_"); if (projectName.isEmpty() == true) return; createProject(projectName); } }; dlg.pad(20); dlg.getContentTable().add("Project Name:"); dlg.getContentTable().add(textProject).pad(20); dlg.button("OK", true); dlg.button("Cancel", false); dlg.key(com.badlogic.gdx.Input.Keys.ENTER, true); dlg.key(com.badlogic.gdx.Input.Keys.ESCAPE, false); dlg.setWidth(480); dlg.show(stage); stage.setKeyboardFocus(textProject); }
Example 4
Source File: WelcomeScreen.java From gdx-skineditor with Apache License 2.0 | 5 votes |
/** * */ private void showDeleteDialog() { Dialog dlgStyle = new Dialog("Delete Project", game.skin) { @Override protected void result(Object object) { if ((Boolean) object == false) { return; } // We delete it FileHandle projectFolder = Gdx.files.local("projects/" + (String) listProjects.getSelected()); projectFolder.deleteDirectory(); refreshProjects(); } }; dlgStyle.pad(20); dlgStyle.getContentTable().add( "You are sure you want to delete this project?"); dlgStyle.button("OK", true); dlgStyle.button("Cancel", false); dlgStyle.key(com.badlogic.gdx.Input.Keys.ENTER, true); dlgStyle.key(com.badlogic.gdx.Input.Keys.ESCAPE, false); dlgStyle.show(stage); }
Example 5
Source File: SkinEditorGame.java From gdx-skineditor with Apache License 2.0 | 5 votes |
/** * Display a dialog with a notice */ public void showNotice(String title, String message, Stage stage) { Dialog dlg = new Dialog(title, skin); dlg.pad(20); dlg.getContentTable().add(message).pad(20); dlg.button("OK", true); dlg.key(com.badlogic.gdx.Input.Keys.ENTER, true); dlg.key(com.badlogic.gdx.Input.Keys.ESCAPE, false); dlg.show(stage); }
Example 6
Source File: MenuBar.java From gdx-skineditor with Apache License 2.0 | 4 votes |
protected void showExportDialog() { final Preferences prefs = Gdx.app.getPreferences("skin_editor_project_" + game.screenMain.getcurrentProject()); final TextField textDirectory = new TextField(prefs.getString("export_to_directory"),game.skin); Dialog dlg = new Dialog("Export to Directory", game.skin) { @Override protected void result(Object object) { if ((Boolean) object == true) { if (textDirectory.getText().isEmpty() == true) { game.showNotice("Warning", "Directory field is empty!", game.screenMain.stage); return; } FileHandle targetDirectory = new FileHandle(textDirectory.getText()); if (targetDirectory.exists() == false) { game.showNotice("Warning", "Directory not found!", game.screenMain.stage); return; } // Copy uiskin.* and *.fnt FileHandle projectFolder = Gdx.files.local("projects").child(game.screenMain.getcurrentProject()); for(FileHandle file : projectFolder.list()) { if (file.name().startsWith("uiskin.") || (file.extension().equalsIgnoreCase("fnt"))) { Gdx.app.log("MenuBar","Copying file: " + file.name() + " ..."); FileHandle target = targetDirectory.child(file.name()); file.copyTo(target); } } game.showNotice("Operation Completed", "Project successfully exported!", game.screenMain.stage); } } }; dlg.pad(20); Table table = dlg.getContentTable(); table.padTop(20); table.add("Directory:"); table.add(textDirectory).width(320); TextButton buttonChoose = new TextButton("...", game.skin); buttonChoose.addListener(new ChangeListener() { @Override public void changed(ChangeEvent event, Actor actor) { // Need to steal focus first with this hack (Thanks to Z-Man) Frame frame = new Frame(); frame.setUndecorated(true); frame.setOpacity(0); frame.setLocationRelativeTo(null); frame.setVisible(true); frame.toFront(); frame.setVisible(false); frame.dispose(); JFileChooser chooser = new JFileChooser(); chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); int ret = chooser.showOpenDialog(null); if (ret == JFileChooser.APPROVE_OPTION) { File f = chooser.getSelectedFile(); textDirectory.setText(f.getAbsolutePath()); // Store to file prefs.putString("export_to_directory", f.getAbsolutePath()); prefs.flush(); } } }); table.add(buttonChoose); table.row(); table.padBottom(20); dlg.button("Export", true); dlg.button("Cancel", false); dlg.key(com.badlogic.gdx.Input.Keys.ENTER, true); dlg.key(com.badlogic.gdx.Input.Keys.ESCAPE, false); dlg.show(getStage()); }
Example 7
Source File: OptionsPane.java From gdx-skineditor with Apache License 2.0 | 4 votes |
/** * */ protected void createNewStyle() { final TextField textStyleName = new TextField("", game.skin); Dialog dlgStyle = new Dialog("New Style", game.skin) { @Override protected void result(Object object) { if ((Boolean) object == false) { return; } String styleName = textStyleName.getText(); if (styleName.length() == 0) { game.showNotice("Warning", "No style name entered!", game.screenMain.stage); return; } // Check if the style name is already in use if (listItems.contains(styleName, false)) { game.showNotice("Warning", "Style name already in use!", game.screenMain.stage); return; } try { game.skinProject.add(styleName, currentStyle.getClass().newInstance()); } catch(Exception e) { e.printStackTrace(); } //game.skinProject.add(text, game.skin.get("default", currentStyle.getClass()), currentStyle.getClass()); game.screenMain.saveToSkin(); refresh(); game.screenMain.panePreview.refresh(); } }; dlgStyle.pad(20); dlgStyle.getContentTable().add("Style Name:"); dlgStyle.getContentTable().add(textStyleName).pad(20); dlgStyle.button("OK", true); dlgStyle.button("Cancel", false); dlgStyle.key(com.badlogic.gdx.Input.Keys.ENTER, true); dlgStyle.key(com.badlogic.gdx.Input.Keys.ESCAPE, false); dlgStyle.show(getStage()); getStage().setKeyboardFocus(textStyleName); }