From fc25ccef4e102d12a458a7796a1844ceffa1306b Mon Sep 17 00:00:00 2001 From: Sebastian Wick Date: Tue, 14 Jun 2011 22:11:36 +0200 Subject: [PATCH] MW_Dialog set ro right propertys --- apps/openmw/mwgui/messagebox.cpp | 25 +++++++++++++++++++ apps/openmw/mwgui/messagebox.hpp | 14 ++++++++--- apps/openmw/mwgui/window_manager.cpp | 2 +- .../openmw_messagebox_layout.xml | 5 +--- 4 files changed, 37 insertions(+), 9 deletions(-) diff --git a/apps/openmw/mwgui/messagebox.cpp b/apps/openmw/mwgui/messagebox.cpp index 78235fa8c..1a8c3c169 100644 --- a/apps/openmw/mwgui/messagebox.cpp +++ b/apps/openmw/mwgui/messagebox.cpp @@ -2,6 +2,11 @@ using namespace MWGui; +MessageBoxManager::MessageBoxManager (WindowManager *windowManager) +{ + mWindowManager = windowManager; +} + void MessageBoxManager::createMessageBox (const std::string& message) { std::cout << "create non-interactive message box" << std::endl; @@ -20,4 +25,24 @@ MessageBox::MessageBox(MessageBoxManager& parMessageBoxManager, const std::strin , mMessageBoxManager(parMessageBoxManager) { setText("message", message); + + MyGUI::WidgetPtr messageWidget; + getWidget(messageWidget, "message"); + + MyGUI::IntSize size = messageWidget->_getTextSize(); + size.width += 20; + size.height += 20; + + MyGUI::IntSize gameWindowSize = mMessageBoxManager.mWindowManager->getGui()->getViewSize(); + MyGUI::IntCoord coord; + coord.left = (gameWindowSize.width - size.width)/2; + coord.top = (gameWindowSize.height - size.height); + + + std::cout << "Setting MainWidget to position (" << coord.left << "|" << coord.top + << ") and size to (" << size.width << "|" << size.height << ")" << std::endl; + + mMainWidget->setCoord(coord); + mMainWidget->setSize(size); + } diff --git a/apps/openmw/mwgui/messagebox.hpp b/apps/openmw/mwgui/messagebox.hpp index 31286dacd..86e9cb28e 100644 --- a/apps/openmw/mwgui/messagebox.hpp +++ b/apps/openmw/mwgui/messagebox.hpp @@ -5,6 +5,7 @@ #include #include "window_base.hpp" +#include "window_manager.hpp" namespace MWGui { @@ -14,18 +15,23 @@ namespace MWGui class MessageBoxManager { - private: - std::vector mMessageBoxes; public: + MessageBoxManager (WindowManager* windowManager); void createMessageBox (const std::string& message); void createInteractiveMessageBox (const std::string& message, const std::vector& buttons); + + WindowManager *mWindowManager; + + private: + std::vector mMessageBoxes; }; class MessageBox : public OEngine::GUI::Layout { public: - MessageBox(MessageBoxManager& parMessageBoxManager, const std::string& message); - void setMessage(const std::string& message); + MessageBox (MessageBoxManager& parMessageBoxManager, const std::string& message); + void setMessage (const std::string& message); + protected: MessageBoxManager& mMessageBoxManager; }; diff --git a/apps/openmw/mwgui/window_manager.cpp b/apps/openmw/mwgui/window_manager.cpp index 1c9cda677..1c9217a92 100644 --- a/apps/openmw/mwgui/window_manager.cpp +++ b/apps/openmw/mwgui/window_manager.cpp @@ -61,7 +61,7 @@ WindowManager::WindowManager(MyGUI::Gui *_gui, MWWorld::Environment& environment inventory = new InventoryWindow (); #endif console = new Console(w,h, environment, extensions); - mMessageBoxManager = new MessageBoxManager(); + mMessageBoxManager = new MessageBoxManager(this); // The HUD is always on hud->setVisible(true); diff --git a/extern/mygui_3.0.1/openmw_resources/openmw_messagebox_layout.xml b/extern/mygui_3.0.1/openmw_resources/openmw_messagebox_layout.xml index 9debd1096..e2caf1e31 100644 --- a/extern/mygui_3.0.1/openmw_resources/openmw_messagebox_layout.xml +++ b/extern/mygui_3.0.1/openmw_resources/openmw_messagebox_layout.xml @@ -2,9 +2,6 @@ - - - - +