Magic_Ling_Pixel_Dungeon/src/com/shatteredpixel/shatteredpixeldungeon/scenes/BadgesScene.java

119 lines
3.2 KiB
Java
Raw Normal View History

2014-07-27 13:39:07 +00:00
/*
* Pixel Dungeon
2015-06-12 20:44:04 +00:00
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2015 Evan Debenham
2014-07-27 13:39:07 +00:00
*
* 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 <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.scenes;
2014-07-27 13:39:07 +00:00
import com.watabou.noosa.BitmapText;
import com.watabou.noosa.Camera;
2015-02-05 06:25:24 +00:00
import com.watabou.noosa.Game;
2014-07-27 13:39:07 +00:00
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;
2014-10-18 08:56:57 +00:00
import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon;
import com.shatteredpixel.shatteredpixeldungeon.ui.Archs;
import com.shatteredpixel.shatteredpixeldungeon.ui.BadgesList;
2014-10-18 08:56:57 +00:00
import com.shatteredpixel.shatteredpixeldungeon.ui.ExitButton;
import com.shatteredpixel.shatteredpixeldungeon.ui.ScrollPane;
import com.shatteredpixel.shatteredpixeldungeon.ui.Window;
2015-02-05 06:25:24 +00:00
import com.watabou.utils.Callback;
2014-07-27 13:39:07 +00:00
public class BadgesScene extends PixelScene {
2015-02-05 06:25:24 +00:00
2014-07-27 13:39:07 +00:00
private static final String TXT_TITLE = "Your Badges";
2015-02-05 06:25:24 +00:00
private static final int MAX_PANE_WIDTH = 160;
2014-07-27 13:39:07 +00:00
@Override
public void create() {
2015-02-05 06:25:24 +00:00
2014-07-27 13:39:07 +00:00
super.create();
2015-02-05 06:25:24 +00:00
2014-07-27 13:39:07 +00:00
Music.INSTANCE.play( Assets.THEME, true );
Music.INSTANCE.volume( ShatteredPixelDungeon.musicVol() / 10f );
2015-02-05 06:25:24 +00:00
2014-07-27 13:39:07 +00:00
uiCamera.visible = false;
2015-02-05 06:25:24 +00:00
2014-07-27 13:39:07 +00:00
int w = Camera.main.width;
int h = Camera.main.height;
2015-02-05 06:25:24 +00:00
2014-07-27 13:39:07 +00:00
Archs archs = new Archs();
archs.setSize( w, h );
add( archs );
2015-02-05 06:25:24 +00:00
int pw = Math.min( MAX_PANE_WIDTH, w - 6 );
2014-10-18 08:56:57 +00:00
int ph = h - 30;
2015-02-05 06:25:24 +00:00
2014-07-27 13:39:07 +00:00
NinePatch panel = Chrome.get( Chrome.Type.WINDOW );
panel.size( pw, ph );
panel.x = (w - pw) / 2;
panel.y = (h - ph) / 2;
add( panel );
2015-02-05 06:25:24 +00:00
2014-07-27 13:39:07 +00:00
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;
2014-07-27 13:39:07 +00:00
add( title );
2015-02-05 06:25:24 +00:00
2014-07-27 13:39:07 +00:00
Badges.loadGlobal();
2015-02-05 06:25:24 +00:00
2014-07-27 13:39:07 +00:00
ScrollPane list = new BadgesList( true );
add( list );
2015-02-05 06:25:24 +00:00
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 );
2014-07-27 13:39:07 +00:00
fadeIn();
2015-02-05 06:25:24 +00:00
Badges.loadingListener = new Callback() {
@Override
public void call() {
if (Game.scene() == BadgesScene.this) {
ShatteredPixelDungeon.switchNoFade( BadgesScene.class );
}
}
};
2014-07-27 13:39:07 +00:00
}
2015-02-05 06:25:24 +00:00
@Override
public void destroy() {
Badges.saveGlobal();
Badges.loadingListener = null;
super.destroy();
}
2014-07-27 13:39:07 +00:00
@Override
protected void onBackPressed() {
2015-02-05 06:25:24 +00:00
ShatteredPixelDungeon.switchNoFade( TitleScene.class );
2014-07-27 13:39:07 +00:00
}
}