diff --git a/THEMES.md b/THEMES.md index d8e2ecd9d..15801a157 100644 --- a/THEMES.md +++ b/THEMES.md @@ -102,6 +102,7 @@ Pretty much any image format is supported. `` - No default. `` - No default. `` - No default. +`` - Nine patch. Default is the "button.png" resource. Sounds ====== @@ -110,10 +111,11 @@ Sounds are defined like this: `./some/path/here.wav` Only .wav files are supported. -`` - No default. -`` - No default. -`` - No default. -`` - No default. +`` - No default. Played when a list scrolls. +`` - No default. Played when a game is launched. +`` - No default. Played when leaving a folder in the game list. +`` - No default. Played when the menu is opened. +`` - No default. Played when the menu is closed. Nine Patches diff --git a/src/ThemeData.cpp b/src/ThemeData.cpp index 62b60949e..06749c476 100644 --- a/src/ThemeData.cpp +++ b/src/ThemeData.cpp @@ -27,13 +27,15 @@ std::map 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 ThemeData::sDefaultSounds = boost::assign::map_list_of ("scrollSound", SoundDef("")) ("gameSelectSound", SoundDef("")) ("backSound", SoundDef("")) - ("menuOpenSound", SoundDef("")); + ("menuOpenSound", SoundDef("")) + ("menuCloseSound", SoundDef("")); diff --git a/src/components/GuiFastSelect.cpp b/src/components/GuiFastSelect.cpp index f56acf0ef..0022f4abc 100644 --- a/src/components/GuiFastSelect.cpp +++ b/src/components/GuiFastSelect.cpp @@ -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& theme = mGameList->getTheme(); + mBackground.setImagePath(theme->getImage("fastSelectBackgroundImage").path); mBackground.fitTo(mSize); addChild(&mBackground); diff --git a/src/components/GuiMenu.cpp b/src/components/GuiMenu.cpp index 653c745fc..da4884a3d 100644 --- a/src/components/GuiMenu.cpp +++ b/src/components/GuiMenu.cpp @@ -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 theme = std::make_shared(); - 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(); + 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) diff --git a/src/components/GuiMenu.h b/src/components/GuiMenu.h index 17249b7f3..a620435dd 100644 --- a/src/components/GuiMenu.h +++ b/src/components/GuiMenu.h @@ -13,6 +13,7 @@ public: bool input(InputConfig* config, Input input) override; private: + std::shared_ptr mTheme; NinePatchComponent mBackground; TextListComponent< std::function > mList; }; diff --git a/src/views/BasicGameListView.cpp b/src/views/BasicGameListView.cpp index 008411544..bc6a4e829 100644 --- a/src/views/BasicGameListView.cpp +++ b/src/views/BasicGameListView.cpp @@ -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(); diff --git a/src/views/GameListView.cpp b/src/views/GameListView.cpp index 56f9d7655..b819b3fe4 100644 --- a/src/views/GameListView.cpp +++ b/src/views/GameListView.cpp @@ -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); diff --git a/src/views/ViewController.cpp b/src/views/ViewController.cpp index eb18e758d..8a6e32fcb 100644 --- a/src/views/ViewController.cpp +++ b/src/views/ViewController.cpp @@ -86,6 +86,7 @@ void ViewController::launch(FileData* game) } // Effect TODO + game->getSystem()->getTheme()->playSound("gameSelectSound"); game->getSystem()->launchGame(mWindow, game); }