forked from teamnwah/openmw-tes3coop
everything works, also the readPressedButton function should do the job
This commit is contained in:
parent
16ed02baeb
commit
317c920e03
4 changed files with 60 additions and 0 deletions
|
@ -47,6 +47,12 @@ void MessageBoxManager::onFrame (float frameDuration)
|
||||||
it++;
|
it++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(mInterMessageBoxe != NULL && mInterMessageBoxe->mMarkedToDelete) {
|
||||||
|
delete mInterMessageBoxe;
|
||||||
|
mInterMessageBoxe = NULL;
|
||||||
|
mWindowManager->setNextMode(GM_Game);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MessageBoxManager::createMessageBox (const std::string& message)
|
void MessageBoxManager::createMessageBox (const std::string& message)
|
||||||
|
@ -124,6 +130,16 @@ void MessageBoxManager::setMessageBoxSpeed (int speed)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int MessageBoxManager::readPressedButton ()
|
||||||
|
{
|
||||||
|
if(mInterMessageBoxe != NULL)
|
||||||
|
{
|
||||||
|
return mInterMessageBoxe->readPressedButton();
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
MessageBox::MessageBox(MessageBoxManager& parMessageBoxManager, const std::string& message)
|
MessageBox::MessageBox(MessageBoxManager& parMessageBoxManager, const std::string& message)
|
||||||
|
@ -186,6 +202,7 @@ int MessageBox::getHeight ()
|
||||||
InteractiveMessageBox::InteractiveMessageBox(MessageBoxManager& parMessageBoxManager, 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)
|
||||||
|
, mButtonPressed(-1)
|
||||||
{
|
{
|
||||||
int fixedWidth = 500;
|
int fixedWidth = 500;
|
||||||
int textPadding = 10; // padding between text-widget and main-widget
|
int textPadding = 10; // padding between text-widget and main-widget
|
||||||
|
@ -195,6 +212,8 @@ InteractiveMessageBox::InteractiveMessageBox(MessageBoxManager& parMessageBoxMan
|
||||||
int buttonPadding = 5; // padding between button label and button itself
|
int buttonPadding = 5; // padding between button label and button itself
|
||||||
int buttonMainPadding = 10; // padding between buttons and bottom of the main widget
|
int buttonMainPadding = 10; // padding between buttons and bottom of the main widget
|
||||||
|
|
||||||
|
mMarkedToDelete = false;
|
||||||
|
|
||||||
|
|
||||||
getWidget(mMessageWidget, "message");
|
getWidget(mMessageWidget, "message");
|
||||||
getWidget(mButtonsWidget, "buttons");
|
getWidget(mButtonsWidget, "buttons");
|
||||||
|
@ -222,6 +241,8 @@ InteractiveMessageBox::InteractiveMessageBox(MessageBoxManager& parMessageBoxMan
|
||||||
MyGUI::Align::Default);
|
MyGUI::Align::Default);
|
||||||
button->setCaption(*it);
|
button->setCaption(*it);
|
||||||
|
|
||||||
|
button->eventMouseButtonClick = MyGUI::newDelegate(this, &InteractiveMessageBox::mousePressed);
|
||||||
|
|
||||||
mButtons.push_back(button);
|
mButtons.push_back(button);
|
||||||
|
|
||||||
buttonWidth = button->_getTextSize().width + 2*buttonPadding + buttonLeftPadding;
|
buttonWidth = button->_getTextSize().width + 2*buttonPadding + buttonLeftPadding;
|
||||||
|
@ -343,6 +364,30 @@ InteractiveMessageBox::InteractiveMessageBox(MessageBoxManager& parMessageBoxMan
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void InteractiveMessageBox::mousePressed (MyGUI::Widget* pressed)
|
||||||
|
{
|
||||||
|
mMarkedToDelete = true;
|
||||||
|
int index = 0;
|
||||||
|
std::vector<MyGUI::ButtonPtr>::const_iterator button;
|
||||||
|
for(button = mButtons.begin(); button != mButtons.end(); ++button)
|
||||||
|
{
|
||||||
|
if(*button == pressed)
|
||||||
|
{
|
||||||
|
mButtonPressed = index;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
index++;
|
||||||
|
}
|
||||||
|
std::cout << "Cant be possible :/" << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
int InteractiveMessageBox::readPressedButton ()
|
||||||
|
{
|
||||||
|
int pressed = mButtonPressed;
|
||||||
|
mButtonPressed = -1;
|
||||||
|
return pressed;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -34,6 +34,8 @@ namespace MWGui
|
||||||
bool removeMessageBox (MessageBox *msgbox);
|
bool removeMessageBox (MessageBox *msgbox);
|
||||||
void setMessageBoxSpeed (int speed);
|
void setMessageBoxSpeed (int speed);
|
||||||
|
|
||||||
|
int readPressedButton ();
|
||||||
|
|
||||||
WindowManager *mWindowManager;
|
WindowManager *mWindowManager;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -67,6 +69,10 @@ namespace MWGui
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
InteractiveMessageBox (MessageBoxManager& parMessageBoxManager, const std::string& message, const std::vector<std::string>& buttons);
|
InteractiveMessageBox (MessageBoxManager& parMessageBoxManager, const std::string& message, const std::vector<std::string>& buttons);
|
||||||
|
void mousePressed (MyGUI::Widget* _widget);
|
||||||
|
int readPressedButton ();
|
||||||
|
|
||||||
|
bool mMarkedToDelete;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
MessageBoxManager& mMessageBoxManager;
|
MessageBoxManager& mMessageBoxManager;
|
||||||
|
@ -75,6 +81,7 @@ namespace MWGui
|
||||||
std::vector<MyGUI::ButtonPtr> mButtons;
|
std::vector<MyGUI::ButtonPtr> mButtons;
|
||||||
|
|
||||||
int mTextButtonPadding;
|
int mTextButtonPadding;
|
||||||
|
int mButtonPressed;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -468,6 +468,11 @@ void WindowManager::messageBox (const std::string& message, const std::vector<st
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int WindowManager::readPressedButton ()
|
||||||
|
{
|
||||||
|
return mMessageBoxManager->readPressedButton();
|
||||||
|
}
|
||||||
|
|
||||||
const std::string &WindowManager::getGameSettingString(const std::string &id, const std::string &default_)
|
const std::string &WindowManager::getGameSettingString(const std::string &id, const std::string &default_)
|
||||||
{
|
{
|
||||||
const ESM::GameSetting *setting = environment.mWorld->getStore().gameSettings.search(id);
|
const ESM::GameSetting *setting = environment.mWorld->getStore().gameSettings.search(id);
|
||||||
|
|
|
@ -250,6 +250,9 @@ namespace MWGui
|
||||||
|
|
||||||
void messageBox (const std::string& message, const std::vector<std::string>& buttons);
|
void messageBox (const std::string& message, const std::vector<std::string>& buttons);
|
||||||
|
|
||||||
|
int readPressedButton ();
|
||||||
|
///< returns the index of the pressed button or -1 if no button was pressed (->MessageBoxmanager->InteractiveMessageBox)
|
||||||
|
|
||||||
void onFrame (float frameDuration);
|
void onFrame (float frameDuration);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue