diff options
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/widgets/shoplistbox.cpp | 2 | ||||
-rw-r--r-- | src/gui/windows/inventorywindow.cpp | 34 | ||||
-rw-r--r-- | src/gui/windows/shopwindow.cpp | 28 | ||||
-rw-r--r-- | src/gui/windows/skilldialog.cpp | 139 |
4 files changed, 94 insertions, 109 deletions
diff --git a/src/gui/widgets/shoplistbox.cpp b/src/gui/widgets/shoplistbox.cpp index ce5f5f8e9..6dd871825 100644 --- a/src/gui/widgets/shoplistbox.cpp +++ b/src/gui/widgets/shoplistbox.cpp @@ -109,7 +109,7 @@ void ShopListBox::draw(Graphics *graphics) ShopItem *const item = mShopItems->at(i); if (item && (item->getDisabled() || - (mShopItems && mPlayerMoney < item->getPrice() && mPriceCheck) || + (mPlayerMoney < item->getPrice() && mPriceCheck) || (mProtectItems && PlayerInfo::isItemProtected(item->getId())))) { if (i != mSelected) diff --git a/src/gui/windows/inventorywindow.cpp b/src/gui/windows/inventorywindow.cpp index e21299583..5c6ae3faa 100644 --- a/src/gui/windows/inventorywindow.cpp +++ b/src/gui/windows/inventorywindow.cpp @@ -572,28 +572,32 @@ void InventoryWindow::mouseClicked(MouseEvent &event) tradeWindow->isWindowVisible() && inputManager.isActionActive(InputAction::STOP_ATTACK)); - if (!mod && !mod2 && event.getButton() == MouseButton::RIGHT) + if (mInventory) { - Item *const item = mItems->getSelectedItem(); + if (!mod && !mod2 && event.getButton() == MouseButton::RIGHT) + { + Item *const item = mItems->getSelectedItem(); - if (!item) - return; + if (!item) + return; - /* Convert relative to the window coordinates to absolute screen - * coordinates. - */ - const int mx = event.getX() + getX(); - const int my = event.getY() + getY(); + /* Convert relative to the window coordinates to absolute screen + * coordinates. + */ + const int mx = event.getX() + getX(); + const int my = event.getY() + getY(); - if (popupMenu) - popupMenu->showPopup(this, mx, my, item, mInventory->getType()); + if (popupMenu) + popupMenu->showPopup(this, mx, my, item, mInventory->getType()); + } } - - if (!mInventory) + else + { return; + } - if (event.getButton() == MouseButton::LEFT - || event.getButton() == MouseButton::RIGHT) + if (event.getButton() == MouseButton::LEFT || + event.getButton() == MouseButton::RIGHT) { Item *const item = mItems->getSelectedItem(); diff --git a/src/gui/windows/shopwindow.cpp b/src/gui/windows/shopwindow.cpp index 7c75c4f92..cf57312dd 100644 --- a/src/gui/windows/shopwindow.cpp +++ b/src/gui/windows/shopwindow.cpp @@ -270,10 +270,10 @@ void ShopWindow::action(const ActionEvent &event) { if (isBuySelected) { - if (mBuyShopItems && mBuyShopItems->getNumberOfElements() > 0) + if (mBuyShopItems->getNumberOfElements() > 0) announce(mBuyShopItems, BUY); } - else if (mSellShopItems && mSellShopItems->getNumberOfElements() > 0) + else if (mSellShopItems->getNumberOfElements() > 0) { announce(mSellShopItems, SELL); } @@ -493,7 +493,7 @@ void ShopWindow::setVisible(Visible visible) void ShopWindow::addBuyItem(const Item *const item, const int amount, const int price) { - if (!mBuyShopItems || !item) + if (!item) return; const bool emp = isShopEmpty(); mBuyShopItems->addItemNoDup(item->getId(), @@ -510,7 +510,7 @@ void ShopWindow::addBuyItem(const Item *const item, const int amount, void ShopWindow::addSellItem(const Item *const item, const int amount, const int price) { - if (!mBuyShopItems || !item) + if (!item) return; const bool emp = isShopEmpty(); mSellShopItems->addItemNoDup(item->getId(), @@ -526,9 +526,6 @@ void ShopWindow::addSellItem(const Item *const item, const int amount, void ShopWindow::loadList() { - if (!mBuyShopItems || !mSellShopItems) - return; - std::ifstream shopFile; struct stat statbuf; @@ -562,12 +559,12 @@ void ShopWindow::loadList() if (tokens.size() == 5 && tokens[0]) { // +++ need impliment colors? - if (tokens[1] && tokens[2] && mBuyShopItems) + if (tokens[1] && tokens[2]) { mBuyShopItems->addItem( tokens[0], 0, ItemColor_one, tokens[1], tokens[2]); } - if (tokens[3] && tokens[4] && mSellShopItems) + if (tokens[3] && tokens[4]) { mSellShopItems->addItem( tokens[0], 0, ItemColor_one, tokens[3], tokens[4]); @@ -581,9 +578,6 @@ void ShopWindow::loadList() void ShopWindow::saveList() const { - if (!mBuyShopItems || !mSellShopItems) - return; - std::ofstream shopFile; const std::string shopListName = settings.serverConfigDir + "/shoplist.txt"; @@ -1045,17 +1039,9 @@ bool ShopWindow::findShopItem(const ShopItem *const shopItem, std::vector<ShopItem*> items; if (mode == SELL) - { - if (!mSellShopItems) - return false; items = mSellShopItems->items(); - } else - { - if (!mBuyShopItems) - return false; items = mBuyShopItems->items(); - } FOR_EACH (std::vector<ShopItem*>::const_iterator, it, items) { @@ -1095,8 +1081,6 @@ int ShopWindow::sumAmount(const Item *const shopItem) bool ShopWindow::isShopEmpty() const { - if (!mBuyShopItems || !mSellShopItems) - return true; if (mBuyShopItems->empty() && mSellShopItems->empty()) return true; return false; diff --git a/src/gui/windows/skilldialog.cpp b/src/gui/windows/skilldialog.cpp index d8ae3ef2d..c5eb45c02 100644 --- a/src/gui/windows/skilldialog.cpp +++ b/src/gui/windows/skilldialog.cpp @@ -745,95 +745,92 @@ void SkillDialog::useSkill(const SkillInfo *const info, if (!cmd.empty()) SpellManager::invokeCommand(cmd, localPlayer->getTarget()); } - if (localPlayer) + switch (info->type) { - switch (info->type) + case SkillType::Attack: { - case SkillType::Attack: + const Being *being = localPlayer->getTarget(); + if (!being && autoTarget == AutoTarget_true) { - const Being *being = localPlayer->getTarget(); - if (!being && autoTarget == AutoTarget_true) - { - being = localPlayer->setNewTarget(ActorType::Monster, - AllowSort_true); - } - if (being) - { - skillHandler->useBeing(info->id, - level, - being->getId()); - } - break; + being = localPlayer->setNewTarget(ActorType::Monster, + AllowSort_true); } - case SkillType::Support: + if (being) { - const Being *being = localPlayer->getTarget(); - if (!being) - being = localPlayer; - if (being) - { - skillHandler->useBeing(info->id, - level, - being->getId()); - } - break; + skillHandler->useBeing(info->id, + level, + being->getId()); } - case SkillType::Self: + break; + } + case SkillType::Support: + { + const Being *being = localPlayer->getTarget(); + if (!being) + being = localPlayer; + if (being) + { skillHandler->useBeing(info->id, level, - localPlayer->getId()); - break; + being->getId()); + } + break; + } + case SkillType::Self: + skillHandler->useBeing(info->id, + level, + localPlayer->getId()); + break; - case SkillType::Ground: + case SkillType::Ground: + { + int x = 0; + int y = 0; + viewport->getMouseTile(x, y); + if (info->useTextParameter) { - int x = 0; - int y = 0; - viewport->getMouseTile(x, y); - if (info->useTextParameter) + if (withText) { - if (withText) - { - skillHandler->usePos(info->id, - level, - x, y, - text); - } - else - { - textSkillListener.setSkill(info->id, - x, - y, - level); - TextDialog *const dialog = CREATEWIDGETR(TextDialog, - // TRANSLATORS: text skill dialog header - strprintf(_("Add text to skill %s"), - data->name.c_str()), - // TRANSLATORS: text skill dialog field - _("Text: ")); - dialog->setModal(Modal_true); - textSkillListener.setDialog(dialog); - dialog->setActionEventId("ok"); - dialog->addActionListener(&textSkillListener); - } + skillHandler->usePos(info->id, + level, + x, y, + text); } else { - skillHandler->usePos(info->id, - level, - x, y); + textSkillListener.setSkill(info->id, + x, + y, + level); + TextDialog *const dialog = CREATEWIDGETR(TextDialog, + // TRANSLATORS: text skill dialog header + strprintf(_("Add text to skill %s"), + data->name.c_str()), + // TRANSLATORS: text skill dialog field + _("Text: ")); + dialog->setModal(Modal_true); + textSkillListener.setDialog(dialog); + dialog->setActionEventId("ok"); + dialog->addActionListener(&textSkillListener); } - break; } + else + { + skillHandler->usePos(info->id, + level, + x, y); + } + break; + } - case SkillType::TargetTrap: - // for now unused - break; + case SkillType::TargetTrap: + // for now unused + break; - case SkillType::Unknown: - case SkillType::Unused: - default: - break; - } + case SkillType::Unknown: + case SkillType::Unused: + default: + break; } } |