diff --git a/code/ryzom/client/src/interface_v3/interface_manager.cpp b/code/ryzom/client/src/interface_v3/interface_manager.cpp index 9624e1074..48d846795 100644 --- a/code/ryzom/client/src/interface_v3/interface_manager.cpp +++ b/code/ryzom/client/src/interface_v3/interface_manager.cpp @@ -50,6 +50,7 @@ #include "view_bitmap_faber_mp.h" #include "view_bitmap_combo.h" #include "nel/gui/view_text.h" +#include "view_text_id.h" // Ctrl #include "nel/gui/ctrl_scroll.h" #include "nel/gui/ctrl_button.h" @@ -250,6 +251,25 @@ int CInterfaceManager::DebugTrackGroupsGetId( CInterfaceGroup *pIG ) #endif // AJM_DEBUG_TRACK_INTERFACE_GROUPS + +class CStringManagerTextProvider : public CViewTextID::IViewTextProvider +{ + bool getString( uint32 stringId, ucstring &result ) + { + return STRING_MANAGER::CStringManagerClient::instance()->getString( stringId, result ); + } + + bool getDynString( uint32 dynStringId, ucstring &result ) + { + return STRING_MANAGER::CStringManagerClient::instance()->getDynString( dynStringId, result ); + } +}; + +namespace +{ + CStringManagerTextProvider SMTextProvider; +} + // ------------------------------------------------------------------------------------------------ CInterfaceManager::CInterfaceManager( NL3D::UDriver *driver, NL3D::UTextContext *textcontext ) { @@ -261,6 +281,8 @@ CInterfaceManager::CInterfaceManager( NL3D::UDriver *driver, NL3D::UTextContext CViewRenderer::hwCursorScale = ClientCfg.HardwareCursorScale; CViewRenderer::hwCursors = &ClientCfg.HardwareCursors; CViewRenderer::getInstance(); + CViewTextID::setTextProvider( &SMTextProvider ); + _Instance = this; NLGUI::CDBManager::getInstance()->resizeBanks( NB_CDB_BANKS ); @@ -340,6 +362,7 @@ CInterfaceManager::CInterfaceManager( NL3D::UDriver *driver, NL3D::UTextContext // ------------------------------------------------------------------------------------------------ CInterfaceManager::~CInterfaceManager() { + CViewTextID::setTextProvider( NULL ); reset(); // to flush IDStringWaiters _ParentPositionsMap.clear(); diff --git a/code/ryzom/client/src/interface_v3/view_text_id.cpp b/code/ryzom/client/src/interface_v3/view_text_id.cpp index 041745571..fd37dc6bb 100644 --- a/code/ryzom/client/src/interface_v3/view_text_id.cpp +++ b/code/ryzom/client/src/interface_v3/view_text_id.cpp @@ -14,24 +14,18 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . - - - -#include "stdpch.h" - -#include "interface_manager.h" -#include "../string_manager_client.h" +#include "nel/gui/db_manager.h" #include "view_text_id.h" #include "nel/misc/xml_auto_ptr.h" -#include "../client_cfg.h" #include "nel/misc/algo.h" using namespace std; -using namespace STRING_MANAGER; using NLMISC::CCDBNodeLeaf; NLMISC_REGISTER_OBJECT(CViewBase, CViewTextID, std::string, "text_id"); +CViewTextID::IViewTextProvider* CViewTextID::textProvider = NULL; + // *************************************************************************** CViewTextID::CViewTextID(const std::string& id,const std::string &/* idDBPath */, sint FontSize /*=12*/,NLMISC::CRGBA Color /*=NLMISC::CRGBA(255,255,255)*/,bool Shadow /*=false*/) : CViewText (id, std::string(""), FontSize, Color, Shadow) @@ -116,13 +110,15 @@ void CViewTextID::checkCoords() { // String result ucstring result; - CStringManagerClient *pSMC = CStringManagerClient::instance(); - // Get the string - if (_DynamicString) - _Initialized = pSMC->getDynString (_TextId, result); - else - _Initialized = pSMC->getString (_TextId, result); + if( textProvider != NULL ) + { + // Get the string + if( _DynamicString ) + _Initialized = textProvider->getDynString( _TextId, result ); + else + _Initialized = textProvider->getString( _TextId, result ); + } // Remove all {break} for(;;) diff --git a/code/ryzom/client/src/interface_v3/view_text_id.h b/code/ryzom/client/src/interface_v3/view_text_id.h index f976791be..4335846df 100644 --- a/code/ryzom/client/src/interface_v3/view_text_id.h +++ b/code/ryzom/client/src/interface_v3/view_text_id.h @@ -23,7 +23,7 @@ #include "nel/gui/view_text.h" namespace NLMISC{ -class CCDBNodeLeaf; + class CCDBNodeLeaf; } // *************************************************************************** @@ -45,6 +45,15 @@ public: class CViewTextID : public CViewText { public: + + /// Interface for classes that can provide text to CViewTextId + class IViewTextProvider + { + public: + virtual ~IViewTextProvider(){} + virtual bool getString( uint32 stringId, ucstring &result ) = 0; + virtual bool getDynString( uint32 dynStringId, ucstring &result ) = 0; + }; CViewTextID(const TCtorParam ¶m) : CViewText(param) { @@ -109,6 +118,8 @@ public: REFLECT_STRING("textid_dblink", getTextIdDbLink, setTextIdDbLink); REFLECT_EXPORT_END + static void setTextProvider( IViewTextProvider *provider ){ textProvider = provider; } + protected: bool _IsDBLink; @@ -130,6 +141,9 @@ protected: std::string _DBPath; #endif +private: + static IViewTextProvider *textProvider; + };