Search in sources :

Example 1 with ExitButton

use of com.watabou.pixeldungeon.ui.ExitButton in project pixel-dungeon by watabou.

the class BadgesScene method create.

@Override
public void create() {
    super.create();
    Music.INSTANCE.play(Assets.THEME, true);
    Music.INSTANCE.volume(1f);
    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 = (int) Math.min(w, (PixelDungeon.landscape() ? MIN_WIDTH_L : MIN_WIDTH_P) * 3) - 16;
    int ph = (int) Math.min(h, (PixelDungeon.landscape() ? MIN_HEIGHT_L : MIN_HEIGHT_P) * 3) - 32;
    float size = (float) Math.sqrt(pw * ph / 27f);
    int nCols = (int) Math.ceil(pw / size);
    int nRows = (int) Math.ceil(ph / size);
    size = Math.min(pw / nCols, ph / nRows);
    float left = (w - size * nCols) / 2;
    float top = (h - size * nRows) / 2;
    BitmapText title = PixelScene.createText(TXT_TITLE, 9);
    title.hardlight(Window.TITLE_COLOR);
    title.measure();
    title.x = align((w - title.width()) / 2);
    title.y = align((top - title.baseLine()) / 2);
    add(title);
    Badges.loadGlobal();
    List<Badges.Badge> badges = Badges.filtered(true);
    for (int i = 0; i < nRows; i++) {
        for (int j = 0; j < nCols; j++) {
            int index = i * nCols + j;
            Badges.Badge b = index < badges.size() ? badges.get(index) : null;
            BadgeButton button = new BadgeButton(b);
            button.setPos(left + j * size + (size - button.width()) / 2, top + i * size + (size - button.height()) / 2);
            add(button);
        }
    }
    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) {
                PixelDungeon.switchNoFade(BadgesScene.class);
            }
        }
    };
}
Also used : ExitButton(com.watabou.pixeldungeon.ui.ExitButton) WndBadge(com.watabou.pixeldungeon.windows.WndBadge) Callback(com.watabou.utils.Callback) Archs(com.watabou.pixeldungeon.ui.Archs) BitmapText(com.watabou.noosa.BitmapText) Badges(com.watabou.pixeldungeon.Badges)

Example 2 with ExitButton

use of com.watabou.pixeldungeon.ui.ExitButton in project pixel-dungeon by watabou.

the class StartScene method create.

@Override
public void create() {
    super.create();
    Badges.loadGlobal();
    uiCamera.visible = false;
    int w = Camera.main.width;
    int h = Camera.main.height;
    float width, height;
    if (PixelDungeon.landscape()) {
        width = WIDTH_L;
        height = HEIGHT_L;
    } else {
        width = WIDTH_P;
        height = HEIGHT_P;
    }
    float left = (w - width) / 2;
    float top = (h - height) / 2;
    float bottom = h - top;
    Archs archs = new Archs();
    archs.setSize(w, h);
    add(archs);
    Image title = BannerSprites.get(Type.SELECT_YOUR_HERO);
    title.x = align((w - title.width()) / 2);
    title.y = align(top);
    add(title);
    buttonX = left;
    buttonY = bottom - BUTTON_HEIGHT;
    btnNewGame = new GameButton(TXT_NEW) {

        @Override
        protected void onClick() {
            if (GamesInProgress.check(curClass) != null) {
                StartScene.this.add(new WndOptions(TXT_REALLY, TXT_WARNING, TXT_YES, TXT_NO) {

                    @Override
                    protected void onSelect(int index) {
                        if (index == 0) {
                            startNewGame();
                        }
                    }
                });
            } else {
                startNewGame();
            }
        }
    };
    add(btnNewGame);
    btnLoad = new GameButton(TXT_LOAD) {

        @Override
        protected void onClick() {
            InterlevelScene.mode = InterlevelScene.Mode.CONTINUE;
            Game.switchScene(InterlevelScene.class);
        }
    };
    add(btnLoad);
    float centralHeight = buttonY - title.y - title.height();
    HeroClass[] classes = { HeroClass.WARRIOR, HeroClass.MAGE, HeroClass.ROGUE, HeroClass.HUNTRESS };
    for (HeroClass cl : classes) {
        ClassShield shield = new ClassShield(cl);
        shields.put(cl, shield);
        add(shield);
    }
    if (PixelDungeon.landscape()) {
        float shieldW = width / 4;
        float shieldH = Math.min(centralHeight, shieldW);
        top = title.y + title.height + (centralHeight - shieldH) / 2;
        for (int i = 0; i < classes.length; i++) {
            ClassShield shield = shields.get(classes[i]);
            shield.setRect(left + i * shieldW, top, shieldW, shieldH);
        }
        ChallengeButton challenge = new ChallengeButton();
        challenge.setPos(w / 2 - challenge.width() / 2, top + shieldH - challenge.height() / 2);
        add(challenge);
    } else {
        float shieldW = width / 2;
        float shieldH = Math.min(centralHeight / 2, shieldW * 1.2f);
        top = title.y + title.height() + centralHeight / 2 - shieldH;
        for (int i = 0; i < classes.length; i++) {
            ClassShield shield = shields.get(classes[i]);
            shield.setRect(left + (i % 2) * shieldW, top + (i / 2) * shieldH, shieldW, shieldH);
        }
        ChallengeButton challenge = new ChallengeButton();
        challenge.setPos(w / 2 - challenge.width() / 2, top + shieldH - challenge.height() / 2);
        add(challenge);
    }
    unlock = new Group();
    add(unlock);
    if (!(huntressUnlocked = Badges.isUnlocked(Badges.Badge.BOSS_SLAIN_3))) {
        BitmapTextMultiline text = PixelScene.createMultiline(TXT_UNLOCK, 9);
        text.maxWidth = (int) width;
        text.measure();
        float pos = (bottom - BUTTON_HEIGHT) + (BUTTON_HEIGHT - text.height()) / 2;
        for (BitmapText line : text.new LineSplitter().split()) {
            line.measure();
            line.hardlight(0xFFFF00);
            line.x = PixelScene.align(w / 2 - line.width() / 2);
            line.y = PixelScene.align(pos);
            unlock.add(line);
            pos += line.height();
        }
    }
    ExitButton btnExit = new ExitButton();
    btnExit.setPos(Camera.main.width - btnExit.width(), 0);
    add(btnExit);
    curClass = null;
    updateClass(HeroClass.values()[PixelDungeon.lastClass()]);
    fadeIn();
    Badges.loadingListener = new Callback() {

        @Override
        public void call() {
            if (Game.scene() == StartScene.this) {
                PixelDungeon.switchNoFade(StartScene.class);
            }
        }
    };
}
Also used : WndOptions(com.watabou.pixeldungeon.windows.WndOptions) Group(com.watabou.noosa.Group) ExitButton(com.watabou.pixeldungeon.ui.ExitButton) Image(com.watabou.noosa.Image) BitmapTextMultiline(com.watabou.noosa.BitmapTextMultiline) Callback(com.watabou.utils.Callback) Archs(com.watabou.pixeldungeon.ui.Archs) BitmapText(com.watabou.noosa.BitmapText) HeroClass(com.watabou.pixeldungeon.actors.hero.HeroClass)

Example 3 with ExitButton

use of com.watabou.pixeldungeon.ui.ExitButton in project pixel-dungeon by watabou.

the class RankingsScene method create.

@Override
public void create() {
    super.create();
    Music.INSTANCE.play(Assets.THEME, true);
    Music.INSTANCE.volume(1f);
    uiCamera.visible = false;
    int w = Camera.main.width;
    int h = Camera.main.height;
    archs = new Archs();
    archs.setSize(w, h);
    add(archs);
    Rankings.INSTANCE.load();
    if (Rankings.INSTANCE.records.size() > 0) {
        float rowHeight = PixelDungeon.landscape() ? ROW_HEIGHT_L : ROW_HEIGHT_P;
        float left = (w - Math.min(MAX_ROW_WIDTH, w)) / 2 + GAP;
        float top = align((h - rowHeight * Rankings.INSTANCE.records.size()) / 2);
        BitmapText title = PixelScene.createText(TXT_TITLE, 9);
        title.hardlight(Window.TITLE_COLOR);
        title.measure();
        title.x = align((w - title.width()) / 2);
        title.y = align(top - title.height() - GAP);
        add(title);
        int pos = 0;
        for (Rankings.Record rec : Rankings.INSTANCE.records) {
            Record row = new Record(pos, pos == Rankings.INSTANCE.lastRecord, rec);
            row.setRect(left, top + pos * rowHeight, w - left * 2, rowHeight);
            add(row);
            pos++;
        }
        if (Rankings.INSTANCE.totalNumber >= Rankings.TABLE_SIZE) {
            BitmapText label = PixelScene.createText(TXT_TOTAL, 8);
            label.hardlight(DEFAULT_COLOR);
            label.measure();
            add(label);
            BitmapText won = PixelScene.createText(Integer.toString(Rankings.INSTANCE.wonNumber), 8);
            won.hardlight(Window.TITLE_COLOR);
            won.measure();
            add(won);
            BitmapText total = PixelScene.createText("/" + Rankings.INSTANCE.totalNumber, 8);
            total.hardlight(DEFAULT_COLOR);
            total.measure();
            total.x = align((w - total.width()) / 2);
            total.y = align(top + pos * rowHeight + GAP);
            add(total);
            float tw = label.width() + won.width() + total.width();
            label.x = align((w - tw) / 2);
            won.x = label.x + label.width();
            total.x = won.x + won.width();
            label.y = won.y = total.y = align(top + pos * rowHeight + GAP);
        }
    } else {
        BitmapText title = PixelScene.createText(TXT_NO_GAMES, 8);
        title.hardlight(DEFAULT_COLOR);
        title.measure();
        title.x = align((w - title.width()) / 2);
        title.y = align((h - title.height()) / 2);
        add(title);
    }
    ExitButton btnExit = new ExitButton();
    btnExit.setPos(Camera.main.width - btnExit.width(), 0);
    add(btnExit);
    fadeIn();
}
Also used : Archs(com.watabou.pixeldungeon.ui.Archs) BitmapText(com.watabou.noosa.BitmapText) ExitButton(com.watabou.pixeldungeon.ui.ExitButton) Rankings(com.watabou.pixeldungeon.Rankings)

Example 4 with ExitButton

use of com.watabou.pixeldungeon.ui.ExitButton in project pixel-dungeon by watabou.

the class TitleScene method create.

@Override
public void create() {
    super.create();
    Music.INSTANCE.play(Assets.THEME, true);
    Music.INSTANCE.volume(1f);
    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 height = title.height + (PixelDungeon.landscape() ? DashboardItem.SIZE : DashboardItem.SIZE * 2);
    title.x = (w - title.width()) / 2;
    title.y = (h - height) / 2;
    placeTorch(title.x + 18, title.y + 20);
    placeTorch(title.x + title.width - 18, title.y + 20);
    Image signs = new Image(BannerSprites.get(BannerSprites.Type.PIXEL_DUNGEON_SIGNS)) {

        private float time = 0;

        @Override
        public void update() {
            super.update();
            am = (float) Math.sin(-(time += Game.elapsed));
        }

        @Override
        public void draw() {
            GLES20.glBlendFunc(GL10.GL_SRC_ALPHA, GL10.GL_ONE);
            super.draw();
            GLES20.glBlendFunc(GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA);
        }
    };
    signs.x = title.x;
    signs.y = title.y;
    add(signs);
    DashboardItem btnBadges = new DashboardItem(TXT_BADGES, 3) {

        @Override
        protected void onClick() {
            PixelDungeon.switchNoFade(BadgesScene.class);
        }
    };
    add(btnBadges);
    DashboardItem btnAbout = new DashboardItem(TXT_ABOUT, 1) {

        @Override
        protected void onClick() {
            PixelDungeon.switchNoFade(AboutScene.class);
        }
    };
    add(btnAbout);
    DashboardItem btnPlay = new DashboardItem(TXT_PLAY, 0) {

        @Override
        protected void onClick() {
            PixelDungeon.switchNoFade(StartScene.class);
        }
    };
    add(btnPlay);
    DashboardItem btnHighscores = new DashboardItem(TXT_HIGHSCORES, 2) {

        @Override
        protected void onClick() {
            PixelDungeon.switchNoFade(RankingsScene.class);
        }
    };
    add(btnHighscores);
    if (PixelDungeon.landscape()) {
        float y = (h + height) / 2 - DashboardItem.SIZE;
        btnHighscores.setPos(w / 2 - btnHighscores.width(), y);
        btnBadges.setPos(w / 2, y);
        btnPlay.setPos(btnHighscores.left() - btnPlay.width(), y);
        btnAbout.setPos(btnBadges.right(), y);
    } else {
        btnBadges.setPos(w / 2 - btnBadges.width(), (h + height) / 2 - DashboardItem.SIZE);
        btnAbout.setPos(w / 2, (h + height) / 2 - DashboardItem.SIZE);
        btnPlay.setPos(w / 2 - btnPlay.width(), btnAbout.top() - DashboardItem.SIZE);
        btnHighscores.setPos(w / 2, btnPlay.top());
    }
    BitmapText version = new BitmapText("v " + Game.version, font1x);
    version.measure();
    version.hardlight(0x888888);
    version.x = w - version.width();
    version.y = h - version.height();
    add(version);
    PrefsButton btnPrefs = new PrefsButton();
    btnPrefs.setPos(0, 0);
    add(btnPrefs);
    ExitButton btnExit = new ExitButton();
    btnExit.setPos(w - btnExit.width(), 0);
    add(btnExit);
    fadeIn();
}
Also used : Archs(com.watabou.pixeldungeon.ui.Archs) BitmapText(com.watabou.noosa.BitmapText) ExitButton(com.watabou.pixeldungeon.ui.ExitButton) PrefsButton(com.watabou.pixeldungeon.ui.PrefsButton) Image(com.watabou.noosa.Image)

Example 5 with ExitButton

use of com.watabou.pixeldungeon.ui.ExitButton in project pixel-dungeon by watabou.

the class AboutScene method create.

@Override
public void create() {
    super.create();
    BitmapTextMultiline text = createMultiline(TXT, 8);
    text.maxWidth = Math.min(Camera.main.width, 120);
    text.measure();
    add(text);
    text.x = align((Camera.main.width - text.width()) / 2);
    text.y = align((Camera.main.height - text.height()) / 2);
    BitmapTextMultiline link = createMultiline(LNK, 8);
    link.maxWidth = Math.min(Camera.main.width, 120);
    link.measure();
    link.hardlight(Window.TITLE_COLOR);
    add(link);
    link.x = text.x;
    link.y = text.y + text.height();
    TouchArea hotArea = new TouchArea(link) {

        @Override
        protected void onClick(Touch touch) {
            Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://" + LNK));
            Game.instance.startActivity(intent);
        }
    };
    add(hotArea);
    Image wata = Icons.WATA.get();
    wata.x = align((Camera.main.width - wata.width) / 2);
    wata.y = text.y - wata.height - 8;
    add(wata);
    new Flare(7, 64).color(0x112233, true).show(wata, 0).angularSpeed = +20;
    Archs archs = new Archs();
    archs.setSize(Camera.main.width, Camera.main.height);
    addToBack(archs);
    ExitButton btnExit = new ExitButton();
    btnExit.setPos(Camera.main.width - btnExit.width(), 0);
    add(btnExit);
    fadeIn();
}
Also used : Flare(com.watabou.pixeldungeon.effects.Flare) TouchArea(com.watabou.noosa.TouchArea) Archs(com.watabou.pixeldungeon.ui.Archs) ExitButton(com.watabou.pixeldungeon.ui.ExitButton) Intent(android.content.Intent) Touch(com.watabou.input.Touchscreen.Touch) Image(com.watabou.noosa.Image) BitmapTextMultiline(com.watabou.noosa.BitmapTextMultiline)

Aggregations

Archs (com.watabou.pixeldungeon.ui.Archs)5 ExitButton (com.watabou.pixeldungeon.ui.ExitButton)5 BitmapText (com.watabou.noosa.BitmapText)4 Image (com.watabou.noosa.Image)3 BitmapTextMultiline (com.watabou.noosa.BitmapTextMultiline)2 Callback (com.watabou.utils.Callback)2 Intent (android.content.Intent)1 Touch (com.watabou.input.Touchscreen.Touch)1 Group (com.watabou.noosa.Group)1 TouchArea (com.watabou.noosa.TouchArea)1 Badges (com.watabou.pixeldungeon.Badges)1 Rankings (com.watabou.pixeldungeon.Rankings)1 HeroClass (com.watabou.pixeldungeon.actors.hero.HeroClass)1 Flare (com.watabou.pixeldungeon.effects.Flare)1 PrefsButton (com.watabou.pixeldungeon.ui.PrefsButton)1 WndBadge (com.watabou.pixeldungeon.windows.WndBadge)1 WndOptions (com.watabou.pixeldungeon.windows.WndOptions)1