Added fastSelectBackgroundImage and menuCloseSound to ThemeData, implemented some missing sounds.

This commit is contained in:
Aloshi 2013-11-28 13:52:21 -06:00
parent 0cfa38fcf9
commit 25a4c8a2e5
8 changed files with 26 additions and 13 deletions

View file

@ -102,6 +102,7 @@ Pretty much any image format is supported.
`<headerImage>` - No default. `<headerImage>` - No default.
`<infoBackgroundImage>` - No default. `<infoBackgroundImage>` - No default.
`<verticalDividerImage>` - No default. `<verticalDividerImage>` - No default.
`<fastSelectBackgroundImage>` - Nine patch. Default is the "button.png" resource.
Sounds Sounds
====== ======
@ -110,10 +111,11 @@ Sounds are defined like this:
`<resourceName>./some/path/here.wav</resourceName>` `<resourceName>./some/path/here.wav</resourceName>`
Only .wav files are supported. Only .wav files are supported.
`<scrollSound>` - No default. `<scrollSound>` - No default. Played when a list scrolls.
`<gameSelectSound>` - No default. `<gameSelectSound>` - No default. Played when a game is launched.
`<backSound>` - No default. `<backSound>` - No default. Played when leaving a folder in the game list.
`<menuOpenSound>` - No default. `<menuOpenSound>` - No default. Played when the menu is opened.
`<menuCloseSound>` - No default. Played when the menu is closed.
Nine Patches Nine Patches

View file

@ -27,13 +27,15 @@ std::map<std::string, ImageDef> ThemeData::sDefaultImages = boost::assign::map_l
("backgroundImage", ImageDef("", true)) ("backgroundImage", ImageDef("", true))
("headerImage", ImageDef("", false)) ("headerImage", ImageDef("", false))
("infoBackgroundImage", ImageDef("", false)) ("infoBackgroundImage", ImageDef("", false))
("verticalDividerImage", ImageDef("", false)); ("verticalDividerImage", ImageDef("", false))
("fastSelectBackgroundImage", ImageDef(":/button.png", false));
std::map<std::string, SoundDef> ThemeData::sDefaultSounds = boost::assign::map_list_of std::map<std::string, SoundDef> ThemeData::sDefaultSounds = boost::assign::map_list_of
("scrollSound", SoundDef("")) ("scrollSound", SoundDef(""))
("gameSelectSound", SoundDef("")) ("gameSelectSound", SoundDef(""))
("backSound", SoundDef("")) ("backSound", SoundDef(""))
("menuOpenSound", SoundDef("")); ("menuOpenSound", SoundDef(""))
("menuCloseSound", SoundDef(""));

View file

@ -6,13 +6,14 @@
static const std::string LETTERS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; static const std::string LETTERS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
GuiFastSelect::GuiFastSelect(Window* window, GameListView* gamelist) : GuiComponent(window), GuiFastSelect::GuiFastSelect(Window* window, GameListView* gamelist) : GuiComponent(window),
mBackground(window, ":/button.png"), mSortText(window), mLetterText(window), mGameList(gamelist) mBackground(window), mSortText(window), mLetterText(window), mGameList(gamelist)
{ {
setPosition(Renderer::getScreenWidth() * 0.2f, Renderer::getScreenHeight() * 0.2f); setPosition(Renderer::getScreenWidth() * 0.2f, Renderer::getScreenHeight() * 0.2f);
setSize(Renderer::getScreenWidth() * 0.6f, Renderer::getScreenHeight() * 0.6f); setSize(Renderer::getScreenWidth() * 0.6f, Renderer::getScreenHeight() * 0.6f);
const std::shared_ptr<ThemeData>& theme = mGameList->getTheme(); const std::shared_ptr<ThemeData>& theme = mGameList->getTheme();
mBackground.setImagePath(theme->getImage("fastSelectBackgroundImage").path);
mBackground.fitTo(mSize); mBackground.fitTo(mSize);
addChild(&mBackground); addChild(&mBackground);

View file

@ -38,12 +38,12 @@ GuiMenu::GuiMenu(Window* window) : GuiComponent(window), mBackground(window, ":/
mBackground.fitTo(Eigen::Vector2f(mList.getSize().x(), mSize.y()), Eigen::Vector3f(mList.getPosition().x(), 0, 0)); mBackground.fitTo(Eigen::Vector2f(mList.getSize().x(), mSize.y()), Eigen::Vector3f(mList.getPosition().x(), 0, 0));
addChild(&mBackground); addChild(&mBackground);
std::shared_ptr<ThemeData> theme = std::make_shared<ThemeData>(); mTheme = std::make_shared<ThemeData>();
theme->setFont("listFont", FontDef(0.09f, theme->getFontDef("listFont").path)); mTheme->setFont("listFont", FontDef(0.09f, mTheme->getFontDef("listFont").path));
theme->setColor("listSelectorColor", 0xBBBBBBFF); mTheme->setColor("listSelectorColor", 0xBBBBBBFF);
theme->setColor("listPrimaryColor", 0x0000FFFF); mTheme->setColor("listPrimaryColor", 0x0000FFFF);
theme->setColor("listSecondaryColor", 0xFF0000FF); mTheme->setColor("listSecondaryColor", 0xFF0000FF);
mList.setTheme(theme); mList.setTheme(mTheme);
addChild(&mList); addChild(&mList);
} }
@ -54,6 +54,7 @@ bool GuiMenu::input(InputConfig* config, Input input)
{ {
if(config->isMappedTo("b", input) || config->isMappedTo("menu", input)) if(config->isMappedTo("b", input) || config->isMappedTo("menu", input))
{ {
mTheme->playSound("menuCloseSound");
delete this; delete this;
return true; return true;
}else if(config->isMappedTo("a", input) && mList.getList().size() > 0) }else if(config->isMappedTo("a", input) && mList.getList().size() > 0)

View file

@ -13,6 +13,7 @@ public:
bool input(InputConfig* config, Input input) override; bool input(InputConfig* config, Input input) override;
private: private:
std::shared_ptr<ThemeData> mTheme;
NinePatchComponent mBackground; NinePatchComponent mBackground;
TextListComponent< std::function<void()> > mList; TextListComponent< std::function<void()> > mList;
}; };

View file

@ -159,6 +159,7 @@ bool BasicGameListView::input(InputConfig* config, Input input)
populateList(mCursorStack.top()->getParent()); populateList(mCursorStack.top()->getParent());
mList.setCursor(mCursorStack.top()); mList.setCursor(mCursorStack.top());
mCursorStack.pop(); mCursorStack.pop();
mTheme->playSound("backSound");
}else{ }else{
mList.stopScrolling(); mList.stopScrolling();
mWindow->getViewController()->goToSystemSelect(); mWindow->getViewController()->goToSystemSelect();

View file

@ -21,15 +21,19 @@ bool GameListView::input(InputConfig* config, Input input)
onFileChanged(file, FILE_REMOVED); //tell the view onFileChanged(file, FILE_REMOVED); //tell the view
delete file; //free it delete file; //free it
})); }));
mTheme->playSound("menuOpenSound");
return true; return true;
}else if(config->isMappedTo("menu", input) && input.value != 0) }else if(config->isMappedTo("menu", input) && input.value != 0)
{ {
// open menu // open menu
mWindow->pushGui(new GuiMenu(mWindow)); mWindow->pushGui(new GuiMenu(mWindow));
mTheme->playSound("menuOpenSound");
return true;
}else if(config->isMappedTo("select", input) && input.value != 0) }else if(config->isMappedTo("select", input) && input.value != 0)
{ {
// open fast select // open fast select
mWindow->pushGui(new GuiFastSelect(mWindow, this)); mWindow->pushGui(new GuiFastSelect(mWindow, this));
return true;
} }
return GuiComponent::input(config, input); return GuiComponent::input(config, input);

View file

@ -86,6 +86,7 @@ void ViewController::launch(FileData* game)
} }
// Effect TODO // Effect TODO
game->getSystem()->getTheme()->playSound("gameSelectSound");
game->getSystem()->launchGame(mWindow, game); game->getSystem()->launchGame(mWindow, game);
} }