2012-08-26 10:52:06 +02:00
|
|
|
#include "quickkeysmenu.hpp"
|
|
|
|
|
2015-01-10 02:50:43 +01:00
|
|
|
#include <MyGUI_Button.h>
|
|
|
|
#include <MyGUI_EditBox.h>
|
|
|
|
#include <MyGUI_Gui.h>
|
2015-05-28 02:37:35 +02:00
|
|
|
#include <MyGUI_ImageBox.h>
|
2019-11-09 12:52:38 +04:00
|
|
|
#include <MyGUI_RenderManager.h>
|
2015-01-10 02:50:43 +01:00
|
|
|
|
2022-01-22 15:58:41 +01:00
|
|
|
#include <components/esm3/esmwriter.hpp>
|
2022-09-05 19:35:15 +02:00
|
|
|
#include <components/esm3/loadmgef.hpp>
|
2022-01-22 15:58:41 +01:00
|
|
|
#include <components/esm3/quickkeys.hpp>
|
2022-06-29 00:32:11 +02:00
|
|
|
#include <components/misc/resourcehelpers.hpp>
|
2022-09-05 19:35:15 +02:00
|
|
|
#include <components/resource/resourcesystem.hpp>
|
2014-05-02 12:47:28 +02:00
|
|
|
|
2014-01-18 10:52:16 +01:00
|
|
|
#include "../mwworld/class.hpp"
|
2014-12-19 11:26:54 +01:00
|
|
|
#include "../mwworld/esmstore.hpp"
|
2012-08-26 11:37:33 +02:00
|
|
|
#include "../mwworld/inventorystore.hpp"
|
2014-08-22 21:36:39 -05:00
|
|
|
#include "../mwworld/player.hpp"
|
2014-01-18 10:52:16 +01:00
|
|
|
|
|
|
|
#include "../mwbase/environment.hpp"
|
2017-08-18 19:24:34 +04:00
|
|
|
#include "../mwbase/mechanicsmanager.hpp"
|
2015-07-18 19:40:31 +02:00
|
|
|
#include "../mwbase/windowmanager.hpp"
|
2014-01-18 10:52:16 +01:00
|
|
|
#include "../mwbase/world.hpp"
|
|
|
|
|
2015-08-21 21:12:39 +12:00
|
|
|
#include "../mwmechanics/actorutil.hpp"
|
2014-01-18 10:52:16 +01:00
|
|
|
#include "../mwmechanics/creaturestats.hpp"
|
2020-04-26 20:46:51 +03:00
|
|
|
#include "../mwmechanics/spellutil.hpp"
|
2014-01-18 10:52:16 +01:00
|
|
|
|
2012-08-26 10:52:06 +02:00
|
|
|
#include "itemselection.hpp"
|
2014-06-05 22:13:18 +02:00
|
|
|
#include "itemwidget.hpp"
|
2014-06-10 03:28:21 +02:00
|
|
|
#include "sortfilteritemmodel.hpp"
|
2014-12-15 13:13:25 +01:00
|
|
|
#include "spellview.hpp"
|
2012-08-26 11:37:33 +02:00
|
|
|
|
2012-08-26 10:52:06 +02:00
|
|
|
namespace MWGui
|
|
|
|
{
|
|
|
|
|
2013-04-10 14:46:21 -04:00
|
|
|
QuickKeysMenu::QuickKeysMenu()
|
|
|
|
: WindowBase("openmw_quickkeys_menu.layout")
|
2018-06-29 23:43:51 +10:00
|
|
|
, mKey(std::vector<keyData>(10))
|
2018-06-28 17:02:25 +10:00
|
|
|
, mSelected(nullptr)
|
|
|
|
, mActivated(nullptr)
|
|
|
|
|
2012-08-26 10:52:06 +02:00
|
|
|
{
|
|
|
|
getWidget(mOkButton, "OKButton");
|
|
|
|
getWidget(mInstructionLabel, "InstructionLabel");
|
|
|
|
|
|
|
|
mMainWidget->setSize(mMainWidget->getWidth(),
|
2018-06-28 13:27:08 +10:00
|
|
|
mMainWidget->getHeight() + (mInstructionLabel->getTextSize().height - mInstructionLabel->getHeight()));
|
2012-08-26 10:52:06 +02:00
|
|
|
|
|
|
|
mOkButton->eventMouseButtonClick += MyGUI::newDelegate(this, &QuickKeysMenu::onOkButtonClicked);
|
|
|
|
center();
|
|
|
|
|
|
|
|
for (int i = 0; i < 10; ++i)
|
|
|
|
{
|
2018-06-29 01:58:57 +10:00
|
|
|
mKey[i].index = i + 1;
|
2018-06-28 13:27:08 +10:00
|
|
|
getWidget(mKey[i].button, "QuickKey" + MyGUI::utility::toString(i + 1));
|
|
|
|
mKey[i].button->eventMouseButtonClick += MyGUI::newDelegate(this, &QuickKeysMenu::onQuickKeyButtonClicked);
|
2012-08-26 10:52:06 +02:00
|
|
|
|
2018-06-28 13:27:08 +10:00
|
|
|
unassign(&mKey[i]);
|
2012-08-26 10:52:06 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-05-01 21:16:32 +02:00
|
|
|
void QuickKeysMenu::clear()
|
|
|
|
{
|
2018-06-28 17:02:25 +10:00
|
|
|
mActivated = nullptr;
|
2017-08-18 19:24:34 +04:00
|
|
|
|
2014-05-01 21:16:32 +02:00
|
|
|
for (int i = 0; i < 10; ++i)
|
|
|
|
{
|
2018-06-28 13:27:08 +10:00
|
|
|
unassign(&mKey[i]);
|
2014-05-01 21:16:32 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-11-23 14:55:50 +08:00
|
|
|
inline void QuickKeysMenu::validate(int index)
|
2018-06-13 12:56:58 +04:00
|
|
|
{
|
2021-11-23 14:55:50 +08:00
|
|
|
MWWorld::Ptr player = MWMechanics::getPlayer();
|
2018-06-13 12:56:58 +04:00
|
|
|
MWWorld::InventoryStore& store = player.getClass().getInventoryStore(player);
|
2021-11-24 01:44:14 +08:00
|
|
|
switch (mKey[index].type)
|
|
|
|
{
|
2023-03-21 20:53:04 +01:00
|
|
|
case ESM::QuickKeys::Type::Unassigned:
|
|
|
|
case ESM::QuickKeys::Type::HandToHand:
|
|
|
|
case ESM::QuickKeys::Type::Magic:
|
2021-11-23 04:07:10 +08:00
|
|
|
break;
|
2023-03-21 20:53:04 +01:00
|
|
|
case ESM::QuickKeys::Type::Item:
|
|
|
|
case ESM::QuickKeys::Type::MagicItem:
|
2021-11-23 04:07:10 +08:00
|
|
|
{
|
2021-11-23 14:55:50 +08:00
|
|
|
MWWorld::Ptr item = *mKey[index].button->getUserData<MWWorld::Ptr>();
|
2021-11-23 04:07:10 +08:00
|
|
|
// Make sure the item is available and is not broken
|
2023-01-17 01:21:37 +01:00
|
|
|
if (item.isEmpty() || item.getRefData().getCount() < 1
|
2018-06-13 12:56:58 +04:00
|
|
|
|| (item.getClass().hasItemHealth(item) && item.getClass().getItemHealth(item) <= 0))
|
2021-11-23 04:07:10 +08:00
|
|
|
{
|
|
|
|
// Try searching for a compatible replacement
|
2021-11-23 14:55:50 +08:00
|
|
|
item = store.findReplacement(mKey[index].id);
|
2018-06-29 23:32:05 +10:00
|
|
|
|
2023-01-17 01:21:37 +01:00
|
|
|
if (!item.isEmpty())
|
2021-11-23 14:55:50 +08:00
|
|
|
mKey[index].button->setUserData(MWWorld::Ptr(item));
|
2018-06-13 12:56:58 +04:00
|
|
|
|
2021-11-23 04:07:10 +08:00
|
|
|
break;
|
2018-06-13 12:56:58 +04:00
|
|
|
}
|
|
|
|
}
|
2021-11-24 01:44:14 +08:00
|
|
|
}
|
2018-06-13 12:56:58 +04:00
|
|
|
}
|
|
|
|
|
2021-11-23 04:07:10 +08:00
|
|
|
void QuickKeysMenu::onOpen()
|
|
|
|
{
|
|
|
|
WindowBase::onOpen();
|
|
|
|
|
2021-11-23 14:55:50 +08:00
|
|
|
// Quick key index
|
|
|
|
for (int index = 0; index < 10; ++index)
|
|
|
|
{
|
|
|
|
validate(index);
|
|
|
|
}
|
2021-11-23 04:07:10 +08:00
|
|
|
}
|
|
|
|
|
2022-07-25 01:00:07 +03:00
|
|
|
void QuickKeysMenu::onClose()
|
|
|
|
{
|
|
|
|
WindowBase::onClose();
|
|
|
|
|
|
|
|
if (mAssignDialog)
|
|
|
|
mAssignDialog->setVisible(false);
|
|
|
|
if (mItemSelectionDialog)
|
|
|
|
mItemSelectionDialog->setVisible(false);
|
|
|
|
if (mMagicSelectionDialog)
|
|
|
|
mMagicSelectionDialog->setVisible(false);
|
|
|
|
}
|
|
|
|
|
2018-06-29 23:43:51 +10:00
|
|
|
void QuickKeysMenu::unassign(keyData* key)
|
2012-08-26 10:52:06 +02:00
|
|
|
{
|
2018-06-28 13:27:08 +10:00
|
|
|
key->button->clearUserStrings();
|
|
|
|
key->button->setItem(MWWorld::Ptr());
|
2018-06-25 16:02:28 +10:00
|
|
|
|
2018-06-28 17:02:25 +10:00
|
|
|
while (key->button->getChildCount()) // Destroy number label
|
2018-06-28 13:27:08 +10:00
|
|
|
MyGUI::Gui::getInstance().destroyWidget(key->button->getChildAt(0));
|
2012-08-26 10:52:06 +02:00
|
|
|
|
2018-07-01 13:46:23 +10:00
|
|
|
if (key->index == 10)
|
2015-03-12 02:23:46 +01:00
|
|
|
{
|
2023-03-21 20:53:04 +01:00
|
|
|
key->type = ESM::QuickKeys::Type::HandToHand;
|
2015-03-12 02:23:46 +01:00
|
|
|
|
2018-06-28 13:27:08 +10:00
|
|
|
MyGUI::ImageBox* image = key->button->createWidget<MyGUI::ImageBox>(
|
2015-03-12 02:23:46 +01:00
|
|
|
"ImageBox", MyGUI::IntCoord(14, 13, 32, 32), MyGUI::Align::Default);
|
2018-06-28 13:27:08 +10:00
|
|
|
|
2015-03-12 02:23:46 +01:00
|
|
|
image->setImageTexture("icons\\k\\stealth_handtohand.dds");
|
|
|
|
image->setNeedMouseFocus(false);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2023-03-21 20:53:04 +01:00
|
|
|
key->type = ESM::QuickKeys::Type::Unassigned;
|
2023-02-17 19:20:29 +01:00
|
|
|
key->id = ESM::RefId();
|
2022-05-04 22:33:39 +02:00
|
|
|
key->name.clear();
|
2012-08-27 15:51:01 +02:00
|
|
|
|
2018-06-28 13:27:08 +10:00
|
|
|
MyGUI::TextBox* textBox = key->button->createWidgetReal<MyGUI::TextBox>(
|
|
|
|
"SandText", MyGUI::FloatCoord(0, 0, 1, 1), MyGUI::Align::Default);
|
|
|
|
|
|
|
|
textBox->setTextAlign(MyGUI::Align::Center);
|
2018-06-29 01:58:57 +10:00
|
|
|
textBox->setCaption(MyGUI::utility::toString(key->index));
|
2018-06-28 13:27:08 +10:00
|
|
|
textBox->setNeedMouseFocus(false);
|
2015-03-12 02:23:46 +01:00
|
|
|
}
|
2012-08-26 10:52:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void QuickKeysMenu::onQuickKeyButtonClicked(MyGUI::Widget* sender)
|
|
|
|
{
|
|
|
|
int index = -1;
|
2018-06-28 17:02:25 +10:00
|
|
|
for (int i = 0; i < 10; ++i)
|
2012-08-26 10:52:06 +02:00
|
|
|
{
|
2018-06-28 17:02:25 +10:00
|
|
|
if (sender == mKey[i].button || sender->getParent() == mKey[i].button)
|
2012-08-26 10:52:06 +02:00
|
|
|
{
|
|
|
|
index = i;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
assert(index != -1);
|
2018-08-01 20:17:59 +04:00
|
|
|
if (index < 0)
|
|
|
|
{
|
|
|
|
mSelected = nullptr;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-06-28 17:02:25 +10:00
|
|
|
mSelected = &mKey[index];
|
2012-08-26 10:52:06 +02:00
|
|
|
|
2023-03-21 20:53:04 +01:00
|
|
|
// prevent reallocation of zero key from ESM::QuickKeys::Type::HandToHand
|
2018-07-01 13:46:23 +10:00
|
|
|
if (mSelected->index == 10)
|
|
|
|
return;
|
|
|
|
|
2018-06-13 12:56:58 +04:00
|
|
|
// open assign dialog
|
2018-06-28 17:02:25 +10:00
|
|
|
if (!mAssignDialog)
|
2022-08-31 19:48:23 +02:00
|
|
|
mAssignDialog = std::make_unique<QuickKeysMenuAssign>(this);
|
2018-06-28 13:27:08 +10:00
|
|
|
|
|
|
|
mAssignDialog->setVisible(true);
|
2012-08-26 10:52:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void QuickKeysMenu::onOkButtonClicked(MyGUI::Widget* sender)
|
|
|
|
{
|
2013-04-10 00:32:05 -04:00
|
|
|
MWBase::Environment::get().getWindowManager()->removeGuiMode(GM_QuickKeysMenu);
|
2012-08-26 10:52:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void QuickKeysMenu::onItemButtonClicked(MyGUI::Widget* sender)
|
|
|
|
{
|
2018-06-28 17:02:25 +10:00
|
|
|
if (!mItemSelectionDialog)
|
2012-08-26 10:52:06 +02:00
|
|
|
{
|
2022-08-31 19:48:23 +02:00
|
|
|
mItemSelectionDialog = std::make_unique<ItemSelectionDialog>("#{sQuickMenu6}");
|
2012-08-26 10:52:06 +02:00
|
|
|
mItemSelectionDialog->eventItemSelected += MyGUI::newDelegate(this, &QuickKeysMenu::onAssignItem);
|
|
|
|
mItemSelectionDialog->eventDialogCanceled += MyGUI::newDelegate(this, &QuickKeysMenu::onAssignItemCancel);
|
|
|
|
}
|
|
|
|
mItemSelectionDialog->setVisible(true);
|
2015-08-21 21:12:39 +12:00
|
|
|
mItemSelectionDialog->openContainer(MWMechanics::getPlayer());
|
2014-06-10 03:28:21 +02:00
|
|
|
mItemSelectionDialog->setFilter(SortFilterItemModel::Filter_OnlyUsableItems);
|
2012-08-26 10:52:06 +02:00
|
|
|
|
2018-06-28 17:02:25 +10:00
|
|
|
mAssignDialog->setVisible(false);
|
2012-08-26 10:52:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void QuickKeysMenu::onMagicButtonClicked(MyGUI::Widget* sender)
|
|
|
|
{
|
2018-06-28 17:02:25 +10:00
|
|
|
if (!mMagicSelectionDialog)
|
2012-08-26 10:52:06 +02:00
|
|
|
{
|
2022-08-31 19:48:23 +02:00
|
|
|
mMagicSelectionDialog = std::make_unique<MagicSelectionDialog>(this);
|
2012-08-26 10:52:06 +02:00
|
|
|
}
|
|
|
|
mMagicSelectionDialog->setVisible(true);
|
|
|
|
|
2018-06-28 13:27:08 +10:00
|
|
|
mAssignDialog->setVisible(false);
|
2012-08-26 10:52:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void QuickKeysMenu::onUnassignButtonClicked(MyGUI::Widget* sender)
|
|
|
|
{
|
2018-06-28 17:02:25 +10:00
|
|
|
unassign(mSelected);
|
2018-06-28 13:27:08 +10:00
|
|
|
mAssignDialog->setVisible(false);
|
2012-08-26 10:52:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void QuickKeysMenu::onCancelButtonClicked(MyGUI::Widget* sender)
|
|
|
|
{
|
2018-06-28 13:27:08 +10:00
|
|
|
mAssignDialog->setVisible(false);
|
2012-08-26 10:52:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void QuickKeysMenu::onAssignItem(MWWorld::Ptr item)
|
|
|
|
{
|
2018-06-28 17:02:25 +10:00
|
|
|
assert(mSelected);
|
2014-06-05 22:13:18 +02:00
|
|
|
|
2018-06-28 17:02:25 +10:00
|
|
|
while (mSelected->button->getChildCount()) // Destroy number label
|
|
|
|
MyGUI::Gui::getInstance().destroyWidget(mSelected->button->getChildAt(0));
|
2014-06-05 22:13:18 +02:00
|
|
|
|
2023-03-21 20:53:04 +01:00
|
|
|
mSelected->type = ESM::QuickKeys::Type::Item;
|
2018-06-28 17:02:25 +10:00
|
|
|
mSelected->id = item.getCellRef().getRefId();
|
|
|
|
mSelected->name = item.getClass().getName(item);
|
2012-08-26 10:52:06 +02:00
|
|
|
|
2018-06-28 17:02:25 +10:00
|
|
|
mSelected->button->setItem(item, ItemWidget::Barter);
|
|
|
|
mSelected->button->setUserString("ToolTipType", "ItemPtr");
|
|
|
|
mSelected->button->setUserData(item);
|
2018-06-28 13:27:08 +10:00
|
|
|
|
2018-06-28 17:02:25 +10:00
|
|
|
if (mItemSelectionDialog)
|
2014-05-01 21:16:32 +02:00
|
|
|
mItemSelectionDialog->setVisible(false);
|
2012-08-26 10:52:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void QuickKeysMenu::onAssignItemCancel()
|
|
|
|
{
|
|
|
|
mItemSelectionDialog->setVisible(false);
|
|
|
|
}
|
|
|
|
|
2018-06-28 13:27:08 +10:00
|
|
|
void QuickKeysMenu::onAssignMagicItem(MWWorld::Ptr item)
|
2012-08-26 10:52:06 +02:00
|
|
|
{
|
2018-06-28 17:02:25 +10:00
|
|
|
assert(mSelected);
|
2014-06-05 22:13:18 +02:00
|
|
|
|
2018-06-28 17:02:25 +10:00
|
|
|
while (mSelected->button->getChildCount()) // Destroy number label
|
|
|
|
MyGUI::Gui::getInstance().destroyWidget(mSelected->button->getChildAt(0));
|
2014-06-05 22:13:18 +02:00
|
|
|
|
2023-03-21 20:53:04 +01:00
|
|
|
mSelected->type = ESM::QuickKeys::Type::MagicItem;
|
2018-09-30 21:16:02 +03:00
|
|
|
mSelected->id = item.getCellRef().getRefId();
|
|
|
|
mSelected->name = item.getClass().getName(item);
|
2014-06-05 22:13:18 +02:00
|
|
|
|
2019-11-09 12:52:38 +04:00
|
|
|
float scale = 1.f;
|
|
|
|
MyGUI::ITexture* texture
|
|
|
|
= MyGUI::RenderManager::getInstance().getTexture("textures\\menu_icon_select_magic_magic.dds");
|
|
|
|
if (texture)
|
|
|
|
scale = texture->getHeight() / 64.f;
|
|
|
|
|
|
|
|
mSelected->button->setFrame(
|
|
|
|
"textures\\menu_icon_select_magic_magic.dds", MyGUI::IntCoord(0, 0, 44 * scale, 44 * scale));
|
2018-06-28 17:02:25 +10:00
|
|
|
mSelected->button->setIcon(item);
|
2012-08-27 15:51:01 +02:00
|
|
|
|
2018-06-28 17:02:25 +10:00
|
|
|
mSelected->button->setUserString("ToolTipType", "ItemPtr");
|
|
|
|
mSelected->button->setUserData(MWWorld::Ptr(item));
|
2018-06-28 13:27:08 +10:00
|
|
|
|
2018-06-28 17:02:25 +10:00
|
|
|
if (mMagicSelectionDialog)
|
2014-05-01 21:16:32 +02:00
|
|
|
mMagicSelectionDialog->setVisible(false);
|
2012-08-26 10:52:06 +02:00
|
|
|
}
|
|
|
|
|
Initial commit: In ESM structures, replace the string members that are RefIds to other records, to a new strong type
The strong type is actually just a string underneath, but this will help in the future to have a distinction so it's easier to search and replace when we use an integer ID
Slowly going through all the changes to make, still hundreds of errors
a lot of functions/structures use std::string or stringview to designate an ID. So it takes time
Continues slowly replacing ids. There are technically more and more compilation errors
I have good hope that there is a point where the amount of errors will dramatically go down as all the main functions use the ESM::RefId type
Continue moving forward, changes to the stores
slowly moving along
Starting to see the fruit of those changes.
still many many error, but more and more Irun into a situation where a function is sandwiched between two functions that use the RefId type.
More replacements. Things are starting to get easier
I can see more and more often the issue is that the function is awaiting a RefId, but is given a string
there is less need to go down functions and to fix a long list of them.
Still moving forward, and for the first time error count is going down!
Good pace, not sure about topics though, mId and mName are actually the same thing and are used interchangeably
Cells are back to using string for the name, haven't fixed everything yet. Many other changes
Under the bar of 400 compilation errors.
more good progress <100 compile errors!
More progress
Game settings store can use string for find, it was a bit absurd how every use of it required to create refId from string
some more progress on other fronts
Mostly game settings clean
one error opened a lot of other errors. Down to 18, but more will prbably appear
only link errors left??
Fixed link errors
OpenMW compiles, and launches, with some issues, but still!
2022-09-25 13:17:09 +02:00
|
|
|
void QuickKeysMenu::onAssignMagic(const ESM::RefId& spellId)
|
2012-08-26 10:52:06 +02:00
|
|
|
{
|
2018-06-28 17:02:25 +10:00
|
|
|
assert(mSelected);
|
|
|
|
while (mSelected->button->getChildCount()) // Destroy number label
|
|
|
|
MyGUI::Gui::getInstance().destroyWidget(mSelected->button->getChildAt(0));
|
2012-08-27 15:51:01 +02:00
|
|
|
|
2023-04-20 21:07:53 +02:00
|
|
|
const MWWorld::ESMStore& esmStore = *MWBase::Environment::get().getESMStore();
|
2018-09-30 21:16:02 +03:00
|
|
|
const ESM::Spell* spell = esmStore.get<ESM::Spell>().find(spellId);
|
|
|
|
|
2023-03-21 20:53:04 +01:00
|
|
|
mSelected->type = ESM::QuickKeys::Type::Magic;
|
2018-06-28 17:02:25 +10:00
|
|
|
mSelected->id = spellId;
|
2018-09-30 21:16:02 +03:00
|
|
|
mSelected->name = spell->mName;
|
2012-08-27 15:51:01 +02:00
|
|
|
|
2018-06-28 17:02:25 +10:00
|
|
|
mSelected->button->setItem(MWWorld::Ptr());
|
|
|
|
mSelected->button->setUserString("ToolTipType", "Spell");
|
2023-03-24 01:32:27 +01:00
|
|
|
mSelected->button->setUserString("Spell", spellId.serialize());
|
2012-08-26 11:37:33 +02:00
|
|
|
|
|
|
|
// use the icon of the first effect
|
2018-09-30 21:16:02 +03:00
|
|
|
const ESM::MagicEffect* effect = esmStore.get<ESM::MagicEffect>().find(spell->mEffects.mList.front().mEffectID);
|
2012-11-06 11:29:18 +04:00
|
|
|
|
2012-09-17 11:37:50 +04:00
|
|
|
std::string path = effect->mIcon;
|
2023-02-10 18:34:20 +03:00
|
|
|
std::replace(path.begin(), path.end(), '/', '\\');
|
2014-08-12 12:18:38 +02:00
|
|
|
int slashPos = path.rfind('\\');
|
2012-08-26 11:37:33 +02:00
|
|
|
path.insert(slashPos + 1, "b_");
|
2022-06-29 00:32:11 +02:00
|
|
|
path = Misc::ResourceHelpers::correctIconPath(path, MWBase::Environment::get().getResourceSystem()->getVFS());
|
2012-08-26 11:37:33 +02:00
|
|
|
|
2019-11-09 12:52:38 +04:00
|
|
|
float scale = 1.f;
|
|
|
|
MyGUI::ITexture* texture
|
|
|
|
= MyGUI::RenderManager::getInstance().getTexture("textures\\menu_icon_select_magic.dds");
|
|
|
|
if (texture)
|
|
|
|
scale = texture->getHeight() / 64.f;
|
|
|
|
|
|
|
|
mSelected->button->setFrame(
|
|
|
|
"textures\\menu_icon_select_magic.dds", MyGUI::IntCoord(0, 0, 44 * scale, 44 * scale));
|
2018-06-28 17:02:25 +10:00
|
|
|
mSelected->button->setIcon(path);
|
2012-08-26 10:52:06 +02:00
|
|
|
|
2014-05-01 21:16:32 +02:00
|
|
|
if (mMagicSelectionDialog)
|
|
|
|
mMagicSelectionDialog->setVisible(false);
|
2012-08-26 10:52:06 +02:00
|
|
|
}
|
|
|
|
|
2018-06-28 17:02:25 +10:00
|
|
|
void QuickKeysMenu::onAssignMagicCancel()
|
2012-08-26 10:52:06 +02:00
|
|
|
{
|
|
|
|
mMagicSelectionDialog->setVisible(false);
|
|
|
|
}
|
|
|
|
|
2017-08-18 19:24:34 +04:00
|
|
|
void QuickKeysMenu::updateActivatedQuickKey()
|
|
|
|
{
|
|
|
|
// there is no delayed action, nothing to do.
|
2018-06-28 17:02:25 +10:00
|
|
|
if (!mActivated)
|
2017-08-18 19:24:34 +04:00
|
|
|
return;
|
|
|
|
|
2018-06-28 17:02:25 +10:00
|
|
|
activateQuickKey(mActivated->index);
|
2017-08-18 19:24:34 +04:00
|
|
|
}
|
|
|
|
|
2012-08-27 15:51:01 +02:00
|
|
|
void QuickKeysMenu::activateQuickKey(int index)
|
|
|
|
{
|
2018-07-01 13:46:23 +10:00
|
|
|
assert(index >= 1 && index <= 10);
|
2018-06-28 22:55:02 +10:00
|
|
|
|
2018-06-29 23:43:51 +10:00
|
|
|
keyData* key = &mKey[index - 1];
|
2022-09-22 21:26:05 +03:00
|
|
|
|
2015-08-21 21:12:39 +12:00
|
|
|
MWWorld::Ptr player = MWMechanics::getPlayer();
|
2014-05-22 20:37:22 +02:00
|
|
|
MWWorld::InventoryStore& store = player.getClass().getInventoryStore(player);
|
2017-08-18 19:24:34 +04:00
|
|
|
const MWMechanics::CreatureStats& playerStats = player.getClass().getCreatureStats(player);
|
|
|
|
|
2021-11-23 14:55:50 +08:00
|
|
|
validate(index - 1);
|
2021-11-23 04:07:10 +08:00
|
|
|
|
2017-08-18 19:24:34 +04:00
|
|
|
// Delay action executing,
|
|
|
|
// if player is busy for now (casting a spell, attacking someone, etc.)
|
|
|
|
bool isDelayNeeded = MWBase::Environment::get().getMechanicsManager()->isAttackingOrSpell(player)
|
|
|
|
|| playerStats.getKnockedDown() || playerStats.getHitRecovery();
|
|
|
|
|
2020-10-09 20:34:36 +03:00
|
|
|
bool godmode = MWBase::Environment::get().getWorld()->getGodModeState();
|
|
|
|
bool isReturnNeeded = (!godmode && playerStats.isParalyzed()) || playerStats.isDead();
|
2018-06-28 17:02:25 +10:00
|
|
|
|
2022-07-29 11:28:56 +03:00
|
|
|
if (isReturnNeeded)
|
2018-07-29 12:43:24 +03:00
|
|
|
{
|
2017-08-18 19:24:34 +04:00
|
|
|
return;
|
2018-07-29 12:43:24 +03:00
|
|
|
}
|
2022-07-29 11:28:56 +03:00
|
|
|
else if (isDelayNeeded)
|
2018-07-29 12:43:24 +03:00
|
|
|
{
|
2018-06-28 17:02:25 +10:00
|
|
|
mActivated = key;
|
2018-07-29 12:43:24 +03:00
|
|
|
return;
|
|
|
|
}
|
2017-08-18 19:24:34 +04:00
|
|
|
else
|
2018-07-29 12:43:24 +03:00
|
|
|
{
|
2018-06-28 17:02:25 +10:00
|
|
|
mActivated = nullptr;
|
2018-07-29 12:43:24 +03:00
|
|
|
}
|
2013-12-27 00:51:29 +01:00
|
|
|
|
2023-03-21 20:53:04 +01:00
|
|
|
if (key->type == ESM::QuickKeys::Type::Item || key->type == ESM::QuickKeys::Type::MagicItem)
|
2013-12-27 00:51:29 +01:00
|
|
|
{
|
2018-06-28 17:02:25 +10:00
|
|
|
MWWorld::Ptr item = *key->button->getUserData<MWWorld::Ptr>();
|
2018-06-25 16:02:28 +10:00
|
|
|
|
|
|
|
MWWorld::ContainerStoreIterator it = store.begin();
|
|
|
|
for (; it != store.end(); ++it)
|
|
|
|
{
|
|
|
|
if (*it == item)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (it == store.end())
|
2018-06-28 13:27:08 +10:00
|
|
|
item = nullptr;
|
2018-06-23 17:51:32 +10:00
|
|
|
|
|
|
|
// check the item is available and not broken
|
2023-01-17 01:21:37 +01:00
|
|
|
if (item.isEmpty() || item.getRefData().getCount() < 1
|
2018-06-28 17:02:25 +10:00
|
|
|
|| (item.getClass().hasItemHealth(item) && item.getClass().getItemHealth(item) <= 0))
|
2018-06-23 17:51:32 +10:00
|
|
|
{
|
2018-06-28 17:02:25 +10:00
|
|
|
item = store.findReplacement(key->id);
|
|
|
|
|
2023-01-17 01:21:37 +01:00
|
|
|
if (item.isEmpty() || item.getRefData().getCount() < 1)
|
2018-06-23 17:51:32 +10:00
|
|
|
{
|
|
|
|
MWBase::Environment::get().getWindowManager()->messageBox("#{sQuickMenu5} " + key->name);
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-03-21 20:53:04 +01:00
|
|
|
if (key->type == ESM::QuickKeys::Type::Item)
|
2013-12-27 00:51:29 +01:00
|
|
|
{
|
2020-04-11 14:42:04 +03:00
|
|
|
if (!store.isEquipped(item))
|
|
|
|
MWBase::Environment::get().getWindowManager()->useItem(item);
|
2018-06-23 17:51:32 +10:00
|
|
|
MWWorld::ConstContainerStoreIterator rightHand
|
|
|
|
= store.getSlot(MWWorld::InventoryStore::Slot_CarriedRight);
|
|
|
|
// change draw state only if the item is in player's right hand
|
|
|
|
if (rightHand != store.end() && item == *rightHand)
|
|
|
|
{
|
2022-07-17 19:36:48 +03:00
|
|
|
MWBase::Environment::get().getWorld()->getPlayer().setDrawState(MWMechanics::DrawState::Weapon);
|
2018-06-23 17:51:32 +10:00
|
|
|
}
|
2013-12-27 00:51:29 +01:00
|
|
|
}
|
2023-03-21 20:53:04 +01:00
|
|
|
else if (key->type == ESM::QuickKeys::Type::MagicItem)
|
2018-06-23 17:51:32 +10:00
|
|
|
{
|
2020-04-11 14:42:04 +03:00
|
|
|
// equip, if it can be equipped and isn't yet equipped
|
|
|
|
if (!item.getClass().getEquipmentSlots(item).first.empty() && !store.isEquipped(item))
|
2018-06-23 17:51:32 +10:00
|
|
|
{
|
|
|
|
MWBase::Environment::get().getWindowManager()->useItem(item);
|
|
|
|
|
|
|
|
// make sure that item was successfully equipped
|
|
|
|
if (!store.isEquipped(item))
|
|
|
|
return;
|
|
|
|
}
|
2012-08-27 20:44:14 +02:00
|
|
|
|
2018-06-23 17:51:32 +10:00
|
|
|
store.setSelectedEnchantItem(it);
|
2022-07-17 19:36:48 +03:00
|
|
|
MWBase::Environment::get().getWorld()->getPlayer().setDrawState(MWMechanics::DrawState::Spell);
|
2018-06-23 17:51:32 +10:00
|
|
|
}
|
|
|
|
}
|
2023-03-21 20:53:04 +01:00
|
|
|
else if (key->type == ESM::QuickKeys::Type::Magic)
|
2012-08-27 15:51:01 +02:00
|
|
|
{
|
Initial commit: In ESM structures, replace the string members that are RefIds to other records, to a new strong type
The strong type is actually just a string underneath, but this will help in the future to have a distinction so it's easier to search and replace when we use an integer ID
Slowly going through all the changes to make, still hundreds of errors
a lot of functions/structures use std::string or stringview to designate an ID. So it takes time
Continues slowly replacing ids. There are technically more and more compilation errors
I have good hope that there is a point where the amount of errors will dramatically go down as all the main functions use the ESM::RefId type
Continue moving forward, changes to the stores
slowly moving along
Starting to see the fruit of those changes.
still many many error, but more and more Irun into a situation where a function is sandwiched between two functions that use the RefId type.
More replacements. Things are starting to get easier
I can see more and more often the issue is that the function is awaiting a RefId, but is given a string
there is less need to go down functions and to fix a long list of them.
Still moving forward, and for the first time error count is going down!
Good pace, not sure about topics though, mId and mName are actually the same thing and are used interchangeably
Cells are back to using string for the name, haven't fixed everything yet. Many other changes
Under the bar of 400 compilation errors.
more good progress <100 compile errors!
More progress
Game settings store can use string for find, it was a bit absurd how every use of it required to create refId from string
some more progress on other fronts
Mostly game settings clean
one error opened a lot of other errors. Down to 18, but more will prbably appear
only link errors left??
Fixed link errors
OpenMW compiles, and launches, with some issues, but still!
2022-09-25 13:17:09 +02:00
|
|
|
const ESM::RefId& spellId = key->id;
|
2014-01-17 13:13:58 +01:00
|
|
|
|
|
|
|
// Make sure the player still has this spell
|
|
|
|
MWMechanics::CreatureStats& stats = player.getClass().getCreatureStats(player);
|
|
|
|
MWMechanics::Spells& spells = stats.getSpells();
|
2018-06-28 17:02:25 +10:00
|
|
|
|
2014-01-17 13:13:58 +01:00
|
|
|
if (!spells.hasSpell(spellId))
|
2018-04-18 18:25:53 +03:00
|
|
|
{
|
2018-09-30 21:16:02 +03:00
|
|
|
MWBase::Environment::get().getWindowManager()->messageBox("#{sQuickMenu5} " + key->name);
|
2014-01-17 13:13:58 +01:00
|
|
|
return;
|
2018-04-18 18:25:53 +03:00
|
|
|
}
|
2018-06-28 17:02:25 +10:00
|
|
|
|
2012-08-27 20:44:14 +02:00
|
|
|
store.setSelectedEnchantItem(store.end());
|
2018-06-28 17:02:25 +10:00
|
|
|
MWBase::Environment::get().getWindowManager()->setSelectedSpell(
|
|
|
|
spellId, int(MWMechanics::getSpellSuccessChance(spellId, player)));
|
2022-07-17 19:36:48 +03:00
|
|
|
MWBase::Environment::get().getWorld()->getPlayer().setDrawState(MWMechanics::DrawState::Spell);
|
2012-08-27 15:51:01 +02:00
|
|
|
}
|
2023-03-21 20:53:04 +01:00
|
|
|
else if (key->type == ESM::QuickKeys::Type::HandToHand)
|
2015-03-12 02:23:46 +01:00
|
|
|
{
|
2023-01-16 23:51:04 +01:00
|
|
|
store.unequipSlot(MWWorld::InventoryStore::Slot_CarriedRight);
|
2022-07-17 19:36:48 +03:00
|
|
|
MWBase::Environment::get().getWorld()->getPlayer().setDrawState(MWMechanics::DrawState::Weapon);
|
2015-03-12 02:23:46 +01:00
|
|
|
}
|
2012-08-27 15:51:01 +02:00
|
|
|
}
|
|
|
|
|
2012-08-26 10:52:06 +02:00
|
|
|
// ---------------------------------------------------------------------------------------------------------
|
|
|
|
|
2013-04-10 14:46:21 -04:00
|
|
|
QuickKeysMenuAssign::QuickKeysMenuAssign(QuickKeysMenu* parent)
|
|
|
|
: WindowModal("openmw_quickkeys_menu_assign.layout")
|
2012-08-26 10:52:06 +02:00
|
|
|
, mParent(parent)
|
|
|
|
{
|
|
|
|
getWidget(mLabel, "Label");
|
|
|
|
getWidget(mItemButton, "ItemButton");
|
|
|
|
getWidget(mMagicButton, "MagicButton");
|
|
|
|
getWidget(mUnassignButton, "UnassignButton");
|
|
|
|
getWidget(mCancelButton, "CancelButton");
|
|
|
|
|
|
|
|
mItemButton->eventMouseButtonClick += MyGUI::newDelegate(mParent, &QuickKeysMenu::onItemButtonClicked);
|
|
|
|
mMagicButton->eventMouseButtonClick += MyGUI::newDelegate(mParent, &QuickKeysMenu::onMagicButtonClicked);
|
|
|
|
mUnassignButton->eventMouseButtonClick += MyGUI::newDelegate(mParent, &QuickKeysMenu::onUnassignButtonClicked);
|
|
|
|
mCancelButton->eventMouseButtonClick += MyGUI::newDelegate(mParent, &QuickKeysMenu::onCancelButtonClicked);
|
|
|
|
|
2017-07-16 13:11:34 +04:00
|
|
|
int maxWidth = mLabel->getTextSize().width + 24;
|
|
|
|
maxWidth = std::max(maxWidth, mItemButton->getTextSize().width + 24);
|
2012-08-26 10:52:06 +02:00
|
|
|
maxWidth = std::max(maxWidth, mMagicButton->getTextSize().width + 24);
|
|
|
|
maxWidth = std::max(maxWidth, mUnassignButton->getTextSize().width + 24);
|
|
|
|
maxWidth = std::max(maxWidth, mCancelButton->getTextSize().width + 24);
|
|
|
|
|
|
|
|
mMainWidget->setSize(maxWidth + 24, mMainWidget->getHeight());
|
|
|
|
mLabel->setSize(maxWidth, mLabel->getHeight());
|
|
|
|
|
|
|
|
mItemButton->setCoord((maxWidth - mItemButton->getTextSize().width - 24) / 2 + 8, mItemButton->getTop(),
|
|
|
|
mItemButton->getTextSize().width + 24, mItemButton->getHeight());
|
|
|
|
mMagicButton->setCoord((maxWidth - mMagicButton->getTextSize().width - 24) / 2 + 8, mMagicButton->getTop(),
|
|
|
|
mMagicButton->getTextSize().width + 24, mMagicButton->getHeight());
|
|
|
|
mUnassignButton->setCoord((maxWidth - mUnassignButton->getTextSize().width - 24) / 2 + 8,
|
|
|
|
mUnassignButton->getTop(), mUnassignButton->getTextSize().width + 24, mUnassignButton->getHeight());
|
|
|
|
mCancelButton->setCoord((maxWidth - mCancelButton->getTextSize().width - 24) / 2 + 8, mCancelButton->getTop(),
|
|
|
|
mCancelButton->getTextSize().width + 24, mCancelButton->getHeight());
|
|
|
|
|
|
|
|
center();
|
|
|
|
}
|
|
|
|
|
2014-05-01 21:16:32 +02:00
|
|
|
void QuickKeysMenu::write(ESM::ESMWriter& writer)
|
|
|
|
{
|
|
|
|
writer.startRecord(ESM::REC_KEYS);
|
|
|
|
|
2014-05-02 12:47:28 +02:00
|
|
|
ESM::QuickKeys keys;
|
|
|
|
|
2019-11-20 19:57:21 +03:00
|
|
|
// NB: The quick key with index 9 always has Hand-to-Hand type and must not be saved
|
|
|
|
for (int i = 0; i < 9; ++i)
|
2014-05-01 21:16:32 +02:00
|
|
|
{
|
2018-06-28 13:27:08 +10:00
|
|
|
ItemWidget* button = mKey[i].button;
|
2014-05-01 21:16:32 +02:00
|
|
|
|
2023-03-21 20:53:04 +01:00
|
|
|
const ESM::QuickKeys::Type type = mKey[i].type;
|
2014-05-02 12:47:28 +02:00
|
|
|
|
|
|
|
ESM::QuickKeys::QuickKey key;
|
|
|
|
key.mType = type;
|
2014-05-01 21:16:32 +02:00
|
|
|
|
|
|
|
switch (type)
|
|
|
|
{
|
2023-03-21 20:53:04 +01:00
|
|
|
case ESM::QuickKeys::Type::Unassigned:
|
|
|
|
case ESM::QuickKeys::Type::HandToHand:
|
2014-05-01 21:16:32 +02:00
|
|
|
break;
|
2023-03-21 20:53:04 +01:00
|
|
|
case ESM::QuickKeys::Type::Item:
|
|
|
|
case ESM::QuickKeys::Type::MagicItem:
|
2014-05-01 21:16:32 +02:00
|
|
|
{
|
2014-06-05 22:13:18 +02:00
|
|
|
MWWorld::Ptr item = *button->getUserData<MWWorld::Ptr>();
|
2014-05-25 14:13:07 +02:00
|
|
|
key.mId = item.getCellRef().getRefId();
|
2014-05-01 21:16:32 +02:00
|
|
|
break;
|
|
|
|
}
|
2023-03-21 20:53:04 +01:00
|
|
|
case ESM::QuickKeys::Type::Magic:
|
2023-03-24 01:32:27 +01:00
|
|
|
key.mId = ESM::RefId::deserialize(button->getUserString("Spell"));
|
2014-05-01 21:16:32 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2014-05-02 12:47:28 +02:00
|
|
|
keys.mKeys.push_back(key);
|
2014-05-01 21:16:32 +02:00
|
|
|
}
|
|
|
|
|
2014-05-02 12:47:28 +02:00
|
|
|
keys.save(writer);
|
|
|
|
|
2014-05-01 21:16:32 +02:00
|
|
|
writer.endRecord(ESM::REC_KEYS);
|
|
|
|
}
|
|
|
|
|
2015-01-22 19:04:59 +01:00
|
|
|
void QuickKeysMenu::readRecord(ESM::ESMReader& reader, uint32_t type)
|
2014-05-01 21:16:32 +02:00
|
|
|
{
|
2018-06-28 17:02:25 +10:00
|
|
|
if (type != ESM::REC_KEYS)
|
2014-05-01 21:16:32 +02:00
|
|
|
return;
|
|
|
|
|
2014-05-02 12:47:28 +02:00
|
|
|
ESM::QuickKeys keys;
|
|
|
|
keys.load(reader);
|
|
|
|
|
2018-06-13 12:56:58 +04:00
|
|
|
MWWorld::Ptr player = MWMechanics::getPlayer();
|
|
|
|
MWWorld::InventoryStore& store = player.getClass().getInventoryStore(player);
|
|
|
|
|
2014-05-01 21:16:32 +02:00
|
|
|
int i = 0;
|
2019-03-02 13:27:59 +04:00
|
|
|
for (ESM::QuickKeys::QuickKey& quickKey : keys.mKeys)
|
2014-05-01 21:16:32 +02:00
|
|
|
{
|
2019-11-20 19:57:21 +03:00
|
|
|
// NB: The quick key with index 9 always has Hand-to-Hand type and must not be loaded
|
|
|
|
if (i >= 9)
|
2014-05-02 12:47:28 +02:00
|
|
|
return;
|
2014-05-01 21:16:32 +02:00
|
|
|
|
2018-06-28 17:02:25 +10:00
|
|
|
mSelected = &mKey[i];
|
2014-05-01 21:16:32 +02:00
|
|
|
|
2019-03-02 13:27:59 +04:00
|
|
|
switch (quickKey.mType)
|
2014-05-01 21:16:32 +02:00
|
|
|
{
|
2023-03-21 20:53:04 +01:00
|
|
|
case ESM::QuickKeys::Type::Magic:
|
2023-04-20 21:07:53 +02:00
|
|
|
if (MWBase::Environment::get().getESMStore()->get<ESM::Spell>().search(quickKey.mId))
|
2019-03-02 13:27:59 +04:00
|
|
|
onAssignMagic(quickKey.mId);
|
2014-05-01 21:16:32 +02:00
|
|
|
break;
|
2023-03-21 20:53:04 +01:00
|
|
|
case ESM::QuickKeys::Type::Item:
|
|
|
|
case ESM::QuickKeys::Type::MagicItem:
|
2014-05-01 21:16:32 +02:00
|
|
|
{
|
|
|
|
// Find the item by id
|
2019-03-02 13:27:59 +04:00
|
|
|
MWWorld::Ptr item = store.findReplacement(quickKey.mId);
|
2022-09-22 21:26:05 +03:00
|
|
|
|
2018-06-28 17:02:25 +10:00
|
|
|
if (item.isEmpty())
|
2018-09-30 21:16:02 +03:00
|
|
|
unassign(mSelected);
|
2022-09-22 21:26:05 +03:00
|
|
|
else
|
|
|
|
{
|
2023-03-21 20:53:04 +01:00
|
|
|
if (quickKey.mType == ESM::QuickKeys::Type::Item)
|
2014-05-01 21:16:32 +02:00
|
|
|
onAssignItem(item);
|
2023-03-21 20:53:04 +01:00
|
|
|
else // if (quickKey.mType == ESM::QuickKeys::Type::MagicItem)
|
2014-05-01 21:16:32 +02:00
|
|
|
onAssignMagicItem(item);
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
2023-03-21 20:53:04 +01:00
|
|
|
case ESM::QuickKeys::Type::Unassigned:
|
|
|
|
case ESM::QuickKeys::Type::HandToHand:
|
2018-09-30 21:16:02 +03:00
|
|
|
unassign(mSelected);
|
2014-05-01 21:16:32 +02:00
|
|
|
break;
|
|
|
|
}
|
2014-05-02 12:47:28 +02:00
|
|
|
|
2014-05-01 21:16:32 +02:00
|
|
|
++i;
|
|
|
|
}
|
|
|
|
}
|
2012-08-26 10:52:06 +02:00
|
|
|
|
|
|
|
// ---------------------------------------------------------------------------------------------------------
|
|
|
|
|
2013-04-10 14:46:21 -04:00
|
|
|
MagicSelectionDialog::MagicSelectionDialog(QuickKeysMenu* parent)
|
|
|
|
: WindowModal("openmw_magicselection_dialog.layout")
|
2012-08-26 10:52:06 +02:00
|
|
|
, mParent(parent)
|
|
|
|
{
|
|
|
|
getWidget(mCancelButton, "CancelButton");
|
2012-08-26 11:37:33 +02:00
|
|
|
getWidget(mMagicList, "MagicList");
|
2012-08-26 10:52:06 +02:00
|
|
|
mCancelButton->eventMouseButtonClick += MyGUI::newDelegate(this, &MagicSelectionDialog::onCancelButtonClicked);
|
|
|
|
|
2014-12-15 13:13:25 +01:00
|
|
|
mMagicList->setShowCostColumn(false);
|
|
|
|
mMagicList->setHighlightSelected(false);
|
|
|
|
mMagicList->eventSpellClicked += MyGUI::newDelegate(this, &MagicSelectionDialog::onModelIndexSelected);
|
|
|
|
|
2012-08-26 10:52:06 +02:00
|
|
|
center();
|
|
|
|
}
|
|
|
|
|
|
|
|
void MagicSelectionDialog::onCancelButtonClicked(MyGUI::Widget* sender)
|
|
|
|
{
|
2014-05-27 13:50:24 -04:00
|
|
|
exit();
|
|
|
|
}
|
|
|
|
|
2017-09-23 12:18:39 +02:00
|
|
|
bool MagicSelectionDialog::exit()
|
2014-05-27 13:50:24 -04:00
|
|
|
{
|
|
|
|
mParent->onAssignMagicCancel();
|
2017-09-23 12:18:39 +02:00
|
|
|
return true;
|
2012-08-26 10:52:06 +02:00
|
|
|
}
|
|
|
|
|
2017-09-22 17:10:53 +02:00
|
|
|
void MagicSelectionDialog::onOpen()
|
2012-08-26 11:37:33 +02:00
|
|
|
{
|
2017-09-22 17:10:53 +02:00
|
|
|
WindowModal::onOpen();
|
2012-08-26 11:37:33 +02:00
|
|
|
|
2015-08-21 21:12:39 +12:00
|
|
|
mMagicList->setModel(new SpellModel(MWMechanics::getPlayer()));
|
2015-06-04 23:09:40 +03:00
|
|
|
mMagicList->resetScrollbars();
|
2012-08-26 11:37:33 +02:00
|
|
|
}
|
|
|
|
|
2014-12-15 13:13:25 +01:00
|
|
|
void MagicSelectionDialog::onModelIndexSelected(SpellModel::ModelIndex index)
|
2012-08-26 11:37:33 +02:00
|
|
|
{
|
2014-12-15 13:13:25 +01:00
|
|
|
const Spell& spell = mMagicList->getModel()->getItem(index);
|
|
|
|
if (spell.mType == Spell::Type_EnchantedItem)
|
|
|
|
mParent->onAssignMagicItem(spell.mItem);
|
2012-08-26 11:37:33 +02:00
|
|
|
else
|
2014-12-15 13:13:25 +01:00
|
|
|
mParent->onAssignMagic(spell.mId);
|
2012-08-26 11:37:33 +02:00
|
|
|
}
|
|
|
|
|
2012-08-26 10:52:06 +02:00
|
|
|
}
|