Search in sources :

Example 1 with WndStartGame

use of com.shatteredpixel.shatteredpixeldungeon.windows.WndStartGame 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)

Example 2 with WndStartGame

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

the class WelcomeScene method create.

@Override
public void create() {
    super.create();
    final int previousVersion = SPDSettings.version();
    if (ShatteredPixelDungeon.versionCode == previousVersion) {
        ShatteredPixelDungeon.switchNoFade(TitleScene.class);
        return;
    }
    uiCamera.visible = false;
    int w = Camera.main.width;
    int h = Camera.main.height;
    Image title = BannerSprites.get(BannerSprites.Type.PIXEL_DUNGEON);
    title.brightness(0.6f);
    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);
    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);
    DarkRedButton okay = new DarkRedButton(Messages.get(this, "continue")) {

        @Override
        protected void onClick() {
            super.onClick();
            if (previousVersion == 0) {
                SPDSettings.version(ShatteredPixelDungeon.versionCode);
                WelcomeScene.this.add(new WndStartGame(1));
            } else {
                updateVersion(previousVersion);
                ShatteredPixelDungeon.switchScene(TitleScene.class);
            }
        }
    };
    if (previousVersion != 0) {
        DarkRedButton changes = new DarkRedButton(Messages.get(this, "changelist")) {

            @Override
            protected void onClick() {
                super.onClick();
                updateVersion(previousVersion);
                ShatteredPixelDungeon.switchScene(ChangesScene.class);
            }
        };
        okay.setRect(title.x, h - 20, (title.width() / 2) - 2, 16);
        okay.textColor(0xBBBB33);
        add(okay);
        changes.setRect(okay.right() + 2, h - 20, (title.width() / 2) - 2, 16);
        changes.textColor(0xBBBB33);
        add(changes);
    } else {
        okay.setRect(title.x, h - 20, title.width(), 16);
        okay.textColor(0xBBBB33);
        add(okay);
    }
    RenderedTextMultiline text = PixelScene.renderMultiline(6);
    String message;
    if (previousVersion == 0) {
        message = Messages.get(this, "welcome_msg");
    } else if (previousVersion <= ShatteredPixelDungeon.versionCode) {
        if (previousVersion < LATEST_UPDATE) {
            message = Messages.get(this, "update_intro");
            message += "\n\n" + Messages.get(this, "update_msg");
        } else {
            // TODO: change the messages here in accordance with the type of patch.
            message = Messages.get(this, "patch_intro");
            message += "\n\n" + Messages.get(this, "patch_bugfixes");
            message += "\n" + Messages.get(this, "patch_translations");
            message += "\n" + Messages.get(this, "patch_balance");
        }
    } else {
        message = Messages.get(this, "what_msg");
    }
    text.text(message, w - 20);
    float textSpace = h - title.y - (title.height() - 10) - okay.height() - 2;
    text.setPos((w - text.width()) / 2f, title.y + (title.height() - 10) + ((textSpace - text.height()) / 2));
    add(text);
}
Also used : WndStartGame(com.shatteredpixel.shatteredpixeldungeon.windows.WndStartGame) RenderedTextMultiline(com.shatteredpixel.shatteredpixeldungeon.ui.RenderedTextMultiline) Image(com.watabou.noosa.Image)

Aggregations

WndStartGame (com.shatteredpixel.shatteredpixeldungeon.windows.WndStartGame)2 Image (com.watabou.noosa.Image)2 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 RenderedTextMultiline (com.shatteredpixel.shatteredpixeldungeon.ui.RenderedTextMultiline)1 UpdateNotification (com.shatteredpixel.shatteredpixeldungeon.ui.UpdateNotification)1 BitmapText (com.watabou.noosa.BitmapText)1 Button (com.watabou.noosa.ui.Button)1