Java Code Examples for com.badlogic.gdx.scenes.scene2d.ui.Table#setFillParent()

The following examples show how to use com.badlogic.gdx.scenes.scene2d.ui.Table#setFillParent() . 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: TestFloatingGroup.java    From vis-ui with Apache License 2.0 6 votes vote down vote up
@Override
public void create () {
	VisUI.load();

	stage = new Stage(new ScreenViewport());
	final Table root = new Table();
	root.setFillParent(true);
	stage.addActor(root);

	TestWindow window = new TestWindow();
	TestCollapsible collapsible = new TestCollapsible();
	window.setKeepWithinParent(true);
	window.setPosition(110, 110);
	collapsible.setKeepWithinParent(true);
	collapsible.setPosition(200, 200);

	FloatingGroup floatingGroup = new FloatingGroup(1000, 600);
	floatingGroup.addActor(window);
	floatingGroup.addActor(collapsible);

	root.debugAll();
	root.left().bottom();
	root.add(floatingGroup).padLeft(100).padBottom(100);

	Gdx.input.setInputProcessor(stage);
}
 
Example 2
Source File: CardDeckApplication.java    From androidsvgdrawable-plugin with Apache License 2.0 5 votes vote down vote up
private void initializeAssets() {
    skin = manager.get("skin.json", Skin.class);
    atlas = manager.get("skin.atlas", TextureAtlas.class);

    // layout
    Table table = new Table();
    table.pad(10);
    table.defaults().space(10);
    table.setFillParent(true);

    // header
    table.row();
    table.add(new Label("LibGDX Card Deck", skin, "cantarell")).colspan(RANKS.length);

    // deck
    for (String suit : SUITS) {
        table.row();
        for (String rank : RANKS) {
            table.add(
                    new Image(
                            new SpriteDrawable(atlas.createSprite(String.format("card1_suit_%s_rank_%s", suit, rank))),
                            Scaling.fit));
        }
    }

    stage.addActor(table);
}
 
Example 3
Source File: StatusBar.java    From ninja-rabbit with GNU General Public License v2.0 5 votes vote down vote up
public StatusBar(final Batch batch, final AssetManager assets) {
	overlay = new Stage(new ScreenViewport(), batch);

	Label.LabelStyle style = new Label.LabelStyle();
	style.fontColor = Color.WHITE;
	style.font = assets.get(Assets.HUD_FONT);
	style.font.setFixedWidthGlyphs(NUMBER_GLYPHS);

	collectiblesLabel = new Label(String.format(TWO_DIGITS, 0), style);
	livesLabel = new Label(String.format(TWO_DIGITS, 0), style);
	scoreLabel = new Label(String.format(EIGHT_DIGITS, 0), style);
	timeLabel = new Label(String.format(THREE_DIGITS, 0), style);

	TextureAtlas hudAtlas = assets.get(Assets.NINJA_RABBIT_ATLAS);

	Table table = new Table();
	table.add(new Image(hudAtlas.findRegion(SMALL_CARROT_REGION))).padRight(8.0f);
	table.add(collectiblesLabel).bottom();
	table.add(new Image(hudAtlas.findRegion(LIVES_REGION))).padLeft(15.0f);
	table.add(livesLabel).bottom();
	table.add(scoreLabel).expandX();
	table.add(new Image(hudAtlas.findRegion(TIME_REGION))).padRight(12.0f);
	table.add(timeLabel);
	table.setFillParent(true);
	table.top();
	table.pad(15.0f);

	overlay.addActor(table);
}
 
Example 4
Source File: GameOverOverlay.java    From ninja-rabbit with GNU General Public License v2.0 5 votes vote down vote up
public GameOverOverlay(final Batch batch, final AssetManager assets) {
	stage = new Stage(new ScreenViewport(), batch);
	Label.LabelStyle style = new Label.LabelStyle();
	style.fontColor = Color.WHITE;
	style.font = assets.get(Assets.HUD_FONT);
	Label gameOver = new Label(GAME_OVER_TEXT, style);

	Table table = new Table();
	table.setFillParent(true);
	table.add(gameOver).expand();

	stage.addActor(table);
	overlay = new ShapeRenderer();

}
 
Example 5
Source File: ExampleMain.java    From gdx-smart-font with MIT License 5 votes vote down vote up
@Override
public void create() {
	Gdx.app.setLogLevel(Application.LOG_DEBUG);
	SmartFontGenerator fontGen = new SmartFontGenerator();
	FileHandle exoFile = Gdx.files.local("LiberationMono-Regular.ttf");
	BitmapFont fontSmall = fontGen.createFont(exoFile, "exo-small", 24);
	BitmapFont fontMedium = fontGen.createFont(exoFile, "exo-medium", 48);
	BitmapFont fontLarge = fontGen.createFont(exoFile, "exo-large", 64);

	stage = new Stage();

	Label.LabelStyle smallStyle = new Label.LabelStyle();
	smallStyle.font = fontSmall;
	Label.LabelStyle mediumStyle = new Label.LabelStyle();
	mediumStyle.font = fontMedium;
	Label.LabelStyle largeStyle = new Label.LabelStyle();
	largeStyle.font = fontLarge;

	Label small = new Label("Small Font", smallStyle);
	Label medium = new Label("Medium Font", mediumStyle);
	Label large = new Label("Large Font", largeStyle);

	Table table = new Table();
	table.setFillParent(true);
	table.align(Align.center);
	stage.addActor(table);

	table.defaults().size(Gdx.graphics.getWidth() / 2, Gdx.graphics.getHeight() / 6);

	table.add(small).row();
	table.add(medium).row();
	table.add(large).row();
}
 
Example 6
Source File: VisualSettingsMenu.java    From Radix with MIT License 5 votes vote down vote up
@Override
public void init() {
    VisualSettings visualSettings = RadixClient.getInstance().getSettingsManager().getVisualSettings();

    stage = new Stage();

    Table table = new Table();
    table.setFillParent(true);
    table.add(visualSettings.getFancyTrees().getManipulationActor());
    table.add(visualSettings.getPerCornerLight().getManipulationActor());
    table.row();
    table.add(visualSettings.getNonContinuous().getManipulationActor());
    table.add(visualSettings.getFinishEachFrame().getManipulationActor());
    stage.addActor(table);
}
 
Example 7
Source File: MenuState.java    From Entitas-Java with MIT License 5 votes vote down vote up
@Override
public void loadResources() {
    assetsManager = engine.getManager(BaseAssetsManager.class);
    this.stage = new Stage();
    mainTable = new Table();
    mainTable.setFillParent(true);
    stage.clear();
    stage.getViewport().update(Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), true);
    this.stage.addActor(mainTable);
    Gdx.input.setInputProcessor(stage);
    Gdx.app.log("Menu", "LoadResources");
}
 
Example 8
Source File: MainMenuScreen.java    From Norii with Apache License 2.0 5 votes vote down vote up
private void initializeClassVariables() {
	playerMonsters = new ArrayList<Entity>();
	stage = new Stage();
	mainMenuTableOfButtons = new Table();
	mainMenuTableOfButtons.setFillParent(true);
	selectedLevel = AITeams.DESERT_TEAM;
}
 
Example 9
Source File: UIStage.java    From talos with Apache License 2.0 5 votes vote down vote up
public void init () {
	fullScreenTable = new Table();
	fullScreenTable.setFillParent(true);

	stage.addActor(fullScreenTable);

	defaults();
	constructMenu();
	constructTabPane();
	constructSplitPanes();

	initFileChoosers();

	batchConvertDialog = new BatchConvertDialog();
	settingsDialog = new SettingsDialog();

	FileHandle list = Gdx.files.internal("modules.xml");
	XmlReader xmlReader = new XmlReader();
	XmlReader.Element root = xmlReader.parse(list);
	WrapperRegistry.map.clear();
	moduleListPopup = new ModuleListPopup(root);

	colorPicker = new ColorPicker();
	colorPicker.padTop(32);
	colorPicker.padLeft(16);
	colorPicker.setHeight(330);
	colorPicker.setWidth(430);
	colorPicker.padRight(26);
}
 
Example 10
Source File: DepthScreen.java    From xibalba with MIT License 5 votes vote down vote up
/**
 * Screen for depth transitions.
 */
public DepthScreen() {
  stage = new Stage(new FitViewport(960, 540));

  Table table = new Table();
  table.setFillParent(true);
  stage.addActor(table);

  Label label = new Label(
      "Going " + (WorldManager.state == WorldManager.State.GOING_DOWN ? "Down" : "Up"),
      Main.skin
  );
  table.add(label);
}
 
Example 11
Source File: GeneratingWorldScreen.java    From xibalba with MIT License 5 votes vote down vote up
/**
 * World generation screen.
 *
 * @param main        Instance of Main
 * @param playerSetup Holds data for player creation
 */
public GeneratingWorldScreen(Main main, PlayerSetup playerSetup) {
  this.main = main;
  this.playerSetup = playerSetup;

  stage = new Stage(new FitViewport(960, 540));

  Table table = new Table();
  table.setFillParent(true);
  stage.addActor(table);

  table.add(new Label("HUN-CAME IS PREPARING.", Main.skin));

  new Thread(() -> Gdx.app.postRunnable(this::generateWorld)).start();
}
 
Example 12
Source File: PauseScreen.java    From xibalba with MIT License 5 votes vote down vote up
/**
 * Main Menu Screen.
 *
 * @param main Instance of main class
 */
public PauseScreen(Main main) {
  stage = new Stage(new FitViewport(960, 540));

  Table table = new Table();
  table.setFillParent(true);
  stage.addActor(table);

  ActionButton returnToGameButton = new ActionButton("ESC", "Return to Game");
  returnToGameButton.setKeys(Input.Keys.ESCAPE);
  returnToGameButton.setAction(table, () -> main.setScreen(Main.playScreen));

  ActionButton mainMenuButton = new ActionButton("M", "Main Menu");
  mainMenuButton.setKeys(Input.Keys.M);
  mainMenuButton.setAction(table, () -> {
    Main.playScreen.dispose();
    main.setScreen(new MainMenuScreen(main));
  });

  ActionButton quitButton = new ActionButton("Q", "Quit");
  quitButton.setKeys(Input.Keys.Q);
  quitButton.setAction(table, () -> Gdx.app.exit());

  table.add(new Label("[LIGHT_GRAY]PAUSED[]", Main.skin)).pad(0, 0, 10, 0);
  table.row();
  table.add(returnToGameButton).pad(0, 0, 10, 0);
  table.row();
  table.add(mainMenuButton).pad(0, 0, 10, 0);
  table.row();
  table.add(quitButton);

  Gdx.input.setInputProcessor(stage);
  stage.setKeyboardFocus(table);
}
 
Example 13
Source File: BehaviorTreeTests.java    From gdx-ai with Apache License 2.0 5 votes vote down vote up
public MainScreen() {
	Gdx.gl.glClearColor(.3f, .3f, .3f, 1);

	skin = new Skin(Gdx.files.internal("data/uiskin.json"));

	stage = new Stage(new ScreenViewport());
	stage.setDebugAll(DEBUG_STAGE);

	// Create split pane
	List<String> testList = createTestList();
	ScrollPane leftScrollPane = new ScrollPane(testList, skin);
	splitPane = new SplitPane(leftScrollPane, null, false, skin, "default-horizontal");
	splitPane.setSplitAmount(Math.min((testList.getPrefWidth() + 10) / stage.getWidth(), splitPane.getSplitAmount()));

	// Create layout
	Table t = new Table(skin);
	t.setFillParent(true);
	t.add(splitPane).colspan(3).grow();
	t.row();
	t.add(pauseButton = new PauseButton(skin)).width(90).left();
	t.add(new FpsLabel("FPS: ", skin)).left();
	t.add(testDescriptionLabel = new Label("", skin)).left();
	stage.addActor(t);

	// Set selected test
	changeTest(0);
}
 
Example 14
Source File: LoadingScreen.java    From xibalba with MIT License 5 votes vote down vote up
/**
 * Loading screen.
 *
 * @param main Instance of Main
 */
public LoadingScreen(Main main) {
  this.main = main;

  stage = new Stage(new FitViewport(960, 540));

  Table table = new Table();
  table.setFillParent(true);
  stage.addActor(table);

  label = new Label("", Main.skin);
  table.add(label);

  new Thread(() -> Gdx.app.postRunnable(this::loadAssets)).start();
}
 
Example 15
Source File: MainMenuInterface.java    From buffer_bci with GNU General Public License v3.0 4 votes vote down vote up
private void createTable() {
	table = new Table();
	table.setFillParent(true);
	table.align(Align.left);
	stage.addActor(table);
}
 
Example 16
Source File: GLTFDemo.java    From gdx-gltf with Apache License 2.0 4 votes vote down vote up
private void load(ModelEntry entry, String variant) {
	
	clearScene();
	
	if(rootModel != null){
		rootModel.dispose();
		rootModel = null;
		if(lastFileName != null){
			if(USE_ASSET_MANAGER){
				assetManager.unload(lastFileName);
			}
			lastFileName = null;
		}
	}
	
	
	if(variant.isEmpty()) return;
	
	final String fileName = entry.variants.get(variant);
	if(fileName == null) return;
	
	if(entry.url != null){
		
		final Table waitUI = new Table(skin);
		waitUI.add("LOADING...").expand().center();
		waitUI.setFillParent(true);
		stage.addActor(waitUI);
		
		HttpRequest httpRequest = new HttpRequest(HttpMethods.GET);
		httpRequest.setUrl(entry.url + variant + "/" + fileName);

		Gdx.net.sendHttpRequest(httpRequest, new SafeHttpResponseListener(){
			@Override
			protected void handleData(byte[] bytes) {
				Gdx.app.log(TAG, "loading " + fileName);
				
				if(fileName.endsWith(".gltf")){
					throw new GdxRuntimeException("remote gltf format not supported.");
				}else if(fileName.endsWith(".glb")){
					rootModel = new GLBLoader().load(bytes);
				}else{
					throw new GdxRuntimeException("unknown file extension for " + fileName);
				}
				
				load();
				
				Gdx.app.log(TAG, "loaded " + fileName);
			}
			@Override
			protected void handleError(Throwable t) {
				Gdx.app.error(TAG, "request error", t);
			}
			@Override
			protected void handleEnd() {
				waitUI.remove();
			}
		});
	}else{
		FileHandle baseFolder = rootFolder.child(entry.name).child(variant);
		FileHandle glFile = baseFolder.child(fileName);
		
		load(glFile);
	}
}
 
Example 17
Source File: AbilitiesScreen.java    From xibalba with MIT License 4 votes vote down vote up
/**
 * View and use your abilities.
 *
 * @param main Instance of Main
 */
public AbilitiesScreen(Main main) {
  this.main = main;

  abilities = ComponentMappers.abilities.get(WorldManager.player).abilities;
  playerDetails = ComponentMappers.player.get(WorldManager.player);

  stage = new Stage(new FitViewport(960, 540));

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

  Table titleTable = new Table();

  HorizontalGroup titleGroup = new HorizontalGroup();
  titleGroup.space(10);
  titleTable.add(titleGroup).pad(10).width(Gdx.graphics.getWidth() - 20);

  ActionButton closeButton = new ActionButton("Q", null);
  closeButton.setKeys(Input.Keys.Q);
  closeButton.setAction(table, () -> main.setScreen(Main.playScreen));
  titleGroup.addActor(closeButton);

  Label title = new Label("Abilities", Main.skin);
  titleGroup.addActor(title);

  abilitiesGroup = new VerticalGroup().top().left().columnLeft();

  Table abilitiesTable = new Table();
  abilitiesTable.add(abilitiesGroup).pad(10).top().left().width(Gdx.graphics.getWidth() / 2);

  table.add(titleTable);
  table.row();
  table.add(abilitiesTable).left();

  setupAbilities();

  Gdx.input.setInputProcessor(stage);
  stage.setKeyboardFocus(table);
}
 
Example 18
Source File: HelpScreen.java    From xibalba with MIT License 4 votes vote down vote up
/**
 * Help screen.
 *
 * @param main Instance of Main
 */
public HelpScreen(Main main) {
  stage = new Stage(new FitViewport(960, 540));

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

  Table titleTable = new Table();

  HorizontalGroup titleGroup = new HorizontalGroup();
  titleGroup.space(10);
  titleTable.add(titleGroup).pad(10).width(Gdx.graphics.getWidth() - 20);

  ActionButton closeButton = new ActionButton("Q", null);
  closeButton.setKeys(Input.Keys.Q);
  closeButton.setAction(table, () -> main.setScreen(Main.playScreen));
  titleGroup.addActor(closeButton);

  Label title = new Label("Help", Main.skin);
  titleGroup.addActor(title);

  VerticalGroup group = new VerticalGroup().top().left().columnLeft();

  Table helpTable = new Table();
  helpTable.add(group).pad(10).top().left();

  group.addActor(new Label("[DARK_GRAY]Movement & melee attacks:[] numpad keys", Main.skin));
  group.addActor(new Label("[DARK_GRAY]Shoot range weapon:[] r", Main.skin));
  group.addActor(new Label("[DARK_GRAY]Focused attack:[] shift + attack key", Main.skin));
  group.addActor(new Label("[DARK_GRAY]Look at a tile you're not on:[] s", Main.skin));
  group.addActor(new Label("[DARK_GRAY]Throw:[] t", Main.skin));
  group.addActor(new Label("[DARK_GRAY]Confirm action:[] space", Main.skin));
  group.addActor(new Label("[DARK_GRAY]Close dialogs or cancel actions:[] q", Main.skin));

  table.add(titleTable);
  table.row();
  table.add(helpTable).left();

  Gdx.input.setInputProcessor(stage);
  stage.setKeyboardFocus(table);
}
 
Example 19
Source File: HudRenderer.java    From xibalba with MIT License 4 votes vote down vote up
/**
 * Renders the HUD.
 *
 * @param main  Instance of Main class
 * @param batch The sprite batch to use (set in PlayScreen)
 */
public HudRenderer(Main main, SpriteBatch batch) {
  this.main = main;

  viewport = new FitViewport(960, 540, new OrthographicCamera());
  stage = new Stage(viewport, batch);

  player = WorldManager.player;
  playerDetails = ComponentMappers.player.get(player);
  playerAttributes = ComponentMappers.attributes.get(player);
  playerPosition = ComponentMappers.position.get(player);
  god = ComponentMappers.god.get(WorldManager.god);

  Table topTable = new Table();
  topTable.top().left();
  topTable.setFillParent(true);
  stage.addActor(topTable);

  playerInfo = new VerticalGroup().top().left().columnLeft();
  enemyInfo = new VerticalGroup().top().center().columnCenter();
  gameInfo = new VerticalGroup().top().right().columnRight();

  int width = Gdx.graphics.getWidth() / 3 - 20;

  topTable.add(playerInfo).pad(10, 10, 10, 10).width(width).top();
  topTable.add(enemyInfo).pad(10, 10, 10, 10).width(width).top();
  topTable.add(gameInfo).pad(10, 10, 10, 10).width(width).top();

  bottomTable = new Table();
  bottomTable.bottom().left();
  bottomTable.setFillParent(true);
  stage.addActor(bottomTable);

  actionLog = new VerticalGroup().top().left().columnLeft();
  focusedTable = new Table().top().center();
  buttonsAndAreaDetails = new VerticalGroup().top().right().columnRight();

  areaDetails = new VerticalGroup().top().right().columnRight().pad(0, 0, 5, 0);
  buttonsAndAreaDetails.addActor(areaDetails);

  menuButtons = new Table().right();
  setupMenuButtons();

  bottomTable.add(actionLog).pad(10, 10, 10, 10).width(width).bottom();
  bottomTable.add(focusedTable).pad(10, 10, 10, 10).width(width).top();
  bottomTable.add(buttonsAndAreaDetails).pad(10, 10, 10, 10).width(width).bottom();

  setupDeathDialog();

  stage.setKeyboardFocus(bottomTable);
}
 
Example 20
Source File: MusicEventTool.java    From gdx-soundboard with MIT License 3 votes vote down vote up
@Override
public void create() {
    skin = new Skin(Gdx.files.internal("uiskin.json"));

    stage = new Stage(new ScreenViewport());

    content = new Table(skin);

    stage.addActor(content);
    content.setFillParent(true);
    content.defaults().top().left();

    stateListPanel = new StateListPanel(skin, this);
    content.add(stateListPanel).minWidth(200).expandY().fillY();

    Table main = new Table(skin);
    eventDetailsPanel = new MusicStatePanel(skin, this);
    main.add(eventDetailsPanel).fill().expand().row();
    
    stateInfoPanel = new StateInfoPanel(skin, stage, getEventManager());
    main.add(stateInfoPanel).bottom().fillX().expandX();
    
    content.add(main).fill().expand().minWidth(580);
    

    Gdx.input.setInputProcessor(stage);
    new MenuDialog(skin, stage, eventManager).show(stage);
}