CHANGED: #1471 CViewTextID no longer depends on the client string manager.

This commit is contained in:
dfighter1985 2012-06-21 06:57:39 +02:00
parent 69068877fc
commit b16c0362ef
3 changed files with 49 additions and 16 deletions

View file

@ -50,6 +50,7 @@
#include "view_bitmap_faber_mp.h" #include "view_bitmap_faber_mp.h"
#include "view_bitmap_combo.h" #include "view_bitmap_combo.h"
#include "nel/gui/view_text.h" #include "nel/gui/view_text.h"
#include "view_text_id.h"
// Ctrl // Ctrl
#include "nel/gui/ctrl_scroll.h" #include "nel/gui/ctrl_scroll.h"
#include "nel/gui/ctrl_button.h" #include "nel/gui/ctrl_button.h"
@ -250,6 +251,25 @@ int CInterfaceManager::DebugTrackGroupsGetId( CInterfaceGroup *pIG )
#endif // AJM_DEBUG_TRACK_INTERFACE_GROUPS #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 ) CInterfaceManager::CInterfaceManager( NL3D::UDriver *driver, NL3D::UTextContext *textcontext )
{ {
@ -261,6 +281,8 @@ CInterfaceManager::CInterfaceManager( NL3D::UDriver *driver, NL3D::UTextContext
CViewRenderer::hwCursorScale = ClientCfg.HardwareCursorScale; CViewRenderer::hwCursorScale = ClientCfg.HardwareCursorScale;
CViewRenderer::hwCursors = &ClientCfg.HardwareCursors; CViewRenderer::hwCursors = &ClientCfg.HardwareCursors;
CViewRenderer::getInstance(); CViewRenderer::getInstance();
CViewTextID::setTextProvider( &SMTextProvider );
_Instance = this; _Instance = this;
NLGUI::CDBManager::getInstance()->resizeBanks( NB_CDB_BANKS ); NLGUI::CDBManager::getInstance()->resizeBanks( NB_CDB_BANKS );
@ -340,6 +362,7 @@ CInterfaceManager::CInterfaceManager( NL3D::UDriver *driver, NL3D::UTextContext
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
CInterfaceManager::~CInterfaceManager() CInterfaceManager::~CInterfaceManager()
{ {
CViewTextID::setTextProvider( NULL );
reset(); // to flush IDStringWaiters reset(); // to flush IDStringWaiters
_ParentPositionsMap.clear(); _ParentPositionsMap.clear();

View file

@ -14,24 +14,18 @@
// You should have received a copy of the GNU Affero General Public License // You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>. // along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "nel/gui/db_manager.h"
#include "stdpch.h"
#include "interface_manager.h"
#include "../string_manager_client.h"
#include "view_text_id.h" #include "view_text_id.h"
#include "nel/misc/xml_auto_ptr.h" #include "nel/misc/xml_auto_ptr.h"
#include "../client_cfg.h"
#include "nel/misc/algo.h" #include "nel/misc/algo.h"
using namespace std; using namespace std;
using namespace STRING_MANAGER;
using NLMISC::CCDBNodeLeaf; using NLMISC::CCDBNodeLeaf;
NLMISC_REGISTER_OBJECT(CViewBase, CViewTextID, std::string, "text_id"); 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*/) 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) : CViewText (id, std::string(""), FontSize, Color, Shadow)
@ -116,13 +110,15 @@ void CViewTextID::checkCoords()
{ {
// String result // String result
ucstring result; ucstring result;
CStringManagerClient *pSMC = CStringManagerClient::instance();
// Get the string if( textProvider != NULL )
if (_DynamicString) {
_Initialized = pSMC->getDynString (_TextId, result); // Get the string
else if( _DynamicString )
_Initialized = pSMC->getString (_TextId, result); _Initialized = textProvider->getDynString( _TextId, result );
else
_Initialized = textProvider->getString( _TextId, result );
}
// Remove all {break} // Remove all {break}
for(;;) for(;;)

View file

@ -23,7 +23,7 @@
#include "nel/gui/view_text.h" #include "nel/gui/view_text.h"
namespace NLMISC{ namespace NLMISC{
class CCDBNodeLeaf; class CCDBNodeLeaf;
} }
// *************************************************************************** // ***************************************************************************
@ -45,6 +45,15 @@ public:
class CViewTextID : public CViewText class CViewTextID : public CViewText
{ {
public: 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 &param) : CViewText(param) CViewTextID(const TCtorParam &param) : CViewText(param)
{ {
@ -109,6 +118,8 @@ public:
REFLECT_STRING("textid_dblink", getTextIdDbLink, setTextIdDbLink); REFLECT_STRING("textid_dblink", getTextIdDbLink, setTextIdDbLink);
REFLECT_EXPORT_END REFLECT_EXPORT_END
static void setTextProvider( IViewTextProvider *provider ){ textProvider = provider; }
protected: protected:
bool _IsDBLink; bool _IsDBLink;
@ -130,6 +141,9 @@ protected:
std::string _DBPath; std::string _DBPath;
#endif #endif
private:
static IViewTextProvider *textProvider;
}; };