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

View file

@ -27,13 +27,15 @@ std::map<std::string, ImageDef> ThemeData::sDefaultImages = boost::assign::map_l
("backgroundImage", ImageDef("", true))
("headerImage", 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
("scrollSound", SoundDef(""))
("gameSelectSound", SoundDef(""))
("backSound", SoundDef(""))
("menuOpenSound", SoundDef(""));
("menuOpenSound", SoundDef(""))
("menuCloseSound", SoundDef(""));

View file

@ -6,13 +6,14 @@
static const std::string LETTERS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
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);
setSize(Renderer::getScreenWidth() * 0.6f, Renderer::getScreenHeight() * 0.6f);
const std::shared_ptr<ThemeData>& theme = mGameList->getTheme();
mBackground.setImagePath(theme->getImage("fastSelectBackgroundImage").path);
mBackground.fitTo(mSize);
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));
addChild(&mBackground);
std::shared_ptr<ThemeData> theme = std::make_shared<ThemeData>();
theme->setFont("listFont", FontDef(0.09f, theme->getFontDef("listFont").path));
theme->setColor("listSelectorColor", 0xBBBBBBFF);
theme->setColor("listPrimaryColor", 0x0000FFFF);
theme->setColor("listSecondaryColor", 0xFF0000FF);
mList.setTheme(theme);
mTheme = std::make_shared<ThemeData>();
mTheme->setFont("listFont", FontDef(0.09f, mTheme->getFontDef("listFont").path));
mTheme->setColor("listSelectorColor", 0xBBBBBBFF);
mTheme->setColor("listPrimaryColor", 0x0000FFFF);
mTheme->setColor("listSecondaryColor", 0xFF0000FF);
mList.setTheme(mTheme);
addChild(&mList);
}
@ -54,6 +54,7 @@ bool GuiMenu::input(InputConfig* config, Input input)
{
if(config->isMappedTo("b", input) || config->isMappedTo("menu", input))
{
mTheme->playSound("menuCloseSound");
delete this;
return true;
}else if(config->isMappedTo("a", input) && mList.getList().size() > 0)

View file

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

View file

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

View file

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

View file

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