Exemple #1
0
  @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)));
  }
Exemple #2
0
  @Override
  public void create() {

    w = Gdx.graphics.getWidth();
    h = Gdx.graphics.getHeight();
    margin = 10;
    stage = new Stage();
    Gdx.input.setInputProcessor(stage);

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

    FreeTypeFontGenerator generator =
        new FreeTypeFontGenerator(Gdx.files.internal("data/arial.ttf"));
    BitmapFont font15 = generator.generateFont(15);
    generator.dispose();

    LabelStyle lblStyle = new LabelStyle(skin.get(LabelStyle.class));
    lblStyle.font = font15;
    lblStyle.fontColor = Color.BLACK;
    lblStyle.background = null;

    LabelStyle lblOutStyle = new LabelStyle(skin.get(LabelStyle.class));
    lblOutStyle.font = font15;
    lblOutStyle.fontColor = Color.BLACK;
    lblOutStyle.background = new ColorDrawable(new HSV_Color(Color.WHITE));

    TextButtonStyle btnStyle = skin.get(TextButtonStyle.class);
    btnStyle.font = font15;
    btnStyle.fontColor = Color.BLACK;

    lblMsg = new Label(Msg, lblStyle);
    stage.addActor(lblMsg);

    lblOut = new Label("", lblOutStyle);
    // lblOut = new Label("", lblStyle);
    lblOut.setText(" ");
    stage.addActor(lblOut);

    btnRunLibGdx = new TextButton("", btnStyle);
    stage.addActor(btnRunLibGdx);

    btnRunTranslations = new TextButton("download and copy latest translations", btnStyle);
    btnRunTranslations.addListener(runListenerTranslations);
    stage.addActor(btnRunTranslations);

    btnRunTexturePacker = new TextButton("Pack and copy Texture Images", btnStyle);
    btnRunTexturePacker.addListener(runListenerTexture);
    stage.addActor(btnRunTexturePacker);

    TeePrintStream tee = new TeePrintStream(System.out);
    System.setOut(tee);

    chkSource();

    layout();
  }
Exemple #3
0
  private void loadHUD() {
    Skin skin = new Skin();
    TextButtonStyle style = new TextButton.TextButtonStyle();
    skin.add("default", new BitmapFont());
    style.font = skin.getFont("default");
    skin.add("default", style);

    TextButton button1 = new TextButton("HUD-Label1", skin);
    uiStage.addActor(button1);
    button1.setPosition(camera.viewportWidth / 2 - 100, 0);
    button1.setBounds(button1.getX(), button1.getY(), button1.getWidth(), button1.getHeight());

    uiStage.addActor(new TextButton("HUD-Label2", skin));
  }
  @Override
  public void resize(int width, int height) {
    if (stage == null) {
      stage = new Stage(width, height, true);
    }
    stage.clear();

    Gdx.input.setInputProcessor(stage);

    TextButtonStyle butStyle = new TextButtonStyle();
    butStyle.up = butSkin.getDrawable("butdown");
    butStyle.down = butSkin.getDrawable("butup");
    butStyle.font = font1;

    LabelStyle labelStyle = new LabelStyle();
    labelStyle.font = font1;

    mainButton = new TextButton("Start Game!", butStyle);
    closeButton = new TextButton("Do nothing", butStyle);

    mainButton.setWidth(400);
    mainButton.setHeight(100);
    mainButton.setX(Gdx.graphics.getWidth() / 2 - mainButton.getWidth() / 2);
    mainButton.setY(Gdx.graphics.getHeight() / 2 - 2 * (mainButton.getHeight() / 1.2f));

    closeButton.setWidth(400);
    closeButton.setHeight(100);
    closeButton.setX(Gdx.graphics.getWidth() / 2 - closeButton.getWidth() / 2);
    closeButton.setY(
        Gdx.graphics.getHeight() / 2
            - 2 * (closeButton.getHeight() / 1.2f)
            - (closeButton.getHeight() + 5));

    mainButton.addListener(
        new InputListener() {
          public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
            System.out.println("down");
            return true;
          }

          public void touchUp(InputEvent event, float x, float y, int pointer, int button) {
            golf.setCall(false); // disable splash screen after first use
            golf.setScreen(golf.hole, 1);
          }
        });

    stage.addActor(mainButton);
    stage.addActor(closeButton);
  }
Exemple #5
0
  private static void loadButtons(Skin skin) {
    TextButtonStyle textButtonStyle;

    for (ColorEnum color : ButtonEnum.colors) {
      for (LabelEnum size : ButtonEnum.sizes) {
        for (ButtonEnum button : ButtonEnum.values()) {
          textButtonStyle = new TextButtonStyle();
          textButtonStyle.font = skin.getFont(size.fontName);
          textButtonStyle.fontColor = color.getColor();
          textButtonStyle.up = skin.getDrawable(button.type + ".up");
          textButtonStyle.over = skin.getDrawable(button.type + ".over");
          textButtonStyle.down = skin.getDrawable(button.type + ".down");
          if (ButtonEnum.defaultColor == color) {
            if (ButtonEnum.defaultSize == size) {
              skin.add(button.type, textButtonStyle);
            }
            skin.add(button.type + "." + size.fontName, textButtonStyle);
          }
          skin.add(button.type + "." + size.fontName + "." + color.colorName, textButtonStyle);
        }
      }
    }

    skin.add("default", skin.get("default.default.black", TextButtonStyle.class));
  }
  @Override
  public void show() {
    stage = new Stage();

    Gdx.input.setInputProcessor(stage);

    atlas = new TextureAtlas("button.pack");
    skin = new Skin(atlas);

    table = new Table(skin);
    table.setBounds(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
    // table.background(new TextureRegionDrawable(new TextureRegion("Splash.png")));

    // creating font
    white = new BitmapFont(Gdx.files.internal("font.fnt"), false);

    // creating buttons
    TextButtonStyle buttonStyle = new TextButtonStyle();
    buttonStyle.up = skin.getDrawable("button.up");
    buttonStyle.down = skin.getDrawable("button.down");
    buttonStyle.pressedOffsetX = 1;
    buttonStyle.pressedOffsetY = -1;
    buttonStyle.font = white;

    buttonStart = new TextButton("START", buttonStyle);
    buttonStart.pad(10);

    table.add(buttonStart);
    stage.addActor(table);
  }
    public TextButton getPlayButton() {
      // Generate a 1x1 white texture and store it in the skin named "white".
      playBtnPixmap.setColor(Color.GREEN);
      playBtnPixmap.fill();
      skin.add("white", new Texture(playBtnPixmap));

      // Store the default libgdx font under the name "default".
      BitmapFont bfont = new BitmapFont();
      // bfont.getData().scale(1.0f);;
      skin.add("default", bfont);

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

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

      skin.add("default", textButtonStyle);

      TextButton btn = new TextButton("Play game! \nTada", textButtonStyle);
      btn.setX(Gdx.graphics.getWidth() / 2 - btn.getWidth() / 2);
      btn.setY(Gdx.graphics.getHeight() / 2);

      return btn;
    }
Exemple #8
0
  private void generateUI() {
    addActor(Res.get(Setting.UI_BASE_IMG).size(166, 133).a(.15f));
    addActor(Res.get(Setting.UI_BASE_IMG).size(74, 121).position(6, 6).a(.1f));
    addActor(Res.get(Setting.UI_BASE_IMG).size(74, 121).position(86, 6).a(.1f));

    TextButtonStyle tstyle = new TextButtonStyle();
    tstyle.down = Setting.UI_BUTTON;
    tstyle.up = Res.getDrawable(Setting.IMAGE_MENU_EQUIP + "throwbut.png");
    tstyle.font = Res.font.get(18);

    $.add(new TextButton("+1", tstyle))
        .appendTo(this)
        .onClick(
            new Runnable() {
              public void run() {
                add(1);
              }
            })
        .setPosition(198, 100)
        .setSize(120, 40)
        .getCell()
        .prefSize(140, 40);
    $.add(new TextButton("-1", tstyle))
        .appendTo(this)
        .onClick(
            new Runnable() {
              public void run() {
                add(-1);
              }
            })
        .setPosition(333, 100)
        .setSize(120, 40)
        .getCell()
        .prefSize(140, 40);

    $.add(new TextButton("+10", tstyle))
        .appendTo(this)
        .onClick(
            new Runnable() {
              public void run() {
                add(10);
              }
            })
        .setPosition(198, 50)
        .setSize(120, 40)
        .getCell()
        .prefSize(140, 40);
    $.add(new TextButton("-10", tstyle))
        .appendTo(this)
        .onClick(
            new Runnable() {
              public void run() {
                add(-10);
              }
            })
        .setPosition(333, 50)
        .setSize(120, 40)
        .getCell()
        .prefSize(140, 40);

    $.add(new TextButton("MAX", tstyle))
        .appendTo(this)
        .onClick(
            new Runnable() {
              public void run() {
                set(getMax());
              }
            })
        .setPosition(198, 0)
        .setSize(120, 40)
        .getCell()
        .prefSize(140, 40);
    $.add(new TextButton("C", tstyle))
        .appendTo(this)
        .onClick(
            new Runnable() {
              public void run() {
                set(0);
              }
            })
        .setPosition(333, 0)
        .setSize(120, 40)
        .getCell()
        .prefSize(140, 40);

    $.add(l = new Label(0, 85).align(6, 23).width(74)).appendTo(this);
    $.add(r = new Label(0, 85).align(86, 23).width(74)).appendTo(this);
  }
  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);
  }
  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);
  }
  @Override
  public void show() {
    Gdx.input.setInputProcessor(stage);

    table.setBounds(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());

    final TextButtonStyle textButtonStyle = new TextButtonStyle();
    textButtonStyle.up = skin.getDrawable("out");
    textButtonStyle.down = skin.getDrawable("pressed");
    textButtonStyle.font = font;

    heading.setFontScale(2);

    exitButton = new TextButton("EXIT", textButtonStyle);
    exitButton.addListener(
        new ClickListener() {

          @Override
          public void clicked(InputEvent event, float x, float y) {
            Gdx.app.exit();
          }
        });
    exitButton.pad(15);

    sandBoxButton = new TextButton("PATH FINDING SAND BOX", textButtonStyle);
    sandBoxButton.addListener(
        new ClickListener() {

          @Override
          public void clicked(InputEvent event, float x, float y) {
            ((Game) Gdx.app.getApplicationListener())
                .setScreen(new PathFindingSandbox(sound, "maps/grid3.tmx", true, textButtonStyle));
          }
        });
    sandBoxButton.pad(15);

    levelSelect = new TextButton("SELECT LEVEL", textButtonStyle);
    levelSelect.addListener(
        new ClickListener() {

          @Override
          public void clicked(InputEvent event, float x, float y) {
            ((Game) Gdx.app.getApplicationListener()).setScreen(new LevelMenu(sound));
          }
        });
    levelSelect.pad(15);

    toggleSound = new TextButton("TOGGLE SOUND", textButtonStyle);
    toggleSound.addListener(
        new ClickListener() {

          @Override
          public void clicked(InputEvent event, float x, float y) {
            sound.toggleGameSound();
          }
        });
    toggleSound.pad(15);

    playButton = new TextButton("PLAY", textButtonStyle);
    playButton.addListener(
        new ClickListener() {

          @Override
          public void clicked(InputEvent event, float x, float y) {
            ((Game) Gdx.app.getApplicationListener())
                .setScreen(new GearBeltSetup(sound, "maps/grid1.tmx", false));
          }
        });
    playButton.pad(15);

    table.add(heading).spaceBottom(100).row();
    table.add(playButton).spaceBottom(10).row();
    table.add(levelSelect).spaceBottom(10).row();
    table.add(sandBoxButton).spaceBottom(10).row();
    table.add(toggleSound).spaceBottom(10).row();
    table.add(exitButton).spaceBottom(10).row();
    stage.addActor(table);
  }
Exemple #12
0
  @Override
  public void show() {
    // TODO Auto-generated method stub
    stage = new Stage();
    font = new BitmapFont(Gdx.files.internal("font.fnt"), false);
    style = new LabelStyle(font, Color.RED);
    label = new Label("Juego de Prueba", style);
    label.setPosition(Gdx.graphics.getWidth() / 3, Gdx.graphics.getHeight() - 100);
    stage.addActor(label);

    skin = new Skin();
    buttonatlas = new TextureAtlas("buttons/button.pack");
    skin.addRegions(buttonatlas);

    buttonstyle = new TextButtonStyle();
    buttonstyle.up = skin.getDrawable("button");
    buttonstyle.over = skin.getDrawable("buttonpress");
    buttonstyle.down = skin.getDrawable("buttonpress");
    buttonstyle.font = font;

    button = new TextButton("Play", buttonstyle);

    stage.addActor(button);

    button.addListener(
        new InputListener() {

          @Override
          public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
            // TODO Auto-generated method stub

            game.setScreen(new PlayScreen(game));
            MainMenu.this.dispose();
            return true;
          }
        });

    // ok

    skin2 = new Skin();
    buttonatlas2 = new TextureAtlas("buttons/button2.pack");
    skin2.addRegions(buttonatlas2);

    buttonstyle2 = new TextButtonStyle();
    buttonstyle2.up = skin2.getDrawable("button2");
    buttonstyle2.over = skin2.getDrawable("button2press");
    buttonstyle2.down = skin2.getDrawable("button2press");
    buttonstyle2.font = font;

    button2 = new TextButton("", buttonstyle2);

    button2.setPosition(Gdx.graphics.getWidth() - 250, 0);

    stage.addActor(button2);

    button2.addListener(
        new InputListener() {

          @Override
          public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
            // TODO Auto-generated method stub

            game.setScreen(new tablescreen(game));
            MainMenu.this.dispose();
            return true;
          }
        });

    batch = new SpriteBatch();

    Gdx.input.setInputProcessor(stage);
  }
  @Override
  public void show() {
    // Creates an stage that contains all the GUI elements
    stage = new Stage();
    stage.clear();
    Gdx.input.setInputProcessor(stage);

    // Title label
    font100orange = new BitmapFont(Gdx.files.internal("fonts/prehistorik100orange.fnt"));
    titleLabel = new Label(this.title, new LabelStyle(font100orange, Color.WHITE));
    titleLabel.setPosition(
        Gdx.graphics.getWidth() / 2.0f - titleLabel.getWidth() / 2,
        7.1f * Gdx.graphics.getHeight() / 9.0f);

    // Textbox label
    white30boldFont = new BitmapFont(Gdx.files.internal("fonts/white30bold.fnt"));
    label1 = new Label("IP adress of game creator:", new LabelStyle(white30boldFont, Color.WHITE));
    label1.setPosition(
        Gdx.graphics.getWidth() / 2.0f - label1.getWidth() / 2,
        6 * Gdx.graphics.getHeight() / 9.0f);

    // Username
    Label usernameLabel = ScreenUtils.createLabel("Username:"******"", 0, 0);
    usernameInput.setPosition(
        Gdx.graphics.getWidth() / 2f - usernameInput.getWidth() / 2f,
        3 * Gdx.graphics.getHeight() / 9.0f);

    // Atlas of the GUI
    atlas = new TextureAtlas("gui/gui.pack");
    skin = new Skin(atlas);

    // Buttons
    font60 = new BitmapFont(Gdx.files.internal("fonts/prehistorik60black.fnt"), false);
    TextButtonStyle buttonStyle = new TextButtonStyle();
    buttonStyle.up = skin.getDrawable("button1");
    buttonStyle.over = skin.getDrawable("button1-over");
    buttonStyle.down = skin.getDrawable("button1-down");
    buttonStyle.font = font60;

    joinButton = new TextButton("Join Game", buttonStyle);
    joinButton.setHeight(100f);
    joinButton.setWidth(500f);
    joinButton.setPosition(
        Gdx.graphics.getWidth() / 2.0f - joinButton.getWidth() / 2,
        1.5f * Gdx.graphics.getHeight() / 9.0f);

    menuButton = new TextButton("Main Menu", buttonStyle);
    menuButton.setHeight(100f);
    menuButton.setWidth(500f);
    menuButton.setPosition(
        Gdx.graphics.getWidth() / 2.0f - joinButton.getWidth() / 2,
        0f * Gdx.graphics.getHeight() / 9.0f);

    // TextField
    white36nonoFont = new BitmapFont(Gdx.files.internal("fonts/white36mono.fnt"));
    TextFieldStyle tfs = new TextFieldStyle();
    tfs.font = white36nonoFont;
    tfs.cursor = skin.getDrawable("cursor");
    tfs.background = skin.getDrawable("textField");
    tfs.fontColor = Color.WHITE;
    inputAddress = new TextField("localhost", tfs);
    inputAddress.setHeight(50);
    inputAddress.setWidth(300);
    inputAddress.setPosition(
        Gdx.graphics.getWidth() / 2.0f - inputAddress.getWidth() / 2,
        5 * Gdx.graphics.getHeight() / 9.0f);

    // add actors
    stage.addActor(joinButton);
    stage.addActor(menuButton);
    stage.addActor(inputAddress);
    stage.addActor(titleLabel);
    stage.addActor(usernameLabel);
    stage.addActor(usernameInput);
    stage.addActor(titleLabel);
    stage.addActor(label1);

    joinButton.addListener(
        new ChangeListener() {

          @Override
          public void changed(ChangeEvent event, Actor actor) {
            System.out.println(inputAddress.getText());

            GameScreen.createInstance(game, false, inputAddress.getText(), usernameInput.getText());
            game.setScreen(GameScreen.getInstance());
            //						game.initInputListeners();

          }
        });

    menuButton.addListener(
        new ChangeListener() {

          @Override
          public void changed(ChangeEvent event, Actor actor) {
            game.setScreen(new MenuScreen(game));
          }
        });
  }
  @Override
  public void show() {
    openingtheme.play();
    openingtheme.setLooping(true);
    // openingtheme.setVolume(game.state.volume);
    batch = new SpriteBatch();

    stage = new Stage();
    Gdx.input.setInputProcessor(stage);
    // Straight up stolen from https://www.pinterest.comore
    //        img = new Texture("menubackground1.png");
    img = new Texture("menu_background_fix.png");
    titleimg = new Texture("SlashHeroesTitle.png");
    img.setFilter(Texture.TextureFilter.Linear, Texture.TextureFilter.Linear);
    // change these numbers around so it looks good on the presentation phone
    TextureRegion region = new TextureRegion(img, 0, 0, 600, 400);
    sprite = new Sprite(region);
    sprite.setSize(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
    sprite.setOrigin(0, 0);

    skin = new Skin();
    // Generate a 1x1 white texture and store it in the skin named "white".
    Pixmap pixmap = new Pixmap(320, 75, Pixmap.Format.RGBA8888);
    pixmap.setColor(Color.GREEN);
    pixmap.fill();
    skin.add("white", new Texture(pixmap));

    // create the custom font
    FreeTypeFontGenerator generator =
        new FreeTypeFontGenerator(Gdx.files.internal("fonts/slkscre.ttf"));
    FreeTypeFontGenerator.FreeTypeFontParameter parameter =
        new FreeTypeFontGenerator.FreeTypeFontParameter();
    parameter.size = 80;
    BitmapFont OurFont = generator.generateFont(parameter);
    generator.dispose(); // don't forget to dispose to avoid memory leaks!

    // add ourfont to the skin for our buttons.
    skin.add("default", OurFont);

    // textbuttonstyle wont overwrite the font
    TextButtonStyle textButtonStyle = new TextButtonStyle();
    textButtonStyle.up = skin.newDrawable("white", Color.DARK_GRAY);
    textButtonStyle.down = skin.newDrawable("white", Color.DARK_GRAY);
    textButtonStyle.checked = skin.newDrawable("white", Color.BLUE);
    textButtonStyle.over = skin.newDrawable("white", Color.LIGHT_GRAY);
    textButtonStyle.font = skin.getFont("default");

    skin.add("default", textButtonStyle);

    // Create a button with the "default" TextButtonStyle.
    final TextButton PlayButton = new TextButton("PLAY", textButtonStyle);
    // final TextButton ContinueButton = new TextButton("Continue",textButtonStyle);
    final TextButton SettingsButton = new TextButton("Mute", textButtonStyle);
    final TextButton QuitButton = new TextButton("Quit", textButtonStyle);
    PlayButton.setPosition(Gdx.graphics.getWidth() / 2 - 160, Gdx.graphics.getHeight() / 2 - 150);
    // ContinueButton.setPosition(Gdx.graphics.getWidth()/2 - 160, Gdx.graphics.getHeight()/2 - 85);
    //        SettingsButton.setPosition(Gdx.graphics.getWidth()/2 - 160, Gdx.graphics.getHeight()/2
    // - 165);
    SettingsButton.setPosition(
        Gdx.graphics.getWidth() / 2 - 160, Gdx.graphics.getHeight() / 2 - 300);
    //        QuitButton.setPosition(Gdx.graphics.getWidth()/2 - 160, Gdx.graphics.getHeight()/2 -
    // 245);
    QuitButton.setPosition(Gdx.graphics.getWidth() / 2 - 160, Gdx.graphics.getHeight() / 2 - 450);
    stage.addActor(PlayButton);
    // stage.addActor(ContinueButton);
    stage.addActor(SettingsButton);
    stage.addActor(QuitButton);

    PlayButton.addListener(
        new ChangeListener() {
          public void changed(ChangeEvent event, Actor actor) {
            select.play();
            PlayButton.setText("Starting new game");
            openingtheme.stop();
            game.setScreen(game.introscreen);
          }
        });
    SettingsButton.addListener(
        new ChangeListener() {
          public void changed(ChangeEvent event, Actor actor) {
            // System.out.println("Clicked! Is checked: " + button.isChecked());
            select.play();
            if (game.state.volume == 0f) {
              game.state.volume = .7f;
              openingtheme.play();
              openingtheme.setVolume(game.state.volume);
              SettingsButton.setText("Mute");
            } else {
              game.state.volume = 0f;
              openingtheme.stop();
              SettingsButton.setText("Unmute");
            }

            // TODO make this mute and unmute the non existant sound
            // mute and unmute;
          }
        });
    QuitButton.addListener(
        new ChangeListener() {
          public void changed(ChangeEvent event, Actor actor) {
            select.play();
            openingtheme.stop();
            QuitButton.setText("Quitting");
            // TODO make this quit the correct way
            System.exit(0);
          }
        });
  }