Associate open/close sounds with the GUI mode

pull/303/head
scrawl 7 years ago
parent 531e7ac586
commit 20766fb508

@ -117,9 +117,9 @@ namespace MWBase
virtual void pushGuiMode (MWGui::GuiMode mode, const MWWorld::Ptr& arg) = 0;
virtual void pushGuiMode (MWGui::GuiMode mode) = 0;
virtual void popGuiMode() = 0;
virtual void popGuiMode(bool noSound=false) = 0;
virtual void removeGuiMode (MWGui::GuiMode mode) = 0;
virtual void removeGuiMode (MWGui::GuiMode mode, bool noSound=false) = 0;
///< can be anywhere in the stack
virtual void goToJail(int days) = 0;

@ -85,8 +85,6 @@ namespace MWGui
clearPages();
mCurrentPage = 0;
MWBase::Environment::get().getWindowManager()->playSound("book open");
MWWorld::LiveCellRef<ESM::Book> *ref = mBook.get<ESM::Book>();
Formatting::BookFormatter formatter;
@ -100,9 +98,6 @@ namespace MWGui
void BookWindow::exit()
{
// no 3d sounds because the object could be in a container.
MWBase::Environment::get().getWindowManager()->playSound("book close");
MWBase::Environment::get().getWindowManager()->removeGuiMode(GM_Book);
}

@ -52,9 +52,6 @@ namespace MWGui
void ScrollWindow::setPtr (const MWWorld::Ptr& scroll)
{
// no 3d sounds because the object could be in a container.
MWBase::Environment::get().getWindowManager()->playSound("scroll");
mScroll = scroll;
MWWorld::Ptr player = MWMechanics::getPlayer();
@ -81,8 +78,6 @@ namespace MWGui
void ScrollWindow::exit()
{
MWBase::Environment::get().getWindowManager()->playSound("scroll");
MWBase::Environment::get().getWindowManager()->removeGuiMode(GM_Scroll);
}
@ -110,6 +105,6 @@ namespace MWGui
MWWorld::ActionTake take(mScroll);
take.execute (MWMechanics::getPlayer());
MWBase::Environment::get().getWindowManager()->removeGuiMode(GM_Scroll);
MWBase::Environment::get().getWindowManager()->removeGuiMode(GM_Scroll, true);
}
}

@ -354,6 +354,8 @@ namespace MWGui
bool questList = mResourceSystem->getVFS()->exists("textures/tx_menubook_options_over.dds");
mJournal = JournalWindow::create(JournalViewModel::create (), questList);
mGuiModeStates[GM_Journal] = GuiModeState(mJournal);
mGuiModeStates[GM_Journal].mCloseSound = "book close";
mGuiModeStates[GM_Journal].mOpenSound = "book open";
mMessageBoxManager = new MessageBoxManager(mStore->get<ESM::GameSetting>().find("fMessageTimePerChar")->getFloat());
mSpellBuyingWindow = new SpellBuyingWindow();
@ -374,9 +376,13 @@ namespace MWGui
mToolTips = new ToolTips();
mScrollWindow = new ScrollWindow();
mGuiModeStates[GM_Scroll] = GuiModeState(mScrollWindow);
mGuiModeStates[GM_Scroll].mOpenSound = "scroll";
mGuiModeStates[GM_Scroll].mCloseSound = "scroll";
mBookWindow = new BookWindow();
mGuiModeStates[GM_Book] = GuiModeState(mBookWindow);
mGuiModeStates[GM_Book].mOpenSound = "book open";
mGuiModeStates[GM_Book].mCloseSound = "book close";
mCountDialog = new CountDialog();
mSettingsWindow = new SettingsWindow();
@ -840,7 +846,6 @@ namespace MWGui
mRepair->exit();
break;
case GM_Journal:
playSound("book close");
removeGuiMode(GM_Journal); //Simple way to remove it
break;
default:
@ -1242,6 +1247,7 @@ namespace MWGui
mGuiModes.push_back(mode);
mGuiModeStates[mode].update(true);
playSound(mGuiModeStates[mode].mOpenSound);
}
for (WindowBase* window : mGuiModeStates[mode].mWindows)
window->setPtr(arg);
@ -1252,7 +1258,7 @@ namespace MWGui
updateVisible();
}
void WindowManager::popGuiMode()
void WindowManager::popGuiMode(bool noSound)
{
if (mDragAndDrop && mDragAndDrop->mIsOnDragAndDrop)
{
@ -1262,6 +1268,8 @@ namespace MWGui
if (!mGuiModes.empty())
{
mGuiModeStates[mGuiModes.back()].update(false);
if (!noSound)
playSound(mGuiModeStates[mGuiModes.back()].mCloseSound);
mGuiModes.pop_back();
}
@ -1274,11 +1282,11 @@ namespace MWGui
updateVisible();
}
void WindowManager::removeGuiMode(GuiMode mode)
void WindowManager::removeGuiMode(GuiMode mode, bool noSound)
{
if (!mGuiModes.empty() && mGuiModes.back() == mode)
{
popGuiMode();
popGuiMode(noSound);
return;
}
@ -1992,6 +2000,8 @@ namespace MWGui
void WindowManager::playSound(const std::string& soundId, float volume, float pitch)
{
if (soundId.empty())
return;
MWBase::Environment::get().getSoundManager()->playSound(soundId, volume, pitch, MWSound::Type::Sfx, MWSound::PlayMode::NoEnv);
}

@ -162,8 +162,8 @@ namespace MWGui
virtual void pushGuiMode(GuiMode mode, const MWWorld::Ptr& arg);
virtual void pushGuiMode (GuiMode mode);
virtual void popGuiMode();
virtual void removeGuiMode(GuiMode mode); ///< can be anywhere in the stack
virtual void popGuiMode(bool noSound=false);
virtual void removeGuiMode(GuiMode mode, bool noSound=false); ///< can be anywhere in the stack
virtual void goToJail(int days);
@ -497,6 +497,9 @@ namespace MWGui
std::vector<WindowBase*> mWindows;
std::vector<bool> mVisibilityMask; // optional, may be used to temporarily exclude windows from this mode.
std::string mCloseSound;
std::string mOpenSound;
};
// Defines the windows that should be shown in a particular GUI mode.
std::map<GuiMode, GuiModeState> mGuiModeStates;

@ -1039,12 +1039,10 @@ namespace MWInput
&& MWBase::Environment::get().getWindowManager()->getMode() != MWGui::GM_MainMenu
&& MWBase::Environment::get().getWindowManager ()->getJournalAllowed())
{
MWBase::Environment::get().getWindowManager()->playSound ("book open");
MWBase::Environment::get().getWindowManager()->pushGuiMode(MWGui::GM_Journal);
}
else if(MWBase::Environment::get().getWindowManager()->containsMode(MWGui::GM_Journal))
{
MWBase::Environment::get().getWindowManager()->playSound ("book close");
MWBase::Environment::get().getWindowManager()->removeGuiMode(MWGui::GM_Journal);
}
}

Loading…
Cancel
Save