diff --git a/apps/openmw/mwgui/messagebox.cpp b/apps/openmw/mwgui/messagebox.cpp index c4334250d..17de1f504 100644 --- a/apps/openmw/mwgui/messagebox.cpp +++ b/apps/openmw/mwgui/messagebox.cpp @@ -2,10 +2,9 @@ using namespace MWGui; -MessageBoxManager::MessageBoxManager (WindowManager *windowManager, MyGUI::Gui *_gui) +MessageBoxManager::MessageBoxManager (WindowManager *windowManager) { mWindowManager = windowManager; - gui = _gui; // defines mMessageBoxSpeed = 0.1; mInterMessageBoxe = NULL; @@ -84,7 +83,7 @@ bool MessageBoxManager::createInteractiveMessageBox (const std::string& message, std::copy (buttons.begin(), buttons.end(), std::ostream_iterator (std::cout, ", ")); std::cout << std::endl; - mInterMessageBoxe = new InteractiveMessageBox(*this, gui, message, buttons); + mInterMessageBoxe = new InteractiveMessageBox(*this, message, buttons); return true; } @@ -184,11 +183,12 @@ int MessageBox::getHeight () -InteractiveMessageBox::InteractiveMessageBox(MessageBoxManager& parMessageBoxManager, MyGUI::Gui *_gui, const std::string& message, const std::vector& buttons) +InteractiveMessageBox::InteractiveMessageBox(MessageBoxManager& parMessageBoxManager, const std::string& message, const std::vector& buttons) : Layout("openmw_interactive_messagebox_layout.xml") , mMessageBoxManager(parMessageBoxManager) - , mGUI(_gui) { + mTextButtonPadding = 10; + getWidget(mMessageWidget, "message"); getWidget(mButtonsWidget, "buttons"); @@ -207,13 +207,19 @@ InteractiveMessageBox::InteractiveMessageBox(MessageBoxManager& parMessageBoxMan size.height = textSize.height; mMessageWidget->setSize(size); + MyGUI::IntCoord coord(10, textSize.height+mTextButtonPadding, 100, 50); + std::vector::const_iterator it; for(it = buttons.begin(); it != buttons.end(); ++it) { std::cout << "add button " << *it << std::endl; - MyGUI::ButtonPtr button = mGUI->createWidget("button1", 10, textSize.height, 480, 100, MyGUI::Align::Default, "buttons"); + MyGUI::ButtonPtr button = mButtonsWidget->createWidget( + MyGUI::WidgetStyle::Child, + std::string("MW_Button"), + coord, + MyGUI::Align::Default); button->setCaption(*it); - //mButtons.push_back(button); + mButtons.push_back(button); } } diff --git a/apps/openmw/mwgui/messagebox.hpp b/apps/openmw/mwgui/messagebox.hpp index 5e31cb346..f7c7197fa 100644 --- a/apps/openmw/mwgui/messagebox.hpp +++ b/apps/openmw/mwgui/messagebox.hpp @@ -24,7 +24,7 @@ namespace MWGui class MessageBoxManager { public: - MessageBoxManager (WindowManager* windowManager, MyGUI::Gui *_gui); + MessageBoxManager (WindowManager* windowManager); void onFrame (float frameDuration); void createMessageBox (const std::string& message); bool createInteractiveMessageBox (const std::string& message, const std::vector& buttons); @@ -40,7 +40,6 @@ namespace MWGui std::vector mMessageBoxes; InteractiveMessageBox* mInterMessageBoxe; std::vector mTimers; - MyGUI::Gui *gui; float mMessageBoxSpeed; }; @@ -67,14 +66,15 @@ namespace MWGui class InteractiveMessageBox : public OEngine::GUI::Layout { public: - InteractiveMessageBox (MessageBoxManager& parMessageBoxManager, MyGUI::Gui *_gui, const std::string& message, const std::vector& buttons); + InteractiveMessageBox (MessageBoxManager& parMessageBoxManager, const std::string& message, const std::vector& buttons); - protected: + private: MessageBoxManager& mMessageBoxManager; MyGUI::EditPtr mMessageWidget; MyGUI::WidgetPtr mButtonsWidget; - MyGUI::Gui *mGUI; - //std::vector mButtons; + std::vector mButtons; + + int mTextButtonPadding; }; } diff --git a/apps/openmw/mwgui/window_manager.cpp b/apps/openmw/mwgui/window_manager.cpp index 55d0c93cf..b5a6e36a6 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(this, (MyGUI::Gui*)gui); + mMessageBoxManager = new MessageBoxManager(this); // The HUD is always on hud->setVisible(true); diff --git a/extern/mygui_3.0.1/openmw_resources/openmw_interactive_messagebox_layout.xml b/extern/mygui_3.0.1/openmw_resources/openmw_interactive_messagebox_layout.xml index bba5d631c..40c0787b8 100644 --- a/extern/mygui_3.0.1/openmw_resources/openmw_interactive_messagebox_layout.xml +++ b/extern/mygui_3.0.1/openmw_resources/openmw_interactive_messagebox_layout.xml @@ -13,7 +13,7 @@ - +