Search in sources :

Example 1 with PrefsButton

use of com.shatteredpixel.shatteredpixeldungeon.ui.PrefsButton in project shattered-pixel-dungeon-gdx by 00-Evan.

the class TitleScene method create.

@Override
public void create() {
    super.create();
    Music.INSTANCE.play(Assets.THEME, true);
    uiCamera.visible = false;
    int w = Camera.main.width;
    int h = Camera.main.height;
    Archs archs = new Archs();
    archs.setSize(w, h);
    add(archs);
    Image title = BannerSprites.get(BannerSprites.Type.PIXEL_DUNGEON);
    add(title);
    float topRegion = Math.max(95f, h * 0.45f);
    title.x = (w - title.width()) / 2f;
    if (SPDSettings.landscape())
        title.y = (topRegion - title.height()) / 2f;
    else
        title.y = 16 + (topRegion - title.height() - 16) / 2f;
    align(title);
    placeTorch(title.x + 22, title.y + 46);
    placeTorch(title.x + title.width - 22, title.y + 46);
    Image signs = new Image(BannerSprites.get(BannerSprites.Type.PIXEL_DUNGEON_SIGNS)) {

        private float time = 0;

        @Override
        public void update() {
            super.update();
            am = Math.max(0f, (float) Math.sin(time += Game.elapsed));
            if (time >= 1.5f * Math.PI)
                time = 0;
        }

        @Override
        public void draw() {
            Blending.setLightMode();
            super.draw();
            Blending.setNormalMode();
        }
    };
    signs.x = title.x + (title.width() - signs.width()) / 2f;
    signs.y = title.y;
    add(signs);
    DashboardItem btnBadges = new DashboardItem(Messages.get(this, "badges"), 3) {

        @Override
        protected void onClick() {
            ShatteredPixelDungeon.switchNoFade(BadgesScene.class);
        }
    };
    add(btnBadges);
    DashboardItem btnAbout = new DashboardItem(Messages.get(this, "about"), 1) {

        @Override
        protected void onClick() {
            ShatteredPixelDungeon.switchNoFade(AboutScene.class);
        }
    };
    add(btnAbout);
    DashboardItem btnPlay = new DashboardItem(Messages.get(this, "play"), 0) {

        @Override
        protected void onClick() {
            if (GamesInProgress.checkAll().size() == 0) {
                TitleScene.this.add(new WndStartGame(1));
            } else {
                ShatteredPixelDungeon.switchNoFade(StartScene.class);
            }
        }
    };
    add(btnPlay);
    DashboardItem btnRankings = new DashboardItem(Messages.get(this, "rankings"), 2) {

        @Override
        protected void onClick() {
            ShatteredPixelDungeon.switchNoFade(RankingsScene.class);
        }
    };
    add(btnRankings);
    if (SPDSettings.landscape()) {
        btnRankings.setPos(w / 2 - btnRankings.width(), topRegion);
        btnBadges.setPos(w / 2, topRegion);
        btnPlay.setPos(btnRankings.left() - btnPlay.width(), topRegion);
        btnAbout.setPos(btnBadges.right(), topRegion);
    } else {
        btnPlay.setPos(w / 2 - btnPlay.width(), topRegion);
        btnRankings.setPos(w / 2, btnPlay.top());
        btnBadges.setPos(w / 2 - btnBadges.width(), btnPlay.top() + DashboardItem.SIZE);
        btnAbout.setPos(w / 2, btnBadges.top());
    }
    BitmapText version = new BitmapText("v " + Game.version + "", pixelFont);
    version.measure();
    version.hardlight(0xCCCCCC);
    version.x = w - version.width();
    version.y = h - version.height();
    add(version);
    Button changes = new ChangesButton();
    changes.setPos(w - changes.width(), h - version.height() - changes.height());
    add(changes);
    int pos = 0;
    PrefsButton btnPrefs = new PrefsButton();
    btnPrefs.setRect(pos, 0, 16, 16);
    add(btnPrefs);
    pos += btnPrefs.width();
    LanguageButton btnLang = new LanguageButton();
    btnLang.setRect(pos, 0, 14, 16);
    add(btnLang);
    ExitButton btnExit = new ExitButton();
    btnExit.setPos(w - btnExit.width(), 0);
    add(btnExit);
    UpdateNotification updInfo = new UpdateNotification();
    updInfo.setPos(0, h - updInfo.height());
    add(updInfo);
    fadeIn();
}
Also used : LanguageButton(com.shatteredpixel.shatteredpixeldungeon.ui.LanguageButton) UpdateNotification(com.shatteredpixel.shatteredpixeldungeon.ui.UpdateNotification) ExitButton(com.shatteredpixel.shatteredpixeldungeon.ui.ExitButton) ChangesButton(com.shatteredpixel.shatteredpixeldungeon.ui.ChangesButton) Image(com.watabou.noosa.Image) WndStartGame(com.shatteredpixel.shatteredpixeldungeon.windows.WndStartGame) Archs(com.shatteredpixel.shatteredpixeldungeon.ui.Archs) BitmapText(com.watabou.noosa.BitmapText) PrefsButton(com.shatteredpixel.shatteredpixeldungeon.ui.PrefsButton) ExitButton(com.shatteredpixel.shatteredpixeldungeon.ui.ExitButton) ChangesButton(com.shatteredpixel.shatteredpixeldungeon.ui.ChangesButton) LanguageButton(com.shatteredpixel.shatteredpixeldungeon.ui.LanguageButton) Button(com.watabou.noosa.ui.Button) PrefsButton(com.shatteredpixel.shatteredpixeldungeon.ui.PrefsButton)

Aggregations

Archs (com.shatteredpixel.shatteredpixeldungeon.ui.Archs)1 ChangesButton (com.shatteredpixel.shatteredpixeldungeon.ui.ChangesButton)1 ExitButton (com.shatteredpixel.shatteredpixeldungeon.ui.ExitButton)1 LanguageButton (com.shatteredpixel.shatteredpixeldungeon.ui.LanguageButton)1 PrefsButton (com.shatteredpixel.shatteredpixeldungeon.ui.PrefsButton)1 UpdateNotification (com.shatteredpixel.shatteredpixeldungeon.ui.UpdateNotification)1 WndStartGame (com.shatteredpixel.shatteredpixeldungeon.windows.WndStartGame)1 BitmapText (com.watabou.noosa.BitmapText)1 Image (com.watabou.noosa.Image)1 Button (com.watabou.noosa.ui.Button)1