예제 #1
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();
  }
예제 #2
0
  public void create() {
    stage = new Stage();
    Gdx.input.setInputProcessor(stage);

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

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

    Table labels = new Table();
    root.add(new ScrollPane(labels, skin)).expand().fill();
    root.row();
    root.add(drawnLabel = new Label("", skin));

    for (int i = 0; i < count; i++) {
      labels.add(
          new Label("Label: " + i, skin) {
            public void draw(Batch batch, float parentAlpha) {
              super.draw(batch, parentAlpha);
              drawn++;
            }
          });
      labels.row();
    }
  }
예제 #3
0
  @Override
  public void show() { // @Override in MapPreviewScreen to allow sliding screens
    stage.addActor(table);
    table.setFillParent(true);

    Gdx.input.setInputProcessor(stage);
  }
예제 #4
0
  public JoinServerAsGuestState() {
    Input.setContext(Contexts.get(Sps.Contexts.Non_Free), Client.get().getFirstPlayerIndex());
    stage = new Stage();

    Gdx.input.setInputProcessor(stage);

    Label.LabelStyle lblStyle = new Label.LabelStyle(Assets.get().font(), Color.WHITE);
    label = new Label("Server IP:", lblStyle);

    TextField.TextFieldStyle style = new TextField.TextFieldStyle();
    style.font = Assets.get().font();
    style.cursor = UiAssets.getNewCursor();

    style.fontColor = Color.WHITE;
    style.background = UiAssets.getNewBtnBg();
    ipIn = new TextField("", style);
    stage.setKeyboardFocus(ipIn);

    ipIn.addListener(
        new ChangeListener() {

          @Override
          public void changed(ChangeEvent changeEvent, Actor actor) {
            ipIn.setBlinkTime(1);
          }
        });

    Table table = new Table();
    table.setFillParent(true);
    table.add(label);
    table.add(ipIn).minWidth(300);

    stage.addActor(table);
  }
예제 #5
0
  public IntroScreen(final DirectedGame game) {
    super(game);

    rootTable = new Table();
    rootTable.setFillParent(true);
    final Actor logo = new Image(Assets.assetsManager.get(Assets.HEADMADE_LOGO, Texture.class));
    // logo.setOrigin(logo.getWidth() / 2, logo.getHeight() / 2);
    // logo.scaleBy(2f);
    logo.setColor(Color.BLACK);

    rootTable.add(logo).center().expand();
    rootTable.row();

    // rootTable.setDebug(true);
    this.stage.addActor(rootTable);

    stage.addListener(
        new InputListener() {

          @Override
          public boolean keyDown(InputEvent event, int keycode) {
            if (keycode == Keys.ESCAPE) {
              Gdx.app.exit();
              return true;
            }
            return super.keyDown(event, keycode);
          }
        });

    Assets.instance.loadAll();
  }
예제 #6
0
  @Override
  public void show() {

    musicManager.setVolume(optionsPreferences.getMusicVolume());
    dyingSound.setVolume(optionsPreferences.getSfxVolume());
    musicManager.play(ZombieMusic.LEVEL);

    batch = new SpriteBatch();

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

    exit.setPosition(380, 558);

    table.setFillParent(true);
    stage.addActor(leave.drawReassure(musicManager));
    stage.addActor(buttons.drawButtons());
    stage.addActor(exit);
    Gdx.input.setInputProcessor(stage);

    zombieList = new ZombieList("SpawnTimes/level1.wave");
    zombieList1 = new ZombieList("SpawnTimes/level1.wave");
  }
  private void setStage() {

    stage = new Stage();
    Gdx.input.setInputProcessor(stage);
    Table table = new Table();
    table.setFillParent(true);
    stage.addActor(table);
  }
예제 #8
0
파일: Menu.java 프로젝트: vieux/hnefatafl
  @Override
  public void show() {
    super.show();

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

    TextButtonStyle bStyle = new TextButtonStyle();
    bStyle.font = Cache.getFont(48);
    bStyle.fontColor = Color.LIGHT_GRAY;
    final TextButton buttonPlay = new TextButton("PLAY", bStyle);

    buttonPlay.pad(20);
    table.add(buttonPlay);

    table.row();
    final TextButton buttonCredits = new TextButton("CREDITS", bStyle);

    buttonCredits.pad(20);
    table.add(buttonCredits);
    table.row();
    final TextButton buttonExit = new TextButton("EXIT", bStyle);

    buttonExit.pad(20);
    table.add(buttonExit);
    table.pad(150, 0, 0, 0);
    getStage().addActor(table);

    buttonPlay.addListener(
        new ClickListener() {
          @Override
          public void clicked(InputEvent event, float x, float y) {
            onExit(new LevelSelect(getGame()), buttonPlay, buttonCredits, buttonExit);
          }
        });
    buttonCredits.addListener(
        new ClickListener() {
          @Override
          public void clicked(InputEvent event, float x, float y) {
            onExit(new Credits(getGame()), buttonPlay, buttonCredits, buttonExit);
          }
        });
    buttonExit.addListener(
        new ClickListener() {
          @Override
          public void clicked(InputEvent event, float x, float y) {
            Gdx.app.exit();
          }
        });
    Tween.set(buttonPlay, ActorAccessor.ALPHA).target(0).start(getTweenManager());
    Tween.to(buttonPlay, ActorAccessor.ALPHA, 1).target(1).start(getTweenManager());
    Tween.set(buttonCredits, ActorAccessor.ALPHA).target(0).start(getTweenManager());
    Tween.to(buttonCredits, ActorAccessor.ALPHA, 1).target(1).delay(0.1f).start(getTweenManager());
    Tween.set(buttonExit, ActorAccessor.ALPHA).target(0).start(getTweenManager());
    Tween.to(buttonExit, ActorAccessor.ALPHA, 1).target(1).delay(0.2f).start(getTweenManager());

    Gdx.input.setInputProcessor(new InputMultiplexer(getStage(), new TouchDetector(this)));
  }
예제 #9
0
 /** Set up benchmark table and the rest */
 private void setUp(BenchmarkPosition benchmarkPosition) {
   table = new Table();
   table.setFillParent(true);
   table.setTouchable(Touchable.disabled);
   stage.addActor(table);
   //
   setUpBencmarks();
   setUpPosition(benchmarkPosition);
 }
예제 #10
0
  public void update(float dt, OrthographicCamera cam) {
    stage.act(dt);
    if (Core.persistentAssets.update() && !assetsLoaded) {

      GameSave.save();

      assetsLoaded = true;

      layout = new Table(Core.persistentAssets.get("skins/uiskin.json", Skin.class));
      layout.setFillParent(true);
      layout.center().bottom();

      pressBtn =
          new Label(
              "Press any key to continue",
              Core.persistentAssets.get("skins/uiskin.json", Skin.class));

      layout.add(pressBtn).padBottom(40);

      layout.debug();

      stage.addActor(layout);

      stage.addListener(
          new InputListener() {
            public boolean keyUp(InputEvent event, int keycode) {
              gsm.setState(GameStateManager.MENU);
              return false;
            }

            public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
              return true;
            }

            public void touchUp(InputEvent event, float x, float y, int pointer, int button) {
              gsm.setState(GameStateManager.MENU);
            }
          });
    }

    if (Core.persistentAssets.isLoaded("images/main-menu/background.jpg")) {
      if (!bgLoaded) {
        bgLoaded = true;
        bg =
            new Sprite(Core.persistentAssets.get("images/main-menu/background.jpg", Texture.class));
        float[] size =
            ImageUtils.minimalStretch(bg.getWidth(), bg.getHeight(), Core.WIDTH, Core.HEIGHT);

        bg.setSize(size[0], size[1]);
        bg.setPosition(size[2], size[3]);
      }
      bgOpacity += bgOpacityModifier * dt;
      bgOpacity = bgOpacity > 1 ? 1 : bgOpacity;
    }
  }
예제 #11
0
  public MainUI() {
    stage = new Stage();

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

    // LabelStyle style = new LabelStyle();
    // Label label = new Label("SOME TEXT", style);
    resize(200, 200);
  }
예제 #12
0
  private void inizializiraneWarningMessage() {
    tableMessage = new Table();
    tableMessage.setFillParent(true);
    tableMessage.top();

    labelMessage = new Label("", skin);
    labelMessage.setColor(Color.WHITE);
    labelMessage.setAlignment(Align.center);
    tableMessage.add(labelMessage).expandX().padTop(Constant.CONSTANT_TABLE_MESSAGE_PAD_TOP);
    stage.addActor(tableMessage);
  }
예제 #13
0
 protected Table getTable() {
   if (table == null) {
     table = new Table(getSkin());
     table.setFillParent(true);
     if (BeatBlaster.DEV_MODE) {
       table.debug();
     }
     stage.addActor(table);
   }
   return table;
 }
예제 #14
0
  public void create() {
    stage = new Stage();
    Gdx.input.setInputProcessor(stage);
    Skin skin = new Skin(Gdx.files.internal("data/uiskin.json"));

    Label nameLabel = new Label("Name:", skin);
    TextField nameText = new TextField("", skin);
    Label addressLabel = new Label("Address:", skin);
    TextField addressText = new TextField("", skin);

    Table table = new Table();
    stage.addActor(table);
    table.setSize(260, 195);
    table.setPosition(190, 142);
    // table.align(Align.right | Align.bottom);

    table.debug();

    TextureRegion upRegion = skin.getRegion("default-slider-knob");
    TextureRegion downRegion = skin.getRegion("default-slider-knob");
    BitmapFont buttonFont = skin.getFont("default-font");

    TextButton button = new TextButton("Button 1", skin);
    button.addListener(
        new InputListener() {
          public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
            System.out.println("touchDown 1");
            return false;
          }
        });
    table.add(button);
    // table.setTouchable(Touchable.disabled);

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

    TextButton button2 = new TextButton("Button 2", skin);
    button2.addListener(
        new ChangeListener() {
          public void changed(ChangeEvent event, Actor actor) {
            System.out.println("2!");
          }
        });
    button2.addListener(
        new InputListener() {
          public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
            System.out.println("touchDown 2");
            return false;
          }
        });
    table2.add(button2);
  }
예제 #15
0
  public GameOverlay() {
    batch = new SpriteBatch();
    stage = new Stage();
    inMux = new InputMultiplexer();
    inMux.addProcessor(stage);
    overlayStage = new Stage();

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

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

    overlayMenu = new Table();
    overlayMenu.setFillParent(true);
    overlayMenu.center();
    overlayStage.addActor(overlayMenu);
  }
예제 #16
0
  @Override
  public void show() {
    stage = new Stage();
    Gdx.input.setInputProcessor(stage);

    table = new Table();
    table.setFillParent(true);
    // table.row();
    table.right();

    mainInit();
    buttonInit();

    stage.addActor(table);
  }
  public PropertyTable(Skin skin) {
    //		super(skin);
    table = new Table(skin);
    this.skin = skin;
    top().left();
    table.top().left();

    table.add(new Label("Name", skin));
    table.add(new Label("Value", skin));
    table.setFillParent(true);

    fill();
    prefHeight(1000);

    setActor(table);
  }
예제 #18
0
  public FinalDialogueScreen(final ButtonGame game) {
    this.game = game;
    stage = new Stage(new ScreenViewport());

    dialogueLabel = new Label("", Resources.Skin());
    dialogueLabel.setWrap(true);
    dialogueLabel.setColor(Color.CYAN);

    leftPerson = new Image(new Texture(Gdx.files.internal("graphics/CaptainCalamari.png")));
    leftPerson.setVisible(false);
    rightPerson = new Image(new Texture(Gdx.files.internal("graphics/JimmyTwoButton.png")));
    leftPerson.setScaling(Scaling.none);
    rightPerson.setScaling(Scaling.none);
    stage.addListener(
        new InputListener() {
          @Override
          public boolean touchDown(
              InputEvent event, float screenX, float screenY, int pointer, int button) {

            if (count < maxCount) {
              count = advanceDialogue(count);
            } else {
              game.startLevel(Level.get(game, 10));
            }
            return true;
          }
        });

    Table table = new Table();
    table.setFillParent(true);
    table.align(Align.top);
    table.add().height(50).colspan(3).center();
    table.row();
    table.add(leftPerson);
    table.add(); // .width(20);
    table.add(rightPerson);
    table.row();
    table.add().colspan(3).height(50);
    table.row();
    table.add(dialogueLabel).width(600).colspan(3).center();
    if (Resources.DEBUG) {
      table.setDebug(true);
    }

    stage.addActor(table);
  }
예제 #19
0
파일: Hud.java 프로젝트: dfsilva/MarioBros
  public Hud(SpriteBatch sb) {
    // define our tracking variables
    worldTimer = 300;
    timeCount = 0;
    score = 0;

    // setup the HUD viewport using a new camera seperate from our gamecam
    // define our stage using that viewport and our games spritebatch
    viewport = new FitViewport(MarioBros.V_WIDTH, MarioBros.V_HEIGHT, new OrthographicCamera());
    stage = new Stage(viewport, sb);

    // define a table used to organize our hud's labels
    Table table = new Table();
    // Top-Align table
    table.top();
    // make the table fill the entire stage
    table.setFillParent(true);

    // define our labels using the String, and a Label style consisting of a font and color
    countdownLabel =
        new Label(
            String.format("%03d", worldTimer), new Label.LabelStyle(new BitmapFont(), Color.WHITE));
    scoreLabel =
        new Label(
            String.format("%06d", score), new Label.LabelStyle(new BitmapFont(), Color.WHITE));
    timeLabel = new Label("TIME", new Label.LabelStyle(new BitmapFont(), Color.WHITE));
    levelLabel = new Label("1-1", new Label.LabelStyle(new BitmapFont(), Color.WHITE));
    worldLabel = new Label("WORLD", new Label.LabelStyle(new BitmapFont(), Color.WHITE));
    marioLabel = new Label("MARIO", new Label.LabelStyle(new BitmapFont(), Color.WHITE));

    // add our labels to our table, padding the top, and giving them all equal width with expandX
    table.add(marioLabel).expandX().padTop(10);
    table.add(worldLabel).expandX().padTop(10);
    table.add(timeLabel).expandX().padTop(10);
    // add a second row to our table
    table.row();
    table.add(scoreLabel).expandX();
    table.add(levelLabel).expandX();
    table.add(countdownLabel).expandX();

    // add our table to the stage
    stage.addActor(table);
  }
예제 #20
0
  @Override
  public void show() {
    super.show();
    Table table = new Table(mSkin);
    table.setFillParent(true);

    mStage.addActor(table);

    for (NetGame game : mGames) {
      final TextButton button = new TextButton(game.getId(), mSkin);
      table.add(button).size(350, 50).uniform().spaceBottom(10);
      table.row();

      button.addListener(
          new ClickListener() {
            @Override
            public void clicked(InputEvent event, float x, float y) {
              super.clicked(event, x, y);
            }
          });
    }
  }
예제 #21
0
 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");
 }
예제 #22
0
  public void initTable() {
    table = new Table();
    table.setWidth(getWidth());
    table.setFillParent(true);
    table.center();
    table.debug();

    titleLabel = new TransparentBackgroundLabel(this.game, "", skin, "default_label");
    // Make it bigger
    titleLabel.setFontScale(1.0f);
    titleLabel.setWrap(true);
    titleLabel.setAlignment(Align.center);

    definitionLabel = new TransparentBackgroundLabel(this.game, "", skin, "default_label");
    definitionLabel.setFontScale(0.6f);
    definitionLabel.setWrap(true);
    definitionLabel.setAlignment(Align.center);

    table
        .add(titleLabel)
        .center()
        .expand()
        .width(getWidth() * 0.9f)
        .padTop(70f)
        .height(getHeight() * 0.10f);
    table.row();
    table
        .add(definitionLabel)
        .center()
        .top()
        .expand()
        .width(getWidth() * 0.9f)
        .maxHeight(getHeight() * 0.7f)
        .spaceBottom(150f);
    this.addActor(table);
  }
  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);
  }
  @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);
  }
예제 #25
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);
  }
  @Override
  public void show() {
    stage = new Stage();
    Gdx.input.setInputProcessor(stage);
    Gdx.input.setCatchBackKey(true);
    batch = new SpriteBatch();

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

    Table table1 = new Table();

    TextButton backButton = new TextButton("Change nickname", Constants.skin);
    backButton.addAction(Actions.alpha(Constants.DEFAULT_ALPHA));
    backButton.addListener(
        new ChangeListener() {
          @Override
          public void changed(ChangeEvent event, Actor actor) {
            isValidate = true;
            if (!TextFieldManager.getNewNicknameTextField()
                .getText()
                .equals(TextFieldManager.getRepeatNewNicknameTextField().getText())) {
              statusLabel.setText("Nicknames are not same!");
              isValidate = false;
            }
            if (TextFieldManager.getNewNicknameTextField()
                .getText()
                .equals(TextFieldManager.getUsernameLogin().getText())) {
              statusLabel.setText("Choose Different Nickname!");
              isValidate = false;
            }
            if (!(TextFieldManager.getNewNicknameTextField().getText().length()
                    >= Constants.MIN_PASSWORD_USERNAME_AND_NICKNAME_LENGTH
                && TextFieldManager.getNewNicknameTextField().getText().length()
                    <= Constants.MAX_PASSWORD_USERNAME_AND_NICKNAME_LENGTH)) {

              TextFieldManager.getNewNicknameTextField().setText("");
              TextFieldManager.getRepeatNewNicknameTextField().setText("");
              TextFieldManager.getRepeatNewNicknameTextField()
                  .setMessageText("must be > 4 or < 10 letters");
              TextFieldManager.getNewNicknameTextField()
                  .setMessageText("must be > 4 or < 10 letters");

            } else if (isValidate) {

              ((Game) Gdx.app.getApplicationListener()).setScreen(new ChangeProfileScreen());
            }
          }
        });

    table.add(statusLabel).row();
    table
        .add(fieldManager.changeNicknameScreenTextFields("New Nickname"))
        .pad(Constants.DEFAULT_PADDING)
        .size(Constants.DEFAULT_TEXT_FIELD_WIDTH, Constants.DEFAULT_TEXT_FIELD_HEIGHT)
        .row();
    table
        .add(fieldManager.changeNicknameScreenTextFields("repeat Nickname"))
        .pad(Constants.DEFAULT_PADDING)
        .size(Constants.DEFAULT_TEXT_FIELD_WIDTH, Constants.DEFAULT_BUTTON_HEIGHT)
        .row();
    table1
        .add(backButton)
        .size(Constants.DEFAULT_BUTTON_WIDTH, Constants.DEFAULT_BUTTON_HEIGHT)
        .pad(Constants.DEFAULT_PADDING)
        .row();
    table.add(table1).row();

    stage.addActor(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.
      }
    }
예제 #28
0
  @Override
  public void show() {
    // TODO Auto-generated method stub
    /*	skin = new Skin();
    skin.add("MAZE RUNNER 1",new Texture("dragon.png"));
    skin.add("Settings", setture);
    skin.add("How", howture);
    skin.add("About", abouture);
    skin.add("Hall", hallture);*/
    setButtonS =
        new ImageButtonStyle(
            new TextureRegionDrawable(setButtonR),
            new TextureRegionDrawable(setButtonR),
            new TextureRegionDrawable(setButtonR),
            new TextureRegionDrawable(setButtonR),
            new TextureRegionDrawable(setButtonR),
            new TextureRegionDrawable(setButtonR));
    hallButtonS =
        new ImageButtonStyle(
            new TextureRegionDrawable(hallButtonR),
            new TextureRegionDrawable(hallButtonR),
            new TextureRegionDrawable(hallButtonR),
            new TextureRegionDrawable(hallButtonR),
            new TextureRegionDrawable(hallButtonR),
            new TextureRegionDrawable(hallButtonR));
    howButtonS =
        new ImageButtonStyle(
            new TextureRegionDrawable(howButtonR),
            new TextureRegionDrawable(howButtonR),
            new TextureRegionDrawable(howButtonR),
            new TextureRegionDrawable(howButtonR),
            new TextureRegionDrawable(howButtonR),
            new TextureRegionDrawable(howButtonR));
    ;
    aboutButtonS =
        new ImageButtonStyle(
            new TextureRegionDrawable(aboutButtonR),
            new TextureRegionDrawable(aboutButtonR),
            new TextureRegionDrawable(aboutButtonR),
            new TextureRegionDrawable(aboutButtonR),
            new TextureRegionDrawable(aboutButtonR),
            new TextureRegionDrawable(aboutButtonR));
    ;
    playButtonS =
        new ImageButtonStyle(
            new TextureRegionDrawable(playButtonR),
            new TextureRegionDrawable(playButtonR),
            new TextureRegionDrawable(playButtonR),
            new TextureRegionDrawable(playButtonR),
            new TextureRegionDrawable(playButtonR),
            new TextureRegionDrawable(playButtonR));
    ;
    setButton = new ImageButton(setButtonS);
    setButton.addListener(
        new ClickListener() {
          public void clicked(InputEvent event, float x, float y) {
            game.setScreen(new Settings(game));
          }
        });

    hallButton = new ImageButton(hallButtonS);
    hallButton.addListener(
        new ClickListener() {
          public void clicked(InputEvent event, float x, float y) {
            game.setScreen(new HallFame(game, 1));
          }
        });
    howButton = new ImageButton(howButtonS);
    howButton.addListener(
        new ClickListener() {
          public void clicked(InputEvent event, float x, float y) {
            game.setScreen(new HallFame(game, 2));
            dispose();
          }
        });
    aboutButton = new ImageButton(aboutButtonS);
    aboutButton.addListener(
        new ClickListener() {
          public void clicked(InputEvent event, float x, float y) {
            game.setScreen(new HallFame(game, 3));
          }
        });
    playButton = new ImageButton(playButtonS);
    playButton.addListener(
        new ClickListener() {
          public void clicked(InputEvent event, float x, float y) {
            // game = new MazeRunner();
            game.setScreen(new PlayMode(game));
          }
        });
    // adding listeners dones
    // add to table
    int x = Gdx.graphics.getWidth() / 2;
    int y = Gdx.graphics.getHeight() / 6;
    table = new Table();
    stage = new Stage();
    table.add(setButton).size(x, y).align(y).padBottom(10).row();
    table.add(aboutButton).size(x, y).align(y).padBottom(10).row();
    table.add(howButton).size(x, y).align(y).padBottom(10).row();
    table.add(playButton).size(x, y).align(y).padBottom(10).row();
    table.add(hallButton).size(x, y).align(y).padBottom(10).row();
    table.setFillParent(true);
    stage.addActor(table);
  }
예제 #29
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));
          }
        });
  }
예제 #30
0
  private void loadScreen() {

    // Grafo de escena que contendrá todo el menú
    stage = new Stage();

    // Crea una tabla, donde añadiremos los elementos de menú
    Table table = new Table();
    table.setPosition(Constants.SCREEN_WIDTH / 2.5f, Constants.SCREEN_HEIGHT / 1.5f);
    // La tabla ocupa toda la pantalla
    table.setFillParent(true);
    table.setHeight(500);
    stage.addActor(table);

    // Etiqueta de texto
    Label label = new Label("Bienvenido a JFighter2DX", game.getSkin());
    table.addActor(label);

    // Botón
    TextButton buttonPlay = new TextButton("Partida Rapida", game.getSkin());
    buttonPlay.setPosition(label.getOriginX(), label.getOriginY() - 120);
    buttonPlay.setWidth(200);
    buttonPlay.setHeight(40);
    buttonPlay.addListener(
        new InputListener() {
          public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
            return true;
          }

          public void touchUp(InputEvent event, float x, float y, int pointer, int button) {

            dispose();
            game.setScreen(new GameScreen(game, GameType.QUICK));
          }
        });
    table.addActor(buttonPlay);

    // Botón
    TextButton buttonHistory = new TextButton("Modo Historia", game.getSkin());
    buttonHistory.setPosition(label.getOriginX(), label.getOriginY() - 170);
    buttonHistory.setWidth(200);
    buttonHistory.setHeight(40);
    buttonHistory.addListener(
        new InputListener() {
          public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
            return true;
          }

          public void touchUp(InputEvent event, float x, float y, int pointer, int button) {

            dispose();
            game.setScreen(new GameScreen(game, GameType.HISTORY));
          }
        });
    table.addActor(buttonHistory);

    // Botón
    TextButton buttonConfig = new TextButton("Configurar", game.getSkin());
    buttonConfig.setPosition(label.getOriginX(), label.getOriginY() - 220);
    buttonConfig.setWidth(200);
    buttonConfig.setHeight(40);
    buttonConfig.addListener(
        new InputListener() {
          public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
            return true;
          }

          public void touchUp(InputEvent event, float x, float y, int pointer, int button) {

            dispose();
            game.setScreen(new ConfigurationScreen(game));
          }
        });
    table.addActor(buttonConfig);

    // Botón
    TextButton buttonQuit = new TextButton("Salir", game.getSkin());
    buttonQuit.setPosition(label.getOriginX(), label.getOriginY() - 270);
    buttonQuit.setWidth(200);
    buttonQuit.setHeight(40);
    buttonQuit.addListener(
        new InputListener() {
          public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
            return true;
          }

          public void touchUp(InputEvent event, float x, float y, int pointer, int button) {

            game.dispose();
            System.exit(0);
          }
        });
    table.addActor(buttonQuit);

    Gdx.input.setInputProcessor(stage);
  }