inventory window pinning

actorid
scrawl 13 years ago
parent 822e5fbe1e
commit 78b06d0ebf

@ -26,14 +26,16 @@ using namespace MWGui;
using namespace Widgets; using namespace Widgets;
ContainerBase::ContainerBase(WindowManager& parWindowManager,DragAndDrop* dragAndDrop,std::string guiFile) ContainerBase::ContainerBase(DragAndDrop* dragAndDrop) :
: WindowBase(guiFile, parWindowManager),
mDragAndDrop(dragAndDrop), mDragAndDrop(dragAndDrop),
mFilter(ContainerBase::Filter_All), mFilter(ContainerBase::Filter_All)
mContainer()
{ {
getWidget(mContainerWidget, "Items"); }
getWidget(mItemView, "ItemView");
void ContainerBase::setWidgets(Widget* containerWidget, ScrollView* itemView)
{
mContainerWidget = containerWidget;
mItemView = itemView;
mContainerWidget->eventMouseButtonClick += MyGUI::newDelegate(this, &ContainerBase::onContainerClicked); mContainerWidget->eventMouseButtonClick += MyGUI::newDelegate(this, &ContainerBase::onContainerClicked);
} }
@ -90,24 +92,16 @@ void ContainerBase::onContainerClicked(MyGUI::Widget* _sender)
} }
} }
void ContainerBase::setName(std::string contName)
{
setText("_Main", contName);
adjustWindowCaption();
}
void ContainerBase::setFilter(ContainerBase::Filter filter) void ContainerBase::setFilter(ContainerBase::Filter filter)
{ {
mFilter = filter; mFilter = filter;
drawItems(); drawItems();
} }
void ContainerBase::open(MWWorld::Ptr container) void ContainerBase::openContainer(MWWorld::Ptr container)
{ {
mContainer = container; mContainer = container;
setName(MWWorld::Class::get(container).getName(container));
drawItems(); drawItems();
setVisible(true);
} }
void ContainerBase::drawItems() void ContainerBase::drawItems()
@ -206,11 +200,18 @@ void ContainerBase::Update()
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
ContainerWindow::ContainerWindow(WindowManager& parWindowManager,DragAndDrop* dragAndDrop) ContainerWindow::ContainerWindow(WindowManager& parWindowManager,DragAndDrop* dragAndDrop)
: ContainerBase(parWindowManager, dragAndDrop, "openmw_container_window_layout.xml") : ContainerBase(dragAndDrop)
, WindowBase("openmw_container_window_layout.xml", parWindowManager)
{ {
getWidget(mTakeButton, "TakeButton"); getWidget(mTakeButton, "TakeButton");
getWidget(mCloseButton, "CloseButton"); getWidget(mCloseButton, "CloseButton");
MyGUI::ScrollView* itemView;
MyGUI::Widget* containerWidget;
getWidget(containerWidget, "Items");
getWidget(itemView, "ItemView");
setWidgets(containerWidget, itemView);
mCloseButton->eventMouseButtonClick += MyGUI::newDelegate(this, &ContainerWindow::onCloseButtonClicked); mCloseButton->eventMouseButtonClick += MyGUI::newDelegate(this, &ContainerWindow::onCloseButtonClicked);
mTakeButton->eventMouseButtonClick += MyGUI::newDelegate(this, &ContainerWindow::onTakeAllButtonClicked); mTakeButton->eventMouseButtonClick += MyGUI::newDelegate(this, &ContainerWindow::onTakeAllButtonClicked);
@ -239,6 +240,12 @@ void ContainerWindow::onWindowResize(MyGUI::Window* window)
drawItems(); drawItems();
} }
void ContainerWindow::open(MWWorld::Ptr container)
{
openContainer(container);
setTitle(MWWorld::Class::get(container).getName(container));
}
void ContainerWindow::onCloseButtonClicked(MyGUI::Widget* _sender) void ContainerWindow::onCloseButtonClicked(MyGUI::Widget* _sender)
{ {
if(!mDragAndDrop->mIsOnDragAndDrop) if(!mDragAndDrop->mIsOnDragAndDrop)

@ -44,10 +44,10 @@ namespace MWGui
MWWorld::Ptr mItem; MWWorld::Ptr mItem;
}; };
class ContainerBase : public WindowBase class ContainerBase
{ {
public: public:
ContainerBase(WindowManager& parWindowManager, DragAndDrop* dragAndDrop, std::string guiFile); ContainerBase(DragAndDrop* dragAndDrop);
virtual ~ContainerBase(); virtual ~ContainerBase();
enum Filter enum Filter
@ -59,8 +59,9 @@ namespace MWGui
Filter_Misc = 0x05 Filter_Misc = 0x05
}; };
void open(MWWorld::Ptr container); void setWidgets(MyGUI::Widget* containerWidget, MyGUI::ScrollView* itemView); ///< only call once
void setName(std::string contName);
void openContainer(MWWorld::Ptr container);
void setFilter(Filter filter); ///< set category filter void setFilter(Filter filter); ///< set category filter
void Update(); void Update();
@ -79,13 +80,15 @@ namespace MWGui
void drawItems(); void drawItems();
}; };
class ContainerWindow : public ContainerBase class ContainerWindow : public ContainerBase, public WindowBase
{ {
public: public:
ContainerWindow(WindowManager& parWindowManager,DragAndDrop* dragAndDrop); ContainerWindow(WindowManager& parWindowManager,DragAndDrop* dragAndDrop);
virtual ~ContainerWindow(); virtual ~ContainerWindow();
void open(MWWorld::Ptr container);
protected: protected:
std::vector<MyGUI::WidgetPtr> mContainerWidgets; std::vector<MyGUI::WidgetPtr> mContainerWidgets;

@ -22,7 +22,8 @@ namespace MWGui
{ {
InventoryWindow::InventoryWindow(WindowManager& parWindowManager,DragAndDrop* dragAndDrop) InventoryWindow::InventoryWindow(WindowManager& parWindowManager,DragAndDrop* dragAndDrop)
: ContainerBase(parWindowManager,dragAndDrop,"openmw_inventory_window_layout.xml") : ContainerBase(dragAndDrop)
, WindowPinnableBase("openmw_inventory_window_layout.xml", parWindowManager)
{ {
static_cast<MyGUI::Window*>(mMainWidget)->eventWindowChangeCoord += MyGUI::newDelegate(this, &InventoryWindow::onWindowResize); static_cast<MyGUI::Window*>(mMainWidget)->eventWindowChangeCoord += MyGUI::newDelegate(this, &InventoryWindow::onWindowResize);
@ -35,6 +36,12 @@ namespace MWGui
getWidget(mFilterMagic, "MagicButton"); getWidget(mFilterMagic, "MagicButton");
getWidget(mFilterMisc, "MiscButton"); getWidget(mFilterMisc, "MiscButton");
MyGUI::ScrollView* itemView;
MyGUI::Widget* containerWidget;
getWidget(containerWidget, "Items");
getWidget(itemView, "ItemView");
setWidgets(containerWidget, itemView);
mFilterAll->setCaption (MWBase::Environment::get().getWorld()->getStore().gameSettings.search("sAllTab")->str); mFilterAll->setCaption (MWBase::Environment::get().getWorld()->getStore().gameSettings.search("sAllTab")->str);
mFilterWeapon->setCaption (MWBase::Environment::get().getWorld()->getStore().gameSettings.search("sWeaponTab")->str); mFilterWeapon->setCaption (MWBase::Environment::get().getWorld()->getStore().gameSettings.search("sWeaponTab")->str);
mFilterApparel->setCaption (MWBase::Environment::get().getWorld()->getStore().gameSettings.search("sApparelTab")->str); mFilterApparel->setCaption (MWBase::Environment::get().getWorld()->getStore().gameSettings.search("sApparelTab")->str);
@ -72,7 +79,7 @@ namespace MWGui
void InventoryWindow::openInventory() void InventoryWindow::openInventory()
{ {
open(MWBase::Environment::get().getWorld()->getPlayer().getPlayer()); openContainer(MWBase::Environment::get().getWorld()->getPlayer().getPlayer());
onWindowResize(static_cast<MyGUI::Window*>(mMainWidget)); onWindowResize(static_cast<MyGUI::Window*>(mMainWidget));
} }
@ -104,4 +111,9 @@ namespace MWGui
static_cast<MyGUI::Button*>(_sender)->setStateSelected(true); static_cast<MyGUI::Button*>(_sender)->setStateSelected(true);
} }
void InventoryWindow::onPinToggled()
{
mWindowManager.setWeaponVisibility(!mPinned);
}
} }

@ -2,6 +2,8 @@
#define MGUI_Inventory_H #define MGUI_Inventory_H
#include "container.hpp" #include "container.hpp"
#include "window_pinnable_base.hpp"
namespace MWWorld namespace MWWorld
{ {
class Environment; class Environment;
@ -21,7 +23,7 @@ namespace MWGui
namespace MWGui namespace MWGui
{ {
class InventoryWindow : public MWGui::ContainerBase class InventoryWindow : public ContainerBase, public WindowPinnableBase
{ {
public: public:
InventoryWindow(WindowManager& parWindowManager,DragAndDrop* dragAndDrop); InventoryWindow(WindowManager& parWindowManager,DragAndDrop* dragAndDrop);
@ -42,6 +44,7 @@ namespace MWGui
void onWindowResize(MyGUI::Window* _sender); void onWindowResize(MyGUI::Window* _sender);
void onFilterChanged(MyGUI::Widget* _sender); void onFilterChanged(MyGUI::Widget* _sender);
void onPinToggled();
}; };
} }
#endif // Inventory_H #endif // Inventory_H

@ -548,3 +548,13 @@ bool WindowManager::getFullHelp() const
{ {
return mToolTips->getFullHelp(); return mToolTips->getFullHelp();
} }
void WindowManager::setWeaponVisibility(bool visible)
{
hud->weapBox->setVisible(visible);
}
void WindowManager::setSpellVisibility(bool visible)
{
hud->spellBox->setVisible(visible);
}

@ -180,6 +180,8 @@ namespace MWGui
void setHMSVisibility(bool visible); void setHMSVisibility(bool visible);
// sets the visibility of the hud minimap // sets the visibility of the hud minimap
void setMinimapVisibility(bool visible); void setMinimapVisibility(bool visible);
void setWeaponVisibility(bool visible);
void setSpellVisibility(bool visible);
template<typename T> template<typename T>
void removeDialog(T*& dialog); ///< Casts to OEngine::GUI::Layout and calls removeDialog, then resets pointer to nullptr. void removeDialog(T*& dialog); ///< Casts to OEngine::GUI::Layout and calls removeDialog, then resets pointer to nullptr.

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<MyGUI type="Layout"> <MyGUI type="Layout">
<Widget type="Window" skin="MW_Window" layer="Windows" position="0 0 600 300" name="_Main"> <Widget type="Window" skin="MW_Window_Pinnable" layer="Windows" position="0 0 600 300" name="_Main">
<!-- Player encumbrance --> <!-- Player encumbrance -->
<Widget type="ProgressBar" skin="MW_Progress_Blue" position="8 8 212 24" name="EncumbranceBar"> <Widget type="ProgressBar" skin="MW_Progress_Blue" position="8 8 212 24" name="EncumbranceBar">

@ -115,6 +115,13 @@ namespace GUI
static_cast<MyGUI::TextBox*>(pt)->setCaption(caption); static_cast<MyGUI::TextBox*>(pt)->setCaption(caption);
} }
void setTitle(const std::string& title)
{
// NOTE: this assume that mMainWidget is of type Window.
static_cast<MyGUI::Window*>(mMainWidget)->setCaption(title);
adjustWindowCaption();
}
void setState(const std::string& widget, const std::string& state) void setState(const std::string& widget, const std::string& state)
{ {
MyGUI::Widget* pt; MyGUI::Widget* pt;

Loading…
Cancel
Save