public WndGame() { super(); addButton( new RedButton(TXT_SETTINGS) { @Override protected void onClick() { hide(); GameScene.show(new WndSettings(true)); } }); if (Dungeon.hero.getDifficulty() < 2 && Dungeon.hero.isAlive()) { addButton( new RedButton(Game.getVar(R.string.WndGame_Save)) { @Override protected void onClick() { GameScene.show(new WndSaveSlotSelect(true)); } }); addButton( new RedButton(Game.getVar(R.string.WndGame_Load)) { @Override protected void onClick() { GameScene.show(new WndSaveSlotSelect(false)); } }); } if (Dungeon.challenges > 0) { addButton( new RedButton(TXT_CHALLEGES) { @Override protected void onClick() { hide(); GameScene.show(new WndChallenges(Dungeon.challenges, false)); } }); } if (!Dungeon.hero.isAlive()) { RedButton btnStart; addButton( btnStart = new RedButton(TXT_START) { @Override protected void onClick() { Dungeon.hero = null; PixelDungeon.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(TXT_RANKINGS) { @Override protected void onClick() { InterlevelScene.mode = InterlevelScene.Mode.DESCEND; Game.switchScene(RankingsScene.class); } }); } addButton( new RedButton(TXT_MENU) { @Override protected void onClick() { try { Dungeon.saveAll(); } catch (IOException e) { // } Game.switchScene(TitleScene.class); } }); addButton( new RedButton(TXT_EXIT) { @Override protected void onClick() { Game.instance().finish(); } }); addButton( new RedButton(TXT_RETURN) { @Override protected void onClick() { hide(); } }); resize(WIDTH, pos); }
private void addButton(RedButton btn) { add(btn); btn.setRect(0, pos > 0 ? pos += GAP : 0, WIDTH, BTN_HEIGHT); pos += BTN_HEIGHT; }