Move interactive messageBox to separate function

openmw-35
scrawl 10 years ago
parent 91571f51be
commit 579f5d232f

@ -240,9 +240,11 @@ namespace MWBase
/** No guarentee of actually closing the window **/
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 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)
virtual int readPressedButton() = 0;

@ -92,9 +92,7 @@ namespace MWDialogue
quest.addEntry (entry); // we are doing slicing on purpose here
std::vector<std::string> empty;
std::string notification = "#{sJournalEntry}";
MWBase::Environment::get().getWindowManager()->messageBox (notification, empty);
MWBase::Environment::get().getWindowManager()->messageBox ("#{sJournalEntry}");
}
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)
{
if (buttons.empty()) {
/* If there are no buttons, and there is a dialogue window open, messagebox goes to the dialogue window */
if (getMode() == GM_Dialogue && showInDialogueMode != MWGui::ShowInDialogueMode_Never) {
mDialogueWindow->addMessageBox(MyGUI::LanguageManager::getInstance().replaceTags(message));
} else if (showInDialogueMode != MWGui::ShowInDialogueMode_Only) {
mMessageBoxManager->createMessageBox(message);
void WindowManager::interactiveMessageBox(const std::string &message, const std::vector<std::string> &buttons, bool block)
{
mMessageBoxManager->createInteractiveMessageBox(message, buttons);
MWBase::Environment::get().getInputManager()->changeInputMode(isGuiMode());
updateVisible();
if (block)
{
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
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 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 void onFrame (float frameDuration);

@ -743,8 +743,7 @@ namespace MWInput
{
mEngine.screenshot();
std::vector<std::string> empty;
MWBase::Environment::get().getWindowManager()->messageBox ("Screenshot saved", empty);
MWBase::Environment::get().getWindowManager()->messageBox ("Screenshot saved");
}
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
MWBase::Environment::get().getSoundManager ()->playSound ("skillraise", 1, 1);
std::vector <std::string> noButtons;
std::stringstream message;
message << boost::format(MWBase::Environment::get().getWindowManager ()->getGameSettingString ("sNotifyMessage39", ""))
% std::string("#{" + ESM::Skill::sSkillNameIds[skillIndex] + "}")
% 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())
{
// 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);

@ -71,8 +71,7 @@ namespace MWScript
msgBox = MyGUI::LanguageManager::getInstance().replaceTags("#{sNotifyMessage61}");
msgBox = boost::str(boost::format(msgBox) % count % itemName);
}
std::vector <std::string> noButtons;
MWBase::Environment::get().getWindowManager()->messageBox(msgBox, noButtons, MWGui::ShowInDialogueMode_Only);
MWBase::Environment::get().getWindowManager()->messageBox(msgBox, MWGui::ShowInDialogueMode_Only);
}
}
};
@ -143,8 +142,7 @@ namespace MWScript
msgBox = MyGUI::LanguageManager::getInstance().replaceTags("#{sNotifyMessage62}");
msgBox = boost::str (boost::format(msgBox) % itemName);
}
std::vector <std::string> noButtons;
MWBase::Environment::get().getWindowManager()->messageBox(msgBox, noButtons, MWGui::ShowInDialogueMode_Only);
MWBase::Environment::get().getWindowManager()->messageBox(msgBox, MWGui::ShowInDialogueMode_Only);
}
}
};

@ -200,7 +200,10 @@ namespace MWScript
void InterpreterContext::messageBox (const std::string& message,
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)

@ -118,7 +118,7 @@ void MWState::StateManager::askLoadRecent()
std::string message = MWBase::Environment::get().getWindowManager()->getGameSettingString("sLoadLastSaveMsg", tag);
size_t pos = message.find(tag);
message.replace(pos, tag.length(), lastSave.mProfile.mDescription);
MWBase::Environment::get().getWindowManager()->messageBox(message, buttons);
MWBase::Environment::get().getWindowManager()->interactiveMessageBox(message, buttons);
mAskLoadRecent = true;
}
}
@ -259,7 +259,7 @@ void MWState::StateManager::saveGame (const std::string& description, const Slot
std::vector<std::string> buttons;
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 (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;
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;
buttons.push_back("#{sOk}");
MWBase::Environment::get().getWindowManager()->messageBox(message, buttons);
MWBase::Environment::get().getWindowManager()->interactiveMessageBox(message, buttons);
}
}

Loading…
Cancel
Save