private void zoom(float value) { Camera.main.zoom(value); PixelDungeon.zoom((int) (value - PixelScene.defaultZoom)); updateEnabled(); }
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()); } }
private String orientationText() { return PixelDungeon.landscape() ? TXT_SWITCH_PORT : TXT_SWITCH_LAND; }