コード例 #1
0
ファイル: DragPane.java プロジェクト: piotr-j/VisEditor
 /**
  * @param group must append its actors through standard {@link WidgetGroup#addActor(Actor)}
  *     method. Must support {@link WidgetGroup#addActorAfter(Actor, Actor)} and {@link
  *     WidgetGroup#addActorBefore(Actor, Actor)} methods. Note that {@link
  *     com.badlogic.gdx.scenes.scene2d.ui.Table} does not meet these requirements.
  * @see VerticalGroup
  * @see HorizontalGroup
  * @see GridGroup
  */
 public DragPane(final WidgetGroup group) {
   if (group == null) {
     throw new IllegalArgumentException("Group cannot be null.");
   }
   super.setActor(group);
   setTouchable(Touchable.enabled);
 }
コード例 #2
0
ファイル: DragPane.java プロジェクト: piotr-j/VisEditor
 @Override
 public void setBounds(final float x, final float y, final float width, final float height) {
   super.setBounds(x, y, width, height);
   getActor().setWidth(width);
   getActor().setHeight(height);
   // Child position omitted on purpose.
 }
コード例 #3
0
 @Override
 protected void applyToContainer(
     final LmlParser parser,
     final LmlTag tag,
     final Container<?> actor,
     final String rawAttributeData) {
   actor.maxHeight(
       LmlUtilities.parseHorizontalValue(parser, tag.getParent(), actor, rawAttributeData));
 }
コード例 #4
0
ファイル: DragPane.java プロジェクト: piotr-j/VisEditor
 /**
  * @param group will replace the internally managed group. All current children will be moved to
  *     this group.
  */
 @Override
 public void setActor(final WidgetGroup group) {
   if (group == null) {
     throw new IllegalArgumentException("Group cannot be null.");
   }
   final Group previousGroup = getActor();
   super.setActor(group);
   attachListener(); // Attaches draggable to all previous group children.
   for (final Actor child : previousGroup.getChildren()) {
     group.addActor(child); // No need to attach draggable, child was already in pane.
   }
 }
コード例 #5
0
  public final void renderPlayers() {
    // Display participated players
    for (int i = 0; i < playerPositions.size(); i++) {
      switch (playerPositions.get(i)) {
        case 1:
          p1Position.setText(Integer.toString(playerPositions.size() - i));
          p1Field.setVisible(true);

          if (1 == Constants.PLAYERID) {
            p1FieldHighlight.setVisible(true);
          }

          break;

        case 2:
          p2Position.setText(Integer.toString(playerPositions.size() - i));
          p2Field.setVisible(true);

          if (2 == Constants.PLAYERID) {
            p2FieldHighlight.setVisible(true);
          }

          break;

        case 3:
          p3Position.setText(Integer.toString(playerPositions.size() - i));
          p3Field.setVisible(true);

          if (3 == Constants.PLAYERID) {
            p3FieldHighlight.setVisible(true);
          }

          break;

        case 4:
          p4Position.setText(Integer.toString(playerPositions.size() - i));
          p4Field.setVisible(true);

          if (4 == Constants.PLAYERID) {
            p4FieldHighlight.setVisible(true);
          }

          break;
      }
    }
  }
コード例 #6
0
ファイル: DragPane.java プロジェクト: piotr-j/VisEditor
 @Override
 public void validate() {
   super.validate();
   getActor().validate();
 }
コード例 #7
0
ファイル: DragPane.java プロジェクト: piotr-j/VisEditor
 @Override
 public void invalidate() {
   super.invalidate();
   getActor().invalidate();
 }
コード例 #8
0
ファイル: DragPane.java プロジェクト: piotr-j/VisEditor
 @Override
 public void setHeight(final float height) {
   super.setHeight(height);
   getActor().setHeight(height);
 }
コード例 #9
0
ファイル: DragPane.java プロジェクト: piotr-j/VisEditor
 @Override
 public void setWidth(final float width) {
   super.setWidth(width);
   getActor().setWidth(width);
 }
コード例 #10
0
  public void setupGUI() {
    stage = new Stage();

    skin = new Skin(Gdx.files.internal("uiskin.json"));
    table = new Table(skin);
    // table.setBounds(0, 0, Gdx.graphics.getWidth(),
    // Gdx.graphics.getHeight());
    // table.setClip(true);

    Gdx.input.setInputProcessor(stage);

    // defaultStyle.over = skin.getDrawable("button.hover");

    TextButton fullScreenButton = new TextButton("Toglle Full Screen", skin, "default");
    fullScreenButton.addListener(
        new ClickListener() {
          @Override
          public void clicked(InputEvent event, float x, float y) {
            Config.fullscreen = !Config.fullscreen;
          }
        });

    // fullScreenButton.setFillParent(true);
    TextButton saveSettingsButton = new TextButton("Save settings", skin, "default");
    saveSettingsButton.addListener(
        new ClickListener() {
          @Override
          public void clicked(InputEvent event, float x, float y) {
            Config.reload();
            show();
          }
        });
    Container<TextButton> saveSettingContainer = new Container<TextButton>(saveSettingsButton);

    saveSettingContainer.padTop(Value.percentHeight(.6f, table));

    TextButton backButton = new TextButton("Go back", skin, "default");
    backButton.addListener(
        new ClickListener() {
          @Override
          public void clicked(InputEvent event, float x, float y) {
            Screens.setScreen(Screens.MAIN_MENU_SCREEN);
          }
        });

    VerticalGroup buttons1 = new VerticalGroup();
    buttons1.fill();
    buttons1.addActor(fullScreenButton);

    VerticalGroup buttons2 = new VerticalGroup();
    buttons2.fill();
    buttons2.addActor(saveSettingsButton);
    buttons2.addActor(backButton);

    // buttons.setPosition(Gdx.graphics.getWidth()/4,
    // Gdx.graphics.getHeight()/5);

    VerticalGroup resolution = new VerticalGroup();
    ButtonGroup<TextButton> buttonGroup = new ButtonGroup<>();
    buttonGroup.setMaxCheckCount(1);
    resolution.fill();

    transparentSkin = new Skin(new TextureAtlas("select.pack"));
    TextButtonStyle transparent = new TextButtonStyle();
    transparent.checked = transparentSkin.getDrawable("checked");
    transparent.up = transparentSkin.getDrawable("up");
    transparent.font = FontUtil.generateFont(Color.WHITE, 20);

    addResolutions(buttonGroup, transparent);

    for (TextButton b : buttonGroup.getButtons()) {
      resolution.addActor(b);
    }

    resolution.right();

    ScrollPane resolScroll = new ScrollPane(resolution);
    resolScroll.setHeight(700);

    Label fullScreenLabel = new Label("", skin);
    fullScreenLabel.addAction(
        Actions.forever(
            new Action() {
              @Override
              public boolean act(float delta) {
                if (Config.fullscreen) {
                  fullScreenLabel.setColor(Color.GREEN);
                  fullScreenLabel.setText("on");
                } else {
                  fullScreenLabel.setColor(Color.RED);
                  fullScreenLabel.setText("off");
                }
                return true;
              }
            }));

    table.setFillParent(true);
    Table left = new Table();
    left.add(buttons1).spaceBottom(Value.percentHeight(.6f, table));
    left.add(fullScreenLabel).top();
    left.row();
    // left.row();
    left.add(buttons2);
    // table.add(buttons1.left()).left();
    table.add(left).left().padLeft(Value.percentWidth(0.1f, table)).expandX();
    // table.add(fullScreenLabel).top().spaceRight(Value.percentWidth(.5f,
    // table));
    table.add(resolScroll).right().padRight(Value.percentWidth(0.1f, table));

    // table.row();
    // table.add(buttons2).bottom().left();
    // table.center();

    stage.addActor(table);

    if (Config.debug) table.setDebug(true);
  }
コード例 #11
0
 @Override
 protected void applyToCell(final Container<?> actor, final Cell<?> cell) {
   cell.maxHeight(actor.getMaxHeightValue());
 }
コード例 #12
0
  public WinnerScreen(ArrayList<Integer> playerPositions, Game game, Client client, Server server) {
    super(game, client, server);

    // Set input and viewpoint
    stage = new Stage(new StretchViewport(Constants.SCREENWIDTH, Constants.SCREENHEIGHT));
    Gdx.input.setInputProcessor(stage);

    // Unhides the cursor
    Gdx.input.setCursorCatched(false);

    this.playerPositions = playerPositions;

    // Set background
    rootTable.background(
        new TextureRegionDrawable(new TextureRegion(TextureManager.hostBackground)));
    rootTable.setFillParent(true);
    stage.addActor(rootTable);

    // Initialise Font
    FreeTypeFontGenerator.FreeTypeFontParameter fontOptions =
        new FreeTypeFontGenerator.FreeTypeFontParameter();
    fontOptions.size = 11;
    BitmapFont font = TextureManager.menuFont.generateFont(fontOptions);

    /** ------------------------LABEL STYLE------------------------* */
    Label.LabelStyle labelStyle = new Label.LabelStyle();
    fontOptions.size = 60;
    labelStyle.font = TextureManager.menuFont.generateFont(fontOptions);
    labelStyle.fontColor = Color.GOLD;

    /** ------------------------PLAYER DISPLAY WIDGET------------------------* */
    // Table options
    Table table = new Table();
    table.setFillParent(true);

    // P1 spawn field
    p1Field = new Container();
    p1Field.background(new TextureRegionDrawable(TextureManager.p1WalkingDownAnim.getKeyFrame(0)));
    table.add(p1Field).width(64).height(64);

    // P2 spawn field
    p2Field = new Container();
    p2Field.setVisible(false);
    p2Field.background(new TextureRegionDrawable(TextureManager.p2WalkingDownAnim.getKeyFrame(0)));
    table.add(p2Field).width(64).height(64).padLeft(96);

    // P3 spawn field
    p3Field = new Container();
    p3Field.setVisible(false);
    p3Field.background(new TextureRegionDrawable(TextureManager.p3WalkingDownAnim.getKeyFrame(0)));
    table.add(p3Field).width(64).height(64).padLeft(96);

    // P4 spawn field
    p4Field = new Container();
    p4Field.setVisible(false);
    p4Field.background(new TextureRegionDrawable(TextureManager.p4WalkingDownAnim.getKeyFrame(0)));
    table.add(p4Field).width(64).height(64).padLeft(96);

    // Stage & group options
    joinedPlayerGroup.addActor(table);
    joinedPlayerGroup.setPosition(443, 150);
    stage.addActor(joinedPlayerGroup);

    /** ------------------------PLAYER HIGHLIGHT WIDGET------------------------* */
    // Table options
    Table table2 = new Table();
    table2.setFillParent(true);

    // P1 spawn field
    p1FieldHighlight = new Container();
    p1FieldHighlight.setVisible(false);
    p1FieldHighlight.background(
        new TextureRegionDrawable(new TextureRegion(TextureManager.playerMarker)));
    table2.add(p1FieldHighlight).width(80).height(77);

    // P2 spawn field
    p2FieldHighlight = new Container();
    p2FieldHighlight.setVisible(false);
    p2FieldHighlight.background(
        new TextureRegionDrawable(new TextureRegion(TextureManager.playerMarker)));
    table2.add(p2FieldHighlight).width(80).height(77).padLeft(80);

    // P3 spawn field
    p3FieldHighlight = new Container();
    p3FieldHighlight.setVisible(false);
    p3FieldHighlight.background(
        new TextureRegionDrawable(new TextureRegion(TextureManager.playerMarker)));
    table2.add(p3FieldHighlight).width(80).height(77).padLeft(80);

    // P4 spawn field
    p4FieldHighlight = new Container();
    p4FieldHighlight.setVisible(false);
    p4FieldHighlight.background(
        new TextureRegionDrawable(new TextureRegion(TextureManager.playerMarker)));
    table2.add(p4FieldHighlight).width(80).height(77).padLeft(80);

    // Stage & group options
    playerhighlightWidget.addActor(table2);
    playerhighlightWidget.setPosition(442, 152);
    stage.addActor(playerhighlightWidget);

    /** ------------------------LABELS------------------------* */

    // Titel
    titel = new Label("", labelStyle);
    titel.setAlignment(Align.center);
    titel.setPosition((Constants.SCREENWIDTH - titel.getWidth()) / 2 + 50, 385);
    stage.addActor(titel);

    // If you are the winner
    if (Constants.PLAYERID == playerPositions.get(playerPositions.size() - 1)) {
      titel.setText("YOU WON!");
      isWinner = true;
    } else {
      isWinner = false;
      titel.setText("YOU LOOSE!");
      titel.setColor(Color.RED);
    }

    if (-1 == playerPositions.get(playerPositions.size() - 1)) {
      titel.setText("DRAW!");
      titel.setColor(Color.DARK_GRAY);
      isWinner = false;
    }

    Table positionTable = new Table();
    positionTable.setFillParent(true);

    p1Position = new Label("", labelStyle);
    p1Position.setAlignment(Align.center);

    p2Position = new Label("", labelStyle);
    p2Position.setAlignment(Align.center);

    p3Position = new Label("", labelStyle);
    p3Position.setAlignment(Align.center);

    p4Position = new Label("", labelStyle);
    p4Position.setAlignment(Align.center);

    positionTable.add(p1Position).width(64).height(64);
    positionTable.add(p2Position).width(64).height(64).padLeft(96);
    positionTable.add(p3Position).width(64).height(64).padLeft(96);
    positionTable.add(p4Position).width(64).height(64).padLeft(96);

    positionPlayerWidget.addActor(positionTable);
    positionPlayerWidget.setPosition(443, 230);
    stage.addActor(positionPlayerWidget);

    /** ------------------------MUSIC------------------------* */
    if (isWinner == false) {
      AudioManager.setCurrentMusic(AudioManager.getLooserMusic());
      AudioManager.getCurrentMusic().setLooping(true);
      AudioManager.getCurrentMusic().play();
      AudioManager.getCurrentMusic().setVolume(AudioManager.getMusicVolume() * 4);
    } else {
      AudioManager.setCurrentMusic(AudioManager.getWinnerMusic());
      AudioManager.getCurrentMusic().setLooping(true);
      AudioManager.getCurrentMusic().play();
      AudioManager.getCurrentMusic().setVolume(AudioManager.getMusicVolume() * 6);
    }

    /** ------------------------BUTTONS------------------------* */
    TextButton.TextButtonStyle textButtonStyleBack = new TextButton.TextButtonStyle();
    textButtonStyleBack.font = font;
    textButtonStyleBack.up = backSkin.getDrawable("button_up");
    textButtonStyleBack.down = backSkin.getDrawable("button_down");
    textButtonStyleBack.over = backSkin.getDrawable("button_checked");

    // Back button
    backButton = new TextButton("", textButtonStyleBack);
    backButton.setPosition(0, Constants.SCREENHEIGHT - backButton.getHeight() + 7);
    stage.addActor(backButton);

    renderPlayers();

    // Add click listener --> Back button
    backButton.addListener(
        new ChangeListener() {
          @Override
          public void changed(ChangeListener.ChangeEvent event, Actor actor) {
            // Add click musik
            AudioManager.playClickSound();

            // Wait till sound is done
            try {
              Thread.sleep(100);

            } catch (InterruptedException ex) {

            }

            if (isWinner) {
              AudioManager.getCurrentMusic().stop();
            } else {
              AudioManager.getCurrentMusic().stop();
            }

            server.stopServer();
            game.setScreen(new MenuScreen(game, client, server));
          }
        });
  }