creating the buttons on the fly

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

@ -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::string> (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<std::string>& buttons)
InteractiveMessageBox::InteractiveMessageBox(MessageBoxManager& parMessageBoxManager, const std::string& message, const std::vector<std::string>& 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<std::string>::const_iterator it;
for(it = buttons.begin(); it != buttons.end(); ++it)
{
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);
//mButtons.push_back(button);
mButtons.push_back(button);
}
}

@ -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<std::string>& buttons);
@ -40,7 +40,6 @@ namespace MWGui
std::vector<MessageBox*> mMessageBoxes;
InteractiveMessageBox* mInterMessageBoxe;
std::vector<MessageBoxManagerTimer> 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<std::string>& buttons);
InteractiveMessageBox (MessageBoxManager& parMessageBoxManager, const std::string& message, const std::vector<std::string>& buttons);
protected:
private:
MessageBoxManager& mMessageBoxManager;
MyGUI::EditPtr mMessageWidget;
MyGUI::WidgetPtr mButtonsWidget;
MyGUI::Gui *mGUI;
//std::vector<MyGUI::Button> mButtons;
std::vector<MyGUI::ButtonPtr> mButtons;
int mTextButtonPadding;
};
}

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

@ -13,7 +13,7 @@
<Property key="TextColour" value = "0.7 0.7 0.7" />
</Widget>
<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>
</MyGUI>

Loading…
Cancel
Save