Search in sources :

Example 6 with RenderedText

use of com.watabou.noosa.RenderedText in project shattered-pixel-dungeon-gdx by 00-Evan.

the class StartScene method create.

@Override
public void create() {
    super.create();
    Badges.loadGlobal();
    Journal.loadGlobal();
    uiCamera.visible = false;
    int w = Camera.main.width;
    int h = Camera.main.height;
    Archs archs = new Archs();
    archs.setSize(w, h);
    add(archs);
    ExitButton btnExit = new ExitButton();
    btnExit.setPos(w - btnExit.width(), 0);
    add(btnExit);
    RenderedText title = PixelScene.renderText(Messages.get(this, "title"), 9);
    title.hardlight(Window.TITLE_COLOR);
    title.x = (w - title.width()) / 2f;
    title.y = (16 - title.baseLine()) / 2f;
    align(title);
    add(title);
    ArrayList<GamesInProgress.Info> games = GamesInProgress.checkAll();
    int slotGap = SPDSettings.landscape() ? 5 : 10;
    int slotCount = Math.min(GamesInProgress.MAX_SLOTS, games.size() + 1);
    int slotsHeight = slotCount * SLOT_HEIGHT + (slotCount - 1) * slotGap;
    float yPos = (h - slotsHeight) / 2f;
    if (SPDSettings.landscape())
        yPos += 8;
    for (GamesInProgress.Info game : games) {
        SaveSlotButton existingGame = new SaveSlotButton();
        existingGame.set(game.slot);
        existingGame.setRect((w - SLOT_WIDTH) / 2f, yPos, SLOT_WIDTH, SLOT_HEIGHT);
        yPos += SLOT_HEIGHT + slotGap;
        align(existingGame);
        add(existingGame);
    }
    if (games.size() < GamesInProgress.MAX_SLOTS) {
        SaveSlotButton newGame = new SaveSlotButton();
        newGame.set(GamesInProgress.firstEmpty());
        newGame.setRect((w - SLOT_WIDTH) / 2f, yPos, SLOT_WIDTH, SLOT_HEIGHT);
        yPos += SLOT_HEIGHT + slotGap;
        align(newGame);
        add(newGame);
    }
    GamesInProgress.curSlot = 0;
    ActionIndicator.action = null;
    fadeIn();
}
Also used : Archs(com.shatteredpixel.shatteredpixeldungeon.ui.Archs) ExitButton(com.shatteredpixel.shatteredpixeldungeon.ui.ExitButton) RenderedText(com.watabou.noosa.RenderedText) GamesInProgress(com.shatteredpixel.shatteredpixeldungeon.GamesInProgress)

Example 7 with RenderedText

use of com.watabou.noosa.RenderedText in project shattered-pixel-dungeon-gdx by 00-Evan.

the class RankingsScene 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 = new Archs();
    archs.setSize(w, h);
    add(archs);
    Rankings.INSTANCE.load();
    RenderedText title = PixelScene.renderText(Messages.get(this, "title"), 9);
    title.hardlight(Window.TITLE_COLOR);
    title.x = (w - title.width()) / 2f;
    title.y = (16 - title.baseLine()) / 2f;
    align(title);
    add(title);
    if (Rankings.INSTANCE.records.size() > 0) {
        // attempts to give each record as much space as possible, ideally as much space as portrait mode
        float rowHeight = GameMath.gate(ROW_HEIGHT_MIN, (uiCamera.height - 26) / Rankings.INSTANCE.records.size(), ROW_HEIGHT_MAX);
        float left = (w - Math.min(MAX_ROW_WIDTH, w)) / 2 + GAP;
        float top = (h - rowHeight * Rankings.INSTANCE.records.size()) / 2;
        int pos = 0;
        for (Rankings.Record rec : Rankings.INSTANCE.records) {
            Record row = new Record(pos, pos == Rankings.INSTANCE.lastRecord, rec);
            float offset = rowHeight <= 14 ? pos % 2 == 1 ? 5 : -5 : 0;
            row.setRect(left + offset, top + pos * rowHeight, w - left * 2, rowHeight);
            add(row);
            pos++;
        }
        if (Rankings.INSTANCE.totalNumber >= Rankings.TABLE_SIZE) {
            RenderedText label = PixelScene.renderText(Messages.get(this, "total") + " ", 8);
            label.hardlight(0xCCCCCC);
            add(label);
            RenderedText won = PixelScene.renderText(Integer.toString(Rankings.INSTANCE.wonNumber), 8);
            won.hardlight(Window.SHPX_COLOR);
            add(won);
            RenderedText total = PixelScene.renderText("/" + Rankings.INSTANCE.totalNumber, 8);
            total.hardlight(0xCCCCCC);
            total.x = (w - total.width()) / 2;
            total.y = top + pos * rowHeight + GAP;
            add(total);
            float tw = label.width() + won.width() + total.width();
            label.x = (w - tw) / 2;
            won.x = label.x + label.width();
            total.x = won.x + won.width();
            label.y = won.y = total.y = h - label.height() - GAP;
            align(label);
            align(total);
            align(won);
        }
    } else {
        RenderedText noRec = PixelScene.renderText(Messages.get(this, "no_games"), 8);
        noRec.hardlight(0xCCCCCC);
        noRec.x = (w - noRec.width()) / 2;
        noRec.y = (h - noRec.height()) / 2;
        align(noRec);
        add(noRec);
    }
    ExitButton btnExit = new ExitButton();
    btnExit.setPos(Camera.main.width - btnExit.width(), 0);
    add(btnExit);
    fadeIn();
}
Also used : Archs(com.shatteredpixel.shatteredpixeldungeon.ui.Archs) ExitButton(com.shatteredpixel.shatteredpixeldungeon.ui.ExitButton) RenderedText(com.watabou.noosa.RenderedText) Rankings(com.shatteredpixel.shatteredpixeldungeon.Rankings)

Example 8 with RenderedText

use of com.watabou.noosa.RenderedText in project shattered-pixel-dungeon-gdx by 00-Evan.

the class WndGameInProgress method statSlot.

private void statSlot(String label, String value) {
    RenderedText txt = PixelScene.renderText(label, 8);
    txt.y = pos;
    add(txt);
    txt = PixelScene.renderText(value, 8);
    txt.x = WIDTH * 0.6f;
    txt.y = pos;
    PixelScene.align(txt);
    add(txt);
    pos += GAP + txt.baseLine();
}
Also used : RenderedText(com.watabou.noosa.RenderedText)

Aggregations

RenderedText (com.watabou.noosa.RenderedText)8 Archs (com.shatteredpixel.shatteredpixeldungeon.ui.Archs)5 ExitButton (com.shatteredpixel.shatteredpixeldungeon.ui.ExitButton)5 ItemSprite (com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite)2 Image (com.watabou.noosa.Image)2 Badges (com.shatteredpixel.shatteredpixeldungeon.Badges)1 GamesInProgress (com.shatteredpixel.shatteredpixeldungeon.GamesInProgress)1 Rankings (com.shatteredpixel.shatteredpixeldungeon.Rankings)1 Flare (com.shatteredpixel.shatteredpixeldungeon.effects.Flare)1 Ankh (com.shatteredpixel.shatteredpixeldungeon.items.Ankh)1 DewVial (com.shatteredpixel.shatteredpixeldungeon.items.DewVial)1 Honeypot (com.shatteredpixel.shatteredpixeldungeon.items.Honeypot)1 Stylus (com.shatteredpixel.shatteredpixeldungeon.items.Stylus)1 Torch (com.shatteredpixel.shatteredpixeldungeon.items.Torch)1 PlateArmor (com.shatteredpixel.shatteredpixeldungeon.items.armor.PlateArmor)1 CloakOfShadows (com.shatteredpixel.shatteredpixeldungeon.items.artifacts.CloakOfShadows)1 DriedRose (com.shatteredpixel.shatteredpixeldungeon.items.artifacts.DriedRose)1 EtherealChains (com.shatteredpixel.shatteredpixeldungeon.items.artifacts.EtherealChains)1 HornOfPlenty (com.shatteredpixel.shatteredpixeldungeon.items.artifacts.HornOfPlenty)1 TalismanOfForesight (com.shatteredpixel.shatteredpixeldungeon.items.artifacts.TalismanOfForesight)1