Search in sources :

Example 1 with Text

use of com.watabou.noosa.Text in project pixel-dungeon-remix by NYRDS.

the class PixelScene method createMultiline.

public static Text createMultiline(final String text, float size) {
    if (!ModdingMode.getClassicTextRenderingMode()) {
        return new SystemText(text, size, true);
    }
    Text result = Text.createMultiline(text, chooseFont(size));
    result.Scale().set(scale);
    return result;
}
Also used : Text(com.watabou.noosa.Text) SystemText(com.watabou.noosa.SystemText) SystemText(com.watabou.noosa.SystemText)

Example 2 with Text

use of com.watabou.noosa.Text in project pixel-dungeon-remix by NYRDS.

the class WelcomeScene method create.

@Override
public void create() {
    super.create();
    long start = System.nanoTime();
    String[] upds = { Game.getVar(R.string.Welcome_Text), Game.getVar(R.string.Welcome_Text_19), Game.getVar(R.string.Welcome_Text_20), Game.getVar(R.string.Welcome_Text_20_1), Game.getVar(R.string.Welcome_Text_20_2), Game.getVar(R.string.Welcome_Text_21_1), Game.getVar(R.string.Welcome_Text_21_2), Game.getVar(R.string.Welcome_Text_21_3), Game.getVar(R.string.Welcome_Text_21_4), Game.getVar(R.string.Welcome_Text_21_5), Game.getVar(R.string.Welcome_Text_22), Game.getVar(R.string.Welcome_Text_23), Game.getVar(R.string.Welcome_Text_23_1), Game.getVar(R.string.Welcome_Text_23_2), Game.getVar(R.string.Welcome_Text_24), Game.getVar(R.string.Welcome_Text_24_1), Game.getVar(R.string.Welcome_Text_24_2), Game.getVar(R.string.Welcome_Text_25), Game.getVar(R.string.Welcome_Text_25_1), Game.getVar(R.string.Welcome_Text_25_2), Game.getVar(R.string.Welcome_Text_25_3), Game.getVar(R.string.Welcome_Text_25_4), Game.getVar(R.string.Welcome_Text_25_5), Game.getVar(R.string.Welcome_Text_26), Game.getVar(R.string.Welcome_Text_26_1), Game.getVar(R.string.Welcome_Text_26_2), Game.getVar(R.string.Welcome_Text_26_3), Game.getVar(R.string.Welcome_Text_26_4), Game.getVar(R.string.Welcome_Text_26_5), Game.getVar(R.string.Welcome_Text_26_6), Game.getVar(R.string.Welcome_Text_27), Game.getVar(R.string.Welcome_Text_27_1), Game.getVar(R.string.Welcome_Text_27_2), Game.getVar(R.string.Welcome_Text_27_3), Game.getVar(R.string.Welcome_Text_27_4), Game.getVar(R.string.Welcome_Text_28), Game.getVar(R.string.Welcome_Text_28_1) };
    int displayUpdates = Math.min(upds.length, 5);
    Text[] updTexts = new Text[displayUpdates];
    for (int i = 0; i < displayUpdates; i++) {
        updTexts[i] = createMultiline(GuiProperties.regularFontSize());
    }
    Text title = createMultiline(Game.getVar(R.string.Welcome_Title), GuiProperties.bigTitleFontSize());
    int w = Camera.main.width;
    int h = Camera.main.height;
    int pw = w - 10;
    title.maxWidth(pw);
    title.measure();
    title.x = align((w - title.width()) / 2);
    title.y = align(8);
    add(title);
    NinePatch panel = Chrome.get(Chrome.Type.WINDOW);
    panel.x = (w - pw) / 2;
    panel.y = title.y + title.height() + GAP * 2;
    int ph = (int) (h - panel.y - 22);
    panel.size(pw, ph);
    add(panel);
    ScrollPane list = new ScrollPane(new Component());
    add(list);
    list.setRect(panel.x + panel.marginLeft(), panel.y + panel.marginTop(), panel.innerWidth(), panel.innerHeight());
    list.scrollTo(0, 0);
    Component content = list.content();
    content.clear();
    float yPos = 0;
    for (int i = 0; i < displayUpdates; i++) {
        updTexts[i].maxWidth((int) panel.innerWidth());
        updTexts[i].text(upds[upds.length - i - 1]);
        updTexts[i].measure();
        updTexts[i].setPos(0, yPos);
        yPos += updTexts[i].height() + GAP;
        content.add(updTexts[i]);
    }
    content.setSize(panel.innerWidth(), yPos);
    RedButton okay = new RedButton(Game.getVar(R.string.Welcome_Ok)) {

        @Override
        protected void onClick() {
            PixelDungeon.version(Game.versionCode);
            PixelDungeon.versionString(Game.version);
            if (Preferences.INSTANCE.getInt(Preferences.KEY_COLLECT_STATS, 1) == 0) {
                Game.switchScene(AllowStatisticsCollectionScene.class);
            } else {
                Game.switchScene(TitleScene.class);
            }
        }
    };
    okay.setRect((w - pw) / 2, h - 22, pw, 18);
    add(okay);
    Archs archs = new Archs();
    archs.setSize(Camera.main.width, Camera.main.height);
    addToBack(archs);
    long end = System.nanoTime();
    GLog.i("Time: %5.3f", (end - start) / 100000.f);
    fadeIn();
}
Also used : Archs(com.watabou.pixeldungeon.ui.Archs) ScrollPane(com.watabou.pixeldungeon.ui.ScrollPane) NinePatch(com.watabou.noosa.NinePatch) Text(com.watabou.noosa.Text) RedButton(com.watabou.pixeldungeon.ui.RedButton) Component(com.watabou.noosa.ui.Component)

Example 3 with Text

use of com.watabou.noosa.Text in project pixel-dungeon-remix by NYRDS.

the class GameLog method onSignal.

@Override
public void onSignal(String text) {
    if (Game.isPaused()) {
        return;
    }
    int color = CharSprite.DEFAULT;
    if (text.startsWith(GLog.POSITIVE)) {
        text = text.substring(GLog.POSITIVE.length());
        color = CharSprite.POSITIVE;
    } else if (text.startsWith(GLog.NEGATIVE)) {
        text = text.substring(GLog.NEGATIVE.length());
        color = CharSprite.NEGATIVE;
    } else if (text.startsWith(GLog.WARNING)) {
        text = text.substring(GLog.WARNING.length());
        color = CharSprite.WARNING;
    } else if (text.startsWith(GLog.HIGHLIGHT)) {
        text = text.substring(GLog.HIGHLIGHT.length());
        color = CharSprite.NEUTRAL;
    }
    if (text.isEmpty()) {
        return;
    }
    text = Utils.capitalize(text) + (PUNCTUATION.matcher(text).matches() ? "" : ".");
    // Store the message to show in log book tab
    Logbook.addPlayerLogMessage(text, color);
    if (lastEntry != null && color == lastColor) {
        String lastMessage = lastEntry.text();
        lastEntry.text(lastMessage.length() == 0 ? text : lastMessage + " " + text);
        lastEntry.measure();
    } else {
        lastEntry = PixelScene.createMultiline(text, GuiProperties.regularFontSize());
        lastEntry.maxWidth((int) width);
        lastEntry.measure();
        lastEntry.hardlight(color);
        lastColor = color;
        add(lastEntry);
    }
    int texts = 0;
    for (int i = 0; i < getLength(); i++) {
        if (members.get(i) instanceof Text)
            texts++;
    }
    if (texts > MAX_MESSAGES) {
        for (int i = 0; i < getLength(); i++) {
            if (members.get(i) instanceof Text) {
                Text txt = (Text) members.get(i);
                remove(txt);
                txt.destroy();
                break;
            }
        }
    }
    layout();
}
Also used : Text(com.watabou.noosa.Text)

Example 4 with Text

use of com.watabou.noosa.Text in project pixel-dungeon-remix by NYRDS.

the class GameLog method layout.

@Override
protected void layout() {
    float pos = y;
    for (int i = getLength() - 1; i >= 0; i--) {
        Visual entry = (Visual) members.get(i);
        if (entry instanceof Text) {
            entry.x = x;
            entry.y = pos - entry.height();
            pos = entry.y;
        }
    }
}
Also used : Text(com.watabou.noosa.Text) Visual(com.watabou.noosa.Visual)

Example 5 with Text

use of com.watabou.noosa.Text in project pixel-dungeon-remix by NYRDS.

the class WndChooseWay method chooseWay.

private void chooseWay(final MasteryItem item, final HeroSubClass way1, final HeroSubClass way2) {
    IconTitle titlebar = new IconTitle();
    titlebar.icon(new ItemSprite(item));
    titlebar.label(item.name());
    titlebar.setRect(0, 0, WIDTH, 0);
    add(titlebar);
    Highlighter hl = new Highlighter(getWayDesc(way1, way2));
    Text normal = PixelScene.createMultiline(hl.text, GuiProperties.regularFontSize());
    if (hl.isHighlighted()) {
        normal.mask = hl.inverted();
    }
    normal.maxWidth(WIDTH);
    normal.measure();
    normal.x = titlebar.left();
    normal.y = titlebar.bottom() + GAP;
    add(normal);
    if (hl.isHighlighted()) {
        Text highlighted = PixelScene.createMultiline(hl.text, GuiProperties.regularFontSize());
        highlighted.mask = hl.mask;
        highlighted.maxWidth(normal.getMaxWidth());
        highlighted.measure();
        highlighted.x = normal.x;
        highlighted.y = normal.y;
        add(highlighted);
        highlighted.hardlight(TITLE_COLOR);
    }
    RedButton btnWay1 = new RedButton(Utils.capitalize(way1.title())) {

        @Override
        protected void onClick() {
            hide();
            item.choose(way1);
        }
    };
    btnWay1.setRect(0, normal.y + normal.height() + GAP, (WIDTH - GAP) / 2, BTN_HEIGHT);
    add(btnWay1);
    if (way1 != HeroSubClass.LICH) {
        RedButton btnWay2 = new RedButton(Utils.capitalize(way2.title())) {

            @Override
            protected void onClick() {
                hide();
                item.choose(way2);
            }
        };
        btnWay2.setRect(btnWay1.right() + GAP, btnWay1.top(), btnWay1.width(), BTN_HEIGHT);
        add(btnWay2);
    } else {
        btnBreakSpell(btnWay1);
    }
    RedButton btnCancel = new RedButton(TXT_CANCEL) {

        @Override
        protected void onClick() {
            hide();
        }
    };
    btnCancel.setRect(0, btnWay1.bottom() + GAP, WIDTH, BTN_HEIGHT);
    add(btnCancel);
    resize(WIDTH, (int) btnCancel.bottom());
}
Also used : Text(com.watabou.noosa.Text) ItemSprite(com.watabou.pixeldungeon.sprites.ItemSprite) RedButton(com.watabou.pixeldungeon.ui.RedButton)

Aggregations

Text (com.watabou.noosa.Text)18 Archs (com.watabou.pixeldungeon.ui.Archs)6 RedButton (com.watabou.pixeldungeon.ui.RedButton)5 Image (com.watabou.noosa.Image)4 ExitButton (com.watabou.pixeldungeon.ui.ExitButton)4 ScrollPane (com.watabou.pixeldungeon.ui.ScrollPane)4 NinePatch (com.watabou.noosa.NinePatch)3 Component (com.watabou.noosa.ui.Component)3 Intent (android.content.Intent)2 Touch (com.watabou.input.Touchscreen.Touch)2 SystemText (com.watabou.noosa.SystemText)2 TouchArea (com.watabou.noosa.TouchArea)2 Flare (com.watabou.pixeldungeon.effects.Flare)2 ItemSprite (com.watabou.pixeldungeon.sprites.ItemSprite)2 Spell (com.nyrds.pixeldungeon.mechanics.spells.Spell)1 BitmapText (com.watabou.noosa.BitmapText)1 Visual (com.watabou.noosa.Visual)1 BadgesList (com.watabou.pixeldungeon.ui.BadgesList)1 ChangelogButton (com.watabou.pixeldungeon.ui.ChangelogButton)1 DonateButton (com.watabou.pixeldungeon.ui.DonateButton)1