From 90a1049934ba64291f406efbe801bca975894f9f Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Thu, 21 Jun 2012 20:31:10 +0200 Subject: [PATCH] CHANGED: #1471 CViewTextIDFormated is now part of the NELGUI library and is under the NLGUI namespace. --HG-- branch : gui-refactoring --- .../include/nel/gui}/view_text_id_formated.h | 31 +++---- code/nel/src/gui/view_text_id_formated.cpp | 88 +++++++++++++++++++ .../dbgroup_list_sheet_mission.cpp | 2 +- .../src/interface_v3/interface_parser.cpp | 2 +- .../interface_v3/view_text_id_formated.cpp | 82 ----------------- 5 files changed, 106 insertions(+), 99 deletions(-) rename code/{ryzom/client/src/interface_v3 => nel/include/nel/gui}/view_text_id_formated.h (74%) create mode 100644 code/nel/src/gui/view_text_id_formated.cpp delete mode 100644 code/ryzom/client/src/interface_v3/view_text_id_formated.cpp diff --git a/code/ryzom/client/src/interface_v3/view_text_id_formated.h b/code/nel/include/nel/gui/view_text_id_formated.h similarity index 74% rename from code/ryzom/client/src/interface_v3/view_text_id_formated.h rename to code/nel/include/nel/gui/view_text_id_formated.h index d066b2acd..11fa19aa3 100644 --- a/code/ryzom/client/src/interface_v3/view_text_id_formated.h +++ b/code/nel/include/nel/gui/view_text_id_formated.h @@ -29,22 +29,23 @@ * $b -> expand the current bot name ( bot with which the player is talking) * $s -> expand the current short bot name (with no specification/title in it) */ -class CViewTextIDFormated : public CViewTextID -{ -public: - CViewTextIDFormated(const TCtorParam ¶m) : CViewTextID(param) - {} - virtual bool parse(xmlNodePtr cur, CInterfaceGroup * parentGroup); - virtual void checkCoords(); - const ucstring &getFormatString() const { return _FormatString; } - void setFormatString(const ucstring &format); -private: - ucstring _FormatString; -}; - - - +namespace NLGUI +{ + class CViewTextIDFormated : public CViewTextID + { + public: + CViewTextIDFormated(const TCtorParam ¶m) : CViewTextID(param) + {} + virtual bool parse(xmlNodePtr cur, CInterfaceGroup * parentGroup); + virtual void checkCoords(); + const ucstring &getFormatString() const { return _FormatString; } + void setFormatString(const ucstring &format); + private: + ucstring _FormatString; + }; + +} #endif diff --git a/code/nel/src/gui/view_text_id_formated.cpp b/code/nel/src/gui/view_text_id_formated.cpp new file mode 100644 index 000000000..991db0344 --- /dev/null +++ b/code/nel/src/gui/view_text_id_formated.cpp @@ -0,0 +1,88 @@ +// 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/view_text_id_formated.h" +#include "nel/gui/view_text_formated.h" +#include "nel/misc/xml_auto_ptr.h" +#include "nel/misc/i18n.h" + +NLMISC_REGISTER_OBJECT(CViewBase, CViewTextIDFormated, std::string, "text_id_formated"); + +namespace NLGUI +{ + + // ********************************************************************************* + bool CViewTextIDFormated::parse(xmlNodePtr cur,CInterfaceGroup * parentGroup) + { + if (!CViewTextID::parse(cur, parentGroup)) return false; + CXMLAutoPtr prop((const char*) xmlGetProp( cur, (xmlChar*)"format" )); + if (prop) + setFormatString(ucstring((const char *) prop)); + else + setFormatString(ucstring("$t")); + return true; + } + + // ********************************************************************************* + void CViewTextIDFormated::checkCoords() + { + if (_IsDBLink) + { + uint32 newId = (uint32)_DBTextId.getSInt64(); + setTextId (newId); + } + + if (!_Initialized) + { + ucstring result, formatedResult; + bool bValid; + + if( CViewTextID::getTextProvider() == NULL ) + { + if(!_DBPath.empty()) + result = ucstring(_DBPath); + else + result = ucstring("Text ID = " + NLMISC::toString(_TextId)); + bValid = true; + } + else + { + bValid = CViewTextID::getTextProvider()->getDynString (_TextId, result); + } + formatedResult = CViewTextFormated::formatString(_FormatString, result); + // + setText (formatedResult); + // + if (bValid) + { + _Initialized = true; + } + } + CViewText::checkCoords(); + } + + // **************************************************************************** + void CViewTextIDFormated::setFormatString(const ucstring &format) + { + _Initialized = false; + _FormatString = format; + if ( (_FormatString.size()>2) && (_FormatString[0] == 'u') && (_FormatString[1] == 'i')) + _FormatString = NLMISC::CI18N::get (format.toString()); + } + +} diff --git a/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_mission.cpp b/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_mission.cpp index fe56bf1d9..ca625340a 100644 --- a/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_mission.cpp +++ b/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_mission.cpp @@ -19,7 +19,7 @@ #include "game_share/mission_desc.h" #include "dbgroup_list_sheet_mission.h" -#include "view_text_id_formated.h" +#include "nel/gui/view_text_id_formated.h" #include "nel/misc/cdb_leaf.h" #include "interface_manager.h" diff --git a/code/ryzom/client/src/interface_v3/interface_parser.cpp b/code/ryzom/client/src/interface_v3/interface_parser.cpp index c53c1b322..15cab1fd9 100644 --- a/code/ryzom/client/src/interface_v3/interface_parser.cpp +++ b/code/ryzom/client/src/interface_v3/interface_parser.cpp @@ -42,7 +42,7 @@ #include "nel/gui/view_text.h" #include "nel/gui/view_text_formated.h" #include "nel/gui/view_text_id.h" -#include "view_text_id_formated.h" +#include "nel/gui/view_text_id_formated.h" #include "view_radar.h" #include "view_pointer.h" // DBView (View linked to the database) diff --git a/code/ryzom/client/src/interface_v3/view_text_id_formated.cpp b/code/ryzom/client/src/interface_v3/view_text_id_formated.cpp deleted file mode 100644 index 24dd2c376..000000000 --- a/code/ryzom/client/src/interface_v3/view_text_id_formated.cpp +++ /dev/null @@ -1,82 +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 "view_text_id_formated.h" -#include "nel/gui/view_text_formated.h" -#include "nel/misc/xml_auto_ptr.h" - -NLMISC_REGISTER_OBJECT(CViewBase, CViewTextIDFormated, std::string, "text_id_formated"); - -// ********************************************************************************* -bool CViewTextIDFormated::parse(xmlNodePtr cur,CInterfaceGroup * parentGroup) -{ - if (!CViewTextID::parse(cur, parentGroup)) return false; - CXMLAutoPtr prop((const char*) xmlGetProp( cur, (xmlChar*)"format" )); - if (prop) - setFormatString(ucstring((const char *) prop)); - else - setFormatString(ucstring("$t")); - return true; -} - -// ********************************************************************************* -void CViewTextIDFormated::checkCoords() -{ - if (_IsDBLink) - { - uint32 newId = (uint32)_DBTextId.getSInt64(); - setTextId (newId); - } - - if (!_Initialized) - { - ucstring result, formatedResult; - bool bValid; - - if( CViewTextID::getTextProvider() == NULL ) - { - if(!_DBPath.empty()) - result = ucstring(_DBPath); - else - result = ucstring("Text ID = " + NLMISC::toString(_TextId)); - bValid = true; - } - else - { - bValid = CViewTextID::getTextProvider()->getDynString (_TextId, result); - } - formatedResult = CViewTextFormated::formatString(_FormatString, result); - // - setText (formatedResult); - // - if (bValid) - { - _Initialized = true; - } - } - CViewText::checkCoords(); -} - -// **************************************************************************** -void CViewTextIDFormated::setFormatString(const ucstring &format) -{ - _Initialized = false; - _FormatString = format; - if ( (_FormatString.size()>2) && (_FormatString[0] == 'u') && (_FormatString[1] == 'i')) - _FormatString = NLMISC::CI18N::get (format.toString()); -}