mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-16 19:19:56 +00:00
last bits of the quick key menu.
This commit is contained in:
parent
a4c1d979d6
commit
6161f81c24
5 changed files with 91 additions and 33 deletions
|
@ -23,6 +23,12 @@ namespace MWGui
|
||||||
getWidget(cancelButton, "CancelButton");
|
getWidget(cancelButton, "CancelButton");
|
||||||
cancelButton->eventMouseButtonClick += MyGUI::newDelegate(this, &ItemSelectionDialog::onCancelButtonClicked);
|
cancelButton->eventMouseButtonClick += MyGUI::newDelegate(this, &ItemSelectionDialog::onCancelButtonClicked);
|
||||||
|
|
||||||
|
int dx = (cancelButton->getTextSize().width + 24) - cancelButton->getWidth();
|
||||||
|
cancelButton->setCoord(cancelButton->getLeft() - dx,
|
||||||
|
cancelButton->getTop(),
|
||||||
|
cancelButton->getTextSize ().width + 24,
|
||||||
|
cancelButton->getHeight());
|
||||||
|
|
||||||
center();
|
center();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,8 +6,13 @@
|
||||||
#include "../mwbase/world.hpp"
|
#include "../mwbase/world.hpp"
|
||||||
#include "../mwworld/player.hpp"
|
#include "../mwworld/player.hpp"
|
||||||
#include "../mwworld/inventorystore.hpp"
|
#include "../mwworld/inventorystore.hpp"
|
||||||
|
#include "../mwworld/actionequip.hpp"
|
||||||
#include "../mwmechanics/spells.hpp"
|
#include "../mwmechanics/spells.hpp"
|
||||||
#include "../mwmechanics/creaturestats.hpp"
|
#include "../mwmechanics/creaturestats.hpp"
|
||||||
|
#include "../mwmechanics/spellsuccess.hpp"
|
||||||
|
#include "../mwgui/inventorywindow.hpp"
|
||||||
|
#include "../mwgui/bookwindow.hpp"
|
||||||
|
#include "../mwgui/scrollwindow.hpp"
|
||||||
|
|
||||||
#include "windowmanagerimp.hpp"
|
#include "windowmanagerimp.hpp"
|
||||||
#include "itemselection.hpp"
|
#include "itemselection.hpp"
|
||||||
|
@ -263,20 +268,82 @@ namespace MWGui
|
||||||
|
|
||||||
QuickKeyType type = *button->getUserData<QuickKeyType>();
|
QuickKeyType type = *button->getUserData<QuickKeyType>();
|
||||||
|
|
||||||
|
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer();
|
||||||
|
MWWorld::InventoryStore& store = MWWorld::Class::get(player).getInventoryStore(player);
|
||||||
|
MWMechanics::CreatureStats& stats = MWWorld::Class::get(player).getCreatureStats(player);
|
||||||
|
MWMechanics::Spells& spells = stats.getSpells();
|
||||||
|
|
||||||
if (type == Type_Magic)
|
if (type == Type_Magic)
|
||||||
{
|
{
|
||||||
std::string spellId = button->getChildAt(0)->getUserString("Spell");
|
std::string spellId = button->getChildAt(0)->getUserString("Spell");
|
||||||
MWBase::Environment::get().getWindowManager ()->setSelectedSpell (spellId, 100);
|
spells.setSelectedSpell(spellId);
|
||||||
|
store.setSelectedEnchantItem(store.end());
|
||||||
|
mWindowManager.setSelectedSpell(spellId, int(MWMechanics::getSpellSuccessChance(spellId, player)));
|
||||||
}
|
}
|
||||||
else if (type == Type_Item)
|
else if (type == Type_Item)
|
||||||
{
|
{
|
||||||
MWWorld::Ptr item = *button->getChildAt (0)->getUserData<MWWorld::Ptr>();
|
MWWorld::Ptr item = *button->getChildAt (0)->getUserData<MWWorld::Ptr>();
|
||||||
MWBase::Environment::get().getWindowManager ()->setSelectedWeapon(item, 100);
|
|
||||||
|
// make sure the item is available
|
||||||
|
if (item.getRefData ().getCount() == 0)
|
||||||
|
{
|
||||||
|
MWBase::Environment::get().getWindowManager ()->messageBox (
|
||||||
|
"#{sQuickMenu5} " + MWWorld::Class::get(item).getName(item), std::vector<std::string>());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
boost::shared_ptr<MWWorld::Action> action = MWWorld::Class::get(item).use(item);
|
||||||
|
|
||||||
|
action->execute (MWBase::Environment::get().getWorld()->getPlayer().getPlayer());
|
||||||
|
|
||||||
|
// this is necessary for books/scrolls: if they are already in the player's inventory,
|
||||||
|
// the "Take" button should not be visible.
|
||||||
|
// NOTE: the take button is "reset" when the window opens, so we can safely do the following
|
||||||
|
// without screwing up future book windows
|
||||||
|
mWindowManager.getBookWindow()->setTakeButtonShow(false);
|
||||||
|
mWindowManager.getScrollWindow()->setTakeButtonShow(false);
|
||||||
|
|
||||||
|
// since we changed equipping status, update the inventory window
|
||||||
|
mWindowManager.getInventoryWindow()->drawItems();
|
||||||
}
|
}
|
||||||
else if (type == Type_MagicItem)
|
else if (type == Type_MagicItem)
|
||||||
{
|
{
|
||||||
MWWorld::Ptr item = *button->getChildAt (0)->getUserData<MWWorld::Ptr>();
|
MWWorld::Ptr item = *button->getChildAt (0)->getUserData<MWWorld::Ptr>();
|
||||||
MWBase::Environment::get().getWindowManager ()->setSelectedEnchantItem (item, 100);
|
|
||||||
|
// make sure the item is available
|
||||||
|
if (item.getRefData ().getCount() == 0)
|
||||||
|
{
|
||||||
|
MWBase::Environment::get().getWindowManager ()->messageBox (
|
||||||
|
"#{sQuickMenu5} " + MWWorld::Class::get(item).getName(item), std::vector<std::string>());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// retrieve ContainerStoreIterator to the item
|
||||||
|
MWWorld::ContainerStoreIterator it = store.begin();
|
||||||
|
for (; it != store.end(); ++it)
|
||||||
|
{
|
||||||
|
if (*it == item)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
assert(it != store.end());
|
||||||
|
|
||||||
|
// equip, if it can be equipped
|
||||||
|
if (!MWWorld::Class::get(item).getEquipmentSlots(item).first.empty())
|
||||||
|
{
|
||||||
|
// Note: can't use Class::use here because enchanted scrolls for example would then open the scroll window instead of equipping
|
||||||
|
|
||||||
|
MWWorld::ActionEquip action(item);
|
||||||
|
action.execute (MWBase::Environment::get().getWorld ()->getPlayer ().getPlayer ());
|
||||||
|
|
||||||
|
// since we changed equipping status, update the inventory window
|
||||||
|
mWindowManager.getInventoryWindow()->drawItems();
|
||||||
|
}
|
||||||
|
|
||||||
|
store.setSelectedEnchantItem(it);
|
||||||
|
spells.setSelectedSpell("");
|
||||||
|
mWindowManager.setSelectedEnchantItem(item, 100); /// \todo track charge %
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -339,6 +406,12 @@ namespace MWGui
|
||||||
getWidget(mMagicList, "MagicList");
|
getWidget(mMagicList, "MagicList");
|
||||||
mCancelButton->eventMouseButtonClick += MyGUI::newDelegate(this, &MagicSelectionDialog::onCancelButtonClicked);
|
mCancelButton->eventMouseButtonClick += MyGUI::newDelegate(this, &MagicSelectionDialog::onCancelButtonClicked);
|
||||||
|
|
||||||
|
int dx = (mCancelButton->getTextSize().width + 24) - mCancelButton->getWidth();
|
||||||
|
mCancelButton->setCoord(mCancelButton->getLeft() - dx,
|
||||||
|
mCancelButton->getTop(),
|
||||||
|
mCancelButton->getTextSize ().width + 24,
|
||||||
|
mCancelButton->getHeight());
|
||||||
|
|
||||||
center();
|
center();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
|
|
||||||
#include "../mwworld/player.hpp"
|
#include "../mwworld/player.hpp"
|
||||||
#include "../mwworld/inventorystore.hpp"
|
#include "../mwworld/inventorystore.hpp"
|
||||||
|
#include "../mwworld/actionequip.hpp"
|
||||||
|
|
||||||
#include "../mwmechanics/spells.hpp"
|
#include "../mwmechanics/spells.hpp"
|
||||||
#include "../mwmechanics/creaturestats.hpp"
|
#include "../mwmechanics/creaturestats.hpp"
|
||||||
|
@ -350,34 +351,10 @@ namespace MWGui
|
||||||
if (_sender->getUserString("Equipped") == "false"
|
if (_sender->getUserString("Equipped") == "false"
|
||||||
&& !MWWorld::Class::get(item).getEquipmentSlots(item).first.empty())
|
&& !MWWorld::Class::get(item).getEquipmentSlots(item).first.empty())
|
||||||
{
|
{
|
||||||
// sound
|
|
||||||
MWBase::Environment::get().getSoundManager()->playSound(MWWorld::Class::get(item).getUpSoundId(item), 1.0, 1.0);
|
|
||||||
|
|
||||||
// Note: can't use Class::use here because enchanted scrolls for example would then open the scroll window instead of equipping
|
// Note: can't use Class::use here because enchanted scrolls for example would then open the scroll window instead of equipping
|
||||||
|
|
||||||
/// \todo the following code is pretty much copy&paste from ActionEquip, put it in a function?
|
MWWorld::ActionEquip action(item);
|
||||||
// slots that this item can be equipped in
|
action.execute (MWBase::Environment::get().getWorld ()->getPlayer ().getPlayer ());
|
||||||
std::pair<std::vector<int>, bool> slots = MWWorld::Class::get(item).getEquipmentSlots(item);
|
|
||||||
|
|
||||||
// equip the item in the first free slot
|
|
||||||
for (std::vector<int>::const_iterator slot=slots.first.begin();
|
|
||||||
slot!=slots.first.end(); ++slot)
|
|
||||||
{
|
|
||||||
// if all slots are occupied, replace the last slot
|
|
||||||
if (slot == --slots.first.end())
|
|
||||||
{
|
|
||||||
store.equip(*slot, it);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (store.getSlot(*slot) == store.end())
|
|
||||||
{
|
|
||||||
// slot is not occupied
|
|
||||||
store.equip(*slot, it);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/// \todo scripts?
|
|
||||||
|
|
||||||
// since we changed equipping status, update the inventory window
|
// since we changed equipping status, update the inventory window
|
||||||
mWindowManager.getInventoryWindow()->drawItems();
|
mWindowManager.getInventoryWindow()->drawItems();
|
||||||
|
|
|
@ -8,6 +8,8 @@
|
||||||
#include "../mwworld/class.hpp"
|
#include "../mwworld/class.hpp"
|
||||||
#include "../mwmechanics/creaturestats.hpp"
|
#include "../mwmechanics/creaturestats.hpp"
|
||||||
|
|
||||||
|
#include <components/esm_store/store.hpp>
|
||||||
|
|
||||||
#include "npcstats.hpp"
|
#include "npcstats.hpp"
|
||||||
|
|
||||||
namespace MWMechanics
|
namespace MWMechanics
|
||||||
|
|
|
@ -2,16 +2,16 @@
|
||||||
<MyGUI type="Layout">
|
<MyGUI type="Layout">
|
||||||
<Widget type="Window" skin="MW_Dialog" position="0 0 330 370" layer="Windows" name="_Main">
|
<Widget type="Window" skin="MW_Dialog" position="0 0 330 370" layer="Windows" name="_Main">
|
||||||
|
|
||||||
<Widget type="TextBox" skin="SandText" position="8 8 300 24">
|
<Widget type="TextBox" skin="SandText" position="8 8 292 24">
|
||||||
<Property key="Caption" value="Select a magic to quick key."/>
|
<Property key="Caption" value="Select a magic to quick key."/>
|
||||||
</Widget>
|
</Widget>
|
||||||
|
|
||||||
<Widget type="Widget" skin="MW_Box" position="8 38 314 285" name="box" align="Left Top Stretch">
|
<Widget type="Widget" skin="MW_Box" position="8 38 306 285" name="box" align="Left Top Stretch">
|
||||||
<Widget type="ScrollView" skin="MW_ScrollView" position="4 4 306 277" name="MagicList" align="Left Top Stretch">
|
<Widget type="ScrollView" skin="MW_ScrollView" position="4 4 298 277" name="MagicList" align="Left Top Stretch">
|
||||||
</Widget>
|
</Widget>
|
||||||
</Widget>
|
</Widget>
|
||||||
|
|
||||||
<Widget type="Button" skin="MW_Button" name="CancelButton" position="288 340 32 24" align="Right Bottom">
|
<Widget type="Button" skin="MW_Button" name="CancelButton" position="284 330 32 24" align="Right Bottom">
|
||||||
<Property key="Caption" value="#{sCancel}"/>
|
<Property key="Caption" value="#{sCancel}"/>
|
||||||
</Widget>
|
</Widget>
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue