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();
}
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();
}
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();
}
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());
}
Aggregations