forked from mirror/openmw-tes3mp
some work for dropping objects.
This commit is contained in:
parent
5603cb312c
commit
5f8c08b18b
6 changed files with 93 additions and 62 deletions
|
@ -24,10 +24,10 @@ using namespace MWGui;
|
|||
using namespace Widgets;
|
||||
|
||||
|
||||
ContainerWindow::ContainerWindow(WindowManager& parWindowManager,MWWorld::Environment& environment,MyGUI::Widget* dragAndDropWidget)
|
||||
ContainerWindow::ContainerWindow(WindowManager& parWindowManager,MWWorld::Environment& environment,DragAndDrop* dragAndDrop)
|
||||
: WindowBase("openmw_container_window_layout.xml", parWindowManager),
|
||||
mEnvironment(environment),
|
||||
mDragAndDropWidget(dragAndDropWidget)
|
||||
mDragAndDrop(dragAndDrop)
|
||||
{
|
||||
setText("_Main", "Name of Container");
|
||||
|
||||
|
@ -42,27 +42,23 @@ ContainerWindow::ContainerWindow(WindowManager& parWindowManager,MWWorld::Enviro
|
|||
getWidget(closeButton, "CloseButton");
|
||||
|
||||
closeButton->eventMouseButtonClick += MyGUI::newDelegate(this, &ContainerWindow::onByeClicked);
|
||||
|
||||
mContainerWidget->eventMouseButtonClick += MyGUI::newDelegate(this, &ContainerWindow::onContainerClicked);
|
||||
setText("CloseButton","Close");
|
||||
setText("TakeButton","Take All");
|
||||
|
||||
mIsOnDragAndDrop = false;
|
||||
mDraggedWidget = 0;
|
||||
//mContainerWidget->eventMouseItemActivate += MyGUI::newDelegate(this,&ContainerWindow::onSelectedItem);
|
||||
}
|
||||
|
||||
ContainerWindow::ContainerWindow(WindowManager& parWindowManager,MWWorld::Environment& environment,MyGUI::Widget* dragAndDropWidget,std::string guiFile)
|
||||
ContainerWindow::ContainerWindow(WindowManager& parWindowManager,MWWorld::Environment& environment,DragAndDrop* dragAndDrop,std::string guiFile)
|
||||
: WindowBase(guiFile, parWindowManager),
|
||||
mEnvironment(environment),
|
||||
mDragAndDropWidget(dragAndDropWidget)
|
||||
mDragAndDrop(dragAndDrop)
|
||||
{
|
||||
setText("_Main", "Name of Container");
|
||||
//center();
|
||||
adjustWindowCaption();
|
||||
getWidget(mContainerWidget, "Items");
|
||||
|
||||
mIsOnDragAndDrop = false;
|
||||
mDraggedWidget = 0;
|
||||
mContainerWidget->eventMouseButtonClick += MyGUI::newDelegate(this, &ContainerWindow::onContainerClicked);
|
||||
//getWidget(takeButton, "TakeButton");
|
||||
//getWidget(closeButton, "CloseButton");
|
||||
|
||||
|
@ -151,7 +147,7 @@ void ContainerWindow::open(MWWorld::Ptr& container)
|
|||
if(iter->getRefData().getCount() > 1)
|
||||
text->setCaption(boost::lexical_cast<std::string>(iter->getRefData().getCount()));
|
||||
|
||||
//mContainerWidgets.push_back(image);
|
||||
//mContainerWidgets
|
||||
|
||||
int pos = path.rfind(".");
|
||||
path.erase(pos);
|
||||
|
@ -168,37 +164,56 @@ void ContainerWindow::open(MWWorld::Ptr& container)
|
|||
|
||||
void ContainerWindow::Update()
|
||||
{
|
||||
if(mIsOnDragAndDrop)
|
||||
if(mDragAndDrop->mIsOnDragAndDrop)
|
||||
{
|
||||
if(mDraggedWidget)
|
||||
mDraggedWidget->setPosition(MyGUI::InputManager::getInstance().getMousePosition());
|
||||
else mIsOnDragAndDrop = false; //If this happens, there is a bug.
|
||||
if(mDragAndDrop->mDraggedWidget)
|
||||
mDragAndDrop->mDraggedWidget->setPosition(MyGUI::InputManager::getInstance().getMousePosition());
|
||||
else mDragAndDrop->mIsOnDragAndDrop = false; //If this happens, there is a bug.
|
||||
}
|
||||
}
|
||||
|
||||
void ContainerWindow::onByeClicked(MyGUI::Widget* _sender)
|
||||
{
|
||||
mEnvironment.mWindowManager->setGuiMode(GM_Game);
|
||||
|
||||
setVisible(false);
|
||||
if(!mDragAndDrop->mIsOnDragAndDrop)
|
||||
{
|
||||
mEnvironment.mWindowManager->setGuiMode(GM_Game);
|
||||
setVisible(false);
|
||||
}
|
||||
}
|
||||
|
||||
void ContainerWindow::onSelectedItem(MyGUI::Widget* _sender)
|
||||
{
|
||||
mIsOnDragAndDrop = true;
|
||||
_sender->detachFromWidget();
|
||||
_sender->attachToWidget(mDragAndDropWidget);
|
||||
//std::cout << mContainerWidget->getParent()->getParent()->getName();
|
||||
_sender->setUserString("drag","on");
|
||||
mDraggedWidget = _sender;
|
||||
std::cout << "selected!";
|
||||
if(!mDragAndDrop->mIsOnDragAndDrop)
|
||||
{
|
||||
mDragAndDrop->mIsOnDragAndDrop = true;
|
||||
_sender->detachFromWidget();
|
||||
_sender->attachToWidget(mDragAndDrop->mDragAndDropWidget);
|
||||
//std::cout << mContainerWidget->getParent()->getParent()->getName();
|
||||
_sender->setUserString("drag","on");
|
||||
mDragAndDrop->mDraggedWidget = _sender;
|
||||
mDragAndDrop->mContainerWindow = const_cast<MWGui::ContainerWindow*>(this);
|
||||
std::cout << "selected!";
|
||||
}
|
||||
}
|
||||
|
||||
void ContainerWindow::onMouseMove(MyGUI::Widget* _sender, int _left, int _top)
|
||||
{
|
||||
/*if(_sender->getUserString("drag") == "on")
|
||||
{
|
||||
_sender->setPosition(_left,_top);
|
||||
|
||||
_sender->setPosition(_left,_top);
|
||||
|
||||
}*/
|
||||
}
|
||||
|
||||
void ContainerWindow::onContainerClicked(MyGUI::Widget* _sender)
|
||||
{
|
||||
std::cout << "container clicked";
|
||||
if(mDragAndDrop->mIsOnDragAndDrop) //drop widget here
|
||||
{
|
||||
mDragAndDrop->mIsOnDragAndDrop = false;
|
||||
mDragAndDrop->mDraggedWidget->detachFromWidget();
|
||||
mDragAndDrop->mDraggedWidget->attachToWidget(mContainerWidget);
|
||||
mDragAndDrop->mDraggedWidget = 0;
|
||||
mDragAndDrop->mContainerWindow = 0;
|
||||
}
|
||||
}
|
|
@ -18,47 +18,54 @@ namespace MWWorld
|
|||
|
||||
namespace MyGUI
|
||||
{
|
||||
class Gui;
|
||||
class Widget;
|
||||
class Gui;
|
||||
class Widget;
|
||||
}
|
||||
|
||||
namespace MWGui
|
||||
{
|
||||
class WindowManager;
|
||||
class ContainerWindow;
|
||||
}
|
||||
|
||||
|
||||
namespace MWGui
|
||||
{
|
||||
|
||||
class DragAndDrop
|
||||
{
|
||||
public:
|
||||
bool mIsOnDragAndDrop;
|
||||
ContainerWindow* mContainerWindow;
|
||||
MyGUI::Widget* mDraggedWidget;
|
||||
MyGUI::Widget* mDragAndDropWidget;
|
||||
};
|
||||
|
||||
class ContainerWindow : public WindowBase
|
||||
{
|
||||
public:
|
||||
ContainerWindow(WindowManager& parWindowManager,MWWorld::Environment& environment,MyGUI::Widget* dragAndDropWidget);
|
||||
ContainerWindow(WindowManager& parWindowManager,MWWorld::Environment& environment,MyGUI::Widget* dragAndDropWidget,
|
||||
std::string guiFile);
|
||||
public:
|
||||
ContainerWindow(WindowManager& parWindowManager,MWWorld::Environment& environment,DragAndDrop* dragAndDrop);
|
||||
ContainerWindow(WindowManager& parWindowManager,MWWorld::Environment& environment,DragAndDrop* dragAndDrop,
|
||||
std::string guiFile);
|
||||
|
||||
|
||||
void open(MWWorld::Ptr& container);
|
||||
void setName(std::string contName);
|
||||
void Update();
|
||||
void open(MWWorld::Ptr& container);
|
||||
void setName(std::string contName);
|
||||
void Update();
|
||||
|
||||
virtual ~ContainerWindow();
|
||||
virtual ~ContainerWindow();
|
||||
|
||||
protected:
|
||||
protected:
|
||||
MWWorld::Environment& mEnvironment;
|
||||
std::vector<MyGUI::WidgetPtr> mContainerWidgets;
|
||||
MyGUI::ItemBoxPtr mContainerWidget;
|
||||
|
||||
MyGUI::ButtonPtr takeButton;
|
||||
MyGUI::ButtonPtr closeButton;
|
||||
MyGUI::Widget* mDragAndDropWidget;
|
||||
bool mIsOnDragAndDrop;
|
||||
MyGUI::Widget* mDraggedWidget;
|
||||
DragAndDrop* mDragAndDrop;
|
||||
|
||||
void onByeClicked(MyGUI::Widget* _sender);
|
||||
void onSelectedItem(MyGUI::Widget* _sender);
|
||||
void onContainerClicked(MyGUI::Widget* _sender);
|
||||
void onMouseMove(MyGUI::Widget* _sender, int _left, int _top);
|
||||
|
||||
//MWWorld::Ptr& mContainer;
|
||||
|
|
|
@ -21,8 +21,8 @@
|
|||
namespace MWGui
|
||||
{
|
||||
|
||||
InventoryWindow::InventoryWindow(WindowManager& parWindowManager,MWWorld::Environment& environment,MyGUI::Widget* dragAndDropWidget)
|
||||
:ContainerWindow(parWindowManager,environment,dragAndDropWidget,"openmw_inventory_window_layout.xml")
|
||||
InventoryWindow::InventoryWindow(WindowManager& parWindowManager,MWWorld::Environment& environment,DragAndDrop* dragAndDrop)
|
||||
:ContainerWindow(parWindowManager,environment,dragAndDrop,"openmw_inventory_window_layout.xml")
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ namespace MWGui
|
|||
class InventoryWindow : public MWGui::ContainerWindow
|
||||
{
|
||||
public:
|
||||
InventoryWindow(WindowManager& parWindowManager,MWWorld::Environment& environment,MyGUI::Widget* dragAndDropWidget);
|
||||
InventoryWindow(WindowManager& parWindowManager,MWWorld::Environment& environment,DragAndDrop* dragAndDrop);
|
||||
|
||||
void openInventory();
|
||||
};
|
||||
|
|
|
@ -36,7 +36,7 @@ WindowManager::WindowManager(MWWorld::Environment& environment,
|
|||
, mMessageBoxManager(NULL)
|
||||
, console(NULL)
|
||||
, mJournal(NULL)
|
||||
, dialogueWindow(nullptr)
|
||||
, mDialogueWindow(nullptr)
|
||||
, mCharGen(NULL)
|
||||
, playerClass()
|
||||
, playerName()
|
||||
|
@ -77,6 +77,12 @@ WindowManager::WindowManager(MWWorld::Environment& environment,
|
|||
MyGUI::Widget* dragAndDropWidget = gui->createWidgetT("Widget","",0,0,w,h,MyGUI::Align::Default,"DragAndDrop","DragAndDropWidget");
|
||||
dragAndDropWidget->setVisible(false);
|
||||
|
||||
DragAndDrop* mDragAndDrop = new DragAndDrop();
|
||||
mDragAndDrop->mIsOnDragAndDrop = false;
|
||||
mDragAndDrop->mDraggedWidget = 0;
|
||||
mDragAndDrop->mDragAndDropWidget = dragAndDropWidget;
|
||||
mDragAndDrop->mContainerWindow = 0;
|
||||
|
||||
hud = new HUD(w,h, showFPSLevel);
|
||||
menu = new MainMenu(w,h);
|
||||
map = new MapWindow(*this);
|
||||
|
@ -84,9 +90,9 @@ WindowManager::WindowManager(MWWorld::Environment& environment,
|
|||
console = new Console(w,h, environment, extensions);
|
||||
mJournal = new JournalWindow(*this);
|
||||
mMessageBoxManager = new MessageBoxManager(this);
|
||||
dialogueWindow = new DialogueWindow(*this,environment);
|
||||
containerWindow = new ContainerWindow(*this,environment,dragAndDropWidget);
|
||||
mInventoryWindow = new InventoryWindow(*this,environment,dragAndDropWidget);
|
||||
mDialogueWindow = new DialogueWindow(*this,environment);
|
||||
mContainerWindow = new ContainerWindow(*this,environment,mDragAndDrop);
|
||||
mInventoryWindow = new InventoryWindow(*this,environment,mDragAndDrop);
|
||||
|
||||
// The HUD is always on
|
||||
hud->setVisible(true);
|
||||
|
@ -124,10 +130,11 @@ WindowManager::~WindowManager()
|
|||
delete menu;
|
||||
delete stats;
|
||||
delete mJournal;
|
||||
delete dialogueWindow;
|
||||
delete containerWindow;
|
||||
delete mDialogueWindow;
|
||||
delete mContainerWindow;
|
||||
delete mInventoryWindow;
|
||||
delete mCharGen;
|
||||
delete mDragAndDrop;
|
||||
|
||||
cleanupGarbage();
|
||||
}
|
||||
|
@ -186,8 +193,8 @@ void WindowManager::updateVisible()
|
|||
stats->setVisible(false);
|
||||
console->disable();
|
||||
mJournal->setVisible(false);
|
||||
dialogueWindow->setVisible(false);
|
||||
containerWindow->setVisible(false);
|
||||
mDialogueWindow->setVisible(false);
|
||||
mContainerWindow->setVisible(false);
|
||||
mInventoryWindow->setVisible(false);
|
||||
|
||||
// Mouse is visible whenever we're not in game mode
|
||||
|
@ -229,12 +236,12 @@ void WindowManager::updateVisible()
|
|||
break;
|
||||
}
|
||||
case GM_Container:
|
||||
containerWindow->setVisible(true);
|
||||
mContainerWindow->setVisible(true);
|
||||
mInventoryWindow->setVisible(true);
|
||||
mInventoryWindow->openInventory();
|
||||
break;
|
||||
case GM_Dialogue:
|
||||
dialogueWindow->open();
|
||||
mDialogueWindow->open();
|
||||
break;
|
||||
case GM_InterMessageBox:
|
||||
if(!mMessageBoxManager->isInteractiveMessageBox()) {
|
||||
|
@ -413,11 +420,11 @@ const std::string &WindowManager::getGameSettingString(const std::string &id, co
|
|||
|
||||
void WindowManager::onDialogueWindowBye()
|
||||
{
|
||||
if (dialogueWindow)
|
||||
if (mDialogueWindow)
|
||||
{
|
||||
//FIXME set some state and stuff?
|
||||
//removeDialog(dialogueWindow);
|
||||
dialogueWindow->setVisible(false);
|
||||
mDialogueWindow->setVisible(false);
|
||||
}
|
||||
setGuiMode(GM_Game);
|
||||
}
|
||||
|
@ -426,7 +433,7 @@ void WindowManager::onFrame (float frameDuration)
|
|||
{
|
||||
mMessageBoxManager->onFrame(frameDuration);
|
||||
mInventoryWindow->Update();
|
||||
containerWindow->Update();
|
||||
mContainerWindow->Update();
|
||||
}
|
||||
|
||||
const ESMS::ESMStore& WindowManager::getStore() const
|
||||
|
|
|
@ -63,6 +63,7 @@ namespace MWGui
|
|||
class JournalWindow;
|
||||
class CharacterCreation;
|
||||
class ContainerWindow;
|
||||
class DragAndDrop;
|
||||
class InventoryWindow;
|
||||
class TextInputDialog;
|
||||
class InfoBoxDialog;
|
||||
|
@ -126,9 +127,9 @@ namespace MWGui
|
|||
updateVisible();
|
||||
}
|
||||
|
||||
MWGui::DialogueWindow* getDialogueWindow() {return dialogueWindow;}
|
||||
MWGui::DialogueWindow* getDialogueWindow() {return mDialogueWindow;}
|
||||
|
||||
MWGui::ContainerWindow* getContainerWindow() {return containerWindow;}
|
||||
MWGui::ContainerWindow* getContainerWindow() {return mContainerWindow;}
|
||||
|
||||
MyGUI::Gui* getGui() const { return gui; }
|
||||
|
||||
|
@ -203,8 +204,9 @@ namespace MWGui
|
|||
MessageBoxManager *mMessageBoxManager;
|
||||
Console *console;
|
||||
JournalWindow* mJournal;
|
||||
DialogueWindow *dialogueWindow;
|
||||
ContainerWindow *containerWindow;
|
||||
DialogueWindow *mDialogueWindow;
|
||||
ContainerWindow *mContainerWindow;
|
||||
DragAndDrop* mDragAndDrop;
|
||||
InventoryWindow *mInventoryWindow;
|
||||
CharacterCreation* mCharGen;
|
||||
|
||||
|
|
Loading…
Reference in a new issue