From 44643839be782e8b2cb487d8664d28cfc14491f1 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Mon, 16 Jul 2012 06:16:43 +0200 Subject: [PATCH 1/2] CHANGED: #1471 The local string mapper is now instantiated by CWidgetManager. --HG-- branch : gui-refactoring --- code/nel/include/nel/gui/interface_element.h | 5 ++++- code/nel/src/gui/interface_element.cpp | 15 +++++++++++++-- code/nel/src/gui/widget_manager.cpp | 4 ++++ .../src/interface_v3/interface_manager.cpp | 17 ----------------- 4 files changed, 21 insertions(+), 20 deletions(-) diff --git a/code/nel/include/nel/gui/interface_element.h b/code/nel/include/nel/gui/interface_element.h index b5aa6fcb0..095fef7c3 100644 --- a/code/nel/include/nel/gui/interface_element.h +++ b/code/nel/include/nel/gui/interface_element.h @@ -521,7 +521,6 @@ namespace NLGUI TLinkVect *_Links; // links, or NULL if no link }; - extern NLMISC::CStringMapper *_UIStringMapper; /** * class to compress string usage in the interface * \author Matthieu 'Trap' Besson @@ -586,9 +585,13 @@ namespace NLGUI } } + static void createStringMapper(); + static void deleteStringMapper(); + private: NLMISC::TStringId _Id; + static NLMISC::CStringMapper *_UIStringMapper; }; inline bool operator==(const CStringShared &lhs, const CStringShared &rhs) { return lhs.getStringId() == rhs.getStringId(); } diff --git a/code/nel/src/gui/interface_element.cpp b/code/nel/src/gui/interface_element.cpp index 0149b739b..affc6ef31 100644 --- a/code/nel/src/gui/interface_element.cpp +++ b/code/nel/src/gui/interface_element.cpp @@ -32,8 +32,6 @@ using namespace NLMISC; namespace NLGUI { - CStringMapper *_UIStringMapper = NULL; - // ------------------------------------------------------------------------------------------------ CInterfaceElement::~CInterfaceElement() { @@ -1271,6 +1269,19 @@ namespace NLGUI return false; } + CStringMapper* CStringShared::_UIStringMapper = NULL; + + + void CStringShared::createStringMapper() + { + if( _UIStringMapper == NULL ) + _UIStringMapper = CStringMapper::createLocalMapper(); + } + + void CStringShared::deleteStringMapper() + { + delete _UIStringMapper; + } } diff --git a/code/nel/src/gui/widget_manager.cpp b/code/nel/src/gui/widget_manager.cpp index 4cee9f340..8710e530a 100644 --- a/code/nel/src/gui/widget_manager.cpp +++ b/code/nel/src/gui/widget_manager.cpp @@ -3093,6 +3093,8 @@ namespace NLGUI CWidgetManager::CWidgetManager() { + CStringShared::createStringMapper(); + CReflectableRegister::registerClasses(); parser = IParser::createParser(); @@ -3133,6 +3135,8 @@ namespace NLGUI _Pointer = NULL; curContextHelp = NULL; + + CStringShared::deleteStringMapper(); } } diff --git a/code/ryzom/client/src/interface_v3/interface_manager.cpp b/code/ryzom/client/src/interface_v3/interface_manager.cpp index f537cc383..75452bf2d 100644 --- a/code/ryzom/client/src/interface_v3/interface_manager.cpp +++ b/code/ryzom/client/src/interface_v3/interface_manager.cpp @@ -137,7 +137,6 @@ using namespace NLMISC; namespace NLGUI { extern void luaDebuggerMainLoop(); - extern NLMISC::CStringMapper *_UIStringMapper; } extern CClientChatManager ChatMngr; @@ -543,10 +542,6 @@ CInterfaceManager::~CInterfaceManager() CViewTextFormated::setFormatter( NULL ); reset(); // to flush IDStringWaiters - // release the local string mapper - delete _UIStringMapper; - _UIStringMapper = NULL; - // release the database observers releaseServerToLocalAutoCopyObservers(); @@ -636,10 +631,6 @@ void CInterfaceManager::initLogin() // Init LUA Scripting initLUA(); - // Create String mapper - if (_UIStringMapper == NULL) - _UIStringMapper = CStringMapper::createLocalMapper(); - // Clear the action manager Actions.clear(); EditActions.clear(); @@ -708,10 +699,6 @@ void CInterfaceManager::uninitLogin() // ------------------------------------------------------------------------------------------------ void CInterfaceManager::initOutGame() { - // create String mapper - if (_UIStringMapper == NULL) - _UIStringMapper = CStringMapper::createLocalMapper(); - // Clear the action manager Actions.clear(); EditActions.clear(); @@ -871,10 +858,6 @@ void CInterfaceManager::initInGame() // Init LUA Scripting initLUA(); - // create the _UIStringMapper - if (_UIStringMapper == NULL) - _UIStringMapper = CStringMapper::createLocalMapper(); - // Clear the action manager Actions.clear(); EditActions.clear(); From 1c1af9fbbc021370192ce231772a8da364258b49 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Mon, 16 Jul 2012 07:15:40 +0200 Subject: [PATCH 2/2] CHANGED: #1471 Added some comments to the headers. --HG-- branch : gui-refactoring --- code/nel/include/nel/gui/db_manager.h | 24 +++++++++++++++++++ code/nel/include/nel/gui/group_html.h | 5 ++++ code/nel/include/nel/gui/interface_parser.h | 15 ++++++++---- code/nel/include/nel/gui/lua_manager.h | 14 ++++++++++- code/nel/include/nel/gui/parser.h | 1 + code/nel/include/nel/gui/reflect_register.h | 1 + code/nel/include/nel/gui/view_renderer.h | 1 + code/nel/include/nel/gui/view_text_formated.h | 1 + code/nel/include/nel/gui/view_text_id.h | 2 +- code/nel/include/nel/gui/widget_manager.h | 12 +++++++++- 10 files changed, 69 insertions(+), 7 deletions(-) diff --git a/code/nel/include/nel/gui/db_manager.h b/code/nel/include/nel/gui/db_manager.h index 38e75a755..72f665923 100644 --- a/code/nel/include/nel/gui/db_manager.h +++ b/code/nel/include/nel/gui/db_manager.h @@ -23,15 +23,39 @@ namespace NLGUI { + /** + Database Manager + + Provides access to a simple CDB based tree hierarchical data store + */ class CDBManager : public NLMISC::CCDBManager { public: static CDBManager* getInstance(); static void release(); + /** + Retrieves a leaf node from the database. + @param name - name of the data leaf node we are querying. + @param create - when true if a node cannot be found it is created. + */ NLMISC::CCDBNodeLeaf* getDbProp( const std::string &name, bool create = true ); + + /** + Deletes a node from the database. + @param name - name of the node. + */ void delDbProp( const std::string &name ); + + /** + Returns a leaf node's content as an sint32 + @param name - name of the leaf node. + */ sint32 getDbValue32( const std::string &name ); + + /** + Returns the root branch of the database. + */ NLMISC::CCDBNodeBranch* getDB() const; private: diff --git a/code/nel/include/nel/gui/group_html.h b/code/nel/include/nel/gui/group_html.h index 3d0b641fd..44bad783f 100644 --- a/code/nel/include/nel/gui/group_html.h +++ b/code/nel/include/nel/gui/group_html.h @@ -63,12 +63,17 @@ namespace NLGUI friend void TextEndUnparsedElement(HText *me, const char *buffer, int length); friend int requestTerminater (HTRequest * request, HTResponse * response, void * param, int status); + /// Web browser options for CGroupHTML struct SWebOptions { public: + /// Id of the browser ( e.g.: Chrome, Firefox, Ryzom ) std::string appName; + /// Version of the browser std::string appVersion; + /// Language code of the browser( e.g.: en, hu ) std::string languageCode; + /// List of domains the widget can consider secure. std::vector< std::string > trustedDomains; SWebOptions() diff --git a/code/nel/include/nel/gui/interface_parser.h b/code/nel/include/nel/gui/interface_parser.h index 032884437..be333044c 100644 --- a/code/nel/include/nel/gui/interface_parser.h +++ b/code/nel/include/nel/gui/interface_parser.h @@ -53,15 +53,21 @@ namespace NLGUI public: + /// Interface for parser modules + /// Such modules can be plugged into CInterfaceParser, and + /// the modules then can parse GUI XMLs for widget classes that are not + /// generic enough to be in the GUI library. class IParserModule { public: + + /// Various parsing stages enum ParsingStage { - None = 0, - Unresolved = 1, - Resolved = 2, - GroupChildren = 4 + None = 0, /// module cannot parse in any stage. + Unresolved = 1, /// module can parse in the first stage when styles, templates, etc have not been resolved yet + Resolved = 2, /// module can parse after resolving styles and templates + GroupChildren = 4 /// module can parse when parsing the group children }; IParserModule(){ @@ -86,6 +92,7 @@ namespace NLGUI uint parsingStage; }; + /// Interface for event handlers which can be called when setting up the options. class ISetupOptionCallbackClass { public: diff --git a/code/nel/include/nel/gui/lua_manager.h b/code/nel/include/nel/gui/lua_manager.h index 0f1eb3b3b..9044dfcd5 100644 --- a/code/nel/include/nel/gui/lua_manager.h +++ b/code/nel/include/nel/gui/lua_manager.h @@ -23,7 +23,11 @@ namespace NLGUI { class CLuaState; - /// Provides a single global access point to the Lua state, and related stuff. :( + /** + Lua Manager + + Provides a single global access point to the Lua state, and related stuff. :( + */ class CLuaManager { public: @@ -41,12 +45,20 @@ namespace NLGUI /// Enables attaching the Lua debugger in the CLuaState instance, only matters on startup. static void enableLuaDebugging(){ debugLua = true; } + /// Returns the Lua state. NLGUI::CLuaState* getLuaState() const{ return luaState; } + /** + Executes a Lua script + @param luaScript - the script we want to execute ( the actual script, not the filename! ) + @param smallScript - true if the script is very small, so it can be cached for the possible next execution. + */ bool executeLuaScript( const std::string &luaScript, bool smallScript = false ); + /// Resets the Lua state, that is deallocates it and allocates a new one. void ResetLuaState(); + /// Forces the Garbage Collector to run. void forceGarbageCollect(); private: diff --git a/code/nel/include/nel/gui/parser.h b/code/nel/include/nel/gui/parser.h index 5adfd0691..e032928c7 100644 --- a/code/nel/include/nel/gui/parser.h +++ b/code/nel/include/nel/gui/parser.h @@ -31,6 +31,7 @@ namespace NLGUI class CCtrlSheetSelection; class CInterfaceLink; + /// Interface for the GUI XML parser class. class IParser { public: diff --git a/code/nel/include/nel/gui/reflect_register.h b/code/nel/include/nel/gui/reflect_register.h index 0d86cf262..96c1be798 100644 --- a/code/nel/include/nel/gui/reflect_register.h +++ b/code/nel/include/nel/gui/reflect_register.h @@ -20,6 +20,7 @@ namespace NLGUI { + /// Helper class to register reflectable classes class CReflectableRegister { public: diff --git a/code/nel/include/nel/gui/view_renderer.h b/code/nel/include/nel/gui/view_renderer.h index 83b45f79f..effe4fd70 100644 --- a/code/nel/include/nel/gui/view_renderer.h +++ b/code/nel/include/nel/gui/view_renderer.h @@ -580,6 +580,7 @@ namespace NLGUI public: static NL3D::UTextContext* getTextContext(){ return textcontext; } + /// Set of hw cursor images static std::set< std::string > *hwCursors; static float hwCursorScale; diff --git a/code/nel/include/nel/gui/view_text_formated.h b/code/nel/include/nel/gui/view_text_formated.h index dd9d1149a..884923d51 100644 --- a/code/nel/include/nel/gui/view_text_formated.h +++ b/code/nel/include/nel/gui/view_text_formated.h @@ -36,6 +36,7 @@ namespace NLGUI { public: + /// Interface for classes which can format the text for this view. class IViewTextFormatter { public: diff --git a/code/nel/include/nel/gui/view_text_id.h b/code/nel/include/nel/gui/view_text_id.h index fea01f59c..5dd0808af 100644 --- a/code/nel/include/nel/gui/view_text_id.h +++ b/code/nel/include/nel/gui/view_text_id.h @@ -49,7 +49,7 @@ namespace NLGUI { public: - /// Interface for classes that can provide text to CViewTextId + /// Interface for classes which can provide text to CViewTextId class IViewTextProvider { public: diff --git a/code/nel/include/nel/gui/widget_manager.h b/code/nel/include/nel/gui/widget_manager.h index 8410bcc4a..5a29aa804 100644 --- a/code/nel/include/nel/gui/widget_manager.h +++ b/code/nel/include/nel/gui/widget_manager.h @@ -47,11 +47,16 @@ namespace NLGUI class CInterfaceAnim; class CProcedure; - /// Manages the GUI widgets + /** + GUI Widget Manager + + Manages the GUI widgets, asks them to draw themselves, etc. + */ class CWidgetManager{ public: + /// Interface for event handlers that can be called when the screen is resized. class INewScreenSizeHandler { public: @@ -59,6 +64,7 @@ namespace NLGUI virtual void process( uint32 w, uint32 h ) = 0; }; + /// Interface for event handlers that can be called when the widgets finished drawing. class IOnWidgetsDrawnHandler { public: @@ -66,11 +72,15 @@ namespace NLGUI virtual void process() = 0; }; + /// Frame render times struct SInterfaceTimes { public: + /// Time when the last frame was rendered in ms. sint64 lastFrameMs; + /// Time when the current frame was rendered in ms. sint64 thisFrameMs; + /// Difference between the two times in ms. sint64 frameDiffMs; SInterfaceTimes()