mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-11-05 23:09:04 +00:00
CHANGED: #1471 CViewTextID no longer depends on the client string manager.
--HG-- branch : gui-refactoring
This commit is contained in:
parent
84d826462d
commit
1d3ff3c948
3 changed files with 49 additions and 16 deletions
|
@ -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();
|
||||
|
|
|
@ -14,24 +14,18 @@
|
|||
// 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/>.
|
||||
|
||||
|
||||
|
||||
|
||||
#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(;;)
|
||||
|
|
|
@ -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;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue