mirror of
https://github.com/OpenMW/openmw.git
synced 2025-02-21 23:39:41 +00:00
Move interactive messageBox to separate function
This commit is contained in:
parent
91571f51be
commit
579f5d232f
10 changed files with 43 additions and 31 deletions
|
@ -240,9 +240,11 @@ namespace MWBase
|
||||||
/** No guarentee of actually closing the window **/
|
/** No guarentee of actually closing the window **/
|
||||||
virtual void exitCurrentGuiMode() = 0;
|
virtual void exitCurrentGuiMode() = 0;
|
||||||
|
|
||||||
virtual void messageBox (const std::string& message, const std::vector<std::string>& buttons = std::vector<std::string>(), enum MWGui::ShowInDialogueMode showInDialogueMode = MWGui::ShowInDialogueMode_IfPossible) = 0;
|
virtual void messageBox (const std::string& message, enum MWGui::ShowInDialogueMode showInDialogueMode = MWGui::ShowInDialogueMode_IfPossible) = 0;
|
||||||
virtual void staticMessageBox(const std::string& message) = 0;
|
virtual void staticMessageBox(const std::string& message) = 0;
|
||||||
virtual void removeStaticMessageBox() = 0;
|
virtual void removeStaticMessageBox() = 0;
|
||||||
|
virtual void interactiveMessageBox (const std::string& message,
|
||||||
|
const std::vector<std::string>& buttons = std::vector<std::string>(), bool block=false) = 0;
|
||||||
|
|
||||||
/// returns the index of the pressed button or -1 if no button was pressed (->MessageBoxmanager->InteractiveMessageBox)
|
/// returns the index of the pressed button or -1 if no button was pressed (->MessageBoxmanager->InteractiveMessageBox)
|
||||||
virtual int readPressedButton() = 0;
|
virtual int readPressedButton() = 0;
|
||||||
|
|
|
@ -92,9 +92,7 @@ namespace MWDialogue
|
||||||
|
|
||||||
quest.addEntry (entry); // we are doing slicing on purpose here
|
quest.addEntry (entry); // we are doing slicing on purpose here
|
||||||
|
|
||||||
std::vector<std::string> empty;
|
MWBase::Environment::get().getWindowManager()->messageBox ("#{sJournalEntry}");
|
||||||
std::string notification = "#{sJournalEntry}";
|
|
||||||
MWBase::Environment::get().getWindowManager()->messageBox (notification, empty);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Journal::setJournalIndex (const std::string& id, int index)
|
void Journal::setJournalIndex (const std::string& id, int index)
|
||||||
|
|
|
@ -805,19 +805,30 @@ namespace MWGui
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void WindowManager::messageBox (const std::string& message, const std::vector<std::string>& buttons, enum MWGui::ShowInDialogueMode showInDialogueMode)
|
void WindowManager::interactiveMessageBox(const std::string &message, const std::vector<std::string> &buttons, bool block)
|
||||||
{
|
{
|
||||||
if (buttons.empty()) {
|
mMessageBoxManager->createInteractiveMessageBox(message, buttons);
|
||||||
/* If there are no buttons, and there is a dialogue window open, messagebox goes to the dialogue window */
|
MWBase::Environment::get().getInputManager()->changeInputMode(isGuiMode());
|
||||||
if (getMode() == GM_Dialogue && showInDialogueMode != MWGui::ShowInDialogueMode_Never) {
|
updateVisible();
|
||||||
mDialogueWindow->addMessageBox(MyGUI::LanguageManager::getInstance().replaceTags(message));
|
|
||||||
} else if (showInDialogueMode != MWGui::ShowInDialogueMode_Only) {
|
if (block)
|
||||||
mMessageBoxManager->createMessageBox(message);
|
{
|
||||||
|
while (mMessageBoxManager->readPressedButton() == -1
|
||||||
|
&& !MWBase::Environment::get().getStateManager()->hasQuitRequest())
|
||||||
|
{
|
||||||
|
MWBase::Environment::get().getInputManager()->update(0, true, false);
|
||||||
|
|
||||||
|
mRendering->getWindow()->update();
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
mMessageBoxManager->createInteractiveMessageBox(message, buttons);
|
}
|
||||||
MWBase::Environment::get().getInputManager()->changeInputMode(isGuiMode());
|
|
||||||
updateVisible();
|
void WindowManager::messageBox (const std::string& message, enum MWGui::ShowInDialogueMode showInDialogueMode)
|
||||||
|
{
|
||||||
|
if (getMode() == GM_Dialogue && showInDialogueMode != MWGui::ShowInDialogueMode_Never) {
|
||||||
|
mDialogueWindow->addMessageBox(MyGUI::LanguageManager::getInstance().replaceTags(message));
|
||||||
|
} else if (showInDialogueMode != MWGui::ShowInDialogueMode_Only) {
|
||||||
|
mMessageBoxManager->createMessageBox(message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -238,9 +238,12 @@ namespace MWGui
|
||||||
///Gracefully attempts to exit the topmost GUI mode
|
///Gracefully attempts to exit the topmost GUI mode
|
||||||
virtual void exitCurrentGuiMode();
|
virtual void exitCurrentGuiMode();
|
||||||
|
|
||||||
virtual void messageBox (const std::string& message, const std::vector<std::string>& buttons = std::vector<std::string>(), enum MWGui::ShowInDialogueMode showInDialogueMode = MWGui::ShowInDialogueMode_IfPossible);
|
virtual void messageBox (const std::string& message, enum MWGui::ShowInDialogueMode showInDialogueMode = MWGui::ShowInDialogueMode_IfPossible);
|
||||||
virtual void staticMessageBox(const std::string& message);
|
virtual void staticMessageBox(const std::string& message);
|
||||||
virtual void removeStaticMessageBox();
|
virtual void removeStaticMessageBox();
|
||||||
|
virtual void interactiveMessageBox (const std::string& message,
|
||||||
|
const std::vector<std::string>& buttons = std::vector<std::string>(), bool block=false);
|
||||||
|
|
||||||
virtual int readPressedButton (); ///< returns the index of the pressed button or -1 if no button was pressed (->MessageBoxmanager->InteractiveMessageBox)
|
virtual int readPressedButton (); ///< returns the index of the pressed button or -1 if no button was pressed (->MessageBoxmanager->InteractiveMessageBox)
|
||||||
|
|
||||||
virtual void onFrame (float frameDuration);
|
virtual void onFrame (float frameDuration);
|
||||||
|
|
|
@ -743,8 +743,7 @@ namespace MWInput
|
||||||
{
|
{
|
||||||
mEngine.screenshot();
|
mEngine.screenshot();
|
||||||
|
|
||||||
std::vector<std::string> empty;
|
MWBase::Environment::get().getWindowManager()->messageBox ("Screenshot saved");
|
||||||
MWBase::Environment::get().getWindowManager()->messageBox ("Screenshot saved", empty);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void InputManager::toggleInventory()
|
void InputManager::toggleInventory()
|
||||||
|
|
|
@ -257,18 +257,16 @@ void MWMechanics::NpcStats::increaseSkill(int skillIndex, const ESM::Class &clas
|
||||||
/// \todo check if character is the player, if levelling is ever implemented for NPCs
|
/// \todo check if character is the player, if levelling is ever implemented for NPCs
|
||||||
MWBase::Environment::get().getSoundManager ()->playSound ("skillraise", 1, 1);
|
MWBase::Environment::get().getSoundManager ()->playSound ("skillraise", 1, 1);
|
||||||
|
|
||||||
std::vector <std::string> noButtons;
|
|
||||||
|
|
||||||
std::stringstream message;
|
std::stringstream message;
|
||||||
message << boost::format(MWBase::Environment::get().getWindowManager ()->getGameSettingString ("sNotifyMessage39", ""))
|
message << boost::format(MWBase::Environment::get().getWindowManager ()->getGameSettingString ("sNotifyMessage39", ""))
|
||||||
% std::string("#{" + ESM::Skill::sSkillNameIds[skillIndex] + "}")
|
% std::string("#{" + ESM::Skill::sSkillNameIds[skillIndex] + "}")
|
||||||
% static_cast<int> (base);
|
% static_cast<int> (base);
|
||||||
MWBase::Environment::get().getWindowManager ()->messageBox(message.str(), noButtons, MWGui::ShowInDialogueMode_Never);
|
MWBase::Environment::get().getWindowManager ()->messageBox(message.str(), MWGui::ShowInDialogueMode_Never);
|
||||||
|
|
||||||
if (mLevelProgress >= gmst.find("iLevelUpTotal")->getInt())
|
if (mLevelProgress >= gmst.find("iLevelUpTotal")->getInt())
|
||||||
{
|
{
|
||||||
// levelup is possible now
|
// levelup is possible now
|
||||||
MWBase::Environment::get().getWindowManager ()->messageBox ("#{sLevelUpMsg}", noButtons, MWGui::ShowInDialogueMode_Never);
|
MWBase::Environment::get().getWindowManager ()->messageBox ("#{sLevelUpMsg}", MWGui::ShowInDialogueMode_Never);
|
||||||
}
|
}
|
||||||
|
|
||||||
getSkill (skillIndex).setBase (base);
|
getSkill (skillIndex).setBase (base);
|
||||||
|
|
|
@ -71,8 +71,7 @@ namespace MWScript
|
||||||
msgBox = MyGUI::LanguageManager::getInstance().replaceTags("#{sNotifyMessage61}");
|
msgBox = MyGUI::LanguageManager::getInstance().replaceTags("#{sNotifyMessage61}");
|
||||||
msgBox = boost::str(boost::format(msgBox) % count % itemName);
|
msgBox = boost::str(boost::format(msgBox) % count % itemName);
|
||||||
}
|
}
|
||||||
std::vector <std::string> noButtons;
|
MWBase::Environment::get().getWindowManager()->messageBox(msgBox, MWGui::ShowInDialogueMode_Only);
|
||||||
MWBase::Environment::get().getWindowManager()->messageBox(msgBox, noButtons, MWGui::ShowInDialogueMode_Only);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -143,8 +142,7 @@ namespace MWScript
|
||||||
msgBox = MyGUI::LanguageManager::getInstance().replaceTags("#{sNotifyMessage62}");
|
msgBox = MyGUI::LanguageManager::getInstance().replaceTags("#{sNotifyMessage62}");
|
||||||
msgBox = boost::str (boost::format(msgBox) % itemName);
|
msgBox = boost::str (boost::format(msgBox) % itemName);
|
||||||
}
|
}
|
||||||
std::vector <std::string> noButtons;
|
MWBase::Environment::get().getWindowManager()->messageBox(msgBox, MWGui::ShowInDialogueMode_Only);
|
||||||
MWBase::Environment::get().getWindowManager()->messageBox(msgBox, noButtons, MWGui::ShowInDialogueMode_Only);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -200,7 +200,10 @@ namespace MWScript
|
||||||
void InterpreterContext::messageBox (const std::string& message,
|
void InterpreterContext::messageBox (const std::string& message,
|
||||||
const std::vector<std::string>& buttons)
|
const std::vector<std::string>& buttons)
|
||||||
{
|
{
|
||||||
MWBase::Environment::get().getWindowManager()->messageBox (message, buttons);
|
if (buttons.empty())
|
||||||
|
MWBase::Environment::get().getWindowManager()->messageBox (message);
|
||||||
|
else
|
||||||
|
MWBase::Environment::get().getWindowManager()->interactiveMessageBox(message, buttons);
|
||||||
}
|
}
|
||||||
|
|
||||||
void InterpreterContext::report (const std::string& message)
|
void InterpreterContext::report (const std::string& message)
|
||||||
|
|
|
@ -118,7 +118,7 @@ void MWState::StateManager::askLoadRecent()
|
||||||
std::string message = MWBase::Environment::get().getWindowManager()->getGameSettingString("sLoadLastSaveMsg", tag);
|
std::string message = MWBase::Environment::get().getWindowManager()->getGameSettingString("sLoadLastSaveMsg", tag);
|
||||||
size_t pos = message.find(tag);
|
size_t pos = message.find(tag);
|
||||||
message.replace(pos, tag.length(), lastSave.mProfile.mDescription);
|
message.replace(pos, tag.length(), lastSave.mProfile.mDescription);
|
||||||
MWBase::Environment::get().getWindowManager()->messageBox(message, buttons);
|
MWBase::Environment::get().getWindowManager()->interactiveMessageBox(message, buttons);
|
||||||
mAskLoadRecent = true;
|
mAskLoadRecent = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -259,7 +259,7 @@ void MWState::StateManager::saveGame (const std::string& description, const Slot
|
||||||
|
|
||||||
std::vector<std::string> buttons;
|
std::vector<std::string> buttons;
|
||||||
buttons.push_back("#{sOk}");
|
buttons.push_back("#{sOk}");
|
||||||
MWBase::Environment::get().getWindowManager()->messageBox(error.str(), buttons);
|
MWBase::Environment::get().getWindowManager()->interactiveMessageBox(error.str(), buttons);
|
||||||
|
|
||||||
// If no file was written, clean up the slot
|
// If no file was written, clean up the slot
|
||||||
if (slot && !boost::filesystem::exists(slot->mPath))
|
if (slot && !boost::filesystem::exists(slot->mPath))
|
||||||
|
@ -459,7 +459,7 @@ void MWState::StateManager::loadGame (const Character *character, const std::str
|
||||||
|
|
||||||
std::vector<std::string> buttons;
|
std::vector<std::string> buttons;
|
||||||
buttons.push_back("#{sOk}");
|
buttons.push_back("#{sOk}");
|
||||||
MWBase::Environment::get().getWindowManager()->messageBox(error.str(), buttons);
|
MWBase::Environment::get().getWindowManager()->interactiveMessageBox(error.str(), buttons);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3047,7 +3047,7 @@ namespace MWWorld
|
||||||
|
|
||||||
std::vector<std::string> buttons;
|
std::vector<std::string> buttons;
|
||||||
buttons.push_back("#{sOk}");
|
buttons.push_back("#{sOk}");
|
||||||
MWBase::Environment::get().getWindowManager()->messageBox(message, buttons);
|
MWBase::Environment::get().getWindowManager()->interactiveMessageBox(message, buttons);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue