public WndBlacksmith(Blacksmith troll, Hero hero) { super(); IconTitle titlebar = new IconTitle(); titlebar.icon(troll.sprite()); titlebar.label(Utils.capitalize(troll.name)); titlebar.setRect(0, 0, WIDTH, 0); add(titlebar); BitmapTextMultiline message = PixelScene.createMultiline(TXT_PROMPT, 6); message.maxWidth = WIDTH; message.measure(); message.y = titlebar.bottom() + GAP; add(message); btnItem1 = new ItemButton() { @Override protected void onClick() { btnPressed = btnItem1; GameScene.selectItem(itemSelector, WndBag.Mode.UPGRADEABLE, TXT_SELECT); } }; btnItem1.setRect( (WIDTH - BTN_GAP) / 2 - BTN_SIZE, message.y + message.height() + BTN_GAP, BTN_SIZE, BTN_SIZE); add(btnItem1); btnItem2 = new ItemButton() { @Override protected void onClick() { btnPressed = btnItem2; GameScene.selectItem(itemSelector, WndBag.Mode.UPGRADEABLE, TXT_SELECT); } }; btnItem2.setRect(btnItem1.right() + BTN_GAP, btnItem1.top(), BTN_SIZE, BTN_SIZE); add(btnItem2); btnReforge = new RedButton(TXT_REFORGE) { @Override protected void onClick() { Blacksmith.upgrade(btnItem1.item, btnItem2.item); hide(); } }; btnReforge.enable(false); btnReforge.setRect(0, btnItem1.bottom() + BTN_GAP, WIDTH, 20); add(btnReforge); resize(WIDTH, (int) btnReforge.bottom()); }
@Override public void onSelect(Item item) { if (item != null) { btnPressed.item(item); if (btnItem1.item != null && btnItem2.item != null) { String result = Blacksmith.verify(btnItem1.item, btnItem2.item); if (result != null) { GameScene.show(new WndMessage(result)); btnReforge.enable(false); } else { btnReforge.enable(true); } } } }