Java Code Examples for com.badlogic.gdx.scenes.scene2d.ui.TextButton

The following examples show how to use com.badlogic.gdx.scenes.scene2d.ui.TextButton. These examples are extracted from open source projects. 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 Project: skin-composer   Source File: InfoTable.java    License: MIT License 6 votes vote down vote up
public InfoTable(final Skin skin, final Stage stage) {
    pad(10.0f);
    
    var label = new Label(Core.readAndReplace("about.txt"), skin, "small");
    label.setWrap(true);
    label.setTouchable(Touchable.disabled);
    add(label).growX().expandY().top();
    
    row();
    var textButton = new TextButton("OK", skin);
    add(textButton).growX().height(30.0f);
    textButton.addListener(new ChangeListener() {
        @Override
        public void changed(ChangeListener.ChangeEvent event, Actor actor) {
            Core.transition(InfoTable.this, new MenuTable(skin, stage));
        }
    });
}
 
Example 2
Source Project: gdx-pd   Source File: PdAudioRemoteTest.java    License: Apache License 2.0 6 votes vote down vote up
private void testSendArray(String label, final String name, final int position, final float...values)
{
	String valText = "";
	if(values.length < 8)
		for(float v : values) valText += "," + String.valueOf(v);
	else
		valText = ",...";
	if(valText.length()>0) valText = "(" + valText.substring(1) + ")";
	valText = "at " + String.valueOf(position) + " " + valText;
	TextButton bt = new TextButton(label + " " + valText, skin);
	bt.addListener(new ChangeListener() {
		@Override
		public void changed(ChangeEvent event, Actor actor) {
			Pd.audio.writeArray(name, position, values, 0, values.length);
		}
	});
	table.add("Write array to " + name);
	table.add(bt);
	table.row();
}
 
Example 3
Source Project: gdx-pd   Source File: PdAudioRemoteTest.java    License: Apache License 2.0 6 votes vote down vote up
private void testSendList(String label, final Object...values)
{
	String valText = "";
	for(Object v : values) valText += "," + v.toString();
	valText = "(" + valText.substring(1) + ")";
	
	TextButton bt = new TextButton(label + " " + valText, skin);
	bt.addListener(new ChangeListener() {
		
		@Override
		public void changed(ChangeEvent event, Actor actor) {
			Pd.audio.sendList("recv_list", values);
		}
	});
	table.add("Send List on recv_list");
	table.add(bt);
	table.row();
}
 
Example 4
Source Project: gdx-pd   Source File: PdAudioRemoteTest.java    License: Apache License 2.0 6 votes vote down vote up
private void testSendMessage(String label, final Object...values)
{
	String valText = "";
	for(Object v : values) valText += "," + v.toString();
	valText = "(" + valText.substring(1) + ")";
	
	TextButton bt = new TextButton(label + " " + valText, skin);
	bt.addListener(new ChangeListener() {
		
		@Override
		public void changed(ChangeEvent event, Actor actor) {
			Pd.audio.sendMessage("recv_msg", "test", values);
		}
	});
	table.add("Send Message on recv_msg");
	table.add(bt);
	table.row();
}
 
Example 5
Source Project: riiablo   Source File: SystemProfilerGUI.java    License: Apache License 2.0 6 votes vote down vote up
public SystemProfilerGUI(Skin skin, String style) {
  super("Profiler", skin, style);
  this.skin = skin;

  setVisible(false);
  setResizable(true);
  setResizeBorder(12);
  TextButton closeButton = new TextButton("X", skin);
  getTitleTable().add(closeButton).padRight(3);
  closeButton.addListener(new ClickListener() {
    @Override
    public void clicked(InputEvent event, float x, float y) {
      hide();
    }
  });
}
 
Example 6
Source Project: bladecoder-adventure-engine   Source File: VerbUI.java    License: Apache License 2.0 6 votes vote down vote up
private Table createVerbPanel() {
	Table verbs = new Table();

	verbs.defaults().pad(MARGIN);

	for (int i = 0; i < VERBS.size(); i++) {
		if (i % VERB_COLS == 0)
			verbs.row();

		TextButton b = new TextButton(VERBS_DESC.get(i), style.verbButtonStyle);
		b.setName(VERBS.get(i));
		b.addListener(new ClickListener() {
			@Override
			public void clicked(InputEvent event, float x, float y) {
				currentVerb = event.getListenerActor().getName();
				infoLine.setText(((TextButton) event.getListenerActor()).getText());
				target = null;
			}
		});

		verbs.add(b).fill().expand();
	}

	return verbs;
}
 
Example 7
Source Project: bladecoder-adventure-engine   Source File: TabPanel.java    License: Apache License 2.0 6 votes vote down vote up
public void addTab(String name, Actor panel) {
	Button button = new TextButton(name, skin);
	buttonGroup.add(button);
	header.addActor(button);
	tabs.add(new Tab(button, panel));
	
	button.addListener(new ClickListener() {
		
		@Override
		public void clicked (InputEvent event, float x, float y) {
			setTab((Button)event.getListenerActor());
		}
	});
	
	if(tabs.size() == 1)
		setTab(0);
}
 
Example 8
Source Project: bladecoder-adventure-engine   Source File: ScopePanel.java    License: Apache License 2.0 6 votes vote down vote up
public ScopePanel(Skin skin) {
	super(skin);
	this.skin = skin;
	buttonGroup = new ButtonGroup<TextButton>();
	hPanel = new HorizontalGroup();
	hPanel.wrap(true);
	hPanel.rowAlign(Align.left);
	
	buttonGroup.setMaxCheckCount(1);
	buttonGroup.setMinCheckCount(1);
	buttonGroup.setUncheckLast(true);
	
	hPanel.addActor(new Label("Scope: ", skin));
	
	addButton(WORLD_SCOPE);
	addButton(SCENE_SCOPE);
	addButton(ACTOR_SCOPE);
	
	add(hPanel).expandX().fillX().center();
	
	buttonGroup.getButtons().get(2).setChecked(true);
}
 
Example 9
Source Project: Cubes   Source File: ServerSetupMenu.java    License: 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 10
Source Project: Cubes   Source File: SingleplayerSaveDeleteMenu.java    License: MIT License 6 votes vote down vote up
public SingleplayerSaveDeleteMenu(final Save save) {
  title = new Label(Localization.get("menu.singleplayer.delete.title"), skin.get("title", Label.LabelStyle.class));
  text = new Label(Localization.get("menu.singleplayer.delete.text", save.name), skin);
  delete = new TextButton(Localization.get("menu.singleplayer.delete.delete", save.name), skin);
  back = MenuTools.getBackButton(this);

  text.setAlignment(Align.center);

  delete.addListener(new ChangeListener() {
    @Override
    public void changed(ChangeEvent event, Actor actor) {
      ClientSaveManager.deleteSave(save);
      Menu prev = MenuManager.getPrevious(SingleplayerSaveDeleteMenu.this);
      if (!(prev instanceof SingleplayerSavesMenu)) return;
      ((SingleplayerSavesMenu) prev).updateSavesList();
      Adapter.setMenu(prev);
    }
  });

  stage.addActor(title);
  stage.addActor(text);
  stage.addActor(delete);
  stage.addActor(back);
}
 
Example 11
Source Project: Cubes   Source File: MultiplayerConnectMenu.java    License: 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 12
Source Project: gdx-ai   Source File: ParallelVsSequenceTest.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public Actor createActor (final Skin skin) {
	Table table = new Table();

	LabelStyle labelStyle = new LabelStyle(skin.get(LabelStyle.class));
	labelStyle.background = skin.newDrawable("white", .6f, .6f, .6f, 1);
	String branchChildren = "\n    selectTarget\n    pursue";
	table.add(new Label("parallel policy:\"sequence\" orchestrator:\"resume\"" + branchChildren, labelStyle)).pad(5);
	table.add(new Label("vs", skin)).padLeft(10).padRight(10);
	table.add(new Label("sequence" + branchChildren, labelStyle)).pad(5);

	table.row().padTop(15);

	TextButton startButton = new TextButton("Start", skin);
	startButton.addListener(new ChangeListener() {
		@Override
		public void changed (ChangeEvent event, Actor actor) {
			oldScreen = container.getScreen();
			container.setScreen(new TestScreen(ParallelVsSequenceTest.this, skin));
		}
	});
	table.add();
	table.add(startButton);
	table.add();
	return table;
}
 
Example 13
Source Project: gdx-ai   Source File: ResumeVsJoinTest.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public Actor createActor (final Skin skin) {
	Table table = new Table();

	LabelStyle labelStyle = new LabelStyle(skin.get(LabelStyle.class));
	labelStyle.background = skin.newDrawable("white", .6f, .6f, .6f, 1);
	String branchChildren = "\n    spinAround\n    selectTarget\n    pursue";
	table.add(new Label("parallel policy:\"sequence\" orchestrator:\"resume\"" + branchChildren, labelStyle)).pad(5);
	table.add(new Label("vs", skin)).padLeft(10).padRight(10);
	table.add(new Label("parallel policy:\"sequence\" orchestrator:\"join\"" + branchChildren, labelStyle)).pad(5);

	table.row().padTop(15);

	TextButton startButton = new TextButton("Start", skin);
	startButton.addListener(new ChangeListener() {
		@Override
		public void changed (ChangeEvent event, Actor actor) {
			oldScreen = container.getScreen();
			container.setScreen(new TestScreen(ResumeVsJoinTest.this, skin));
		}
	});
	table.add();
	table.add(startButton);
	table.add();
	return table;
}
 
Example 14
Source Project: gdx-skineditor   Source File: NinePatchEditorDialog.java    License: Apache License 2.0 6 votes vote down vote up
private void reviewTablePreview() {
	tablePreview.clear();
	//tablePreview.debug();
	tablePreview.center().left();
	
	TextButtonStyle stylePreview = new TextButton.TextButtonStyle();
	stylePreview.font = game.skin.getFont("default-font");
	buttonPreview1 = new TextButton("1x Button", stylePreview);
	buttonPreview1.setSize(imgWidth, imgHeight);
	cellPreview1 = tablePreview.add(buttonPreview1).width(buttonPreview1.getWidth()).height(buttonPreview1.getHeight()).padBottom(15);
	tablePreview.row();

	buttonPreview2 = new TextButton("2x Button", stylePreview);
	buttonPreview2.setSize(imgWidth * 2.0f, imgHeight * 2.0f);
	cellPreview2 = tablePreview.add(buttonPreview2).width(buttonPreview2.getWidth()).height(buttonPreview2.getHeight()).padBottom(15);
	tablePreview.row();

	buttonPreview3 = new TextButton("3x Button", stylePreview);
	buttonPreview3.setSize(imgWidth * 3.0f, imgHeight * 3.0f);
	cellPreview3 = tablePreview.add(buttonPreview3).width(buttonPreview3.getWidth()).height(buttonPreview3.getHeight()).padBottom(15);
	tablePreview.row();
	
}
 
Example 15
Source Project: buffer_bci   Source File: CalibrationScreen.java    License: GNU General Public License v3.0 6 votes vote down vote up
/**
 * Adds exit button with listener in right bottom corner
 */
private void createBackButton() {
    // Create Button
    backButton = new TextButton("EXIT", VisUI.getSkin());

    // Set position in bottom right corner
    backButton.setX(Gdx.graphics.getWidth()-60);
    backButton.setY(0);
    backButton.setWidth(60);
    backButton.setHeight(60);
    backButton.setVisible(true);

    // Add Listener that sets the screen to the start screen of the game when button is clicked
    backButton.addListener(new ClickListener(){
        @Override
        public void clicked(InputEvent event, float x, float y) {
            StandardizedInterface.getInstance().StimuliSystem.stopStimulus();
            frameCounter = 0;
            game.setScreen(new MainMenuScreen(game));
        }
    });

    // Add Button to stage
    stage.addActor(backButton);
}
 
Example 16
Source Project: gdx-gltf   Source File: GLTFDemoUI.java    License: Apache License 2.0 5 votes vote down vote up
private void addMaterialTextureSwitch(String name, final Material material, long type){
	final PBRTextureAttribute attribute = material.get(PBRTextureAttribute.class, type);
	if(attribute != null){
		final TextButton bt = new TextButton(name, getSkin(), "toggle");
		bt.setChecked(true);
		materialTable.add(bt);
		
		Image pict = new Image(attribute.textureDescription.texture);
		
		pict.setScaling(Scaling.fit);
		
		materialTable.add(pict).size(64);
		
		materialTable.row();
		
		bt.addListener(new ChangeListener() {
			@Override
			public void changed(ChangeEvent event, Actor actor) {
				if(bt.isChecked()){
					material.set(attribute);
				}else{
					material.remove(attribute.type);
				}
			}
		});
	}
	
}
 
Example 17
Source Project: gdx-gltf   Source File: CollapsableUI.java    License: Apache License 2.0 5 votes vote down vote up
public CollapsableUI(Skin skin, String name, boolean visible) {
	toggle = new TextButton(name, skin, "toggle");
	toggle.setChecked(visible);
	add(toggle).row();
	optTable = new Table(skin);
	optCell = add();
	row();
	show(visible);
	toggle.addListener(new ChangeListener() {
		@Override
		public void changed(ChangeEvent event, Actor actor) {
			show(toggle.isChecked());
		}
	});
}
 
Example 18
Source Project: uracer-kotd   Source File: UIUtils.java    License: Apache License 2.0 5 votes vote down vote up
public static TextButton newButton (String text, ClickListener listener) {
	TextButton b = new TextButton(text, Art.scrSkin);
	if (listener != null) {
		b.addListener(listener);
	}
	return b;
}
 
Example 19
Source Project: Norii   Source File: PauseMenuUI.java    License: Apache License 2.0 5 votes vote down vote up
private void createUI() {
	final Skin statusUISkin = Utility.getStatusUISkin();
	title = new Label("Pause", statusUISkin);
	title.setFontScale(TITLE_FONT_SCALE);
	resumeButton = new TextButton("Resume", statusUISkin);
	settingButton = new TextButton("Settings", statusUISkin);
	mainMenuButton = new TextButton("Main Menu", statusUISkin);
}
 
Example 20
Source Project: Norii   Source File: MainMenuScreen.java    License: Apache License 2.0 5 votes vote down vote up
private void createButtons() {
	final Skin statusUISkin = Utility.getStatusUISkin();
	final LabelStyle labelStyle = createTitleStyle();

	title = new Label("Norii:", labelStyle);
	newGameButton = new TextButton("New Game", statusUISkin);
	exitButton = new TextButton("Exit", statusUISkin);
}
 
Example 21
private EventListener createListener(final Creature creature, final TextButton button, final WorldObjectView view, final Image selection) {
    return new ClickListener() {
        @Override public void clicked(InputEvent event, float x, float y) {
            view.addActor(selection);
            selection.toBack();
            selected = creature;
            button.setDisabled(false);
        }
    };
}
 
Example 22
private ClickListener createListener(final Ability ability, final TextButton button, final Image itemSelection, final Group icon, final LocLabel itemDescriptionLabel) {
    return new ClickListener() {
        @Override public void clicked(InputEvent event, float x, float y) {
            selected = ability;
            icon.addActor(itemSelection);
            itemSelection.toBack();
            button.setDisabled(false);
            itemDescriptionLabel.setParams(Thesaurus.params().with("name", ability.locNameKey()).with("desc", ability.locDescKey()));
        }
    };
}
 
Example 23
Source Project: dice-heroes   Source File: InvitesWindow.java    License: GNU General Public License v3.0 5 votes vote down vote up
public void setPlayers(Array<String> players) {
    list.clear();
    for (String player : players) {
        TextButton button = new TextButton(player, Config.skin);
        button.addListener(createListener(player));
        list.add(button).row();
    }
}
 
Example 24
Source Project: gdx-pd   Source File: PdAudioRemoteTest.java    License: Apache License 2.0 5 votes vote down vote up
private void testSendSymbol(String label, final String symbol)
{
	TextButton bt = new TextButton(label + " (" + symbol + ")", skin);
	bt.addListener(new ChangeListener() {
		
		@Override
		public void changed(ChangeEvent event, Actor actor) {
			Pd.audio.sendSymbol("recv_sym", symbol);
		}
	});
	table.add("Send Symbol on recv_sym");
	table.add(bt);
	table.row();
}
 
Example 25
Source Project: gdx-pd   Source File: PdAudioRemoteTest.java    License: Apache License 2.0 5 votes vote down vote up
private void actionTest(String label, final ActionHandler<?> runnable) {
	TextButton bt = new TextButton("test", skin);
	bt.addListener(new ChangeListener() {
		
		@Override
		public void changed(ChangeEvent event, Actor actor) {
			runnable.run(null);
		}
	});
	table.add(label);
	table.add(bt);
	table.row();
}
 
Example 26
Source Project: Radix   Source File: ToggleOption.java    License: MIT License 5 votes vote down vote up
@Override
public Actor getManipulationActor() {
    TextButton button = new TextButton(String.format("%s: %s", title, getValueStr()), RadixClient.getInstance().getSceneTheme().getButtonStyle());
    button.addListener(new ClickListener() {
        @Override
        public void clicked (InputEvent event, float x, float y) {
            ToggleOption.this.value = !ToggleOption.this.value;
            button.setText(String.format("%s: %s", title, getValueStr()));
        }
    });
    return button;
}
 
Example 27
Source Project: libgdx-utils   Source File: InventoryActor.java    License: MIT License 5 votes vote down vote up
public InventoryActor(Inventory inventory, DragAndDrop dragAndDrop, Skin skin) {
	super("Inventory...", skin);

	TextButton closeButton = new TextButton("X", skin);
	closeButton.addListener(new HidingClickListener(this));
	getButtonTable().add(closeButton).height(getPadTop());

	setPosition(400, 100);
	defaults().space(8);
	row().fill().expandX();

	int i = 0;
	for (Slot slot : inventory.getSlots()) {
		SlotActor slotActor = new SlotActor(skin, slot);
		dragAndDrop.addSource(new SlotSource(slotActor));
		dragAndDrop.addTarget(new SlotTarget(slotActor));
		add(slotActor);

		i++;
		if (i % 5 == 0) {
			row();
		}
	}

	pack();

	// it is hidden by default
	setVisible(false);
}
 
Example 28
Source Project: Codelabs   Source File: MainMenu.java    License: MIT License 5 votes vote down vote up
private void addSampleButtons(List<TextButton> textButtons) {
	int columnCounter = 0;

	for (TextButton textButton : textButtons) {
		table.add(textButton).fill();

		if (++columnCounter >= MAX_TABLE_COLUMNS) {
			columnCounter = 0;
			table.row();
		}
	}

}
 
Example 29
Source Project: Codelabs   Source File: MainMenu.java    License: MIT License 5 votes vote down vote up
private TextButton createTextButton(String text, Skin skin,
		String styleName, EventListener listener) {
	TextButton textButton = new TextButton(text, skin, styleName);
	textButton.pad(10);
	textButton.addListener(listener);

	return textButton;
}
 
Example 30
Source Project: bladecoder-adventure-engine   Source File: ScopePanel.java    License: Apache License 2.0 5 votes vote down vote up
private void addButton(String name) {
	TextButton button = new TextButton(name, skin);
	buttonGroup.add(button);
	hPanel.addActor(button);
	
	button.addListener(new ClickListener() {
		
		@Override
		public void clicked (InputEvent event, float x, float y) {
			changeScope((TextButton)event.getListenerActor());
		}
	});
}