diff --git a/apps/openmw/mwgui/container.cpp b/apps/openmw/mwgui/container.cpp index 2de8e2bb3..8742bf4f7 100644 --- a/apps/openmw/mwgui/container.cpp +++ b/apps/openmw/mwgui/container.cpp @@ -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) diff --git a/apps/openmw/mwgui/container.hpp b/apps/openmw/mwgui/container.hpp index a8c12bb6a..7fe04cd48 100644 --- a/apps/openmw/mwgui/container.hpp +++ b/apps/openmw/mwgui/container.hpp @@ -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 mContainerWidgets; diff --git a/apps/openmw/mwgui/inventorywindow.cpp b/apps/openmw/mwgui/inventorywindow.cpp index 340c03562..560e940d8 100644 --- a/apps/openmw/mwgui/inventorywindow.cpp +++ b/apps/openmw/mwgui/inventorywindow.cpp @@ -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(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(mMainWidget)); } @@ -104,4 +111,9 @@ namespace MWGui static_cast(_sender)->setStateSelected(true); } + void InventoryWindow::onPinToggled() + { + mWindowManager.setWeaponVisibility(!mPinned); + } + } diff --git a/apps/openmw/mwgui/inventorywindow.hpp b/apps/openmw/mwgui/inventorywindow.hpp index 63188e84b..dd4ff90b6 100644 --- a/apps/openmw/mwgui/inventorywindow.hpp +++ b/apps/openmw/mwgui/inventorywindow.hpp @@ -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 diff --git a/apps/openmw/mwgui/window_manager.cpp b/apps/openmw/mwgui/window_manager.cpp index 6dfdc3bb4..249f1fcfd 100644 --- a/apps/openmw/mwgui/window_manager.cpp +++ b/apps/openmw/mwgui/window_manager.cpp @@ -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); +} diff --git a/apps/openmw/mwgui/window_manager.hpp b/apps/openmw/mwgui/window_manager.hpp index c3fb2b9f9..1ea4f267f 100644 --- a/apps/openmw/mwgui/window_manager.hpp +++ b/apps/openmw/mwgui/window_manager.hpp @@ -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 void removeDialog(T*& dialog); ///< Casts to OEngine::GUI::Layout and calls removeDialog, then resets pointer to nullptr. diff --git a/files/mygui/openmw_inventory_window_layout.xml b/files/mygui/openmw_inventory_window_layout.xml index b2b32ea2c..0e8abf45b 100644 --- a/files/mygui/openmw_inventory_window_layout.xml +++ b/files/mygui/openmw_inventory_window_layout.xml @@ -1,7 +1,7 @@ - + diff --git a/libs/openengine/gui/layout.hpp b/libs/openengine/gui/layout.hpp index bda8935af..abcc01753 100644 --- a/libs/openengine/gui/layout.hpp +++ b/libs/openengine/gui/layout.hpp @@ -115,6 +115,13 @@ namespace GUI static_cast(pt)->setCaption(caption); } + void setTitle(const std::string& title) + { + // NOTE: this assume that mMainWidget is of type Window. + static_cast(mMainWidget)->setCaption(title); + adjustWindowCaption(); + } + void setState(const std::string& widget, const std::string& state) { MyGUI::Widget* pt;