Better datadir mod support
parent
f71658e38d
commit
f0d97bfdb9
2
data
2
data
|
@ -1 +1 @@
|
||||||
Subproject commit fc8f515b615235a236641700cc3fcde403548b4f
|
Subproject commit 3aa20285393ba9be6b5db7bc4559f2c90f2155bf
|
|
@ -61,11 +61,12 @@ endif()
|
||||||
# Source files
|
# Source files
|
||||||
set(SOURCES
|
set(SOURCES
|
||||||
app/app.cpp
|
app/app.cpp
|
||||||
|
app/gamedata.cpp
|
||||||
app/main.cpp
|
app/main.cpp
|
||||||
|
app/pausemanager.cpp
|
||||||
app/system.cpp
|
app/system.cpp
|
||||||
app/${SYSTEM_CPP_MODULE}
|
app/${SYSTEM_CPP_MODULE}
|
||||||
app/system_other.cpp
|
app/system_other.cpp
|
||||||
app/pausemanager.cpp
|
|
||||||
common/event.cpp
|
common/event.cpp
|
||||||
common/image.cpp
|
common/image.cpp
|
||||||
common/iman.cpp
|
common/iman.cpp
|
||||||
|
|
116
src/app/app.cpp
116
src/app/app.cpp
|
@ -19,6 +19,7 @@
|
||||||
|
|
||||||
#include "app/app.h"
|
#include "app/app.h"
|
||||||
|
|
||||||
|
#include "app/gamedata.h"
|
||||||
#include "app/system.h"
|
#include "app/system.h"
|
||||||
|
|
||||||
#include "common/logger.h"
|
#include "common/logger.h"
|
||||||
|
@ -100,6 +101,7 @@ CApplication::CApplication()
|
||||||
m_objMan = new CObjectManager();
|
m_objMan = new CObjectManager();
|
||||||
m_eventQueue = new CEventQueue();
|
m_eventQueue = new CEventQueue();
|
||||||
m_profile = new CProfile();
|
m_profile = new CProfile();
|
||||||
|
m_gameData = new CGameData();
|
||||||
|
|
||||||
m_engine = nullptr;
|
m_engine = nullptr;
|
||||||
m_device = nullptr;
|
m_device = nullptr;
|
||||||
|
@ -149,7 +151,6 @@ CApplication::CApplication()
|
||||||
|
|
||||||
m_dataPath = GetSystemUtils()->GetDataPath();
|
m_dataPath = GetSystemUtils()->GetDataPath();
|
||||||
m_langPath = GetSystemUtils()->GetLangPath();
|
m_langPath = GetSystemUtils()->GetLangPath();
|
||||||
m_texPackPath = "";
|
|
||||||
|
|
||||||
m_runSceneName = "";
|
m_runSceneName = "";
|
||||||
m_runSceneRank = 0;
|
m_runSceneRank = 0;
|
||||||
|
@ -161,19 +162,6 @@ CApplication::CApplication()
|
||||||
m_lowCPU = true;
|
m_lowCPU = true;
|
||||||
|
|
||||||
m_protoMode = false;
|
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()
|
CApplication::~CApplication()
|
||||||
|
@ -231,8 +219,8 @@ ParseArgsStatus CApplication::ParseArguments(int argc, char *argv[])
|
||||||
OPT_LOGLEVEL,
|
OPT_LOGLEVEL,
|
||||||
OPT_LANGUAGE,
|
OPT_LANGUAGE,
|
||||||
OPT_DATADIR,
|
OPT_DATADIR,
|
||||||
|
OPT_MOD,
|
||||||
OPT_LANGDIR,
|
OPT_LANGDIR,
|
||||||
OPT_TEXPACK,
|
|
||||||
OPT_VBO
|
OPT_VBO
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -245,9 +233,8 @@ ParseArgsStatus CApplication::ParseArguments(int argc, char *argv[])
|
||||||
{ "loglevel", required_argument, nullptr, OPT_LOGLEVEL },
|
{ "loglevel", required_argument, nullptr, OPT_LOGLEVEL },
|
||||||
{ "language", required_argument, nullptr, OPT_LANGUAGE },
|
{ "language", required_argument, nullptr, OPT_LANGUAGE },
|
||||||
{ "datadir", required_argument, nullptr, OPT_DATADIR },
|
{ "datadir", required_argument, nullptr, OPT_DATADIR },
|
||||||
{ "game", required_argument, nullptr, OPT_DATADIR },
|
{ "mod", required_argument, nullptr, OPT_MOD },
|
||||||
{ "langdir", required_argument, nullptr, OPT_LANGDIR },
|
{ "langdir", required_argument, nullptr, OPT_LANGDIR },
|
||||||
{ "texpack", required_argument, nullptr, OPT_TEXPACK },
|
|
||||||
{ "vbo", required_argument, nullptr, OPT_VBO },
|
{ "vbo", required_argument, nullptr, OPT_VBO },
|
||||||
{ nullptr, 0, nullptr, 0}
|
{ 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(" -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(" -language lang set language (one of: en, de, fr, pl, ru)\n");
|
||||||
GetLogger()->Message(" -datadir path set custom data directory path\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(" -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");
|
GetLogger()->Message(" -vbo mode set OpenGL VBO mode (one of: auto, enable, disable)\n");
|
||||||
return PARSE_ARGS_HELP;
|
return PARSE_ARGS_HELP;
|
||||||
}
|
}
|
||||||
|
@ -355,19 +341,19 @@ ParseArgsStatus CApplication::ParseArguments(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
m_dataPath = optarg;
|
m_dataPath = optarg;
|
||||||
m_customDataPath = true;
|
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_MOD:
|
||||||
|
{
|
||||||
|
m_gameData->AddMod(std::string(optarg));
|
||||||
|
GetLogger()->Info("Running mod from path: '%s'\n", optarg);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case OPT_LANGDIR:
|
case OPT_LANGDIR:
|
||||||
{
|
{
|
||||||
m_langPath = optarg;
|
m_langPath = optarg;
|
||||||
GetLogger()->Info("Using custom language dir: '%s'\n", m_langPath.c_str());
|
GetLogger()->Info("Using language dir: '%s'\n", m_langPath.c_str());
|
||||||
break;
|
|
||||||
}
|
|
||||||
case OPT_TEXPACK:
|
|
||||||
{
|
|
||||||
m_texPackPath = optarg;
|
|
||||||
GetLogger()->Info("Using texturepack: '%s'\n", m_texPackPath.c_str());
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case OPT_VBO:
|
case OPT_VBO:
|
||||||
|
@ -425,6 +411,9 @@ bool CApplication::Create()
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_gameData->SetDataDir(std::string(m_dataPath));
|
||||||
|
m_gameData->Init();
|
||||||
|
|
||||||
if (GetProfile().GetLocalProfileString("Language", "Lang", path)) {
|
if (GetProfile().GetLocalProfileString("Language", "Lang", path)) {
|
||||||
Language language;
|
Language language;
|
||||||
if (ParseLanguage(path, language)) {
|
if (ParseLanguage(path, language)) {
|
||||||
|
@ -446,24 +435,8 @@ bool CApplication::Create()
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
m_sound->Create();
|
m_sound->Create();
|
||||||
|
m_sound->CacheAll();
|
||||||
if (!m_customDataPath && GetProfile().GetLocalProfileString("Resources", "Sound", path))
|
m_sound->AddMusicFiles();
|
||||||
{
|
|
||||||
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));
|
|
||||||
}
|
|
||||||
|
|
||||||
GetLogger()->Info("CApplication created successfully\n");
|
GetLogger()->Info("CApplication created successfully\n");
|
||||||
|
|
||||||
|
@ -1606,59 +1579,6 @@ bool CApplication::GetJoystickEnabled() const
|
||||||
return m_joystickEnabled;
|
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
|
Language CApplication::GetLanguage() const
|
||||||
{
|
{
|
||||||
return m_language;
|
return m_language;
|
||||||
|
|
|
@ -42,6 +42,7 @@ class CInstanceManager;
|
||||||
class CEventQueue;
|
class CEventQueue;
|
||||||
class CRobotMain;
|
class CRobotMain;
|
||||||
class CSoundInterface;
|
class CSoundInterface;
|
||||||
|
class CGameData;
|
||||||
|
|
||||||
namespace Gfx {
|
namespace Gfx {
|
||||||
class CModelManager;
|
class CModelManager;
|
||||||
|
@ -328,18 +329,6 @@ public:
|
||||||
static bool ParseDebugModes(const std::string& str, int& debugModes);
|
static bool ParseDebugModes(const std::string& str, int& debugModes);
|
||||||
//@}
|
//@}
|
||||||
|
|
||||||
//! Returns the full path to data directory
|
|
||||||
std::string GetDataDirPath() const;
|
|
||||||
|
|
||||||
//! Returns the full path to a standard dir in data directory
|
|
||||||
std::string GetDataSubdirPath(DataDir stdDir) const;
|
|
||||||
|
|
||||||
//! Returns the full path to a file in data directory given standard dir and subpath
|
|
||||||
std::string GetDataFilePath(DataDir stdDir, const std::string &subpath) const;
|
|
||||||
|
|
||||||
//! Returns the full path to a file in texture pack directory
|
|
||||||
std::string GetTexPackFilePath(const std::string& textureName) const;
|
|
||||||
|
|
||||||
//! Management of language
|
//! Management of language
|
||||||
//@{
|
//@{
|
||||||
Language GetLanguage() const;
|
Language GetLanguage() const;
|
||||||
|
@ -413,6 +402,8 @@ protected:
|
||||||
CRobotMain* m_robotMain;
|
CRobotMain* m_robotMain;
|
||||||
//! Profile (INI) reader/writer
|
//! Profile (INI) reader/writer
|
||||||
CProfile* m_profile;
|
CProfile* m_profile;
|
||||||
|
//! Game data
|
||||||
|
CGameData* m_gameData;
|
||||||
|
|
||||||
//! Code to return at exit
|
//! Code to return at exit
|
||||||
int m_exitCode;
|
int m_exitCode;
|
||||||
|
@ -486,9 +477,6 @@ protected:
|
||||||
//! Path to directory with language files
|
//! Path to directory with language files
|
||||||
std::string m_langPath;
|
std::string m_langPath;
|
||||||
|
|
||||||
//! Path to directory with user texture pack
|
|
||||||
std::string m_texPackPath;
|
|
||||||
|
|
||||||
//@{
|
//@{
|
||||||
//! Scene to run on startup
|
//! Scene to run on startup
|
||||||
std::string m_runSceneName;
|
std::string m_runSceneName;
|
||||||
|
@ -498,8 +486,6 @@ protected:
|
||||||
//! Scene test mode
|
//! Scene test mode
|
||||||
bool m_sceneTest;
|
bool m_sceneTest;
|
||||||
|
|
||||||
const char* m_standardDataDirs[DIR_MAX];
|
|
||||||
|
|
||||||
//! Application language
|
//! Application language
|
||||||
Language m_language;
|
Language m_language;
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,123 @@
|
||||||
|
// * This file is part of the COLOBOT source code
|
||||||
|
// * Copyright (C) 2014, Polish Portal of Colobot (PPC)
|
||||||
|
// *
|
||||||
|
// * This program is free software: you can redistribute it and/or modify
|
||||||
|
// * it under the terms of the GNU General Public License as published by
|
||||||
|
// * the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// * (at your option) any later version.
|
||||||
|
// *
|
||||||
|
// * This program is distributed in the hope that it will be useful,
|
||||||
|
// * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// * GNU General Public License for more details.
|
||||||
|
// *
|
||||||
|
// * You should have received a copy of the GNU General Public License
|
||||||
|
// * along with this program. If not, see http://www.gnu.org/licenses/.
|
||||||
|
|
||||||
|
#include "app/gamedata.h"
|
||||||
|
|
||||||
|
|
||||||
|
#include "app/app.h"
|
||||||
|
|
||||||
|
#include <boost/filesystem.hpp>
|
||||||
|
|
||||||
|
template<> CGameData* CSingleton<CGameData>::m_instance = nullptr;
|
||||||
|
|
||||||
|
CGameData::CGameData()
|
||||||
|
{
|
||||||
|
m_dataDirSet = 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";
|
||||||
|
}
|
||||||
|
|
||||||
|
CGameData::~CGameData()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void CGameData::SetDataDir(std::string path)
|
||||||
|
{
|
||||||
|
assert(!m_dataDirSet);
|
||||||
|
m_dataDirSet = true;
|
||||||
|
|
||||||
|
m_dataDirs.insert(m_dataDirs.begin(), path);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CGameData::AddMod(std::string path)
|
||||||
|
{
|
||||||
|
m_dataDirs.push_back(path);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CGameData::Init()
|
||||||
|
{
|
||||||
|
std::string out = "Using datadirs: ";
|
||||||
|
bool first = true;
|
||||||
|
for(std::vector<std::string>::reverse_iterator rit = m_dataDirs.rbegin(); rit != m_dataDirs.rend(); ++rit) {
|
||||||
|
if(!first) out += ", ";
|
||||||
|
first = false;
|
||||||
|
out += *rit;
|
||||||
|
}
|
||||||
|
out += "\n";
|
||||||
|
CLogger::GetInstancePointer()->Info(out.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string CGameData::GetFilePath(DataDir dir, const std::string& subpath)
|
||||||
|
{
|
||||||
|
int index = static_cast<int>(dir);
|
||||||
|
assert(index >= 0 && index < DIR_MAX);
|
||||||
|
|
||||||
|
for(std::vector<std::string>::reverse_iterator rit = m_dataDirs.rbegin(); rit != m_dataDirs.rend(); ++rit) {
|
||||||
|
std::stringstream str;
|
||||||
|
str << *rit;
|
||||||
|
str << "/";
|
||||||
|
str << m_standardDataDirs[index];
|
||||||
|
if (dir == DIR_HELP)
|
||||||
|
{
|
||||||
|
str << "/";
|
||||||
|
str << CApplication::GetInstancePointer()->GetLanguageChar();
|
||||||
|
}
|
||||||
|
str << "/";
|
||||||
|
str << subpath;
|
||||||
|
boost::filesystem::path path(str.str());
|
||||||
|
if(boost::filesystem::exists(path))
|
||||||
|
{
|
||||||
|
return str.str();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
std::stringstream str;
|
||||||
|
str << m_dataDirs[0];
|
||||||
|
str << "/";
|
||||||
|
str << m_standardDataDirs[index];
|
||||||
|
if (dir == DIR_HELP)
|
||||||
|
{
|
||||||
|
str << "/";
|
||||||
|
str << CApplication::GetInstancePointer()->GetLanguageChar();
|
||||||
|
}
|
||||||
|
str << "/";
|
||||||
|
str << subpath;
|
||||||
|
return str.str();
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string CGameData::GetDataPath(const std::string &subpath)
|
||||||
|
{
|
||||||
|
for(std::vector<std::string>::reverse_iterator rit = m_dataDirs.rbegin(); rit != m_dataDirs.rend(); ++rit) {
|
||||||
|
std::string path = *rit + "/" + subpath;
|
||||||
|
boost::filesystem::path boostPath(path);
|
||||||
|
if(boost::filesystem::exists(boostPath))
|
||||||
|
{
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return m_dataDirs[0] + "/" + subpath;
|
||||||
|
}
|
|
@ -0,0 +1,66 @@
|
||||||
|
// * This file is part of the COLOBOT source code
|
||||||
|
// * Copyright (C) 2014, Polish Portal of Colobot (PPC)
|
||||||
|
// *
|
||||||
|
// * This program is free software: you can redistribute it and/or modify
|
||||||
|
// * it under the terms of the GNU General Public License as published by
|
||||||
|
// * the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// * (at your option) any later version.
|
||||||
|
// *
|
||||||
|
// * This program is distributed in the hope that it will be useful,
|
||||||
|
// * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// * GNU General Public License for more details.
|
||||||
|
// *
|
||||||
|
// * You should have received a copy of the GNU General Public License
|
||||||
|
// * along with this program. If not, see http://www.gnu.org/licenses/.
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \file app/gamedata.h
|
||||||
|
* \brief Game data
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "common/singleton.h"
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \enum DataDir
|
||||||
|
* \brief Directories in data directory
|
||||||
|
*/
|
||||||
|
enum DataDir
|
||||||
|
{
|
||||||
|
DIR_AI, //! < ai scripts
|
||||||
|
DIR_FONT, //! < fonts
|
||||||
|
DIR_HELP, //! < help files
|
||||||
|
DIR_ICON, //! < icons & images
|
||||||
|
DIR_LEVEL, //! < levels
|
||||||
|
DIR_MODEL, //! < models
|
||||||
|
DIR_MUSIC, //! < music
|
||||||
|
DIR_SOUND, //! < sounds
|
||||||
|
DIR_TEXTURE, //! < textures
|
||||||
|
|
||||||
|
DIR_MAX //! < number of dirs
|
||||||
|
};
|
||||||
|
|
||||||
|
class CGameData : public CSingleton<CGameData>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CGameData();
|
||||||
|
~CGameData();
|
||||||
|
|
||||||
|
void Init();
|
||||||
|
void SetDataDir(std::string path);
|
||||||
|
void AddMod(std::string path);
|
||||||
|
|
||||||
|
std::string GetFilePath(DataDir dir, const std::string &subpath);
|
||||||
|
std::string GetDataPath(const std::string &subpath);
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool m_dataDirSet;
|
||||||
|
std::vector<std::string> m_dataDirs;
|
||||||
|
const char* m_standardDataDirs[DIR_MAX];
|
||||||
|
};
|
||||||
|
|
|
@ -178,25 +178,6 @@ enum Language
|
||||||
LANGUAGE_RUSSIAN = 4
|
LANGUAGE_RUSSIAN = 4
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* \enum DataDir
|
|
||||||
* \brief Directories in data directory
|
|
||||||
*/
|
|
||||||
enum DataDir
|
|
||||||
{
|
|
||||||
DIR_AI, //! < ai scripts
|
|
||||||
DIR_FONT, //! < fonts
|
|
||||||
DIR_HELP, //! < help files
|
|
||||||
DIR_ICON, //! < icons & images
|
|
||||||
DIR_LEVEL, //! < levels
|
|
||||||
DIR_MODEL, //! < models
|
|
||||||
DIR_MUSIC, //! < music
|
|
||||||
DIR_SOUND, //! < sounds
|
|
||||||
DIR_TEXTURE, //! < textures
|
|
||||||
|
|
||||||
DIR_MAX //! < number of dirs
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \enum BuildType
|
* \enum BuildType
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
#include "graphics/engine/engine.h"
|
#include "graphics/engine/engine.h"
|
||||||
|
|
||||||
#include "app/app.h"
|
#include "app/app.h"
|
||||||
|
#include "app/gamedata.h"
|
||||||
|
|
||||||
#include "common/image.h"
|
#include "common/image.h"
|
||||||
#include "common/key.h"
|
#include "common/key.h"
|
||||||
|
@ -2246,34 +2247,13 @@ Texture CEngine::CreateTexture(const std::string& texName, const TextureCreatePa
|
||||||
|
|
||||||
if (image == nullptr)
|
if (image == nullptr)
|
||||||
{
|
{
|
||||||
bool loadedFromTexPack = false;
|
if (! img.Load(CGameData::GetInstancePointer()->GetFilePath(DIR_TEXTURE, texName)))
|
||||||
|
|
||||||
std::string texPackName = m_app->GetTexPackFilePath(texName);
|
|
||||||
if (! texPackName.empty())
|
|
||||||
{
|
|
||||||
if (img.Load(texPackName))
|
|
||||||
{
|
|
||||||
loadedFromTexPack = true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
std::string error = img.GetError();
|
|
||||||
GetLogger()->Error("Couldn't load texture '%s' from texpack: %s, blacklisting the texpack path\n",
|
|
||||||
texName.c_str(), error.c_str());
|
|
||||||
m_texBlacklist.insert(texPackName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!loadedFromTexPack)
|
|
||||||
{
|
|
||||||
if (! img.Load(m_app->GetDataFilePath(DIR_TEXTURE, texName)))
|
|
||||||
{
|
{
|
||||||
std::string error = img.GetError();
|
std::string error = img.GetError();
|
||||||
GetLogger()->Error("Couldn't load texture '%s': %s, blacklisting\n", texName.c_str(), error.c_str());
|
GetLogger()->Error("Couldn't load texture '%s': %s, blacklisting\n", texName.c_str(), error.c_str());
|
||||||
m_texBlacklist.insert(texName);
|
m_texBlacklist.insert(texName);
|
||||||
return Texture(); // invalid texture
|
return Texture(); // invalid texture
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
image = &img;
|
image = &img;
|
||||||
}
|
}
|
||||||
|
@ -2435,7 +2415,7 @@ bool CEngine::ChangeTextureColor(const std::string& texName,
|
||||||
|
|
||||||
|
|
||||||
CImage img;
|
CImage img;
|
||||||
if (! img.Load(m_app->GetDataFilePath(DIR_TEXTURE, texName)))
|
if (! img.Load(CGameData::GetInstancePointer()->GetFilePath(DIR_TEXTURE, texName)))
|
||||||
{
|
{
|
||||||
std::string error = img.GetError();
|
std::string error = img.GetError();
|
||||||
GetLogger()->Error("Couldn't load texture '%s': %s, blacklisting\n", texName.c_str(), error.c_str());
|
GetLogger()->Error("Couldn't load texture '%s': %s, blacklisting\n", texName.c_str(), error.c_str());
|
||||||
|
|
|
@ -1,6 +1,24 @@
|
||||||
|
// * This file is part of the COLOBOT source code
|
||||||
|
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
|
||||||
|
// * Copyright (C) 2012-2014, Polish Portal of Colobot (PPC)
|
||||||
|
// *
|
||||||
|
// * This program is free software: you can redistribute it and/or modify
|
||||||
|
// * it under the terms of the GNU General Public License as published by
|
||||||
|
// * the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// * (at your option) any later version.
|
||||||
|
// *
|
||||||
|
// * This program is distributed in the hope that it will be useful,
|
||||||
|
// * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// * GNU General Public License for more details.
|
||||||
|
// *
|
||||||
|
// * You should have received a copy of the GNU General Public License
|
||||||
|
// * along with this program. If not, see http://www.gnu.org/licenses/.
|
||||||
|
|
||||||
#include "graphics/engine/modelmanager.h"
|
#include "graphics/engine/modelmanager.h"
|
||||||
|
|
||||||
#include "app/app.h"
|
#include "app/app.h"
|
||||||
|
#include "app/gamedata.h"
|
||||||
|
|
||||||
#include "common/logger.h"
|
#include "common/logger.h"
|
||||||
|
|
||||||
|
@ -30,7 +48,7 @@ bool CModelManager::LoadModel(const std::string& fileName, bool mirrored)
|
||||||
if (CApplication::GetInstance().IsDebugModeActive(DEBUG_MODELS))
|
if (CApplication::GetInstance().IsDebugModeActive(DEBUG_MODELS))
|
||||||
modelFile.SetPrintDebugInfo(true);
|
modelFile.SetPrintDebugInfo(true);
|
||||||
|
|
||||||
std::string filePath = CApplication::GetInstance().GetDataFilePath(DIR_MODEL, fileName);
|
std::string filePath = CGameData::GetInstancePointer()->GetFilePath(DIR_MODEL, fileName);
|
||||||
|
|
||||||
if (!modelFile.ReadModel(filePath))
|
if (!modelFile.ReadModel(filePath))
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,3 +1,20 @@
|
||||||
|
// * This file is part of the COLOBOT source code
|
||||||
|
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
|
||||||
|
// * Copyright (C) 2012-2014, Polish Portal of Colobot (PPC)
|
||||||
|
// *
|
||||||
|
// * This program is free software: you can redistribute it and/or modify
|
||||||
|
// * it under the terms of the GNU General Public License as published by
|
||||||
|
// * the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// * (at your option) any later version.
|
||||||
|
// *
|
||||||
|
// * This program is distributed in the hope that it will be useful,
|
||||||
|
// * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// * GNU General Public License for more details.
|
||||||
|
// *
|
||||||
|
// * You should have received a copy of the GNU General Public License
|
||||||
|
// * along with this program. If not, see http://www.gnu.org/licenses/.
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "common/singleton.h"
|
#include "common/singleton.h"
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
#include "graphics/engine/terrain.h"
|
#include "graphics/engine/terrain.h"
|
||||||
|
|
||||||
#include "app/app.h"
|
#include "app/app.h"
|
||||||
|
#include "app/gamedata.h"
|
||||||
|
|
||||||
#include "common/image.h"
|
#include "common/image.h"
|
||||||
#include "common/logger.h"
|
#include "common/logger.h"
|
||||||
|
@ -189,7 +190,7 @@ void CTerrain::AddMaterial(int id, const std::string& texName, const Math::Point
|
||||||
bool CTerrain::LoadResources(const std::string& fileName)
|
bool CTerrain::LoadResources(const std::string& fileName)
|
||||||
{
|
{
|
||||||
CImage img;
|
CImage img;
|
||||||
std::string path = CApplication::GetInstance().GetDataFilePath(DIR_TEXTURE, fileName);
|
std::string path = CGameData::GetInstancePointer()->GetFilePath(DIR_TEXTURE, fileName);
|
||||||
if (! img.Load(path))
|
if (! img.Load(path))
|
||||||
{
|
{
|
||||||
GetLogger()->Error("Cannot load resource file: '%s'\n", path.c_str());
|
GetLogger()->Error("Cannot load resource file: '%s'\n", path.c_str());
|
||||||
|
@ -286,7 +287,7 @@ bool CTerrain::LoadRelief(const std::string &fileName, float scaleRelief,
|
||||||
m_scaleRelief = scaleRelief;
|
m_scaleRelief = scaleRelief;
|
||||||
|
|
||||||
CImage img;
|
CImage img;
|
||||||
std::string path = CApplication::GetInstance().GetDataFilePath(DIR_TEXTURE, fileName);
|
std::string path = CGameData::GetInstancePointer()->GetFilePath(DIR_TEXTURE, fileName);
|
||||||
if (! img.Load(path))
|
if (! img.Load(path))
|
||||||
{
|
{
|
||||||
GetLogger()->Error("Could not load relief file: '%s'!\n", path.c_str());
|
GetLogger()->Error("Could not load relief file: '%s'!\n", path.c_str());
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
#include "graphics/engine/text.h"
|
#include "graphics/engine/text.h"
|
||||||
|
|
||||||
#include "app/app.h"
|
#include "app/app.h"
|
||||||
|
#include "app/gamedata.h"
|
||||||
|
|
||||||
#include "common/image.h"
|
#include "common/image.h"
|
||||||
#include "common/logger.h"
|
#include "common/logger.h"
|
||||||
|
@ -865,7 +866,7 @@ CachedFont* CText::GetOrOpenFont(FontType font, float size)
|
||||||
return m_lastCachedFont;
|
return m_lastCachedFont;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string path = CApplication::GetInstance().GetDataFilePath(DIR_FONT, mf->fileName);
|
std::string path = CGameData::GetInstancePointer()->GetFilePath(DIR_FONT, mf->fileName);
|
||||||
|
|
||||||
m_lastCachedFont = new CachedFont();
|
m_lastCachedFont = new CachedFont();
|
||||||
m_lastCachedFont->font = TTF_OpenFont(path.c_str(), pointSize);
|
m_lastCachedFont->font = TTF_OpenFont(path.c_str(), pointSize);
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
#include "CBot/CBotDll.h"
|
#include "CBot/CBotDll.h"
|
||||||
|
|
||||||
#include "app/app.h"
|
#include "app/app.h"
|
||||||
|
#include "app/gamedata.h"
|
||||||
|
|
||||||
#include "common/event.h"
|
#include "common/event.h"
|
||||||
#include "common/global.h"
|
#include "common/global.h"
|
||||||
|
@ -4081,7 +4082,7 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject)
|
||||||
if (Cmd(line, "Instructions") && !resetObject)
|
if (Cmd(line, "Instructions") && !resetObject)
|
||||||
{
|
{
|
||||||
OpString(line, "name", name);
|
OpString(line, "name", name);
|
||||||
std::string path = m_app->GetDataFilePath(DIR_HELP, name);
|
std::string path = CGameData::GetInstancePointer()->GetFilePath(DIR_HELP, name);
|
||||||
strcpy(m_infoFilename[SATCOM_HUSTON], path.c_str());
|
strcpy(m_infoFilename[SATCOM_HUSTON], path.c_str());
|
||||||
|
|
||||||
m_immediatSatCom = OpInt(line, "immediat", 0);
|
m_immediatSatCom = OpInt(line, "immediat", 0);
|
||||||
|
@ -4093,7 +4094,7 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject)
|
||||||
if (Cmd(line, "Satellite") && !resetObject)
|
if (Cmd(line, "Satellite") && !resetObject)
|
||||||
{
|
{
|
||||||
OpString(line, "name", name);
|
OpString(line, "name", name);
|
||||||
std::string path = m_app->GetDataFilePath(DIR_HELP, name);
|
std::string path = CGameData::GetInstancePointer()->GetFilePath(DIR_HELP, name);
|
||||||
strcpy(m_infoFilename[SATCOM_SAT], path.c_str());
|
strcpy(m_infoFilename[SATCOM_SAT], path.c_str());
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -4101,7 +4102,7 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject)
|
||||||
if (Cmd(line, "Loading") && !resetObject)
|
if (Cmd(line, "Loading") && !resetObject)
|
||||||
{
|
{
|
||||||
OpString(line, "name", name);
|
OpString(line, "name", name);
|
||||||
std::string path = m_app->GetDataFilePath(DIR_HELP, name);
|
std::string path = CGameData::GetInstancePointer()->GetFilePath(DIR_HELP, name);
|
||||||
strcpy(m_infoFilename[SATCOM_LOADING], path.c_str());
|
strcpy(m_infoFilename[SATCOM_LOADING], path.c_str());
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -4109,14 +4110,14 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject)
|
||||||
if (Cmd(line, "HelpFile") && !resetObject)
|
if (Cmd(line, "HelpFile") && !resetObject)
|
||||||
{
|
{
|
||||||
OpString(line, "name", name);
|
OpString(line, "name", name);
|
||||||
std::string path = m_app->GetDataFilePath(DIR_HELP, name);
|
std::string path = CGameData::GetInstancePointer()->GetFilePath(DIR_HELP, name);
|
||||||
strcpy(m_infoFilename[SATCOM_PROG], path.c_str());
|
strcpy(m_infoFilename[SATCOM_PROG], path.c_str());
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (Cmd(line, "SoluceFile") && !resetObject)
|
if (Cmd(line, "SoluceFile") && !resetObject)
|
||||||
{
|
{
|
||||||
OpString(line, "name", name);
|
OpString(line, "name", name);
|
||||||
std::string path = m_app->GetDataFilePath(DIR_HELP, name);
|
std::string path = CGameData::GetInstancePointer()->GetFilePath(DIR_HELP, name);
|
||||||
strcpy(m_infoFilename[SATCOM_SOLUCE], path.c_str());
|
strcpy(m_infoFilename[SATCOM_SOLUCE], path.c_str());
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
#include "script/script.h"
|
#include "script/script.h"
|
||||||
|
|
||||||
#include "app/app.h"
|
#include "app/app.h"
|
||||||
|
#include "app/gamedata.h"
|
||||||
|
|
||||||
#include "common/global.h"
|
#include "common/global.h"
|
||||||
#include "common/iman.h"
|
#include "common/iman.h"
|
||||||
|
@ -4406,7 +4407,7 @@ void CScript::New(Ui::CEdit* edit, const char* name)
|
||||||
sf = m_main->GetScriptFile();
|
sf = m_main->GetScriptFile();
|
||||||
if ( sf[0] != 0 ) // Load an empty program specific?
|
if ( sf[0] != 0 ) // Load an empty program specific?
|
||||||
{
|
{
|
||||||
std::string filename = CApplication::GetInstancePointer()->GetDataFilePath(DIR_AI, sf);
|
std::string filename = CGameData::GetInstancePointer()->GetFilePath(DIR_AI, sf);
|
||||||
file = fopen(filename.c_str(), "rb");
|
file = fopen(filename.c_str(), "rb");
|
||||||
if ( file != NULL )
|
if ( file != NULL )
|
||||||
{
|
{
|
||||||
|
@ -4500,7 +4501,7 @@ bool CScript::ReadScript(const char* filename)
|
||||||
|
|
||||||
if ( strchr(filename, '/') == 0 ) //we're reading non user script
|
if ( strchr(filename, '/') == 0 ) //we're reading non user script
|
||||||
{
|
{
|
||||||
name = CApplication::GetInstancePointer()->GetDataFilePath(DIR_AI, filename);
|
name = CGameData::GetInstancePointer()->GetFilePath(DIR_AI, filename);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -4534,7 +4535,7 @@ bool CScript::WriteScript(const char* filename)
|
||||||
|
|
||||||
if ( strchr(filename, '/') == 0 ) //we're writing non user script
|
if ( strchr(filename, '/') == 0 ) //we're writing non user script
|
||||||
{
|
{
|
||||||
name = CApplication::GetInstancePointer()->GetDataFilePath(DIR_AI, filename);
|
name = CGameData::GetInstancePointer()->GetFilePath(DIR_AI, filename);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -18,6 +18,8 @@
|
||||||
|
|
||||||
#include "sound/oalsound/alsound.h"
|
#include "sound/oalsound/alsound.h"
|
||||||
|
|
||||||
|
#include "app/gamedata.h"
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
|
|
||||||
|
@ -163,7 +165,7 @@ int ALSound::GetMusicVolume()
|
||||||
bool ALSound::Cache(Sound sound, const std::string &filename)
|
bool ALSound::Cache(Sound sound, const std::string &filename)
|
||||||
{
|
{
|
||||||
Buffer *buffer = new Buffer();
|
Buffer *buffer = new Buffer();
|
||||||
if (buffer->LoadFromFile(filename, sound))
|
if (buffer->LoadFromFile(CGameData::GetInstancePointer()->GetFilePath(DIR_SOUND, filename), sound))
|
||||||
{
|
{
|
||||||
m_sounds[sound] = buffer;
|
m_sounds[sound] = buffer;
|
||||||
return true;
|
return true;
|
||||||
|
@ -176,9 +178,7 @@ bool ALSound::CacheMusic(const std::string &filename)
|
||||||
if (m_music.find(filename) == m_music.end())
|
if (m_music.find(filename) == m_music.end())
|
||||||
{
|
{
|
||||||
Buffer *buffer = new Buffer();
|
Buffer *buffer = new Buffer();
|
||||||
std::stringstream file;
|
if (buffer->LoadFromFile(CGameData::GetInstancePointer()->GetFilePath(DIR_MUSIC, filename), static_cast<Sound>(-1)))
|
||||||
file << m_soundPath << "/" << filename;
|
|
||||||
if (buffer->LoadFromFile(file.str(), static_cast<Sound>(-1)))
|
|
||||||
{
|
{
|
||||||
m_music[filename] = buffer;
|
m_music[filename] = buffer;
|
||||||
return true;
|
return true;
|
||||||
|
@ -635,22 +635,21 @@ bool ALSound::PlayMusic(const std::string &filename, bool bRepeat, float fadeTim
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::stringstream file;
|
std::string file = CGameData::GetInstancePointer()->GetFilePath(DIR_MUSIC, filename);
|
||||||
file << m_soundPath << "/" << filename;
|
|
||||||
Buffer *buffer;
|
Buffer *buffer;
|
||||||
|
|
||||||
// check if we have music in cache
|
// check if we have music in cache
|
||||||
if (m_music.find(filename) == m_music.end())
|
if (m_music.find(filename) == m_music.end())
|
||||||
{
|
{
|
||||||
GetLogger()->Debug("Music %s was not cached!\n", filename.c_str());
|
GetLogger()->Debug("Music %s was not cached!\n", filename.c_str());
|
||||||
if (!boost::filesystem::exists(file.str()))
|
if (!boost::filesystem::exists(file))
|
||||||
{
|
{
|
||||||
GetLogger()->Debug("Requested music %s was not found.\n", filename.c_str());
|
GetLogger()->Debug("Requested music %s was not found.\n", filename.c_str());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
buffer = new Buffer();
|
buffer = new Buffer();
|
||||||
if (!buffer->LoadFromFile(file.str(), static_cast<Sound>(-1)))
|
if (!buffer->LoadFromFile(file, static_cast<Sound>(-1)))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,20 +41,19 @@ bool CSoundInterface::Create()
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSoundInterface::CacheAll(const std::string &path)
|
void CSoundInterface::CacheAll()
|
||||||
{
|
{
|
||||||
for ( int i = 1; i < SOUND_MAX; i++ )
|
for ( int i = 1; i < SOUND_MAX; i++ )
|
||||||
{
|
{
|
||||||
std::stringstream filename;
|
std::stringstream filename;
|
||||||
filename << path << "/sound" << std::setfill('0') << std::setw(3) << i << ".wav";
|
filename << "sound" << std::setfill('0') << std::setw(3) << i << ".wav";
|
||||||
if ( !Cache(static_cast<Sound>(i), filename.str()) )
|
if ( !Cache(static_cast<Sound>(i), filename.str()) )
|
||||||
GetLogger()->Warn("Unable to load audio: %s\n", filename.str().c_str());
|
GetLogger()->Warn("Unable to load audio: %s\n", filename.str().c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSoundInterface::AddMusicFiles(const std::string &path)
|
void CSoundInterface::AddMusicFiles()
|
||||||
{
|
{
|
||||||
m_soundPath = path;
|
|
||||||
CacheMusic("Intro1.ogg");
|
CacheMusic("Intro1.ogg");
|
||||||
CacheMusic("Intro2.ogg");
|
CacheMusic("Intro2.ogg");
|
||||||
CacheMusic("music010.ogg");
|
CacheMusic("music010.ogg");
|
||||||
|
|
|
@ -159,10 +159,10 @@ public:
|
||||||
/** Function called to cache all sound effect files.
|
/** Function called to cache all sound effect files.
|
||||||
* Function calls \link CSoundInterface::Cache() \endlink for each file
|
* Function calls \link CSoundInterface::Cache() \endlink for each file
|
||||||
*/
|
*/
|
||||||
void CacheAll(const std::string &path);
|
void CacheAll();
|
||||||
|
|
||||||
/** Function called to add all music files to list */
|
/** Function called to add all music files to list */
|
||||||
void AddMusicFiles(const std::string &path);
|
void AddMusicFiles();
|
||||||
|
|
||||||
/** Function called to cache sound effect file.
|
/** Function called to cache sound effect file.
|
||||||
* This function is called by plugin interface for each file.
|
* This function is called by plugin interface for each file.
|
||||||
|
@ -327,8 +327,5 @@ public:
|
||||||
* \return nothing
|
* \return nothing
|
||||||
*/
|
*/
|
||||||
virtual void StopPauseMusic();
|
virtual void StopPauseMusic();
|
||||||
|
|
||||||
protected:
|
|
||||||
std::string m_soundPath;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
#include "ui/edit.h"
|
#include "ui/edit.h"
|
||||||
|
|
||||||
#include "app/app.h"
|
#include "app/app.h"
|
||||||
|
#include "app/gamedata.h"
|
||||||
|
|
||||||
#include "clipboard/clipboard.h"
|
#include "clipboard/clipboard.h"
|
||||||
|
|
||||||
|
@ -1462,7 +1463,7 @@ bool CEdit::ReadText(std::string filename, int addSize)
|
||||||
std::string path = filename;
|
std::string path = filename;
|
||||||
if (!fs::exists(path))
|
if (!fs::exists(path))
|
||||||
{
|
{
|
||||||
path = CApplication::GetInstancePointer()->GetDataDirPath() + "/" + filename;
|
path = CGameData::GetInstancePointer()->GetDataPath(filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
file = fopen(fs::path(path).make_preferred().string().c_str(), "rb");
|
file = fopen(fs::path(path).make_preferred().string().c_str(), "rb");
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
#include "ui/maindialog.h"
|
#include "ui/maindialog.h"
|
||||||
|
|
||||||
#include "app/app.h"
|
#include "app/app.h"
|
||||||
|
#include "app/gamedata.h"
|
||||||
#include "app/system.h"
|
#include "app/system.h"
|
||||||
|
|
||||||
#include "common/config.h"
|
#include "common/config.h"
|
||||||
|
@ -3588,7 +3589,7 @@ void CMainDialog::BuildSceneName(std::string &filename, char *base, int rank)
|
||||||
{
|
{
|
||||||
rankStream << std::setfill('0') << std::setw(3) << rank;
|
rankStream << std::setfill('0') << std::setw(3) << rank;
|
||||||
filename = base + rankStream.str() + ".txt";
|
filename = base + rankStream.str() + ".txt";
|
||||||
filename = CApplication::GetInstance().GetDataFilePath(DIR_LEVEL, filename);
|
filename = CGameData::GetInstancePointer()->GetFilePath(DIR_LEVEL, filename);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue