diff --git a/apps/openmw/mwgui/hud.cpp b/apps/openmw/mwgui/hud.cpp index ffee9f6c7f..47bf277992 100644 --- a/apps/openmw/mwgui/hud.cpp +++ b/apps/openmw/mwgui/hud.cpp @@ -6,10 +6,14 @@ #include +#include "../mwbase/environment.hpp" + +#include "window_manager.hpp" +#include "container.hpp" using namespace MWGui; -HUD::HUD(int width, int height, int fpsLevel) +HUD::HUD(int width, int height, int fpsLevel, DragAndDrop* dragAndDrop) : Layout("openmw_hud_layout.xml") , health(NULL) , magicka(NULL) @@ -32,6 +36,7 @@ HUD::HUD(int width, int height, int fpsLevel) , spellBoxBaseLeft(0) , effectBoxBaseRight(0) , minimapBoxBaseRight(0) + , mDragAndDrop(dragAndDrop) { setCoord(0,0, width, height); @@ -80,6 +85,8 @@ HUD::HUD(int width, int height, int fpsLevel) setEffect("icons\\s\\tx_s_chameleon.dds"); LocalMapBase::init(minimap, this); + + mMainWidget->eventMouseButtonClick += MyGUI::newDelegate(this, &HUD::onWorldClicked); } void HUD::setFpsLevel(int level) @@ -243,3 +250,20 @@ void HUD::setBottomRightVisibility(bool effectBoxVisible, bool minimapBoxVisible effectBox->setVisible(effectBoxVisible); } +void HUD::onWorldClicked(MyGUI::Widget* _sender) +{ + if (mDragAndDrop->mIsOnDragAndDrop) + { + // drop item into the gameworld + + + mDragAndDrop->mStore.clear(); + mDragAndDrop->mIsOnDragAndDrop = false; + MyGUI::Gui::getInstance().destroyWidget(mDragAndDrop->mDraggedWidget); + mDragAndDrop->mDraggedWidget = 0; + mDragAndDrop->mContainerWindow = 0; + + MWBase::Environment::get().getWindowManager()->setDragDrop(false); + } +} + diff --git a/apps/openmw/mwgui/hud.hpp b/apps/openmw/mwgui/hud.hpp index 831707511e..22b1b87385 100644 --- a/apps/openmw/mwgui/hud.hpp +++ b/apps/openmw/mwgui/hud.hpp @@ -6,10 +6,12 @@ namespace MWGui { + class DragAndDrop; + class HUD : public OEngine::GUI::Layout, public LocalMapBase { public: - HUD(int width, int height, int fpsLevel); + HUD(int width, int height, int fpsLevel, DragAndDrop* dragAndDrop); void setStats(int h, int hmax, int m, int mmax, int s, int smax); void setWeapIcon(const char *str); void setSpellIcon(const char *str); @@ -46,5 +48,9 @@ namespace MWGui int hmsBaseLeft, weapBoxBaseLeft, spellBoxBaseLeft; // bottom right elements int minimapBoxBaseRight, effectBoxBaseRight; + + DragAndDrop* mDragAndDrop; + + void onWorldClicked(MyGUI::Widget* _sender); }; } diff --git a/apps/openmw/mwgui/window_manager.cpp b/apps/openmw/mwgui/window_manager.cpp index 290e0029a5..bb533e698f 100644 --- a/apps/openmw/mwgui/window_manager.cpp +++ b/apps/openmw/mwgui/window_manager.cpp @@ -99,7 +99,6 @@ WindowManager::WindowManager( mDragAndDrop->mDragAndDropWidget = dragAndDropWidget; mDragAndDrop->mContainerWindow = 0; - hud = new HUD(w,h, showFPSLevel); menu = new MainMenu(w,h); map = new MapWindow(*this); stats = new StatsWindow(*this); @@ -109,6 +108,7 @@ WindowManager::WindowManager( mDialogueWindow = new DialogueWindow(*this); mContainerWindow = new ContainerWindow(*this,mDragAndDrop); mInventoryWindow = new InventoryWindow(*this,mDragAndDrop); + hud = new HUD(w,h, showFPSLevel, mDragAndDrop); mToolTips = new ToolTips(this); mScrollWindow = new ScrollWindow(*this); mBookWindow = new BookWindow(*this);