use of com.watabou.noosa.ui.Button in project shattered-pixel-dungeon-gdx by 00-Evan.
the class Toolbar method layout.
@Override
protected void layout() {
int[] visible = new int[4];
int slots = SPDSettings.quickSlots();
for (int i = 0; i <= 3; i++) visible[i] = (int) ((slots > i) ? y + 2 : y + 25);
for (int i = 0; i <= 3; i++) {
btnQuick[i].visible = btnQuick[i].active = slots > i;
// decides on quickslot layout, depending on available screen size.
if (slots == 4 && width < 152) {
if (width < 138) {
if ((SPDSettings.flipToolbar() && i == 3) || (!SPDSettings.flipToolbar() && i == 0)) {
btnQuick[i].border(0, 0);
btnQuick[i].frame(88, 0, 17, 24);
} else {
btnQuick[i].border(0, 1);
btnQuick[i].frame(88, 0, 18, 24);
}
} else {
if (i == 0 && !SPDSettings.flipToolbar() || i == 3 && SPDSettings.flipToolbar()) {
btnQuick[i].border(0, 2);
btnQuick[i].frame(106, 0, 19, 24);
} else if (i == 0 && SPDSettings.flipToolbar() || i == 3 && !SPDSettings.flipToolbar()) {
btnQuick[i].border(2, 1);
btnQuick[i].frame(86, 0, 20, 24);
} else {
btnQuick[i].border(0, 1);
btnQuick[i].frame(88, 0, 18, 24);
}
}
} else {
btnQuick[i].border(2, 2);
btnQuick[i].frame(64, 0, 22, 24);
}
}
float right = width;
switch(Mode.valueOf(SPDSettings.toolbarMode())) {
case SPLIT:
btnWait.setPos(x, y);
btnSearch.setPos(btnWait.right(), y);
btnInventory.setPos(right - btnInventory.width(), y);
btnQuick[0].setPos(btnInventory.left() - btnQuick[0].width(), visible[0]);
btnQuick[1].setPos(btnQuick[0].left() - btnQuick[1].width(), visible[1]);
btnQuick[2].setPos(btnQuick[1].left() - btnQuick[2].width(), visible[2]);
btnQuick[3].setPos(btnQuick[2].left() - btnQuick[3].width(), visible[3]);
break;
// center = group but.. well.. centered, so all we need to do is pre-emptively set the right side further in.
case CENTER:
float toolbarWidth = btnWait.width() + btnSearch.width() + btnInventory.width();
for (Button slot : btnQuick) {
if (slot.visible)
toolbarWidth += slot.width();
}
right = (width + toolbarWidth) / 2;
case GROUP:
btnWait.setPos(right - btnWait.width(), y);
btnSearch.setPos(btnWait.left() - btnSearch.width(), y);
btnInventory.setPos(btnSearch.left() - btnInventory.width(), y);
btnQuick[0].setPos(btnInventory.left() - btnQuick[0].width(), visible[0]);
btnQuick[1].setPos(btnQuick[0].left() - btnQuick[1].width(), visible[1]);
btnQuick[2].setPos(btnQuick[1].left() - btnQuick[2].width(), visible[2]);
btnQuick[3].setPos(btnQuick[2].left() - btnQuick[3].width(), visible[3]);
break;
}
right = width;
if (SPDSettings.flipToolbar()) {
btnWait.setPos((right - btnWait.right()), y);
btnSearch.setPos((right - btnSearch.right()), y);
btnInventory.setPos((right - btnInventory.right()), y);
for (int i = 0; i <= 3; i++) {
btnQuick[i].setPos(right - btnQuick[i].right(), visible[i]);
}
}
}
use of com.watabou.noosa.ui.Button in project shattered-pixel-dungeon-gdx by 00-Evan.
the class TitleScene 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);
Image title = BannerSprites.get(BannerSprites.Type.PIXEL_DUNGEON);
add(title);
float topRegion = Math.max(95f, h * 0.45f);
title.x = (w - title.width()) / 2f;
if (SPDSettings.landscape())
title.y = (topRegion - title.height()) / 2f;
else
title.y = 16 + (topRegion - title.height() - 16) / 2f;
align(title);
placeTorch(title.x + 22, title.y + 46);
placeTorch(title.x + title.width - 22, title.y + 46);
Image signs = new Image(BannerSprites.get(BannerSprites.Type.PIXEL_DUNGEON_SIGNS)) {
private float time = 0;
@Override
public void update() {
super.update();
am = Math.max(0f, (float) Math.sin(time += Game.elapsed));
if (time >= 1.5f * Math.PI)
time = 0;
}
@Override
public void draw() {
Blending.setLightMode();
super.draw();
Blending.setNormalMode();
}
};
signs.x = title.x + (title.width() - signs.width()) / 2f;
signs.y = title.y;
add(signs);
DashboardItem btnBadges = new DashboardItem(Messages.get(this, "badges"), 3) {
@Override
protected void onClick() {
ShatteredPixelDungeon.switchNoFade(BadgesScene.class);
}
};
add(btnBadges);
DashboardItem btnAbout = new DashboardItem(Messages.get(this, "about"), 1) {
@Override
protected void onClick() {
ShatteredPixelDungeon.switchNoFade(AboutScene.class);
}
};
add(btnAbout);
DashboardItem btnPlay = new DashboardItem(Messages.get(this, "play"), 0) {
@Override
protected void onClick() {
if (GamesInProgress.checkAll().size() == 0) {
TitleScene.this.add(new WndStartGame(1));
} else {
ShatteredPixelDungeon.switchNoFade(StartScene.class);
}
}
};
add(btnPlay);
DashboardItem btnRankings = new DashboardItem(Messages.get(this, "rankings"), 2) {
@Override
protected void onClick() {
ShatteredPixelDungeon.switchNoFade(RankingsScene.class);
}
};
add(btnRankings);
if (SPDSettings.landscape()) {
btnRankings.setPos(w / 2 - btnRankings.width(), topRegion);
btnBadges.setPos(w / 2, topRegion);
btnPlay.setPos(btnRankings.left() - btnPlay.width(), topRegion);
btnAbout.setPos(btnBadges.right(), topRegion);
} else {
btnPlay.setPos(w / 2 - btnPlay.width(), topRegion);
btnRankings.setPos(w / 2, btnPlay.top());
btnBadges.setPos(w / 2 - btnBadges.width(), btnPlay.top() + DashboardItem.SIZE);
btnAbout.setPos(w / 2, btnBadges.top());
}
BitmapText version = new BitmapText("v " + Game.version + "", pixelFont);
version.measure();
version.hardlight(0xCCCCCC);
version.x = w - version.width();
version.y = h - version.height();
add(version);
Button changes = new ChangesButton();
changes.setPos(w - changes.width(), h - version.height() - changes.height());
add(changes);
int pos = 0;
PrefsButton btnPrefs = new PrefsButton();
btnPrefs.setRect(pos, 0, 16, 16);
add(btnPrefs);
pos += btnPrefs.width();
LanguageButton btnLang = new LanguageButton();
btnLang.setRect(pos, 0, 14, 16);
add(btnLang);
ExitButton btnExit = new ExitButton();
btnExit.setPos(w - btnExit.width(), 0);
add(btnExit);
UpdateNotification updInfo = new UpdateNotification();
updInfo.setPos(0, h - updInfo.height());
add(updInfo);
fadeIn();
}
Aggregations