diff options
Diffstat (limited to 'src/app/app.cpp')
-rw-r--r-- | src/app/app.cpp | 114 |
1 files changed, 17 insertions, 97 deletions
diff --git a/src/app/app.cpp b/src/app/app.cpp index 51f1e42..549317a 100644 --- a/src/app/app.cpp +++ b/src/app/app.cpp @@ -19,6 +19,7 @@ #include "app/app.h" +#include "app/gamedata.h" #include "app/system.h" #include "common/logger.h" @@ -100,6 +101,7 @@ CApplication::CApplication() m_objMan = new CObjectManager(); m_eventQueue = new CEventQueue(); m_profile = new CProfile(); + m_gameData = new CGameData(); m_engine = nullptr; m_device = nullptr; @@ -149,7 +151,6 @@ CApplication::CApplication() m_dataPath = GetSystemUtils()->GetDataPath(); m_langPath = GetSystemUtils()->GetLangPath(); - m_texPackPath = ""; m_runSceneName = ""; m_runSceneRank = 0; @@ -161,19 +162,6 @@ CApplication::CApplication() m_lowCPU = true; m_protoMode = false; - - for (int i = 0; i < DIR_MAX; ++i) - m_standardDataDirs[i] = nullptr; - - m_standardDataDirs[DIR_AI] = "ai"; - m_standardDataDirs[DIR_FONT] = "fonts"; - m_standardDataDirs[DIR_HELP] = "help"; - m_standardDataDirs[DIR_ICON] = "icons"; - m_standardDataDirs[DIR_LEVEL] = "levels"; - m_standardDataDirs[DIR_MODEL] = "models"; - m_standardDataDirs[DIR_MUSIC] = "music"; - m_standardDataDirs[DIR_SOUND] = "sounds"; - m_standardDataDirs[DIR_TEXTURE] = "textures"; } CApplication::~CApplication() @@ -231,8 +219,8 @@ ParseArgsStatus CApplication::ParseArguments(int argc, char *argv[]) OPT_LOGLEVEL, OPT_LANGUAGE, OPT_DATADIR, + OPT_MOD, OPT_LANGDIR, - OPT_TEXPACK, OPT_VBO }; @@ -245,9 +233,8 @@ ParseArgsStatus CApplication::ParseArguments(int argc, char *argv[]) { "loglevel", required_argument, nullptr, OPT_LOGLEVEL }, { "language", required_argument, nullptr, OPT_LANGUAGE }, { "datadir", required_argument, nullptr, OPT_DATADIR }, - { "game", required_argument, nullptr, OPT_DATADIR }, + { "mod", required_argument, nullptr, OPT_MOD }, { "langdir", required_argument, nullptr, OPT_LANGDIR }, - { "texpack", required_argument, nullptr, OPT_TEXPACK }, { "vbo", required_argument, nullptr, OPT_VBO }, { nullptr, 0, nullptr, 0} }; @@ -286,9 +273,8 @@ ParseArgsStatus CApplication::ParseArguments(int argc, char *argv[]) GetLogger()->Message(" -loglevel level set log level to level (one of: trace, debug, info, warn, error, none)\n"); GetLogger()->Message(" -language lang set language (one of: en, de, fr, pl, ru)\n"); GetLogger()->Message(" -datadir path set custom data directory path\n"); - GetLogger()->Message(" -game modid run mod\n"); + GetLogger()->Message(" -mod path run mod\n"); GetLogger()->Message(" -langdir path set custom language directory path\n"); - GetLogger()->Message(" -texpack path set path to custom texture pack\n"); GetLogger()->Message(" -vbo mode set OpenGL VBO mode (one of: auto, enable, disable)\n"); return PARSE_ARGS_HELP; } @@ -355,19 +341,19 @@ ParseArgsStatus CApplication::ParseArguments(int argc, char *argv[]) { m_dataPath = optarg; m_customDataPath = true; - GetLogger()->Info("Using custom datadir or running mod: '%s'\n", m_dataPath.c_str()); + GetLogger()->Info("Using datadir: '%s'\n", optarg); break; } - case OPT_LANGDIR: + case OPT_MOD: { - m_langPath = optarg; - GetLogger()->Info("Using custom language dir: '%s'\n", m_langPath.c_str()); + m_gameData->AddMod(std::string(optarg)); + GetLogger()->Info("Running mod from path: '%s'\n", optarg); break; } - case OPT_TEXPACK: + case OPT_LANGDIR: { - m_texPackPath = optarg; - GetLogger()->Info("Using texturepack: '%s'\n", m_texPackPath.c_str()); + m_langPath = optarg; + GetLogger()->Info("Using language dir: '%s'\n", m_langPath.c_str()); break; } case OPT_VBO: @@ -424,6 +410,9 @@ bool CApplication::Create() m_exitCode = 1; return false; } + + m_gameData->SetDataDir(std::string(m_dataPath)); + m_gameData->Init(); if (GetProfile().GetLocalProfileString("Language", "Lang", path)) { Language language; @@ -446,24 +435,8 @@ bool CApplication::Create() #endif m_sound->Create(); - - if (!m_customDataPath && GetProfile().GetLocalProfileString("Resources", "Sound", path)) - { - m_sound->CacheAll(path); - } - else - { - m_sound->CacheAll(GetDataSubdirPath(DIR_SOUND)); - } - - if (!m_customDataPath && GetProfile().GetLocalProfileString("Resources", "Music", path)) - { - m_sound->AddMusicFiles(path); - } - else - { - m_sound->AddMusicFiles(GetDataSubdirPath(DIR_MUSIC)); - } + m_sound->CacheAll(); + m_sound->AddMusicFiles(); GetLogger()->Info("CApplication created successfully\n"); @@ -1606,59 +1579,6 @@ bool CApplication::GetJoystickEnabled() const return m_joystickEnabled; } -std::string CApplication::GetDataDirPath() const -{ - return m_dataPath; -} - -std::string CApplication::GetDataSubdirPath(DataDir stdDir) const -{ - int index = static_cast<int>(stdDir); - assert(index >= 0 && index < DIR_MAX); - std::stringstream str; - str << m_dataPath; - str << "/"; - str << m_standardDataDirs[index]; - return str.str(); -} - -std::string CApplication::GetDataFilePath(DataDir stdDir, const std::string& subpath) const -{ - int index = static_cast<int>(stdDir); - assert(index >= 0 && index < DIR_MAX); - std::stringstream str; - str << m_dataPath; - str << "/"; - str << m_standardDataDirs[index]; - if (stdDir == DIR_HELP) - { - str << "/"; - str << GetLanguageChar(); - } - str << "/"; - str << subpath; - return str.str(); -} - -std::string CApplication::GetTexPackFilePath(const std::string& textureName) const -{ - std::stringstream str; - - if (! m_texPackPath.empty()) - { - str << m_texPackPath; - str << "/"; - str << textureName; - if (! boost::filesystem::exists(str.str())) - { - GetLogger()->Trace("Texture '%s' not in texpack\n", textureName.c_str()); - str.str(""); - } - } - - return str.str(); -} - Language CApplication::GetLanguage() const { return m_language; |