some unfinished work for dropping objects into the gameworld

This commit is contained in:
scrawl 2012-05-13 18:35:56 +02:00
parent 967fb13fca
commit 6c9f75b322
3 changed files with 33 additions and 3 deletions

View file

@ -6,10 +6,14 @@
#include <boost/lexical_cast.hpp>
#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);
}
}

View file

@ -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);
};
}

View file

@ -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);