1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-16 21:49:55 +00:00

Merge remote-tracking branch 'scrawl/master'

This commit is contained in:
Marc Zinnschlag 2015-01-11 12:24:51 +01:00
commit 289a912817
16 changed files with 90 additions and 36 deletions

View file

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

View file

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

View file

@ -146,10 +146,11 @@ namespace MWGui
return false;
}
int MessageBoxManager::readPressedButton ()
int MessageBoxManager::readPressedButton (bool reset)
{
int pressed = mLastButtonPressed;
mLastButtonPressed = -1;
if (reset)
mLastButtonPressed = -1;
return pressed;
}

View file

@ -33,7 +33,8 @@ namespace MWGui
bool removeMessageBox (MessageBox *msgbox);
int readPressedButton ();
/// @param reset Reset the pressed button to -1 after reading it.
int readPressedButton (bool reset=true);
typedef MyGUI::delegates::CMultiDelegate1<int> EventHandle_Int;

View file

@ -607,7 +607,7 @@ namespace MWGui
// GM_Loading uses a texture of the last rendered frame so everything previously visible will be rendered.
mHud->setVisible(false);
mToolTips->setVisible(false);
setCursorVisible(false);
setCursorVisible(mMessageBoxManager && mMessageBoxManager->isInteractiveMessageBox());
break;
default:
// Unsupported mode, switch back to game
@ -805,19 +805,31 @@ 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()) {
/* 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);
mMessageBoxManager->createInteractiveMessageBox(message, buttons);
MWBase::Environment::get().getInputManager()->changeInputMode(isGuiMode());
updateVisible();
if (block)
{
while (mMessageBoxManager->readPressedButton(false) == -1
&& !MWBase::Environment::get().getStateManager()->hasQuitRequest())
{
mMessageBoxManager->onFrame(0.f);
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);
}
}

View file

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

View file

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

View file

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

View file

@ -169,6 +169,9 @@ struct AddGlow
instance->setProperty("env_map", sh::makeProperty(new sh::BooleanValue(true)));
instance->setProperty("env_map_color", sh::makeProperty(new sh::Vector3(mColor->x, mColor->y, mColor->z)));
// Workaround for crash in Ogre (https://bitbucket.org/sinbad/ogre/pull-request/447/fix-shadows-crash-for-textureunitstates/diff)
// Remove when the fix is merged
instance->getMaterial()->setShadowCasterMaterial("openmw_shadowcaster_noalpha");
}
};

View file

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

View file

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

View file

@ -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))
@ -353,6 +353,12 @@ void MWState::StateManager::loadGame (const Character *character, const std::str
{
ESM::SavedGame profile;
profile.load(reader);
if (!verifyProfile(profile))
{
cleanup (true);
MWBase::Environment::get().getWindowManager()->pushGuiMode (MWGui::GM_MainMenu);
return;
}
mTimePlayed = profile.mTimePlayed;
}
break;
@ -459,7 +465,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);
}
}
@ -517,3 +523,30 @@ void MWState::StateManager::update (float duration)
}
}
}
bool MWState::StateManager::verifyProfile(const ESM::SavedGame& profile) const
{
const std::vector<std::string>& selectedContentFiles = MWBase::Environment::get().getWorld()->getContentFiles();
bool notFound = false;
for (std::vector<std::string>::const_iterator it = profile.mContentFiles.begin();
it != profile.mContentFiles.end(); ++it)
{
if (std::find(selectedContentFiles.begin(), selectedContentFiles.end(), *it)
== selectedContentFiles.end())
{
notFound = true;
break;
}
}
if (notFound)
{
std::vector<std::string> buttons;
buttons.push_back("#{sYes}");
buttons.push_back("#{sNo}");
MWBase::Environment::get().getWindowManager()->interactiveMessageBox("#{sMissingMastersMsg}", buttons, true);
int selectedButton = MWBase::Environment::get().getWindowManager()->readPressedButton();
if (selectedButton == 1 || selectedButton == -1)
return false;
}
return true;
}

View file

@ -23,6 +23,8 @@ namespace MWState
void cleanup (bool force = false);
bool verifyProfile (const ESM::SavedGame& profile) const;
std::map<int, int> buildContentFileIndexMap (const ESM::ESMReader& reader) const;
public:

View file

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

View file

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<MyGUI type="Layout">
<Widget type="Window" skin="MW_Dialog" layer="Windows" position="0 0 500 400" name="_Main">
<Widget type="Window" skin="MW_Dialog" layer="MessageBox" position="0 0 500 400" name="_Main">
<Widget type="EditBox" skin="MW_TextEditClient" position="10 10 490 20" align="Left Top Stretch" name="message">
<Property key="FontName" value="Default"/>
<Property key="TextAlign" value="Center"/>

View file

@ -11,6 +11,7 @@
<Layer name="Popup" overlapped="true" peek="true"/>
<Layer name="DragAndDrop" overlapped="false" peek="false"/>
<Layer name="LoadingScreen" overlapped="false" peek="true"/>
<Layer name="MessageBox" overlapped="false" peek="true"/>
<Layer name="Overlay" overlapped="false" peek="true"/>
<Layer name="Pointer" overlapped="false" peek="false"/>
</MyGUI>