Ejemplo n.º 1
0
 public static VisTextField createTextField(String style, boolean textCursor) {
   VisTextField visTextField = new VisTextField();
   Skin skin = VisUI.getSkin();
   visTextField.setStyle(skin.get(style, VisTextField.VisTextFieldStyle.class));
   if (textCursor) visTextField.addListener(new CursorListener(CursorManager.TEXT));
   return visTextField;
 }
Ejemplo n.º 2
0
  public void init() {
    assetManager.load(ATLAS_UI, TextureAtlas.class);
    assetManager.load(SKIN_UI, Skin.class);

    assetManager.load(ATLAS_UI_BUTTONS, TextureAtlas.class);
    // assetManager.load(SKIN_UI_BUTTONS, Skin.class);
    // TODO: load game graphics atlas here
    assetManager.finishLoading();

    skinUI = assetManager.get(SKIN_UI);
    textureAtlasUI = assetManager.get(ATLAS_UI);

    textureAtlasButtons = assetManager.get(ATLAS_UI_BUTTONS, TextureAtlas.class);

    // Stopped loading the skinButton skin in the Assetmanager to generate font size on the fly
    skinButton = new Skin();
    skinButton.add(
        "default-font",
        this.fonts.getLemonMilk(Helpers.getFontSize(20, 720.0f, Gdx.graphics.getHeight())));
    skinButton.addRegions(new TextureAtlas(Gdx.files.internal("ui/9patch_buttons.atlas")));
    skinButton.load(Gdx.files.internal("ui/9patch_buttons.json"));

    // this.assetManager = assetManager;

    // assetManager.load(Constants.ATLAS_GAME, TextureAtlas.class);
    // assetManager.finishLoading();
    // TextureAtlas atlas = assetManager.get(Constants.ATLAS_GAME);

    // initAssets(atlas);
  }
Ejemplo n.º 3
0
  public AotHudGameOver(Skin sk) {
    _skin = sk;
    Label gameover = new Label("GAME OVER", _skin.get("JUNEBUG_32", LabelStyle.class));
    _retry = new Label(">> RETRY <<", _skin.get("JUNEBUG_16", LabelStyle.class));
    _lvlselect = new Label(">> LEVEL SELECTION <<", _skin.get("JUNEBUG_16", LabelStyle.class));

    _retry.setPosition(0, 0);
    _lvlselect.setPosition(_retry.getWidth() + 100, 0);

    this.setWidth(_retry.getWidth() + _lvlselect.getWidth() + 100);

    gameover.setPosition((this.getWidth() - gameover.getWidth()) / 2, _retry.getHeight() + 100);

    this.setHeight(_retry.getHeight() + gameover.getHeight() + 100);

    addActor(gameover);
    addActor(_retry);
    addActor(_lvlselect);

    this.setPosition(
        (AbstractScreen.GAME_VIEWPORT_WIDTH - this.getWidth()) / 2,
        (AbstractScreen.MENU_VIEWPORT_HEIGHT - this.getHeight()) / 2 - 100);

    _lvlselect.addListener(this);
    _retry.addListener(this);
  }
Ejemplo n.º 4
0
  private static void createNavigationGroup() {
    navigationGroup = new Group();
    navigationGroup.setVisible(false);
    Skin skin = AbstractScreen.skin;
    final ToolbarButton navigationButton = new ToolbarButton(skin.getDrawable("ic_menu"), skin);
    navigationButton.setBounds(
        0,
        AbstractScreen.stageh - NAVIGATION_BUTTON_WIDTH_HEIGHT,
        NAVIGATION_BUTTON_WIDTH_HEIGHT,
        NAVIGATION_BUTTON_WIDTH_HEIGHT);

    final NavigationPanel p = new NavigationPanel(AbstractScreen.skin, "default", navigationButton);
    p.setName(NAVIGATION_PANEL_NAME);
    p.setModal(false);
    navigationButton.addListener(
        new ClickListener() {
          @Override
          public void clicked(InputEvent event, float x, float y) {
            // event.cancel();
            if (!p.isVisible()) {
              AbstractScreen.mockupController.show(p);
            } else {
              AbstractScreen.mockupController.hide(p);
            }
          }
        });

    navigationGroup.addActor(p);
    navigationGroup.addActor(navigationButton);
  }
  @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);
  }
Ejemplo n.º 6
0
 public static VisValidableTextField createValidableTextField(
     String style, InputValidator inputValidator) {
   VisValidableTextField visTextField = new VisValidableTextField(inputValidator);
   Skin skin = VisUI.getSkin();
   visTextField.setStyle(skin.get(style, VisTextField.VisTextFieldStyle.class));
   visTextField.addListener(new CursorListener(CursorManager.TEXT));
   return visTextField;
 }
 private void doStars(float stars) {
   for (int star = 0; star < 3; star++) {
     if (stars > star) {
       starTable.add(new Image(skin.getDrawable("star-filled"))).width(20).height(15);
     } else {
       starTable.add(new Image(skin.getDrawable("star-unfilled"))).width(20).height(15);
     }
   }
 }
Ejemplo n.º 8
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();
  }
Ejemplo n.º 9
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);
  }
Ejemplo n.º 10
0
    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;
    }
Ejemplo n.º 11
0
  public ButtonMenu(float fX, float fY, float fWidth, float fHeight, String sName) {
    setBounds(fX, fY, fWidth, fHeight);

    taMenu = new TextureAtlas("menu.atlas");

    skMenu = new Skin();
    skMenu.addRegions(taMenu);

    bsMenu = new ButtonStyle();
    bsMenu.up = skMenu.getDrawable(sName + "-up");
    bsMenu.over = skMenu.getDrawable(sName + "-over");
    bsMenu.down = skMenu.getDrawable(sName + "-down");
    setStyle(bsMenu);
  }
Ejemplo n.º 12
0
  @Override
  public Component getComponent(ImageButton component) {
    // Create the component
    ControlComponent controlComponent = gameLoop.createComponent(ControlComponent.class);

    // Load basic skin for the image component
    Skin skin = gameAssets.getSkin();
    final ImageButtonStyle imageButtonStyle =
        new ImageButtonStyle(skin.get(component.getStyle(), ImageButtonStyle.class));
    com.badlogic.gdx.scenes.scene2d.ui.ImageButton button =
        new com.badlogic.gdx.scenes.scene2d.ui.ImageButton(imageButtonStyle);
    controlComponent.setControl(button);

    // If the imageUp is defined, load it and add it to style
    if (component.getImageUp() != null) {
      gameAssets.get(
          component.getImageUp(),
          Texture.class,
          new Assets.AssetLoadedCallback<Texture>() {
            @Override
            public void loaded(String fileName, Texture asset) {
              imageButtonStyle.imageUp = new TextureRegionDrawable(new TextureRegion(asset));
            }

            @Override
            public void error(String fileName, Class type, Throwable exception) {
              Gdx.app.error("ImageButtonProcessor", "Impossible to load " + fileName, exception);
            }
          });
    }

    // If the imageDown is defined, load it and add it to style
    if (component.getImageDown() != null) {
      gameAssets.get(
          component.getImageDown(),
          Texture.class,
          new Assets.AssetLoadedCallback<Texture>() {
            @Override
            public void loaded(String fileName, Texture asset) {
              imageButtonStyle.imageDown = new TextureRegionDrawable(new TextureRegion(asset));
            }

            @Override
            public void error(String fileName, Class type, Throwable exception) {
              Gdx.app.error("ImageButtonProcessor", "Impossible to load " + fileName, exception);
            }
          });
    }
    return controlComponent;
  }
Ejemplo n.º 13
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));
  }
Ejemplo n.º 14
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));
  }
Ejemplo n.º 15
0
  @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);
  }
Ejemplo n.º 16
0
 @Override
 public void dispose() {
   stage.dispose();
   skin.dispose();
   texture1.dispose();
   texture2.dispose();
 }
Ejemplo n.º 17
0
 protected VisValidableTextField createValidableTextField(
     String text, InputValidator inputValidator) {
   VisValidableTextField visTextField = new VisValidableTextField(inputValidator);
   visTextField.setText(text);
   visTextField.setStyle(skin.get("default", VisTextField.VisTextFieldStyle.class));
   return visTextField;
 }
Ejemplo n.º 18
0
 @Override
 public void dispose() {
   stage.dispose();
   skin.dispose();
   atlas.dispose();
   font.dispose();
 }
Ejemplo n.º 19
0
 @Override
 public void dispose() {
   stage.dispose();
   game.dispose();
   skin.dispose();
   batch.dispose();
 }
Ejemplo n.º 20
0
  @Override
  public void dispose() {
    if (currentTest != null) currentTest.dispose();

    stage.dispose();
    skin.dispose();
  }
Ejemplo n.º 21
0
  @Override
  public void show() {
    Texture.setEnforcePotImages(false);
    butBatch = new SpriteBatch();
    logoMenuBatch = new SpriteBatch();
    splashBatch = new SpriteBatch();

    logoTexture = new Texture("resources/logo.png");
    splashTexture = new Texture("resources/teamlogo.png");
    splashBGTexture = new Texture("resources/background2.png");
    menuBGTexture = new Texture("resources/menubg.png");

    splashSprite = new Sprite(splashTexture);
    splashBGSprite = new Sprite(splashBGTexture);
    logoSprite = new Sprite(logoTexture);
    menuBGSprite = new Sprite(menuBGTexture);

    logoSprite.setX(Gdx.graphics.getWidth() / 2 - logoSprite.getWidth() / 2);
    logoSprite.setY(Gdx.graphics.getHeight() / 2 - Gdx.graphics.getHeight() / 7);
    splashSprite.setX(Gdx.graphics.getWidth() / 2 - logoSprite.getWidth() / 2);
    splashSprite.setY(Gdx.graphics.getHeight() / 7);

    // buttons
    butAtlas = new TextureAtlas("resources/button.pack");
    butSkin = new Skin();
    butSkin.addRegions(butAtlas);
    font1 = new BitmapFont(Gdx.files.internal("resources/font_black.fnt"), false);
  }
Ejemplo n.º 22
0
  public MenuItem(Menu parentMenu, String text, Skin skin) {
    this.parentMenu = parentMenu;
    style = skin.get(MenuItemStyle.class);
    labelStyle = new LabelStyle();
    labelStyle.font = style.font;
    labelStyle.fontColor = style.fontColor;
    this.label = new Label(text, labelStyle);

    contextMenu = new ContextMenu(skin);
    contextMenu.setVisible(false);

    addActor(this.label);
    addActor(contextMenu);

    addListener(
        new ClickListener() {
          @Override
          public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
            if (contextMenu.isVisible()) {
              MenuItem.this.parentMenu.selected(null, true);
            } else {
              MenuItem.this.parentMenu.selected(MenuItem.this, true);
            }
            event.stop();
            return false;
          }

          @Override
          public void enter(InputEvent event, float x, float y, int pointer, Actor fromActor) {
            MenuItem.this.parentMenu.selected(MenuItem.this, false);
          }
        });
  }
Ejemplo n.º 23
0
 @Override
 public void dispose() {
   stage.dispose();
   skin.dispose();
   title.dispose();
   buttonClick.dispose();
   launchSound.dispose();
 }
  @Override
  public void dispose() {
    super.dispose();
    // stage.dispose();
    skin.dispose();

    game.getMusicManager().stop();
  }
Ejemplo n.º 25
0
 public ToggleBox(String text, Skin skin) {
   this.text = text;
   this.skin = skin;
   font = skin.getFont("default-font");
   checked = skin.getDrawable("check-on");
   active = skin.getDrawable("check-off");
   setTouchable(Touchable.enabled);
   addListener(
       new ClickListener() {
         public void clicked(InputEvent ev, float x, float y) {
           setSelected(!isSelected());
         }
       });
   TextBounds fb = font.getBounds(text);
   setSize(
       checked.getMinWidth() + pad + fb.width,
       Math.max(checked.getMinHeight(), font.getCapHeight()));
 }
Ejemplo n.º 26
0
 @Override
 public void dispose() {
   batch.dispose();
   ui.dispose();
   fontLabel.dispose();
   stage.dispose();
   skin.dispose();
   tiledMap.dispose();
 }
Ejemplo n.º 27
0
    public void drawLabel(Skin skin) {
      if (percentageLbl != null) this.percentageLbl.remove();

      String lifeString = String.valueOf((int) (percentage * 100)) + "%";
      this.percentageLbl = new Label(lifeString, skin);
      this.percentageLbl.setX(this.getX() + 400);
      this.percentageLbl.setY(this.getY() + 20);
      this.percentageLbl.setStyle(new LabelStyle(skin.getFont("andalus-font"), Color.WHITE));
      if (this.getStage() != null) this.getStage().addActor(percentageLbl);
    }
Ejemplo n.º 28
0
 private Touchpad getTouchPad(
     String backgroundTexturePath, String knobTexturePath, float xPos, float yPos) {
   Skin skin = new Skin();
   Texture padbgTex = new Texture(Gdx.files.internal(backgroundTexturePath));
   Texture knobTex = new Texture(Gdx.files.internal(knobTexturePath));
   padbgTex.setFilter(TextureFilter.Linear, TextureFilter.Linear);
   knobTex.setFilter(TextureFilter.Linear, TextureFilter.Linear);
   Sprite padSprite = new Sprite(padbgTex);
   padSprite.setSize(30, 30);
   Sprite knobSprite = new Sprite(knobTex);
   knobSprite.setSize(20, 20);
   skin.add("padbg", padSprite);
   skin.add("knob", knobSprite);
   TouchpadStyle touchpadStyle =
       new TouchpadStyle(skin.getDrawable("padbg"), skin.getDrawable("knob"));
   Touchpad touchpad = new Touchpad(3, touchpadStyle);
   touchpad.setPosition(xPos, yPos);
   return touchpad;
 }
Ejemplo n.º 29
0
  public CategoryButton(
      String icon, String buttonText, String categoryName, Color color, Skin skin) {
    super(true, skin.getDrawable(SkinConstants.DRAWABLE_BUTTON));
    backgroundColor(color);

    this.buttonText = buttonText;
    this.categoryName = categoryName;
    this.color = color;

    add(new IconButton(icon, skin, SkinConstants.STYLE_TOOLBAR)).marginLeft(PAD).marginRight(PAD);
    add(new Label(buttonText, skin, SkinConstants.STYLE_TOOLBAR)).expandX();
  }
Ejemplo n.º 30
0
  @Override
  public void dispose() {
    Gdx.input.setInputProcessor(null);

    if (disposeCount == 1) return;
    butBatch.dispose();
    splashBatch.dispose();
    logoMenuBatch.dispose();
    butAtlas.dispose();
    font1.dispose();
    butSkin.dispose();
    stage.dispose();
    disposeCount = 1;
  }