use of com.shatteredpixel.shatteredpixeldungeon.Badges in project shattered-pixel-dungeon-gdx by 00-Evan.
the class BadgesScene 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 archs = new Archs();
archs.setSize(w, h);
add(archs);
float left = 5;
float top = 16;
RenderedText title = PixelScene.renderText(Messages.get(this, "title"), 9);
title.hardlight(Window.TITLE_COLOR);
title.x = (w - title.width()) / 2f;
title.y = (top - title.baseLine()) / 2f;
align(title);
add(title);
Badges.loadGlobal();
List<Badges.Badge> badges = Badges.filtered(true);
int blankBadges = 34;
blankBadges -= badges.size();
if (badges.contains(Badges.Badge.ALL_ITEMS_IDENTIFIED))
blankBadges -= 6;
if (badges.contains(Badges.Badge.YASD))
blankBadges -= 5;
blankBadges = Math.max(0, blankBadges);
// guarantees a max of 5 rows in landscape, and 8 in portrait, assuming a max of 40 buttons
int nCols = SPDSettings.landscape() ? 7 : 4;
if (badges.size() + blankBadges > 32 && !SPDSettings.landscape())
nCols++;
int nRows = 1 + (blankBadges + badges.size()) / nCols;
float badgeWidth = (w - 2 * left) / nCols;
float badgeHeight = (h - 2 * top) / nRows;
for (int i = 0; i < badges.size() + blankBadges; i++) {
int row = i / nCols;
int col = i % nCols;
Badges.Badge b = i < badges.size() ? badges.get(i) : null;
BadgeButton button = new BadgeButton(b);
button.setPos(left + col * badgeWidth + (badgeWidth - button.width()) / 2, top + row * badgeHeight + (badgeHeight - button.height()) / 2);
align(button);
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) {
ShatteredPixelDungeon.switchNoFade(BadgesScene.class);
}
}
};
}
Aggregations