diff --git a/engines/ultima8/conf/setting_manager.cpp b/engines/ultima8/conf/setting_manager.cpp index c170c20033c..69ccb0174a6 100644 --- a/engines/ultima8/conf/setting_manager.cpp +++ b/engines/ultima8/conf/setting_manager.cpp @@ -172,20 +172,9 @@ void SettingManager::unregisterCallback(istring key, ConfigCallback callback) { } std::vector SettingManager::listGames() { - // identifies if a section is a game section by checking for a 'path' key - - std::vector sections, games; - sections = conffileman->listSections("settings", false); - + std::vector games; games.push_back("pentagram"); - - for (unsigned int i = 0; i < sections.size(); ++i) { - istring name = sections[i]; - - istring pathkey = "settings/" + name + "/path"; - if (name.find(':') == istring::npos && conffileman->exists(pathkey) && name != "pentagram") - games.push_back(name); - } + games.push_back("ultima8"); return games; } diff --git a/engines/ultima8/kernel/core_app.cpp b/engines/ultima8/kernel/core_app.cpp index ab518688c07..6ce45ac9291 100644 --- a/engines/ultima8/kernel/core_app.cpp +++ b/engines/ultima8/kernel/core_app.cpp @@ -35,18 +35,14 @@ namespace Ultima8 { using std::string; -static void ToLower(std::string &str); - - // p_dynamic_cast stuff DEFINE_RUNTIME_CLASSTYPE_CODE_BASE_CLASS(CoreApp) CoreApp *CoreApp::application = 0; -CoreApp::CoreApp(int argc_, const char *const *argv_) - : isRunning(false), gameinfo(0), filesystem(0), - configfileman(0), settingman(0), argc(argc_), - argv(argv_), oHelp(false), oQuiet(false), oVQuiet(false) { +CoreApp::CoreApp(const Ultima8GameDescription *gameDesc) + : _gameDesc(gameDesc), isRunning(false), gameinfo(0), filesystem(0), + configfileman(0), settingman(0), oHelp(false), oQuiet(false), oVQuiet(false) { assert(application == 0); application = this; _console = new Console(); @@ -70,7 +66,7 @@ CoreApp::~CoreApp() { void CoreApp::startup() { DeclareArgs(); // Note: this is virtual - ParseArgs(argc, argv); + ParseArgs(0, nullptr); // if we're spitting out help, we probably want to avoid having the // other cruft dumped too... @@ -272,57 +268,35 @@ bool CoreApp::getGameInfo(Pentagram::istring &game, GameInfo *ginfo) { if (game == "pentagram") { ginfo->type = GameInfo::GAME_PENTAGRAM_MENU; ginfo->language = GameInfo::GAMELANG_ENGLISH; - } else { - std::string gametype; - if (!configfileman->get(gamekey + "/type", gametype)) - gametype = "unknown"; - ToLower(gametype); - if (gametype == "u8") { - ginfo->type = GameInfo::GAME_U8; - } else if (gametype == "remorse") { - ginfo->type = GameInfo::GAME_REMORSE; + } else { + assert(game == "ultima8"); + + ginfo->type = GameInfo::GAME_U8; + + switch (_gameDesc->desc.language) { + case Common::EN_ANY: + ginfo->language = GameInfo::GAMELANG_ENGLISH; + break; + case Common::FR_FRA: + ginfo->language = GameInfo::GAMELANG_FRENCH; + break; + case Common::DE_DEU: + ginfo->language = GameInfo::GAMELANG_GERMAN; + break; + case Common::ES_ESP: + ginfo->language = GameInfo::GAMELANG_SPANISH; + break; + case Common::JA_JPN: + ginfo->language = GameInfo::GAMELANG_JAPANESE; + break; + default: + error("Unknown language"); + break; } } - std::string version; - if (!configfileman->get(gamekey + "/version", version)) - version = "unknown"; - - std::string language; - if (!configfileman->get(gamekey + "/language", language)) - language = "unknown"; - ToLower(language); - - - //!! TODO: version parsing - - if (language == "english") { - ginfo->language = GameInfo::GAMELANG_ENGLISH; - } else if (language == "french") { - ginfo->language = GameInfo::GAMELANG_FRENCH; - } else if (language == "german") { - ginfo->language = GameInfo::GAMELANG_GERMAN; - } else if (language == "spanish") { - ginfo->language = GameInfo::GAMELANG_SPANISH; - } else if (language == "japanese") { - ginfo->language = GameInfo::GAMELANG_JAPANESE; - } - - if (ginfo->type == GameInfo::GAME_UNKNOWN || - /* ginfo->version == 0 || */ - ginfo->language == GameInfo::GAMELANG_UNKNOWN) { - std::string path; - if (!configfileman->get(gamekey + "/path", path)) return false; - - return GameDetector::detect(path, ginfo); - } - - if (ginfo->type == GameInfo::GAME_UNKNOWN) { - return false; - } - - return true; + return ginfo->type != GameInfo::GAME_UNKNOWN; } void CoreApp::setupGamePaths(GameInfo *ginfo) { @@ -340,8 +314,6 @@ void CoreApp::setupGamePaths(GameInfo *ginfo) { std::string gpath; settingman->get("path", gpath, SettingManager::DOM_GAME); filesystem->AddVirtualPath("@game", gpath); - con->Printf(MM_INFO, "Game Path: %s\n", gpath.c_str()); - // load work path. Default is @home/game-work // where 'game' in the above is the specified 'game' loaded @@ -396,10 +368,4 @@ GameInfo *CoreApp::getGameInfo(Pentagram::istring game) const { return 0; } -static void ToLower(std::string &str) { - for (unsigned int i = 0; i < str.size(); ++i) { - str.setChar(std::tolower(str[i]), i); - } -} - } // End of namespace Ultima8 diff --git a/engines/ultima8/kernel/core_app.h b/engines/ultima8/kernel/core_app.h index 286b031e6b5..8b369e0a55b 100644 --- a/engines/ultima8/kernel/core_app.h +++ b/engines/ultima8/kernel/core_app.h @@ -27,6 +27,7 @@ #include "ultima8/misc/args.h" #include "ultima8/games/game_info.h" #include "ultima8/misc/p_dynamic_cast.h" +#include "ultima8/detection.h" namespace Ultima8 { @@ -46,7 +47,7 @@ struct GameInfo; class CoreApp { public: ENABLE_RUNTIME_CLASSTYPE() - CoreApp(int argc, const char *const *argv); + CoreApp(const Ultima8GameDescription *gameDesc); virtual ~CoreApp(); static CoreApp *get_instance() { @@ -109,8 +110,7 @@ protected: static CoreApp *application; private: - int argc; - const char *const *argv; + const Ultima8GameDescription *_gameDesc; Console *_console; //! start filesystem, kernel, config diff --git a/engines/ultima8/ultima8.cpp b/engines/ultima8/ultima8.cpp index b33695c6952..6e853844863 100644 --- a/engines/ultima8/ultima8.cpp +++ b/engines/ultima8/ultima8.cpp @@ -131,7 +131,7 @@ DEFINE_RUNTIME_CLASSTYPE_CODE(Ultima8Engine, CoreApp) #define DATA_VERSION_MINOR 0 Ultima8Engine::Ultima8Engine(OSystem *syst, const Ultima8GameDescription *gameDesc) : - Engine(syst), CoreApp(0, nullptr), _gameDescription(gameDesc), + Engine(syst), CoreApp(gameDesc), _gameDescription(gameDesc), _randomSource("Ultima8"), save_count(0), game(nullptr), kernel(nullptr), _dataArchive(nullptr), objectmanager(nullptr), hidmanager(nullptr), _mouse(nullptr), ucmachine(nullptr), screen(nullptr), fontmanager(nullptr), fullscreen(false),