コード例 #1
0
  public WndChooseWay(final TomeOfMastery tome, final HeroSubClass way) {

    super();

    final String TXT_REMASTERY = "Do you want to respec into %s?";

    final String TXT_OK = "Yes, I want to respec";
    final String TXT_CANCEL = "Maybe later";

    float bottom =
        createCommonStuff(
            tome, way.desc() + "\n\n" + Utils.format(TXT_REMASTERY, Utils.indefinite(way.title())));

    RedButton btnWay =
        new RedButton(TXT_OK) {
          @Override
          protected void onClick() {
            hide();
            tome.choose(way);
          }
        };
    btnWay.setRect(0, bottom + GAP, WIDTH, BTN_HEIGHT);
    add(btnWay);

    RedButton btnCancel =
        new RedButton(TXT_CANCEL) {
          @Override
          protected void onClick() {
            hide();
          }
        };
    btnCancel.setRect(0, btnWay.bottom() + GAP, WIDTH, BTN_HEIGHT);
    add(btnCancel);

    resize(WIDTH, (int) btnCancel.bottom());
  }
コード例 #2
0
  public WndSettings(boolean inGame) {
    super();

    CheckBox btnImmersive = null;

    if (inGame) {
      int w = BTN_HEIGHT;

      btnZoomOut =
          new RedButton(TXT_ZOOM_OUT) {
            @Override
            protected void onClick() {
              zoom(Camera.main.zoom - 1);
            }
          };
      add(btnZoomOut.setRect(0, 0, w, BTN_HEIGHT));

      btnZoomIn =
          new RedButton(TXT_ZOOM_IN) {
            @Override
            protected void onClick() {
              zoom(Camera.main.zoom + 1);
            }
          };
      add(btnZoomIn.setRect(WIDTH - w, 0, w, BTN_HEIGHT));

      add(
          new RedButton(TXT_ZOOM_DEFAULT) {
            @Override
            protected void onClick() {
              zoom(PixelScene.defaultZoom);
            }
          }.setRect(
              btnZoomOut.right(), 0, WIDTH - btnZoomIn.width() - btnZoomOut.width(), BTN_HEIGHT));

      updateEnabled();

    } else {

      CheckBox btnScaleUp =
          new CheckBox(TXT_SCALE_UP) {
            @Override
            protected void onClick() {
              super.onClick();
              PixelDungeon.scaleUp(checked());
            }
          };
      btnScaleUp.setRect(0, 0, WIDTH, BTN_HEIGHT);
      btnScaleUp.checked(PixelDungeon.scaleUp());
      add(btnScaleUp);

      btnImmersive =
          new CheckBox(TXT_IMMERSIVE) {
            @Override
            protected void onClick() {
              super.onClick();
              PixelDungeon.immerse(checked());
            }
          };
      btnImmersive.setRect(0, btnScaleUp.bottom() + GAP, WIDTH, BTN_HEIGHT);
      btnImmersive.checked(PixelDungeon.immersed());
      btnImmersive.enable(android.os.Build.VERSION.SDK_INT >= 19);
      add(btnImmersive);
    }

    CheckBox btnMusic =
        new CheckBox(TXT_MUSIC) {
          @Override
          protected void onClick() {
            super.onClick();
            PixelDungeon.music(checked());
          }
        };
    btnMusic.setRect(
        0, (btnImmersive != null ? btnImmersive.bottom() : BTN_HEIGHT) + GAP, WIDTH, BTN_HEIGHT);
    btnMusic.checked(PixelDungeon.music());
    add(btnMusic);

    CheckBox btnSound =
        new CheckBox(TXT_SOUND) {
          @Override
          protected void onClick() {
            super.onClick();
            PixelDungeon.soundFx(checked());
            Sample.INSTANCE.play(Assets.SND_CLICK);
          }
        };
    btnSound.setRect(0, btnMusic.bottom() + GAP, WIDTH, BTN_HEIGHT);
    btnSound.checked(PixelDungeon.soundFx());
    add(btnSound);

    if (inGame) {

      CheckBox btnBrightness =
          new CheckBox(TXT_BRIGHTNESS) {
            @Override
            protected void onClick() {
              super.onClick();
              PixelDungeon.brightness(checked());
            }
          };
      btnBrightness.setRect(0, btnSound.bottom() + GAP, WIDTH, BTN_HEIGHT);
      btnBrightness.checked(PixelDungeon.brightness());
      add(btnBrightness);

      CheckBox btnQuickslot =
          new CheckBox(TXT_QUICKSLOT) {
            @Override
            protected void onClick() {
              super.onClick();
              Toolbar.secondQuickslot(checked());
            }
          };
      btnQuickslot.setRect(0, btnBrightness.bottom() + GAP, WIDTH, BTN_HEIGHT);
      btnQuickslot.checked(Toolbar.secondQuickslot());
      add(btnQuickslot);

      resize(WIDTH, (int) btnQuickslot.bottom());

    } else {

      RedButton btnOrientation =
          new RedButton(orientationText()) {
            @Override
            protected void onClick() {
              PixelDungeon.landscape(!PixelDungeon.landscape());
            }
          };
      btnOrientation.setRect(0, btnSound.bottom() + GAP, WIDTH, BTN_HEIGHT);
      add(btnOrientation);

      resize(WIDTH, (int) btnOrientation.bottom());
    }
  }
コード例 #3
0
  public WndChooseWay(final TomeOfMastery tome, final HeroSubClass way1, final HeroSubClass way2) {

    super();

    final String TXT_MASTERY = "Which way will you follow?";
    final String TXT_CANCEL = "I'll decide later";

    float bottom =
        createCommonStuff(tome, way1.desc() + "\n\n" + way2.desc() + "\n\n" + TXT_MASTERY);

    RedButton btnWay1 =
        new RedButton(Utils.capitalize(way1.title())) {
          @Override
          protected void onClick() {
            hide();
            tome.choose(way1);
          }
        };
    btnWay1.setRect(0, bottom + GAP, (WIDTH - GAP) / 2, BTN_HEIGHT);
    add(btnWay1);

    RedButton btnWay2 =
        new RedButton(Utils.capitalize(way2.title())) {
          @Override
          protected void onClick() {
            hide();
            tome.choose(way2);
          }
        };
    btnWay2.setRect(btnWay1.right() + GAP, btnWay1.top(), btnWay1.width(), BTN_HEIGHT);
    add(btnWay2);

    RedButton btnCancel =
        new RedButton(TXT_CANCEL) {
          @Override
          protected void onClick() {
            hide();
          }
        };
    btnCancel.setRect(0, btnWay2.bottom() + GAP, WIDTH, BTN_HEIGHT);
    add(btnCancel);

    resize(WIDTH, (int) btnCancel.bottom());
  }
コード例 #4
0
 private void updateEnabled() {
   float zoom = Camera.main.zoom;
   btnZoomIn.enable(zoom < PixelScene.maxZoom);
   btnZoomOut.enable(zoom > PixelScene.minZoom);
 }