diff --git a/THEMES.md b/THEMES.md index b472a41d3..a85846650 100644 --- a/THEMES.md +++ b/THEMES.md @@ -77,6 +77,8 @@ Or, you can create your own elements by adding `extra="true"` (as is done in the Advanced Features ================= +It is recommended that if you are writing a theme you launch EmulationStation with the `--debug` and `--windowed` switches. This way you can read error messages without having to check the log file. You can also reload the current gamelist view with `Ctrl-R` if `--debug` is specified. + ### The `` tag You can include theme files within theme files, similar to `#include` in C (though the mechanism is different, the effect is the same). Example: diff --git a/src/SystemData.cpp b/src/SystemData.cpp index a0ee45567..486c809ee 100644 --- a/src/SystemData.cpp +++ b/src/SystemData.cpp @@ -46,15 +46,7 @@ SystemData::SystemData(const std::string& name, const std::string& fullName, con mRootFolder->sort(FileSorts::SortTypes.at(0)); - mTheme = std::make_shared(); - try - { - mTheme->loadFile(getThemePath()); - } catch(ThemeException& e) - { - LOG(LogError) << e.what(); - mTheme = std::make_shared(); // reset to empty - } + loadTheme(); } SystemData::~SystemData() @@ -384,3 +376,16 @@ unsigned int SystemData::getGameCount() const { return mRootFolder->getFilesRecursive(GAME).size(); } + +void SystemData::loadTheme() +{ + mTheme = std::make_shared(); + try + { + mTheme->loadFile(getThemePath()); + } catch(ThemeException& e) + { + LOG(LogError) << e.what(); + mTheme = std::make_shared(); // reset to empty + } +} diff --git a/src/SystemData.h b/src/SystemData.h index 901b3756d..149a3afd4 100644 --- a/src/SystemData.h +++ b/src/SystemData.h @@ -58,6 +58,9 @@ public: return *it; } + // Load or re-load theme. + void loadTheme(); + private: std::string mName; std::string mFullName; diff --git a/src/views/ViewController.cpp b/src/views/ViewController.cpp index 7f6bcf922..d0b4dc8af 100644 --- a/src/views/ViewController.cpp +++ b/src/views/ViewController.cpp @@ -226,7 +226,7 @@ void ViewController::preload() } } -void ViewController::reloadGameListView(IGameListView* view) +void ViewController::reloadGameListView(IGameListView* view, bool reloadTheme) { for(auto it = mGameListViews.begin(); it != mGameListViews.end(); it++) { @@ -237,6 +237,9 @@ void ViewController::reloadGameListView(IGameListView* view) FileData* cursor = view->getCursor(); mGameListViews.erase(it); + if(reloadTheme) + system->loadTheme(); + std::shared_ptr newView = getGameListView(system); newView->setCursor(cursor); diff --git a/src/views/ViewController.h b/src/views/ViewController.h index a924d9f58..b2225275e 100644 --- a/src/views/ViewController.h +++ b/src/views/ViewController.h @@ -16,7 +16,7 @@ public: // If a basic view detected a metadata change, it can request to recreate // the current gamelist view (as it may change to be detailed). - void reloadGameListView(IGameListView* gamelist); + void reloadGameListView(IGameListView* gamelist, bool reloadTheme = false); // Navigation. void goToNextGameList(); diff --git a/src/views/gamelist/IGameListView.cpp b/src/views/gamelist/IGameListView.cpp index 096db00ce..3e8574db5 100644 --- a/src/views/gamelist/IGameListView.cpp +++ b/src/views/gamelist/IGameListView.cpp @@ -4,9 +4,11 @@ #include "../../components/GuiMenu.h" #include "../../components/GuiFastSelect.h" #include "../ViewController.h" +#include "../../Settings.h" bool IGameListView::input(InputConfig* config, Input input) { + // F3 to open metadata editor if(config->getDeviceId() == DEVICE_KEYBOARD && input.id == SDLK_F3 && input.value != 0) { // open metadata editor @@ -23,6 +25,15 @@ bool IGameListView::input(InputConfig* config, Input input) })); Sound::getFromTheme(mTheme, getName(), "menuOpen")->play(); return true; + + // Ctrl-R to reload a view when debugging + }else if(Settings::getInstance()->getBool("DEBUG") && config->getDeviceId() == DEVICE_KEYBOARD && + (SDL_GetModState() & (KMOD_LCTRL | KMOD_RCTRL)) && input.id == SDLK_r && input.value != 0) + { + LOG(LogDebug) << "reloading view"; + mWindow->getViewController()->reloadGameListView(this, true); + return true; + // select opens the fast select GUI }else if(config->isMappedTo("select", input) && input.value != 0) { // open fast select