CInterfaceManager no longer depends on Driver global variable.

--HG--
branch : gui-refactoring
This commit is contained in:
dfighter1985 2012-02-11 23:44:55 +01:00
parent 598ab0b6dc
commit 0ee882f9f1
3 changed files with 35 additions and 19 deletions

View file

@ -1075,7 +1075,7 @@ void prelogInit()
// resetTextContext ("bremenb.ttf", false); // resetTextContext ("bremenb.ttf", false);
resetTextContext ("ryzom.ttf", false); resetTextContext ("ryzom.ttf", false);
CInterfaceManager::getInstance()->setTextContext( TextContext ); CInterfaceManager::create( Driver, TextContext );
ProgressBar.setFontFactor(0.85f); ProgressBar.setFontFactor(0.85f);

View file

@ -97,7 +97,7 @@
#include "../login.h" #include "../login.h"
#include "../sheet_manager.h" // for emotes #include "../sheet_manager.h" // for emotes
#include "../global.h" // for emotes //#include "../global.h" // for emotes
#include "../entity_animation_manager.h" // for emotes #include "../entity_animation_manager.h" // for emotes
#include "../net_manager.h" // for emotes #include "../net_manager.h" // for emotes
#include "../client_chat_manager.h" // for emotes #include "../client_chat_manager.h" // for emotes
@ -127,6 +127,7 @@ extern CContinentManager ContinentMngr;
extern CStringMapper *_UIStringMapper; extern CStringMapper *_UIStringMapper;
extern bool IsInRingSession; extern bool IsInRingSession;
extern CEventsListener EventsListener; extern CEventsListener EventsListener;
extern CEntityAnimationManager *EAM;
namespace R2 namespace R2
{ {
@ -163,7 +164,7 @@ using namespace NLNET;
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
extern NL3D::UDriver *Driver; //extern NL3D::UDriver *Driver;
extern bool loginFinished; extern bool loginFinished;
// Edit actions // Edit actions
CActionsManager EditActions; CActionsManager EditActions;
@ -253,9 +254,11 @@ int CInterfaceManager::DebugTrackGroupsGetId( CInterfaceGroup *pIG )
#endif // AJM_DEBUG_TRACK_INTERFACE_GROUPS #endif // AJM_DEBUG_TRACK_INTERFACE_GROUPS
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
CInterfaceManager::CInterfaceManager() : CInterfaceManager::CInterfaceManager( NL3D::UDriver *driver, NL3D::UTextContext *textcontext ) :
_ViewRenderer( Driver, TextContext ) _ViewRenderer( driver, textcontext )
{ {
this->driver = driver;
this->textcontext = textcontext;
_Instance = this; _Instance = this;
_DbRootNode = new CCDBNodeBranch("ROOT"); _DbRootNode = new CCDBNodeBranch("ROOT");
_ScreenW = _ScreenH = 0; _ScreenW = _ScreenH = 0;
@ -430,6 +433,14 @@ void CInterfaceManager::resetShardSpecificData()
pGC->setActive(false); pGC->setActive(false);
} }
// ------------------------------------------------------------------------------------------------
void CInterfaceManager::create( NL3D::UDriver *driver, NL3D::UTextContext *textcontext )
{
nlassert( _Instance == NULL );
new CInterfaceManager( driver, textcontext );
}
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
void CInterfaceManager::destroy () void CInterfaceManager::destroy ()
{ {
@ -646,7 +657,8 @@ void CInterfaceManager::uninitOutGame()
void badXMLParseMessageBox() void badXMLParseMessageBox()
{ {
NL3D::UDriver::TMessageBoxId ret = Driver->systemMessageBox( "Interface XML reading failed!\n" NL3D::UDriver *driver = CInterfaceManager::getInstance()->getViewRenderer().getDriver();
NL3D::UDriver::TMessageBoxId ret = driver->systemMessageBox( "Interface XML reading failed!\n"
"Some XML files are corrupted and may have been removed.\n" "Some XML files are corrupted and may have been removed.\n"
"Ryzom may need to be restarted to run properly.\n" "Ryzom may need to be restarted to run properly.\n"
"Would you like to quit now?", "Would you like to quit now?",
@ -1468,7 +1480,8 @@ void CInterfaceManager::setupOptions()
// Try to change font if any // Try to change font if any
string sFont = _SystemOptions[OptionFont].getValStr(); string sFont = _SystemOptions[OptionFont].getValStr();
if ((!sFont.empty()) && (Driver != NULL)) extern void resetTextContext( const char*, bool );
if ((!sFont.empty()) && (driver != NULL))
resetTextContext(sFont.c_str(), true); resetTextContext(sFont.c_str(), true);
// Continue to parse the rest of the interface // Continue to parse the rest of the interface
@ -2056,9 +2069,9 @@ void CInterfaceManager::drawViews(NL3D::UCamera camera)
{ {
if ( (nPriority == WIN_PRIORITY_WORLD_SPACE) && !camera.empty()) if ( (nPriority == WIN_PRIORITY_WORLD_SPACE) && !camera.empty())
{ {
Driver->setViewMatrix(CMatrix::Identity); driver->setViewMatrix(CMatrix::Identity);
Driver->setModelMatrix(CMatrix::Identity); driver->setModelMatrix(CMatrix::Identity);
Driver->setFrustum(camera.getFrustum()); driver->setFrustum(camera.getFrustum());
_ViewRenderer.activateWorldSpaceMatrix (true); _ViewRenderer.activateWorldSpaceMatrix (true);
} }
@ -2082,7 +2095,7 @@ void CInterfaceManager::drawViews(NL3D::UCamera camera)
if ( (nPriority == WIN_PRIORITY_WORLD_SPACE) && !camera.empty()) if ( (nPriority == WIN_PRIORITY_WORLD_SPACE) && !camera.empty())
{ {
Driver->setMatrixMode2D11(); driver->setMatrixMode2D11();
_ViewRenderer.activateWorldSpaceMatrix (false); _ViewRenderer.activateWorldSpaceMatrix (false);
} }
} }
@ -2138,7 +2151,7 @@ void CInterfaceManager::drawViews(NL3D::UCamera camera)
_ViewRenderer.flush(); _ViewRenderer.flush();
// todo hulud remove Return in 2d world // todo hulud remove Return in 2d world
Driver->setMatrixMode2D11(); driver->setMatrixMode2D11();
// flush obs // flush obs
CCDBNodeBranch::flushObserversCalls(); CCDBNodeBranch::flushObserversCalls();
@ -5615,9 +5628,9 @@ REGISTER_ACTION_HANDLER( CHandlerEmote, "emote");
bool CInterfaceManager::testDragCopyKey() bool CInterfaceManager::testDragCopyKey()
{ {
// hardcoded for now // hardcoded for now
return Driver->AsyncListener.isKeyDown(KeyCONTROL) || return driver->AsyncListener.isKeyDown(KeyCONTROL) ||
Driver->AsyncListener.isKeyDown(KeyLCONTROL) || driver->AsyncListener.isKeyDown(KeyLCONTROL) ||
Driver->AsyncListener.isKeyDown(KeyRCONTROL); driver->AsyncListener.isKeyDown(KeyRCONTROL);
} }
// *************************************************************************** // ***************************************************************************

View file

@ -113,11 +113,13 @@ public:
/// Singleton method : Get the unique interface loader instance /// Singleton method : Get the unique interface loader instance
static CInterfaceManager* getInstance() static CInterfaceManager* getInstance()
{ {
if (_Instance == NULL) nlassert( _Instance != NULL );
_Instance = new CInterfaceManager();
return _Instance; return _Instance;
} }
/// Create singleton
static void create( NL3D::UDriver *driver, NL3D::UTextContext *textcontext );
/// Destroy singleton /// Destroy singleton
static void destroy (); static void destroy ();
@ -725,7 +727,6 @@ public:
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
private: private:
NL3D::UTextContext *textcontext;
// Observer for copying db branch changes // Observer for copying db branch changes
class CServerToLocalAutoCopy class CServerToLocalAutoCopy
@ -906,7 +907,7 @@ private:
uint8 _GlobalRolloverFactorContainer; uint8 _GlobalRolloverFactorContainer;
/// Constructor /// Constructor
CInterfaceManager(); CInterfaceManager( NL3D::UDriver *driver, NL3D::UTextContext *textcontext );
///the singleton's instance ///the singleton's instance
static CInterfaceManager* _Instance; static CInterfaceManager* _Instance;
@ -1067,6 +1068,8 @@ private:
// Update tooltip coordinate if they need to be (getInvalidCoords() returns a value != 0) // Update tooltip coordinate if they need to be (getInvalidCoords() returns a value != 0)
void updateTooltipCoords(CCtrlBase *newCtrl); void updateTooltipCoords(CCtrlBase *newCtrl);
NL3D::UDriver *driver;
NL3D::UTextContext *textcontext;
}; };
#endif // NL_INTERFACE_MANAGER_H #endif // NL_INTERFACE_MANAGER_H