use of com.watabou.noosa.BitmapTextMultiline in project pixel-dungeon by watabou.
the class StartScene method create.
@Override
public void create() {
super.create();
Badges.loadGlobal();
uiCamera.visible = false;
int w = Camera.main.width;
int h = Camera.main.height;
float width, height;
if (PixelDungeon.landscape()) {
width = WIDTH_L;
height = HEIGHT_L;
} else {
width = WIDTH_P;
height = HEIGHT_P;
}
float left = (w - width) / 2;
float top = (h - height) / 2;
float bottom = h - top;
Archs archs = new Archs();
archs.setSize(w, h);
add(archs);
Image title = BannerSprites.get(Type.SELECT_YOUR_HERO);
title.x = align((w - title.width()) / 2);
title.y = align(top);
add(title);
buttonX = left;
buttonY = bottom - BUTTON_HEIGHT;
btnNewGame = new GameButton(TXT_NEW) {
@Override
protected void onClick() {
if (GamesInProgress.check(curClass) != null) {
StartScene.this.add(new WndOptions(TXT_REALLY, TXT_WARNING, TXT_YES, TXT_NO) {
@Override
protected void onSelect(int index) {
if (index == 0) {
startNewGame();
}
}
});
} else {
startNewGame();
}
}
};
add(btnNewGame);
btnLoad = new GameButton(TXT_LOAD) {
@Override
protected void onClick() {
InterlevelScene.mode = InterlevelScene.Mode.CONTINUE;
Game.switchScene(InterlevelScene.class);
}
};
add(btnLoad);
float centralHeight = buttonY - title.y - title.height();
HeroClass[] classes = { HeroClass.WARRIOR, HeroClass.MAGE, HeroClass.ROGUE, HeroClass.HUNTRESS };
for (HeroClass cl : classes) {
ClassShield shield = new ClassShield(cl);
shields.put(cl, shield);
add(shield);
}
if (PixelDungeon.landscape()) {
float shieldW = width / 4;
float shieldH = Math.min(centralHeight, shieldW);
top = title.y + title.height + (centralHeight - shieldH) / 2;
for (int i = 0; i < classes.length; i++) {
ClassShield shield = shields.get(classes[i]);
shield.setRect(left + i * shieldW, top, shieldW, shieldH);
}
ChallengeButton challenge = new ChallengeButton();
challenge.setPos(w / 2 - challenge.width() / 2, top + shieldH - challenge.height() / 2);
add(challenge);
} else {
float shieldW = width / 2;
float shieldH = Math.min(centralHeight / 2, shieldW * 1.2f);
top = title.y + title.height() + centralHeight / 2 - shieldH;
for (int i = 0; i < classes.length; i++) {
ClassShield shield = shields.get(classes[i]);
shield.setRect(left + (i % 2) * shieldW, top + (i / 2) * shieldH, shieldW, shieldH);
}
ChallengeButton challenge = new ChallengeButton();
challenge.setPos(w / 2 - challenge.width() / 2, top + shieldH - challenge.height() / 2);
add(challenge);
}
unlock = new Group();
add(unlock);
if (!(huntressUnlocked = Badges.isUnlocked(Badges.Badge.BOSS_SLAIN_3))) {
BitmapTextMultiline text = PixelScene.createMultiline(TXT_UNLOCK, 9);
text.maxWidth = (int) width;
text.measure();
float pos = (bottom - BUTTON_HEIGHT) + (BUTTON_HEIGHT - text.height()) / 2;
for (BitmapText line : text.new LineSplitter().split()) {
line.measure();
line.hardlight(0xFFFF00);
line.x = PixelScene.align(w / 2 - line.width() / 2);
line.y = PixelScene.align(pos);
unlock.add(line);
pos += line.height();
}
}
ExitButton btnExit = new ExitButton();
btnExit.setPos(Camera.main.width - btnExit.width(), 0);
add(btnExit);
curClass = null;
updateClass(HeroClass.values()[PixelDungeon.lastClass()]);
fadeIn();
Badges.loadingListener = new Callback() {
@Override
public void call() {
if (Game.scene() == StartScene.this) {
PixelDungeon.switchNoFade(StartScene.class);
}
}
};
}
use of com.watabou.noosa.BitmapTextMultiline in project pixel-dungeon by watabou.
the class WndInfoItem method fillFields.
private void fillFields(int image, ItemSprite.Glowing glowing, int titleColor, String title, String info) {
IconTitle titlebar = new IconTitle();
titlebar.icon(new ItemSprite(image, glowing));
titlebar.label(Utils.capitalize(title), titleColor);
titlebar.setRect(0, 0, WIDTH, 0);
add(titlebar);
BitmapTextMultiline txtInfo = PixelScene.createMultiline(info, 6);
txtInfo.maxWidth = WIDTH;
txtInfo.measure();
txtInfo.x = titlebar.left();
txtInfo.y = titlebar.bottom() + GAP;
add(txtInfo);
resize(WIDTH, (int) (txtInfo.y + txtInfo.height()));
}
use of com.watabou.noosa.BitmapTextMultiline in project pixel-dungeon by watabou.
the class WndTradeItem method createDescription.
private float createDescription(Item item, boolean forSale) {
IconTitle titlebar = new IconTitle();
titlebar.icon(new ItemSprite(item.image(), item.glowing()));
titlebar.label(forSale ? Utils.format(TXT_SALE, item.toString(), price(item)) : Utils.capitalize(item.toString()));
titlebar.setRect(0, 0, WIDTH, 0);
add(titlebar);
if (item.levelKnown) {
if (item.level() < 0) {
titlebar.color(ItemSlot.DEGRADED);
} else if (item.level() > 0) {
titlebar.color(item.isBroken() ? ItemSlot.WARNING : ItemSlot.UPGRADED);
}
}
BitmapTextMultiline info = PixelScene.createMultiline(item.info(), 6);
info.maxWidth = WIDTH;
info.measure();
info.x = titlebar.left();
info.y = titlebar.bottom() + GAP;
add(info);
return info.y + info.height();
}
use of com.watabou.noosa.BitmapTextMultiline in project pixel-dungeon by watabou.
the class PixelScene method createMultiline.
public static BitmapTextMultiline createMultiline(String text, float size) {
chooseFont(size);
BitmapTextMultiline result = new BitmapTextMultiline(text, font);
result.scale.set(scale);
return result;
}
use of com.watabou.noosa.BitmapTextMultiline in project pixel-dungeon by watabou.
the class AboutScene method create.
@Override
public void create() {
super.create();
BitmapTextMultiline text = createMultiline(TXT, 8);
text.maxWidth = Math.min(Camera.main.width, 120);
text.measure();
add(text);
text.x = align((Camera.main.width - text.width()) / 2);
text.y = align((Camera.main.height - text.height()) / 2);
BitmapTextMultiline link = createMultiline(LNK, 8);
link.maxWidth = Math.min(Camera.main.width, 120);
link.measure();
link.hardlight(Window.TITLE_COLOR);
add(link);
link.x = text.x;
link.y = text.y + text.height();
TouchArea hotArea = new TouchArea(link) {
@Override
protected void onClick(Touch touch) {
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://" + LNK));
Game.instance.startActivity(intent);
}
};
add(hotArea);
Image wata = Icons.WATA.get();
wata.x = align((Camera.main.width - wata.width) / 2);
wata.y = text.y - wata.height - 8;
add(wata);
new Flare(7, 64).color(0x112233, true).show(wata, 0).angularSpeed = +20;
Archs archs = new Archs();
archs.setSize(Camera.main.width, Camera.main.height);
addToBack(archs);
ExitButton btnExit = new ExitButton();
btnExit.setPos(Camera.main.width - btnExit.width(), 0);
add(btnExit);
fadeIn();
}
Aggregations