CHANGED: #1471 CViewTextIDFormated is now part of the NELGUI library and is under the NLGUI namespace.

This commit is contained in:
dfighter1985 2012-06-21 20:31:10 +02:00
parent 842d1cf70a
commit 4de283c561
5 changed files with 105 additions and 98 deletions

View file

@ -29,6 +29,10 @@
* $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)
*/
namespace NLGUI
{
class CViewTextIDFormated : public CViewTextID
{
public:
@ -42,9 +46,6 @@ private:
ucstring _FormatString;
};
}
#endif

View file

@ -0,0 +1,88 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#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());
}
}

View file

@ -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"

View file

@ -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)

View file

@ -1,82 +0,0 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#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());
}