mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2025-01-17 22:55:38 +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,
|
||||
// saving and deletion of a CollectionSystemManager instance.
|
||||
CollectionSystemManager* CollectionSystemManager::sInstance = NULL;
|
||||
CollectionSystemManager* CollectionSystemManager::sInstance = nullptr;
|
||||
|
||||
CollectionSystemManager::CollectionSystemManager(Window* window) : mWindow(window)
|
||||
{
|
||||
|
@ -82,7 +82,10 @@ CollectionSystemManager::CollectionSystemManager(Window* window) : mWindow(windo
|
|||
CollectionSystemManager::~CollectionSystemManager()
|
||||
{
|
||||
assert(sInstance == this);
|
||||
removeCollectionsFromDisplayedSystems();
|
||||
|
||||
// Don't attempt to remove any collections if no systems exist.
|
||||
if (SystemData::sSystemVector.size() > 0)
|
||||
removeCollectionsFromDisplayedSystems();
|
||||
|
||||
// Iterate the map.
|
||||
for (std::map<std::string, CollectionSystemData>::const_iterator
|
||||
|
|
|
@ -303,7 +303,9 @@ bool SystemData::loadConfig()
|
|||
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;
|
||||
}
|
||||
|
|
|
@ -41,6 +41,12 @@
|
|||
|
||||
#include <FreeImage.h>
|
||||
|
||||
enum eErrorCodes {
|
||||
NO_ERRORS,
|
||||
NO_SYSTEMS_FILE,
|
||||
NO_ROMS
|
||||
};
|
||||
|
||||
bool parseArgs(int argc, char* argv[])
|
||||
{
|
||||
Utils::FileSystem::setExePath(argv[0]);
|
||||
|
@ -246,31 +252,33 @@ bool verifyHomeFolderExists()
|
|||
return true;
|
||||
}
|
||||
|
||||
// Returns true if everything is OK.
|
||||
bool loadSystemConfigFile(const char** errorString)
|
||||
// Returns NO_ERRORS if everything is OK.
|
||||
// Otherwise returns either NO_SYSTEMS_FILE or NO_ROMS.
|
||||
unsigned int loadSystemConfigFile(std::string& errorMsg)
|
||||
{
|
||||
*errorString = NULL;
|
||||
|
||||
if (!SystemData::loadConfig()) {
|
||||
LOG(LogError) << "Error while parsing systems configuration file!";
|
||||
*errorString = "IT LOOKS LIKE YOUR SYSTEMS CONFIGURATION FILE HAS NOT BEEN SET UP "
|
||||
"OR IS INVALID. YOU'LL NEED TO DO THIS BY HAND, UNFORTUNATELY.\n\n"
|
||||
"VISIT EMULATIONSTATION.ORG FOR MORE INFORMATION.";
|
||||
return false;
|
||||
errorMsg = "COULDN'T FIND THE SYSTEMS CONFIGURATION FILE.\n"
|
||||
"WILL ATTEMPT TO INSTALL A TEMPLATE ES_SYSTEMS.CFG FILE FROM "
|
||||
"THE EMULATIONSTATION RESOURCES DIRECTORY.\n"
|
||||
"PLEASE RESTART THE APPLICATION.";
|
||||
return NO_SYSTEMS_FILE;
|
||||
}
|
||||
|
||||
if (SystemData::sSystemVector.size() == 0)
|
||||
{
|
||||
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!)";
|
||||
*errorString = "WE CAN'T FIND ANY SYSTEMS!\n"
|
||||
"CHECK THAT YOUR PATHS ARE CORRECT IN THE SYSTEMS CONFIGURATION FILE, "
|
||||
"AND YOUR GAME DIRECTORY HAS AT LEAST ONE GAME WITH THE CORRECT EXTENSION.\n\n"
|
||||
"VISIT EMULATIONSTATION.ORG FOR MORE INFORMATION.";
|
||||
return false;
|
||||
"that extensions match!)\n";
|
||||
errorMsg = "THE SYSTEMS CONFIGURATION FILE EXISTS BUT NO GAME "
|
||||
"ROM FILES WERE FOUND. PLEASE MAKE SURE THAT THE 'ROMDIRECTORY' "
|
||||
"SETTING IN ES_SYSTEMS.CFG IS POINTING TO YOUR ROM DIRECTORY "
|
||||
"AND THAT YOUR GAME ROMS ARE USING SUPPORTED FILE EXTENSIONS. "
|
||||
"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.
|
||||
|
@ -361,10 +369,11 @@ int main(int argc, char* argv[])
|
|||
window.renderLoadingScreen(progressText);
|
||||
}
|
||||
|
||||
const char* errorMsg = NULL;
|
||||
if (!loadSystemConfigFile(&errorMsg)) {
|
||||
std::string errorMsg;
|
||||
|
||||
if (loadSystemConfigFile(errorMsg) != NO_ERRORS) {
|
||||
// Something went terribly wrong.
|
||||
if (errorMsg == NULL)
|
||||
if (errorMsg == "")
|
||||
{
|
||||
LOG(LogError) << "Unknown error occured while parsing system config file.";
|
||||
Renderer::deinit();
|
||||
|
@ -372,12 +381,15 @@ int main(int argc, char* argv[])
|
|||
}
|
||||
|
||||
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,
|
||||
// so display the error message and then quit.
|
||||
window.pushGui(new GuiMsgBox(&window, helpStyle,
|
||||
errorMsg,
|
||||
errorMsg.c_str(),
|
||||
"QUIT", [] {
|
||||
SDL_Event* quit = new SDL_Event();
|
||||
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.
|
||||
// (Hopefully fixes "automatically started emulator" bug.)
|
||||
SDL_JoystickEventState(SDL_DISABLE);
|
||||
|
@ -397,7 +413,7 @@ int main(int argc, char* argv[])
|
|||
window.renderLoadingScreen("Done.");
|
||||
|
||||
// Choose which GUI to open depending on if an input configuration already exists.
|
||||
if (errorMsg == NULL) {
|
||||
if (errorMsg == "") {
|
||||
if (Utils::FileSystem::exists(InputManager::getConfigPath()) &&
|
||||
InputManager::getInstance()->getNumConfiguredDevices() > 0) {
|
||||
ViewController::get()->goToStart();
|
||||
|
|
|
@ -479,9 +479,10 @@ void ViewController::preload()
|
|||
(*it)->getIndex()->resetFilters();
|
||||
getGameListView(*it);
|
||||
}
|
||||
// Load navigation sounds.
|
||||
NavigationSounds::getInstance()->loadThemeNavigationSounds(
|
||||
SystemData::sSystemVector.front()->getTheme());
|
||||
// Load navigation sounds, but only if at least one system exists.
|
||||
if (SystemData::sSystemVector.size() > 0)
|
||||
NavigationSounds::getInstance()->loadThemeNavigationSounds(
|
||||
SystemData::sSystemVector.front()->getTheme());
|
||||
}
|
||||
|
||||
void ViewController::reloadGameListView(IGameListView* view, bool reloadTheme)
|
||||
|
|
Loading…
Reference in a new issue