mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-03-03 03:49:41 +00:00
Refactor item icon code into ItemWidget (Fixes #1391)
- Removed duplicate code - Fixed missing magic backgrounds during item drag&drop - Change background texture used for HUD icons
This commit is contained in:
parent
f53e86cad9
commit
6db936bb3a
26 changed files with 408 additions and 341 deletions
|
@ -33,7 +33,7 @@ add_openmw_dir (mwgui
|
|||
merchantrepair repair soulgemdialog companionwindow bookpage journalviewmodel journalbooks
|
||||
keywordsearch itemmodel containeritemmodel inventoryitemmodel sortfilteritemmodel itemview
|
||||
tradeitemmodel companionitemmodel pickpocketitemmodel fontloader controllers savegamedialog
|
||||
recharge mode videowidget backgroundimage
|
||||
recharge mode videowidget backgroundimage itemwidget
|
||||
)
|
||||
|
||||
add_openmw_dir (mwdialogue
|
||||
|
|
|
@ -13,20 +13,7 @@
|
|||
#include "inventoryitemmodel.hpp"
|
||||
#include "sortfilteritemmodel.hpp"
|
||||
#include "itemview.hpp"
|
||||
|
||||
namespace
|
||||
{
|
||||
std::string getIconPath(MWWorld::Ptr ptr)
|
||||
{
|
||||
std::string path = std::string("icons\\");
|
||||
path += ptr.getClass().getInventoryIcon(ptr);
|
||||
int pos = path.rfind(".");
|
||||
path.erase(pos);
|
||||
path.append(".dds");
|
||||
return path;
|
||||
}
|
||||
|
||||
}
|
||||
#include "itemwidget.hpp"
|
||||
|
||||
namespace MWGui
|
||||
{
|
||||
|
@ -149,7 +136,7 @@ namespace MWGui
|
|||
{
|
||||
mApparatus.at (index)->setUserString ("ToolTipType", "ItemPtr");
|
||||
mApparatus.at (index)->setUserData (*iter);
|
||||
mApparatus.at (index)->setImageTexture (getIconPath (*iter));
|
||||
mApparatus.at (index)->setItem(*iter);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -189,7 +176,7 @@ namespace MWGui
|
|||
MWMechanics::Alchemy::TIngredientsIterator it = mAlchemy.beginIngredients ();
|
||||
for (int i=0; i<4; ++i)
|
||||
{
|
||||
MyGUI::ImageBox* ingredient = mIngredients[i];
|
||||
ItemWidget* ingredient = mIngredients[i];
|
||||
|
||||
MWWorld::Ptr item;
|
||||
if (it != mAlchemy.endIngredients ())
|
||||
|
@ -204,15 +191,15 @@ namespace MWGui
|
|||
if (ingredient->getChildCount())
|
||||
MyGUI::Gui::getInstance().destroyWidget(ingredient->getChildAt(0));
|
||||
|
||||
ingredient->setImageTexture("");
|
||||
ingredient->clearUserStrings ();
|
||||
|
||||
ingredient->setItem(item);
|
||||
|
||||
if (item.isEmpty ())
|
||||
continue;
|
||||
|
||||
ingredient->setUserString("ToolTipType", "ItemPtr");
|
||||
ingredient->setUserData(item);
|
||||
ingredient->setImageTexture(getIconPath(item));
|
||||
|
||||
MyGUI::TextBox* text = ingredient->createWidget<MyGUI::TextBox>("SandBrightText", MyGUI::IntCoord(0, 14, 32, 18), MyGUI::Align::Default, std::string("Label"));
|
||||
text->setTextAlign(MyGUI::Align::Right);
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
namespace MWGui
|
||||
{
|
||||
class ItemView;
|
||||
class ItemWidget;
|
||||
class SortFilterItemModel;
|
||||
|
||||
class AlchemyWindow : public WindowBase
|
||||
|
@ -44,8 +45,8 @@ namespace MWGui
|
|||
|
||||
MWMechanics::Alchemy mAlchemy;
|
||||
|
||||
std::vector<MyGUI::ImageBox *> mApparatus;
|
||||
std::vector<MyGUI::ImageBox *> mIngredients;
|
||||
std::vector<ItemWidget*> mApparatus;
|
||||
std::vector<ItemWidget*> mIngredients;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include "inventorywindow.hpp"
|
||||
|
||||
#include "itemview.hpp"
|
||||
#include "itemwidget.hpp"
|
||||
#include "inventoryitemmodel.hpp"
|
||||
#include "sortfilteritemmodel.hpp"
|
||||
#include "pickpocketitemmodel.hpp"
|
||||
|
@ -46,22 +47,15 @@ namespace MWGui
|
|||
mSourceSortModel->addDragItem(mItem.mBase, count);
|
||||
}
|
||||
|
||||
std::string path = std::string("icons\\");
|
||||
path += mItem.mBase.getClass().getInventoryIcon(mItem.mBase);
|
||||
MyGUI::ImageBox* baseWidget = mDragAndDropWidget->createWidget<MyGUI::ImageBox>
|
||||
("ImageBox", MyGUI::IntCoord(0, 0, 42, 42), MyGUI::Align::Default);
|
||||
ItemWidget* baseWidget = mDragAndDropWidget->createWidget<ItemWidget>
|
||||
("MW_ItemIcon", MyGUI::IntCoord(0, 0, 42, 42), MyGUI::Align::Default);
|
||||
mDraggedWidget = baseWidget;
|
||||
MyGUI::ImageBox* image = baseWidget->createWidget<MyGUI::ImageBox>("ImageBox",
|
||||
MyGUI::IntCoord(5, 5, 32, 32), MyGUI::Align::Default);
|
||||
size_t pos = path.rfind(".");
|
||||
if (pos != std::string::npos)
|
||||
path.erase(pos);
|
||||
path.append(".dds");
|
||||
image->setImageTexture(path);
|
||||
image->setNeedMouseFocus(false);
|
||||
baseWidget->setItem(mItem.mBase);
|
||||
baseWidget->setNeedMouseFocus(false);
|
||||
|
||||
// text widget that shows item count
|
||||
MyGUI::TextBox* text = image->createWidget<MyGUI::TextBox>("SandBrightText",
|
||||
// TODO: move to ItemWidget
|
||||
MyGUI::TextBox* text = baseWidget->createWidget<MyGUI::TextBox>("SandBrightText",
|
||||
MyGUI::IntCoord(0, 14, 32, 18), MyGUI::Align::Default, std::string("Label"));
|
||||
text->setTextAlign(MyGUI::Align::Right);
|
||||
text->setNeedMouseFocus(false);
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
|
||||
#include "itemselection.hpp"
|
||||
#include "container.hpp"
|
||||
#include "itemwidget.hpp"
|
||||
|
||||
#include "sortfilteritemmodel.hpp"
|
||||
|
||||
|
@ -57,8 +58,45 @@ namespace MWGui
|
|||
void EnchantingDialog::open()
|
||||
{
|
||||
center();
|
||||
onRemoveItem(NULL);
|
||||
onRemoveSoul(NULL);
|
||||
|
||||
setSoulGem(MWWorld::Ptr());
|
||||
setItem(MWWorld::Ptr());
|
||||
}
|
||||
|
||||
void EnchantingDialog::setSoulGem(const MWWorld::Ptr &gem)
|
||||
{
|
||||
if (gem.isEmpty())
|
||||
{
|
||||
mSoulBox->setItem(MWWorld::Ptr());
|
||||
mSoulBox->clearUserStrings();
|
||||
mEnchanting.setSoulGem(MWWorld::Ptr());
|
||||
}
|
||||
else
|
||||
{
|
||||
mSoulBox->setItem(gem);
|
||||
mSoulBox->setUserString ("ToolTipType", "ItemPtr");
|
||||
mSoulBox->setUserData(gem);
|
||||
mEnchanting.setSoulGem(gem);
|
||||
}
|
||||
updateLabels();
|
||||
}
|
||||
|
||||
void EnchantingDialog::setItem(const MWWorld::Ptr &item)
|
||||
{
|
||||
if (item.isEmpty())
|
||||
{
|
||||
mItemBox->setItem(MWWorld::Ptr());
|
||||
mItemBox->clearUserStrings();
|
||||
mEnchanting.setOldItem(MWWorld::Ptr());
|
||||
}
|
||||
else
|
||||
{
|
||||
mItemBox->setItem(item);
|
||||
mItemBox->setUserString ("ToolTipType", "ItemPtr");
|
||||
mItemBox->setUserData(item);
|
||||
mEnchanting.setOldItem(item);
|
||||
}
|
||||
updateLabels();
|
||||
}
|
||||
|
||||
void EnchantingDialog::exit()
|
||||
|
@ -122,16 +160,7 @@ namespace MWGui
|
|||
startEditing();
|
||||
mEnchanting.setSoulGem(soulgem);
|
||||
|
||||
MyGUI::ImageBox* image = mSoulBox->createWidget<MyGUI::ImageBox>("ImageBox", MyGUI::IntCoord(0, 0, 32, 32), MyGUI::Align::Default);
|
||||
std::string path = std::string("icons\\");
|
||||
path += soulgem.getClass().getInventoryIcon(soulgem);
|
||||
int pos = path.rfind(".");
|
||||
path.erase(pos);
|
||||
path.append(".dds");
|
||||
image->setImageTexture (path);
|
||||
image->setUserString ("ToolTipType", "ItemPtr");
|
||||
image->setUserData(soulgem);
|
||||
image->eventMouseButtonClick += MyGUI::newDelegate(this, &EnchantingDialog::onRemoveSoul);
|
||||
setSoulGem(soulgem);
|
||||
|
||||
mPrice->setVisible(false);
|
||||
mPriceText->setVisible(false);
|
||||
|
@ -151,46 +180,31 @@ namespace MWGui
|
|||
|
||||
void EnchantingDialog::onSelectItem(MyGUI::Widget *sender)
|
||||
{
|
||||
delete mItemSelectionDialog;
|
||||
mItemSelectionDialog = new ItemSelectionDialog("#{sEnchantItems}");
|
||||
mItemSelectionDialog->eventItemSelected += MyGUI::newDelegate(this, &EnchantingDialog::onItemSelected);
|
||||
mItemSelectionDialog->eventDialogCanceled += MyGUI::newDelegate(this, &EnchantingDialog::onItemCancel);
|
||||
mItemSelectionDialog->setVisible(true);
|
||||
mItemSelectionDialog->openContainer(MWBase::Environment::get().getWorld()->getPlayerPtr());
|
||||
mItemSelectionDialog->setFilter(SortFilterItemModel::Filter_OnlyEnchantable);
|
||||
if (mEnchanting.getOldItem().isEmpty())
|
||||
{
|
||||
delete mItemSelectionDialog;
|
||||
mItemSelectionDialog = new ItemSelectionDialog("#{sEnchantItems}");
|
||||
mItemSelectionDialog->eventItemSelected += MyGUI::newDelegate(this, &EnchantingDialog::onItemSelected);
|
||||
mItemSelectionDialog->eventDialogCanceled += MyGUI::newDelegate(this, &EnchantingDialog::onItemCancel);
|
||||
mItemSelectionDialog->setVisible(true);
|
||||
mItemSelectionDialog->openContainer(MWBase::Environment::get().getWorld()->getPlayerPtr());
|
||||
mItemSelectionDialog->setFilter(SortFilterItemModel::Filter_OnlyEnchantable);
|
||||
}
|
||||
else
|
||||
{
|
||||
setItem(MWWorld::Ptr());
|
||||
}
|
||||
}
|
||||
|
||||
void EnchantingDialog::onItemSelected(MWWorld::Ptr item)
|
||||
{
|
||||
mItemSelectionDialog->setVisible(false);
|
||||
|
||||
while (mItemBox->getChildCount ())
|
||||
MyGUI::Gui::getInstance ().destroyWidget (mItemBox->getChildAt(0));
|
||||
|
||||
MyGUI::ImageBox* image = mItemBox->createWidget<MyGUI::ImageBox>("ImageBox", MyGUI::IntCoord(0, 0, 32, 32), MyGUI::Align::Default);
|
||||
std::string path = std::string("icons\\");
|
||||
path += item.getClass().getInventoryIcon(item);
|
||||
int pos = path.rfind(".");
|
||||
path.erase(pos);
|
||||
path.append(".dds");
|
||||
image->setImageTexture (path);
|
||||
image->setUserString ("ToolTipType", "ItemPtr");
|
||||
image->setUserData(item);
|
||||
image->eventMouseButtonClick += MyGUI::newDelegate(this, &EnchantingDialog::onRemoveItem);
|
||||
|
||||
mEnchanting.setOldItem(item);
|
||||
setItem(item);
|
||||
mEnchanting.nextCastStyle();
|
||||
updateLabels();
|
||||
}
|
||||
|
||||
void EnchantingDialog::onRemoveItem(MyGUI::Widget *sender)
|
||||
{
|
||||
while (mItemBox->getChildCount ())
|
||||
MyGUI::Gui::getInstance ().destroyWidget (mItemBox->getChildAt(0));
|
||||
mEnchanting.setOldItem(MWWorld::Ptr());
|
||||
updateLabels();
|
||||
}
|
||||
|
||||
void EnchantingDialog::onItemCancel()
|
||||
{
|
||||
mItemSelectionDialog->setVisible(false);
|
||||
|
@ -207,28 +221,7 @@ namespace MWGui
|
|||
return;
|
||||
}
|
||||
|
||||
while (mSoulBox->getChildCount ())
|
||||
MyGUI::Gui::getInstance ().destroyWidget (mSoulBox->getChildAt(0));
|
||||
|
||||
MyGUI::ImageBox* image = mSoulBox->createWidget<MyGUI::ImageBox>("ImageBox", MyGUI::IntCoord(0, 0, 32, 32), MyGUI::Align::Default);
|
||||
std::string path = std::string("icons\\");
|
||||
path += item.getClass().getInventoryIcon(item);
|
||||
int pos = path.rfind(".");
|
||||
path.erase(pos);
|
||||
path.append(".dds");
|
||||
image->setImageTexture (path);
|
||||
image->setUserString ("ToolTipType", "ItemPtr");
|
||||
image->setUserData(item);
|
||||
image->eventMouseButtonClick += MyGUI::newDelegate(this, &EnchantingDialog::onRemoveSoul);
|
||||
updateLabels();
|
||||
}
|
||||
|
||||
void EnchantingDialog::onRemoveSoul(MyGUI::Widget *sender)
|
||||
{
|
||||
while (mSoulBox->getChildCount ())
|
||||
MyGUI::Gui::getInstance ().destroyWidget (mSoulBox->getChildAt(0));
|
||||
mEnchanting.setSoulGem(MWWorld::Ptr());
|
||||
updateLabels();
|
||||
setSoulGem(item);
|
||||
}
|
||||
|
||||
void EnchantingDialog::onSoulCancel()
|
||||
|
@ -238,15 +231,22 @@ namespace MWGui
|
|||
|
||||
void EnchantingDialog::onSelectSoul(MyGUI::Widget *sender)
|
||||
{
|
||||
delete mItemSelectionDialog;
|
||||
mItemSelectionDialog = new ItemSelectionDialog("#{sSoulGemsWithSouls}");
|
||||
mItemSelectionDialog->eventItemSelected += MyGUI::newDelegate(this, &EnchantingDialog::onSoulSelected);
|
||||
mItemSelectionDialog->eventDialogCanceled += MyGUI::newDelegate(this, &EnchantingDialog::onSoulCancel);
|
||||
mItemSelectionDialog->setVisible(true);
|
||||
mItemSelectionDialog->openContainer(MWBase::Environment::get().getWorld()->getPlayerPtr());
|
||||
mItemSelectionDialog->setFilter(SortFilterItemModel::Filter_OnlyChargedSoulstones);
|
||||
if (mEnchanting.getGem().isEmpty())
|
||||
{
|
||||
delete mItemSelectionDialog;
|
||||
mItemSelectionDialog = new ItemSelectionDialog("#{sSoulGemsWithSouls}");
|
||||
mItemSelectionDialog->eventItemSelected += MyGUI::newDelegate(this, &EnchantingDialog::onSoulSelected);
|
||||
mItemSelectionDialog->eventDialogCanceled += MyGUI::newDelegate(this, &EnchantingDialog::onSoulCancel);
|
||||
mItemSelectionDialog->setVisible(true);
|
||||
mItemSelectionDialog->openContainer(MWBase::Environment::get().getWorld()->getPlayerPtr());
|
||||
mItemSelectionDialog->setFilter(SortFilterItemModel::Filter_OnlyChargedSoulstones);
|
||||
|
||||
//MWBase::Environment::get().getWindowManager()->messageBox("#{sInventorySelectNoSoul}");
|
||||
//MWBase::Environment::get().getWindowManager()->messageBox("#{sInventorySelectNoSoul}");
|
||||
}
|
||||
else
|
||||
{
|
||||
setSoulGem(MWWorld::Ptr());
|
||||
}
|
||||
}
|
||||
|
||||
void EnchantingDialog::notifyEffectsChanged ()
|
||||
|
|
|
@ -11,6 +11,7 @@ namespace MWGui
|
|||
{
|
||||
|
||||
class ItemSelectionDialog;
|
||||
class ItemWidget;
|
||||
|
||||
class EnchantingDialog : public WindowBase, public ReferenceInterface, public EffectEditorBase
|
||||
{
|
||||
|
@ -22,6 +23,9 @@ namespace MWGui
|
|||
|
||||
virtual void exit();
|
||||
|
||||
void setSoulGem (const MWWorld::Ptr& gem);
|
||||
void setItem (const MWWorld::Ptr& item);
|
||||
|
||||
void startEnchanting(MWWorld::Ptr actor);
|
||||
void startSelfEnchanting(MWWorld::Ptr soulgem);
|
||||
|
||||
|
@ -32,8 +36,6 @@ namespace MWGui
|
|||
void onCancelButtonClicked(MyGUI::Widget* sender);
|
||||
void onSelectItem (MyGUI::Widget* sender);
|
||||
void onSelectSoul (MyGUI::Widget* sender);
|
||||
void onRemoveItem (MyGUI::Widget* sender);
|
||||
void onRemoveSoul (MyGUI::Widget* sender);
|
||||
|
||||
void onItemSelected(MWWorld::Ptr item);
|
||||
void onItemCancel();
|
||||
|
@ -46,8 +48,8 @@ namespace MWGui
|
|||
ItemSelectionDialog* mItemSelectionDialog;
|
||||
|
||||
MyGUI::Button* mCancelButton;
|
||||
MyGUI::ImageBox* mItemBox;
|
||||
MyGUI::ImageBox* mSoulBox;
|
||||
ItemWidget* mItemBox;
|
||||
ItemWidget* mSoulBox;
|
||||
|
||||
MyGUI::Button* mTypeButton;
|
||||
MyGUI::Button* mBuyButton;
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
#include "container.hpp"
|
||||
|
||||
#include "itemmodel.hpp"
|
||||
#include "itemwidget.hpp"
|
||||
|
||||
namespace MWGui
|
||||
{
|
||||
|
@ -423,9 +424,6 @@ namespace MWGui
|
|||
mSpellStatus->setProgressRange(100);
|
||||
mSpellStatus->setProgressPosition(successChancePercent);
|
||||
|
||||
if (mSpellImage->getChildCount())
|
||||
MyGUI::Gui::getInstance().destroyWidget(mSpellImage->getChildAt(0));
|
||||
|
||||
mSpellBox->setUserString("ToolTipType", "Spell");
|
||||
mSpellBox->setUserString("Spell", spellId);
|
||||
|
||||
|
@ -438,7 +436,9 @@ namespace MWGui
|
|||
icon.insert(slashPos+1, "b_");
|
||||
icon = std::string("icons\\") + icon;
|
||||
Widgets::fixTexturePath(icon);
|
||||
mSpellImage->setImageTexture(icon);
|
||||
|
||||
mSpellImage->setItem(MWWorld::Ptr());
|
||||
mSpellImage->setIcon(icon);
|
||||
}
|
||||
|
||||
void HUD::setSelectedEnchantItem(const MWWorld::Ptr& item, int chargePercent)
|
||||
|
@ -455,21 +455,10 @@ namespace MWGui
|
|||
mSpellStatus->setProgressRange(100);
|
||||
mSpellStatus->setProgressPosition(chargePercent);
|
||||
|
||||
if (mSpellImage->getChildCount())
|
||||
MyGUI::Gui::getInstance().destroyWidget(mSpellImage->getChildAt(0));
|
||||
|
||||
mSpellBox->setUserString("ToolTipType", "ItemPtr");
|
||||
mSpellBox->setUserData(item);
|
||||
|
||||
mSpellImage->setImageTexture("textures\\menu_icon_magic_mini.dds");
|
||||
MyGUI::ImageBox* itemBox = mSpellImage->createWidgetReal<MyGUI::ImageBox>("ImageBox", MyGUI::FloatCoord(0,0,1,1)
|
||||
, MyGUI::Align::Stretch);
|
||||
|
||||
std::string path = std::string("icons\\");
|
||||
path+=item.getClass().getInventoryIcon(item);
|
||||
Widgets::fixTexturePath(path);
|
||||
itemBox->setImageTexture(path);
|
||||
itemBox->setNeedMouseFocus(false);
|
||||
mSpellImage->setItem(item);
|
||||
}
|
||||
|
||||
void HUD::setSelectedWeapon(const MWWorld::Ptr& item, int durabilityPercent)
|
||||
|
@ -489,23 +478,7 @@ namespace MWGui
|
|||
mWeapStatus->setProgressRange(100);
|
||||
mWeapStatus->setProgressPosition(durabilityPercent);
|
||||
|
||||
if (mWeapImage->getChildCount())
|
||||
MyGUI::Gui::getInstance().destroyWidget(mWeapImage->getChildAt(0));
|
||||
|
||||
std::string path = std::string("icons\\");
|
||||
path+=item.getClass().getInventoryIcon(item);
|
||||
Widgets::fixTexturePath(path);
|
||||
|
||||
if (item.getClass().getEnchantment(item) != "")
|
||||
{
|
||||
mWeapImage->setImageTexture("textures\\menu_icon_magic_mini.dds");
|
||||
MyGUI::ImageBox* itemBox = mWeapImage->createWidgetReal<MyGUI::ImageBox>("ImageBox", MyGUI::FloatCoord(0,0,1,1)
|
||||
, MyGUI::Align::Stretch);
|
||||
itemBox->setImageTexture(path);
|
||||
itemBox->setNeedMouseFocus(false);
|
||||
}
|
||||
else
|
||||
mWeapImage->setImageTexture(path);
|
||||
mWeapImage->setItem(item);
|
||||
}
|
||||
|
||||
void HUD::unsetSelectedSpell()
|
||||
|
@ -519,11 +492,9 @@ namespace MWGui
|
|||
mWeaponSpellBox->setVisible(true);
|
||||
}
|
||||
|
||||
if (mSpellImage->getChildCount())
|
||||
MyGUI::Gui::getInstance().destroyWidget(mSpellImage->getChildAt(0));
|
||||
mSpellStatus->setProgressRange(100);
|
||||
mSpellStatus->setProgressPosition(0);
|
||||
mSpellImage->setImageTexture("");
|
||||
mSpellImage->setItem(MWWorld::Ptr());
|
||||
mSpellBox->clearUserStrings();
|
||||
}
|
||||
|
||||
|
@ -538,17 +509,17 @@ namespace MWGui
|
|||
mWeaponSpellBox->setVisible(true);
|
||||
}
|
||||
|
||||
if (mWeapImage->getChildCount())
|
||||
MyGUI::Gui::getInstance().destroyWidget(mWeapImage->getChildAt(0));
|
||||
mWeapStatus->setProgressRange(100);
|
||||
mWeapStatus->setProgressPosition(0);
|
||||
|
||||
MWBase::World *world = MWBase::Environment::get().getWorld();
|
||||
MWWorld::Ptr player = world->getPlayerPtr();
|
||||
|
||||
mWeapImage->setItem(MWWorld::Ptr());
|
||||
if (player.getClass().getNpcStats(player).isWerewolf())
|
||||
mWeapImage->setImageTexture("icons\\k\\tx_werewolf_hand.dds");
|
||||
mWeapImage->setIcon("icons\\k\\tx_werewolf_hand.dds");
|
||||
else
|
||||
mWeapImage->setImageTexture("icons\\k\\stealth_handtohand.dds");
|
||||
mWeapImage->setIcon("icons\\k\\stealth_handtohand.dds");
|
||||
|
||||
mWeapBox->clearUserStrings();
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@ namespace MWGui
|
|||
{
|
||||
class DragAndDrop;
|
||||
class SpellIcons;
|
||||
class ItemWidget;
|
||||
|
||||
class HUD : public OEngine::GUI::Layout, public LocalMapBase
|
||||
{
|
||||
|
@ -63,7 +64,7 @@ namespace MWGui
|
|||
MyGUI::ProgressBar *mHealth, *mMagicka, *mStamina, *mEnemyHealth, *mDrowning;
|
||||
MyGUI::Widget* mHealthFrame;
|
||||
MyGUI::Widget *mWeapBox, *mSpellBox, *mSneakBox;
|
||||
MyGUI::ImageBox *mWeapImage, *mSpellImage;
|
||||
ItemWidget *mWeapImage, *mSpellImage;
|
||||
MyGUI::ProgressBar *mWeapStatus, *mSpellStatus;
|
||||
MyGUI::Widget *mEffectBox, *mMinimapBox;
|
||||
MyGUI::Button* mMinimapButton;
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
#include "../mwworld/class.hpp"
|
||||
|
||||
#include "itemmodel.hpp"
|
||||
#include "itemwidget.hpp"
|
||||
|
||||
namespace MWGui
|
||||
{
|
||||
|
@ -80,53 +81,24 @@ void ItemView::update()
|
|||
const ItemStack& item = mModel->getItem(i);
|
||||
|
||||
/// \todo performance improvement: don't create/destroy all the widgets everytime the container window changes size, only reposition them
|
||||
std::string path = std::string("icons\\");
|
||||
path += item.mBase.getClass().getInventoryIcon(item.mBase);
|
||||
|
||||
// background widget (for the "equipped" frame and magic item background image)
|
||||
bool isMagic = (item.mFlags & ItemStack::Flag_Enchanted);
|
||||
MyGUI::ImageBox* backgroundWidget = dragArea->createWidget<MyGUI::ImageBox>("ImageBox",
|
||||
ItemWidget* itemWidget = dragArea->createWidget<ItemWidget>("MW_ItemIcon",
|
||||
MyGUI::IntCoord(x, y, 42, 42), MyGUI::Align::Default);
|
||||
backgroundWidget->setUserString("ToolTipType", "ItemModelIndex");
|
||||
backgroundWidget->setUserData(std::make_pair(i, mModel));
|
||||
itemWidget->setUserString("ToolTipType", "ItemModelIndex");
|
||||
itemWidget->setUserData(std::make_pair(i, mModel));
|
||||
ItemWidget::ItemState state = ItemWidget::None;
|
||||
if (item.mType == ItemStack::Type_Barter)
|
||||
state = ItemWidget::Barter;
|
||||
if (item.mType == ItemStack::Type_Equipped)
|
||||
state = ItemWidget::Equip;
|
||||
itemWidget->setItem(item.mBase, state);
|
||||
|
||||
std::string backgroundTex = "textures\\menu_icon";
|
||||
if (isMagic)
|
||||
backgroundTex += "_magic";
|
||||
if (item.mType == ItemStack::Type_Normal)
|
||||
{
|
||||
if (!isMagic)
|
||||
backgroundTex = "";
|
||||
}
|
||||
else if (item.mType == ItemStack::Type_Equipped)
|
||||
backgroundTex += "_equip";
|
||||
else if (item.mType == ItemStack::Type_Barter)
|
||||
backgroundTex += "_barter";
|
||||
|
||||
if (backgroundTex != "")
|
||||
backgroundTex += ".dds";
|
||||
|
||||
backgroundWidget->setImageTexture(backgroundTex);
|
||||
if ((item.mType == ItemStack::Type_Barter) && !isMagic)
|
||||
backgroundWidget->setProperty("ImageCoord", "2 2 42 42");
|
||||
else
|
||||
backgroundWidget->setProperty("ImageCoord", "0 0 42 42");
|
||||
backgroundWidget->eventMouseButtonClick += MyGUI::newDelegate(this, &ItemView::onSelectedItem);
|
||||
backgroundWidget->eventMouseWheel += MyGUI::newDelegate(this, &ItemView::onMouseWheel);
|
||||
|
||||
// image
|
||||
MyGUI::ImageBox* image = backgroundWidget->createWidget<MyGUI::ImageBox>("ImageBox",
|
||||
MyGUI::IntCoord(5, 5, 32, 32), MyGUI::Align::Default);
|
||||
std::string::size_type pos = path.rfind(".");
|
||||
if(pos != std::string::npos)
|
||||
path.erase(pos);
|
||||
path.append(".dds");
|
||||
image->setImageTexture(path);
|
||||
image->setNeedMouseFocus(false);
|
||||
itemWidget->eventMouseButtonClick += MyGUI::newDelegate(this, &ItemView::onSelectedItem);
|
||||
itemWidget->eventMouseWheel += MyGUI::newDelegate(this, &ItemView::onMouseWheel);
|
||||
|
||||
// text widget that shows item count
|
||||
MyGUI::TextBox* text = image->createWidget<MyGUI::TextBox>("SandBrightText",
|
||||
MyGUI::IntCoord(0, 14, 32, 18), MyGUI::Align::Default, std::string("Label"));
|
||||
// TODO: move to ItemWidget
|
||||
MyGUI::TextBox* text = itemWidget->createWidget<MyGUI::TextBox>("SandBrightText",
|
||||
MyGUI::IntCoord(5, 19, 32, 18), MyGUI::Align::Default, std::string("Label"));
|
||||
text->setTextAlign(MyGUI::Align::Right);
|
||||
text->setNeedMouseFocus(false);
|
||||
text->setTextShadow(true);
|
||||
|
|
105
apps/openmw/mwgui/itemwidget.cpp
Normal file
105
apps/openmw/mwgui/itemwidget.cpp
Normal file
|
@ -0,0 +1,105 @@
|
|||
#include "itemwidget.hpp"
|
||||
|
||||
#include <MyGUI_FactoryManager.h>
|
||||
#include <MyGUI_ImageBox.h>
|
||||
|
||||
#include "../mwworld/class.hpp"
|
||||
|
||||
namespace MWGui
|
||||
{
|
||||
|
||||
ItemWidget::ItemWidget()
|
||||
: mItem(NULL)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void ItemWidget::registerComponents()
|
||||
{
|
||||
MyGUI::FactoryManager::getInstance().registerFactory<ItemWidget>("Widget");
|
||||
}
|
||||
|
||||
void ItemWidget::initialiseOverride()
|
||||
{
|
||||
assignWidget(mItem, "Item");
|
||||
if (mItem)
|
||||
mItem->setNeedMouseFocus(false);
|
||||
assignWidget(mFrame, "Frame");
|
||||
if (mFrame)
|
||||
mFrame->setNeedMouseFocus(false);
|
||||
|
||||
Base::initialiseOverride();
|
||||
}
|
||||
|
||||
void ItemWidget::setIcon(const std::string &icon)
|
||||
{
|
||||
if (mItem)
|
||||
mItem->setImageTexture(icon);
|
||||
}
|
||||
|
||||
void ItemWidget::setFrame(const std::string &frame, const MyGUI::IntCoord &coord)
|
||||
{
|
||||
if (mFrame)
|
||||
{
|
||||
mFrame->setImageTexture(frame);
|
||||
mFrame->setImageTile(MyGUI::IntSize(coord.width, coord.height)); // Why is this needed? MyGUI bug?
|
||||
mFrame->setImageCoord(coord);
|
||||
}
|
||||
}
|
||||
|
||||
void ItemWidget::setIcon(const MWWorld::Ptr &ptr)
|
||||
{
|
||||
// image
|
||||
std::string path = std::string("icons\\");
|
||||
path += ptr.getClass().getInventoryIcon(ptr);
|
||||
|
||||
std::string::size_type pos = path.rfind(".");
|
||||
if(pos != std::string::npos)
|
||||
path.erase(pos);
|
||||
path.append(".dds");
|
||||
setIcon(path);
|
||||
}
|
||||
|
||||
|
||||
void ItemWidget::setItem(const MWWorld::Ptr &ptr, ItemState state)
|
||||
{
|
||||
if (!mItem)
|
||||
return;
|
||||
|
||||
if (ptr.isEmpty())
|
||||
{
|
||||
if (mFrame)
|
||||
mFrame->setImageTexture("");
|
||||
mItem->setImageTexture("");
|
||||
return;
|
||||
}
|
||||
|
||||
bool isMagic = !ptr.getClass().getEnchantment(ptr).empty();
|
||||
|
||||
std::string backgroundTex = "textures\\menu_icon";
|
||||
if (isMagic)
|
||||
backgroundTex += "_magic";
|
||||
if (state == None)
|
||||
{
|
||||
if (!isMagic)
|
||||
backgroundTex = "";
|
||||
}
|
||||
else if (state == Equip)
|
||||
{
|
||||
backgroundTex += "_equip";
|
||||
}
|
||||
else if (state == Barter)
|
||||
backgroundTex += "_barter";
|
||||
|
||||
if (backgroundTex != "")
|
||||
backgroundTex += ".dds";
|
||||
|
||||
if (state == Barter && !isMagic)
|
||||
setFrame(backgroundTex, MyGUI::IntCoord(2,2,42,42));
|
||||
else
|
||||
setFrame(backgroundTex, MyGUI::IntCoord(0,0,42,42));
|
||||
|
||||
setIcon(ptr);
|
||||
}
|
||||
|
||||
}
|
49
apps/openmw/mwgui/itemwidget.hpp
Normal file
49
apps/openmw/mwgui/itemwidget.hpp
Normal file
|
@ -0,0 +1,49 @@
|
|||
#ifndef OPENMW_MWGUI_ITEMWIDGET_H
|
||||
#define OPENMW_MWGUI_ITEMWIDGET_H
|
||||
|
||||
#include <MyGUI_Widget.h>
|
||||
|
||||
namespace MWWorld
|
||||
{
|
||||
class Ptr;
|
||||
}
|
||||
|
||||
namespace MWGui
|
||||
{
|
||||
|
||||
/// @brief A widget that shows an icon for an MWWorld::Ptr
|
||||
class ItemWidget : public MyGUI::Widget
|
||||
{
|
||||
MYGUI_RTTI_DERIVED(ItemWidget)
|
||||
public:
|
||||
ItemWidget();
|
||||
|
||||
/// Register needed components with MyGUI's factory manager
|
||||
static void registerComponents ();
|
||||
|
||||
enum ItemState
|
||||
{
|
||||
None,
|
||||
Equip,
|
||||
Barter,
|
||||
Magic
|
||||
};
|
||||
|
||||
/// \a ptr may be empty
|
||||
void setItem (const MWWorld::Ptr& ptr, ItemState state = None);
|
||||
|
||||
// Set icon and frame manually
|
||||
void setIcon (const std::string& icon);
|
||||
void setIcon (const MWWorld::Ptr& ptr);
|
||||
void setFrame (const std::string& frame, const MyGUI::IntCoord& coord);
|
||||
|
||||
private:
|
||||
virtual void initialiseOverride();
|
||||
|
||||
MyGUI::ImageBox* mItem;
|
||||
MyGUI::ImageBox* mFrame;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
|
@ -23,6 +23,8 @@
|
|||
|
||||
#include "spellwindow.hpp"
|
||||
|
||||
#include "itemwidget.hpp"
|
||||
|
||||
|
||||
namespace MWGui
|
||||
{
|
||||
|
@ -46,14 +48,16 @@ namespace MWGui
|
|||
|
||||
for (int i = 0; i < 10; ++i)
|
||||
{
|
||||
MyGUI::Button* button;
|
||||
ItemWidget* button;
|
||||
getWidget(button, "QuickKey" + boost::lexical_cast<std::string>(i+1));
|
||||
|
||||
button->eventMouseButtonClick += MyGUI::newDelegate(this, &QuickKeysMenu::onQuickKeyButtonClicked);
|
||||
|
||||
unassign(button, i);
|
||||
|
||||
mQuickKeyButtons.push_back(button);
|
||||
|
||||
mAssigned.push_back(Type_Unassigned);
|
||||
|
||||
unassign(button, i);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -77,12 +81,14 @@ namespace MWGui
|
|||
delete mMagicSelectionDialog;
|
||||
}
|
||||
|
||||
void QuickKeysMenu::unassign(MyGUI::Widget* key, int index)
|
||||
void QuickKeysMenu::unassign(ItemWidget* key, int index)
|
||||
{
|
||||
while (key->getChildCount ())
|
||||
MyGUI::Gui::getInstance ().destroyWidget (key->getChildAt(0));
|
||||
key->clearUserStrings();
|
||||
key->setItem(MWWorld::Ptr());
|
||||
while (key->getChildCount()) // Destroy number label
|
||||
MyGUI::Gui::getInstance().destroyWidget(key->getChildAt(0));
|
||||
|
||||
key->setUserData(Type_Unassigned);
|
||||
mAssigned[index] = Type_Unassigned;
|
||||
|
||||
MyGUI::TextBox* textBox = key->createWidgetReal<MyGUI::TextBox>("SandText", MyGUI::FloatCoord(0,0,1,1), MyGUI::Align::Default);
|
||||
textBox->setTextAlign (MyGUI::Align::Center);
|
||||
|
@ -156,27 +162,16 @@ namespace MWGui
|
|||
|
||||
void QuickKeysMenu::onAssignItem(MWWorld::Ptr item)
|
||||
{
|
||||
MyGUI::Button* button = mQuickKeyButtons[mSelectedIndex];
|
||||
while (button->getChildCount ())
|
||||
MyGUI::Gui::getInstance ().destroyWidget (button->getChildAt(0));
|
||||
assert (mSelectedIndex > 0);
|
||||
ItemWidget* button = mQuickKeyButtons[mSelectedIndex];
|
||||
while (button->getChildCount()) // Destroy number label
|
||||
MyGUI::Gui::getInstance().destroyWidget(button->getChildAt(0));
|
||||
|
||||
button->setUserData(Type_Item);
|
||||
mAssigned[mSelectedIndex] = Type_Item;
|
||||
|
||||
MyGUI::ImageBox* frame = button->createWidget<MyGUI::ImageBox>("ImageBox", MyGUI::IntCoord(9, 8, 42, 42), MyGUI::Align::Default);
|
||||
std::string backgroundTex = "textures\\menu_icon_barter.dds";
|
||||
frame->setImageTexture (backgroundTex);
|
||||
frame->setImageCoord (MyGUI::IntCoord(4, 4, 40, 40));
|
||||
frame->setUserString ("ToolTipType", "ItemPtr");
|
||||
frame->setUserData(item);
|
||||
frame->eventMouseButtonClick += MyGUI::newDelegate(this, &QuickKeysMenu::onQuickKeyButtonClicked);
|
||||
MyGUI::ImageBox* image = frame->createWidget<MyGUI::ImageBox>("ImageBox", MyGUI::IntCoord(5, 5, 32, 32), MyGUI::Align::Default);
|
||||
std::string path = std::string("icons\\");
|
||||
path += item.getClass().getInventoryIcon(item);
|
||||
int pos = path.rfind(".");
|
||||
path.erase(pos);
|
||||
path.append(".dds");
|
||||
image->setImageTexture (path);
|
||||
image->setNeedMouseFocus (false);
|
||||
button->setItem(item, ItemWidget::Barter);
|
||||
button->setUserString ("ToolTipType", "ItemPtr");
|
||||
button->setUserData(item);
|
||||
|
||||
if (mItemSelectionDialog)
|
||||
mItemSelectionDialog->setVisible(false);
|
||||
|
@ -189,28 +184,18 @@ namespace MWGui
|
|||
|
||||
void QuickKeysMenu::onAssignMagicItem (MWWorld::Ptr item)
|
||||
{
|
||||
MyGUI::Button* button = mQuickKeyButtons[mSelectedIndex];
|
||||
while (button->getChildCount ())
|
||||
MyGUI::Gui::getInstance ().destroyWidget (button->getChildAt(0));
|
||||
assert (mSelectedIndex > 0);
|
||||
ItemWidget* button = mQuickKeyButtons[mSelectedIndex];
|
||||
while (button->getChildCount()) // Destroy number label
|
||||
MyGUI::Gui::getInstance().destroyWidget(button->getChildAt(0));
|
||||
|
||||
button->setUserData(Type_MagicItem);
|
||||
mAssigned[mSelectedIndex] = Type_MagicItem;
|
||||
|
||||
MyGUI::ImageBox* frame = button->createWidget<MyGUI::ImageBox>("ImageBox", MyGUI::IntCoord(9, 8, 42, 42), MyGUI::Align::Default);
|
||||
std::string backgroundTex = "textures\\menu_icon_select_magic_magic.dds";
|
||||
frame->setImageTexture (backgroundTex);
|
||||
frame->setImageCoord (MyGUI::IntCoord(2, 2, 40, 40));
|
||||
frame->setUserString ("ToolTipType", "ItemPtr");
|
||||
frame->setUserData(item);
|
||||
frame->eventMouseButtonClick += MyGUI::newDelegate(this, &QuickKeysMenu::onQuickKeyButtonClicked);
|
||||
button->setFrame("textures\\menu_icon_select_magic_magic.dds", MyGUI::IntCoord(2, 2, 40, 40));
|
||||
button->setIcon(item);
|
||||
|
||||
MyGUI::ImageBox* image = frame->createWidget<MyGUI::ImageBox>("ImageBox", MyGUI::IntCoord(5, 5, 32, 32), MyGUI::Align::Default);
|
||||
std::string path = std::string("icons\\");
|
||||
path += item.getClass().getInventoryIcon(item);
|
||||
int pos = path.rfind(".");
|
||||
path.erase(pos);
|
||||
path.append(".dds");
|
||||
image->setImageTexture (path);
|
||||
image->setNeedMouseFocus (false);
|
||||
button->setUserString ("ToolTipType", "ItemPtr");
|
||||
button->setUserData(item);
|
||||
|
||||
if (mMagicSelectionDialog)
|
||||
mMagicSelectionDialog->setVisible(false);
|
||||
|
@ -218,21 +203,16 @@ namespace MWGui
|
|||
|
||||
void QuickKeysMenu::onAssignMagic (const std::string& spellId)
|
||||
{
|
||||
MyGUI::Button* button = mQuickKeyButtons[mSelectedIndex];
|
||||
while (button->getChildCount ())
|
||||
MyGUI::Gui::getInstance ().destroyWidget (button->getChildAt(0));
|
||||
assert (mSelectedIndex > 0);
|
||||
ItemWidget* button = mQuickKeyButtons[mSelectedIndex];
|
||||
while (button->getChildCount()) // Destroy number label
|
||||
MyGUI::Gui::getInstance().destroyWidget(button->getChildAt(0));
|
||||
|
||||
button->setUserData(Type_Magic);
|
||||
mAssigned[mSelectedIndex] = Type_Magic;
|
||||
|
||||
MyGUI::ImageBox* frame = button->createWidget<MyGUI::ImageBox>("ImageBox", MyGUI::IntCoord(9, 8, 42, 42), MyGUI::Align::Default);
|
||||
std::string backgroundTex = "textures\\menu_icon_select_magic.dds";
|
||||
frame->setImageTexture (backgroundTex);
|
||||
frame->setImageCoord (MyGUI::IntCoord(2, 2, 40, 40));
|
||||
frame->setUserString ("ToolTipType", "Spell");
|
||||
frame->setUserString ("Spell", spellId);
|
||||
frame->eventMouseButtonClick += MyGUI::newDelegate(this, &QuickKeysMenu::onQuickKeyButtonClicked);
|
||||
|
||||
MyGUI::ImageBox* image = frame->createWidget<MyGUI::ImageBox>("ImageBox", MyGUI::IntCoord(5, 5, 32, 32), MyGUI::Align::Default);
|
||||
button->setItem(MWWorld::Ptr());
|
||||
button->setUserString ("ToolTipType", "Spell");
|
||||
button->setUserString ("Spell", spellId);
|
||||
|
||||
const MWWorld::ESMStore &esmStore =
|
||||
MWBase::Environment::get().getWorld()->getStore();
|
||||
|
@ -251,8 +231,8 @@ namespace MWGui
|
|||
path.erase(pos);
|
||||
path.append(".dds");
|
||||
|
||||
image->setImageTexture (path);
|
||||
image->setNeedMouseFocus (false);
|
||||
button->setFrame("textures\\menu_icon_select_magic.dds", MyGUI::IntCoord(2, 2, 40, 40));
|
||||
button->setIcon(path);
|
||||
|
||||
if (mMagicSelectionDialog)
|
||||
mMagicSelectionDialog->setVisible(false);
|
||||
|
@ -265,16 +245,17 @@ namespace MWGui
|
|||
|
||||
void QuickKeysMenu::activateQuickKey(int index)
|
||||
{
|
||||
MyGUI::Button* button = mQuickKeyButtons[index-1];
|
||||
assert (index-1 > 0);
|
||||
ItemWidget* button = mQuickKeyButtons[index-1];
|
||||
|
||||
QuickKeyType type = *button->getUserData<QuickKeyType>();
|
||||
QuickKeyType type = mAssigned[index-1];
|
||||
|
||||
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr();
|
||||
MWWorld::InventoryStore& store = player.getClass().getInventoryStore(player);
|
||||
|
||||
if (type == Type_Item || type == Type_MagicItem)
|
||||
{
|
||||
MWWorld::Ptr item = *button->getChildAt (0)->getUserData<MWWorld::Ptr>();
|
||||
MWWorld::Ptr item = *button->getUserData<MWWorld::Ptr>();
|
||||
// make sure the item is available
|
||||
if (item.getRefData ().getCount() < 1)
|
||||
{
|
||||
|
@ -286,7 +267,7 @@ namespace MWGui
|
|||
if (Misc::StringUtils::ciEqual(it->getCellRef().getRefId(), id))
|
||||
{
|
||||
item = *it;
|
||||
button->getChildAt(0)->setUserData(item);
|
||||
button->setUserData(item);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -303,7 +284,7 @@ namespace MWGui
|
|||
|
||||
if (type == Type_Magic)
|
||||
{
|
||||
std::string spellId = button->getChildAt(0)->getUserString("Spell");
|
||||
std::string spellId = button->getUserString("Spell");
|
||||
|
||||
// Make sure the player still has this spell
|
||||
MWMechanics::CreatureStats& stats = player.getClass().getCreatureStats(player);
|
||||
|
@ -315,13 +296,13 @@ namespace MWGui
|
|||
}
|
||||
else if (type == Type_Item)
|
||||
{
|
||||
MWWorld::Ptr item = *button->getChildAt (0)->getUserData<MWWorld::Ptr>();
|
||||
MWWorld::Ptr item = *button->getUserData<MWWorld::Ptr>();
|
||||
|
||||
MWBase::Environment::get().getWindowManager()->getInventoryWindow()->useItem(item);
|
||||
}
|
||||
else if (type == Type_MagicItem)
|
||||
{
|
||||
MWWorld::Ptr item = *button->getChildAt (0)->getUserData<MWWorld::Ptr>();
|
||||
MWWorld::Ptr item = *button->getUserData<MWWorld::Ptr>();
|
||||
|
||||
// retrieve ContainerStoreIterator to the item
|
||||
MWWorld::ContainerStoreIterator it = store.begin();
|
||||
|
@ -403,9 +384,9 @@ namespace MWGui
|
|||
|
||||
for (int i=0; i<10; ++i)
|
||||
{
|
||||
MyGUI::Button* button = mQuickKeyButtons[i];
|
||||
ItemWidget* button = mQuickKeyButtons[i];
|
||||
|
||||
int type = *button->getUserData<QuickKeyType>();
|
||||
int type = mAssigned[i];
|
||||
|
||||
ESM::QuickKeys::QuickKey key;
|
||||
key.mType = type;
|
||||
|
@ -417,12 +398,12 @@ namespace MWGui
|
|||
case Type_Item:
|
||||
case Type_MagicItem:
|
||||
{
|
||||
MWWorld::Ptr item = *button->getChildAt(0)->getUserData<MWWorld::Ptr>();
|
||||
MWWorld::Ptr item = *button->getUserData<MWWorld::Ptr>();
|
||||
key.mId = item.getCellRef().getRefId();
|
||||
break;
|
||||
}
|
||||
case Type_Magic:
|
||||
std::string spellId = button->getChildAt(0)->getUserString("Spell");
|
||||
std::string spellId = button->getUserString("Spell");
|
||||
key.mId = spellId;
|
||||
break;
|
||||
}
|
||||
|
@ -452,7 +433,7 @@ namespace MWGui
|
|||
mSelectedIndex = i;
|
||||
int keyType = it->mType;
|
||||
std::string id = it->mId;
|
||||
MyGUI::Button* button = mQuickKeyButtons[i];
|
||||
ItemWidget* button = mQuickKeyButtons[i];
|
||||
|
||||
switch (keyType)
|
||||
{
|
||||
|
|
|
@ -11,6 +11,7 @@ namespace MWGui
|
|||
class QuickKeysMenuAssign;
|
||||
class ItemSelectionDialog;
|
||||
class MagicSelectionDialog;
|
||||
class ItemWidget;
|
||||
|
||||
class QuickKeysMenu : public WindowBase
|
||||
{
|
||||
|
@ -51,7 +52,8 @@ namespace MWGui
|
|||
MyGUI::EditBox* mInstructionLabel;
|
||||
MyGUI::Button* mOkButton;
|
||||
|
||||
std::vector<MyGUI::Button*> mQuickKeyButtons;
|
||||
std::vector<ItemWidget*> mQuickKeyButtons;
|
||||
std::vector<QuickKeyType> mAssigned;
|
||||
|
||||
QuickKeysMenuAssign* mAssignDialog;
|
||||
ItemSelectionDialog* mItemSelectionDialog;
|
||||
|
@ -63,7 +65,7 @@ namespace MWGui
|
|||
void onQuickKeyButtonClicked(MyGUI::Widget* sender);
|
||||
void onOkButtonClicked(MyGUI::Widget* sender);
|
||||
|
||||
void unassign(MyGUI::Widget* key, int index);
|
||||
void unassign(ItemWidget* key, int index);
|
||||
};
|
||||
|
||||
class QuickKeysMenuAssign : public WindowModal
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
#include "../mwmechanics/npcstats.hpp"
|
||||
|
||||
#include "widgets.hpp"
|
||||
#include "itemwidget.hpp"
|
||||
|
||||
namespace MWGui
|
||||
{
|
||||
|
@ -45,12 +46,7 @@ void Recharge::exit()
|
|||
|
||||
void Recharge::start (const MWWorld::Ptr &item)
|
||||
{
|
||||
std::string path = std::string("icons\\");
|
||||
path += item.getClass().getInventoryIcon(item);
|
||||
int pos = path.rfind(".");
|
||||
path.erase(pos);
|
||||
path.append(".dds");
|
||||
mGemIcon->setImageTexture (path);
|
||||
mGemIcon->setItem(item);
|
||||
mGemIcon->setUserString("ToolTipType", "ItemPtr");
|
||||
mGemIcon->setUserData(item);
|
||||
|
||||
|
@ -108,14 +104,9 @@ void Recharge::updateView()
|
|||
text->setNeedMouseFocus(false);
|
||||
currentY += 19;
|
||||
|
||||
MyGUI::ImageBox* icon = mView->createWidget<MyGUI::ImageBox> (
|
||||
"ImageBox", MyGUI::IntCoord(16, currentY, 32, 32), MyGUI::Align::Default);
|
||||
std::string path = std::string("icons\\");
|
||||
path += iter->getClass().getInventoryIcon(*iter);
|
||||
int pos = path.rfind(".");
|
||||
path.erase(pos);
|
||||
path.append(".dds");
|
||||
icon->setImageTexture (path);
|
||||
ItemWidget* icon = mView->createWidget<ItemWidget> (
|
||||
"MW_ItemIconSmall", MyGUI::IntCoord(16, currentY, 32, 32), MyGUI::Align::Default);
|
||||
icon->setItem(*iter);
|
||||
icon->setUserString("ToolTipType", "ItemPtr");
|
||||
icon->setUserData(*iter);
|
||||
icon->eventMouseButtonClick += MyGUI::newDelegate(this, &Recharge::onItemClicked);
|
||||
|
|
|
@ -8,6 +8,8 @@
|
|||
namespace MWGui
|
||||
{
|
||||
|
||||
class ItemWidget;
|
||||
|
||||
class Recharge : public WindowBase
|
||||
{
|
||||
public:
|
||||
|
@ -25,7 +27,7 @@ protected:
|
|||
|
||||
MyGUI::Widget* mGemBox;
|
||||
|
||||
MyGUI::ImageBox* mGemIcon;
|
||||
ItemWidget* mGemIcon;
|
||||
|
||||
MyGUI::TextBox* mChargeLabel;
|
||||
|
||||
|
|
|
@ -13,6 +13,8 @@
|
|||
|
||||
#include "widgets.hpp"
|
||||
|
||||
#include "itemwidget.hpp"
|
||||
|
||||
namespace MWGui
|
||||
{
|
||||
|
||||
|
@ -44,12 +46,7 @@ void Repair::startRepairItem(const MWWorld::Ptr &item)
|
|||
{
|
||||
mRepair.setTool(item);
|
||||
|
||||
std::string path = std::string("icons\\");
|
||||
path += item.getClass().getInventoryIcon(item);
|
||||
int pos = path.rfind(".");
|
||||
path.erase(pos);
|
||||
path.append(".dds");
|
||||
mToolIcon->setImageTexture (path);
|
||||
mToolIcon->setItem(item);
|
||||
mToolIcon->setUserString("ToolTipType", "ItemPtr");
|
||||
mToolIcon->setUserData(item);
|
||||
|
||||
|
@ -113,14 +110,9 @@ void Repair::updateRepairView()
|
|||
text->setNeedMouseFocus(false);
|
||||
currentY += 19;
|
||||
|
||||
MyGUI::ImageBox* icon = mRepairView->createWidget<MyGUI::ImageBox> (
|
||||
"ImageBox", MyGUI::IntCoord(16, currentY, 32, 32), MyGUI::Align::Default);
|
||||
std::string path = std::string("icons\\");
|
||||
path += iter->getClass().getInventoryIcon(*iter);
|
||||
int pos = path.rfind(".");
|
||||
path.erase(pos);
|
||||
path.append(".dds");
|
||||
icon->setImageTexture (path);
|
||||
ItemWidget* icon = mRepairView->createWidget<ItemWidget> (
|
||||
"MW_ItemIconSmall", MyGUI::IntCoord(16, currentY, 32, 32), MyGUI::Align::Default);
|
||||
icon->setItem(*iter);
|
||||
icon->setUserString("ToolTipType", "ItemPtr");
|
||||
icon->setUserData(*iter);
|
||||
icon->eventMouseButtonClick += MyGUI::newDelegate(this, &Repair::onRepairItem);
|
||||
|
|
|
@ -8,6 +8,8 @@
|
|||
namespace MWGui
|
||||
{
|
||||
|
||||
class ItemWidget;
|
||||
|
||||
class Repair : public WindowBase
|
||||
{
|
||||
public:
|
||||
|
@ -25,7 +27,7 @@ protected:
|
|||
|
||||
MyGUI::Widget* mToolBox;
|
||||
|
||||
MyGUI::ImageBox* mToolIcon;
|
||||
ItemWidget* mToolIcon;
|
||||
|
||||
MyGUI::TextBox* mUsesLabel;
|
||||
MyGUI::TextBox* mQualityLabel;
|
||||
|
|
|
@ -64,6 +64,7 @@
|
|||
#include "fontloader.hpp"
|
||||
#include "videowidget.hpp"
|
||||
#include "backgroundimage.hpp"
|
||||
#include "itemwidget.hpp"
|
||||
|
||||
namespace MWGui
|
||||
{
|
||||
|
@ -166,6 +167,7 @@ namespace MWGui
|
|||
MyGUI::FactoryManager::getInstance().registerFactory<BackgroundImage>("Widget");
|
||||
BookPage::registerMyGUIComponents ();
|
||||
ItemView::registerComponents();
|
||||
ItemWidget::registerComponents();
|
||||
|
||||
MyGUI::FactoryManager::getInstance().registerFactory<MWGui::Controllers::ControllerRepeatClick>("Controller");
|
||||
|
||||
|
|
|
@ -23,21 +23,13 @@
|
|||
|
||||
<Widget type="Widget" skin="" position="10 66 260 50">
|
||||
|
||||
<Widget type="Widget" skin="MW_Box" position="0 0 50 50">
|
||||
<Widget type="ImageBox" skin="ImageBox" position="9 9 32 32" name="Apparatus1"/>
|
||||
</Widget>
|
||||
<Widget type="ItemWidget" skin="MW_ItemIconBox" position="0 0 50 50" name="Apparatus1"/>
|
||||
|
||||
<Widget type="Widget" skin="MW_Box" position="60 0 50 50">
|
||||
<Widget type="ImageBox" skin="ImageBox" position="9 9 32 32" name="Apparatus2"/>
|
||||
</Widget>
|
||||
<Widget type="ItemWidget" skin="MW_ItemIconBox" position="60 0 50 50" name="Apparatus2"/>
|
||||
|
||||
<Widget type="Widget" skin="MW_Box" position="120 0 50 50">
|
||||
<Widget type="ImageBox" skin="ImageBox" position="9 9 32 32" name="Apparatus3"/>
|
||||
</Widget>
|
||||
<Widget type="ItemWidget" skin="MW_ItemIconBox" position="120 0 50 50" name="Apparatus3"/>
|
||||
|
||||
<Widget type="Widget" skin="MW_Box" position="180 0 50 50">
|
||||
<Widget type="ImageBox" skin="ImageBox" position="9 9 32 32" name="Apparatus4"/>
|
||||
</Widget>
|
||||
<Widget type="ItemWidget" skin="MW_ItemIconBox" position="180 0 50 50" name="Apparatus4"/>
|
||||
|
||||
</Widget>
|
||||
|
||||
|
@ -51,21 +43,13 @@
|
|||
|
||||
<Widget type="Widget" skin="" position="10 146 260 50">
|
||||
|
||||
<Widget type="Widget" skin="MW_Box" position="0 0 50 50">
|
||||
<Widget type="ImageBox" skin="ImageBox" position="9 9 32 32" name="Ingredient1"/>
|
||||
</Widget>
|
||||
<Widget type="ItemWidget" skin="MW_ItemIconBox" position="0 0 50 50" name="Ingredient1"/>
|
||||
|
||||
<Widget type="Widget" skin="MW_Box" position="60 0 50 50">
|
||||
<Widget type="ImageBox" skin="ImageBox" position="9 9 32 32" name="Ingredient2"/>
|
||||
</Widget>
|
||||
<Widget type="ItemWidget" skin="MW_ItemIconBox" position="60 0 50 50" name="Ingredient2"/>
|
||||
|
||||
<Widget type="Widget" skin="MW_Box" position="120 0 50 50">
|
||||
<Widget type="ImageBox" skin="ImageBox" position="9 9 32 32" name="Ingredient3"/>
|
||||
</Widget>
|
||||
<Widget type="ItemWidget" skin="MW_ItemIconBox" position="120 0 50 50" name="Ingredient3"/>
|
||||
|
||||
<Widget type="Widget" skin="MW_Box" position="180 0 50 50">
|
||||
<Widget type="ImageBox" skin="ImageBox" position="9 9 32 32" name="Ingredient4"/>
|
||||
</Widget>
|
||||
<Widget type="ItemWidget" skin="MW_ItemIconBox" position="180 0 50 50" name="Ingredient4"/>
|
||||
|
||||
</Widget>
|
||||
|
||||
|
@ -106,4 +90,4 @@
|
|||
</Widget>
|
||||
|
||||
</Widget>
|
||||
</MyGUI>
|
||||
</MyGUI>
|
||||
|
|
|
@ -73,4 +73,9 @@ as around the sections of the stats window, or around popup info windows -->
|
|||
<Child type="Widget" skin="IB_BL" offset="0 514 2 2" align="Bottom Left"/>
|
||||
<Child type="Widget" skin="IB_BR" offset="514 514 2 2" align="Bottom Right"/>
|
||||
</Skin>
|
||||
|
||||
<Skin name="MW_Box_Overlay" size="516 516">
|
||||
<Property key="NeedMouse" value="false"/>
|
||||
<Child type="Widget" skin="MW_Box" offset="0 0 516 516" align="Stretch"/>
|
||||
</Skin>
|
||||
</MyGUI>
|
||||
|
|
|
@ -26,8 +26,7 @@
|
|||
<Widget type="AutoSizedTextBox" skin="NormalText">
|
||||
<Property key="Caption" value="#{sItem}"/>
|
||||
</Widget>
|
||||
<Widget type="Widget" skin="MW_Box" position="0 0 50 50">
|
||||
<Widget type="ImageBox" skin="ImageBox" position="9 9 32 32" name="ItemBox"/>
|
||||
<Widget type="ItemWidget" skin="MW_ItemIconBox" position="0 0 50 50" name="ItemBox">
|
||||
</Widget>
|
||||
|
||||
<Widget type="Widget" position="0 0 8 0"/>
|
||||
|
@ -35,8 +34,7 @@
|
|||
<Widget type="AutoSizedTextBox" skin="NormalText">
|
||||
<Property key="Caption" value="#{sSoulGem}"/>
|
||||
</Widget>
|
||||
<Widget type="Button" skin="MW_Box" position="0 0 50 50">
|
||||
<Widget type="ImageBox" skin="ImageBox" position="9 9 32 32" name="SoulBox"/>
|
||||
<Widget type="ItemWidget" skin="MW_ItemIconBox" position="0 0 50 50" name="SoulBox">
|
||||
</Widget>
|
||||
|
||||
</Widget>
|
||||
|
|
|
@ -59,7 +59,7 @@
|
|||
<Widget type="Button" skin="" position="82 146 36 41" align="Left Bottom" name="WeapBox">
|
||||
<Widget type="Widget" skin="HUD_Box" position="0 0 36 36">
|
||||
<Property key="NeedMouse" value="false"/>
|
||||
<Widget type="ImageBox" skin="ImageBox" position="2 2 32 32" align="Left Top" name="WeapImage">
|
||||
<Widget type="ItemWidget" skin="MW_ItemIcon" position="-3 -3 42 42" align="Left Top" name="WeapImage">
|
||||
<Property key="NeedMouse" value="false"/>
|
||||
</Widget>
|
||||
</Widget>
|
||||
|
@ -71,7 +71,7 @@
|
|||
<!-- Selected spell box -->
|
||||
<Widget type="Button" position="122 146 36 41" align="Left Bottom" name="SpellBox">
|
||||
<Widget type="Widget" skin="HUD_Box" position="0 0 36 36">
|
||||
<Widget type="ImageBox" skin="ImageBox" position="2 2 32 32" align="Left Top" name="SpellImage"/>
|
||||
<Widget type="ItemWidget" skin="MW_ItemIcon" position="-3 -3 42 42" align="Left Top" name="SpellImage"/>
|
||||
<Property key="NeedMouse" value="false"/>
|
||||
</Widget>
|
||||
<Widget type="ProgressBar" skin="MW_EnergyBar_Red" position="0 36 36 6" align="Left Bottom" name="SpellStatus">
|
||||
|
|
|
@ -17,16 +17,16 @@
|
|||
|
||||
<Widget type="Widget" skin="" position="15 55 332 128" align="Left Bottom HCenter">
|
||||
|
||||
<Widget type="Button" skin="MW_Box" position="0 0 60 59" name="QuickKey1"/>
|
||||
<Widget type="Button" skin="MW_Box" position="68 0 60 59" name="QuickKey2"/>
|
||||
<Widget type="Button" skin="MW_Box" position="136 0 60 59" name="QuickKey3"/>
|
||||
<Widget type="Button" skin="MW_Box" position="204 0 60 59" name="QuickKey4"/>
|
||||
<Widget type="Button" skin="MW_Box" position="272 0 60 59" name="QuickKey5"/>
|
||||
<Widget type="Button" skin="MW_Box" position="0 67 60 59" name="QuickKey6"/>
|
||||
<Widget type="Button" skin="MW_Box" position="68 67 60 59" name="QuickKey7"/>
|
||||
<Widget type="Button" skin="MW_Box" position="136 67 60 59" name="QuickKey8"/>
|
||||
<Widget type="Button" skin="MW_Box" position="204 67 60 59" name="QuickKey9"/>
|
||||
<Widget type="Button" skin="MW_Box" position="272 67 60 59" name="QuickKey10"/>
|
||||
<Widget type="ItemWidget" skin="MW_ItemIconBox" position="0 0 60 59" name="QuickKey1"/>
|
||||
<Widget type="ItemWidget" skin="MW_ItemIconBox" position="68 0 60 59" name="QuickKey2"/>
|
||||
<Widget type="ItemWidget" skin="MW_ItemIconBox" position="136 0 60 59" name="QuickKey3"/>
|
||||
<Widget type="ItemWidget" skin="MW_ItemIconBox" position="204 0 60 59" name="QuickKey4"/>
|
||||
<Widget type="ItemWidget" skin="MW_ItemIconBox" position="272 0 60 59" name="QuickKey5"/>
|
||||
<Widget type="ItemWidget" skin="MW_ItemIconBox" position="0 67 60 59" name="QuickKey6"/>
|
||||
<Widget type="ItemWidget" skin="MW_ItemIconBox" position="68 67 60 59" name="QuickKey7"/>
|
||||
<Widget type="ItemWidget" skin="MW_ItemIconBox" position="136 67 60 59" name="QuickKey8"/>
|
||||
<Widget type="ItemWidget" skin="MW_ItemIconBox" position="204 67 60 59" name="QuickKey9"/>
|
||||
<Widget type="ItemWidget" skin="MW_ItemIconBox" position="272 67 60 59" name="QuickKey10"/>
|
||||
|
||||
</Widget>
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
<Widget type="Window" skin="MW_Dialog" layer="Windows" position="0 0 329 253" name="_Main">
|
||||
|
||||
<Widget type="Widget" skin="" position="4 4 321 42" name="GemBox">
|
||||
<Widget type="ImageBox" skin="ImageBox" position="5 6 32 32" name="GemIcon"/>
|
||||
<Widget type="ItemWidget" skin="MW_ItemIconSmall" position="5 6 32 32" name="GemIcon"/>
|
||||
|
||||
<Widget type="TextBox" skin="SandText" position="55 13 250 18" name="ChargeLabel">
|
||||
<Property key="Caption" value="#{sQuality}"/>
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
<Widget type="Window" skin="MW_Dialog" layer="Windows" position="0 0 329 253" name="_Main">
|
||||
|
||||
<Widget type="Widget" skin="" position="4 4 321 42" name="ToolBox">
|
||||
<Widget type="ImageBox" skin="ImageBox" position="5 6 32 32" name="ToolIcon"/>
|
||||
<Widget type="ItemWidget" skin="MW_ItemIconSmall" position="5 6 32 32" name="ToolIcon"/>
|
||||
|
||||
<Widget type="AutoSizedTextBox" skin="SandText" position="55 13 300 18" name="UsesLabel">
|
||||
<Property key="Caption" value="#{sUses}"/>
|
||||
|
|
|
@ -319,4 +319,30 @@
|
|||
</Widget>
|
||||
</Resource>
|
||||
|
||||
<Resource type="ResourceLayout" name="MW_ItemIcon" version="3.2.0">
|
||||
<Widget type="Widget" skin="" position="0 0 42 42" name="Root">
|
||||
<Widget type="ImageBox" skin="ImageBox" position="0 0 42 42" align="Stretch" name="Frame">
|
||||
<Widget type="ImageBox" skin="ImageBox" position="5 5 32 32" align="Stretch" name="Item"/>
|
||||
</Widget>
|
||||
</Widget>
|
||||
</Resource>
|
||||
|
||||
<Resource type="ResourceLayout" name="MW_ItemIconSmall" version="3.2.0">
|
||||
<Widget type="Widget" skin="" position="0 0 32 32" name="Root">
|
||||
<Widget type="ImageBox" skin="ImageBox" position="0 0 32 32" align="Stretch" name="Frame">
|
||||
<Widget type="ImageBox" skin="ImageBox" position="0 0 32 32" align="Stretch" name="Item"/>
|
||||
</Widget>
|
||||
</Widget>
|
||||
</Resource>
|
||||
|
||||
<Resource type="ResourceLayout" name="MW_ItemIconBox" version="3.2.0">
|
||||
<Widget type="Widget" skin="" position="0 0 50 50" name="Root">
|
||||
<Widget type="ImageBox" skin="ImageBox" position="4 4 42 42" align="Center" name="Frame">
|
||||
<Widget type="ImageBox" skin="ImageBox" position="5 5 32 32" align="Center" name="Item"/>
|
||||
</Widget>
|
||||
|
||||
<Widget type="Widget" skin="MW_Box_Overlay" position="0 0 50 50" align="Stretch"/>
|
||||
</Widget>
|
||||
</Resource>
|
||||
|
||||
</MyGUI>
|
||||
|
|
Loading…
Reference in a new issue