Added some more menu sound theming tags.

Menu scroll sound now also applies to the fast select menu.
This commit is contained in:
Aloshi 2012-10-13 15:05:43 -05:00
parent 7f50376fd0
commit 65701c58c1
7 changed files with 54 additions and 11 deletions

View file

@ -103,7 +103,13 @@ Audio
Themes can also define menu sounds. Sounds should be in the .wav format.
`<menuScrollSound>` - path to the sound to play when the game list is scrolling.
`<menuScrollSound>` - path to the sound to play when the game list or fast select menu is scrolling.
`<menuSelectSound>` - path to the sound to play when the user selects something from the game list.
`<menuBackSound>` - path to the sound to play when the user "goes up" from a folder in the game list.
`<menuOpenSound>` - path to the sound to play when the user opens a menu (either the "main menu" or the fast select menu).
List of variables

View file

@ -1,3 +1,7 @@
October 13
-Added sound support through SDL_mixer.
-Added new theme tags for defining menu sounds. See THEMES.md for details.
October 10
-Added a theming tag for the Fast Select box's text.
-Fixed GuiBox background being positioned wrong.

View file

@ -6,7 +6,7 @@ const std::string GuiFastSelect::LETTERS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const int GuiFastSelect::SCROLLSPEED = 100;
const int GuiFastSelect::SCROLLDELAY = 507;
GuiFastSelect::GuiFastSelect(GuiComponent* parent, GuiList<FileData*>* list, char startLetter, GuiBoxData data, int textcolor)
GuiFastSelect::GuiFastSelect(GuiComponent* parent, GuiList<FileData*>* list, char startLetter, GuiBoxData data, int textcolor, Sound* scrollsound)
{
mLetterID = LETTERS.find(toupper(startLetter));
if(mLetterID == std::string::npos)
@ -17,6 +17,7 @@ GuiFastSelect::GuiFastSelect(GuiComponent* parent, GuiList<FileData*>* list, cha
mParent = parent;
mList = list;
mScrollSound = scrollsound;
mScrolling = false;
mScrollTimer = 0;
@ -25,7 +26,6 @@ GuiFastSelect::GuiFastSelect(GuiComponent* parent, GuiList<FileData*>* list, cha
unsigned int sw = Renderer::getScreenWidth(), sh = Renderer::getScreenHeight();
mBox = new GuiBox(sw * 0.2, sh * 0.2, sw * 0.6, sh * 0.6);
mBox->setData(data);
//addChild(mBox);
mTextColor = textcolor;
@ -58,14 +58,14 @@ void GuiFastSelect::onInput(InputManager::InputButton button, bool keyDown)
{
if(button == InputManager::UP && keyDown)
{
setLetterID(mLetterID - 1);
mScrollOffset = -1;
scroll();
}
if(button == InputManager::DOWN && keyDown)
{
setLetterID(mLetterID + 1);
mScrollOffset = 1;
scroll();
}
if((button == InputManager::UP || button == InputManager::DOWN) && !keyDown)
@ -98,9 +98,15 @@ void GuiFastSelect::onTick(int deltaTime)
if(mScrolling && mScrollTimer >= SCROLLSPEED)
{
mScrollTimer = 0;
scroll();
}
}
}
void GuiFastSelect::scroll()
{
setLetterID(mLetterID + mScrollOffset);
}
}
mScrollSound->play();
}
void GuiFastSelect::setLetterID(int id)

View file

@ -4,13 +4,14 @@
#include "../GuiComponent.h"
#include "../SystemData.h"
#include "../FolderData.h"
#include "../Sound.h"
#include "GuiList.h"
#include "GuiBox.h"
class GuiFastSelect : GuiComponent
{
public:
GuiFastSelect(GuiComponent* parent, GuiList<FileData*>* list, char startLetter, GuiBoxData data, int textcolor);
GuiFastSelect(GuiComponent* parent, GuiList<FileData*>* list, char startLetter, GuiBoxData data, int textcolor, Sound* scrollsound);
~GuiFastSelect();
void onRender();
@ -22,7 +23,7 @@ private:
static const int SCROLLDELAY;
void setListPos();
void scroll();
void setLetterID(int id);
GuiList<FileData*>* mList;
@ -35,6 +36,8 @@ private:
int mScrollTimer, mScrollOffset;
bool mScrolling;
Sound* mScrollSound;
};
#endif

View file

@ -113,6 +113,9 @@ void GuiGameList::onInput(InputManager::InputButton button, bool keyDown)
{
if(!keyDown)
{
//play select sound
mTheme->getMenuSelectSound()->play();
FileData* file = mList->getSelectedObject();
if(file->isFolder()) //if you selected a folder, add this directory to the stack, and use the selected one
{
@ -120,6 +123,9 @@ void GuiGameList::onInput(InputManager::InputButton button, bool keyDown)
mFolder = (FolderData*)file;
updateList();
}else{
//wait for the sound to finish or we'll never hear it...
while(mTheme->getMenuSelectSound()->isPlaying());
mSystem->launchGame((GameData*)file);
}
}
@ -132,6 +138,9 @@ void GuiGameList::onInput(InputManager::InputButton button, bool keyDown)
mFolderStack.pop();
updateList();
updateDetailData();
//play the back sound
mTheme->getMenuBackSound()->play();
}
//only allow switching systems if more than one exists (otherwise it'll reset your position when you switch and it's annoying)
@ -147,14 +156,16 @@ void GuiGameList::onInput(InputManager::InputButton button, bool keyDown)
}
}
//open the "start menu"
if(button == InputManager::MENU && keyDown)
{
new GuiMenu(this);
}
//open the fast select menu
if(button == InputManager::SELECT && keyDown)
{
new GuiFastSelect(this, mList, mList->getSelectedObject()->getName()[0], mTheme->getBoxData(), mTheme->getFastSelectColor());
new GuiFastSelect(this, mList, mList->getSelectedObject()->getName()[0], mTheme->getBoxData(), mTheme->getFastSelectColor(), mTheme->getMenuScrollSound());
}
if(mDetailed)
@ -232,6 +243,7 @@ void GuiGameList::updateDetailData()
//these are called when the menu opens/closes
void GuiGameList::onPause()
{
mTheme->getMenuOpenSound()->play();
InputManager::unregisterComponent(this);
}

View file

@ -25,6 +25,9 @@ int GuiTheme::getSelectedTextColor() { return mListSelectedColor; }
GuiBoxData GuiTheme::getBoxData() { return mBoxData; }
Sound* GuiTheme::getMenuScrollSound() { return &mMenuScrollSound; }
Sound* GuiTheme::getMenuSelectSound() { return &mMenuSelectSound; }
Sound* GuiTheme::getMenuBackSound() { return &mMenuBackSound; }
Sound* GuiTheme::getMenuOpenSound() { return &mMenuOpenSound; }
GuiTheme::GuiTheme(std::string path)
{
@ -64,6 +67,9 @@ void GuiTheme::setDefaults()
mBoxData.cornerPath = "";
mMenuScrollSound.loadFile("");
mMenuSelectSound.loadFile("");
mMenuBackSound.loadFile("");
mMenuOpenSound.loadFile("");
}
void GuiTheme::deleteComponents()
@ -132,7 +138,10 @@ void GuiTheme::readXML(std::string path)
mListTextOffsetX = strToFloat(root.child("listTextOffsetX").text().get(), mListTextOffsetX);
//sounds
mMenuScrollSound.loadFile(root.child("menuScrollSound").text().get());
mMenuScrollSound.loadFile(expandPath(root.child("menuScrollSound").text().get()));
mMenuSelectSound.loadFile(expandPath(root.child("menuSelectSound").text().get()));
mMenuBackSound.loadFile(expandPath(root.child("menuBackSound").text().get()));
mMenuOpenSound.loadFile(expandPath(root.child("menuOpenSound").text().get()));
//recursively create children for all <components> with proper parenting
createComponentChildren(root, this);

View file

@ -32,6 +32,9 @@ public:
GuiBoxData getBoxData();
Sound* getMenuScrollSound();
Sound* getMenuSelectSound();
Sound* getMenuBackSound();
Sound* getMenuOpenSound();
private:
void setDefaults();
void deleteComponents();
@ -54,7 +57,7 @@ private:
GuiBoxData mBoxData;
Sound mMenuScrollSound;
Sound mMenuScrollSound, mMenuSelectSound, mMenuBackSound, mMenuOpenSound;
};
#endif