diff --git a/apps/openmw/mwgui/levelupdialog.cpp b/apps/openmw/mwgui/levelupdialog.cpp index 1434455b2..362ad3b1c 100644 --- a/apps/openmw/mwgui/levelupdialog.cpp +++ b/apps/openmw/mwgui/levelupdialog.cpp @@ -89,7 +89,7 @@ namespace MWGui void LevelupDialog::resetCoins() { - const int coinSpacing = 10; + const int coinSpacing = 33; int curX = mCoinBox->getWidth()/2 - (coinSpacing*(mCoinCount - 1) + 16*mCoinCount)/2; for (unsigned int i=0; isetDisplayMode(ItemChargeView::DisplayMode_EnchantmentCharge); + mGemIcon->eventMouseButtonClick += MyGUI::newDelegate(this, &Recharge::onSelectItem); + setVisible(false); } @@ -87,6 +90,12 @@ void Recharge::updateView() mGemBox->setVisible(toolBoxVisible); mGemBox->setUserString("Hidden", toolBoxVisible ? "false" : "true"); + if (!toolBoxVisible) + { + mGemIcon->setItem(MWWorld::Ptr()); + mGemIcon->clearUserStrings(); + } + mBox->update(); Gui::Box* box = dynamic_cast(mMainWidget); @@ -102,6 +111,34 @@ void Recharge::onCancel(MyGUI::Widget *sender) exit(); } +void Recharge::onSelectItem(MyGUI::Widget *sender) +{ + delete mItemSelectionDialog; + mItemSelectionDialog = new ItemSelectionDialog("#{sSoulGemsWithSouls}"); + mItemSelectionDialog->eventItemSelected += MyGUI::newDelegate(this, &Recharge::onItemSelected); + mItemSelectionDialog->eventDialogCanceled += MyGUI::newDelegate(this, &Recharge::onItemCancel); + mItemSelectionDialog->setVisible(true); + mItemSelectionDialog->openContainer(MWMechanics::getPlayer()); + mItemSelectionDialog->setFilter(SortFilterItemModel::Filter_OnlyChargedSoulstones); +} + +void Recharge::onItemSelected(MWWorld::Ptr item) +{ + mItemSelectionDialog->setVisible(false); + + mGemIcon->setItem(item); + mGemIcon->setUserString ("ToolTipType", "ItemPtr"); + mGemIcon->setUserData(item); + + MWBase::Environment::get().getSoundManager()->playSound(item.getClass().getDownSoundId(item), 1, 1); + updateView(); +} + +void Recharge::onItemCancel() +{ + mItemSelectionDialog->setVisible(false); +} + void Recharge::onItemClicked(MyGUI::Widget *sender, const MWWorld::Ptr& item) { MWWorld::Ptr gem = *mGemIcon->getUserData(); diff --git a/apps/openmw/mwgui/recharge.hpp b/apps/openmw/mwgui/recharge.hpp index bbcf994dd..cc3db14df 100644 --- a/apps/openmw/mwgui/recharge.hpp +++ b/apps/openmw/mwgui/recharge.hpp @@ -3,6 +3,8 @@ #include "windowbase.hpp" +#include "itemselection.hpp" + namespace MWWorld { class Ptr; @@ -11,6 +13,7 @@ namespace MWWorld namespace MWGui { +class ItemSelectionDialog; class ItemWidget; class ItemChargeView; @@ -32,12 +35,19 @@ protected: ItemWidget* mGemIcon; + ItemSelectionDialog* mItemSelectionDialog; + MyGUI::TextBox* mChargeLabel; MyGUI::Button* mCancelButton; void updateView(); + void onSelectItem(MyGUI::Widget* sender); + + void onItemSelected(MWWorld::Ptr item); + void onItemCancel(); + void onItemClicked (MyGUI::Widget* sender, const MWWorld::Ptr& item); void onCancel (MyGUI::Widget* sender); void onMouseWheel(MyGUI::Widget* _sender, int _rel); diff --git a/apps/openmw/mwgui/repair.cpp b/apps/openmw/mwgui/repair.cpp index 3acea985b..156f4412b 100644 --- a/apps/openmw/mwgui/repair.cpp +++ b/apps/openmw/mwgui/repair.cpp @@ -30,6 +30,7 @@ namespace MWGui Repair::Repair() : WindowBase("openmw_repair.layout") + , mItemSelectionDialog(NULL) { getWidget(mRepairBox, "RepairBox"); getWidget(mToolBox, "ToolBox"); @@ -39,9 +40,11 @@ Repair::Repair() getWidget(mCancelButton, "CancelButton"); mCancelButton->eventMouseButtonClick += MyGUI::newDelegate(this, &Repair::onCancel); - mRepairBox->eventItemClicked += MyGUI::newDelegate(this, &Repair::onRepairItem); + mRepairBox->eventItemClicked += MyGUI::newDelegate(this, &Repair::onRepairItem); mRepairBox->setDisplayMode(ItemChargeView::DisplayMode_Health); + + mToolIcon->eventMouseButtonClick += MyGUI::newDelegate(this, &Repair::onSelectItem); } void Repair::open() @@ -83,6 +86,8 @@ void Repair::updateRepairView() float quality = ref->mBase->mData.mQuality; + mToolIcon->setUserData(mRepair.getTool()); + std::stringstream qualityStr; qualityStr << std::setprecision(3) << quality; @@ -93,6 +98,12 @@ void Repair::updateRepairView() mToolBox->setVisible(toolBoxVisible); mToolBox->setUserString("Hidden", toolBoxVisible ? "false" : "true"); + if (!toolBoxVisible) + { + mToolIcon->setItem(MWWorld::Ptr()); + mToolIcon->clearUserStrings(); + } + mRepairBox->update(); Gui::Box* box = dynamic_cast(mMainWidget); @@ -103,6 +114,36 @@ void Repair::updateRepairView() center(); } +void Repair::onSelectItem(MyGUI::Widget *sender) +{ + delete mItemSelectionDialog; + mItemSelectionDialog = new ItemSelectionDialog("#{sRepair}"); + mItemSelectionDialog->eventItemSelected += MyGUI::newDelegate(this, &Repair::onItemSelected); + mItemSelectionDialog->eventDialogCanceled += MyGUI::newDelegate(this, &Repair::onItemCancel); + mItemSelectionDialog->setVisible(true); + mItemSelectionDialog->openContainer(MWMechanics::getPlayer()); + mItemSelectionDialog->setFilter(SortFilterItemModel::Filter_OnlyRepairTools); +} + +void Repair::onItemSelected(MWWorld::Ptr item) +{ + mItemSelectionDialog->setVisible(false); + + mToolIcon->setItem(item); + mToolIcon->setUserString ("ToolTipType", "ItemPtr"); + mToolIcon->setUserData(item); + + mRepair.setTool(item); + + MWBase::Environment::get().getSoundManager()->playSound(item.getClass().getDownSoundId(item), 1, 1); + updateRepairView(); +} + +void Repair::onItemCancel() +{ + mItemSelectionDialog->setVisible(false); +} + void Repair::onCancel(MyGUI::Widget* /*sender*/) { exit(); diff --git a/apps/openmw/mwgui/repair.hpp b/apps/openmw/mwgui/repair.hpp index 8746f7dc4..c50ba861a 100644 --- a/apps/openmw/mwgui/repair.hpp +++ b/apps/openmw/mwgui/repair.hpp @@ -3,11 +3,14 @@ #include "windowbase.hpp" +#include "itemselection.hpp" + #include "../mwmechanics/repair.hpp" namespace MWGui { +class ItemSelectionDialog; class ItemWidget; class ItemChargeView; @@ -29,6 +32,8 @@ protected: ItemWidget* mToolIcon; + ItemSelectionDialog* mItemSelectionDialog; + MyGUI::TextBox* mUsesLabel; MyGUI::TextBox* mQualityLabel; @@ -38,6 +43,11 @@ protected: void updateRepairView(); + void onSelectItem(MyGUI::Widget* sender); + + void onItemSelected(MWWorld::Ptr item); + void onItemCancel(); + void onRepairItem(MyGUI::Widget* sender, const MWWorld::Ptr& ptr); void onCancel(MyGUI::Widget* sender); diff --git a/apps/openmw/mwgui/sortfilteritemmodel.cpp b/apps/openmw/mwgui/sortfilteritemmodel.cpp index 09438b950..60111fb79 100644 --- a/apps/openmw/mwgui/sortfilteritemmodel.cpp +++ b/apps/openmw/mwgui/sortfilteritemmodel.cpp @@ -129,6 +129,8 @@ namespace MWGui if ((mFilter & Filter_OnlyChargedSoulstones) && (base.getTypeName() != typeid(ESM::Miscellaneous).name() || base.getCellRef().getSoul() == "")) return false; + if ((mFilter & Filter_OnlyRepairTools) && (base.getTypeName() != typeid(ESM::Repair).name())) + return false; if ((mFilter & Filter_OnlyEnchantable) && (item.mFlags & ItemStack::Flag_Enchanted || (base.getTypeName() != typeid(ESM::Armor).name() && base.getTypeName() != typeid(ESM::Clothing).name() diff --git a/apps/openmw/mwgui/sortfilteritemmodel.hpp b/apps/openmw/mwgui/sortfilteritemmodel.hpp index 3d5396e2a..4731cbb8a 100644 --- a/apps/openmw/mwgui/sortfilteritemmodel.hpp +++ b/apps/openmw/mwgui/sortfilteritemmodel.hpp @@ -41,6 +41,7 @@ namespace MWGui static const int Filter_OnlyUsableItems = (1<<4); // Only items with a Use action static const int Filter_OnlyRepairable = (1<<5); static const int Filter_OnlyRechargable = (1<<6); + static const int Filter_OnlyRepairTools = (1<<7); private: diff --git a/apps/openmw/mwmechanics/aicombataction.cpp b/apps/openmw/mwmechanics/aicombataction.cpp index 1082c540b..d0464418b 100644 --- a/apps/openmw/mwmechanics/aicombataction.cpp +++ b/apps/openmw/mwmechanics/aicombataction.cpp @@ -264,6 +264,13 @@ namespace MWMechanics case ESM::MagicEffect::ResistCorprusDisease: case ESM::MagicEffect::Invisibility: case ESM::MagicEffect::Chameleon: + case ESM::MagicEffect::NightEye: + case ESM::MagicEffect::Vampirism: + case ESM::MagicEffect::StuntedMagicka: + case ESM::MagicEffect::ExtraSpell: + case ESM::MagicEffect::RemoveCurse: + case ESM::MagicEffect::CommandCreature: + case ESM::MagicEffect::CommandHumanoid: return 0.f; case ESM::MagicEffect::Sound: @@ -295,6 +302,8 @@ namespace MWMechanics case ESM::MagicEffect::ResistParalysis: case ESM::MagicEffect::ResistPoison: case ESM::MagicEffect::ResistShock: + case ESM::MagicEffect::SpellAbsorption: + case ESM::MagicEffect::Reflect: return 0.f; // probably useless since we don't know in advance what the enemy will cast // don't cast these for now as they would make the NPC cast the same effect over and over again, especially when they have potions @@ -304,13 +313,50 @@ namespace MWMechanics case ESM::MagicEffect::FortifyFatigue: case ESM::MagicEffect::FortifySkill: case ESM::MagicEffect::FortifyMaximumMagicka: + case ESM::MagicEffect::FortifyAttack: return 0.f; + case ESM::MagicEffect::Burden: + { + if (enemy.isEmpty()) + return 0.f; + + // Ignore enemy without inventory + if (!enemy.getClass().hasInventoryStore(enemy)) + return 0.f; + + // burden makes sense only to overburden an enemy + float burden = enemy.getClass().getEncumbrance(enemy) - enemy.getClass().getCapacity(enemy); + if (burden > 0) + return 0.f; + + if ((effect.mMagnMin + effect.mMagnMax)/2.f > -burden) + rating *= 3; + else + return 0.f; + + break; + } + case ESM::MagicEffect::Feather: - if (actor.getClass().getEncumbrance(actor) - actor.getClass().getCapacity(actor) >= 0) - return 100.f; - else - return 0.f; + { + // Ignore actors without inventory + if (!actor.getClass().hasInventoryStore(actor)) + return 0.f; + + // feather makes sense only for overburden actors + float burden = actor.getClass().getEncumbrance(actor) - actor.getClass().getCapacity(actor); + if (burden <= 0) + return 0.f; + + if ((effect.mMagnMin + effect.mMagnMax)/2.f >= burden) + rating *= 3; + else + return 0.f; + + break; + } + case ESM::MagicEffect::Levitate: return 0.f; // AI isn't designed to take advantage of this, and could be perceived as unfair anyway case ESM::MagicEffect::BoundBoots: diff --git a/files/mygui/openmw_chargen_class.layout b/files/mygui/openmw_chargen_class.layout index 53a6a6642..35dd57ca3 100644 --- a/files/mygui/openmw_chargen_class.layout +++ b/files/mygui/openmw_chargen_class.layout @@ -27,16 +27,23 @@ - - - - - - - + + + + + + + + + + + + + - - + + + diff --git a/files/mygui/openmw_chargen_create_class.layout b/files/mygui/openmw_chargen_create_class.layout index 5f0b02c1b..9ca6c6a31 100644 --- a/files/mygui/openmw_chargen_create_class.layout +++ b/files/mygui/openmw_chargen_create_class.layout @@ -26,22 +26,30 @@ - - - - - - - - + + + + + + + + + + + + + - - + + + + + diff --git a/files/mygui/openmw_chargen_race.layout b/files/mygui/openmw_chargen_race.layout index bddede361..04bd9cc53 100644 --- a/files/mygui/openmw_chargen_race.layout +++ b/files/mygui/openmw_chargen_race.layout @@ -57,7 +57,7 @@ - + diff --git a/files/mygui/openmw_chargen_select_attribute.layout b/files/mygui/openmw_chargen_select_attribute.layout index a00577e41..0821d4a57 100644 --- a/files/mygui/openmw_chargen_select_attribute.layout +++ b/files/mygui/openmw_chargen_select_attribute.layout @@ -1,23 +1,23 @@ - - + + - + - - - - - - - - + + + + + + + + diff --git a/files/mygui/openmw_chargen_select_skill.layout b/files/mygui/openmw_chargen_select_skill.layout index b6e90b688..d1061882d 100644 --- a/files/mygui/openmw_chargen_select_skill.layout +++ b/files/mygui/openmw_chargen_select_skill.layout @@ -1,6 +1,6 @@ - + diff --git a/files/mygui/openmw_chargen_select_specialization.layout b/files/mygui/openmw_chargen_select_specialization.layout index 70c5fdca5..c4fe6c631 100644 --- a/files/mygui/openmw_chargen_select_specialization.layout +++ b/files/mygui/openmw_chargen_select_specialization.layout @@ -1,13 +1,13 @@ - + - + - + diff --git a/files/mygui/openmw_infobox.layout b/files/mygui/openmw_infobox.layout index ea9f78614..252a237cd 100644 --- a/files/mygui/openmw_infobox.layout +++ b/files/mygui/openmw_infobox.layout @@ -11,6 +11,6 @@ - + diff --git a/files/mygui/openmw_itemselection_dialog.layout b/files/mygui/openmw_itemselection_dialog.layout index 5ae30563a..b2337b669 100644 --- a/files/mygui/openmw_itemselection_dialog.layout +++ b/files/mygui/openmw_itemselection_dialog.layout @@ -1,6 +1,6 @@ - + diff --git a/files/mygui/openmw_levelup_dialog.layout b/files/mygui/openmw_levelup_dialog.layout index ad0004934..fc11ddfd7 100644 --- a/files/mygui/openmw_levelup_dialog.layout +++ b/files/mygui/openmw_levelup_dialog.layout @@ -2,7 +2,7 @@ - + @@ -22,25 +22,25 @@ - + - + - - - - - - - - + + + + + + + + - + @@ -54,7 +54,7 @@ - + @@ -68,7 +68,7 @@ - + @@ -82,7 +82,7 @@ - + @@ -97,7 +97,7 @@ - + @@ -111,7 +111,7 @@ - + @@ -125,7 +125,7 @@ - + @@ -139,7 +139,7 @@ - + diff --git a/files/mygui/openmw_list.skin.xml b/files/mygui/openmw_list.skin.xml index 111d3bf30..8a238879c 100644 --- a/files/mygui/openmw_list.skin.xml +++ b/files/mygui/openmw_list.skin.xml @@ -127,7 +127,7 @@ - + @@ -140,7 +140,7 @@ - + diff --git a/files/mygui/openmw_recharge_dialog.layout b/files/mygui/openmw_recharge_dialog.layout index 9301bec92..d620aadab 100644 --- a/files/mygui/openmw_recharge_dialog.layout +++ b/files/mygui/openmw_recharge_dialog.layout @@ -1,22 +1,12 @@ - + - - - - - - - - - - - - + + @@ -26,14 +16,25 @@ - - - - - - + + + + + + + + + + + + + + + + + + - diff --git a/files/mygui/openmw_repair.layout b/files/mygui/openmw_repair.layout index 9a349c56b..340711bb1 100644 --- a/files/mygui/openmw_repair.layout +++ b/files/mygui/openmw_repair.layout @@ -1,26 +1,13 @@ - + - - - - - - - - - - - - - - - - + + + @@ -29,14 +16,31 @@ - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + - -