mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2025-01-29 19:55:37 +00:00
Improved error handling for missing configuration files and ROMs.
This commit is contained in:
parent
fb0ab2f06c
commit
f635e5bd2d
|
@ -39,7 +39,7 @@ std::string myCollectionsName = "collections";
|
||||||
|
|
||||||
// Handles the getting, initialization, deinitialization,
|
// Handles the getting, initialization, deinitialization,
|
||||||
// saving and deletion of a CollectionSystemManager instance.
|
// saving and deletion of a CollectionSystemManager instance.
|
||||||
CollectionSystemManager* CollectionSystemManager::sInstance = NULL;
|
CollectionSystemManager* CollectionSystemManager::sInstance = nullptr;
|
||||||
|
|
||||||
CollectionSystemManager::CollectionSystemManager(Window* window) : mWindow(window)
|
CollectionSystemManager::CollectionSystemManager(Window* window) : mWindow(window)
|
||||||
{
|
{
|
||||||
|
@ -82,7 +82,10 @@ CollectionSystemManager::CollectionSystemManager(Window* window) : mWindow(windo
|
||||||
CollectionSystemManager::~CollectionSystemManager()
|
CollectionSystemManager::~CollectionSystemManager()
|
||||||
{
|
{
|
||||||
assert(sInstance == this);
|
assert(sInstance == this);
|
||||||
removeCollectionsFromDisplayedSystems();
|
|
||||||
|
// Don't attempt to remove any collections if no systems exist.
|
||||||
|
if (SystemData::sSystemVector.size() > 0)
|
||||||
|
removeCollectionsFromDisplayedSystems();
|
||||||
|
|
||||||
// Iterate the map.
|
// Iterate the map.
|
||||||
for (std::map<std::string, CollectionSystemData>::const_iterator
|
for (std::map<std::string, CollectionSystemData>::const_iterator
|
||||||
|
|
|
@ -303,7 +303,9 @@ bool SystemData::loadConfig()
|
||||||
sSystemVector.push_back(newSys);
|
sSystemVector.push_back(newSys);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
CollectionSystemManager::get()->loadCollectionSystems();
|
// Don't load any collections if there are no systems available.
|
||||||
|
if (sSystemVector.size() > 0)
|
||||||
|
CollectionSystemManager::get()->loadCollectionSystems();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,6 +41,12 @@
|
||||||
|
|
||||||
#include <FreeImage.h>
|
#include <FreeImage.h>
|
||||||
|
|
||||||
|
enum eErrorCodes {
|
||||||
|
NO_ERRORS,
|
||||||
|
NO_SYSTEMS_FILE,
|
||||||
|
NO_ROMS
|
||||||
|
};
|
||||||
|
|
||||||
bool parseArgs(int argc, char* argv[])
|
bool parseArgs(int argc, char* argv[])
|
||||||
{
|
{
|
||||||
Utils::FileSystem::setExePath(argv[0]);
|
Utils::FileSystem::setExePath(argv[0]);
|
||||||
|
@ -246,31 +252,33 @@ bool verifyHomeFolderExists()
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns true if everything is OK.
|
// Returns NO_ERRORS if everything is OK.
|
||||||
bool loadSystemConfigFile(const char** errorString)
|
// Otherwise returns either NO_SYSTEMS_FILE or NO_ROMS.
|
||||||
|
unsigned int loadSystemConfigFile(std::string& errorMsg)
|
||||||
{
|
{
|
||||||
*errorString = NULL;
|
|
||||||
|
|
||||||
if (!SystemData::loadConfig()) {
|
if (!SystemData::loadConfig()) {
|
||||||
LOG(LogError) << "Error while parsing systems configuration file!";
|
LOG(LogError) << "Error while parsing systems configuration file!";
|
||||||
*errorString = "IT LOOKS LIKE YOUR SYSTEMS CONFIGURATION FILE HAS NOT BEEN SET UP "
|
errorMsg = "COULDN'T FIND THE SYSTEMS CONFIGURATION FILE.\n"
|
||||||
"OR IS INVALID. YOU'LL NEED TO DO THIS BY HAND, UNFORTUNATELY.\n\n"
|
"WILL ATTEMPT TO INSTALL A TEMPLATE ES_SYSTEMS.CFG FILE FROM "
|
||||||
"VISIT EMULATIONSTATION.ORG FOR MORE INFORMATION.";
|
"THE EMULATIONSTATION RESOURCES DIRECTORY.\n"
|
||||||
return false;
|
"PLEASE RESTART THE APPLICATION.";
|
||||||
|
return NO_SYSTEMS_FILE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (SystemData::sSystemVector.size() == 0)
|
if (SystemData::sSystemVector.size() == 0)
|
||||||
{
|
{
|
||||||
LOG(LogError) << "No systems found! Does at least one system have a game present? (check "
|
LOG(LogError) << "No systems found! Does at least one system have a game present? (check "
|
||||||
"that extensions match!)\n(Also, make sure you've updated your es_systems.cfg for XML!)";
|
"that extensions match!)\n";
|
||||||
*errorString = "WE CAN'T FIND ANY SYSTEMS!\n"
|
errorMsg = "THE SYSTEMS CONFIGURATION FILE EXISTS BUT NO GAME "
|
||||||
"CHECK THAT YOUR PATHS ARE CORRECT IN THE SYSTEMS CONFIGURATION FILE, "
|
"ROM FILES WERE FOUND. PLEASE MAKE SURE THAT THE 'ROMDIRECTORY' "
|
||||||
"AND YOUR GAME DIRECTORY HAS AT LEAST ONE GAME WITH THE CORRECT EXTENSION.\n\n"
|
"SETTING IN ES_SYSTEMS.CFG IS POINTING TO YOUR ROM DIRECTORY "
|
||||||
"VISIT EMULATIONSTATION.ORG FOR MORE INFORMATION.";
|
"AND THAT YOUR GAME ROMS ARE USING SUPPORTED FILE EXTENSIONS. "
|
||||||
return false;
|
"THIS IS THE CURRENTLY CONFIGURED ROM DIRECTORY:\n";
|
||||||
|
errorMsg += FileData::getROMDirectory();
|
||||||
|
return NO_ROMS;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return NO_ERRORS;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Called on exit, assuming we get far enough to have the log initialized.
|
// Called on exit, assuming we get far enough to have the log initialized.
|
||||||
|
@ -361,10 +369,11 @@ int main(int argc, char* argv[])
|
||||||
window.renderLoadingScreen(progressText);
|
window.renderLoadingScreen(progressText);
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* errorMsg = NULL;
|
std::string errorMsg;
|
||||||
if (!loadSystemConfigFile(&errorMsg)) {
|
|
||||||
|
if (loadSystemConfigFile(errorMsg) != NO_ERRORS) {
|
||||||
// Something went terribly wrong.
|
// Something went terribly wrong.
|
||||||
if (errorMsg == NULL)
|
if (errorMsg == "")
|
||||||
{
|
{
|
||||||
LOG(LogError) << "Unknown error occured while parsing system config file.";
|
LOG(LogError) << "Unknown error occured while parsing system config file.";
|
||||||
Renderer::deinit();
|
Renderer::deinit();
|
||||||
|
@ -372,12 +381,15 @@ int main(int argc, char* argv[])
|
||||||
}
|
}
|
||||||
|
|
||||||
HelpStyle helpStyle = HelpStyle();
|
HelpStyle helpStyle = HelpStyle();
|
||||||
helpStyle.applyTheme(ViewController::get()->getState().getSystem()->getTheme(), "system");
|
|
||||||
|
if (errorMsg == "")
|
||||||
|
helpStyle.applyTheme(ViewController::get()->
|
||||||
|
getState().getSystem()->getTheme(), "system");
|
||||||
|
|
||||||
// We can't handle es_systems.cfg file problems inside ES itself,
|
// We can't handle es_systems.cfg file problems inside ES itself,
|
||||||
// so display the error message and then quit.
|
// so display the error message and then quit.
|
||||||
window.pushGui(new GuiMsgBox(&window, helpStyle,
|
window.pushGui(new GuiMsgBox(&window, helpStyle,
|
||||||
errorMsg,
|
errorMsg.c_str(),
|
||||||
"QUIT", [] {
|
"QUIT", [] {
|
||||||
SDL_Event* quit = new SDL_Event();
|
SDL_Event* quit = new SDL_Event();
|
||||||
quit->type = SDL_QUIT;
|
quit->type = SDL_QUIT;
|
||||||
|
@ -385,6 +397,10 @@ int main(int argc, char* argv[])
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::vector<HelpPrompt> prompts;
|
||||||
|
prompts.push_back(HelpPrompt("a", "Quit"));
|
||||||
|
window.setHelpPrompts(prompts, HelpStyle());
|
||||||
|
|
||||||
// Dont generate joystick events while we're loading.
|
// Dont generate joystick events while we're loading.
|
||||||
// (Hopefully fixes "automatically started emulator" bug.)
|
// (Hopefully fixes "automatically started emulator" bug.)
|
||||||
SDL_JoystickEventState(SDL_DISABLE);
|
SDL_JoystickEventState(SDL_DISABLE);
|
||||||
|
@ -397,7 +413,7 @@ int main(int argc, char* argv[])
|
||||||
window.renderLoadingScreen("Done.");
|
window.renderLoadingScreen("Done.");
|
||||||
|
|
||||||
// Choose which GUI to open depending on if an input configuration already exists.
|
// Choose which GUI to open depending on if an input configuration already exists.
|
||||||
if (errorMsg == NULL) {
|
if (errorMsg == "") {
|
||||||
if (Utils::FileSystem::exists(InputManager::getConfigPath()) &&
|
if (Utils::FileSystem::exists(InputManager::getConfigPath()) &&
|
||||||
InputManager::getInstance()->getNumConfiguredDevices() > 0) {
|
InputManager::getInstance()->getNumConfiguredDevices() > 0) {
|
||||||
ViewController::get()->goToStart();
|
ViewController::get()->goToStart();
|
||||||
|
|
|
@ -479,9 +479,10 @@ void ViewController::preload()
|
||||||
(*it)->getIndex()->resetFilters();
|
(*it)->getIndex()->resetFilters();
|
||||||
getGameListView(*it);
|
getGameListView(*it);
|
||||||
}
|
}
|
||||||
// Load navigation sounds.
|
// Load navigation sounds, but only if at least one system exists.
|
||||||
NavigationSounds::getInstance()->loadThemeNavigationSounds(
|
if (SystemData::sSystemVector.size() > 0)
|
||||||
SystemData::sSystemVector.front()->getTheme());
|
NavigationSounds::getInstance()->loadThemeNavigationSounds(
|
||||||
|
SystemData::sSystemVector.front()->getTheme());
|
||||||
}
|
}
|
||||||
|
|
||||||
void ViewController::reloadGameListView(IGameListView* view, bool reloadTheme)
|
void ViewController::reloadGameListView(IGameListView* view, bool reloadTheme)
|
||||||
|
|
Loading…
Reference in a new issue