public AudioTab() {
      OptionSlider musicVol =
          new OptionSlider(Messages.get(this, "music_vol"), "0", "10", 0, 10) {
            @Override
            protected void onChange() {
              Music.INSTANCE.volume(getSelectedValue() / 10f);
              ShatteredPixelDungeon.musicVol(getSelectedValue());
            }
          };
      musicVol.setSelectedValue(ShatteredPixelDungeon.musicVol());
      musicVol.setRect(0, 0, WIDTH, SLIDER_HEIGHT);
      add(musicVol);

      CheckBox musicMute =
          new CheckBox(Messages.get(this, "music_mute")) {
            @Override
            protected void onClick() {
              super.onClick();
              ShatteredPixelDungeon.music(!checked());
            }
          };
      musicMute.setRect(0, musicVol.bottom() + GAP_SML, WIDTH, BTN_HEIGHT);
      musicMute.checked(!ShatteredPixelDungeon.music());
      add(musicMute);

      OptionSlider SFXVol =
          new OptionSlider(Messages.get(this, "sfx_vol"), "0", "10", 0, 10) {
            @Override
            protected void onChange() {
              Sample.INSTANCE.volume(getSelectedValue() / 10f);
              ShatteredPixelDungeon.SFXVol(getSelectedValue());
            }
          };
      SFXVol.setSelectedValue(ShatteredPixelDungeon.SFXVol());
      SFXVol.setRect(0, musicMute.bottom() + GAP_LRG, WIDTH, SLIDER_HEIGHT);
      add(SFXVol);

      CheckBox btnSound =
          new CheckBox(Messages.get(this, "sfx_mute")) {
            @Override
            protected void onClick() {
              super.onClick();
              ShatteredPixelDungeon.soundFx(!checked());
              Sample.INSTANCE.play(Assets.SND_CLICK);
            }
          };
      btnSound.setRect(0, SFXVol.bottom() + GAP_SML, WIDTH, BTN_HEIGHT);
      btnSound.checked(!ShatteredPixelDungeon.soundFx());
      add(btnSound);

      resize(WIDTH, (int) btnSound.bottom());
    }
  public WndSettings() {
    super();

    screen = new ScreenTab();
    add(screen);

    ui = new UITab();
    add(ui);

    audio = new AudioTab();
    add(audio);

    add(
        new LabeledTab(Messages.get(this, "screen")) {
          @Override
          protected void select(boolean value) {
            super.select(value);
            screen.visible = screen.active = value;
            if (value) last_index = 0;
          }
        });

    add(
        new LabeledTab(Messages.get(this, "ui")) {
          @Override
          protected void select(boolean value) {
            super.select(value);
            ui.visible = ui.active = value;
            if (value) last_index = 1;
          }
        });

    add(
        new LabeledTab(Messages.get(this, "audio")) {
          @Override
          protected void select(boolean value) {
            super.select(value);
            audio.visible = audio.active = value;
            if (value) last_index = 2;
          }
        });

    resize(WIDTH, HEIGHT);

    layoutTabs();

    select(last_index);
  }
  @Override
  public boolean act() {
    if (target.isAlive()) {

      if ((level = Random.NormalIntRange(level / 2, level)) > 0) {

        target.damage(level, this);
        if (target.sprite.visible) {
          Splash.at(
              target.sprite.center(),
              -PointF.PI / 2,
              PointF.PI / 6,
              target.sprite.blood(),
              Math.min(10 * level / target.HT, 10));
        }

        if (target == Dungeon.hero && !target.isAlive()) {
          Dungeon.fail(getClass());
          GLog.n(Messages.get(this, "ondeath"));
        }

        spend(TICK);
      } else {
        detach();
      }

    } else {

      detach();
    }

    return true;
  }
  public WndInfoBuff(Buff buff) {
    super();

    IconTitle titlebar = new IconTitle();

    icons = TextureCache.get(Assets.BUFFS_LARGE);
    film = new TextureFilm(icons, 16, 16);

    Image buffIcon = new Image(icons);
    buffIcon.frame(film.get(buff.icon()));

    titlebar.icon(buffIcon);
    titlebar.label(Messages.titleCase(buff.toString()), Window.TITLE_COLOR);
    titlebar.setRect(0, 0, WIDTH, 0);
    add(titlebar);

    RenderedTextMultiline txtInfo = PixelScene.renderMultiline(buff.desc(), 6);
    txtInfo.maxWidth(WIDTH);
    txtInfo.setPos(titlebar.left(), titlebar.bottom() + GAP);
    add(txtInfo);

    resize(WIDTH, (int) (txtInfo.top() + txtInfo.height()));
  }
  public WndGame() {

    super();

    addButton(
        new RedButton(Messages.get(this, "settings")) {
          @Override
          protected void onClick() {
            hide();
            GameScene.show(new WndSettings());
          }
        });

    // Challenges window
    if (Dungeon.challenges > 0) {
      addButton(
          new RedButton(Messages.get(this, "challenges")) {
            @Override
            protected void onClick() {
              hide();
              GameScene.show(new WndChallenges(Dungeon.challenges, false));
            }
          });
    }

    // Restart
    if (!Dungeon.hero.isAlive()) {

      RedButton btnStart;
      addButton(
          btnStart =
              new RedButton(Messages.get(this, "start")) {
                @Override
                protected void onClick() {
                  Dungeon.hero = null;
                  ShatteredPixelDungeon.challenges(Dungeon.challenges);
                  InterlevelScene.mode = InterlevelScene.Mode.DESCEND;
                  InterlevelScene.noStory = true;
                  Game.switchScene(InterlevelScene.class);
                }
              });
      btnStart.icon(Icons.get(Dungeon.hero.heroClass));

      addButton(
          new RedButton(Messages.get(this, "rankings")) {
            @Override
            protected void onClick() {
              InterlevelScene.mode = InterlevelScene.Mode.DESCEND;
              Game.switchScene(RankingsScene.class);
            }
          });
    }

    addButtons(
        // Main menu
        new RedButton(Messages.get(this, "menu")) {
          @Override
          protected void onClick() {
            try {
              Dungeon.saveAll();
            } catch (IOException e) {
              ShatteredPixelDungeon.reportException(e);
            }
            Game.switchScene(TitleScene.class);
          }
        },
        // Quit
        new RedButton(Messages.get(this, "exit")) {
          @Override
          protected void onClick() {
            Game.instance.finish();
          }
        });

    // Cancel
    addButton(
        new RedButton(Messages.get(this, "return")) {
          @Override
          protected void onClick() {
            hide();
          }
        });

    resize(WIDTH, pos);
  }
 @Override
 public String description() {
   return Messages.get(this, "desc", weapon.name());
 }
Esempio n. 7
0
 @Override
 public String desc() {
   return Messages.get(this, "desc", dispTurns(left), damage);
 }
Esempio n. 8
0
 @Override
 public String toString() {
   return Messages.get(this, "name");
 }
 @Override
 public String tileDesc() {
   return Messages.get(this, "desc");
 }
 @Override
 public String desc() {
   return Messages.get(this, "desc", level);
 }
 @Override
 public String heroMessage() {
   return Messages.get(this, "heromsg");
 }
    public UITab() {
      super();

      RenderedText barDesc = PixelScene.renderText(Messages.get(this, "mode"), 9);
      barDesc.x = (WIDTH - barDesc.width()) / 2;
      PixelScene.align(barDesc);
      add(barDesc);

      RedButton btnSplit =
          new RedButton(Messages.get(this, "split")) {
            @Override
            protected void onClick() {
              ShatteredPixelDungeon.toolbarMode(Toolbar.Mode.SPLIT.name());
              Toolbar.updateLayout();
            }
          };
      btnSplit.setRect(1, barDesc.y + barDesc.baseLine() + GAP_TINY, 36, 16);
      add(btnSplit);

      RedButton btnGrouped =
          new RedButton(Messages.get(this, "group")) {
            @Override
            protected void onClick() {
              ShatteredPixelDungeon.toolbarMode(Toolbar.Mode.GROUP.name());
              Toolbar.updateLayout();
            }
          };
      btnGrouped.setRect(btnSplit.right() + 1, barDesc.y + barDesc.baseLine() + GAP_TINY, 36, 16);
      add(btnGrouped);

      RedButton btnCentered =
          new RedButton(Messages.get(this, "center")) {
            @Override
            protected void onClick() {
              ShatteredPixelDungeon.toolbarMode(Toolbar.Mode.CENTER.name());
              Toolbar.updateLayout();
            }
          };
      btnCentered.setRect(
          btnGrouped.right() + 1, barDesc.y + barDesc.baseLine() + GAP_TINY, 36, 16);
      add(btnCentered);

      CheckBox chkFlipToolbar =
          new CheckBox(Messages.get(this, "flip_toolbar")) {
            @Override
            protected void onClick() {
              super.onClick();
              ShatteredPixelDungeon.flipToolbar(checked());
              Toolbar.updateLayout();
            }
          };
      chkFlipToolbar.setRect(0, btnGrouped.bottom() + GAP_TINY, WIDTH, BTN_HEIGHT);
      chkFlipToolbar.checked(ShatteredPixelDungeon.flipToolbar());
      add(chkFlipToolbar);

      final CheckBox chkFlipTags =
          new CheckBox(Messages.get(this, "flip_indicators")) {
            @Override
            protected void onClick() {
              super.onClick();
              ShatteredPixelDungeon.flipTags(checked());
              GameScene.layoutTags();
            }
          };
      chkFlipTags.setRect(0, chkFlipToolbar.bottom() + GAP_TINY, WIDTH, BTN_HEIGHT);
      chkFlipTags.checked(ShatteredPixelDungeon.flipTags());
      add(chkFlipTags);

      OptionSlider slots =
          new OptionSlider(Messages.get(this, "quickslots"), "0", "4", 0, 4) {
            @Override
            protected void onChange() {
              ShatteredPixelDungeon.quickSlots(getSelectedValue());
              Toolbar.updateLayout();
            }
          };
      slots.setSelectedValue(ShatteredPixelDungeon.quickSlots());
      slots.setRect(0, chkFlipTags.bottom() + GAP_TINY, WIDTH, SLIDER_HEIGHT);
      add(slots);

      CheckBox chkFont =
          new CheckBox(Messages.get(this, "system_font")) {
            @Override
            protected void onClick() {
              super.onClick();
              ShatteredPixelDungeon.switchNoFade(
                  (Class<? extends PixelScene>) ShatteredPixelDungeon.scene().getClass(),
                  new Game.SceneChangeCallback() {
                    @Override
                    public void beforeCreate() {
                      ShatteredPixelDungeon.classicFont(!checked());
                    }

                    @Override
                    public void afterCreate() {
                      Game.scene().add(new WndSettings());
                    }
                  });
            }
          };
      chkFont.setRect(0, slots.bottom() + GAP_SML, WIDTH, BTN_HEIGHT);
      chkFont.checked(!ShatteredPixelDungeon.classicFont());
      add(chkFont);
    }
    public ScreenTab() {
      super();

      OptionSlider scale =
          new OptionSlider(
              Messages.get(this, "scale"),
              (int) Math.ceil(2 * Game.density) + "X",
              PixelScene.maxDefaultZoom + "X",
              (int) Math.ceil(2 * Game.density),
              PixelScene.maxDefaultZoom) {
            @Override
            protected void onChange() {
              if (getSelectedValue() != ShatteredPixelDungeon.scale()) {
                ShatteredPixelDungeon.scale(getSelectedValue());
                ShatteredPixelDungeon.switchNoFade(
                    (Class<? extends PixelScene>) ShatteredPixelDungeon.scene().getClass(),
                    new Game.SceneChangeCallback() {
                      @Override
                      public void beforeCreate() {
                        // do nothing
                      }

                      @Override
                      public void afterCreate() {
                        Game.scene().add(new WndSettings());
                      }
                    });
              }
            }
          };
      scale.setSelectedValue(PixelScene.defaultZoom);
      scale.setRect(0, 0, WIDTH, SLIDER_HEIGHT);
      if ((int) Math.ceil(2 * Game.density) < PixelScene.maxDefaultZoom) add(scale);

      OptionSlider brightness =
          new OptionSlider(
              Messages.get(this, "brightness"),
              Messages.get(this, "dark"),
              Messages.get(this, "bright"),
              -2,
              2) {
            @Override
            protected void onChange() {
              ShatteredPixelDungeon.brightness(getSelectedValue());
            }
          };
      brightness.setSelectedValue(ShatteredPixelDungeon.brightness());
      brightness.setRect(0, scale.bottom() + GAP_TINY, WIDTH, SLIDER_HEIGHT);
      add(brightness);

      CheckBox chkImmersive =
          new CheckBox(Messages.get(this, "soft_keys")) {
            @Override
            protected void onClick() {
              super.onClick();
              ShatteredPixelDungeon.immerse(checked());
            }
          };
      chkImmersive.setRect(0, brightness.bottom() + GAP_SML, WIDTH, BTN_HEIGHT);
      chkImmersive.checked(ShatteredPixelDungeon.immersed());
      chkImmersive.enable(android.os.Build.VERSION.SDK_INT >= 19);
      add(chkImmersive);

      CheckBox chkSaver =
          new CheckBox(Messages.get(this, "saver")) {
            @Override
            protected void onClick() {
              super.onClick();
              if (checked()) {
                checked(!checked());
                ShatteredPixelDungeon.scene()
                    .add(
                        new WndOptions(
                            Messages.get(ScreenTab.class, "saver"),
                            Messages.get(ScreenTab.class, "saver_desc"),
                            Messages.get(ScreenTab.class, "okay"),
                            Messages.get(ScreenTab.class, "cancel")) {
                          @Override
                          protected void onSelect(int index) {
                            if (index == 0) {
                              checked(!checked());
                              ShatteredPixelDungeon.powerSaver(checked());
                            }
                          }
                        });
              } else {
                ShatteredPixelDungeon.powerSaver(checked());
              }
            }
          };
      chkSaver.setRect(0, chkImmersive.bottom() + GAP_TINY, WIDTH, BTN_HEIGHT);
      chkSaver.checked(ShatteredPixelDungeon.powerSaver());
      if (PixelScene.maxScreenZoom >= 2) add(chkSaver);

      RedButton btnOrientation =
          new RedButton(
              ShatteredPixelDungeon.landscape()
                  ? Messages.get(this, "portrait")
                  : Messages.get(this, "landscape")) {
            @Override
            protected void onClick() {
              ShatteredPixelDungeon.landscape(!ShatteredPixelDungeon.landscape());
            }
          };
      btnOrientation.setRect(0, chkSaver.bottom() + GAP_SML, WIDTH, BTN_HEIGHT);
      add(btnOrientation);
    }