mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-11-25 07:35:38 +00:00
Added a utility to the menu for rescanning the ROM directory
Also added a new Utilities menu to the main menu
This commit is contained in:
parent
07d390ccda
commit
d27dd211c3
|
@ -88,28 +88,35 @@ CollectionSystemsManager* CollectionSystemsManager::getInstance()
|
|||
return &instance;
|
||||
}
|
||||
|
||||
void CollectionSystemsManager::deinit()
|
||||
void CollectionSystemsManager::deinit(const bool shutdown)
|
||||
{
|
||||
// Don't attempt to remove any collections if no systems exist.
|
||||
if (SystemData::sSystemVector.size() > 0) {
|
||||
removeCollectionsFromDisplayedSystems();
|
||||
|
||||
// Delete all custom collections.
|
||||
for (std::map<std::string, CollectionSystemData, StringComparator>::const_iterator it =
|
||||
mCustomCollectionSystemsData.cbegin();
|
||||
it != mCustomCollectionSystemsData.cend(); ++it)
|
||||
for (std::map<std::string, CollectionSystemData, StringComparator>::iterator it =
|
||||
mCustomCollectionSystemsData.begin();
|
||||
it != mCustomCollectionSystemsData.end(); ++it) {
|
||||
delete it->second.system;
|
||||
|
||||
// Delete the custom collections bundle.
|
||||
if (mCustomCollectionsBundle)
|
||||
delete mCustomCollectionsBundle;
|
||||
|
||||
// Delete the auto collections systems.
|
||||
for (auto it = mAutoCollectionSystemsData.cbegin(); // Line break.
|
||||
it != mAutoCollectionSystemsData.cend(); ++it)
|
||||
delete (*it).second.system;
|
||||
it->second.system = nullptr;
|
||||
}
|
||||
|
||||
// Delete the custom collections bundle.
|
||||
if (mCustomCollectionsBundle) {
|
||||
delete mCustomCollectionsBundle;
|
||||
mCustomCollectionsBundle = nullptr;
|
||||
}
|
||||
|
||||
// Delete the auto collections systems.
|
||||
for (auto it = mAutoCollectionSystemsData.begin(); // Line break.
|
||||
it != mAutoCollectionSystemsData.end(); ++it) {
|
||||
delete (*it).second.system;
|
||||
(*it).second.system = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
if (shutdown)
|
||||
delete mCollectionEnvData;
|
||||
}
|
||||
|
||||
|
|
|
@ -78,8 +78,8 @@ public:
|
|||
static CollectionSystemsManager* getInstance();
|
||||
void saveCustomCollection(SystemData* sys);
|
||||
|
||||
// Clean up all systems, called during application shutdown.
|
||||
void deinit();
|
||||
// Clean up all systems, called during application shutdown and ROM directory rescan.
|
||||
void deinit(const bool shutdown);
|
||||
|
||||
// Functions to load all collections into memory, and enable the active ones:
|
||||
// Load all collection systems.
|
||||
|
@ -137,7 +137,7 @@ public:
|
|||
const bool isEditing() const { return mIsEditingCustom; }
|
||||
const std::string& getEditingCollection() const { return mEditingCollection; }
|
||||
|
||||
static inline std::string myCollectionsName = "collections";
|
||||
static inline std::string myCollectionsName {"collections"};
|
||||
|
||||
protected:
|
||||
void trimCollectionCount(FileData* rootFolder, int limit);
|
||||
|
|
|
@ -65,6 +65,9 @@ GuiMenu::GuiMenu()
|
|||
if (isFullUI)
|
||||
addEntry("OTHER SETTINGS", mMenuColorPrimary, true, [this] { openOtherOptions(); });
|
||||
|
||||
if (isFullUI)
|
||||
addEntry("UTILITIES", mMenuColorPrimary, true, [this] { openUtilities(); });
|
||||
|
||||
if (!Settings::getInstance()->getBool("ForceKiosk") &&
|
||||
Settings::getInstance()->getString("UIMode") != "kiosk") {
|
||||
#if defined(__APPLE__)
|
||||
|
@ -1727,6 +1730,72 @@ void GuiMenu::openOtherOptions()
|
|||
mWindow->pushGui(s);
|
||||
}
|
||||
|
||||
void GuiMenu::openUtilities()
|
||||
{
|
||||
auto s = new GuiSettings("UTILITIES");
|
||||
|
||||
Window* window {mWindow};
|
||||
HelpStyle style {getHelpStyle()};
|
||||
|
||||
ComponentListRow row;
|
||||
|
||||
row.makeAcceptInputHandler([s, window, this] {
|
||||
window->pushGui(new GuiMsgBox(
|
||||
this->getHelpStyle(),
|
||||
"THIS WILL RESCAN YOUR ROM DIRECTORY\n"
|
||||
"FOR CHANGES SUCH AS ADDED OR REMOVED\n"
|
||||
"GAMES AND SYSTEMS, PROCEED?",
|
||||
"YES",
|
||||
[this, window] {
|
||||
if (CollectionSystemsManager::getInstance()->isEditing())
|
||||
CollectionSystemsManager::getInstance()->exitEditMode();
|
||||
window->stopInfoPopup();
|
||||
GuiMenu::close(true);
|
||||
// Write any gamelist.xml changes before proceeding with the reload.
|
||||
if (Settings::getInstance()->getString("SaveGamelistsMode") != "never") {
|
||||
for (auto system : SystemData::sSystemVector)
|
||||
system->writeMetaData();
|
||||
}
|
||||
window->renderSplashScreen(Window::SplashScreenState::SCANNING, 0.0f);
|
||||
ViewController::getInstance()->resetAll();
|
||||
CollectionSystemsManager::getInstance()->deinit(false);
|
||||
SystemData::loadConfig();
|
||||
if (SystemData::sStartupExitSignal) {
|
||||
SDL_Event quit;
|
||||
quit.type = SDL_QUIT;
|
||||
SDL_PushEvent(&quit);
|
||||
return;
|
||||
}
|
||||
if (SystemData::sSystemVector.empty()) {
|
||||
// It's possible that there are no longer any games.
|
||||
window->invalidateCachedBackground();
|
||||
ViewController::getInstance()->noGamesDialog();
|
||||
}
|
||||
else {
|
||||
ViewController::getInstance()->preload();
|
||||
if (SystemData::sStartupExitSignal) {
|
||||
SDL_Event quit;
|
||||
quit.type = SDL_QUIT;
|
||||
SDL_PushEvent(&quit);
|
||||
return;
|
||||
}
|
||||
ViewController::getInstance()->goToStart(false);
|
||||
}
|
||||
},
|
||||
"NO", nullptr));
|
||||
});
|
||||
auto rescanROMDirectory = std::make_shared<TextComponent>(
|
||||
"RESCAN ROM DIRECTORY", Font::get(FONT_SIZE_MEDIUM), mMenuColorPrimary);
|
||||
rescanROMDirectory->setSelectable(true);
|
||||
row.addElement(rescanROMDirectory, true);
|
||||
s->addRow(row);
|
||||
|
||||
row.elements.clear();
|
||||
|
||||
s->setSize(mSize);
|
||||
mWindow->pushGui(s);
|
||||
}
|
||||
|
||||
void GuiMenu::openQuitMenu()
|
||||
{
|
||||
if (!Settings::getInstance()->getBool("ShowQuitMenu")) {
|
||||
|
|
|
@ -44,6 +44,7 @@ private:
|
|||
void openConfigInput(GuiSettings* settings);
|
||||
void openCollectionSystemOptions();
|
||||
void openOtherOptions();
|
||||
void openUtilities();
|
||||
void openQuitMenu();
|
||||
|
||||
Renderer* mRenderer;
|
||||
|
|
|
@ -855,7 +855,7 @@ int main(int argc, char* argv[])
|
|||
delete window->peekGui();
|
||||
window->deinit();
|
||||
|
||||
CollectionSystemsManager::getInstance()->deinit();
|
||||
CollectionSystemsManager::getInstance()->deinit(true);
|
||||
SystemData::deleteSystems();
|
||||
NavigationSounds::getInstance().deinit();
|
||||
|
||||
|
|
|
@ -1209,8 +1209,7 @@ void ViewController::render(const glm::mat4& parentTrans)
|
|||
|
||||
void ViewController::preload()
|
||||
{
|
||||
unsigned int systemCount {static_cast<unsigned int>(SystemData::sSystemVector.size())};
|
||||
|
||||
const unsigned int systemCount {static_cast<unsigned int>(SystemData::sSystemVector.size())};
|
||||
// This reduces the amount of texture pop-in when loading theme extras.
|
||||
if (!SystemData::sSystemVector.empty())
|
||||
getSystemListView();
|
||||
|
@ -1409,6 +1408,15 @@ void ViewController::reloadAll()
|
|||
updateHelpPrompts();
|
||||
}
|
||||
|
||||
void ViewController::resetAll()
|
||||
{
|
||||
mGamelistViews.clear();
|
||||
mSystemListView.reset();
|
||||
mCurrentView.reset();
|
||||
mPreviousView.reset();
|
||||
mSkipView.reset();
|
||||
}
|
||||
|
||||
std::vector<HelpPrompt> ViewController::getHelpPrompts()
|
||||
{
|
||||
std::vector<HelpPrompt> prompts;
|
||||
|
|
|
@ -54,6 +54,9 @@ public:
|
|||
// Used when the "ThemeSet" setting changes.
|
||||
void reloadAll();
|
||||
|
||||
// Reset all views, which is needed when rescanning the ROM directory.
|
||||
void resetAll();
|
||||
|
||||
// Navigation.
|
||||
void goToNextGamelist();
|
||||
void goToPrevGamelist();
|
||||
|
|
Loading…
Reference in a new issue