inventory window pinning

actorid
scrawl 13 years ago
parent 822e5fbe1e
commit 78b06d0ebf

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

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

@ -22,7 +22,8 @@ namespace MWGui
{
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);
@ -35,6 +36,12 @@ namespace MWGui
getWidget(mFilterMagic, "MagicButton");
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);
mFilterWeapon->setCaption (MWBase::Environment::get().getWorld()->getStore().gameSettings.search("sWeaponTab")->str);
mFilterApparel->setCaption (MWBase::Environment::get().getWorld()->getStore().gameSettings.search("sApparelTab")->str);
@ -72,7 +79,7 @@ namespace MWGui
void InventoryWindow::openInventory()
{
open(MWBase::Environment::get().getWorld()->getPlayer().getPlayer());
openContainer(MWBase::Environment::get().getWorld()->getPlayer().getPlayer());
onWindowResize(static_cast<MyGUI::Window*>(mMainWidget));
}
@ -104,4 +111,9 @@ namespace MWGui
static_cast<MyGUI::Button*>(_sender)->setStateSelected(true);
}
void InventoryWindow::onPinToggled()
{
mWindowManager.setWeaponVisibility(!mPinned);
}
}

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

@ -548,3 +548,13 @@ bool WindowManager::getFullHelp() const
{
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);
// sets the visibility of the hud minimap
void setMinimapVisibility(bool visible);
void setWeaponVisibility(bool visible);
void setSpellVisibility(bool visible);
template<typename T>
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"?>
<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 -->
<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);
}
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)
{
MyGUI::Widget* pt;

Loading…
Cancel
Save