creating the buttons on the fly

actorid
Sebastian Wick 14 years ago
parent 5db8e8c449
commit 23194a932f

@ -2,10 +2,9 @@
using namespace MWGui; using namespace MWGui;
MessageBoxManager::MessageBoxManager (WindowManager *windowManager, MyGUI::Gui *_gui) MessageBoxManager::MessageBoxManager (WindowManager *windowManager)
{ {
mWindowManager = windowManager; mWindowManager = windowManager;
gui = _gui;
// defines // defines
mMessageBoxSpeed = 0.1; mMessageBoxSpeed = 0.1;
mInterMessageBoxe = NULL; mInterMessageBoxe = NULL;
@ -84,7 +83,7 @@ bool MessageBoxManager::createInteractiveMessageBox (const std::string& message,
std::copy (buttons.begin(), buttons.end(), std::ostream_iterator<std::string> (std::cout, ", ")); std::copy (buttons.begin(), buttons.end(), std::ostream_iterator<std::string> (std::cout, ", "));
std::cout << std::endl; std::cout << std::endl;
mInterMessageBoxe = new InteractiveMessageBox(*this, gui, message, buttons); mInterMessageBoxe = new InteractiveMessageBox(*this, message, buttons);
return true; return true;
} }
@ -184,11 +183,12 @@ int MessageBox::getHeight ()
InteractiveMessageBox::InteractiveMessageBox(MessageBoxManager& parMessageBoxManager, MyGUI::Gui *_gui, const std::string& message, const std::vector<std::string>& buttons) InteractiveMessageBox::InteractiveMessageBox(MessageBoxManager& parMessageBoxManager, const std::string& message, const std::vector<std::string>& buttons)
: Layout("openmw_interactive_messagebox_layout.xml") : Layout("openmw_interactive_messagebox_layout.xml")
, mMessageBoxManager(parMessageBoxManager) , mMessageBoxManager(parMessageBoxManager)
, mGUI(_gui)
{ {
mTextButtonPadding = 10;
getWidget(mMessageWidget, "message"); getWidget(mMessageWidget, "message");
getWidget(mButtonsWidget, "buttons"); getWidget(mButtonsWidget, "buttons");
@ -207,13 +207,19 @@ InteractiveMessageBox::InteractiveMessageBox(MessageBoxManager& parMessageBoxMan
size.height = textSize.height; size.height = textSize.height;
mMessageWidget->setSize(size); mMessageWidget->setSize(size);
MyGUI::IntCoord coord(10, textSize.height+mTextButtonPadding, 100, 50);
std::vector<std::string>::const_iterator it; std::vector<std::string>::const_iterator it;
for(it = buttons.begin(); it != buttons.end(); ++it) for(it = buttons.begin(); it != buttons.end(); ++it)
{ {
std::cout << "add button " << *it << std::endl; std::cout << "add button " << *it << std::endl;
MyGUI::ButtonPtr button = mGUI->createWidget<MyGUI::Button>("button1", 10, textSize.height, 480, 100, MyGUI::Align::Default, "buttons"); MyGUI::ButtonPtr button = mButtonsWidget->createWidget<MyGUI::Button>(
MyGUI::WidgetStyle::Child,
std::string("MW_Button"),
coord,
MyGUI::Align::Default);
button->setCaption(*it); button->setCaption(*it);
//mButtons.push_back(button); mButtons.push_back(button);
} }
} }

@ -24,7 +24,7 @@ namespace MWGui
class MessageBoxManager class MessageBoxManager
{ {
public: public:
MessageBoxManager (WindowManager* windowManager, MyGUI::Gui *_gui); MessageBoxManager (WindowManager* windowManager);
void onFrame (float frameDuration); void onFrame (float frameDuration);
void createMessageBox (const std::string& message); void createMessageBox (const std::string& message);
bool createInteractiveMessageBox (const std::string& message, const std::vector<std::string>& buttons); bool createInteractiveMessageBox (const std::string& message, const std::vector<std::string>& buttons);
@ -40,7 +40,6 @@ namespace MWGui
std::vector<MessageBox*> mMessageBoxes; std::vector<MessageBox*> mMessageBoxes;
InteractiveMessageBox* mInterMessageBoxe; InteractiveMessageBox* mInterMessageBoxe;
std::vector<MessageBoxManagerTimer> mTimers; std::vector<MessageBoxManagerTimer> mTimers;
MyGUI::Gui *gui;
float mMessageBoxSpeed; float mMessageBoxSpeed;
}; };
@ -67,14 +66,15 @@ namespace MWGui
class InteractiveMessageBox : public OEngine::GUI::Layout class InteractiveMessageBox : public OEngine::GUI::Layout
{ {
public: public:
InteractiveMessageBox (MessageBoxManager& parMessageBoxManager, MyGUI::Gui *_gui, const std::string& message, const std::vector<std::string>& buttons); InteractiveMessageBox (MessageBoxManager& parMessageBoxManager, const std::string& message, const std::vector<std::string>& buttons);
protected: private:
MessageBoxManager& mMessageBoxManager; MessageBoxManager& mMessageBoxManager;
MyGUI::EditPtr mMessageWidget; MyGUI::EditPtr mMessageWidget;
MyGUI::WidgetPtr mButtonsWidget; MyGUI::WidgetPtr mButtonsWidget;
MyGUI::Gui *mGUI; std::vector<MyGUI::ButtonPtr> mButtons;
//std::vector<MyGUI::Button> mButtons;
int mTextButtonPadding;
}; };
} }

@ -61,7 +61,7 @@ WindowManager::WindowManager(MyGUI::Gui *_gui, MWWorld::Environment& environment
inventory = new InventoryWindow (); inventory = new InventoryWindow ();
#endif #endif
console = new Console(w,h, environment, extensions); console = new Console(w,h, environment, extensions);
mMessageBoxManager = new MessageBoxManager(this, (MyGUI::Gui*)gui); mMessageBoxManager = new MessageBoxManager(this);
// The HUD is always on // The HUD is always on
hud->setVisible(true); hud->setVisible(true);

@ -13,7 +13,7 @@
<Property key="TextColour" value = "0.7 0.7 0.7" /> <Property key="TextColour" value = "0.7 0.7 0.7" />
</Widget> </Widget>
<Widget type="Widget" skin="" position="0 0 500 400" align="ALIGN_STRETCH" name="buttons"> <Widget type="Widget" skin="" position="0 0 500 400" align="ALIGN_STRETCH" name="buttons">
<Widget type="Button" skin="MW_Button" position="0 0 30 18" name="somefunnybutton"/> <!-- Widget type="Button" skin="MW_Button" position="0 0 30 18" name="somefunnybutton"/ -->
</Widget> </Widget>
</Widget> </Widget>
</MyGUI> </MyGUI>

Loading…
Cancel
Save