From d257a3e8963d7630d20b8c86d0e1580ecee8e1a9 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Thu, 21 Jun 2012 07:18:25 +0200 Subject: [PATCH] CHANGED: #1471 CViewTextID is now part of the NELGUI library and is under the NLGUI namespace. --HG-- branch : gui-refactoring --- code/nel/include/nel/gui/view_text_id.h | 156 ++++++++++++ code/nel/src/gui/view_text_id.cpp | 225 ++++++++++++++++++ .../src/interface_v3/action_handler_help.cpp | 2 +- .../src/interface_v3/bot_chat_manager.cpp | 2 +- .../interface_v3/bot_chat_page_mission.cpp | 2 +- .../src/interface_v3/ctrl_text_button.cpp | 2 +- .../src/interface_v3/encyclopedia_manager.cpp | 2 +- .../src/interface_v3/group_container.cpp | 2 +- .../interface_v3/group_in_scene_bubble.cpp | 2 +- .../client/src/interface_v3/group_list.cpp | 2 +- .../src/interface_v3/group_paragraph.cpp | 2 +- .../client/src/interface_v3/group_table.cpp | 2 +- .../src/interface_v3/interface_manager.cpp | 2 +- .../src/interface_v3/interface_parser.cpp | 2 +- .../register_interface_elements.cpp | 2 +- .../client/src/interface_v3/view_text_id.cpp | 220 ----------------- .../client/src/interface_v3/view_text_id.h | 152 ------------ .../src/interface_v3/view_text_id_formated.h | 2 +- code/ryzom/client/src/net_manager.cpp | 2 +- 19 files changed, 396 insertions(+), 387 deletions(-) create mode 100644 code/nel/include/nel/gui/view_text_id.h create mode 100644 code/nel/src/gui/view_text_id.cpp delete mode 100644 code/ryzom/client/src/interface_v3/view_text_id.cpp delete mode 100644 code/ryzom/client/src/interface_v3/view_text_id.h diff --git a/code/nel/include/nel/gui/view_text_id.h b/code/nel/include/nel/gui/view_text_id.h new file mode 100644 index 000000000..e293f0d4c --- /dev/null +++ b/code/nel/include/nel/gui/view_text_id.h @@ -0,0 +1,156 @@ +// Ryzom - MMORPG Framework +// Copyright (C) 2010 Winch Gate Property Limited +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + + + +#ifndef NL_VIEW_TEXT_ID_H +#define NL_VIEW_TEXT_ID_H + +#include "nel/misc/types_nl.h" +#include "nel/gui/view_text.h" + +namespace NLMISC{ + class CCDBNodeLeaf; +} + +namespace NLGUI +{ + + // *************************************************************************** + class IOnReceiveTextId + { + public: + virtual ~IOnReceiveTextId() {} + // the deriver may change the input text + virtual void onReceiveTextId(ucstring &str) =0; + }; + + // *************************************************************************** + /** + * class implementing a text view that take the text from an id + * \author Matthieu 'TrapII' Besson + * \author Nevrax France + * \date 2002 + */ + 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) + { + _StringModifier= NULL; + _IsDBLink = false; + _TextId = 0xFFFFFFFF; + _Initialized = false; + _DynamicString = false; + _IsTextFormatTaged= false; + } + + // ctor with a text id + CViewTextID (const std::string& id, uint32 nID, sint FontSize=12, + NLMISC::CRGBA Color=NLMISC::CRGBA(255,255,255), bool Shadow=false) : + CViewText (id, std::string(""), FontSize, Color, Shadow) + { + _StringModifier= NULL; + _IsDBLink = false; + _TextId = nID; + _Initialized = false; + _DynamicString = false; + _IsTextFormatTaged= false; + } + + // ctor with a db path entry + CViewTextID (const std::string& id, + const std::string &idDBPath, + sint FontSize=12, + NLMISC::CRGBA Color=NLMISC::CRGBA(255,255,255), + bool Shadow=false); + + + ~CViewTextID(); + + virtual bool parse(xmlNodePtr cur, CInterfaceGroup * parentGroup); + virtual void checkCoords(); + + bool parseTextIdOptions(xmlNodePtr cur); + + uint32 getTextId () const; + void setTextId (uint32 id); + + /** set a text id from a db path + * \return true if the link could be done + */ + bool setDBTextID(const std::string &dbPath); + // set a text from a db leaf + void setDBLeaf(NLMISC::CCDBNodeLeaf *leaf); + + std::string getTextIdDbLink() const; + void setTextIdDbLink(const std::string &link); + + void setDynamicString(bool state) {_DynamicString= state;} + bool getDynamicString() const {return _DynamicString;} + + // modify name when received + void setOnReceiveTextId(IOnReceiveTextId *callBack) {_StringModifier= callBack;} + IOnReceiveTextId *getOnReceiveTextId() const {return _StringModifier;} + + REFLECT_EXPORT_START(CViewTextID, CViewText) + REFLECT_UINT32("textid", getTextId, setTextId); + REFLECT_STRING("textid_dblink", getTextIdDbLink, setTextIdDbLink); + REFLECT_EXPORT_END + + static void setTextProvider( IViewTextProvider *provider ){ textProvider = provider; } + + protected: + + bool _IsDBLink; + CInterfaceProperty _DBTextId; + uint32 _TextId; + + bool _Initialized; + + // If true, use a dynamic string (CStringManagerClient::getDynString), else use a server string id (CStringManagerClient::getString) + bool _DynamicString; + + // If true, setTextFormatted() is used instead of setText() + bool _IsTextFormatTaged; + + // Optional ucstring modifier + IOnReceiveTextId *_StringModifier; + + #if defined(NL_DEBUG) + std::string _DBPath; + #endif + + private: + static IViewTextProvider *textProvider; + + }; + +} + +#endif // NL_VIEW_TEXT_ID_H + +/* End of view_text_id.h */ diff --git a/code/nel/src/gui/view_text_id.cpp b/code/nel/src/gui/view_text_id.cpp new file mode 100644 index 000000000..e487051a3 --- /dev/null +++ b/code/nel/src/gui/view_text_id.cpp @@ -0,0 +1,225 @@ +// Ryzom - MMORPG Framework +// Copyright (C) 2010 Winch Gate Property Limited +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +#include "nel/gui/db_manager.h" +#include "nel/gui/view_text_id.h" +#include "nel/misc/xml_auto_ptr.h" +#include "nel/misc/algo.h" + +using namespace std; +using NLMISC::CCDBNodeLeaf; + +NLMISC_REGISTER_OBJECT(CViewBase, CViewTextID, std::string, "text_id"); + +namespace NLGUI +{ + + 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) + { + _StringModifier= NULL; + _IsDBLink = true; + _DBTextId.link(id.c_str()); + _Initialized = false; + _DynamicString = true; + _IsTextFormatTaged= false; + } + + // *************************************************************************** + CViewTextID::~CViewTextID() + { + } + + // *************************************************************************** + bool CViewTextID::parse(xmlNodePtr cur, CInterfaceGroup * parentGroup) + { + if (!CViewText::parse(cur, parentGroup)) + return false; + + if(!parseTextIdOptions(cur)) + return false; + + return true; + } + + // *************************************************************************** + bool CViewTextID::parseTextIdOptions(xmlNodePtr cur) + { + _Initialized = false; + + CXMLAutoPtr prop((const char*) xmlGetProp( cur, (xmlChar*)"textid" )); + _IsDBLink = false; + _TextId = 0xFFFFFFFF; + if (prop) + { + if ( isdigit(*prop.getDatas()) || *(prop.getDatas())=='-') + { + NLMISC::fromString((const char*)prop, _TextId); + } + else + { + if (_DBTextId.link(prop)) + { + _TextId = (uint32)_DBTextId.getSInt64(); + _IsDBLink = true; + } + else + { + return false; + } + } + } + + prop= (char*) xmlGetProp( cur, (xmlChar*)"dynamic_string" ); + _DynamicString = true; + if (prop) + _DynamicString = convertBool(prop); + + // format_taged + prop= (char*) xmlGetProp( cur, (xmlChar*)"format_taged" ); + _IsTextFormatTaged= false; + if(prop) + _IsTextFormatTaged= convertBool(prop); + + return true; + } + + // *************************************************************************** + void CViewTextID::checkCoords() + { + if (_IsDBLink) + { + uint32 newId = (uint32)_DBTextId.getSInt64(); + setTextId (newId); + } + + if (!_Initialized) + { + // String result + ucstring result; + + if( textProvider != NULL ) + { + // Get the string + if( _DynamicString ) + _Initialized = textProvider->getDynString( _TextId, result ); + else + _Initialized = textProvider->getString( _TextId, result ); + } + + // Remove all {break} + for(;;) + { + ucstring::size_type index = result.find (ucstring("{break}")); + if (index == ucstring::npos) break; + result = result.substr (0, index) + result.substr(index+7, result.size()); + } + + + // Remove all {ros_exit} + while(NLMISC::strFindReplace(result, "{ros_exit}", "")); + + // Modify the text? + if(_StringModifier) + _StringModifier->onReceiveTextId(result); + + // Set the Text + if(_IsTextFormatTaged) + setTextFormatTaged(result); + else + setText (result); + } + CViewText::checkCoords(); + } + + // *************************************************************************** + uint32 CViewTextID::getTextId () const + { + return _TextId; + } + + // *************************************************************************** + void CViewTextID::setTextId (uint32 newId) + { + if (newId != _TextId) + _Initialized = false; + _TextId = newId; + if (_IsDBLink) + _DBTextId.setSInt64(_TextId); + } + + // *************************************************************************** + bool CViewTextID::setDBTextID(const std::string &dbPath) + { + if (_DBTextId.link(dbPath.c_str())) + { + _TextId = (uint32)_DBTextId.getSInt64(); + _IsDBLink = true; + _Initialized = false; + #ifdef NL_DEBUG + _DBPath =dbPath; + #endif + return true; + } + else + { + _IsDBLink = false; + _Initialized = false; + #ifdef NL_DEBUG + _DBPath="Bad db path : " + dbPath; + #endif + return false; + } + } + + // *************************************************************************** + void CViewTextID::setDBLeaf(CCDBNodeLeaf *leaf) + { + if (!leaf) + { + _IsDBLink = false; + _TextId = 0; + return; + } + _IsDBLink = true; + _DBTextId.setNodePtr(leaf); + } + + // *************************************************************************** + string CViewTextID::getTextIdDbLink() const + { + if (!_IsDBLink) return ""; + if (_DBTextId.getNodePtr() == NULL) return ""; + return _DBTextId.getNodePtr()->getFullName(); + } + + // *************************************************************************** + void CViewTextID::setTextIdDbLink(const string &link) + { + CCDBNodeLeaf *pNL = NLGUI::CDBManager::getInstance()->getDbProp(link,false); + if (pNL == NULL) + { + nlwarning("cant set textidlink for %s",link.c_str()); + return; + } + setDBLeaf(pNL); + } + +} + diff --git a/code/ryzom/client/src/interface_v3/action_handler_help.cpp b/code/ryzom/client/src/interface_v3/action_handler_help.cpp index 04bc833e7..4e12abb10 100644 --- a/code/ryzom/client/src/interface_v3/action_handler_help.cpp +++ b/code/ryzom/client/src/interface_v3/action_handler_help.cpp @@ -29,7 +29,7 @@ #include "group_container.h" #include "group_editbox.h" #include "group_quick_help.h" -#include "view_text_id.h" +#include "nel/gui/view_text_id.h" #include "../user_entity.h" #include "../entities.h" #include "dbgroup_combo_box.h" diff --git a/code/ryzom/client/src/interface_v3/bot_chat_manager.cpp b/code/ryzom/client/src/interface_v3/bot_chat_manager.cpp index 9e96fb602..a315005dd 100644 --- a/code/ryzom/client/src/interface_v3/bot_chat_manager.cpp +++ b/code/ryzom/client/src/interface_v3/bot_chat_manager.cpp @@ -23,7 +23,7 @@ #include "nel/gui/action_handler.h" #include "../user_entity.h" #include "interface_manager.h" -#include "view_text_id.h" +#include "nel/gui/view_text_id.h" #include "nel/gui/interface_group.h" #include "game_share/prerequisit_infos.h" diff --git a/code/ryzom/client/src/interface_v3/bot_chat_page_mission.cpp b/code/ryzom/client/src/interface_v3/bot_chat_page_mission.cpp index 6a8f75e8c..4897defa3 100644 --- a/code/ryzom/client/src/interface_v3/bot_chat_page_mission.cpp +++ b/code/ryzom/client/src/interface_v3/bot_chat_page_mission.cpp @@ -26,7 +26,7 @@ #include "nel/gui/action_handler.h" #include "group_container.h" #include "dbctrl_sheet.h" -#include "view_text_id.h" +#include "nel/gui/view_text_id.h" #include "../net_manager.h" using namespace std; diff --git a/code/ryzom/client/src/interface_v3/ctrl_text_button.cpp b/code/ryzom/client/src/interface_v3/ctrl_text_button.cpp index 62a82831b..bdba8c1f0 100644 --- a/code/ryzom/client/src/interface_v3/ctrl_text_button.cpp +++ b/code/ryzom/client/src/interface_v3/ctrl_text_button.cpp @@ -24,7 +24,7 @@ #include "interface_manager.h" #include "nel/misc/xml_auto_ptr.h" #include "nel/gui/view_text.h" -#include "view_text_id.h" +#include "nel/gui/view_text_id.h" #include "group_container.h" #include "nel/gui/lua_ihm.h" #include "lua_ihm_ryzom.h" diff --git a/code/ryzom/client/src/interface_v3/encyclopedia_manager.cpp b/code/ryzom/client/src/interface_v3/encyclopedia_manager.cpp index 8bdac6a34..d6d6bf44e 100644 --- a/code/ryzom/client/src/interface_v3/encyclopedia_manager.cpp +++ b/code/ryzom/client/src/interface_v3/encyclopedia_manager.cpp @@ -20,7 +20,7 @@ #include "encyclopedia_manager.h" #include "interface_manager.h" #include "group_tree.h" -#include "view_text_id.h" +#include "nel/gui/view_text_id.h" #include "view_bitmap.h" #include "action_handler_misc.h" #include "../sheet_manager.h" diff --git a/code/ryzom/client/src/interface_v3/group_container.cpp b/code/ryzom/client/src/interface_v3/group_container.cpp index c1efb9c0d..afd611854 100644 --- a/code/ryzom/client/src/interface_v3/group_container.cpp +++ b/code/ryzom/client/src/interface_v3/group_container.cpp @@ -28,7 +28,7 @@ #include "../time_client.h" #include "group_editbox.h" #include "view_text_formated.h" -#include "view_text_id.h" +#include "nel/gui/view_text_id.h" #include "nel/gui/lua_ihm.h" #include "group_list.h" diff --git a/code/ryzom/client/src/interface_v3/group_in_scene_bubble.cpp b/code/ryzom/client/src/interface_v3/group_in_scene_bubble.cpp index 603c7f5e5..97777043d 100644 --- a/code/ryzom/client/src/interface_v3/group_in_scene_bubble.cpp +++ b/code/ryzom/client/src/interface_v3/group_in_scene_bubble.cpp @@ -30,7 +30,7 @@ #include "../main_loop.h" #include "../bg_downloader_access.h" -#include "view_text_id.h" +#include "nel/gui/view_text_id.h" using namespace std; using namespace NLMISC; diff --git a/code/ryzom/client/src/interface_v3/group_list.cpp b/code/ryzom/client/src/interface_v3/group_list.cpp index 64fe82706..9315d9024 100644 --- a/code/ryzom/client/src/interface_v3/group_list.cpp +++ b/code/ryzom/client/src/interface_v3/group_list.cpp @@ -23,7 +23,7 @@ #include "nel/gui/interface_element.h" #include "../client_chat_manager.h" #include "view_bitmap.h" -#include "view_text_id.h" +#include "nel/gui/view_text_id.h" #include "group_container.h" #include "nel/gui/lua_ihm.h" #include "lua_ihm_ryzom.h" diff --git a/code/ryzom/client/src/interface_v3/group_paragraph.cpp b/code/ryzom/client/src/interface_v3/group_paragraph.cpp index 2ac417734..b3d915235 100644 --- a/code/ryzom/client/src/interface_v3/group_paragraph.cpp +++ b/code/ryzom/client/src/interface_v3/group_paragraph.cpp @@ -24,7 +24,7 @@ #include "nel/gui/interface_element.h" #include "../client_chat_manager.h" #include "view_bitmap.h" -#include "view_text_id.h" +#include "nel/gui/view_text_id.h" #include "group_container.h" #include "nel/misc/i_xml.h" diff --git a/code/ryzom/client/src/interface_v3/group_table.cpp b/code/ryzom/client/src/interface_v3/group_table.cpp index 09d3b9283..0b4bb5cd1 100644 --- a/code/ryzom/client/src/interface_v3/group_table.cpp +++ b/code/ryzom/client/src/interface_v3/group_table.cpp @@ -23,7 +23,7 @@ #include "nel/gui/interface_element.h" #include "../client_chat_manager.h" #include "view_bitmap.h" -#include "view_text_id.h" +#include "nel/gui/view_text_id.h" #include "group_container.h" #include "nel/misc/i_xml.h" diff --git a/code/ryzom/client/src/interface_v3/interface_manager.cpp b/code/ryzom/client/src/interface_v3/interface_manager.cpp index 48d846795..0219aa87c 100644 --- a/code/ryzom/client/src/interface_v3/interface_manager.cpp +++ b/code/ryzom/client/src/interface_v3/interface_manager.cpp @@ -50,7 +50,7 @@ #include "view_bitmap_faber_mp.h" #include "view_bitmap_combo.h" #include "nel/gui/view_text.h" -#include "view_text_id.h" +#include "nel/gui/view_text_id.h" // Ctrl #include "nel/gui/ctrl_scroll.h" #include "nel/gui/ctrl_button.h" diff --git a/code/ryzom/client/src/interface_v3/interface_parser.cpp b/code/ryzom/client/src/interface_v3/interface_parser.cpp index cec1aeac6..7188c9671 100644 --- a/code/ryzom/client/src/interface_v3/interface_parser.cpp +++ b/code/ryzom/client/src/interface_v3/interface_parser.cpp @@ -41,7 +41,7 @@ #include "view_bitmap_combo.h" #include "nel/gui/view_text.h" #include "view_text_formated.h" -#include "view_text_id.h" +#include "nel/gui/view_text_id.h" #include "view_text_id_formated.h" #include "view_radar.h" #include "view_pointer.h" diff --git a/code/ryzom/client/src/interface_v3/register_interface_elements.cpp b/code/ryzom/client/src/interface_v3/register_interface_elements.cpp index 299ff3f4b..51bbc1ae6 100644 --- a/code/ryzom/client/src/interface_v3/register_interface_elements.cpp +++ b/code/ryzom/client/src/interface_v3/register_interface_elements.cpp @@ -21,7 +21,7 @@ #include "interface_3d_scene.h" #include "nel/gui/view_base.h" #include "nel/gui/view_text.h" -#include "view_text_id.h" +#include "nel/gui/view_text_id.h" #include "view_bitmap.h" #include "view_radar.h" #include "nel/gui/group_submenu_base.h" diff --git a/code/ryzom/client/src/interface_v3/view_text_id.cpp b/code/ryzom/client/src/interface_v3/view_text_id.cpp deleted file mode 100644 index fd37dc6bb..000000000 --- a/code/ryzom/client/src/interface_v3/view_text_id.cpp +++ /dev/null @@ -1,220 +0,0 @@ -// Ryzom - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -#include "nel/gui/db_manager.h" -#include "view_text_id.h" -#include "nel/misc/xml_auto_ptr.h" -#include "nel/misc/algo.h" - -using namespace std; -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) -{ - _StringModifier= NULL; - _IsDBLink = true; - _DBTextId.link(id.c_str()); - _Initialized = false; - _DynamicString = true; - _IsTextFormatTaged= false; -} - -// *************************************************************************** -CViewTextID::~CViewTextID() -{ -} - -// *************************************************************************** -bool CViewTextID::parse(xmlNodePtr cur, CInterfaceGroup * parentGroup) -{ - if (!CViewText::parse(cur, parentGroup)) - return false; - - if(!parseTextIdOptions(cur)) - return false; - - return true; -} - -// *************************************************************************** -bool CViewTextID::parseTextIdOptions(xmlNodePtr cur) -{ - _Initialized = false; - - CXMLAutoPtr prop((const char*) xmlGetProp( cur, (xmlChar*)"textid" )); - _IsDBLink = false; - _TextId = 0xFFFFFFFF; - if (prop) - { - if ( isdigit(*prop.getDatas()) || *(prop.getDatas())=='-') - { - NLMISC::fromString((const char*)prop, _TextId); - } - else - { - if (_DBTextId.link(prop)) - { - _TextId = (uint32)_DBTextId.getSInt64(); - _IsDBLink = true; - } - else - { - return false; - } - } - } - - prop= (char*) xmlGetProp( cur, (xmlChar*)"dynamic_string" ); - _DynamicString = true; - if (prop) - _DynamicString = convertBool(prop); - - // format_taged - prop= (char*) xmlGetProp( cur, (xmlChar*)"format_taged" ); - _IsTextFormatTaged= false; - if(prop) - _IsTextFormatTaged= convertBool(prop); - - return true; -} - -// *************************************************************************** -void CViewTextID::checkCoords() -{ - if (_IsDBLink) - { - uint32 newId = (uint32)_DBTextId.getSInt64(); - setTextId (newId); - } - - if (!_Initialized) - { - // String result - ucstring result; - - if( textProvider != NULL ) - { - // Get the string - if( _DynamicString ) - _Initialized = textProvider->getDynString( _TextId, result ); - else - _Initialized = textProvider->getString( _TextId, result ); - } - - // Remove all {break} - for(;;) - { - ucstring::size_type index = result.find (ucstring("{break}")); - if (index == ucstring::npos) break; - result = result.substr (0, index) + result.substr(index+7, result.size()); - } - - - // Remove all {ros_exit} - while(NLMISC::strFindReplace(result, "{ros_exit}", "")); - - // Modify the text? - if(_StringModifier) - _StringModifier->onReceiveTextId(result); - - // Set the Text - if(_IsTextFormatTaged) - setTextFormatTaged(result); - else - setText (result); - } - CViewText::checkCoords(); -} - -// *************************************************************************** -uint32 CViewTextID::getTextId () const -{ - return _TextId; -} - -// *************************************************************************** -void CViewTextID::setTextId (uint32 newId) -{ - if (newId != _TextId) - _Initialized = false; - _TextId = newId; - if (_IsDBLink) - _DBTextId.setSInt64(_TextId); -} - -// *************************************************************************** -bool CViewTextID::setDBTextID(const std::string &dbPath) -{ - if (_DBTextId.link(dbPath.c_str())) - { - _TextId = (uint32)_DBTextId.getSInt64(); - _IsDBLink = true; - _Initialized = false; - #ifdef NL_DEBUG - _DBPath =dbPath; - #endif - return true; - } - else - { - _IsDBLink = false; - _Initialized = false; - #ifdef NL_DEBUG - _DBPath="Bad db path : " + dbPath; - #endif - return false; - } -} - -// *************************************************************************** -void CViewTextID::setDBLeaf(CCDBNodeLeaf *leaf) -{ - if (!leaf) - { - _IsDBLink = false; - _TextId = 0; - return; - } - _IsDBLink = true; - _DBTextId.setNodePtr(leaf); -} - -// *************************************************************************** -string CViewTextID::getTextIdDbLink() const -{ - if (!_IsDBLink) return ""; - if (_DBTextId.getNodePtr() == NULL) return ""; - return _DBTextId.getNodePtr()->getFullName(); -} - -// *************************************************************************** -void CViewTextID::setTextIdDbLink(const string &link) -{ - CCDBNodeLeaf *pNL = NLGUI::CDBManager::getInstance()->getDbProp(link,false); - if (pNL == NULL) - { - nlwarning("cant set textidlink for %s",link.c_str()); - return; - } - setDBLeaf(pNL); -} - diff --git a/code/ryzom/client/src/interface_v3/view_text_id.h b/code/ryzom/client/src/interface_v3/view_text_id.h deleted file mode 100644 index 4335846df..000000000 --- a/code/ryzom/client/src/interface_v3/view_text_id.h +++ /dev/null @@ -1,152 +0,0 @@ -// Ryzom - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - - - -#ifndef NL_VIEW_TEXT_ID_H -#define NL_VIEW_TEXT_ID_H - -#include "nel/misc/types_nl.h" -#include "nel/gui/view_text.h" - -namespace NLMISC{ - class CCDBNodeLeaf; -} - -// *************************************************************************** -class IOnReceiveTextId -{ -public: - virtual ~IOnReceiveTextId() {} - // the deriver may change the input text - virtual void onReceiveTextId(ucstring &str) =0; -}; - -// *************************************************************************** -/** - * class implementing a text view that take the text from an id - * \author Matthieu 'TrapII' Besson - * \author Nevrax France - * \date 2002 - */ -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) - { - _StringModifier= NULL; - _IsDBLink = false; - _TextId = 0xFFFFFFFF; - _Initialized = false; - _DynamicString = false; - _IsTextFormatTaged= false; - } - - // ctor with a text id - CViewTextID (const std::string& id, uint32 nID, sint FontSize=12, - NLMISC::CRGBA Color=NLMISC::CRGBA(255,255,255), bool Shadow=false) : - CViewText (id, std::string(""), FontSize, Color, Shadow) - { - _StringModifier= NULL; - _IsDBLink = false; - _TextId = nID; - _Initialized = false; - _DynamicString = false; - _IsTextFormatTaged= false; - } - - // ctor with a db path entry - CViewTextID (const std::string& id, - const std::string &idDBPath, - sint FontSize=12, - NLMISC::CRGBA Color=NLMISC::CRGBA(255,255,255), - bool Shadow=false); - - - ~CViewTextID(); - - virtual bool parse(xmlNodePtr cur, CInterfaceGroup * parentGroup); - virtual void checkCoords(); - - bool parseTextIdOptions(xmlNodePtr cur); - - uint32 getTextId () const; - void setTextId (uint32 id); - - /** set a text id from a db path - * \return true if the link could be done - */ - bool setDBTextID(const std::string &dbPath); - // set a text from a db leaf - void setDBLeaf(NLMISC::CCDBNodeLeaf *leaf); - - std::string getTextIdDbLink() const; - void setTextIdDbLink(const std::string &link); - - void setDynamicString(bool state) {_DynamicString= state;} - bool getDynamicString() const {return _DynamicString;} - - // modify name when received - void setOnReceiveTextId(IOnReceiveTextId *callBack) {_StringModifier= callBack;} - IOnReceiveTextId *getOnReceiveTextId() const {return _StringModifier;} - - REFLECT_EXPORT_START(CViewTextID, CViewText) - REFLECT_UINT32("textid", getTextId, setTextId); - REFLECT_STRING("textid_dblink", getTextIdDbLink, setTextIdDbLink); - REFLECT_EXPORT_END - - static void setTextProvider( IViewTextProvider *provider ){ textProvider = provider; } - -protected: - - bool _IsDBLink; - CInterfaceProperty _DBTextId; - uint32 _TextId; - - bool _Initialized; - - // If true, use a dynamic string (CStringManagerClient::getDynString), else use a server string id (CStringManagerClient::getString) - bool _DynamicString; - - // If true, setTextFormatted() is used instead of setText() - bool _IsTextFormatTaged; - - // Optional ucstring modifier - IOnReceiveTextId *_StringModifier; - - #if defined(NL_DEBUG) - std::string _DBPath; - #endif - -private: - static IViewTextProvider *textProvider; - -}; - - -#endif // NL_VIEW_TEXT_ID_H - -/* End of view_text_id.h */ diff --git a/code/ryzom/client/src/interface_v3/view_text_id_formated.h b/code/ryzom/client/src/interface_v3/view_text_id_formated.h index c2dec1dbf..d066b2acd 100644 --- a/code/ryzom/client/src/interface_v3/view_text_id_formated.h +++ b/code/ryzom/client/src/interface_v3/view_text_id_formated.h @@ -19,7 +19,7 @@ #ifndef VIEW_TEXT_ID_FORMATED_H #define VIEW_TEXT_ID_FORMATED_H -#include "view_text_id.h" +#include "nel/gui/view_text_id.h" /** The same as a view text id, but with some display option * The input is a formated string, every character is copied, but subsitution is done for each character preceded by $ diff --git a/code/ryzom/client/src/net_manager.cpp b/code/ryzom/client/src/net_manager.cpp index f4683d72e..5c1929acd 100644 --- a/code/ryzom/client/src/net_manager.cpp +++ b/code/ryzom/client/src/net_manager.cpp @@ -57,7 +57,7 @@ #include "interface_v3/people_interraction.h" #include "interface_v3/bot_chat_manager.h" #include "interface_v3/bot_chat_page_all.h" -#include "interface_v3/view_text_id.h" +#include "nel/gui/view_text_id.h" #include "interface_v3/ctrl_text_button.h" #include "interface_v3/input_handler_manager.h" #include "interface_v3/guild_manager.h"