mirror of
				https://github.com/OpenMW/openmw.git
				synced 2025-11-03 23:56:43 +00:00 
			
		
		
		
	Changes the logic of WindowManager::messageBox()
Fixes removeItem Fixes addItem
This commit is contained in:
		
							parent
							
								
									7e05b725d0
								
							
						
					
					
						commit
						24d619d6b4
					
				
					 4 changed files with 24 additions and 19 deletions
				
			
		| 
						 | 
				
			
			@ -200,7 +200,7 @@ namespace MWBase
 | 
			
		|||
            virtual void removeDialog(OEngine::GUI::Layout* dialog) = 0;
 | 
			
		||||
            ///< Hides dialog and schedules dialog to be deleted.
 | 
			
		||||
 | 
			
		||||
            virtual void messageBox (const std::string& message, const std::vector<std::string>& buttons = std::vector<std::string>()) = 0;
 | 
			
		||||
            virtual void messageBox (const std::string& message, const std::vector<std::string>& buttons = std::vector<std::string>(), bool showInDialogueModeOnly = false) = 0;
 | 
			
		||||
            virtual void staticMessageBox(const std::string& message) = 0;
 | 
			
		||||
            virtual void removeStaticMessageBox() = 0;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -584,18 +584,21 @@ namespace MWGui
 | 
			
		|||
        mGarbageDialogs.push_back(dialog);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    void WindowManager::messageBox (const std::string& message, const std::vector<std::string>& buttons)
 | 
			
		||||
    void WindowManager::messageBox (const std::string& message, const std::vector<std::string>& buttons, bool showInDialogueModeOnly)
 | 
			
		||||
    {
 | 
			
		||||
        if(buttons.empty()){
 | 
			
		||||
        if (buttons.empty()) {
 | 
			
		||||
            /* If there are no buttons, and there is a dialogue window open, messagebox goes to the dialogue window */
 | 
			
		||||
            if(!mGuiModes.empty() && mGuiModes.back() == GM_Dialogue)
 | 
			
		||||
            if (getMode() == GM_Dialogue) {
 | 
			
		||||
                mDialogueWindow->addMessageBox(MyGUI::LanguageManager::getInstance().replaceTags(message));
 | 
			
		||||
            else
 | 
			
		||||
                mMessageBoxManager->createMessageBox(message);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        else
 | 
			
		||||
        {
 | 
			
		||||
            } else {
 | 
			
		||||
                if (showInDialogueModeOnly) {
 | 
			
		||||
                    if (getMode() == GM_Dialogue)
 | 
			
		||||
                        mMessageBoxManager->createMessageBox(message);
 | 
			
		||||
                } else {
 | 
			
		||||
                    mMessageBoxManager->createMessageBox(message);
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        } else {
 | 
			
		||||
            mMessageBoxManager->createInteractiveMessageBox(message, buttons);
 | 
			
		||||
            MWBase::Environment::get().getInputManager()->changeInputMode(isGuiMode());
 | 
			
		||||
        }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -191,7 +191,7 @@ namespace MWGui
 | 
			
		|||
 | 
			
		||||
    virtual void removeDialog(OEngine::GUI::Layout* dialog); ///< Hides dialog and schedules dialog to be deleted.
 | 
			
		||||
 | 
			
		||||
    virtual void messageBox (const std::string& message, const std::vector<std::string>& buttons = std::vector<std::string>());
 | 
			
		||||
    virtual void messageBox (const std::string& message, const std::vector<std::string>& buttons = std::vector<std::string>(), bool showInDialogueModeOnly = false);
 | 
			
		||||
    virtual void staticMessageBox(const std::string& message);
 | 
			
		||||
    virtual void removeStaticMessageBox();
 | 
			
		||||
    virtual void enterPressed ();
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -66,8 +66,8 @@ namespace MWScript
 | 
			
		|||
 | 
			
		||||
                    MWWorld::Class::get (ptr).getContainerStore (ptr).add (ref.getPtr());
 | 
			
		||||
 | 
			
		||||
                    // Spawn a messagebox (only for items added to player's inventory)
 | 
			
		||||
                    if (ptr == MWBase::Environment::get().getWorld ()->getPlayer ().getPlayer())
 | 
			
		||||
                    // Spawn a messagebox (only for items added to player's inventory and if player is talking to someone)
 | 
			
		||||
                    if (ptr == MWBase::Environment::get().getWorld ()->getPlayer ().getPlayer() )
 | 
			
		||||
                    {
 | 
			
		||||
                        // The two GMST entries below expand to strings informing the player of what, and how many of it has been added to their inventory
 | 
			
		||||
                        std::string msgBox;
 | 
			
		||||
| 
						 | 
				
			
			@ -82,8 +82,8 @@ namespace MWScript
 | 
			
		|||
                            msgBox = MyGUI::LanguageManager::getInstance().replaceTags("#{sNotifyMessage61}");
 | 
			
		||||
                            msgBox = boost::str(boost::format(msgBox) % count % itemName);
 | 
			
		||||
                        }
 | 
			
		||||
 | 
			
		||||
                        MWBase::Environment::get().getWindowManager()->messageBox(msgBox);
 | 
			
		||||
                        std::vector <std::string> noButtons;
 | 
			
		||||
                        MWBase::Environment::get().getWindowManager()->messageBox(msgBox, noButtons, /*showInDialogueModeOnly*/ true);
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
        };
 | 
			
		||||
| 
						 | 
				
			
			@ -161,12 +161,15 @@ namespace MWScript
 | 
			
		|||
                        }
 | 
			
		||||
                    }
 | 
			
		||||
                  
 | 
			
		||||
                    // Spawn a messagebox (only for items added to player's inventory)
 | 
			
		||||
                    // Spawn a messagebox (only for items removed from player's inventory)
 | 
			
		||||
                    if (ptr == MWBase::Environment::get().getWorld ()->getPlayer ().getPlayer())
 | 
			
		||||
                    {
 | 
			
		||||
                        // The two GMST entries below expand to strings informing the player of what, and how many of it has been removed from their inventory
 | 
			
		||||
                        std::string msgBox;
 | 
			
		||||
                        int numRemoved = (originalCount - count);
 | 
			
		||||
                        if (numRemoved == 0)
 | 
			
		||||
                            return;
 | 
			
		||||
                        
 | 
			
		||||
                        if(numRemoved > 1)
 | 
			
		||||
                        {
 | 
			
		||||
                            msgBox = MyGUI::LanguageManager::getInstance().replaceTags("#{sNotifyMessage63}");
 | 
			
		||||
| 
						 | 
				
			
			@ -177,9 +180,8 @@ namespace MWScript
 | 
			
		|||
                            msgBox = MyGUI::LanguageManager::getInstance().replaceTags("#{sNotifyMessage62}");
 | 
			
		||||
                            msgBox = boost::str (boost::format(msgBox) % itemName);
 | 
			
		||||
                        }
 | 
			
		||||
 | 
			
		||||
                        if (numRemoved > 0)
 | 
			
		||||
                            MWBase::Environment::get().getWindowManager()->messageBox(msgBox);
 | 
			
		||||
                        std::vector <std::string> noButtons;
 | 
			
		||||
                        MWBase::Environment::get().getWindowManager()->messageBox(msgBox, noButtons, /*showInDialogueModeOnly*/ true);
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
        };
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in a new issue