From f5433fb361ceb55a92cb885791c47a0e00ea1240 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Thu, 12 Jul 2012 23:04:36 +0200 Subject: [PATCH] CHANGED: #1471 no need to go thru CInterfaceManager, when CViewRenderer has it's own Singleton. --- code/ryzom/client/src/global.cpp | 2 +- code/ryzom/client/src/init.cpp | 3 +- .../src/interface_v3/interface_manager.cpp | 43 ++++++++----------- .../src/interface_v3/interface_manager.h | 19 +------- 4 files changed, 22 insertions(+), 45 deletions(-) diff --git a/code/ryzom/client/src/global.cpp b/code/ryzom/client/src/global.cpp index ee6e1f483..269a2736f 100644 --- a/code/ryzom/client/src/global.cpp +++ b/code/ryzom/client/src/global.cpp @@ -83,7 +83,7 @@ void resetTextContext (const char *font, bool resetInterfaceManager) if (resetInterfaceManager) { CInterfaceManager *im = CInterfaceManager::getInstance(); - im->setTextContext( TextContext ); + CViewRenderer::setTextContext( TextContext ); im->resetTextIndex(); } } diff --git a/code/ryzom/client/src/init.cpp b/code/ryzom/client/src/init.cpp index e4abd38ba..0efb68169 100644 --- a/code/ryzom/client/src/init.cpp +++ b/code/ryzom/client/src/init.cpp @@ -1084,8 +1084,7 @@ void prelogInit() resetTextContext ("ryzom.ttf", false); - CWidgetManager::getInstance(); - CInterfaceManager::create( Driver, TextContext ); + CInterfaceManager::getInstance(); // Yoyo: initialize NOW the InputHandler for Event filtering. CInputHandlerManager *InputHandlerManager = CInputHandlerManager::getInstance(); diff --git a/code/ryzom/client/src/interface_v3/interface_manager.cpp b/code/ryzom/client/src/interface_v3/interface_manager.cpp index 055441bd1..88e6b3eea 100644 --- a/code/ryzom/client/src/interface_v3/interface_manager.cpp +++ b/code/ryzom/client/src/interface_v3/interface_manager.cpp @@ -130,6 +130,8 @@ using namespace NLGUI; #include "parser_modules.h" +#include "../global.h" + using namespace NLMISC; namespace NLGUI @@ -433,8 +435,15 @@ namespace CRyzomTextFormatter RyzomTextFormatter; } +CInterfaceManager* CInterfaceManager::getInstance() +{ + if( _Instance == NULL ) + _Instance = new CInterfaceManager(); + return _Instance; +} + // ------------------------------------------------------------------------------------------------ -CInterfaceManager::CInterfaceManager( NL3D::UDriver *driver, NL3D::UTextContext *textcontext ) +CInterfaceManager::CInterfaceManager() { parser = new CInterfaceParser(); parser->setSetupOptionsCallback( this ); @@ -450,10 +459,8 @@ CInterfaceManager::CInterfaceManager( NL3D::UDriver *driver, NL3D::UTextContext parser->setCacheUIParsing( ClientCfg.CacheUIParsing ); CWidgetManager::parser = parser; - this->driver = driver; - this->textcontext = textcontext; - CViewRenderer::setDriver( driver ); - CViewRenderer::setTextContext( textcontext ); + CViewRenderer::setDriver( Driver ); + CViewRenderer::setTextContext( TextContext ); CViewRenderer::hwCursorScale = ClientCfg.HardwareCursorScale; CViewRenderer::hwCursors = &ClientCfg.HardwareCursors; CViewRenderer::getInstance(); @@ -464,7 +471,6 @@ CInterfaceManager::CInterfaceManager( NL3D::UDriver *driver, NL3D::UTextContext CGroupHTML::options.appName = "Ryzom"; CGroupHTML::options.appVersion = RYZOM_VERSION; - _Instance = this; NLGUI::CDBManager::getInstance()->resizeBanks( NB_CDB_BANKS ); interfaceLinkUpdater = new CInterfaceLink::CInterfaceLinkUpdater(); _ScreenW = _ScreenH = 0; @@ -527,7 +533,7 @@ CInterfaceManager::CInterfaceManager( NL3D::UDriver *driver, NL3D::UTextContext _DebugTrackGroupCreateCount = 0; _DebugTrackGroupDestroyCount = 0; #endif // AJM_DEBUG_TRACK_INTERFACE_GROUPS - textcontext = NULL; + } // ------------------------------------------------------------------------------------------------ @@ -605,12 +611,6 @@ void CInterfaceManager::resetShardSpecificData() // ------------------------------------------------------------------------------------------------ -void CInterfaceManager::create( NL3D::UDriver *driver, NL3D::UTextContext *textcontext ) -{ - nlassert( _Instance == NULL ); - new CInterfaceManager( driver, textcontext ); -} - // ------------------------------------------------------------------------------------------------ void CInterfaceManager::destroy () { @@ -1535,7 +1535,7 @@ void CInterfaceManager::updateFrameViews(NL3D::UCamera camera) drawViews(camera); // The interface manager may change usual Global setup. reset them. - textcontext->setShadeColor(CRGBA::Black); + CViewRenderer::getTextContext()->setShadeColor(CRGBA::Black); } @@ -1547,8 +1547,7 @@ void CInterfaceManager::setupOptions() // Try to change font if any string sFont = wm->getSystemOption( CWidgetManager::OptionFont ).getValStr(); - extern void resetTextContext( const char*, bool ); - if ((!sFont.empty()) && (driver != NULL)) + if ((!sFont.empty()) && (Driver != NULL)) resetTextContext(sFont.c_str(), true); // Continue to parse the rest of the interface } @@ -3138,9 +3137,9 @@ bool CInterfaceManager::CEmoteCmd::execute(const std::string &/* rawCommandStrin bool CInterfaceManager::testDragCopyKey() { // hardcoded for now - return driver->AsyncListener.isKeyDown(KeyCONTROL) || - driver->AsyncListener.isKeyDown(KeyLCONTROL) || - driver->AsyncListener.isKeyDown(KeyRCONTROL); + return Driver->AsyncListener.isKeyDown(KeyCONTROL) || + Driver->AsyncListener.isKeyDown(KeyLCONTROL) || + Driver->AsyncListener.isKeyDown(KeyRCONTROL); } // *************************************************************************** @@ -3976,10 +3975,4 @@ bool CInterfaceManager::parseTokens(ucstring& ucstr) return true;; } -void CInterfaceManager::setTextContext( NL3D::UTextContext *textcontext ) -{ - this->textcontext = textcontext; - CViewRenderer::getInstance()->setTextContext( textcontext ); -} - diff --git a/code/ryzom/client/src/interface_v3/interface_manager.h b/code/ryzom/client/src/interface_v3/interface_manager.h index a5b764755..4f21e7d07 100644 --- a/code/ryzom/client/src/interface_v3/interface_manager.h +++ b/code/ryzom/client/src/interface_v3/interface_manager.h @@ -119,14 +119,7 @@ public: public: /// Singleton method : Get the unique interface loader instance - static CInterfaceManager* getInstance() - { - nlassert( _Instance != NULL ); - return _Instance; - } - - /// Create singleton - static void create( NL3D::UDriver *driver, NL3D::UTextContext *textcontext ); + static CInterfaceManager* getInstance(); /// Destroy singleton static void destroy (); @@ -428,12 +421,6 @@ public: */ static bool parseTokens(ucstring& ucstr); - /// Sets the current TextContext. - void setTextContext( NL3D::UTextContext *textcontext ); - - /// Retrueves the current TextContext - inline NL3D::UTextContext* getTextContext() const{ return textcontext; }; - // ------------------------------------------------------------------------------------------------ private: @@ -582,7 +569,7 @@ private: /// Constructor - CInterfaceManager( NL3D::UDriver *driver, NL3D::UTextContext *textcontext ); + CInterfaceManager(); ///the singleton's instance static CInterfaceManager* _Instance; @@ -655,8 +642,6 @@ private: // Pop a new message box. If the message box was found, returns a pointer on it void messageBoxInternal(const std::string &msgBoxGroup, const ucstring &text, const std::string &masterGroup, TCaseMode caseMode); - NL3D::UDriver *driver; - NL3D::UTextContext *textcontext; CInterfaceLink::CInterfaceLinkUpdater *interfaceLinkUpdater; NLGUI::CInterfaceParser *parser;