com.badlogic.gdx.scenes.scene2d.ui.TextField Java Examples

The following examples show how to use com.badlogic.gdx.scenes.scene2d.ui.TextField. 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: FloatFieldFilter.java    From talos with Apache License 2.0 6 votes vote down vote up
@Override
public boolean acceptChar (TextField textField, char c) {
    if(Character.isDigit(c)) {
        return true;
    }
    if(c == '.') {
        if(textField.getText() != null && textField.getText().length() > 0) {
            if(textField.getText().contains(".")) {
                return false;
            } else {
                return true;
            }
        } else {
            return true;
        }
    }

    return false;
}
 
Example #2
Source File: AddStateDialog.java    From gdx-soundboard with MIT License 6 votes vote down vote up
public AddStateDialog(final Stage stage, final Skin skin, final MusicEventManager eventManager) {

        super("Add State", skin);
        this.stage = stage;
        this.skin = skin;
        this.eventManager = eventManager;


        Table content = this.getContentTable();
        Label label = new Label("State name", skin);
        label.setAlignment(Align.left);
        content.add(label).left().fillX().expandX().row();

        eventName = new TextField("", skin);
        content.add(eventName).right().fillX().expandX().row();

        Table buttons = this.getButtonTable();
        buttons.defaults().fillX().expandX();
        
        this.button("Ok", true);
        this.button("Cancel", false);
        

        key(Keys.ENTER, true);
        key(Keys.ESCAPE, false);
    }
 
Example #3
Source File: IntegerSetting.java    From Cubes with MIT License 6 votes vote down vote up
private TextField getTextField(VisualSettingManager visualSettingManager) {
  final TextField textField = new TextField(i + "", visualSettingManager.getSkin());
  textField.addListener(new EventListener() {
    @Override
    public boolean handle(Event event) {
      if (!(event instanceof SettingsMenu.SaveEvent)) return false;
      try {
        int n = Integer.parseInt(textField.getText());
        if (hasRange && (n < rangeStart || n > rangeEnd)) {
          throw new NumberFormatException();
        } else {
          set(n);
          return true;
        }
      } catch (Exception e) {
        textField.setText(i + "");
        return false;
      }
    }
  });
  textField.setTextFieldFilter(new TextField.TextFieldFilter.DigitsOnlyFilter());
  if (hasRange) textField.setMessageText("(" + rangeStart + "-" + rangeEnd + ")");
  return textField;
}
 
Example #4
Source File: MultiplayerConnectMenu.java    From Cubes with MIT License 6 votes vote down vote up
public MultiplayerConnectMenu() {
  super();
  title = new Label(Localization.get("menu.multiplayer.title"), skin.get("title", Label.LabelStyle.class));
  address = new TextField("", skin);
  address.setMessageText(Localization.get("menu.multiplayer.address"));
  port = new TextField("", skin);
  port.setMessageText(Localization.get("menu.multiplayer.port", 24842)); //Not "Settings.getIntegerSettingValue(Settings.NETWORKING_PORT)" because the port is set on the server
  port.setTextFieldFilter(new TextField.TextFieldFilter.DigitsOnlyFilter());
  connect = new TextButton(Localization.get("menu.multiplayer.connect"), skin);
  back = MenuTools.getBackButton(this);

  connect.addListener(new ChangeListener() {
    @Override
    public void changed(ChangeEvent event, Actor actor) {
      Adapter.setMenu(new MultiplayerLoadingMenu(address.getText().isEmpty() ? "localhost" : address.getText(), port.getText().isEmpty() ? 24842 : Integer.parseInt(port.getText())));
    }
  });

  stage.addActor(title);
  stage.addActor(address);
  stage.addActor(port);
  stage.addActor(connect);
  stage.addActor(back);
}
 
Example #5
Source File: ServerSetupMenu.java    From Cubes with MIT License 6 votes vote down vote up
public ServerSetupMenu(final Save save) {
  super();
  title = new Label(Localization.get("menu.server.title"), skin.get("title", Label.LabelStyle.class));
  saveLabel = new Label(Localization.get("menu.server.save", save.name), skin);
  saveLabel.setAlignment(Align.center);
  port = new TextField("", skin);
  port.setMessageText(Localization.get("menu.server.port", Settings.getIntegerSettingValue(Settings.NETWORKING_PORT)));
  port.setTextFieldFilter(new TextField.TextFieldFilter.DigitsOnlyFilter());
  start = new TextButton(Localization.get("menu.server.start"), skin);
  back = MenuTools.getBackButton(this);

  start.addListener(new ChangeListener() {
    @Override
    public void changed(ChangeEvent event, Actor actor) {
      int p = port.getText().isEmpty() ? Settings.getIntegerSettingValue(Settings.NETWORKING_PORT) : Integer.parseInt(port.getText());
      Adapter.setMenu(new ServerRunningMenu(save, p));
    }
  });

  stage.addActor(title);
  stage.addActor(saveLabel);
  stage.addActor(port);
  stage.addActor(start);
  stage.addActor(back);
}
 
Example #6
Source File: PropertyTable.java    From bladecoder-adventure-engine with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
public void setProperty(String name, String value) {
	SnapshotArray<Actor> actors = table.getChildren();

	for (Actor a : actors) {
		if (name.equals(a.getName())) {
			if (a instanceof SelectBox<?>) {
				((SelectBox<String>) a).setSelected(value == null ? "" : value);
			} else {
				((TextField) a).setText(value == null ? "" : value);
			}

			return;
		}
	}
}
 
Example #7
Source File: PropertyTable.java    From bladecoder-adventure-engine with Apache License 2.0 6 votes vote down vote up
@Override
		public void keyTyped(TextField actor, char c) {
			if (c == 13) { // ENTER KEY
				updateModel(actor.getName(), ((TextField) actor).getText());
				EditorLogger.debug("Updating property: " + actor.getName());
			}
		}
	});

	tf.addListener(new FocusListener() {

		@Override
		public void keyboardFocusChanged(FocusEvent event, Actor actor, boolean focused) {
			if (!focused) {
				updateModel(actor.getName(), ((TextField) actor).getText());
				EditorLogger.debug("Updating property: " + actor.getName());
			}
		}
	});
}
 
Example #8
Source File: CCTextFieldTest.java    From cocos-ui-libgdx with Apache License 2.0 6 votes vote down vote up
@Test
@NeedGL
public void shouldParseTextField() throws Exception {
    FileHandle defaultFont = Gdx.files.internal("share/MLFZS.ttf");
    CocoStudioUIEditor editor = new CocoStudioUIEditor(
        Gdx.files.internal("textField/MainScene.json"), null, null, defaultFont, null);

    Group group = editor.createGroup();
    TextField textField = group.findActor("TextField_1");
    assertThat(textField.getText(), is("Here is text"));
    assertThat(textField.getMessageText(), is("Place Holder"));
    assertThat(textField.getText(), is("Here is text"));
    assertThat(textField.getColor().toString(), is("008000ff"));
    assertThat(textField.getListeners().size, is(1));
    textField = group.findActor("TextField_2");
    assertThat(textField.getText(), is(""));
    assertThat(textField.getMessageText(), is("Place Holder"));
    assertThat(textField.getColor().toString(), is("ff0000ff"));
    assertThat(textField.getListeners().size, is(1));
}
 
Example #9
Source File: FloatPropertyWidget.java    From talos with Apache License 2.0 6 votes vote down vote up
@Override
public Actor getSubWidget() {
    textField = new TextField("", TalosMain.Instance().getSkin(), "panel");
    textField.setTextFieldFilter(new FloatFieldFilter());

    listener = new ChangeListener() {
        @Override
        public void changed(ChangeEvent event, Actor actor) {
            if(textField.getText().isEmpty()) return;
            try {
                valueChanged(Float.parseFloat(textField.getText()));
            } catch (NumberFormatException e){
                valueChanged(0f);
            }
        }
    };
    textField.addListener(listener);
    return textField;
}
 
Example #10
Source File: VisUITest.java    From libgdx-inGameConsole with Apache License 2.0 5 votes vote down vote up
@Override public void create () {
	VisUI.load();
	Gdx.gl.glClearColor(0, 0, 0, 1);
	console = new GUIConsole(VisUI.getSkin(), false, 0, VisWindow.class, VisTable.class, "default-pane", TextField.class,
		VisTextButton.class, VisLabel.class, VisScrollPane.class);
	console.setCommandExecutor(new MyCommandExecutor());
	console.setSizePercent(100, 100);
	console.setPosition(0, 0);
	console.setVisible(true);
	console.enableSubmitButton(true);
	console.resetInputProcessing();
}
 
Example #11
Source File: DimensionInputPanel.java    From bladecoder-adventure-engine with Apache License 2.0 5 votes vote down vote up
DimensionInputPanel(Skin skin, String title, String desc, boolean mandatory, String defaultValue) {
	dimPanel = new Table(skin);
	width = new TextField("", skin);
	height = new TextField("", skin);

	dimPanel.add(new Label(" width ", skin));
	dimPanel.add(width);
	dimPanel.add(new Label("  height ", skin));
	dimPanel.add(height);

	init(skin, title, desc, dimPanel, mandatory, defaultValue);
}
 
Example #12
Source File: WelcomeScreen.java    From gdx-skineditor with Apache License 2.0 5 votes vote down vote up
/**
 * 
 */
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 #13
Source File: Scene2dUtils.java    From gdx-soundboard with MIT License 5 votes vote down vote up
public static TextField addTextField(String labelText, Table parent, Skin skin){
    Label label = new Label(labelText, skin);
    label.setAlignment(Align.left);
    parent.add(label).left();

    TextField info = new TextField("", skin);
    parent.add(info).right().fillX().expandX().row();

    return info;
}
 
Example #14
Source File: MainListener.java    From skin-composer with MIT License 5 votes vote down vote up
@Override
public void customPropertyValueChanged(CustomProperty customProperty,
        Actor styleActor) {
    if (null != customProperty.getType()) switch (customProperty.getType()) {
        case DRAWABLE:
            dialogFactory.showDialogDrawables(customProperty, dialogListener);
            break;
        case COLOR:
            dialogFactory.showDialogColors(customProperty, dialogListener);
            break;
        case FONT:
            dialogFactory.showDialogFonts(customProperty, dialogListener);
            break;
        case NUMBER:
            main.getUndoableManager().addUndoable(new UndoableManager.CustomDoubleUndoable(main, customProperty, ((Spinner) styleActor).getValue()), false);
            break;
        case TEXT:
        case RAW_TEXT:
            main.getUndoableManager().addUndoable(new UndoableManager.CustomTextUndoable(main, customProperty, ((TextField) styleActor).getText()), false);
            break;
        case BOOL:
            main.getUndoableManager().addUndoable(new UndoableManager.CustomBoolUndoable(main, customProperty, ((Button) styleActor).isChecked()), false);
            break;
        case STYLE:
            dialogFactory.showDialogCustomStyleSelection(customProperty, dialogListener);
            break;
        default:
            break;
    }  
}
 
Example #15
Source File: IntegerSetting.java    From Cubes with MIT License 5 votes vote down vote up
public IntegerSetting(int i) {
  this.i = i;
  this.hasRange = false;
  this.rangeStart = 0;
  this.rangeEnd = 0;
  this.type = Type.TextField;
}
 
Example #16
Source File: IntegerSetting.java    From Cubes with MIT License 5 votes vote down vote up
@Override
public Actor getActor(String settingName, VisualSettingManager visualSettingManager) {
  switch (type) {
    case TextField:
      return getTextField(visualSettingManager);
    case Slider:
      return getSlider(visualSettingManager);
  }
  return null;
}
 
Example #17
Source File: NewFileDialog.java    From gdx-soundboard with MIT License 5 votes vote down vote up
public NewFileDialog(String title, Skin skin) {
    super(title, skin);
    
    Table content = this.getContentTable();
    
    fileName = new TextField("", skin);
    content.add(fileName).fillX().expandX();
    
    button("Create", true);
    button("Cancel", false);
    
    key(Keys.ENTER, true);
    key(Keys.ESCAPE, false);
}
 
Example #18
Source File: StringSetting.java    From Cubes with MIT License 5 votes vote down vote up
@Override
public Actor getActor(String settingName, VisualSettingManager visualSettingManager) {
  final TextField textField = new TextField(s, visualSettingManager.getSkin());
  textField.addListener(new EventListener() {
    @Override
    public boolean handle(Event event) {
      if (!(event instanceof SettingsMenu.SaveEvent)) return false;
      set(textField.getText());
      return true;
    }
  });
  return textField;
}
 
Example #19
Source File: FloatSetting.java    From Cubes with MIT License 5 votes vote down vote up
public FloatSetting(float f) {
  this.f = f;
  this.hasRange = false;
  this.rangeStart = 0;
  this.rangeEnd = 0;
  this.type = Type.TextField;
}
 
Example #20
Source File: FloatSetting.java    From Cubes with MIT License 5 votes vote down vote up
@Override
public Actor getActor(String settingName, VisualSettingManager visualSettingManager) {
  switch (type) {
    case TextField:
      return getTextField(visualSettingManager);
    case Slider:
      return getSlider(visualSettingManager);
  }
  return null;
}
 
Example #21
Source File: Vector2InputPanel.java    From bladecoder-adventure-engine with Apache License 2.0 5 votes vote down vote up
Vector2InputPanel(Skin skin, String title, String desc, boolean mandatory, String defaultValue) {
	dimPanel = new Table(skin);
	x = new TextField("", skin);
	y = new TextField("", skin);

	dimPanel.add(new Label(" x ", skin));
	dimPanel.add(x);
	dimPanel.add(new Label("  y ", skin));
	dimPanel.add(y);

	init(skin, title, desc, dimPanel, mandatory, defaultValue);
}
 
Example #22
Source File: MenuScreen.java    From Cardshifter with Apache License 2.0 4 votes vote down vote up
public MenuScreen(final CardshifterGame game) {
    final Preferences prefs = Gdx.app.getPreferences("cardshifter");
    this.table = new Table();
    this.game = game;
    this.table.setFillParent(true);
    
    Image imageObject = new Image(new Texture(Gdx.files.internal("bg2.png")));
    this.table.add(imageObject);
    this.table.row();

    Table inner = new Table();

    final TextField username = new TextField("", game.skin);
    String[] servers = isGWT() ? availableWSServers : availableServers;
    inner.add(username).expand().fill().colspan(servers.length).row();
    username.setText(prefs.getString("username", "YourUserName"));

    HorizontalGroup serverView = new HorizontalGroup();
    for (final String server : servers) {
        final String[] serverData = server.split(":");
        TextButton button = new TextButton(serverData[0], game.skin);
        button.addListener(new ClickListener() {
            @Override
            public void clicked(InputEvent event, float x, float y) {
                prefs.putString("username", username.getText());
                prefs.flush();
                String hostname = isGWT() ? "ws://" + serverData[0] : serverData[0];
                try {
                    ClientScreen clientScreen = new ClientScreen(game, hostname, Integer.parseInt(serverData[1]), username.getText());
                    game.setScreen(clientScreen);
                } catch (GdxRuntimeException e) {
                	MenuScreen.this.connectionLabel.setText("Connection Failed!");
                }
            }
        });
        serverView.addActor(button);
    }
    inner.add(serverView).expand().fill();
    table.add(inner);
    table.row();
    
    this.connectionLabel = new Label(" ", game.skin);
    this.table.add(this.connectionLabel);
    
}
 
Example #23
Source File: OptionsPane.java    From gdx-skineditor with Apache License 2.0 4 votes vote down vote up
/**
 * 
 */
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);

}
 
Example #24
Source File: MenuBar.java    From gdx-skineditor with Apache License 2.0 4 votes vote down vote up
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 #25
Source File: SettingsScreen.java    From buffer_bci with GNU General Public License v3.0 4 votes vote down vote up
public SettingsScreen(Game game) {

        this.game = game;
        this.camera = new OrthographicCamera();
        this.viewport = new ExtendViewport(Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), this.camera);
        this.stage = new Stage(viewport);

        // Buttons
        this.statusButton = new TextButton("Connect", VisUI.getSkin());
        this.backButton = new TextButton("Back", VisUI.getSkin());

        // IP
        this.ipLabel = new Label("IP Address:", VisUI.getSkin());
        this.ipField = new TextField("", VisUI.getSkin());

        // Port
        this.portLabel = new Label("Port:", VisUI.getSkin());
        this.portField = new TextField("", VisUI.getSkin());

        // Server connection status label
        this.statusLabel = new Label("No Information to see yet.", VisUI.getSkin());

        // BCI Modes

        // Stimuli ON and OFF
        this.stimuliOff = new CheckBox("Stimuli OFF", VisUI.getSkin());
        this.stimuliOn = new CheckBox("Stimuli ON", VisUI.getSkin());

        // Synchronous and asynchronous
        this.synchronous = new CheckBox("Synchronous", VisUI.getSkin());
        this.asynchronous = new CheckBox("Asynchronous", VisUI.getSkin());


        // Controls: direct/sticky keys
        this.gamePlayModeSelectorLabel = new Label("Game play mode", VisUI.getSkin());
        this.gamePlayModeSelector= new SelectBox<>(VisUI.getSkin());
        this.gamePlayModeSelector.setItems("Direct","Sticky");

        // Decay -> Not implemented
        this.keyCommandDecayField = new TextField("", VisUI.getSkin());
        keyCommandDecayField .setMessageText("default : 200 ms ");
        keyCommandDecayField .needsLayout();
        this.keyCommandDecayLabel = new Label("Key command decay (/millisecond):", VisUI.getSkin());

        // File choosers

        // Game stimuli chooser
        this.stimuliLabel = new Label("Stimuli file:", VisUI.getSkin());
        this.fileChooser = new FileChooser("Choose Stimuli File", FileChooser.Mode.OPEN);
        fileChooser.setSize(stage.getWidth(), stage.getHeight());
        this.fileField = new TextField("", VisUI.getSkin() );
        fileField.setMessageText("no file chosen");

        // Calibration stimuli chooser
        this.calibrationLabel = new Label("Calibration file:", VisUI.getSkin() );
        this.calibrationChooser = new FileChooser("Choose Calibration File", FileChooser.Mode.OPEN);
        calibrationChooser.setSize(stage.getWidth(), stage.getHeight());
        this.calibrationField = new TextField("", VisUI.getSkin() );
        calibrationField.setMessageText("no file chosen");

        // Timeout
        this.timeoutField = new TextField("", VisUI.getSkin());
        timeoutField.setMessageText("100");
        timeoutField.needsLayout();
        this.timeoutLabel = new Label("Timeout after (ms):", VisUI.getSkin());

        // Game step
        this.gameStepLabel = new Label("Game step time:", VisUI.getSkin());
        this.gameStepField = new TextField("", VisUI.getSkin());
        gameStepField.setMessageText(""+StandardizedInterface.getInstance().getGameStepLength());
    }
 
Example #26
Source File: NameScreen.java    From xibalba with MIT License 4 votes vote down vote up
/**
 * Character Creation: Review Screen.
 *
 * @param main Instance of main class
 */
public NameScreen(Main main, PlayerSetup playerSetup) {
  this.main = main;
  this.playerSetup = playerSetup;

  stage = new Stage(new FitViewport(960, 540));
  worldSeed = System.currentTimeMillis();

  Table table = new Table();
  table.setFillParent(true);
  table.left().top();
  table.pad(10);
  stage.addActor(table);

  ActionButton backButton = new ActionButton("Q", "Back");
  backButton.setKeys(Input.Keys.Q);
  backButton.setAction(table, () -> main.setScreen(new YouScreen(main)));
  table.add(backButton).pad(0, 0, 10, 0).left();

  table.row();

  Label worldSeedLabel = new Label("World Seed", Main.skin);
  table.add(worldSeedLabel).pad(0, 0, 10, 0).width(Gdx.graphics.getWidth() / 2);
  table.row();
  worldSeedField = new TextField(worldSeed + "", Main.skin);
  table.add(worldSeedField).pad(0, 0, 10, 0).width(Gdx.graphics.getWidth() / 2);

  table.row();
  Label playerNameLabel = new Label("Name", Main.skin);
  table.add(playerNameLabel).pad(0, 0, 10, 0).width(Gdx.graphics.getWidth() / 2);
  table.row();
  playerNameField = new TextField(playerSetup.name, Main.skin);
  table.add(playerNameField).pad(0, 0, 10, 0).width(Gdx.graphics.getWidth() / 2);

  table.row();
  Label playerColorLabel = new Label("Color", Main.skin);
  table.add(playerColorLabel).pad(0, 0, 10, 0).width(Gdx.graphics.getWidth() / 2);
  table.row();
  playerColorField = new TextField(playerSetup.color, Main.skin);
  playerColorField.setMaxLength(6);
  table.add(playerColorField).pad(0, 0, 10, 0).width(Gdx.graphics.getWidth() / 2);

  ActionButton continueButton = new ActionButton("ENTER", "Begin Your Journey");
  continueButton.setKeys(Input.Keys.ENTER);
  continueButton.setAction(table, this::startGame);

  table.row();
  table.add(continueButton).left();

  Gdx.input.setInputProcessor(stage);
  stage.setKeyboardFocus(table);
}
 
Example #27
Source File: SingleplayerSaveCreateMenu.java    From Cubes with MIT License 4 votes vote down vote up
public SingleplayerSaveCreateMenu() {
  super();
  title = new Label(Localization.get("menu.singleplayer.create.title"), skin.get("title", Label.LabelStyle.class));
  name = new TextField("", skin);
  name.setMessageText(Localization.get("menu.singleplayer.create.name"));
  name.setTextFieldFilter(new TextField.TextFieldFilter() {
    @Override
    public boolean acceptChar(TextField textField, char c) {
      return c >= 0x20 && c < 0x7F;
    }
  });

  generator = new SelectBox<SaveTypeDisplay>(skin);
  String[] types = GeneratorManager.ids();
  SaveTypeDisplay[] display = new SaveTypeDisplay[types.length];
  for (int i = 0; i < types.length; i++) {
    display[i] = new SaveTypeDisplay(types[i]);
  }
  generator.setItems(display);

  mode = new SelectBox<Gamemode>(skin);
  mode.setItems(Gamemode.values());

  seed = new TextField("", skin);
  seed.setMessageText(Localization.get("menu.singleplayer.create.seed"));

  start = new TextButton(Localization.get("menu.singleplayer.create.start"), skin);
  back = MenuTools.getBackButton(this);

  start.addListener(startListener = new ChangeListener() {
    @Override
    public void changed(ChangeEvent event, Actor actor) {
      Adapter.setMenu(new SingleplayerLoadingMenu(ClientSaveManager.createSave(name.getText(), generator.getSelected().id, mode.getSelected(), seed.getText())));
    }
  });

  stage.addActor(title);
  stage.addActor(name);
  stage.addActor(generator);
  stage.addActor(mode);
  stage.addActor(seed);
  stage.addActor(start);
  stage.addActor(back);
}
 
Example #28
Source File: StringInputPanel.java    From bladecoder-adventure-engine with Apache License 2.0 4 votes vote down vote up
public void setText(String s) {
	((TextField)field).setText(s);
}
 
Example #29
Source File: StringInputPanel.java    From bladecoder-adventure-engine with Apache License 2.0 4 votes vote down vote up
public String getText() {
	String text = ((TextField)field).getText();
	return text.isEmpty()?null:text;
}
 
Example #30
Source File: StringInputPanel.java    From bladecoder-adventure-engine with Apache License 2.0 4 votes vote down vote up
StringInputPanel(Skin skin, String title, String desc, boolean mandatory, String defaultValue) {
	input = new TextField("", skin);
	init(skin, title, desc, input, mandatory, defaultValue);
}