Java Code Examples for com.badlogic.gdx.scenes.scene2d.Stage#addActor()

The following examples show how to use com.badlogic.gdx.scenes.scene2d.Stage#addActor() . 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: MainMenuScreen.java    From xibalba with MIT License 6 votes vote down vote up
/**
 * Main Menu Screen.
 *
 * @param main Instance of main class
 */
public MainMenuScreen(Main main) {
  stage = new Stage(new FitViewport(960, 540));

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

  ActionButton newGameButton = new ActionButton("N", "New Game");
  newGameButton.setKeys(Input.Keys.N);
  newGameButton.setAction(table, () -> main.setScreen(new YouScreen(main)));

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

  table.add(new Label("[LIGHT_GRAY]Xibalba v0.1.0[]", Main.skin)).pad(0, 0, 10, 0);
  table.row();

  table.add(newGameButton).pad(0, 0, 10, 0);
  table.row();
  table.add(quitButton);

  Gdx.input.setInputProcessor(stage);
  stage.setKeyboardFocus(table);
}
 
Example 2
Source File: GameOverScreen.java    From Bomberman_libGdx with MIT License 6 votes vote down vote up
@Override
public void show() {
    viewport = new FitViewport(640, 480);
    stage = new Stage(viewport, batch);

    font = new BitmapFont(Gdx.files.internal("fonts/foo.fnt"));

    Label.LabelStyle labelStyle = new Label.LabelStyle(font, Color.WHITE);
    Label gameOverLabel = new Label("Game Over", labelStyle);
    gameOverLabel.setPosition((640 - gameOverLabel.getWidth()) / 2, 226f);

    GameManager.getInstance().playMusic("GameOver.ogg", false);

    stage.addActor(gameOverLabel);

    stage.addAction(Actions.sequence(
            Actions.delay(1f),
            Actions.fadeOut(2f),
            Actions.run(new Runnable() {
                @Override
                public void run() {
                    game.setScreen(new MainMenuScreen(game));
                }
            })));

}
 
Example 3
Source File: InventoryScreen.java    From libgdx-utils with MIT License 5 votes vote down vote up
@Override
public void show() {
	stage = new Stage();
	Gdx.input.setInputProcessor(stage);

	Skin skin = LibgdxUtils.assets.get("skins/uiskin.json", Skin.class);
	DragAndDrop dragAndDrop = new DragAndDrop();
	inventoryActor = new InventoryActor(new Inventory(), dragAndDrop, skin);
	stage.addActor(inventoryActor);
}
 
Example 4
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 5
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 6
Source File: DemoScreen.java    From cocos-ui-libgdx with Apache License 2.0 5 votes vote down vote up
private void initDemoChange(InputMultiplexer multiplexer) {
    Stage demoChangeStage = new Stage(new StretchViewport(DemoGame.GAME_WIDTH, DemoGame.GAME_HEIGHT));
    Actor actor = new Actor();
    actor.setWidth(stage.getWidth());
    actor.setHeight(stage.getHeight());
    actor.addListener(new ClickListener() {
        @Override
        public void clicked(InputEvent event, float x, float y) {
            updateCurrentIndex();
            changeDemo();
        }
    });
    demoChangeStage.addActor(actor);
    multiplexer.addProcessor(demoChangeStage);
}
 
Example 7
Source File: Hint.java    From dice-heroes with GNU General Public License v3.0 5 votes vote down vote up
public void show(Stage stage, float stageX, float stageY) {
    if (shown || stage == null)
        return;
    shown = true;
    stage.addActor(table);
    updateTableWidth(Float.MAX_VALUE);
    // if actor is too high, try to place it left or right
    if (table.getHeight() + stageY + TOUCH_OFFSET > stage.getHeight() - SCREEN_EDGE_OFFSET) {
        if (stageX > stage.getWidth() / 2) {
            //left
            updateTableWidth(stageX - TOUCH_OFFSET - SCREEN_EDGE_OFFSET);
            table.setX(stageX - TOUCH_OFFSET - table.getWidth());
        } else {
            //right
            updateTableWidth(stage.getWidth() - stageX - TOUCH_OFFSET - SCREEN_EDGE_OFFSET);
            table.setX(stageX + TOUCH_OFFSET);
        }
        table.setY(MathUtils.clamp(stageY - table.getHeight() / 2, SCREEN_EDGE_OFFSET, stage.getHeight() - table.getHeight() - SCREEN_EDGE_OFFSET));
    } else {
        table.setPosition(
            MathUtils.clamp(stageX - table.getWidth() / 2, SCREEN_EDGE_OFFSET, stage.getWidth() - table.getWidth() - SCREEN_EDGE_OFFSET),
            stageY + TOUCH_OFFSET
        );
    }
    table.clearActions();
    table.getColor().a = 0;
    table.addAction(alpha(1, 0.25f));
}
 
Example 8
Source File: SplashScreen.java    From Codelabs with MIT License 4 votes vote down vote up
@Override
public void show() {
	stage = new Stage();

	/* Load splash image */
	codelabsImage = new Image(new Texture(
			Gdx.files.internal("data/images/codelabs_splash.png")));
	
	githubImage = new Image(new Texture(
			Gdx.files.internal("data/images/github_splash.png")));

	/* Set the splash image in the center of the screen */
	float width = Gdx.graphics.getWidth();
	float height = Gdx.graphics.getHeight();

	codelabsImage.setPosition((width - codelabsImage.getWidth()) / 2,
			(height - codelabsImage.getHeight()) / 2);

	/* Fade in the image and then swing it down */
	codelabsImage.getColor().a = 0f;
	codelabsImage.addAction(Actions.sequence(Actions.fadeIn(0.5f), Actions
			.delay(1, Actions.fadeOut(0.5f))));
	
	githubImage.setPosition((width - githubImage.getWidth()) / 2,
			(height - githubImage.getHeight()) / 2);

	/* Fade in the image and then swing it down */
	githubImage.getColor().a = 0f;
	githubImage.addAction(Actions.delay(2, Actions.sequence(Actions.fadeIn(0.5f), Actions
			.delay(1, Actions.moveBy(0,
					-(height - githubImage.getHeight() / 2), 1,
					Interpolation.swingIn)), Actions.run(new Runnable() {
		@Override
		public void run() {

			/* Show main menu after swing out */
			((Game) Gdx.app.getApplicationListener())
					.setScreen(new MainMenu());
		}
	}))));

	stage.addActor(codelabsImage);
	stage.addActor(githubImage);
}
 
Example 9
Source File: Dialogs.java    From vis-ui with Apache License 2.0 4 votes vote down vote up
/** Dialog with title "Error", provided text, and provided details available after pressing 'Details' button. */
public static DetailsDialog showErrorDialog (Stage stage, String text, String details) {
	DetailsDialog dialog = new DetailsDialog(text, Text.ERROR.get(), details);
	stage.addActor(dialog.fadeIn());
	return dialog;
}
 
Example 10
Source File: Message.java    From bladecoder-adventure-engine with Apache License 2.0 4 votes vote down vote up
private static void add(Stage stage, String text) {
	msg.clearActions();

	msg.setText(text);

	GlyphLayout textLayout = new GlyphLayout();

	textLayout.setText(msg.getStyle().font, text, Color.BLACK, stage.getWidth() * .8f, Align.center, true);

	msg.setSize(textLayout.width + textLayout.height, textLayout.height + textLayout.height * 2);

	if (!stage.getActors().contains(msg, true))
		stage.addActor(msg);

	msg.setPosition(Math.round((stage.getWidth() - msg.getWidth()) / 2),
			Math.round((stage.getHeight() - msg.getHeight()) / 2));
	msg.invalidate();
}
 
Example 11
Source File: PvpUserWrapper.java    From dice-heroes with GNU General Public License v3.0 4 votes vote down vote up
@Override public IFuture<Response> process(final Params params) {
    final Future<Response> future = new Future<Response>();
    Stage stage = ((DiceHeroes) Gdx.app.getApplicationListener()).getState().stage;
    Tile icon = new Tile("ui/pvp/timer");
    icon.setPosition(ICON_PADDING, ICON_PADDING);

    Tile progress = new Tile("ui-reward-window-background");
    progress.setTouchable(Touchable.disabled);
    progress.setPosition(
        ICON_PADDING * 2 + icon.getWidth(),
        ICON_PADDING + icon.getHeight() * 0.5f - BAR_HEIGHT * 0.5f
    );
    progress.setSize(
        stage.getWidth() - ICON_PADDING * 3 - icon.getWidth(),
        BAR_HEIGHT
    );
    root = new Group();
    root.addActor(progress);
    root.addActor(icon);

    stage.addActor(root);
    root.addAction(delay(25, forever(sequence(
        visible(false),
        delay(0.1f),
        visible(true),
        delay(0.4f)
    ))));
    progress.addAction(
        sequence(
            sizeTo(0, BAR_HEIGHT, 30f),
            run(new Runnable() {
                @Override public void run() {
                    root.remove();
                    skip(future, params);
                }
            })
        )
    );
    processor.process(params).addListener(future);
    return future.addListener(this);
}
 
Example 12
Source File: MainMenuScreen.java    From Bomberman_libGdx with MIT License 4 votes vote down vote up
@Override
public void show() {
    viewport = new FitViewport(640, 480);
    stage = new Stage(viewport, batch);

    font = new BitmapFont(Gdx.files.internal("fonts/foo.fnt"));

    Label.LabelStyle labelStyle = new Label.LabelStyle(font, Color.WHITE);

    Label titleLabel = new Label("Bomberman", labelStyle);
    titleLabel.setFontScale(1.6f);
    titleLabel.setPosition(140, 360);

    Label easyLabel = new Label("Easy", labelStyle);
    easyLabel.setPosition((640 - easyLabel.getWidth()) / 2, 240);

    Label normalLabel = new Label("Normal", labelStyle);
    normalLabel.setPosition((640 - normalLabel.getWidth()) / 2, 180);

    Label hardLabel = new Label("Hard", labelStyle);
    hardLabel.setPosition((640 - hardLabel.getWidth()) / 2, 120);

    Pixmap pixmap = new Pixmap(640, 480, Pixmap.Format.RGB888);
    pixmap.setColor(240.0f / 255.0f, 128 / 255.0f, 0, 1.0f);
    pixmap.fill();
    backgroundTexture = new Texture(pixmap);
    pixmap.dispose();
    Image background = new Image(backgroundTexture);

    indicatorX = 160f;
    indicatorY = 240f;

    TextureAtlas textureAtlas = GameManager.getInstance().getAssetManager().get("img/actors.pack", TextureAtlas.class);
    indicator0 = new Image(new TextureRegion(textureAtlas.findRegion("MainMenuLogo"), 0, 0, 40, 26));
    indicator0.setSize(80f, 52f);
    indicator0.setPosition(indicatorX, indicatorY);

    indicator1 = new Image(new TextureRegion(textureAtlas.findRegion("MainMenuLogo"), 40, 0, 40, 26));
    indicator1.setSize(80f, 52f);
    indicator1.setPosition(indicatorX, indicatorY);
    indicator1.setVisible(false);
    
    indicationsTexture = new Texture("img/indications.png");
    indications = new Image(indicationsTexture);
    indications.setPosition(640f - indications.getWidth() - 12f, 12f);

    stage.addActor(background);
    stage.addActor(indications);
    stage.addActor(titleLabel);
    stage.addActor(easyLabel);
    stage.addActor(normalLabel);
    stage.addActor(hardLabel);
    stage.addActor(indicator0);
    stage.addActor(indicator1);

    currentSelection = 0;
    selected = false;
    
    GameManager.getInstance().playMusic("SuperBomberman-Title.ogg", true);
}
 
Example 13
Source File: ResumeVsJoinTest.java    From gdx-ai with Apache License 2.0 4 votes vote down vote up
public TestScreen (final ResumeVsJoinTest test, Skin skin) {
	this.test = test;
	this.skin = skin;
	lastUpdateTime = 0;
	gameOver = false;

	greenFishTextureRegion = new TextureRegion(new Texture("data/green_fish.png"));
	badlogicTextureRegion = new TextureRegion(new Texture("data/badlogicsmall.jpg"));
	targetTextureRegion = new TextureRegion(new Texture("data/target.png"));

	shapeRenderer = new ShapeRenderer();

	stage = new Stage();

	Stack testStack = new Stack();
	stage.addActor(testStack);

	// Add translucent panel (it's only visible when AI is paused)
	final Image translucentPanel = new Image(skin, "translucent");
	translucentPanel.setSize(stage.getWidth(), stage.getHeight());
	translucentPanel.setVisible(false);
	stage.addActor(translucentPanel);

	// Create status bar
	Table statusBar = new Table(skin);
	statusBar.left().bottom();
	statusBar.row().height(26);
	statusBar.add(pauseButton = new PauseButton(translucentPanel, skin)).width(90).left();
	statusBar.add(new FpsLabel("FPS: ", skin)).padLeft(15);
	statusBar.add(new IntValueLabel("Resume (Fish): ", 0, skin) {
		@Override
		public int getValue () {
			return resumePredator.score;
		}
	}).padLeft(15);
	statusBar.add(new IntValueLabel("Join (Badlogics): ", 0, skin) {
		@Override
		public int getValue () {
			return joinPredator.score;
		}
	}).padLeft(15);
	stage.addActor(statusBar);

	// Add test table
	testStack.setSize(stage.getWidth(), stage.getHeight());
	testStack.add(testTable = new Table() {
		@Override
		public void act (float delta) {
			float time = GdxAI.getTimepiece().getTime();
			if (lastUpdateTime != time) {
				lastUpdateTime = time;
				super.act(GdxAI.getTimepiece().getDeltaTime());
			}
		}
	});
	testStack.layout();

	this.sheeps = new Array<Sheep>();

	for (int i = 0; i < 30; i++) {
		Sheep sheep = new Sheep(targetTextureRegion);
		sheep.setMaxLinearAcceleration(50);
		sheep.setMaxLinearSpeed(80);
		sheep.setMaxAngularAcceleration(10); // greater than 0 because independent facing is enabled
		sheep.setMaxAngularSpeed(5);

		Wander<Vector2> wanderSB = new Wander<Vector2>(sheep) //
			.setFaceEnabled(true) // We want to use Face internally (independent facing is on)
			.setAlignTolerance(0.001f) // Used by Face
			.setDecelerationRadius(5) // Used by Face
			.setTimeToTarget(0.1f) // Used by Face
			.setWanderOffset(90) //
			.setWanderOrientation(10) //
			.setWanderRadius(40) //
			.setWanderRate(MathUtils.PI2 * 4);
		sheep.setSteeringBehavior(wanderSB);

		setRandomNonOverlappingPosition(sheep, sheeps, 5);
		setRandomOrientation(sheep);

		testTable.addActor(sheep);

		sheeps.add(sheep);
	}

	resumePredator = createPredator(false);
	joinPredator = createPredator(true);

	// Create GameOver panel
	gameOverButton = new TextButton("Game Over", skin);
	gameOverButton.setVisible(false);
	gameOverButton.addListener(new ChangeListener() {
		@Override
		public void changed (ChangeEvent event, Actor actor) {
			test.backToPreviousScreen();
		}
	});
	testTable.add(gameOverButton);
}
 
Example 14
Source File: ServerConnectGUI.java    From Radix with MIT License 4 votes vote down vote up
@Override
public void init() {
    stage = new Stage();

    // TODO memory manage

    background = new Texture(Gdx.files.internal("textures/block/obsidian.png"));
    background.setWrap(TextureWrap.Repeat, TextureWrap.Repeat);

    errorLabel = new Label(null, new LabelStyle(new BitmapFont(), Color.RED));

    TextFieldStyle fieldStyle = new TextFieldStyle();
    fieldStyle.font = new BitmapFont();
    fieldStyle.fontColor = Color.WHITE;
    TextField ipField = new TextField("IP:Port", fieldStyle);

    ImageTextButtonStyle btnStyle = RadixClient.getInstance().getSceneTheme().getButtonStyle();

    TextButton connectButton = new TextButton("Connect", btnStyle);
    connectButton.addListener(new ClickListener() {
        @Override
        public void clicked(InputEvent event, float x, float y) {
            String[] ipPort = ipField.getText().split(":");

            if(ipPort.length != 2) {
                invalidIpSyntax();
                return;
            }

            try {
                RadixClient.getInstance().enterRemoteWorld(ipPort[0], Short.parseShort(ipPort[1]));
            } catch (NumberFormatException ex) {
                invalidPort();
            }
        }
    });

    Table table = new Table();
    table.setFillParent(true);
    table.add(ipField);
    table.row();
    table.add(errorLabel);
    table.row();
    table.add(connectButton);
    stage.addActor(table);
}
 
Example 15
Source File: Main.java    From graphicsfuzz with Apache License 2.0 4 votes vote down vote up
@Override
public void create() {

  if(this.overrideLogger != null){
    Gdx.app.setApplicationLogger(overrideLogger);
  }

  // Only DesktopLauncher sets this.
  if(gl30 == null) {
    // Gdx.gl30 could also be null though.
    gl30 = Gdx.gl30;
  }

  Gdx.graphics.getGL20().glEnable(GL20.GL_TEXTURE_2D);
  Gdx.graphics.getGL20().glEnable(GL20.GL_DEPTH_TEST);
  Gdx.graphics.getGL20().glDepthFunc(GL20.GL_LESS);

  standardMesh = buildFullScreenQuadMesh();

  if(standaloneRenderJob != null) {
    if (standaloneRenderJob.isSetComputeSource()) {
      updateState(WorkerState.COMPUTE_STANDALONE_PREPARE);
    } else {
      updateState(WorkerState.IMAGE_STANDALONE_PREPARE);
    }
    return;
  }

  PlatformInfoUtil.getPlatformDetails(platformInfoJson);
  PlatformInfoUtil.getGlVersionInfo(platformInfoJson, gl30);

  sanityReferenceImage = createPixelBuffer();
  sanityCheckImage = createPixelBuffer();
  sanityCheckImageTmp = createPixelBuffer();

  GdxStage = new Stage(new ScreenViewport());
  Label.LabelStyle label1Style = new Label.LabelStyle();
  label1Style.font = new BitmapFont();
  label1Style.fontColor = Color.WHITE;

  DisplayContent = new StringBuilder();
  DisplayLabel = new Label(DisplayContent.toString(), label1Style);
  DisplayLabel.setPosition(WIDTH + DISPLAY_TXT_MARGIN, 0);
  DisplayLabel
      .setSize(Gdx.graphics.getWidth() - WIDTH - DISPLAY_TXT_MARGIN - 10, Gdx.graphics.getHeight() - 10);
  DisplayLabel.setAlignment(Align.topLeft);
  DisplayContent = new StringBuilder();
  GdxStage.addActor(DisplayLabel);
}
 
Example 16
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 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: 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);
}
 
Example 19
Source File: Dialogs.java    From vis-ui with Apache License 2.0 2 votes vote down vote up
/**
 * Dialog with title, text and n amount of buttons. If you need dialog with only buttons like Yes, No, Cancel then
 * see {@link #showOptionDialog(Stage, String, String, OptionDialogType, OptionDialogListener)}.
 * <p>
 * @param title dialog title.
 * @param listener button listener for this dialog. This dialog is generic, listener type will depend on
 * 'returns' param type.
 * @since 0.7.0
 */
public static <T> ConfirmDialog<T> showConfirmDialog (Stage stage, String title, String text, String[] buttons, T[] returns, ConfirmDialogListener<T> listener) {
	ConfirmDialog<T> dialog = new ConfirmDialog<T>(title, text, buttons, returns, listener);
	stage.addActor(dialog.fadeIn());
	return dialog;
}
 
Example 20
Source File: Dialogs.java    From vis-ui with Apache License 2.0 2 votes vote down vote up
/**
 * Dialog with text and text field for user input.
 * @param title dialog title.
 * @param cancelable if true dialog may be canceled by user.
 * @param fieldTitle displayed before input field, may be null.
 * @param listener dialog buttons listener.
 */
public static InputDialog showInputDialog (Stage stage, String title, String fieldTitle, boolean cancelable, InputDialogListener listener) {
	InputDialog dialog = new InputDialog(title, fieldTitle, cancelable, null, listener);
	stage.addActor(dialog.fadeIn());
	return dialog;
}