1 // Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
2 // Copyright (C) 2010 Winch Gate Property Limited
4 // This source file has been modified by the following contributors:
5 // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) <dfighter1985@gmail.com>
6 // Copyright (C) 2020 Jan BOON (Kaetemi) <jan.boon@kaetemi.be>
8 // This program is free software: you can redistribute it and/or modify
9 // it under the terms of the GNU Affero General Public License as
10 // published by the Free Software Foundation, either version 3 of the
11 // License, or (at your option) any later version.
13 // This program is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 // GNU Affero General Public License for more details.
18 // You should have received a copy of the GNU Affero General Public License
19 // along with this program. If not, see <http://www.gnu.org/licenses/>.
23 #include "nel/gui/view_text_id_formated.h"
24 #include "nel/gui/view_text_formated.h"
25 #include "nel/misc/xml_auto_ptr.h"
26 #include "nel/misc/i18n.h"
32 NLMISC_REGISTER_OBJECT(CViewBase
, CViewTextIDFormated
, std::string
, "text_id_formated");
37 std::string
CViewTextIDFormated::getProperty(const std::string
&name
) const
41 return getFormatString();
44 return CViewTextID::getProperty(name
);
47 void CViewTextIDFormated::setProperty(const std::string
&name
, const std::string
&value
)
51 setFormatString(value
);
55 CViewTextID::setProperty(name
, value
);
58 xmlNodePtr
CViewTextIDFormated::serialize(xmlNodePtr parentNode
, const char *type
) const
60 xmlNodePtr node
= CViewTextID::serialize(parentNode
, type
);
64 xmlSetProp( node
, BAD_CAST
"type", BAD_CAST
"text_id_formated" );
65 xmlSetProp( node
, BAD_CAST
"format", BAD_CAST
getFormatString().c_str() );
70 // *********************************************************************************
71 bool CViewTextIDFormated::parse(xmlNodePtr cur
,CInterfaceGroup
* parentGroup
)
73 if (!CViewTextID::parse(cur
, parentGroup
)) return false;
74 CXMLAutoPtr
prop((const char*) xmlGetProp( cur
, (xmlChar
*)"format" ));
76 setFormatString((const char *)prop
);
78 setFormatString("$t");
82 // *********************************************************************************
83 void CViewTextIDFormated::checkCoords()
87 uint32 newId
= (uint32
)_DBTextId
.getSInt64();
93 std::string result
, formatedResult
;
96 if( CViewTextID::getTextProvider() == NULL
)
101 result
= "Text ID = " + NLMISC::toString(_TextId
);
106 bValid
= CViewTextID::getTextProvider()->getDynString (_TextId
, result
);
108 formatedResult
= CViewTextFormated::formatString(_FormatString
, result
);
110 setText (formatedResult
);
117 CViewText::checkCoords();
120 // ****************************************************************************
121 void CViewTextIDFormated::setFormatString(const std::string
&format
)
123 _Initialized
= false;
124 if (NLMISC::startsWith(format
, "ui"))
125 _FormatString
= NLMISC::CI18N::get(format
);
127 _FormatString
= format
;