From b5a56bd9e1ea07f578cc70ca7c8d3568c6bfcf52 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Fri, 27 Aug 2010 22:15:51 +0200 Subject: [PATCH] Fixed: #1082 Interface texturemaps can be configured in cfg file, png and tga inside interface texturemap treated equally. --- code/ryzom/client/src/client_cfg.cpp | 51 ++++++++++++++++++- code/ryzom/client/src/client_cfg.h | 13 ++++- .../src/interface_v3/interface_manager.cpp | 45 +++++++++++++--- .../client/src/interface_v3/view_renderer.cpp | 16 +++++- 4 files changed, 114 insertions(+), 11 deletions(-) diff --git a/code/ryzom/client/src/client_cfg.cpp b/code/ryzom/client/src/client_cfg.cpp index d53e6f2c1..8e7206d15 100644 --- a/code/ryzom/client/src/client_cfg.cpp +++ b/code/ryzom/client/src/client_cfg.cpp @@ -169,6 +169,24 @@ else \ cfgWarning("CFG: Default value used for '"#variableName"' !!!"); \ +//----------------------------------------------- +/// Macro to read a String Vector from the CFG. +/// variableName : Variable Name to Read and Set. +//----------------------------------------------- +#define _READ_STRINGVECTOR(variableName) \ + /* Read the Variable Value From Script */ \ + varPtr = ClientCfg.ConfigFile.getVarPtr(#variableName); \ + /* Value found, set the Variable */ \ + if(varPtr) \ + { \ + ClientCfg.variableName.clear (); \ + int iSz = varPtr->size(); \ + for (int i = 0; i < iSz; i++) \ + ClientCfg.variableName.push_back(varPtr->asString(i)); \ + } \ + /* Use the Default Value */ \ + else \ + cfgWarning("CFG: Default value used for '"#variableName"' !!!"); \ //----------------------------------------------- // Macro for the dev version @@ -183,6 +201,7 @@ #define READ_STRING_DEV(variableName) _READ_STRING(variableName) #define READ_CVECTOR_DEV(variableName) _READ_CVECTOR(variableName) #define READ_ENUM_ASINT_DEV(type, variableName) _READ_ENUM_ASINT(type, variableName) +#define READ_STRINGVECTOR_DEV(variableName) _READ_STRINGVECTOR(variableName) #else // !FINAL_VERSION #define READ_BOOL_DEV(variableName) #define READ_INT_DEV(variableName) @@ -192,6 +211,7 @@ #define READ_STRING_DEV(variableName) #define READ_CVECTOR_DEV(variableName) #define READ_ENUM_ASINT_DEV(type, variableName) +#define READ_STRINGVECTOR_DEV(variableName) #endif // !FINAL_VERSION //----------------------------------------------- @@ -206,6 +226,7 @@ #define READ_STRING_FV(variableName) _READ_STRING(variableName) #define READ_CVECTOR_FV(variableName) _READ_CVECTOR(variableName) #define READ_ENUM_ASINT_FV(type, variableName) _READ_ENUM_ASINT(type, variableName) +#define READ_STRINGVECTOR_FV(variableName) _READ_STRINGVECTOR(variableName) /////////// // USING // @@ -277,7 +298,23 @@ CClientConfig::CClientConfig() Local = false; // Default is Net Mode. FSHost = ""; // Default Host. - + +#if 1 // Yubo hack + // The order is important here, because in a layer, global texture are rendered through this order + TexturesInterface.push_back("texture_interfaces_v3"); + // DXTC contain all items and bricks bitmaps, they must come after standard texture + TexturesInterface.push_back("new_texture_interfaces_dxtc"); + // Added icons by Yubo's Team 2009 + TexturesInterface.push_back("texture_extra"); +#else + TexturesInterface.push_back("texture_interfaces_v3"); + TexturesInterfaceDXTC.push_back("texture_interfaces_dxtc"); +#endif + + TexturesOutGameInterface.push_back("texture_interfaces_v3_outgame_ui"); + + TexturesLoginInterface.push_back("texture_interfaces_v3_login"); + DisplayAccountButtons = true; CreateAccountURL = "https://secure.ryzom.com/signup/from_client.php"; ConditionsTermsURL = "https://secure.ryzom.com/signup/terms_of_use.php"; @@ -703,6 +740,18 @@ void CClientConfig::setValues() ClientCfg.SelectedSlot = 0; } + // interface textures login menus + READ_STRINGVECTOR_FV(TexturesLoginInterface); + READ_STRINGVECTOR_FV(TexturesLoginInterfaceDXTC); + + // interface textures outgame menus + READ_STRINGVECTOR_FV(TexturesOutGameInterface); + READ_STRINGVECTOR_FV(TexturesOutGameInterfaceDXTC); + + // interface textures ingame and r2 + READ_STRINGVECTOR_FV(TexturesInterface); + READ_STRINGVECTOR_FV(TexturesInterfaceDXTC); + // interface files login menus ClientCfg.XMLLoginInterfaceFiles.clear (); CConfigFile::CVar *pcvXMLLoginInterface = ClientCfg.ConfigFile.getVarPtr("XMLLoginInterfaceFiles"); diff --git a/code/ryzom/client/src/client_cfg.h b/code/ryzom/client/src/client_cfg.h index d9d8f5b5e..dad8e8077 100644 --- a/code/ryzom/client/src/client_cfg.h +++ b/code/ryzom/client/src/client_cfg.h @@ -78,6 +78,18 @@ struct CClientConfig sint SelectCharacter; /// Selected slot in select char interface uint8 SelectedSlot; + + /// Textures for interface login + std::vector TexturesLoginInterface; + std::vector TexturesLoginInterfaceDXTC; + + /// Textures for interface outgame + std::vector TexturesOutGameInterface; + std::vector TexturesOutGameInterfaceDXTC; + + /// Textures for ingame interface and r2 interface + std::vector TexturesInterface; + std::vector TexturesInterfaceDXTC; /// vector of XML file names that describe the interfaces config for login std::vector XMLLoginInterfaceFiles; @@ -85,7 +97,6 @@ struct CClientConfig /// vector of XML file names that describe the interfaces config for outgame menus std::vector XMLOutGameInterfaceFiles; - /// vector of XML file names that describe the interfaces config std::vector XMLInterfaceFiles; diff --git a/code/ryzom/client/src/interface_v3/interface_manager.cpp b/code/ryzom/client/src/interface_v3/interface_manager.cpp index efe64837e..d859d48d4 100644 --- a/code/ryzom/client/src/interface_v3/interface_manager.cpp +++ b/code/ryzom/client/src/interface_v3/interface_manager.cpp @@ -456,7 +456,19 @@ void CInterfaceManager::initLogin() return; } - loadTextures ("texture_interfaces_v3_login.tga", "texture_interfaces_v3_login.txt"); + nldebug("Textures Login Interface"); + + for (vector::iterator it = ClientCfg.TexturesLoginInterface.begin(), end = ClientCfg.TexturesLoginInterface.end(); it != end; ++it) + { + nldebug("Textures Login Interface: %s", (*it).c_str()); + loadTextures(*it + ".tga", *it + ".txt", false); + } + + for (vector::iterator it = ClientCfg.TexturesLoginInterfaceDXTC.begin(), end = ClientCfg.TexturesLoginInterfaceDXTC.end(); it != end; ++it) + { + nldebug("Textures Login Interface DXTC: %s", (*it).c_str()); + loadTextures(*it + ".tga", *it + ".txt", true); + } parseInterface (ClientCfg.XMLLoginInterfaceFiles, false); @@ -534,7 +546,19 @@ void CInterfaceManager::initOutGame() return; } - loadTextures ("texture_interfaces_v3_outgame_ui.tga", "texture_interfaces_v3_outgame_ui.txt"); + nldebug("Textures OutGame Interface"); + + for (vector::iterator it = ClientCfg.TexturesOutGameInterface.begin(), end = ClientCfg.TexturesOutGameInterface.end(); it != end; ++it) + { + nldebug("Textures OutGame Interface: %s", (*it).c_str()); + loadTextures(*it + ".tga", *it + ".txt", false); + } + + for (vector::iterator it = ClientCfg.TexturesOutGameInterfaceDXTC.begin(), end = ClientCfg.TexturesOutGameInterfaceDXTC.end(); it != end; ++it) + { + nldebug("Textures OutGame Interface DXTC: %s", (*it).c_str()); + loadTextures(*it + ".tga", *it + ".txt", true); + } parseInterface (ClientCfg.XMLOutGameInterfaceFiles, false); @@ -801,14 +825,19 @@ void CInterfaceManager::initInGame() // ------------------------------------------------------------------------------------------------ void CInterfaceManager::loadIngameInterfaceTextures() { - // The order is important here, because in a layer, global texture are rendered through this order - loadTextures ("texture_interfaces_v3.tga", "texture_interfaces_v3.txt"); + nldebug("Textures Ingame Interface"); - // DXTC contain all items and bricks bitmaps, they must come after standard texture - loadTextures ("new_texture_interfaces_dxtc.tga", "new_texture_interfaces_dxtc.txt"); + for (vector::iterator it = ClientCfg.TexturesInterface.begin(), end = ClientCfg.TexturesInterface.end(); it != end; ++it) + { + nldebug("Textures Ingame Interface: %s", (*it).c_str()); + loadTextures(*it + ".tga", *it + ".txt", false); + } - // Added icons by Yubo's Team 2009 - loadTextures ("texture_extra.tga", "texture_extra.txt"); + for (vector::iterator it = ClientCfg.TexturesInterfaceDXTC.begin(), end = ClientCfg.TexturesInterfaceDXTC.end(); it != end; ++it) + { + nldebug("Textures Ingame Interface DXTC: %s", (*it).c_str()); + loadTextures(*it + ".tga", *it + ".txt", true); + } } // ------------------------------------------------------------------------------------------------ diff --git a/code/ryzom/client/src/interface_v3/view_renderer.cpp b/code/ryzom/client/src/interface_v3/view_renderer.cpp index 9e131ec71..a2b38c3f5 100644 --- a/code/ryzom/client/src/interface_v3/view_renderer.cpp +++ b/code/ryzom/client/src/interface_v3/view_renderer.cpp @@ -744,6 +744,13 @@ void CViewRenderer::loadTextures (const std::string &textureFileName, const std: image.UVMax.V = uvMaxV; sTGAname = tgaName; sTGAname = strlwr(sTGAname); + string::size_type stripPng = sTGAname.find(".png"); + if (stripPng != string::npos) + { + sTGAname[stripPng + 1] = 't'; + sTGAname[stripPng + 2] = 'g'; + sTGAname[stripPng + 3] = 'a'; + } image.Name = sTGAname; image.GlobalTexturePtr = &(_GlobalTextures.back()); if (getTextureIdFromName(sTGAname) != -1) @@ -1025,7 +1032,14 @@ sint32 CViewRenderer::getTextureIdFromName (const string &sName) const static string nameLwr; nameLwr= sName; strlwr(nameLwr); - + string::size_type stripPng = nameLwr.find(".png"); + if (stripPng != string::npos) + { + nameLwr[stripPng + 1] = 't'; + nameLwr[stripPng + 2] = 'g'; + nameLwr[stripPng + 3] = 'a'; + } + // Search in map TTextureMap::const_iterator it= _TextureMap.find(nameLwr); if( it==_TextureMap.end() )