Ejemplo n.º 1
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.º 2
0
  private static void loadLabels(Skin skin) {
    Label.LabelStyle labelStyle;

    for (ColorEnum color : LabelEnum.colors) {
      for (LabelEnum label : LabelEnum.values()) {
        labelStyle = new Label.LabelStyle();
        labelStyle.font = skin.getFont(label.fontName);
        labelStyle.fontColor = color.getColor();
        labelStyle.background = skin.getDrawable("transparent");
        if (LabelEnum.defaultColor == color) {
          skin.add(label.fontName, labelStyle);
        }
        skin.add(label.fontName + "." + color.colorName, labelStyle);
      }
    }

    skin.add("default", skin.get("default.black", LabelStyle.class));
  }
Ejemplo n.º 3
0
  private static void loadResources(Skin skin) {
    FreeTypeFontGenerator gen = new FreeTypeFontGenerator(Gdx.files.internal("graduate.ttf"));
    FreeTypeFontGenerator.FreeTypeFontParameter param =
        new FreeTypeFontGenerator.FreeTypeFontParameter();
    param.size = 12;
    skin.add("x-small", gen.generateFont(param));
    param.size = 16;
    skin.add("small", gen.generateFont(param));
    param.size = 20;
    skin.add("default", gen.generateFont(param));
    param.size = 24;
    skin.add("medium", gen.generateFont(param));
    param.size = 32;
    skin.add("big", gen.generateFont(param));
    param.size = 48;
    skin.add("huge", gen.generateFont(param));
    param.size = 72;
    skin.add("x-huge", gen.generateFont(param));

    skin.add(
        "default.up",
        new NinePatch(new Texture(Gdx.files.internal("button.up.default.9.png")), 16, 16, 16, 16));
    skin.add(
        "default.over",
        new NinePatch(
            new Texture(Gdx.files.internal("button.over.default.9.png")), 16, 16, 16, 16));
    skin.add(
        "default.down",
        new NinePatch(
            new Texture(Gdx.files.internal("button.down.default.9.png")), 16, 16, 16, 16));

    skin.add(
        "success.up",
        new NinePatch(new Texture(Gdx.files.internal("button.up.success.9.png")), 16, 16, 16, 16));
    skin.add(
        "success.over",
        new NinePatch(
            new Texture(Gdx.files.internal("button.over.success.9.png")), 16, 16, 16, 16));
    skin.add(
        "success.down",
        new NinePatch(
            new Texture(Gdx.files.internal("button.down.success.9.png")), 16, 16, 16, 16));

    skin.add(
        "warning.up",
        new NinePatch(new Texture(Gdx.files.internal("button.up.warning.9.png")), 16, 16, 16, 16));
    skin.add(
        "warning.over",
        new NinePatch(
            new Texture(Gdx.files.internal("button.over.warning.9.png")), 16, 16, 16, 16));
    skin.add(
        "warning.down",
        new NinePatch(
            new Texture(Gdx.files.internal("button.down.warning.9.png")), 16, 16, 16, 16));

    skin.add(
        "error.up",
        new NinePatch(new Texture(Gdx.files.internal("button.up.error.9.png")), 16, 16, 16, 16));
    skin.add(
        "error.over",
        new NinePatch(new Texture(Gdx.files.internal("button.over.error.9.png")), 16, 16, 16, 16));
    skin.add(
        "error.down",
        new NinePatch(new Texture(Gdx.files.internal("button.down.error.9.png")), 16, 16, 16, 16));

    skin.add(
        "window", new NinePatch(new Texture(Gdx.files.internal("window.9.png")), 32, 32, 32, 32));

    skin.add("checkbox.on", new Texture(Gdx.files.internal("checkbox.on.default.png")));
    skin.add("checkbox.off", new Texture(Gdx.files.internal("checkbox.off.default.png")));
    skin.add("checkbox.on.disabled", new Texture(Gdx.files.internal("checkbox.on.disabled.png")));
    skin.add("checkbox.off.disabled", new Texture(Gdx.files.internal("checkbox.off.disabled.png")));

    skin.add(
        "checkbox.on.slider.horizontal",
        new Texture(Gdx.files.internal("checkbox.on.slider.horizontal.png")));
    skin.add(
        "checkbox.off.slider.horizontal",
        new Texture(Gdx.files.internal("checkbox.off.slider.horizontal.png")));

    skin.add("radiobutton.on", new Texture(Gdx.files.internal("radiobutton.on.default.png")));
    skin.add(
        "radiobutton.on.over", new Texture(Gdx.files.internal("radiobutton.on.over.default.png")));
    skin.add("radiobutton.off", new Texture(Gdx.files.internal("radiobutton.off.default.png")));
    skin.add(
        "radiobutton.off.over",
        new Texture(Gdx.files.internal("radiobutton.off.over.default.png")));
    skin.add(
        "radiobutton.disabled",
        new Texture(Gdx.files.internal("radiobutton.disabled.default.png")));

    skin.add("arrow.up", new Texture(Gdx.files.internal("arrow.up.default.png")));
    skin.add("arrow.up.disabled", new Texture(Gdx.files.internal("arrow.up.disabled.png")));
    skin.add("arrow.down", new Texture(Gdx.files.internal("arrow.down.default.png")));
    skin.add("arrow.down.disabled", new Texture(Gdx.files.internal("arrow.down.disabled.png")));
    skin.add("arrow.left", new Texture(Gdx.files.internal("arrow.left.default.png")));
    skin.add("arrow.left.disabled", new Texture(Gdx.files.internal("arrow.left.disabled.png")));
    skin.add("arrow.right", new Texture(Gdx.files.internal("arrow.right.default.png")));
    skin.add("arrow.right.disabled", new Texture(Gdx.files.internal("arrow.right.disabled.png")));

    for (ColorEnum color : ColorEnum.values()) {
      skin.add(color.colorName, color.getColor());
    }

    Pixmap pixmap;

    pixmap = new Pixmap(1, 1, Pixmap.Format.RGBA8888);
    pixmap.setColor(skin.getColor("white"));
    pixmap.fill();
    skin.add("white", new Texture(pixmap));

    pixmap = new Pixmap(1, 1, Pixmap.Format.RGBA8888);
    pixmap.setColor(skin.getColor("transparent"));
    pixmap.fill();
    skin.add("transparent", new Texture(pixmap));

    pixmap = new Pixmap(8, 1, Pixmap.Format.RGBA8888);
    pixmap.setColor(Color.WHITE);
    pixmap.fill();
    skin.add("white1x8", new Texture(pixmap));

    pixmap = new Pixmap(1, 8, Pixmap.Format.RGBA8888);
    pixmap.setColor(Color.WHITE);
    pixmap.fill();
    skin.add("white8x1", new Texture(pixmap));

    pixmap = new Pixmap(32, 32, Pixmap.Format.RGBA8888);
    pixmap.setColor(Color.WHITE);
    pixmap.fill();
    skin.add("white32s", new Texture(pixmap));
  }