Having "highlight" sound effect play as soon as you press the button instead of when the item is highlighed.

This commit is contained in:
emb 2015-03-06 16:19:41 -06:00
parent e07b00f707
commit 692c098bf0
2 changed files with 7 additions and 17 deletions

View File

@ -38,8 +38,6 @@ Page::Page(Configuration &config)
, UnloadSoundChunk(NULL) , UnloadSoundChunk(NULL)
, HighlightSoundChunk(NULL) , HighlightSoundChunk(NULL)
, SelectSoundChunk(NULL) , SelectSoundChunk(NULL)
, HasSoundedWhenActive(false)
, FirstSoundPlayed(false)
, MinShowTime(0) , MinShowTime(0)
{ {
} }
@ -324,6 +322,7 @@ void Page::Highlight()
void Page::SetScrolling(ScrollDirection direction) void Page::SetScrolling(ScrollDirection direction)
{ {
ScrollingList::ScrollDirection menuDirection; ScrollingList::ScrollDirection menuDirection;
bool prevScrollActive = ScrollActive;
switch(direction) switch(direction)
{ {
@ -342,6 +341,12 @@ void Page::SetScrolling(ScrollDirection direction)
break; break;
} }
if(!prevScrollActive && ScrollActive && HighlightSoundChunk)
{
HighlightSoundChunk->Play();
}
ActiveMenu->SetScrollDirection(menuDirection); ActiveMenu->SetScrollDirection(menuDirection);
} }
@ -486,22 +491,10 @@ void Page::Update(float dt)
menu->Update(dt); menu->Update(dt);
} }
if(SelectedItemChanged && !HasSoundedWhenActive && HighlightSoundChunk)
{
// skip the first sound being played (as it is part of the on-enter)
if(FirstSoundPlayed)
{
HighlightSoundChunk->Play();
HasSoundedWhenActive = true;
}
FirstSoundPlayed = true;
}
if(SelectedItemChanged && !ScrollActive) if(SelectedItemChanged && !ScrollActive)
{ {
Highlight(); Highlight();
SelectedItemChanged = false; SelectedItemChanged = false;
HasSoundedWhenActive = false;
} }
if(TextStatusComponent) if(TextStatusComponent)
@ -572,7 +565,6 @@ void Page::FreeGraphicsMemory()
void Page::AllocateGraphicsMemory() void Page::AllocateGraphicsMemory()
{ {
FirstSoundPlayed = false;
Logger::Write(Logger::ZONE_DEBUG, "Page", "Allocating graphics memory"); Logger::Write(Logger::ZONE_DEBUG, "Page", "Allocating graphics memory");
for(MenuVector_T::iterator it = Menus.begin(); it != Menus.end(); it++) for(MenuVector_T::iterator it = Menus.begin(); it != Menus.end(); it++)

View File

@ -100,8 +100,6 @@ private:
Sound *UnloadSoundChunk; Sound *UnloadSoundChunk;
Sound *HighlightSoundChunk; Sound *HighlightSoundChunk;
Sound *SelectSoundChunk; Sound *SelectSoundChunk;
bool HasSoundedWhenActive;
bool FirstSoundPlayed;
float MinShowTime; float MinShowTime;
float ElapsedTime; float ElapsedTime;