Added simple texturepack support (#208)
parent
06cf93f466
commit
04f747b00b
|
@ -149,6 +149,8 @@ CApplication::CApplication()
|
||||||
|
|
||||||
m_language = LANGUAGE_ENV;
|
m_language = LANGUAGE_ENV;
|
||||||
|
|
||||||
|
m_texPack = "";
|
||||||
|
|
||||||
m_lowCPU = true;
|
m_lowCPU = true;
|
||||||
|
|
||||||
for (int i = 0; i < DIR_MAX; ++i)
|
for (int i = 0; i < DIR_MAX; ++i)
|
||||||
|
@ -219,7 +221,8 @@ ParseArgsStatus CApplication::ParseArguments(int argc, char *argv[])
|
||||||
OPT_LOGLEVEL,
|
OPT_LOGLEVEL,
|
||||||
OPT_LANGUAGE,
|
OPT_LANGUAGE,
|
||||||
OPT_LANGDIR,
|
OPT_LANGDIR,
|
||||||
OPT_VBO
|
OPT_VBO,
|
||||||
|
OPT_TEXPACK
|
||||||
};
|
};
|
||||||
|
|
||||||
option options[] =
|
option options[] =
|
||||||
|
@ -230,7 +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 },
|
||||||
{ "langdir", required_argument, nullptr, OPT_LANGDIR },
|
{ "langdir", required_argument, nullptr, OPT_LANGDIR },
|
||||||
{ "vbo", required_argument, nullptr, OPT_VBO }
|
{ "vbo", required_argument, nullptr, OPT_VBO },
|
||||||
|
{ "texpack", required_argument, nullptr, OPT_TEXPACK }
|
||||||
};
|
};
|
||||||
|
|
||||||
opterr = 0;
|
opterr = 0;
|
||||||
|
@ -267,6 +271,7 @@ ParseArgsStatus CApplication::ParseArguments(int argc, char *argv[])
|
||||||
GetLogger()->Message(" -language lang set language (one of: en, de, fr, pl)\n");
|
GetLogger()->Message(" -language lang set language (one of: en, de, fr, pl)\n");
|
||||||
GetLogger()->Message(" -langdir path set custom language directory path\n");
|
GetLogger()->Message(" -langdir path set custom language directory path\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");
|
||||||
|
GetLogger()->Message(" -texpack name set texture pack\n");
|
||||||
return PARSE_ARGS_HELP;
|
return PARSE_ARGS_HELP;
|
||||||
}
|
}
|
||||||
case OPT_DEBUG:
|
case OPT_DEBUG:
|
||||||
|
@ -330,6 +335,12 @@ ParseArgsStatus CApplication::ParseArguments(int argc, char *argv[])
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case OPT_TEXPACK:
|
||||||
|
{
|
||||||
|
m_texPack = optarg;
|
||||||
|
GetLogger()->Info("Using texturepack: '%s'\n", m_texPack.c_str());
|
||||||
|
break;
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
assert(false); // should never get here
|
assert(false); // should never get here
|
||||||
}
|
}
|
||||||
|
@ -484,6 +495,8 @@ bool CApplication::Create()
|
||||||
|
|
||||||
m_engine->SetDevice(m_device);
|
m_engine->SetDevice(m_device);
|
||||||
|
|
||||||
|
m_engine->SetTexturePack(m_texPack);
|
||||||
|
|
||||||
if (! m_engine->Create() )
|
if (! m_engine->Create() )
|
||||||
{
|
{
|
||||||
m_errorMessage = std::string("Error in CEngine::Init()\n") + standardInfoMessage;
|
m_errorMessage = std::string("Error in CEngine::Init()\n") + standardInfoMessage;
|
||||||
|
|
|
@ -467,6 +467,9 @@ protected:
|
||||||
//! Application language
|
//! Application language
|
||||||
Language m_language;
|
Language m_language;
|
||||||
|
|
||||||
|
//! Texture pack
|
||||||
|
std::string m_texPack;
|
||||||
|
|
||||||
//! Low cpu mode
|
//! Low cpu mode
|
||||||
bool m_lowCPU;
|
bool m_lowCPU;
|
||||||
};
|
};
|
||||||
|
|
|
@ -62,6 +62,8 @@ CEngine::CEngine(CApplication *app)
|
||||||
m_sound = nullptr;
|
m_sound = nullptr;
|
||||||
m_terrain = nullptr;
|
m_terrain = nullptr;
|
||||||
|
|
||||||
|
m_texPack = "";
|
||||||
|
|
||||||
m_showStats = false;
|
m_showStats = false;
|
||||||
|
|
||||||
m_focus = 0.75f;
|
m_focus = 0.75f;
|
||||||
|
@ -236,6 +238,11 @@ void CEngine::SetTerrain(CTerrain* terrain)
|
||||||
m_terrain = terrain;
|
m_terrain = terrain;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CEngine::SetTexturePack(const std::string& texpackName)
|
||||||
|
{
|
||||||
|
m_texPack = texpackName;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool CEngine::Create()
|
bool CEngine::Create()
|
||||||
{
|
{
|
||||||
|
@ -2109,7 +2116,7 @@ void CEngine::SetViewParams(const Math::Vector& eyePt, const Math::Vector& looka
|
||||||
m_sound->SetListener(eyePt, lookatPt);
|
m_sound->SetListener(eyePt, lookatPt);
|
||||||
}
|
}
|
||||||
|
|
||||||
Texture CEngine::CreateTexture(const std::string& texName, const TextureCreateParams& params, CImage* image)
|
Texture CEngine::CreateTexture(const std::string& texName, const TextureCreateParams& params, CImage* image, std::string orginalName)
|
||||||
{
|
{
|
||||||
if (texName.empty())
|
if (texName.empty())
|
||||||
return Texture(); // invalid texture
|
return Texture(); // invalid texture
|
||||||
|
@ -2125,7 +2132,7 @@ Texture CEngine::CreateTexture(const std::string& texName, const TextureCreatePa
|
||||||
if (! img.Load(m_app->GetDataFilePath(DIR_TEXTURE, texName)))
|
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());
|
if(orginalName == "") 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
|
||||||
}
|
}
|
||||||
|
@ -2139,13 +2146,18 @@ Texture CEngine::CreateTexture(const std::string& texName, const TextureCreatePa
|
||||||
|
|
||||||
if (! tex.Valid())
|
if (! tex.Valid())
|
||||||
{
|
{
|
||||||
GetLogger()->Error("Couldn't load texture '%s', blacklisting\n", texName.c_str());
|
if(orginalName == "") GetLogger()->Error("Couldn't load texture '%s', blacklisting\n", texName.c_str());
|
||||||
m_texBlacklist.insert(texName);
|
m_texBlacklist.insert(texName);
|
||||||
return tex;
|
return tex;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_texNameMap[texName] = tex;
|
if(orginalName == "") {
|
||||||
m_revTexNameMap[tex] = texName;
|
m_texNameMap[texName] = tex;
|
||||||
|
m_revTexNameMap[tex] = texName;
|
||||||
|
} else {
|
||||||
|
m_texNameMap[orginalName] = tex;
|
||||||
|
m_revTexNameMap[tex] = orginalName;
|
||||||
|
}
|
||||||
|
|
||||||
return tex;
|
return tex;
|
||||||
}
|
}
|
||||||
|
@ -2170,7 +2182,18 @@ Texture CEngine::LoadTexture(const std::string& name, const TextureCreateParams&
|
||||||
if (it != m_texNameMap.end())
|
if (it != m_texNameMap.end())
|
||||||
return (*it).second;
|
return (*it).second;
|
||||||
|
|
||||||
Texture tex = CreateTexture(name, params);
|
Texture tex;
|
||||||
|
if (m_texPack != "") {
|
||||||
|
std::string name_texpack = m_texPack + "/" + name;
|
||||||
|
|
||||||
|
if (m_texBlacklist.find(name_texpack) == m_texBlacklist.end()) {
|
||||||
|
tex = CreateTexture(name_texpack, params, nullptr, name);
|
||||||
|
if (tex.Valid())
|
||||||
|
return tex;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
tex = CreateTexture(name, params);
|
||||||
return tex;
|
return tex;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -726,6 +726,10 @@ public:
|
||||||
//! Writes a screenshot containing the current frame
|
//! Writes a screenshot containing the current frame
|
||||||
bool WriteScreenShot(const std::string& fileName, int width, int height);
|
bool WriteScreenShot(const std::string& fileName, int width, int height);
|
||||||
|
|
||||||
|
//! Set texture pack
|
||||||
|
void SetTexturePack(const std::string& texpackName);
|
||||||
|
|
||||||
|
|
||||||
//@{
|
//@{
|
||||||
//! Management of game pause mode
|
//! Management of game pause mode
|
||||||
void SetPause(bool pause);
|
void SetPause(bool pause);
|
||||||
|
@ -1229,7 +1233,7 @@ protected:
|
||||||
const Material& mat, int state);
|
const Material& mat, int state);
|
||||||
|
|
||||||
//! Create texture and add it to cache
|
//! Create texture and add it to cache
|
||||||
Texture CreateTexture(const std::string &texName, const TextureCreateParams ¶ms, CImage* image = nullptr);
|
Texture CreateTexture(const std::string &texName, const TextureCreateParams ¶ms, CImage* image = nullptr, std::string orginalName = "");
|
||||||
|
|
||||||
//! Tests whether the given object is visible
|
//! Tests whether the given object is visible
|
||||||
bool IsVisible(int objRank);
|
bool IsVisible(int objRank);
|
||||||
|
@ -1403,6 +1407,9 @@ protected:
|
||||||
* so are disabled for subsequent load calls. */
|
* so are disabled for subsequent load calls. */
|
||||||
std::set<std::string> m_texBlacklist;
|
std::set<std::string> m_texBlacklist;
|
||||||
|
|
||||||
|
//! Texture pack
|
||||||
|
std::string m_texPack;
|
||||||
|
|
||||||
//! Mouse cursor definitions
|
//! Mouse cursor definitions
|
||||||
EngineMouse m_mice[ENG_MOUSE_COUNT];
|
EngineMouse m_mice[ENG_MOUSE_COUNT];
|
||||||
//! Texture with mouse cursors
|
//! Texture with mouse cursors
|
||||||
|
|
Loading…
Reference in New Issue