mirror of
https://port.numenaute.org/aleajactaest/khanat-code-old.git
synced 2024-11-25 16:26:18 +00:00
CHANGED: #1471 CViewTextFormated is now part of NELGUI library, and is under the NLGUI namespace.
This commit is contained in:
parent
86c18351c0
commit
d5b2ee9f71
8 changed files with 145 additions and 136 deletions
67
code/nel/include/nel/gui/view_text_formated.h
Normal file
67
code/nel/include/nel/gui/view_text_formated.h
Normal file
|
@ -0,0 +1,67 @@
|
|||
// 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/>.
|
||||
|
||||
|
||||
|
||||
#ifndef VIEW_TEXT_FORMATED_H
|
||||
#define VIEW_TEXT_FORMATED_H
|
||||
|
||||
#include "nel/gui/view_text.h"
|
||||
|
||||
namespace NLGUI
|
||||
{
|
||||
|
||||
/** 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 $
|
||||
* $p -> expand the player name
|
||||
* $P -> expand the player name in uppercase
|
||||
* $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)
|
||||
* if "ui..." replace the format with CI18N
|
||||
*/
|
||||
class CViewTextFormated : public CViewText
|
||||
{
|
||||
public:
|
||||
|
||||
class IViewTextFormatter
|
||||
{
|
||||
public:
|
||||
virtual ~IViewTextFormatter(){}
|
||||
virtual ucstring formatString( const ucstring &inputString, const ucstring ¶mString ) = 0;
|
||||
};
|
||||
|
||||
CViewTextFormated (const TCtorParam ¶m) : CViewText(param)
|
||||
{}
|
||||
virtual bool parse(xmlNodePtr cur, CInterfaceGroup * parentGroup);
|
||||
virtual void checkCoords();
|
||||
const ucstring &getFormatString() const { return _FormatString; }
|
||||
void setFormatString(const ucstring &format);
|
||||
|
||||
static ucstring formatString(const ucstring &inputString, const ucstring ¶mString);
|
||||
|
||||
static void setFormatter( IViewTextFormatter *formatter ){ textFormatter = formatter; }
|
||||
|
||||
private:
|
||||
ucstring _FormatString;
|
||||
static IViewTextFormatter *textFormatter;
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif
|
74
code/nel/src/gui/view_text_formated.cpp
Normal file
74
code/nel/src/gui/view_text_formated.cpp
Normal file
|
@ -0,0 +1,74 @@
|
|||
// 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_formated.h"
|
||||
#include "nel/misc/xml_auto_ptr.h"
|
||||
#include "nel/misc/i18n.h"
|
||||
|
||||
NLMISC_REGISTER_OBJECT(CViewBase, CViewTextFormated, std::string, "text_formated");
|
||||
|
||||
namespace NLGUI
|
||||
{
|
||||
|
||||
CViewTextFormated::IViewTextFormatter *CViewTextFormated::textFormatter = NULL;
|
||||
|
||||
// ****************************************************************************
|
||||
bool CViewTextFormated::parse(xmlNodePtr cur,CInterfaceGroup * parentGroup)
|
||||
{
|
||||
if (!CViewText::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 CViewTextFormated::checkCoords()
|
||||
{
|
||||
if (!getActive()) return;
|
||||
ucstring formatedResult;
|
||||
formatedResult = formatString(_FormatString, ucstring(""));
|
||||
|
||||
//
|
||||
setText (formatedResult);
|
||||
CViewText::checkCoords();
|
||||
}
|
||||
|
||||
// ****************************************************************************
|
||||
void CViewTextFormated::setFormatString(const ucstring &format)
|
||||
{
|
||||
_FormatString = format;
|
||||
if ( (_FormatString.size()>2) && (_FormatString[0] == 'u') && (_FormatString[1] == 'i'))
|
||||
_FormatString = NLMISC::CI18N::get (format.toString());
|
||||
}
|
||||
|
||||
// ****************************************************************************
|
||||
ucstring CViewTextFormated::formatString(const ucstring &inputString, const ucstring ¶mString)
|
||||
{
|
||||
ucstring formatedResult;
|
||||
|
||||
if( textFormatter == NULL )
|
||||
formatedResult = inputString;
|
||||
else
|
||||
formatedResult = CViewTextFormated::textFormatter->formatString( inputString, paramString );
|
||||
|
||||
return formatedResult;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -27,7 +27,7 @@
|
|||
#include "nel/gui/action_handler.h"
|
||||
#include "../time_client.h"
|
||||
#include "group_editbox.h"
|
||||
#include "view_text_formated.h"
|
||||
#include "nel/gui/view_text_formated.h"
|
||||
#include "nel/gui/view_text_id.h"
|
||||
#include "nel/gui/lua_ihm.h"
|
||||
|
||||
|
|
|
@ -52,7 +52,7 @@
|
|||
#include "view_bitmap_combo.h"
|
||||
#include "nel/gui/view_text.h"
|
||||
#include "nel/gui/view_text_id.h"
|
||||
#include "view_text_formated.h"
|
||||
#include "nel/gui/view_text_formated.h"
|
||||
// Ctrl
|
||||
#include "nel/gui/ctrl_scroll.h"
|
||||
#include "nel/gui/ctrl_button.h"
|
||||
|
|
|
@ -40,7 +40,7 @@
|
|||
#include "view_bitmap_faber_mp.h"
|
||||
#include "view_bitmap_combo.h"
|
||||
#include "nel/gui/view_text.h"
|
||||
#include "view_text_formated.h"
|
||||
#include "nel/gui/view_text_formated.h"
|
||||
#include "nel/gui/view_text_id.h"
|
||||
#include "view_text_id_formated.h"
|
||||
#include "view_radar.h"
|
||||
|
|
|
@ -1,68 +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_formated.h"
|
||||
#include "nel/misc/xml_auto_ptr.h"
|
||||
#include "nel/misc/i18n.h"
|
||||
|
||||
NLMISC_REGISTER_OBJECT(CViewBase, CViewTextFormated, std::string, "text_formated");
|
||||
|
||||
CViewTextFormated::IViewTextFormatter *CViewTextFormated::textFormatter = NULL;
|
||||
|
||||
// ****************************************************************************
|
||||
bool CViewTextFormated::parse(xmlNodePtr cur,CInterfaceGroup * parentGroup)
|
||||
{
|
||||
if (!CViewText::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 CViewTextFormated::checkCoords()
|
||||
{
|
||||
if (!getActive()) return;
|
||||
ucstring formatedResult;
|
||||
formatedResult = formatString(_FormatString, ucstring(""));
|
||||
|
||||
//
|
||||
setText (formatedResult);
|
||||
CViewText::checkCoords();
|
||||
}
|
||||
|
||||
// ****************************************************************************
|
||||
void CViewTextFormated::setFormatString(const ucstring &format)
|
||||
{
|
||||
_FormatString = format;
|
||||
if ( (_FormatString.size()>2) && (_FormatString[0] == 'u') && (_FormatString[1] == 'i'))
|
||||
_FormatString = NLMISC::CI18N::get (format.toString());
|
||||
}
|
||||
|
||||
// ****************************************************************************
|
||||
ucstring CViewTextFormated::formatString(const ucstring &inputString, const ucstring ¶mString)
|
||||
{
|
||||
ucstring formatedResult;
|
||||
|
||||
if( textFormatter == NULL )
|
||||
formatedResult = inputString;
|
||||
else
|
||||
formatedResult = CViewTextFormated::textFormatter->formatString( inputString, paramString );
|
||||
|
||||
return formatedResult;
|
||||
}
|
|
@ -1,64 +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/>.
|
||||
|
||||
|
||||
|
||||
#ifndef VIEW_TEXT_FORMATED_H
|
||||
#define VIEW_TEXT_FORMATED_H
|
||||
|
||||
#include "nel/gui/view_text.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 $
|
||||
* $p -> expand the player name
|
||||
* $P -> expand the player name in uppercase
|
||||
* $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)
|
||||
* if "ui..." replace the format with CI18N
|
||||
*/
|
||||
class CViewTextFormated : public CViewText
|
||||
{
|
||||
public:
|
||||
|
||||
class IViewTextFormatter
|
||||
{
|
||||
public:
|
||||
virtual ~IViewTextFormatter(){}
|
||||
virtual ucstring formatString( const ucstring &inputString, const ucstring ¶mString ) = 0;
|
||||
};
|
||||
|
||||
CViewTextFormated (const TCtorParam ¶m) : CViewText(param)
|
||||
{}
|
||||
virtual bool parse(xmlNodePtr cur, CInterfaceGroup * parentGroup);
|
||||
virtual void checkCoords();
|
||||
const ucstring &getFormatString() const { return _FormatString; }
|
||||
void setFormatString(const ucstring &format);
|
||||
|
||||
static ucstring formatString(const ucstring &inputString, const ucstring ¶mString);
|
||||
|
||||
static void setFormatter( IViewTextFormatter *formatter ){ textFormatter = formatter; }
|
||||
|
||||
private:
|
||||
ucstring _FormatString;
|
||||
static IViewTextFormatter *textFormatter;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
|
@ -18,7 +18,7 @@
|
|||
|
||||
#include "stdpch.h"
|
||||
#include "view_text_id_formated.h"
|
||||
#include "view_text_formated.h"
|
||||
#include "nel/gui/view_text_formated.h"
|
||||
#include "../string_manager_client.h"
|
||||
#include "../user_entity.h"
|
||||
#include "../entities.h"
|
||||
|
|
Loading…
Reference in a new issue