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

The following examples show how to use com.badlogic.gdx.scenes.scene2d.ui.Table#row() . 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: SteeringTestBase.java    From gdx-ai with Apache License 2.0 6 votes vote down vote up
protected void addMaxAngularAccelerationController (Table table, final Limiter limiter, float minValue, float maxValue,
	float step) {
	final Label labelMaxAngAcc = new Label("Max.Ang.Acc.[" + limiter.getMaxAngularAcceleration() + "]", container.skin);
	table.add(labelMaxAngAcc);
	table.row();
	Slider maxAngAcc = new Slider(minValue, maxValue, step, false, container.skin);
	maxAngAcc.setValue(limiter.getMaxAngularAcceleration());
	maxAngAcc.addListener(new ChangeListener() {
		@Override
		public void changed (ChangeEvent event, Actor actor) {
			Slider slider = (Slider)actor;
			limiter.setMaxAngularAcceleration(slider.getValue());
			labelMaxAngAcc.setText("Max.Ang.Acc.[" + limiter.getMaxAngularAcceleration() + "]");
		}
	});
	table.add(maxAngAcc);
}
 
Example 3
Source File: SteeringTestBase.java    From gdx-ai with Apache License 2.0 6 votes vote down vote up
protected void addMaxLinearAccelerationController (Table table, final Limiter limiter, float minValue, float maxValue,
	float step) {
	final Label labelMaxLinAcc = new Label("Max.Linear Acc.[" + limiter.getMaxLinearAcceleration() + "]", container.skin);
	table.add(labelMaxLinAcc);
	table.row();
	Slider maxLinAcc = new Slider(minValue, maxValue, step, false, container.skin);
	maxLinAcc.setValue(limiter.getMaxLinearAcceleration());
	maxLinAcc.addListener(new ChangeListener() {
		@Override
		public void changed (ChangeEvent event, Actor actor) {
			Slider slider = (Slider)actor;
			limiter.setMaxLinearAcceleration(slider.getValue());
			labelMaxLinAcc.setText("Max.Linear Acc.[" + limiter.getMaxLinearAcceleration() + "]");
		}
	});
	table.add(maxLinAcc);
}
 
Example 4
Source File: Entry.java    From ingress-apk-mod with Apache License 2.0 6 votes vote down vote up
public static void PortalInfoDialog_onStatsTableCreated(PortalInfoDialog dialog, Table t) {
    Mod.portalInfoDialog = dialog;

    Label.LabelStyle style = Mod.skin.get("portal-stats", Label.LabelStyle.class);

    List<Cell> cells = new ArrayList<Cell>(t.getCells());
    t.clear();
    t.add((Actor) cells.get(0).getWidget()).left();
    t.add((Actor) cells.get(1).getWidget()).left().expandX();
    t.row();
    t.add((Actor) cells.get(3).getWidget()).left();
    t.add((Actor) cells.get(4).getWidget()).left().expandX();
    t.row();
    t.add(new Label("Keys:", style)).left();
    t.add(new Label(String.valueOf(InventoryUtils.getNumberOfPortalKeys(dialog.portalComponent)), style)).left().expandX();
    t.row();
    t.add(new Label("Dist.:", style)).left();
    t.add(portalInfoDistLabel = new Label("", style)).left().expandX();
}
 
Example 5
Source File: ScrollInventoryActor.java    From Cubes with MIT License 6 votes vote down vote up
public ScrollInventoryActor(Inventory inventory, int slots) {
  defaults().space(4f);

  add(new Label(inventory.getDisplayName(), new LabelStyle(Fonts.hud, Color.WHITE)));
  row();

  inner = new Table();
  inner.defaults().space(4f);
  for (int i = 0; i < inventory.itemStacks.length; i++) {
    SlotActor slotActor = new SlotActor(inventory, i);
    inner.add(slotActor);

    if ((i + 1) % inventory.width == 0) {
      inner.row();
    }
  }
  inner.pack();

  scrollPane = new ScrollPane(inner);
  scrollPane.setScrollingDisabled(true, false);
  add(scrollPane).height(slots * CALIBRATION_PER_ROW).fill();
  row();
  pack();
}
 
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: BlockingWindow.java    From dice-heroes with GNU General Public License v3.0 6 votes vote down vote up
@Override protected void initialize() {
    table.defaults().pad(2);
    Table content = new Table();
    content.defaults().pad(2);
    content.add(new Blink(0));
    content.add(new Blink(1));
    content.add(new Blink(2));
    content.row();
    content.add(new Blink(7));
    content.add();
    content.add(new Blink(3));
    content.row();
    content.add(new Blink(6));
    content.add(new Blink(5));
    content.add(new Blink(4));

    table.add(content);
}
 
Example 8
Source File: CenteredTableBuilder.java    From vis-ui with Apache License 2.0 6 votes vote down vote up
@Override
protected void fillTable (final Table table) {
	final IntArray rowSizes = getRowSizes();
	final int widgetsInRow = getLowestCommonMultiple(rowSizes);

	for (int rowIndex = 0, widgetIndex = 0; rowIndex < rowSizes.size; rowIndex++) {
		final int rowSize = rowSizes.get(rowIndex);
		final int currentWidgetColspan = widgetsInRow / rowSize;
		boolean isFirst = shouldExpand(rowSize);

		for (final int totalWidgetsBeforeRowEnd = widgetIndex + rowSize; widgetIndex < totalWidgetsBeforeRowEnd; widgetIndex++) {
			final Cell<?> cell =
					getWidget(widgetIndex).buildCell(table, getDefaultWidgetPadding()).colspan(
							currentWidgetColspan);
			// Keeping widgets together - expanding X for first and last widget, setting alignments:
			if (isFirst) {
				isFirst = false;
				cell.expandX().right();
			} else if (isLast(widgetIndex, rowSize, totalWidgetsBeforeRowEnd)) {
				cell.expandX().left();
			}
		}
		table.row();
	}
}
 
Example 9
Source File: PortalUpgradeMod.java    From ingress-apk-mod with Apache License 2.0 6 votes vote down vote up
public static void onStatsTableCreated(PortalUpgradeUi ui, Table t) {
    init(ui);

    Label.LabelStyle style = Mod.skin.get("portal-stats", Label.LabelStyle.class);
    final float den = Mod.displayMetrics.density;

    List<Cell> cells = new ArrayList<Cell>(t.getCells());
    t.clear();
    t.left();
    t.defaults().left();
    t.add((Actor) cells.get(1).getWidget()).padLeft(20 * den);
    t.add((Actor) cells.get(2).getWidget()).padLeft(8 * den);
    t.add((Actor) cells.get(3).getWidget()).padLeft(16 * den);
    t.add((Actor) cells.get(4).getWidget()).padLeft(8 * den);
    t.row();
    t.add((Actor) cells.get(7).getWidget()).padLeft(20 * den);
    t.add((Actor) cells.get(8).getWidget()).padLeft(8 * den);
    t.add(new Label("Dist.:", style)).padLeft(16 * den);
    t.add(distLabel = new Label("", style)).padLeft(8 * den);

    updateDistLabel(Mod.world.getPlayerModel().getPlayerLocation());
}
 
Example 10
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 11
Source File: Box2dSeekTest.java    From gdx-ai with Apache License 2.0 5 votes vote down vote up
@Override
public void create () {
	super.create();

	spriteBatch = new SpriteBatch();

	// Create character
	character = createSteeringEntity(world, container.greenFish);
	character.setMaxLinearSpeed(5);
	character.setMaxLinearAcceleration(10);

	// Create target
	target = createSteeringEntity(world, container.target);
	markAsSensor(target);
	inputProcessor = new Box2dTargetInputProcessor(target);

	// Create character's steering behavior
	final Seek<Vector2> seekSB = new Seek<Vector2>(character, target);
	character.setSteeringBehavior(seekSB);

	Table detailTable = new Table(container.skin);

	detailTable.row();
	addMaxLinearAccelerationController(detailTable, character, 0, 200, 1);

	detailTable.row();
	addSeparator(detailTable);

	detailTable.row();
	addMaxLinearSpeedController(detailTable, character, 0, 30, .5f);

	detailWindow = createDetailWindow(detailTable);
}
 
Example 12
Source File: GridTableBuilder.java    From vis-ui with Apache License 2.0 5 votes vote down vote up
@Override
protected void fillTable (final Table table) {
	int widgetsCounter = 0;
	for (final CellWidget<? extends Actor> widget : getWidgets()) {
		widget.buildCell(table, getDefaultWidgetPadding());
		if (++widgetsCounter == rowSize) {
			widgetsCounter -= rowSize;
			table.row();
		}
	}
}
 
Example 13
Source File: StandardTableBuilder.java    From vis-ui with Apache License 2.0 5 votes vote down vote up
@Override
protected void fillTable (final Table table) {
	final IntArray rowSizes = getRowSizes();
	final int widgetsInRow = getLowestCommonMultiple(rowSizes);
	for (int rowIndex = 0, widgetIndex = 0; rowIndex < rowSizes.size; rowIndex++) {
		final int rowSize = rowSizes.get(rowIndex);
		final int currentWidgetColspan = widgetsInRow / rowSize;
		for (final int totalWidgets = widgetIndex + rowSize; widgetIndex < totalWidgets; widgetIndex++) {
			getWidget(widgetIndex).buildCell(table, getDefaultWidgetPadding()).colspan(
					currentWidgetColspan);
		}
		table.row();
	}
}
 
Example 14
Source File: CraftingScreen.java    From TerraLegion with MIT License 5 votes vote down vote up
@Override
public void create() {
	camera = new OrthoCamera();
	camera.resize();

	stageSb = new SpriteBatch();
	stage = new Stage(new StretchViewport(Settings.getWidth(), Settings.getHeight()), stageSb);

	//CATEGORY BUTTONS
	stage.addActor(toolCategoryBtn.getImageButton());
	stage.addActor(furnitureCategoryBtn.getImageButton());

	ScrollPane.ScrollPaneStyle paneStyle = new ScrollPane.ScrollPaneStyle();
	paneStyle.background = new TextureRegionDrawable(new TextureRegion(ResourceManager.getInstance().getTexture("invStageBg")));
	//paneStyle.vScrollKnob = new TextureRegionDrawable();
	//paneStyle.hScroll = paneStyle.hScrollKnob = paneStyle.vScroll = paneStyle.vScrollKnob;

	Table craftingContainer = CachePool.getTable();
	usedTablesCache.add(craftingContainer);
	float startX = (Settings.getWidth() / 2) - 255;
	craftingContainer.setBounds(startX, 0, 370, Settings.getHeight() - 61);

	craftingTable = CachePool.getTable();
	stage.addListener(new CraftingButtonClickListener(stage, craftingTable, craftingContainer.getX(), craftingContainer.getY()));
	usedTablesCache.add(craftingTable);

	pane = new ScrollPane(craftingTable, paneStyle);
	craftingContainer.add(pane).width(370).height(Settings.getHeight() - 61);
	craftingContainer.row();
	stage.addActor(craftingContainer);

	itemNameLabel = new Label("", ResourceManager.getInstance().getFont("font"), startX + 370 + 10, Settings.getHeight() - 61 - 35, false);
	itemInfoLabel = new MultilineLabel("", ResourceManager.getInstance().getFont("font"), startX + 370 + 10, Settings.getHeight() - 61 - 85, false);

	populateCraftableItems(toolCategoryBtn.getCategory());

	InputController.getInstance().addInputProcessor(stage);
}
 
Example 15
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 16
Source File: Scene2dPursueTest.java    From gdx-ai with Apache License 2.0 4 votes vote down vote up
@Override
public void create () {
	super.create();

	character = new SteeringActor(container.badlogicSmall, false);
	character.setPosition(MathUtils.random(container.stageWidth), MathUtils.random(container.stageHeight), Align.center);
	character.setMaxLinearSpeed(100);
	character.setMaxLinearAcceleration(600);

	prey = new SteeringActor(container.target, false);
	prey.setPosition(MathUtils.random(container.stageWidth), MathUtils.random(container.stageHeight), Align.center);
	prey.setMaxLinearSpeed(100);
	prey.setMaxLinearAcceleration(250);
	prey.setMaxAngularAcceleration(0); // used by Wander; set to 0 because independent facing is disabled
	prey.setMaxAngularSpeed(5);

	final Pursue<Vector2> pursueSB = new Pursue<Vector2>(character, prey, 0.3f);
	character.setSteeringBehavior(pursueSB);

	Wander<Vector2> wanderSB = new Wander<Vector2>(prey) //
		// Don't use Face internally because independent facing is off
		.setFaceEnabled(false) //
		// No need to call setAlignTolerance, setDecelerationRadius and setTimeToTarget for the same reason
		.setWanderOffset(110) //
		.setWanderOrientation(10) //
		.setWanderRadius(64) //
		.setWanderRate(MathUtils.PI2 * 3.5f);
	prey.setSteeringBehavior(wanderSB);

	testTable.addActor(character);
	testTable.addActor(prey);

	Table detailTable = new Table(container.skin);

	detailTable.row();
	addMaxLinearAccelerationController(detailTable, character, 0, 2000, 20);

	detailTable.row();
	final Label labelMaxPredictionTime = new Label("Max.Prediction Time[" + pursueSB.getMaxPredictionTime() + "] sec.",
		container.skin);
	detailTable.add(labelMaxPredictionTime);
	detailTable.row();
	Slider maxPredictionTime = new Slider(0, 5, .1f, false, container.skin);
	maxPredictionTime.setValue(pursueSB.getMaxPredictionTime());
	maxPredictionTime.addListener(new ChangeListener() {
		@Override
		public void changed (ChangeEvent event, Actor actor) {
			Slider slider = (Slider)actor;
			pursueSB.setMaxPredictionTime(slider.getValue());
			labelMaxPredictionTime.setText("Max.Prediction Time [" + slider.getValue() + "] sec.");
		}
	});
	detailTable.add(maxPredictionTime);

	detailTable.row();
	addSeparator(detailTable);

	detailTable.row();
	addMaxLinearSpeedController(detailTable, character, 0, 300, 10);

	detailWindow = createDetailWindow(detailTable);
}
 
Example 17
Source File: ConflictWindow.java    From dice-heroes with GNU General Public License v3.0 4 votes vote down vote up
@Override protected void doShow(Params params) {
    callback = params.callback;
    Table content = new Table(Config.skin);
    content.defaults().pad(2);
    content.setTouchable(Touchable.enabled);
    content.setBackground("ui-store-window-background");

    LocLabel desc = new LocLabel("ui-conflict-description");
    desc.setWrap(true);
    desc.setAlignment(Align.center);

    Table diff = new Table(Config.skin);
    diff.defaults().uniform().pad(1);
    UserData local = params.localData;
    UserData server = params.serverData;


    diff.add(String.valueOf(local.numPassedLevels()), "default", AboutWindow.INACTIVE).expandX();
    final Tile levels = new Tile("ui/conflict-window/levels");
    Hint.make(levels, "ui-conflict-window-levels");
    diff.add(levels);
    diff.add(String.valueOf(server.numPassedLevels()), "default", AboutWindow.INACTIVE).expandX();
    diff.row();

    diff.add(String.valueOf(local.diceCount()), "default", AboutWindow.INACTIVE);
    final Tile dice = new Tile("ui/conflict-window/dice");
    Hint.make(dice, "ui-conflict-window-dice");
    diff.add(dice);
    diff.add(String.valueOf(server.diceCount()), "default", AboutWindow.INACTIVE);
    diff.row();

    Item coin = Config.items.get("coin");
    diff.add(String.valueOf(local.getItemCount(coin)), "default", AboutWindow.INACTIVE);
    final Tile coins = new Tile("ui/conflict-window/coins");
    Hint.make(coins, "ui-conflict-window-coins");
    diff.add(coins);
    diff.add(String.valueOf(server.getItemCount(coin)), "default", AboutWindow.INACTIVE);
    diff.row();

    diff.add(String.valueOf(local.potionsCount()), "default", AboutWindow.INACTIVE);
    final Tile potions = new Tile("ui/conflict-window/potions");
    Hint.make(potions, "ui-conflict-window-potions");
    diff.add(potions);
    diff.add(String.valueOf(server.potionsCount()), "default", AboutWindow.INACTIVE);
    diff.row();

    diff.add(String.valueOf(local.itemsCount(Item.Type.ingredient)), "default", AboutWindow.INACTIVE);
    final Tile ingredients = new Tile("ui/conflict-window/ingredients");
    Hint.make(ingredients, "ui-conflict-window-ingredients");
    diff.add(ingredients);
    diff.add(String.valueOf(server.itemsCount(Item.Type.ingredient)), "default", AboutWindow.INACTIVE);

    LocTextButton useLocal = new LocTextButton("ui-use-local");
    useLocal.addListener(listener(GameMapState.ConflictResolution.useLocal));
    LocTextButton useServer = new LocTextButton("ui-use-server");
    useServer.addListener(listener(GameMapState.ConflictResolution.useServer));

    Table buttons = new Table();
    buttons.defaults().uniformX();
    buttons.add(useLocal).expandX().fillX().padRight(3);
    buttons.add(useServer).expandX().fillX();

    content.add(new LocLabel("ui-conflict-header")).padBottom(0).row();
    content.add(desc).width(130).padTop(0).row();
    content.add(new Tile("ui-creature-info-line")).width(80).pad(4).row();
    content.add(diff).width(110).padBottom(3).row();
    content.add(buttons).expandX().fillX();

    table.add(content);
}
 
Example 18
Source File: Editor.java    From bladecoder-adventure-engine with Apache License 2.0 4 votes vote down vote up
@Override
public void create() {

	if (EditorLogger.debugMode()) {
		EngineLogger.setDebug();
	}

	Gdx.graphics.setWindowedMode(Math.max((int) (Gdx.graphics.getDisplayMode().width * 0.9), 1920 / 2),
			Math.max((int) (Gdx.graphics.getDisplayMode().height * 0.9), 1080 / 2));

	skin = new BladeSkin(Gdx.files.internal(SKIN));
	VisUI.load();
	FileChooser.setDefaultPrefsName("com.bladecoder.engineeditor.filechooser");

	/*** STAGE SETUP ***/
	stage = new Stage(new ScreenViewport());
	Gdx.input.setInputProcessor(stage);

	setCtx();

	Message.init(skin);

	scnEditor = new ScnEditor(skin);
	scnEditor.setBackground("background");
	skin.getFont("default-font").getData().markupEnabled = true;

	// RIGHT PANEL
	ScenePanel scenePanel = new ScenePanel(skin);
	ActorPanel actorPanel = new ActorPanel(skin);

	Table rightPanel = new Table(skin);
	rightPanel.top().left();
	rightPanel.add(actorPanel).expand().fill().left();
	rightPanel.setBackground("background");

	SplitPane splitPaneRight = new SplitPane(scnEditor, rightPanel, false, skin);

	splitPaneRight.setSplitAmount(0.75f);

	// LEFT PANEL
	ProjectPanel projectPanel = new ProjectPanel(skin);
	Image img = new Image(Ctx.assetManager.getIcon("title"));
	img.setScaling(Scaling.none);
	img.setAlign(Align.left);

	Table leftPanel = new Table(skin);
	leftPanel.top().left().padLeft(10);
	leftPanel.add(img).expand().fill().padBottom(20).padTop(20).padLeft(0).left();
	leftPanel.row();
	leftPanel.add(new ProjectToolbar(skin)).expandX().fill().left();
	leftPanel.row();
	leftPanel.add(projectPanel).expand().fill().left();
	leftPanel.row();
	leftPanel.add(scenePanel).expand().fill().left();
	leftPanel.setBackground("background");

	SplitPane splitPaneLeft = new SplitPane(leftPanel, splitPaneRight, false, skin);
	splitPaneLeft.setFillParent(true);
	splitPaneLeft.setSplitAmount(0.25f);
	stage.addActor(splitPaneLeft);

	// LOAD LAST OPEN PROJECT
	String lastProject = Ctx.project.getEditorConfig().getProperty(Project.LAST_PROJECT_PROP, "");
	final File lastProjectFile = new File(lastProject);

	if (!lastProject.isEmpty() && lastProjectFile.exists()) {
		EditorLogger.debug("Loading previous project: " + lastProject);

		try {
			EditorUtils.checkVersionAndLoadProject(lastProjectFile, stage, skin);
		} catch (Exception e) {
			EditorLogger.error("Error loading previous project.", e);
			Ctx.project.closeProject();
		}
	}

	stage.setScrollFocus(scnEditor.getScnWidget());
	stage.setKeyboardFocus(scnEditor.getScnWidget());

	// TooltipManager.getInstance().instant();
	TooltipManager.getInstance().initialTime = 0.2f;
	TooltipManager.getInstance().hideAll();
	TooltipManager.getInstance().subsequentTime = 0.2f;
}
 
Example 19
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 20
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());
	
}