/* * Pixel Dungeon * Copyright (C) 2012-2015 Oleg Dolya * * Shattered Pixel Dungeon * Copyright (C) 2014-2015 Evan Debenham * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see */ package com.shatteredpixel.shatteredpixeldungeon.scenes; import com.watabou.noosa.BitmapText; import com.watabou.noosa.Camera; import com.watabou.noosa.Game; import com.watabou.noosa.NinePatch; import com.watabou.noosa.audio.Music; import com.shatteredpixel.shatteredpixeldungeon.Assets; import com.shatteredpixel.shatteredpixeldungeon.Badges; import com.shatteredpixel.shatteredpixeldungeon.Chrome; import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon; import com.shatteredpixel.shatteredpixeldungeon.ui.Archs; import com.shatteredpixel.shatteredpixeldungeon.ui.BadgesList; import com.shatteredpixel.shatteredpixeldungeon.ui.ExitButton; import com.shatteredpixel.shatteredpixeldungeon.ui.ScrollPane; import com.shatteredpixel.shatteredpixeldungeon.ui.Window; import com.watabou.utils.Callback; public class BadgesScene extends PixelScene { private static final String TXT_TITLE = "Your Badges"; private static final int MAX_PANE_WIDTH = 160; @Override public void create() { super.create(); Music.INSTANCE.play( Assets.THEME, true ); Music.INSTANCE.volume( ShatteredPixelDungeon.musicVol() / 10f ); uiCamera.visible = false; int w = Camera.main.width; int h = Camera.main.height; Archs archs = new Archs(); archs.setSize( w, h ); add( archs ); int pw = Math.min( MAX_PANE_WIDTH, w - 6 ); int ph = h - 30; NinePatch panel = Chrome.get( Chrome.Type.WINDOW ); panel.size( pw, ph ); panel.x = (w - pw) / 2; panel.y = (h - ph) / 2; add( panel ); BitmapText title = PixelScene.createText( TXT_TITLE, 9 ); title.hardlight( Window.TITLE_COLOR ); title.measure(); title.x = (w - title.width()) / 2; title.y = (panel.y - title.baseLine()) / 2; add( title ); Badges.loadGlobal(); ScrollPane list = new BadgesList( true ); add( list ); list.setRect( panel.x + panel.marginLeft(), panel.y + panel.marginTop(), panel.innerWidth(), panel.innerHeight() ); ExitButton btnExit = new ExitButton(); btnExit.setPos( Camera.main.width - btnExit.width(), 0 ); add( btnExit ); fadeIn(); Badges.loadingListener = new Callback() { @Override public void call() { if (Game.scene() == BadgesScene.this) { ShatteredPixelDungeon.switchNoFade( BadgesScene.class ); } } }; } @Override public void destroy() { Badges.saveGlobal(); Badges.loadingListener = null; super.destroy(); } @Override protected void onBackPressed() { ShatteredPixelDungeon.switchNoFade( TitleScene.class ); } }