use of com.watabou.noosa.Text in project pixel-dungeon-remix by NYRDS.
the class WndHeroSpells method addSpell.
private float addSpell(String spellName, final Hero hero, float yPos, int i) {
final Spell spell = SpellFactory.getSpellByName(spellName);
if (spell == null || spell.level() > hero.magicLvl()) {
return yPos;
}
int xPos = 0;
if (i % 2 == 0) {
xPos = width - 48 - MARGIN * 2;
}
Text txtName;
txtName = PixelScene.createText(spell.name(), GuiProperties.titleFontSize());
txtName.measure();
txtName.x = xPos;
txtName.y = yPos;
add(txtName);
Image icon = spell.image();
icon.frame(spell.film.get(spell.imageIndex));
icon.y = txtName.bottom();
icon.x = xPos;
add(icon);
SimpleButton btnCast = new SimpleButton(Icons.get(Icons.BTN_TARGET)) {
protected void onClick() {
hide();
spell.cast(hero);
}
};
btnCast.setRect(icon.x + icon.width() + MARGIN, icon.y, 16, 15);
add(btnCast);
SimpleButton btnInfo = new SimpleButton(Icons.get(Icons.BTN_QUESTION)) {
protected void onClick() {
hide();
GameScene.show(new WndSpellInfo(hero, spell));
}
};
btnInfo.setRect(icon.x + icon.width() + MARGIN, btnCast.bottom() + MARGIN, 16, 15);
add(btnInfo);
Text txtCost;
txtCost = PixelScene.createText(Game.getVar(R.string.Mana_Cost) + spell.spellCost(), GuiProperties.titleFontSize());
txtCost.measure();
txtCost.x = xPos;
txtCost.y = icon.bottom();
add(txtCost);
if (xPos == 0) {
return yPos;
}
return txtCost.bottom() + MARGIN;
}
use of com.watabou.noosa.Text in project pixel-dungeon-remix by NYRDS.
the class WndTradeItem method createDescription.
private float createDescription(Item item, boolean forSale) {
// Title
IconTitle titlebar = new IconTitle();
titlebar.icon(new ItemSprite(item));
titlebar.label(forSale ? Utils.format(TXT_SALE, item.toString(), price(item)) : Utils.capitalize(item.toString()));
titlebar.setRect(0, 0, WIDTH, 0);
add(titlebar);
// Upgraded / degraded
if (item.levelKnown && item.level() > 0) {
titlebar.color(ItemSlot.UPGRADED);
} else if (item.levelKnown && item.level() < 0) {
titlebar.color(ItemSlot.DEGRADED);
}
// Description
Text info = PixelScene.createMultiline(item.info(), GuiProperties.regularFontSize());
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.Text 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