mirror of
				https://github.com/OpenMW/openmw.git
				synced 2025-10-31 08:26:42 +00:00 
			
		
		
		
	vanilla style messagebox 2
This commit is contained in:
		
							parent
							
								
									a231037449
								
							
						
					
					
						commit
						1f2311538d
					
				
					 7 changed files with 34 additions and 8 deletions
				
			
		|  | @ -69,6 +69,7 @@ namespace MWGui | ||||||
|     class DialogueWindow; |     class DialogueWindow; | ||||||
|     class WindowModal; |     class WindowModal; | ||||||
|     class JailScreen; |     class JailScreen; | ||||||
|  |     class MessageBox; | ||||||
| 
 | 
 | ||||||
|     enum ShowInDialogueMode { |     enum ShowInDialogueMode { | ||||||
|         ShowInDialogueMode_IfPossible, |         ShowInDialogueMode_IfPossible, | ||||||
|  | @ -145,6 +146,7 @@ namespace MWBase | ||||||
|             virtual MWGui::CountDialog* getCountDialog() = 0; |             virtual MWGui::CountDialog* getCountDialog() = 0; | ||||||
|             virtual MWGui::ConfirmationDialog* getConfirmationDialog() = 0; |             virtual MWGui::ConfirmationDialog* getConfirmationDialog() = 0; | ||||||
|             virtual MWGui::TradeWindow* getTradeWindow() = 0; |             virtual MWGui::TradeWindow* getTradeWindow() = 0; | ||||||
|  |             virtual std::vector<MWGui::MessageBox*> getActiveMessageBoxes() = 0; | ||||||
| 
 | 
 | ||||||
|             /// Make the player use an item, while updating GUI state accordingly
 |             /// Make the player use an item, while updating GUI state accordingly
 | ||||||
|             virtual void useItem(const MWWorld::Ptr& item, bool force=false) = 0; |             virtual void useItem(const MWWorld::Ptr& item, bool force=false) = 0; | ||||||
|  |  | ||||||
|  | @ -161,6 +161,12 @@ namespace MWGui | ||||||
|         return false; |         return false; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  |     std::vector<MessageBox*> MessageBoxManager::getActiveMessageBoxes() | ||||||
|  |     { | ||||||
|  |         return mMessageBoxes; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|     int MessageBoxManager::readPressedButton (bool reset) |     int MessageBoxManager::readPressedButton (bool reset) | ||||||
|     { |     { | ||||||
|         int pressed = mLastButtonPressed; |         int pressed = mLastButtonPressed; | ||||||
|  | @ -202,6 +208,11 @@ namespace MWGui | ||||||
|         mMainWidget->setPosition(pos); |         mMainWidget->setPosition(pos); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  |     std::string MessageBox::getMessage() | ||||||
|  |     {  | ||||||
|  |         return mMessage; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|     int MessageBox::getHeight () |     int MessageBox::getHeight () | ||||||
|     { |     { | ||||||
|         return mMainWidget->getHeight()+mNextBoxPadding; |         return mMainWidget->getHeight()+mNextBoxPadding; | ||||||
|  |  | ||||||
|  | @ -49,6 +49,8 @@ namespace MWGui | ||||||
| 
 | 
 | ||||||
|             void setVisible(bool value); |             void setVisible(bool value); | ||||||
| 
 | 
 | ||||||
|  |             std::vector<MessageBox*> getActiveMessageBoxes(); | ||||||
|  | 
 | ||||||
|         private: |         private: | ||||||
|             std::vector<MessageBox*> mMessageBoxes; |             std::vector<MessageBox*> mMessageBoxes; | ||||||
|             InteractiveMessageBox* mInterMessageBoxe; |             InteractiveMessageBox* mInterMessageBoxe; | ||||||
|  | @ -63,6 +65,7 @@ namespace MWGui | ||||||
|         public: |         public: | ||||||
|             MessageBox (MessageBoxManager& parMessageBoxManager, const std::string& message); |             MessageBox (MessageBoxManager& parMessageBoxManager, const std::string& message); | ||||||
|             void setMessage (const std::string& message); |             void setMessage (const std::string& message); | ||||||
|  |             std::string getMessage(); | ||||||
|             int getHeight (); |             int getHeight (); | ||||||
|             void update (int height); |             void update (int height); | ||||||
|             void setVisible(bool value); |             void setVisible(bool value); | ||||||
|  | @ -72,7 +75,7 @@ namespace MWGui | ||||||
| 
 | 
 | ||||||
|         protected: |         protected: | ||||||
|             MessageBoxManager& mMessageBoxManager; |             MessageBoxManager& mMessageBoxManager; | ||||||
|             const std::string& mMessage; |             const std::string mMessage; | ||||||
|             MyGUI::EditBox* mMessageWidget; |             MyGUI::EditBox* mMessageWidget; | ||||||
|             int mBottomPadding; |             int mBottomPadding; | ||||||
|             int mNextBoxPadding; |             int mNextBoxPadding; | ||||||
|  |  | ||||||
|  | @ -771,6 +771,11 @@ namespace MWGui | ||||||
|         mMessageBoxManager->removeStaticMessageBox(); |         mMessageBoxManager->removeStaticMessageBox(); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  |     std::vector<MWGui::MessageBox*> WindowManager::getActiveMessageBoxes() | ||||||
|  |     { | ||||||
|  |         return mMessageBoxManager->getActiveMessageBoxes(); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|     int WindowManager::readPressedButton () |     int WindowManager::readPressedButton () | ||||||
|     { |     { | ||||||
|         return mMessageBoxManager->readPressedButton(); |         return mMessageBoxManager->readPressedButton(); | ||||||
|  |  | ||||||
|  | @ -187,6 +187,7 @@ namespace MWGui | ||||||
|     MWGui::CountDialog* getCountDialog() override; |     MWGui::CountDialog* getCountDialog() override; | ||||||
|     MWGui::ConfirmationDialog* getConfirmationDialog() override; |     MWGui::ConfirmationDialog* getConfirmationDialog() override; | ||||||
|     MWGui::TradeWindow* getTradeWindow() override; |     MWGui::TradeWindow* getTradeWindow() override; | ||||||
|  |     std::vector<MWGui::MessageBox*> getActiveMessageBoxes() override; | ||||||
| 
 | 
 | ||||||
|     /// Make the player use an item, while updating GUI state accordingly
 |     /// Make the player use an item, while updating GUI state accordingly
 | ||||||
|     void useItem(const MWWorld::Ptr& item, bool bypassBeastRestrictions=false) override; |     void useItem(const MWWorld::Ptr& item, bool bypassBeastRestrictions=false) override; | ||||||
|  |  | ||||||
|  | @ -22,6 +22,8 @@ | ||||||
| #include "../mwmechanics/npcstats.hpp" | #include "../mwmechanics/npcstats.hpp" | ||||||
| #include "../mwmechanics/actorutil.hpp" | #include "../mwmechanics/actorutil.hpp" | ||||||
| 
 | 
 | ||||||
|  | #include "../mwgui/messagebox.hpp" | ||||||
|  | 
 | ||||||
| #include "actions.hpp" | #include "actions.hpp" | ||||||
| #include "bindingsmanager.hpp" | #include "bindingsmanager.hpp" | ||||||
| 
 | 
 | ||||||
|  | @ -39,7 +41,6 @@ namespace MWInput | ||||||
|         , mAlwaysRunActive(Settings::Manager::getBool("always run", "Input")) |         , mAlwaysRunActive(Settings::Manager::getBool("always run", "Input")) | ||||||
|         , mSneaking(false) |         , mSneaking(false) | ||||||
|         , mAttemptJump(false) |         , mAttemptJump(false) | ||||||
|         , mOverencumberedMessageDelay(0.f) |  | ||||||
|         , mTimeIdle(0.f) |         , mTimeIdle(0.f) | ||||||
|     { |     { | ||||||
|     } |     } | ||||||
|  | @ -88,22 +89,26 @@ namespace MWInput | ||||||
|             { |             { | ||||||
|                 player.setUpDown(1); |                 player.setUpDown(1); | ||||||
|                 triedToMove = true; |                 triedToMove = true; | ||||||
|                 mOverencumberedMessageDelay = 0.f; |  | ||||||
|             } |             } | ||||||
| 
 | 
 | ||||||
|             // if player tried to start moving, but can't (due to being overencumbered), display a notification.
 |             // if player tried to start moving, but can't (due to being overencumbered), display a notification.
 | ||||||
|             if (triedToMove) |             if (triedToMove) | ||||||
|             { |             { | ||||||
|                 MWWorld::Ptr playerPtr = MWBase::Environment::get().getWorld ()->getPlayerPtr(); |                 MWWorld::Ptr playerPtr = MWBase::Environment::get().getWorld ()->getPlayerPtr(); | ||||||
|                 mOverencumberedMessageDelay -= dt; |  | ||||||
|                 if (playerPtr.getClass().getEncumbrance(playerPtr) > playerPtr.getClass().getCapacity(playerPtr)) |                 if (playerPtr.getClass().getEncumbrance(playerPtr) > playerPtr.getClass().getCapacity(playerPtr)) | ||||||
|                 { |                 { | ||||||
|                     player.setAutoMove (false); |                     player.setAutoMove (false); | ||||||
|                     if (mOverencumberedMessageDelay <= 0) |                     std::vector<MWGui::MessageBox*> msgboxs = MWBase::Environment::get().getWindowManager()->getActiveMessageBoxes(); | ||||||
|  |                     std::vector<MWGui::MessageBox*>::iterator it = std::find_if(msgboxs.begin(), msgboxs.end(), [](MWGui::MessageBox*& msg) | ||||||
|                     { |                     { | ||||||
|  |                         return (msg->getMessage() == "#{sNotifyMessage59}"); | ||||||
|  |                     }); | ||||||
|  | 
 | ||||||
|  |                     // if an overencumbered messagebox is already present, reset its expiry timer, otherwise create new one.
 | ||||||
|  |                     if (it != msgboxs.end()) | ||||||
|  |                         (*it)->mCurrentTime = 0; | ||||||
|  |                     else | ||||||
|                         MWBase::Environment::get().getWindowManager()->messageBox("#{sNotifyMessage59}"); |                         MWBase::Environment::get().getWindowManager()->messageBox("#{sNotifyMessage59}"); | ||||||
|                         mOverencumberedMessageDelay = 1.0; |  | ||||||
|                     } |  | ||||||
|                 } |                 } | ||||||
|             } |             } | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -67,7 +67,6 @@ namespace MWInput | ||||||
|         bool mSneaking; |         bool mSneaking; | ||||||
|         bool mAttemptJump; |         bool mAttemptJump; | ||||||
| 
 | 
 | ||||||
|         float mOverencumberedMessageDelay; |  | ||||||
|         float mTimeIdle; |         float mTimeIdle; | ||||||
|     }; |     }; | ||||||
| } | } | ||||||
|  |  | ||||||
		Loading…
	
		Reference in a new issue