Merge pull request #2514 from akortunov/guifixes

Generate sCrimeMessageReport only once per frame
pull/541/head
Alexei Dobrohotov 5 years ago committed by GitHub
commit 2e05e0e829
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -104,6 +104,7 @@
Bug #4999: Drop instruction behaves differently from vanilla Bug #4999: Drop instruction behaves differently from vanilla
Bug #5001: Possible data race in the Animation::setAlpha() Bug #5001: Possible data race in the Animation::setAlpha()
Bug #5004: Werewolves shield their eyes during storm Bug #5004: Werewolves shield their eyes during storm
Bug #5012: "Take all" on owned container generates a messagebox per item
Bug #5018: Spell tooltips don't support purely negative magnitudes Bug #5018: Spell tooltips don't support purely negative magnitudes
Bug #5025: Data race in the ICO::setMaximumNumOfObjectsToCompilePerFrame() Bug #5025: Data race in the ICO::setMaximumNumOfObjectsToCompilePerFrame()
Bug #5028: Offered price caps are not trading-specific Bug #5028: Offered price caps are not trading-specific

@ -100,9 +100,12 @@ namespace MWBase
///< Say some text, without an actor ref ///< Say some text, without an actor ref
/// \param filename name of a sound file in "Sound/" in the data directory. /// \param filename name of a sound file in "Sound/" in the data directory.
virtual bool sayDone(const MWWorld::ConstPtr &reference=MWWorld::ConstPtr()) const = 0; virtual bool sayActive(const MWWorld::ConstPtr &reference=MWWorld::ConstPtr()) const = 0;
///< Is actor not speaking? ///< Is actor not speaking?
virtual bool sayDone(const MWWorld::ConstPtr &reference=MWWorld::ConstPtr()) const = 0;
///< For scripting backward compatibility
virtual void stopSay(const MWWorld::ConstPtr &reference=MWWorld::ConstPtr()) = 0; virtual void stopSay(const MWWorld::ConstPtr &reference=MWWorld::ConstPtr()) = 0;
///< Stop an actor speaking ///< Stop an actor speaking

@ -540,7 +540,7 @@ namespace MWDialogue
void DialogueManager::say(const MWWorld::Ptr &actor, const std::string &topic) void DialogueManager::say(const MWWorld::Ptr &actor, const std::string &topic)
{ {
MWBase::SoundManager *sndMgr = MWBase::Environment::get().getSoundManager(); MWBase::SoundManager *sndMgr = MWBase::Environment::get().getSoundManager();
if(!sndMgr->sayDone(actor)) if(sndMgr->sayActive(actor))
{ {
// Actor is already saying something. // Actor is already saying something.
return; return;

@ -175,6 +175,7 @@ namespace MWGui
, mHudEnabled(true) , mHudEnabled(true)
, mCursorVisible(true) , mCursorVisible(true)
, mCursorActive(false) , mCursorActive(false)
, mPlayerBounty(-1)
, mPlayerName() , mPlayerName()
, mPlayerRaceId() , mPlayerRaceId()
, mPlayerAttributes() , mPlayerAttributes()
@ -1025,6 +1026,18 @@ namespace MWGui
if (!gameRunning) if (!gameRunning)
return; return;
// We should display message about crime only once per frame, even if there are several crimes.
// Otherwise we will get message spam when stealing several items via Take All button.
const MWWorld::Ptr player = MWMechanics::getPlayer();
int currentBounty = player.getClass().getNpcStats(player).getBounty();
if (currentBounty != mPlayerBounty)
{
if (mPlayerBounty >= 0 && currentBounty > mPlayerBounty)
messageBox("#{sCrimeMessage}");
mPlayerBounty = currentBounty;
}
mDragAndDrop->onFrame(); mDragAndDrop->onFrame();
mHud->onFrame(frameDuration); mHud->onFrame(frameDuration);
@ -1773,6 +1786,8 @@ namespace MWGui
void WindowManager::clear() void WindowManager::clear()
{ {
mPlayerBounty = -1;
for (WindowBase* window : mWindows) for (WindowBase* window : mWindows)
window->clear(); window->clear();

@ -462,6 +462,8 @@ namespace MWGui
bool mCursorVisible; bool mCursorVisible;
bool mCursorActive; bool mCursorActive;
int mPlayerBounty;
void setCursorVisible(bool visible); void setCursorVisible(bool visible);
/// \todo get rid of this stuff. Move it to the respective UI element classes, if needed. /// \todo get rid of this stuff. Move it to the respective UI element classes, if needed.

@ -372,7 +372,7 @@ namespace MWMechanics
void Actors::playIdleDialogue(const MWWorld::Ptr& actor) void Actors::playIdleDialogue(const MWWorld::Ptr& actor)
{ {
if (!actor.getClass().isActor() || actor == getPlayer() || !MWBase::Environment::get().getSoundManager()->sayDone(actor)) if (!actor.getClass().isActor() || actor == getPlayer() || MWBase::Environment::get().getSoundManager()->sayActive(actor))
return; return;
const CreatureStats &stats = actor.getClass().getCreatureStats(actor); const CreatureStats &stats = actor.getClass().getCreatureStats(actor);

@ -1452,7 +1452,6 @@ namespace MWMechanics
if (reported) if (reported)
{ {
MWBase::Environment::get().getWindowManager()->messageBox("#{sCrimeMessage}");
player.getClass().getNpcStats(player).setBounty(player.getClass().getNpcStats(player).getBounty() player.getClass().getNpcStats(player).setBounty(player.getClass().getNpcStats(player).getBounty()
+ arg); + arg);
@ -1923,7 +1922,6 @@ namespace MWMechanics
{ {
npcStats.setBounty(npcStats.getBounty()+ npcStats.setBounty(npcStats.getBounty()+
gmst.find("iWereWolfBounty")->mValue.getInteger()); gmst.find("iWereWolfBounty")->mValue.getInteger());
windowManager->messageBox("#{sCrimeMessage}");
} }
} }
} }

@ -184,7 +184,7 @@ void HeadAnimationTime::update(float dt)
if (!mEnabled) if (!mEnabled)
return; return;
if (MWBase::Environment::get().getSoundManager()->sayDone(mReference)) if (!MWBase::Environment::get().getSoundManager()->sayActive(mReference))
{ {
mBlinkTimer += dt; mBlinkTimer += dt;

@ -566,6 +566,27 @@ namespace MWSound
return true; return true;
} }
bool SoundManager::sayActive(const MWWorld::ConstPtr &ptr) const
{
SaySoundMap::const_iterator snditer = mSaySoundsQueue.find(ptr);
if(snditer != mSaySoundsQueue.end())
{
if(mOutput->isStreamPlaying(snditer->second))
return true;
return false;
}
snditer = mActiveSaySounds.find(ptr);
if(snditer != mActiveSaySounds.end())
{
if(mOutput->isStreamPlaying(snditer->second))
return true;
return false;
}
return false;
}
void SoundManager::stopSay(const MWWorld::ConstPtr &ptr) void SoundManager::stopSay(const MWWorld::ConstPtr &ptr)
{ {
SaySoundMap::iterator snditer = mSaySoundsQueue.find(ptr); SaySoundMap::iterator snditer = mSaySoundsQueue.find(ptr);

@ -179,9 +179,12 @@ namespace MWSound
///< Say some text, without an actor ref ///< Say some text, without an actor ref
/// \param filename name of a sound file in "Sound/" in the data directory. /// \param filename name of a sound file in "Sound/" in the data directory.
virtual bool sayDone(const MWWorld::ConstPtr &reference=MWWorld::ConstPtr()) const; virtual bool sayActive(const MWWorld::ConstPtr &reference=MWWorld::ConstPtr()) const;
///< Is actor not speaking? ///< Is actor not speaking?
virtual bool sayDone(const MWWorld::ConstPtr &reference=MWWorld::ConstPtr()) const;
///< For scripting backward compatibility
virtual void stopSay(const MWWorld::ConstPtr &reference=MWWorld::ConstPtr()); virtual void stopSay(const MWWorld::ConstPtr &reference=MWWorld::ConstPtr());
///< Stop an actor speaking ///< Stop an actor speaking

Loading…
Cancel
Save