Beispiel #1
0
  @Override
  public void setUpInterface(Table table) {
    // TODO: Move this to the skin.
    ScrollPane.ScrollPaneStyle style = new ScrollPane.ScrollPaneStyle();

    table.pad(20);

    Label header = new Label(game.getLocale().get("main.about"), game.getSkin(), "bold");
    table.add(header).expandX().align(Align.center).height(80).row();

    innerContainer = new Table();
    ScrollPane scroll = new ScrollPane(innerContainer, style);
    table.add(scroll).expand().fill().align(Align.top).row();
    innerContainer.defaults().fill().expand();

    screen = SCREEN_CREDITS;
    updateScrollPane();

    final TextButton changeButton =
        new TextButton(game.getLocale().get("about.license"), game.getSkin());
    changeButton.addListener(
        new ChangeListener() {
          @Override
          public void changed(ChangeEvent event, Actor actor) {
            if (screen == SCREEN_CREDITS) {
              screen = SCREEN_LICENSE;
              changeButton.setText(game.getLocale().get("about.credits"));
              updateScrollPane();
            } else {
              screen = SCREEN_CREDITS;
              changeButton.setText(game.getLocale().get("about.license"));
              updateScrollPane();
            }
            game.player.playSound(SoundPlayer.SoundCode.SELECT);
            event.cancel();
          }
        });

    Table buttonRow = new Table();
    buttonRow.defaults().fill().expand().width(Value.maxWidth).space(10);
    buttonRow.add(changeButton);

    TextButton backButton = new TextButton(game.getLocale().get("core.back"), game.getSkin());
    buttonRow.add(backButton).row();
    backButton.addListener(new ScreenPopper(game));

    table.add(buttonRow).expandX().fillX().height(60).padTop(20).align(Align.bottom).row();
  }
Beispiel #2
0
  private void initialize() {
    setModal(true);

    defaults().space(6);
    add(contentTable = new Table(skin)).expand().fill();
    row();
    add(buttonTable = new Table(skin));

    contentTable.defaults().space(6);
    buttonTable.defaults().space(6);

    buttonTable.addListener(
        new ChangeListener() {
          public void changed(ChangeEvent event, Actor actor) {
            if (!values.containsKey(actor)) return;
            while (actor.getParent() != buttonTable) actor = actor.getParent();
            result(values.get(actor));
            if (!cancelHide) hide();
            cancelHide = false;
          }
        });

    focusListener =
        new FocusListener() {
          public void keyboardFocusChanged(FocusEvent event, Actor actor, boolean focused) {
            if (!focused) focusChanged(event);
          }

          public void scrollFocusChanged(FocusEvent event, Actor actor, boolean focused) {
            if (!focused) focusChanged(event);
          }

          private void focusChanged(FocusEvent event) {
            Stage stage = getStage();
            if (isModal
                && stage != null
                && stage.getRoot().getChildren().size > 0
                && stage.getRoot().getChildren().peek()
                    == Dialog.this) { // Dialog is top most actor.
              Actor newFocusedActor = event.getRelatedActor();
              if (newFocusedActor != null
                  && !newFocusedActor.isDescendantOf(Dialog.this)
                  && !(newFocusedActor.equals(previousKeyboardFocus)
                      || newFocusedActor.equals(previousScrollFocus))) event.cancel();
            }
          }
        };
  }
	private void fillTable() {
		StyleHelper helper = StyleHelper.getInstance();

		Table scrollTable = new Table();
		ImageButton newProfile = new ImageButton(
				helper.getImageButtonStyle("widgets/icon-plus"));

		newProfile.addListener(new NewProfileClickListener());

		scrollTable.defaults().width(500).height(100).space(10);
		
		scrollTable.padTop(30);
		for (Profile profile : profileController.getAllProfiles()) {
			TextButton profileButton = new TextButton(profile.getName(),
					helper.getTextButtonStyle());
			scrollTable.add(profileButton);
			scrollTable.row();
			profileButton.addListener(new ChangeProfileClickListener());
		}

		
		scrollTable.add(newProfile);

		scrollTable.padBottom(15);
		ScrollPane scrollPane = new ScrollPane(scrollTable);
		table.add(scrollPane).expand().fill();
	}
  private Table makeGameFileRow(final FileHandle gameSaveFile) {
    GameSave towerData;
    try {
      towerData = GameSaveFactory.readMetadata(gameSaveFile.read());
    } catch (Exception e) {
      Gdx.app.log(TAG, "Failed to parse file.", e);
      return null;
    }

    FileHandle imageFile =
        Gdx.files.external(TowerConsts.GAME_SAVE_DIRECTORY + gameSaveFile.name() + ".png");

    Actor imageActor = null;
    if (imageFile.exists()) {
      try {
        imageActor = new Image(loadTowerImage(imageFile), Scaling.fit, Align.top);
      } catch (Exception ignored) {
        imageActor = null;
      }
    }

    if (imageActor == null) {
      imageActor = FontManager.Default.makeLabel("No image.");
    }

    Table fileRow = new Table();
    fileRow.defaults().fillX().pad(Display.devicePixel(10)).space(Display.devicePixel(10));
    fileRow.row();
    fileRow.add(imageActor).width(Display.devicePixel(64)).height(Display.devicePixel(64)).center();
    fileRow.add(makeGameFileInfoBox(fileRow, gameSaveFile, towerData)).expandX().top();
    fileRow.row().fillX();
    fileRow.add(new HorizontalRule(Color.DARK_GRAY, 2)).colspan(2);

    return fileRow;
  }
Beispiel #5
0
  public GameScreen(DdsGame game) {
    Dds.gameScreen = this;
    this.game = game;

    stage = new Stage(new FitViewport(Const.DESIGN_WIDTH, Const.DESIGN_HEIGHT));
    Gdx.input.setInputProcessor(stage);
    skin = new Skin(Gdx.files.internal("uiskin.json"));

    Image img = new Image(new Texture("bg.jpg"));
    stage.addActor(img);

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

    int n = NUM;
    int w = (Const.DESIGN_HEIGHT - n * Const.PAD_DIST - 2 * Const.EDGE_DIST) / n;
    table.defaults().width(w).height(w).pad(Const.PAD_DIST);

    labelHit = new Label("0", skin);
    labelHit.setAlignment(Align.right);
    stage.addActor(labelHit);

    labelMiss = new Label("0", skin);
    labelHit.setAlignment(Align.left);
    stage.addActor(labelHit);

    LevelData ld =
        LevelManager.getInstance().getLevelData(LevelManager.getInstance().getCurLevel());
    level = new Level(ld);
    HoleManager.getInstance().init(table, level.data.n);
    level.start();
  }
 private void createTable() {
   // TODO: add actual high-scores
   table = new Table(game.getSkin());
   table.defaults().width(150).height(35).pad(1);
   table.setFillParent(true);
   table.add(game.getLanguage().getString("menu.high.scores")).colspan(2).center().height(50);
   table.row();
   table.add("Name#1");
   table.add("10000");
   table.row();
   table.add("Name#2");
   table.add("10000");
   table.row();
   table.add("Name#3");
   table.add("10000");
   table.row();
   table.add("Name#4");
   table.add("10000");
   table.row();
   table.add("Name#5");
   table.add("10000");
   table.row();
   table.add("Name#6");
   table.add("10000");
   table.row();
   table.add("Name#7");
   table.add("10000");
   table.row();
   table.add("Name#8");
   table.add("10000");
   table.row();
   table.add("Name#9");
   table.add("10000");
   table.row();
   table.add("Name#10");
   table.add("10000");
 }
  public PanelProperties(String title, Skin skin) {
    super(title, skin);

    scroll.getListeners().removeIndex(0);

    TextFieldFilter filter =
        new TextFieldFilter() {
          @Override
          public boolean acceptChar(TextField textField, char c) {
            textBuffer = textField.getText();
            cursorBuffer = textField.getCursorPosition();
            if (c == '-' && (cursorBuffer == 0 || updateProperties)) return true;
            if (c >= '0' && c <= '9' || c == '.') return true;

            return false;
          }
        };

    TextFieldListener listener =
        new TextFieldListener() {
          @Override
          public void keyTyped(TextField textField, char c) {
            if (editActors == null || c == 0 || c == '\t') return;

            if (c == '\r' || c == '\n') {
              getStage().setKeyboardFocus(null);
              return;
            }

            GroupCommand groupCommand = new GroupCommand();

            for (Actor model : editActors) {
              if (textField == name) {
                NameCommand nameCommand = new NameCommand();
                nameCommand.setNewName(textField.getText());
                nameCommand.addActor(model);
                nameCommand.addUpdater(
                    ((MainScreen) GameInstance.game.getScreen()).getTree().panelUpdater);
                groupCommand.addCommand(nameCommand);
              } else {
                if (c == '.'
                    && textField.getText().indexOf(c) != textField.getText().lastIndexOf(c)) {
                  textField.setText(textBuffer);
                  textField.setCursorPosition(cursorBuffer);
                  return;
                }

                if (textField.getText().isEmpty()) return;

                try {
                  Float value = Float.parseFloat(textField.getText());
                  if (textField == positionX) {
                    TranslateCommand transCommand = new TranslateCommand();
                    transCommand.setNewPosition(value, model.getY());
                    transCommand.addActor(model);
                    groupCommand.addCommand(transCommand);
                  } else if (textField == positionY) {
                    TranslateCommand transCommand = new TranslateCommand();
                    transCommand.setNewPosition(model.getX(), value);
                    transCommand.addActor(model);
                    groupCommand.addCommand(transCommand);
                  } else if (textField == rotation) {
                    RotateCommand rotateCommand = new RotateCommand();
                    rotateCommand.setAngle(value);
                    rotateCommand.addActor(model);
                    groupCommand.addCommand(rotateCommand);
                  } else if (textField == scaleX) {
                    ScaleCommand scaleCommand = new ScaleCommand();
                    scaleCommand.setNewScale(
                        value, lockRatio.isChecked() ? value : model.getScaleY());
                    scaleCommand.addActor(model);
                    groupCommand.addCommand(scaleCommand);

                    if (lockRatio.isChecked()) scaleY.setText(scaleX.getText());
                  } else if (textField == scaleY) {
                    ScaleCommand scaleCommand = new ScaleCommand();
                    scaleCommand.setNewScale(model.getScaleX(), value);
                    scaleCommand.addActor(model);
                    groupCommand.addCommand(scaleCommand);
                  } else {
                    ColorCommand colorCommand = new ColorCommand();
                    colorCommand.addActor(model);
                    value /= 255.0f;
                    value = Math.min(1.0f, Math.max(0.0f, value));
                    if (textField == r) colorCommand.setR(value);
                    else if (textField == g) colorCommand.setG(value);
                    else if (textField == b) colorCommand.setB(value);
                    else colorCommand.setA(value);
                    groupCommand.addCommand(colorCommand);
                  }
                } catch (NumberFormatException exception) {
                }
              }
            }

            if (groupCommand.getCommands().size > 0)
              CommandController.instance.addCommand(groupCommand, false);
          }
        };

    InputListener tabListener =
        new InputListener() {
          @Override
          public boolean keyUp(InputEvent event, int keycode) {
            if (event.getCharacter() == '\t') {
              Actor actor = event.getListenerActor();
              if (actor instanceof TextField) ((TextField) actor).selectAll();
            }
            return true;
          }
        };

    // name
    name = new TextField("", skin);
    name.setTextFieldListener(listener);
    name.addListener(tabListener);
    content.add(new Label("Name: ", skin));
    content.add(name);

    // visible
    visible = new CheckBox(" visible", skin);
    visible.getStyle().disabledFontColor = disableColor;
    visible.addListener(
        new ChangeListener() {
          @Override
          public void changed(ChangeEvent event, Actor actor) {
            if (updateProperties || editActors == null) return;

            GroupCommand groupCommand = new GroupCommand();

            for (Actor model : editActors) {
              VisibleCommand command = new VisibleCommand();
              command.setNewVisible(visible.isChecked());
              command.addActor(model);
              groupCommand.addCommand(command);
            }

            CommandController.instance.addCommand(groupCommand);
          }
        });
    content.add(visible);

    content.row();

    // position
    positionX = new TextField("", skin);
    positionX.setTextFieldListener(listener);
    positionX.setTextFieldFilter(filter);
    positionX.addListener(tabListener);
    positionY = new TextField("", skin);
    positionY.setTextFieldListener(listener);
    positionY.setTextFieldFilter(filter);
    positionY.addListener(tabListener);
    content.add(new Label("Position: ", skin));
    content.add(positionX);
    content.add(positionY);

    content.row();

    // angle
    rotation = new TextField("", skin);
    rotation.setTextFieldListener(listener);
    rotation.setTextFieldFilter(filter);
    rotation.addListener(tabListener);
    content.add(new Label("Angle: ", skin));
    content.add(rotation);

    lockRatio = new CheckBox(" ratio", skin);
    lockRatio.getStyle().disabledFontColor = disableColor;
    lockRatio.addListener(
        new ChangeListener() {
          @Override
          public void changed(ChangeEvent event, Actor actor) {
            if (updateProperties || editActors == null) return;

            scaleY.setDisabled(lockRatio.isChecked());
            scaleY.setColor(lockRatio.isChecked() ? disableColor : enableColor);

            if (lockRatio.isChecked()) {
              scaleY.setText(scaleX.getText());

              GroupCommand groupCommand = new GroupCommand();
              for (Actor model : editActors) {
                ScaleCommand scaleCommand = new ScaleCommand();
                scaleCommand.setNewScale(model.getScaleX(), model.getScaleX());
                scaleCommand.addActor(model);
                groupCommand.addCommand(scaleCommand);
              }
              CommandController.instance.addCommand(groupCommand);
            }
          }
        });
    content.add(lockRatio);

    content.row();

    // scale
    scaleX = new TextField("", skin);
    scaleX.setTextFieldListener(listener);
    scaleX.setTextFieldFilter(filter);
    scaleX.addListener(tabListener);
    scaleY = new TextField("", skin);
    scaleY.setTextFieldListener(listener);
    scaleY.setTextFieldFilter(filter);
    scaleX.addListener(tabListener);
    content.add(new Label("Scale: ", skin));
    content.add(scaleX);
    content.add(scaleY);

    content.row();

    r = new TextField("", skin);
    r.setTextFieldListener(listener);
    r.setTextFieldFilter(filter);
    r.addListener(tabListener);
    g = new TextField("", skin);
    g.setTextFieldListener(listener);
    g.setTextFieldFilter(filter);
    g.addListener(tabListener);
    b = new TextField("", skin);
    b.setTextFieldListener(listener);
    b.setTextFieldFilter(filter);
    b.addListener(tabListener);
    a = new TextField("", skin);
    a.setTextFieldListener(listener);
    a.setTextFieldFilter(filter);
    a.addListener(tabListener);
    content.add(new Label("Color: ", skin));

    Table colorTable = new Table(skin);
    colorTable.defaults().spaceBottom(10);
    colorTable.defaults().space(10);
    colorTable.add(r).width(75);
    colorTable.add(g).width(75);
    content.add(colorTable);
    colorTable = new Table(skin);
    colorTable.defaults().spaceBottom(10);
    colorTable.defaults().space(10);
    colorTable.add(b).width(75);
    colorTable.add(a).width(75);
    content.add(colorTable);

    content.row();

    final TextButtonStyle styleButton = skin.get(TextButtonStyle.class);
    TextButtonStyle style =
        new TextButtonStyle(styleButton.up, styleButton.down, styleButton.down, styleButton.font);
    style.disabledFontColor = disableColor;
    advancedButton = new TextButton("Advanced", style);
    advancedButton.addListener(
        new ClickListener() {
          @Override
          public void clicked(InputEvent event, float x, float y) {
            PanelAdvanced advanced = ((MainScreen) GameInstance.game.getScreen()).getAdvanced();
            advanced.setVisible(advancedButton.isChecked());
          }
        });
    content.add(new Label("Settings: ", skin));
    content.add(advancedButton);

    setSize(450, 300);
    setEditActors(null);
  }
 Table table(Actor... actors) {
   Table table = new Table();
   table.defaults().space(6);
   table.add(actors);
   return table;
 }
    void layout() {
      root.defaults().space(6);
      root.columnDefaults(0).top().right().padTop(3);
      root.columnDefaults(1).left();
      root.add("Scale:");
      {
        Table table = table();
        table.add(scaleLabel).width(29);
        table.add(scaleSlider).fillX().expandX();
        root.add(table).fill().row();
      }
      root.add("Flip:");
      root.add(table(flipXCheckbox, flipYCheckbox)).row();
      root.add("Debug:");
      root.add(table(debugBonesCheckbox, debugRegionsCheckbox, debugBoundingBoxesCheckbox)).row();
      root.add();
      root.add(table(debugMeshHullCheckbox, debugMeshTrianglesCheckbox, debugPathsCheckbox)).row();
      root.add("Atlas alpha:");
      root.add(premultipliedCheckbox).row();

      root.add(new Image(skin.newDrawable("white", new Color(0x4e4e4eff))))
          .height(1)
          .fillX()
          .colspan(2)
          .pad(-3, 0, 1, 0)
          .row();

      root.add("Setup pose:");
      root.add(table(bonesSetupPoseButton, slotsSetupPoseButton, setupPoseButton)).row();
      root.add("Skin:");
      root.add(skinScroll).expand().fill().row();

      root.add(new Image(skin.newDrawable("white", new Color(0x4e4e4eff))))
          .height(1)
          .fillX()
          .colspan(2)
          .pad(1, 0, 1, 0)
          .row();

      root.add("Track:");
      {
        Table table = table();
        for (TextButton button : trackButtons.getButtons()) table.add(button);
        table.add(loopCheckbox);
        root.add(table).row();
      }
      root.add("Entry alpha:");
      {
        Table table = table();
        table.add(alphaLabel).width(29);
        table.add(alphaSlider).fillX().expandX();
        root.add(table).fill().row();
      }
      root.add("Animation:");
      root.add(animationScroll).expand().fill().row();
      root.add("Default mix:");
      {
        Table table = table();
        table.add(mixLabel).width(29);
        table.add(mixSlider).fillX().expandX();
        root.add(table).fill().row();
      }
      root.add("Speed:");
      {
        Table table = table();
        table.add(speedLabel).width(29);
        table.add(speedSlider).fillX().expandX();
        root.add(table).fill().row();
      }

      window.add(root).expand().fill();
      window.pack();
      stage.addActor(window);

      stage.addActor(statusLabel);

      {
        Table table = new Table();
        table.setFillParent(true);
        table.setTouchable(Touchable.disabled);
        stage.addActor(table);
        table.pad(10, 10, 22, 10).bottom().right();
        table.add(toasts);
      }

      {
        Table table = new Table();
        table.setFillParent(true);
        table.setTouchable(Touchable.disabled);
        stage.addActor(table);
        table.pad(10).top().right();
        table.defaults().right();
        table.add(new Label("", skin, "default", Color.LIGHT_GRAY)); // Version.
      }
    }
	private void fillTable() {
		StyleHelper helper = StyleHelper.getInstance();

		Table leftTable = new Table();
		ImageButton menu = new ImageButton(
				helper.getImageButtonStyleRound("widgets/icon-menu"));
		ImageButton hint = new ImageButton(
				helper.getImageButtonStyleRound("widgets/icon-hint"));
		zoomIn = new ImageButton(
				helper.getImageButtonStyleRound("widgets/icon-plus"));
		zoomOut = new ImageButton(
				helper.getImageButtonStyleRound("widgets/icon-minus"));
		Button goal = new ImageButton(
				helper.getImageButtonStyleRound("widgets/icon-goal"));
		ImageButton startSimulation = new ImageButton(StyleHelper.getInstance()
				.getImageButtonStyleRound("widgets/icon-next"));
		startSimulation.addListener(new StartSimulationListener());

		// add listeners
		menu.addListener(new MenuClickListener());
		hint.addListener(new HintClickListener());

		leftTable.pad(30);
		leftTable.defaults().space(30);
		leftTable.add(menu).size(100).top().left();
		leftTable.row();
		// TODO only activated after some time
		leftTable.add(hint).expand().size(100).top().left();
		leftTable.row();
		leftTable.add(goal).expand().size(100).top().left();
		leftTable.row();

		leftTable.add(zoomIn).size(70).left();
		leftTable.row();
		leftTable.add(zoomOut).size(70).left();

		final ColorController colorController = gameController
				.getColorController();

		final ActorLayoutConfiguration config = new ActorLayoutConfiguration();
		config.setColorController(colorController);
		boardActor = new BoardActor(gameController.getShownBoard(), config);
		boardActor.setColorBlindEnabled(game.getSettingController()
				.getCurrentSetting().isColorblindEnabled());

		game.getSettingController().addSettingChangeListener(boardActor);
		// used to make resetting the board via game controller possible
		gameController.registerPlacementBoardEventListener(boardActor
				.getBoardEventListener());
		final Table boardTable = new Table();
		boardTable.add(boardActor).fill().expand();

		final Table controlTable = new Table();
		controlTable.add(leftTable).expand().fill();

		if (gameController.getLevel().getShowObjectBar()) {

			boardActor.enableLayoutEditing(
					gameController.getPlacmentBoardEventListener(), true);
			ObjectBar objectBar = boardActor.getObjectBar();
			objectBar.add(startSimulation).size(200);
			controlTable.add(objectBar).padLeft(30);

		} else {
			boardActor.enableLayoutEditing(
					gameController.getPlacmentBoardEventListener(), false);
			controlTable.add(startSimulation).bottom().right().size(200)
					.pad(30);
		}

		table.stack(boardTable, controlTable).fill().expand();
		onSettingChange(game.getSettingController().getCurrentSetting());

		BoardActor goalBoard = new BoardActor(gameController.getLevel()
				.getGoalBoard(), config);
		goalBoard.setZoomAndPanEnabled(false);
		goalBoard.setColorBlindEnabled(game.getSettingController()
				.getCurrentSetting().isColorblindEnabled());
		game.getSettingController().addSettingChangeListener(goalBoard);
		Table goalTable = new Table();
		goalTable.add(goalBoard).size(getViewportHeight());
		goal.addListener(new GoalClickListener());

		goalDialog.addListener(new ClickListener() {
			@Override
			public void clicked(InputEvent event, float x, float y) {
				goalDialog.hide();
			}
		});

		goalDialog.add(goalTable).width(getViewportWidth() - 250)
				.height(getViewportHeight());

	}
  public HotbarInventoryView(
      Stage stage,
      Skin skin,
      Inventory hotbarInventory,
      Inventory inventory,
      DragAndDrop dragAndDrop,
      OreClient client) {
    m_skin = skin;
    m_inventory = inventory;
    m_client = client;
    m_stage = stage;

    m_hotbarInventory = hotbarInventory;
    // attach to the inventory model
    m_hotbarInventory.addListener(this);

    container = new Table(m_skin);
    container.setFillParent(true);
    container.top().left().setSize(800, 100);
    container.padLeft(10).padTop(10);

    container.defaults().space(4);

    stage.addActor(container);

    Image dragImage = new Image();
    dragImage.setSize(32, 32);

    for (byte i = 0; i < Inventory.maxHotbarSlots; ++i) {

      Image slotImage = new Image();

      SlotElement element = new SlotElement();
      m_slots[i] = element;

      element.itemImage = slotImage;

      Table slotTable = new Table(m_skin);
      element.table = slotTable;
      slotTable.setTouchable(Touchable.enabled);
      slotTable.addListener(new SlotClickListener(this, i));
      slotTable.addListener(new SlotInputListener(this, i));

      slotTable.add(slotImage);
      slotTable.background("default-pane");

      slotTable.row();

      Label itemCount = new Label(null, m_skin);
      slotTable.add(itemCount).bottom().fill();
      element.itemCountLabel = itemCount;

      //            container.add(slotTable).size(50, 50);
      container.add(slotTable).fill().size(50, 50);
      setHotbarSlotVisible(i, false);

      dragAndDrop.addSource(new HotbarDragSource(slotTable, i, dragImage, this));

      dragAndDrop.addTarget(new HotbarDragTarget(slotTable, i, this));
    }

    m_tooltip = new Label(null, m_skin);
    stage.addActor(m_tooltip);
  }
Beispiel #12
0
  public InventoryUI() {
    super("Inventory", Utility.STATUSUI_SKIN, "solidbackground");

    _observers = new Array<InventoryObserver>();

    _dragAndDrop = new DragAndDrop();
    _inventoryActors = new Array<Actor>();

    // create
    _inventorySlotTable = new Table();
    _inventorySlotTable.setName("Inventory_Slot_Table");

    _playerSlotsTable = new Table();
    _equipSlots = new Table();
    _equipSlots.setName("Equipment_Slot_Table");

    _equipSlots.defaults().space(10);
    _inventorySlotTooltip = new InventorySlotTooltip(Utility.STATUSUI_SKIN);

    Label DPLabel = new Label("Defense: ", Utility.STATUSUI_SKIN);
    _DPValLabel = new Label(String.valueOf(_DPVal), Utility.STATUSUI_SKIN);

    Label APLabel = new Label("Attack : ", Utility.STATUSUI_SKIN);
    _APValLabel = new Label(String.valueOf(_APVal), Utility.STATUSUI_SKIN);

    Table labelTable = new Table();
    labelTable.add(DPLabel).align(Align.left);
    labelTable.add(_DPValLabel).align(Align.center);
    labelTable.row();
    labelTable.row();
    labelTable.add(APLabel).align(Align.left);
    labelTable.add(_APValLabel).align(Align.center);

    InventorySlot headSlot =
        new InventorySlot(
            ItemUseType.ARMOR_HELMET.getValue(),
            new Image(Utility.ITEMS_TEXTUREATLAS.findRegion("inv_helmet")));

    InventorySlot leftArmSlot =
        new InventorySlot(
            ItemUseType.WEAPON_ONEHAND.getValue()
                | ItemUseType.WEAPON_TWOHAND.getValue()
                | ItemUseType.ARMOR_SHIELD.getValue()
                | ItemUseType.WAND_ONEHAND.getValue()
                | ItemUseType.WAND_TWOHAND.getValue(),
            new Image(Utility.ITEMS_TEXTUREATLAS.findRegion("inv_weapon")));

    InventorySlot rightArmSlot =
        new InventorySlot(
            ItemUseType.WEAPON_ONEHAND.getValue()
                | ItemUseType.WEAPON_TWOHAND.getValue()
                | ItemUseType.ARMOR_SHIELD.getValue()
                | ItemUseType.WAND_ONEHAND.getValue()
                | ItemUseType.WAND_TWOHAND.getValue(),
            new Image(Utility.ITEMS_TEXTUREATLAS.findRegion("inv_shield")));

    InventorySlot chestSlot =
        new InventorySlot(
            ItemUseType.ARMOR_CHEST.getValue(),
            new Image(Utility.ITEMS_TEXTUREATLAS.findRegion("inv_chest")));

    InventorySlot legsSlot =
        new InventorySlot(
            ItemUseType.ARMOR_FEET.getValue(),
            new Image(Utility.ITEMS_TEXTUREATLAS.findRegion("inv_boot")));

    headSlot.addListener(new InventorySlotTooltipListener(_inventorySlotTooltip));
    leftArmSlot.addListener(new InventorySlotTooltipListener(_inventorySlotTooltip));
    rightArmSlot.addListener(new InventorySlotTooltipListener(_inventorySlotTooltip));
    chestSlot.addListener(new InventorySlotTooltipListener(_inventorySlotTooltip));
    legsSlot.addListener(new InventorySlotTooltipListener(_inventorySlotTooltip));

    headSlot.addObserver(this);
    leftArmSlot.addObserver(this);
    rightArmSlot.addObserver(this);
    chestSlot.addObserver(this);
    legsSlot.addObserver(this);

    _dragAndDrop.addTarget(new InventorySlotTarget(headSlot));
    _dragAndDrop.addTarget(new InventorySlotTarget(leftArmSlot));
    _dragAndDrop.addTarget(new InventorySlotTarget(chestSlot));
    _dragAndDrop.addTarget(new InventorySlotTarget(rightArmSlot));
    _dragAndDrop.addTarget(new InventorySlotTarget(legsSlot));

    _playerSlotsTable.setBackground(
        new Image(new NinePatch(Utility.STATUSUI_TEXTUREATLAS.createPatch("dialog")))
            .getDrawable());

    // layout
    for (int i = 1; i <= _numSlots; i++) {
      InventorySlot inventorySlot = new InventorySlot();
      inventorySlot.addListener(new InventorySlotTooltipListener(_inventorySlotTooltip));
      _dragAndDrop.addTarget(new InventorySlotTarget(inventorySlot));

      _inventorySlotTable.add(inventorySlot).size(_slotWidth, _slotHeight);

      inventorySlot.addListener(
          new ClickListener() {
            @Override
            public void touchUp(InputEvent event, float x, float y, int pointer, int button) {
              super.touchUp(event, x, y, pointer, button);
              if (getTapCount() == 2) {
                InventorySlot slot = (InventorySlot) event.getListenerActor();
                if (slot.hasItem()) {
                  InventoryItem item = slot.getTopInventoryItem();
                  if (item.isConsumable()) {
                    String itemInfo =
                        item.getItemUseType()
                            + Component.MESSAGE_TOKEN
                            + item.getItemUseTypeValue();
                    InventoryUI.this.notify(
                        itemInfo, InventoryObserver.InventoryEvent.ITEM_CONSUMED);
                    slot.removeActor(item);
                    slot.remove(item);
                  }
                }
              }
            }
          });

      if (i % _lengthSlotRow == 0) {
        _inventorySlotTable.row();
      }
    }

    _equipSlots.add();
    _equipSlots.add(headSlot).size(_slotWidth, _slotHeight);
    _equipSlots.row();

    _equipSlots.add(leftArmSlot).size(_slotWidth, _slotHeight);
    _equipSlots.add(chestSlot).size(_slotWidth, _slotHeight);
    _equipSlots.add(rightArmSlot).size(_slotWidth, _slotHeight);
    _equipSlots.row();

    _equipSlots.add();
    _equipSlots.right().add(legsSlot).size(_slotWidth, _slotHeight);

    _playerSlotsTable.add(_equipSlots);
    _inventoryActors.add(_inventorySlotTooltip);

    this.add(_playerSlotsTable).padBottom(20);
    this.add(labelTable);
    this.row();
    this.add(_inventorySlotTable).colspan(2);
    this.row();
    this.pack();
  }
	private void fillTable() {
		StyleHelper helper = StyleHelper.getInstance();
		ImageButton back = new ImageButton(
				helper.getImageButtonStyleRound("widgets/icon-back"));

		Table scrollTable = new Table();
		// ScrollPane scroll = new ScrollPane(scrollTable);

		Label gameplay = new Label(_("settings_title_gameplay"),
				helper.getLabelStyle(40));
		Label zoom = new Label(_("settings_title_zoom"), helper.getLabelStyle());
		Label colorBlindness = new Label(_("settings_title_color_blindness"),
				helper.getLabelStyle());
		Label sound = new Label(_("settings_title_sound"),
				helper.getLabelStyle(40));
		Label music = new Label(_("settings_title_music"),
				helper.getLabelStyle());
		Label effects = new Label(_("settings_title_effects"),
				helper.getLabelStyle());
		Label profile = new Label(_("settings_title_profile"),
				helper.getLabelStyle(40));

		zoomCheckBox = new CheckBox("", helper.getCheckBoxStyle());
		colorBlindnessCheckBox = new CheckBox("", helper.getCheckBoxStyle());

		musicSlider = new Slider(0, 100, 1, false, helper.getSliderStyle());
		effectsSlider = new Slider(0, 100, 1, false, helper.getSliderStyle());

		musicSlider.setValue(50);
		effectsSlider.setValue(50);

		TextButton editProfile = new TextButton(
				_("settings_button_edit_profile"), helper.getTextButtonStyle());

		// add listeners
		back.addListener(new LogicalPredecessorListener());

		SettingListener settingListener = new SettingListener();

		zoomCheckBox.addListener(settingListener);
		colorBlindnessCheckBox.addListener(settingListener);

		musicSlider.addListener(settingListener);
		effectsSlider.addListener(settingListener);

		editProfile.addListener(new ClickListener() {
			@Override
			public void clicked(InputEvent event, float x, float y) {
				if (game.getProfileController().getCurrentProfile() != null) {
					Dialog dialog = new EditProfileDialog();
					dialog.show(stage);
				} else {
					Dialog dialog = new NotificationDialog(
							_("warning_no_profile_selected"));
					dialog.show(stage);
				}

			}
		});

		scrollTable.defaults().left().space(10);
		scrollTable.add(gameplay).row();
		scrollTable.add(zoom).expandX().padLeft(30);
		scrollTable.add(zoomCheckBox).size(50).center().row();
		scrollTable.add(colorBlindness).expandX().padLeft(30);
		scrollTable.add(colorBlindnessCheckBox).size(50).center().row();
		scrollTable.add(sound).row();
		scrollTable.add(music).padLeft(30);
		scrollTable.add(musicSlider).width(300).height(50).row();
		scrollTable.add(effects).padLeft(30);
		scrollTable.add(effectsSlider).width(300).height(50).row();
		scrollTable.add(profile).row();
		scrollTable.add(editProfile).width(300).height(75);

		scrollTable.pad(50).padRight(150);
		table.add(back).size(100).top().left();
		table.add(scrollTable).expand().fill();
		table.pad(30);

		onProfileChange(null);
	}
Beispiel #14
0
  public MainMenuScreen(final SpaceLord2Game game, final ActionResolver resolver) {
    this.game = game;
    this.resolver = resolver;

    this.game.font = new BitmapFont();
    this.game.font.getData().scale(3);
    this.game
        .font
        .getRegion()
        .getTexture()
        .setFilter(Texture.TextureFilter.Linear, Texture.TextureFilter.Linear);

    title = new Texture(Gdx.files.internal("space_lord_2_title.png"));

    backGround = new BackGround();

    table = new Table();
    table.defaults().width(600).padBottom(100);

    stage = new Stage(new FitViewport(GameConstants.GAME_WIDTH, GameConstants.GAME_HEIGHT));

    Gdx.input.setInputProcessor(stage);

    launchSound = Gdx.audio.newSound(Gdx.files.internal("sounds/space.mp3"));

    buttonClick = Gdx.audio.newSound(Gdx.files.internal("sounds/button_click.mp3"));

    skin = new Skin();
    skin.add("default", game.font);
    Pixmap pixmap = new Pixmap(100, 100, Pixmap.Format.RGBA8888);
    pixmap.setColor(Color.GRAY);
    pixmap.fill();
    skin.add("white", new Texture(pixmap));

    // Configure a TextButtonStyle and name it "default". Skin resources are stored by type, so this
    // doesn't overwrite the font.
    TextButton.TextButtonStyle textButtonStyle = new TextButton.TextButtonStyle();
    textButtonStyle.up = skin.newDrawable("white", Color.DARK_GRAY);
    textButtonStyle.down = skin.newDrawable("white", Color.WHITE);
    textButtonStyle.checked = skin.newDrawable("white", Color.DARK_GRAY);
    textButtonStyle.over = skin.newDrawable("white", Color.LIGHT_GRAY);

    textButtonStyle.font = skin.getFont("default");

    skin.add("default", textButtonStyle);

    // Create a button with the "default" TextButtonStyle. A 3rd parameter can be used to specify a
    // name other than "default".
    final TextButton playButton = new TextButton("Play", textButtonStyle);
    table.add(playButton);
    table.row();

    final TextButton leaderboardButton = new TextButton("Leaderboard", textButtonStyle);
    table.add(leaderboardButton);
    table.row();

    final TextButton achievementButton = new TextButton("Achievements", textButtonStyle);
    table.add(achievementButton);
    table.row();

    signInButton = new TextButton("Sign In", textButtonStyle);

    table.add(signInButton);
    table.row();

    table.setPosition(GameConstants.GAME_WIDTH / 3, (GameConstants.GAME_HEIGHT / 5) * 2);

    stage.addActor(table);

    playButton.addListener(
        new ChangeListener() {
          public void changed(ChangeEvent event, Actor actor) {
            buttonClick.play();
            game.setScreen(new SpaceLord2(game, resolver));
            dispose();
          }
        });

    leaderboardButton.addListener(
        new ChangeListener() {
          public void changed(ChangeEvent event, Actor actor) {
            resolver.showLeaderboard();
          }
        });

    achievementButton.addListener(
        new ChangeListener() {
          public void changed(ChangeEvent event, Actor actor) {
            resolver.showAchievements();
          }
        });

    signInButton.addListener(
        new ChangeListener() {
          public void changed(ChangeEvent event, Actor actor) {
            buttonClick.play();
            resolver.signIn();
          }
        });

    camera = new OrthographicCamera();
    viewport = new FitViewport(GameConstants.GAME_WIDTH, GameConstants.GAME_HEIGHT, camera);
    viewport.apply();
    camera.position.set(camera.viewportWidth / 2, camera.viewportHeight / 2, 0);
  }
  @Override
  public void show() {

    // BackButton Handeling

    Drawable menuDrawable =
        new TextureRegionDrawable(
            new TextureRegion(new Texture(Gdx.files.internal("images/backgroundlevel.png"))));

    backGImage = new Image(menuDrawable, Scaling.stretch);
    backGImage.setFillParent(true);

    stage.addActor(backGImage);

    skin = new Skin(Gdx.files.internal("ui/JsonFiles/uiskin.json"));
    skin.add(
        "top",
        new TextureRegionDrawable(
            new TextureRegion(
                new Texture(Gdx.files.internal("images/levelscreen.png")), 153, 88, 150, 150)),
        Drawable.class);
    skin.add(
        "lockedlevel",
        new TextureRegionDrawable(
            new TextureRegion(
                new Texture(Gdx.files.internal("images/levelscreen.png")), 1, 88, 150, 150)),
        Drawable.class);

    skin.add(
        "star-filled",
        new TextureRegionDrawable(
            new TextureRegion(
                new Texture(Gdx.files.internal("images/levelscreen.png")), 1, 1, 90, 85)),
        Drawable.class);
    skin.add(
        "star-unfilled",
        new TextureRegionDrawable(
            new TextureRegion(
                new Texture(Gdx.files.internal("images/levelscreen.png")), 93, 1, 90, 85)),
        Drawable.class);

    // skin.add("star-filled", skin.newDrawable("white", Color.YELLOW),
    // Drawable.class);
    // skin.add("star-unfilled", skin.newDrawable("white", Color.GRAY),
    // Drawable.class);
    Gdx.input.setInputProcessor(stage);

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

    PagedScrollPane scroll = new PagedScrollPane();

    scroll.setFlingTime(0.4f);
    scroll.setPageSpacing(80);
    int c = 1;
    for (int l = 0; l < 2; l++) {
      Table levels = new Table().pad(0);
      levels.defaults().pad(0, 20, 0, 15);
      for (int y = 0; y < 2; y++) {
        levels.row();
        for (int x = 0; x < 3; x++) {
          levels.add(getLevelButton(c++)).fill().expand().size(63, 88);
        }
      }
      scroll.addPage(levels);
    }
    container.add(scroll).expand().fill();

    // backGImage.addAction(parallel(moveTo(250, 250, 2, bounceOut),
    // color(Color.RED, 6), delay(0.5f), rotateTo(180, 5, swing)));
    backGImage.addAction(
        repeat(1, (sequence(scaleTo(2, 2, 0.8f), scaleTo(1, 1, 0.8f), delay(1.9f)))));

    InputProcessor backProcessor =
        new InputAdapter() {
          @Override
          public boolean keyDown(int keycode) {

            if ((keycode == Keys.ESCAPE) || (keycode == Keys.BACK))
              game.setScreen(game.getMenuScreen());
            return false;
          }
        };

    InputMultiplexer multiplexer = new InputMultiplexer(stage, backProcessor);
    Gdx.input.setInputProcessor(multiplexer);
    Gdx.input.setCatchBackKey(true);
  }
  public Button getLevelButton(int level) {
    Button button = new Button(skin);
    ButtonStyle style = button.getStyle();
    style.up = style.down = null;

    starTable = new Table();
    starTable.defaults().pad(2);
    // System.out.println("here");

    Label label = new Label(Integer.toString(level), skin);
    label.setFontScale(1f);
    label.setAlignment(Align.center);

    Label label2 = new Label("", skin);
    label2.setFontScale(1f);
    label2.setAlignment(Align.center);

    Label labelLocked = new Label("", skin);
    label2.setFontScale(1f);
    label2.setAlignment(Align.center);

    Label starsLabel = new Label("stadfrs", skin, "big-font");

    starsLabel.setFontScale(0.3f);
    // starsLabel.setPosition(12, -5);
    starsLabel.setAlignment(Align.bottom, Align.center);

    TextureRegion crystal;
    Texture tex = new Texture(Gdx.files.internal("images/hud.png"));

    crystal = new TextureRegion(tex, 80, 0, 16, 16);
    Image img = new Image(crystal);
    img.setScale(0.5f);
    // Stack the image and the label at the top of our button

    switch (level) {
      case 1:
        Table table = new Table();
        starsLabel.setText(game.getPreferencesManager().getLevelOneHighScore() + " / " + 30);
        table.add(starsLabel).padBottom(-30).padLeft(6).bottom();
        table.add(img).padBottom(-29).padLeft(4).bottom();
        // starsLabel.setPosition(100, 100);
        button.stack(new Image(skin.getDrawable("top")), label, table).expand().fill();
        game.manager.load("images/ropes.png", Texture.class);
        break;
      case 2:
        Table table2 = new Table();
        starsLabel.setText(game.getPreferencesManager().getLevelTwoHighScore() + " / " + 30);
        table2.add(starsLabel).padBottom(-30).padLeft(6).bottom();
        table2.add(img).padBottom(-29).padLeft(4).bottom();
        if (starsLevel1 == 0) {
          button
              .stack(new Image(skin.getDrawable("lockedlevel")), labelLocked, table2)
              .expand()
              .fill();

          // button.add(starsLabel);
        } else {
          button.stack(new Image(skin.getDrawable("top")), label, table2).expand().fill();
        }
        break;
      case 3:
        Table table3 = new Table();
        starsLabel.setText(game.getPreferencesManager().getLevelThreeHighScore() + " / " + 30);
        table3.add(starsLabel).padBottom(-30).padLeft(6).bottom();
        table3.add(img).padBottom(-29).padLeft(4).bottom();
        if (starsLevel2 == 0) {
          button
              .stack(new Image(skin.getDrawable("lockedlevel")), labelLocked, table3)
              .expand()
              .fill();

          // button.add(starsLabel);
        } else {
          button.stack(new Image(skin.getDrawable("top")), label, table3).expand().fill();
        }
        break;
      case 4:
        Table table4 = new Table();
        starsLabel.setText(game.getPreferencesManager().getLevelFourHighScore() + " / " + 30);
        table4.add(starsLabel).padBottom(-30).padLeft(6).bottom();
        table4.add(img).padBottom(-29).padLeft(4).bottom();
        if (starsLevel3 == 0) {
          button
              .stack(new Image(skin.getDrawable("lockedlevel")), labelLocked, table4)
              .expand()
              .fill();

          // button.add(starsLabel);
        } else {
          button.stack(new Image(skin.getDrawable("top")), label, table4).expand().fill();
        }
        break;
      case 5:
        Table table5 = new Table();
        starsLabel.setText(game.getPreferencesManager().getLevelFiveHighScore() + " / " + 35);
        table5.add(starsLabel).padBottom(-30).padLeft(6).bottom();
        table5.add(img).padBottom(-29).padLeft(4).bottom();
        if (starsLevel4 == 0) {
          button
              .stack(new Image(skin.getDrawable("lockedlevel")), labelLocked, table5)
              .expand()
              .fill();

        } else {
          button.stack(new Image(skin.getDrawable("top")), label, table5).expand().fill();
        }
        break;
      case 6:
        Table table6 = new Table();
        starsLabel.setText(game.getPreferencesManager().getLevelSixHighScore() + " / " + 35);
        table6.add(starsLabel).padBottom(-30).padLeft(6).bottom();
        table6.add(img).padBottom(-29).padLeft(4).bottom();
        if (starsLevel5 == 0) {
          button
              .stack(new Image(skin.getDrawable("lockedlevel")), labelLocked, table6)
              .expand()
              .fill();

        } else {
          button.stack(new Image(skin.getDrawable("top")), label, table6).expand().fill();
        }
        break;
      case 7:
        Table table7 = new Table();
        starsLabel.setText(game.getPreferencesManager().getLevelSevenHighScore() + " / " + 40);
        table7.add(starsLabel).padBottom(-30).padLeft(6).bottom();
        table7.add(img).padBottom(-29).padLeft(4).bottom();
        if (starsLevel6 == 0) {
          button
              .stack(new Image(skin.getDrawable("lockedlevel")), labelLocked, table7)
              .expand()
              .fill();

        } else {
          button.stack(new Image(skin.getDrawable("top")), label, table7).expand().fill();
        }
        break;
      case 8:
        Table table8 = new Table();
        starsLabel.setText(game.getPreferencesManager().getLevelEightHighScore() + " / " + 35);
        table8.add(starsLabel).padBottom(-30).padLeft(6).bottom();
        table8.add(img).padBottom(-29).padLeft(4).bottom();
        if (starsLevel7 == 0) {
          button
              .stack(new Image(skin.getDrawable("lockedlevel")), labelLocked, table8)
              .expand()
              .fill();

        } else {
          button.stack(new Image(skin.getDrawable("top")), label, table8).expand().fill();
        }
        break;
      case 9:
        Table table9 = new Table();
        starsLabel.setText(game.getPreferencesManager().getLevelNineHighScore() + " / " + 60);
        table9.add(starsLabel).padBottom(-30).padLeft(6).bottom();
        table9.add(img).padBottom(-29).padLeft(4).bottom();
        if (starsLevel8 == 0) {
          button
              .stack(new Image(skin.getDrawable("lockedlevel")), labelLocked, table9)
              .expand()
              .fill();
        } else {
          button.stack(new Image(skin.getDrawable("top")), label, table9).expand().fill();
        }
        break;
      case 10:
        Table table10 = new Table();
        starsLabel.setText(game.getPreferencesManager().getLevelTenHighScore() + " / " + 30);
        table10.add(starsLabel).padBottom(-30).padLeft(6).bottom();
        table10.add(img).padBottom(-29).padLeft(4).bottom();
        if (starsLevel9 == 0) {
          button
              .stack(new Image(skin.getDrawable("lockedlevel")), labelLocked, table10)
              .expand()
              .fill();

          // button.add(starsLabel);
        } else {
          button.stack(new Image(skin.getDrawable("top")), label, table10).expand().fill();
        }
        break;
      case 11:
        Table table11 = new Table();
        starsLabel.setText(game.getPreferencesManager().getLevelElevenHighScore() + " / " + 35);
        table11.add(starsLabel).padBottom(-30).padLeft(6).bottom();
        table11.add(img).padBottom(-29).padLeft(4).bottom();
        if (starsLevel10 == 0) {
          button
              .stack(new Image(skin.getDrawable("lockedlevel")), labelLocked, table11)
              .expand()
              .fill();

          // button.add(starsLabel);
        } else {
          button.stack(new Image(skin.getDrawable("top")), label, table11).expand().fill();
        }
        break;
      case 12:
        Table table12 = new Table();
        starsLabel.setText(game.getPreferencesManager().getLevelTwelveHighScore() + " / " + 30);
        table12.add(starsLabel).padBottom(-30).padLeft(6).bottom();
        table12.add(img).padBottom(-29).padLeft(4).bottom();
        if (starsLevel11 == 0) {
          button
              .stack(new Image(skin.getDrawable("lockedlevel")), labelLocked, table12)
              .expand()
              .fill();

          // button.add(starsLabel);
        } else {
          button.stack(new Image(skin.getDrawable("top")), label, table12).expand().fill();
        }
        break;
    }

    button.row();
    button.add(starTable).height(10);

    button.setName(Integer.toString(level));
    button.addListener(levelClickListener);

    int levelSel = Integer.parseInt(button.getName());

    switch (levelSel) {
      case 1:
        doStars(starsLevel1);
        break;
      case 2:
        doStars(starsLevel2);
        break;
      case 3:
        doStars(starsLevel3);
        break;
      case 4:
        doStars(starsLevel4);
        break;
      case 5:
        doStars(starsLevel5);
        break;
      case 6:
        doStars(starsLevel6);
        break;
      case 7:
        doStars(starsLevel7);
        break;
      case 8:
        doStars(starsLevel8);
        break;
      case 9:
        doStars(starsLevel9);
        break;
      case 10:
        doStars(starsLevel10);
        break;
      case 11:
        doStars(starsLevel11);
        break;
      case 12:
        doStars(starsLevel12);
        break;
      default:
        for (int star = 0; star < 3; star++) {
          if (-1 > star) {
            starTable.add(new Image(skin.getDrawable("star-filled"))).width(20).height(12);
          } else {
            starTable.add(new Image(skin.getDrawable("star-unfilled"))).width(20).height(12);
          }
        }
        break;
    }

    return button;
  }
  private Table makeGameFileInfoBox(
      final Table fileRow, final FileHandle savedGameFile, GameSave towerData) {
    TextButton launchButton = FontManager.RobotoBold18.makeTextButton("Play");
    launchButton.addListener(
        new VibrateClickListener() {
          @Override
          public void onClick(InputEvent event, float x, float y) {
            dismiss();
            try {
              SceneManager.changeScene(
                  LoadTowerSplashScene.class, GameSaveFactory.readFile(savedGameFile));
            } catch (Exception e) {
              throw new RuntimeException(e);
            }
          }
        });

    TextButton deleteButton = FontManager.RobotoBold18.makeTextButton("Delete");
    deleteButton.addListener(
        new VibrateClickListener() {
          @Override
          public void onClick(InputEvent event, float x, float y) {
            new Dialog()
                .setTitle("Are you sure you want to delete this Tower?")
                .setMessage("If you delete this tower, it will disappear forever.\n\nAre you sure?")
                .addButton(
                    "Yes, delete it",
                    new OnClickCallback() {
                      @Override
                      public void onClick(Dialog dialog) {
                        savedGameFile.delete();

                        content.getCell(fileRow).ignore();
                        content.removeActor(fileRow);
                        content.invalidate();

                        dialog.dismiss();
                      }
                    })
                .addButton(
                    "Keep it!",
                    new OnClickCallback() {
                      @Override
                      public void onClick(Dialog dialog) {
                        dialog.dismiss();
                      }
                    })
                .show();
          }
        });

    Table metadata = new Table();
    metadata.defaults().top().left().fillX();
    addLabelRow(metadata, towerData.getTowerName(), FontManager.RobotoBold18, Color.WHITE);
    addLabelRow(
        metadata,
        "Population: " + getNumberInstance().format(towerData.getPlayer().getTotalPopulation()),
        FontManager.Default,
        Color.GRAY);
    Date lastPlayed = towerData.getMetadata().lastPlayed;
    if (lastPlayed != null) {
      PrettyTime prettyTime = new PrettyTime();
      addLabelRow(
          metadata,
          "Last played: " + prettyTime.format(lastPlayed),
          FontManager.Default,
          Color.GRAY);
    }

    Table box = new Table();
    box.defaults().fillX().space(Display.devicePixel(5));
    box.row().top().left().fillX();
    box.add(metadata).top().left().expandX();
    box.add(deleteButton).width(Display.devicePixel(80));
    box.add(launchButton).width(Display.devicePixel(80));

    return box;
  }