Esempio n. 1
0
  public Group createInterface() {
    Font fixedFont = PlayN.graphics().createFont("Fixed", Font.Style.PLAIN, 16);

    Slider slider;
    Label sliderValue;
    Group iface =
        new Group(AxisLayout.vertical().gap(15))
            .add(
                new Shim(15, 15),
                new Label("Click and drag the slider to change the value:"),
                slider = new Slider(0, -100, 100),
                sliderValue =
                    new Label("0")
                        .setConstraint(Constraints.minSize("-000"))
                        .setStyles(Style.HALIGN.right, Style.FONT.is(fixedFont)));
    slider.value.map(FORMATTER).connect(sliderValue.text.slot());
    return iface;
  }
 /**
  * Creates and returns a stylesheet builder configured with some useful default styles. The caller
  * can augment the sheet with additional styles and call {@code create}.
  */
 public static Stylesheet.Builder newSheetBuilder(Graphics gfx) {
   final Font font = FontCache.instance().REGULAR;
   int bgColor = 0xFFCCCCCC, ulColor = UL_COLOR, brColor = 0xFFAAAAAA;
   Background butBg = Background.roundRect(gfx, bgColor, 5, ulColor, 2).inset(5, 6, 2, 6);
   Background butSelBg = Background.roundRect(gfx, bgColor, 5, brColor, 2).inset(6, 5, 1, 7);
   Background disabledChangeViewButtonBackground =
       Background.roundRect(gfx, Palette.DIALOG_BACKGROUND, 5, ulColor, 2).inset(5, 6, 2, 6);
   return Stylesheet.builder()
       .add(Button.class, Style.BACKGROUND.is(butBg), Style.FONT.is(font))
       .add(Button.class, Style.Mode.SELECTED, Style.BACKGROUND.is(butSelBg))
       .add(Button.class, Style.ACTION_SOUND.is(SfxCache.instance().CLICK))
       .add(ToggleButton.class, Style.BACKGROUND.is(butBg))
       .add(ToggleButton.class, Style.Mode.SELECTED, Style.BACKGROUND.is(butSelBg))
       .add(
           CheckBox.class,
           Style.BACKGROUND.is(
               Background.roundRect(gfx, bgColor, 5, ulColor, 2).inset(3, 2, 0, 3)))
       .add(
           CheckBox.class,
           Style.Mode.SELECTED,
           Style.BACKGROUND.is(
               Background.roundRect(gfx, bgColor, 5, brColor, 2).inset(3, 2, 0, 3)))
       // flip ul and br to make Field appear recessed
       .add(
           Field.class,
           Style.BACKGROUND.is(Background.beveled(0xFFFFFFFF, brColor, ulColor).inset(5)),
           Style.HALIGN.left)
       .add(
           Field.class,
           Style.Mode.DISABLED,
           Style.BACKGROUND.is(Background.beveled(0xFFCCCCCC, brColor, ulColor).inset(5)))
       .add(
           Menu.class,
           Style.BACKGROUND.is(Background.bordered(0xFFFFFFFF, 0x00000000, 1).inset(6)))
       .add(
           MenuItem.class,
           Style.BACKGROUND.is(Background.solid(0xFFFFFFFF)),
           Style.HALIGN.left,
           Style.FONT.is(font))
       .add(
           MenuItem.class,
           Style.Mode.SELECTED,
           Style.BACKGROUND.is(Background.solid(0xFF000000)),
           Style.COLOR.is(0xFFFFFFFF))
       .add(Tabs.class, Tabs.HIGHLIGHTER.is(Tabs.textColorHighlighter(0xFF000000, 0xFFFFFFFF)))
       .add(Label.class, Style.FONT.is(font))
       .add(
           GameInteractionArea.ChangeViewControl.ChangeViewButton.class,
           Style.BACKGROUND.is(butBg),
           Style.FONT.is(font))
       .add(
           GameInteractionArea.ChangeViewControl.ChangeViewButton.class,
           Style.Mode.SELECTED,
           Style.BACKGROUND.is(butSelBg))
       .add(
           GameInteractionArea.ChangeViewControl.ChangeViewButton.class,
           Style.Mode.DISABLED,
           Style.BACKGROUND.is(disabledChangeViewButtonBackground))
       .add(
           GameInteractionArea.ChangeViewControl.ChangeViewButton.class,
           Style.TEXT_EFFECT.pixelOutline)
       .add(
           GameInteractionArea.ChangeViewControl.ChangeViewButton.class,
           Style.HIGHLIGHT.is(Palette.UNUSED_SPACE))
       .add(
           GameInteractionArea.ChangeViewControl.ChangeViewButton.class,
           Style.COLOR.is(Palette.FOREGROUND))
       .add(
           GameInteractionArea.ChangeViewControl.ChangeViewButton.class,
           Style.ACTION_SOUND.is(SfxCache.instance().CLICK))
       .add(
           GameInteractionArea.ChangeViewControl.CountLabel.class,
           Style.FONT.is(font.derive(font.size * 0.85f)),
           Style.COLOR.is(GameColors.WHITE),
           Style.TEXT_EFFECT.pixelOutline,
           Style.HIGHLIGHT.is(GameColors.HUNTER_GREEN));
 }