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

The following examples show how to use com.badlogic.gdx.scenes.scene2d.ui.TextButton. 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: ScopePanel.java    From bladecoder-adventure-engine with 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 #2
Source File: SystemProfilerGUI.java    From riiablo with 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 #3
Source File: PdAudioRemoteTest.java    From gdx-pd with 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 #4
Source File: PdAudioRemoteTest.java    From gdx-pd with 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 #5
Source File: PdAudioRemoteTest.java    From gdx-pd with 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 #6
Source File: VerbUI.java    From bladecoder-adventure-engine with 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 File: ResumeVsJoinTest.java    From gdx-ai with 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 #8
Source File: NinePatchEditorDialog.java    From gdx-skineditor with 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 #9
Source File: TabPanel.java    From bladecoder-adventure-engine with 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 #10
Source File: InfoTable.java    From skin-composer with 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 #11
Source File: ParallelVsSequenceTest.java    From gdx-ai with 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 #12
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 #13
Source File: CalibrationScreen.java    From buffer_bci with 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 #14
Source File: SingleplayerSaveDeleteMenu.java    From Cubes with 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 #15
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 #16
Source File: ToggleOption.java    From Radix with 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 #17
Source File: ScreenPause.java    From RuinsOfRevenge with MIT License 5 votes vote down vote up
public ScreenPause(final ResourceLoader resources, final RuinsOfRevenge game) {
	super(new Stage(), game);
	this.resources = resources;
	this.game = game;

	skin = resources.getSkin("uiskin");

	TextButton play = new TextButton("Continue Playing", skin);
	TextButton settings = new TextButton("Settings", skin);
	TextButton backToMM = new TextButton("Back to Main Menu", skin);

	play.addListener(continueListener);
	settings.addListener(settingsListener);
	backToMM.addListener(backToMMListener);

	table = new Table(skin);
	table.add(play).size(320, 64).space(8);
	table.row();
	table.add(settings).size(320, 64).space(8);
	table.row();
	table.add(backToMM).size(320, 64).space(8);
	table.setPosition(Gdx.graphics.getWidth()/2, Gdx.graphics.getHeight()/2);
	stage.addActor(table);
	stage.addListener(new KeyUpListener() {
		@Override
		public boolean keyUp(InputEvent event, int keycode) {
			if (keycode == Config.get().key("escape"))
				game.popScreen();
			return false;
		}
	});
}
 
Example #18
Source File: PauseMenuUI.java    From Norii with 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 #19
Source File: UIUtils.java    From uracer-kotd with 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 #20
Source File: ScreenMenu.java    From RuinsOfRevenge with MIT License 5 votes vote down vote up
public ScreenMenu(final ResourceLoader resources, final RuinsOfRevenge game) {
	super(new Stage(), game);
	this.resources = resources;
	this.game = game;
	this.background = resources.getRegion("background");
	background.getTexture().setFilter(TextureFilter.Linear, TextureFilter.Linear);
	this.ruinsOfRevengeText = resources.getRegion("RuinsOfRevenge");

	skin = resources.getSkin("uiskin");

	Image rorLogo = new Image(ruinsOfRevengeText);
	TextButton play = new TextButton("Play", skin);
	TextButton settings = new TextButton("Settings", skin);
	TextButton exit = new TextButton("Exit", skin);

	play.addListener(playListener);
	settings.addListener(settingsListener);
	exit.addListener(exitListener);

	table = new Table(skin);
	table.add(rorLogo).size(600, 200).space(32);
	table.row();
	table.add(play).size(320, 64).space(8);
	table.row();
	table.add(settings).size(320, 64).space(8);
	table.row();
	table.add(exit).size(320, 64).space(8);
	table.setPosition(Gdx.graphics.getWidth()/2, Gdx.graphics.getHeight()/2);
	stage.addActor(table);
}
 
Example #21
Source File: GLTFDemoUI.java    From gdx-gltf with 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 #22
Source File: PdAudioRemoteTest.java    From gdx-pd with 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 #23
Source File: InventoryActor.java    From libgdx-utils with 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 #24
Source File: MainMenu.java    From Codelabs with 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 #25
Source File: MainMenu.java    From Codelabs with 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 #26
Source File: ScopePanel.java    From bladecoder-adventure-engine with 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());
		}
	});
}
 
Example #27
Source File: BooleanSetting.java    From Cubes with MIT License 5 votes vote down vote up
@Override
public Actor getActor(String settingName, VisualSettingManager visualSettingManager) {
  final TextButton textButton = new TextButton(b ? "True" : "False", visualSettingManager.getSkin());
  textButton.addListener(new ChangeListener() {
    @Override
    public void changed(ChangeEvent event, Actor actor) {//easier than SettingsMenu.SaveEvent and works
      set(!get());
      textButton.setText(b ? "True" : "False");
    }
  });
  return textButton;
}
 
Example #28
Source File: InfoMenu.java    From Cubes with MIT License 5 votes vote down vote up
public InfoMenu(String labelText, String buttonText) {
  super();
  text = new Label(labelText, new LabelStyle(Fonts.hud, Color.WHITE));
  text.setAlignment(Align.center, Align.center);
  button = new TextButton(buttonText, skin);

  stage.addActor(text);
  stage.addActor(button);
}
 
Example #29
Source File: MenuTools.java    From Cubes with MIT License 5 votes vote down vote up
public static TextButton getBackButton(final Menu menu) {
  TextButton textButton = new TextButton(Localization.get("menu.general.back"), Menu.skin);
  textButton.addListener(new ChangeListener() {
    @Override
    public void changed(ChangeEvent event, Actor actor) {
      Menu prev = MenuManager.getPrevious(menu);
      if (prev == null) return;
      Adapter.setMenu(prev);
    }
  });
  return textButton;
}
 
Example #30
Source File: SettingGroup.java    From Cubes with MIT License 5 votes vote down vote up
public Actor getActor(final VisualSettingManager visualSettingManager) {
  final TextButton textButton = new TextButton(Localization.get("menu.settings.open_group"), visualSettingManager.getSkin());
  textButton.addListener(new ChangeListener() {
    @Override
    public void changed(ChangeEvent event, Actor actor) {
      visualSettingManager.setSettingGroup(SettingGroup.this);
    }
  });
  return textButton;
}