mirror of
https://port.numenaute.org/aleajactaest/khanat-code-old.git
synced 2024-11-30 15:45:58 +00:00
CHANGED: #1471 CViewTextID is now part of the NELGUI library and is under the NLGUI namespace.
This commit is contained in:
parent
b16c0362ef
commit
ed9c2c84ec
19 changed files with 396 additions and 387 deletions
156
code/nel/include/nel/gui/view_text_id.h
Normal file
156
code/nel/include/nel/gui/view_text_id.h
Normal file
|
@ -0,0 +1,156 @@
|
|||
// 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 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 */
|
225
code/nel/src/gui/view_text_id.cpp
Normal file
225
code/nel/src/gui/view_text_id.cpp
Normal file
|
@ -0,0 +1,225 @@
|
|||
// 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/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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -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"
|
||||
|
|
|
@ -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"
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -1,220 +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 "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);
|
||||
}
|
||||
|
|
@ -1,152 +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 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 */
|
|
@ -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 $
|
||||
|
|
|
@ -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"
|
||||
|
|
Loading…
Reference in a new issue