Search in sources :

Example 1 with ScrollPane

use of com.watabou.pixeldungeon.ui.ScrollPane 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 2 with ScrollPane

use of com.watabou.pixeldungeon.ui.ScrollPane in project pixel-dungeon-remix by NYRDS.

the class AllowStatisticsCollectionScene method create.

@Override
public void create() {
    super.create();
    Text title = createMultiline(TTL_Welcome, 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;
    Text text = createMultiline(Game.getVar(R.string.AllowStatisticsCollectionScene_Request), GuiProperties.regularFontSize());
    text.maxWidth((int) panel.innerWidth());
    text.measure();
    content.add(text);
    yPos += text.height() + GAP;
    content.setSize(panel.innerWidth(), yPos);
    RedButton allow = new RedButton(Game.getVar(R.string.AllowStatisticsCollectionScene_Allow)) {

        @Override
        protected void onClick() {
            Preferences.INSTANCE.put(Preferences.KEY_COLLECT_STATS, 100);
            Game.instance().initEventCollector();
            Game.switchScene(TitleScene.class);
        }
    };
    RedButton deny = new RedButton(Game.getVar(R.string.AllowStatisticsCollectionScene_Deny)) {

        @Override
        protected void onClick() {
            Preferences.INSTANCE.put(Preferences.KEY_COLLECT_STATS, -100);
            Game.instance().initEventCollector();
            Game.switchScene(TitleScene.class);
        }
    };
    allow.setRect((w - pw) / 2, h - 22, pw / 2 - GAP, 18);
    deny.setRect((w - pw) / 2 + pw / 2, h - 22, pw / 2 - GAP, 18);
    add(allow);
    add(deny);
    Archs archs = new Archs();
    archs.setSize(Camera.main.width, Camera.main.height);
    addToBack(archs);
    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 ScrollPane

use of com.watabou.pixeldungeon.ui.ScrollPane in project pixel-dungeon-remix by NYRDS.

the class BadgesScene method create.

@Override
public void create() {
    super.create();
    Music.INSTANCE.play(Assets.THEME, true);
    Music.INSTANCE.volume(1f);
    uiCamera.setVisible(false);
    int w = Camera.main.width;
    int h = Camera.main.height;
    Archs archs = new Archs();
    archs.setSize(w, h);
    add(archs);
    int pw = Math.min(160, w - 6);
    int ph = h - 30;
    NinePatch panel = Chrome.get(Chrome.Type.WINDOW);
    panel.size(pw, ph);
    panel.x = (w - pw) / 2;
    panel.y = (h - ph) / 2;
    add(panel);
    Text title = PixelScene.createText(TXT_TITLE, GuiProperties.titleFontSize());
    title.hardlight(Window.TITLE_COLOR);
    title.measure();
    title.x = align((w - title.width()) / 2);
    title.y = align((panel.y - title.baseLine()) / 2);
    add(title);
    Badges.loadGlobal();
    ScrollPane list = new BadgesList(true);
    add(list);
    list.setRect(panel.x + panel.marginLeft(), panel.y + panel.marginTop(), panel.innerWidth(), panel.innerHeight());
    ExitButton btnExit = new ExitButton();
    btnExit.setPos(Camera.main.width - btnExit.width(), 0);
    add(btnExit);
    fadeIn();
}
Also used : Archs(com.watabou.pixeldungeon.ui.Archs) ExitButton(com.watabou.pixeldungeon.ui.ExitButton) ScrollPane(com.watabou.pixeldungeon.ui.ScrollPane) NinePatch(com.watabou.noosa.NinePatch) BadgesList(com.watabou.pixeldungeon.ui.BadgesList) Text(com.watabou.noosa.Text)

Example 4 with ScrollPane

use of com.watabou.pixeldungeon.ui.ScrollPane in project pixel-dungeon-remix by NYRDS.

the class GenericInfo method makeInfo.

public static void makeInfo(Window parent, Image icon, String title, int titleColor, String desc) {
    IconTitle titlebar = new IconTitle();
    titlebar.icon(icon);
    titlebar.label(Utils.capitalize(title), titleColor);
    titlebar.setRect(0, 0, WIDTH, 0);
    parent.add(titlebar);
    Text txtInfo = PixelScene.createMultiline(desc, GuiProperties.regularFontSize());
    txtInfo.maxWidth(WIDTH);
    txtInfo.measure();
    txtInfo.setPos(0, 0);
    int wndHeight = (int) Math.min((titlebar.bottom() + txtInfo.height() + 3 * GAP), MAX_HEIGHT);
    parent.resize(WIDTH, wndHeight);
    int scroolZoneHeight = (int) (wndHeight - titlebar.bottom() - GAP * 2);
    ScrollPane list = new ScrollPane(new Component());
    parent.add(list);
    list.setRect(0, titlebar.height() + GAP, WIDTH, scroolZoneHeight);
    Component content = list.content();
    content.clear();
    content.add(txtInfo);
    content.setSize(txtInfo.width(), txtInfo.height());
}
Also used : ScrollPane(com.watabou.pixeldungeon.ui.ScrollPane) Text(com.watabou.noosa.Text) Component(com.watabou.noosa.ui.Component) IconTitle(com.watabou.pixeldungeon.windows.IconTitle)

Aggregations

Text (com.watabou.noosa.Text)4 ScrollPane (com.watabou.pixeldungeon.ui.ScrollPane)4 NinePatch (com.watabou.noosa.NinePatch)3 Component (com.watabou.noosa.ui.Component)3 Archs (com.watabou.pixeldungeon.ui.Archs)3 RedButton (com.watabou.pixeldungeon.ui.RedButton)2 BadgesList (com.watabou.pixeldungeon.ui.BadgesList)1 ExitButton (com.watabou.pixeldungeon.ui.ExitButton)1 IconTitle (com.watabou.pixeldungeon.windows.IconTitle)1