@ -442,6 +442,9 @@ void CGroupHTML::addText (const char * buf, int len)
{
{
if ( _Browsing )
if ( _Browsing )
{
{
if ( _IgnoreText )
return ;
// Build a UTF8 string
// Build a UTF8 string
string inputString ( buf , buf + len ) ;
string inputString ( buf , buf + len ) ;
// inputString.resize (len);
// inputString.resize (len);
@ -525,6 +528,11 @@ void CGroupHTML::addLink (uint element_number, uint /* attribute_number */, HTCh
// in ah: command we don't respect the uri standard so the HTAnchor_address doesn't work correctly
// in ah: command we don't respect the uri standard so the HTAnchor_address doesn't work correctly
_Link . push_back ( suri ) ;
_Link . push_back ( suri ) ;
}
}
else if ( suri [ 0 ] = = ' # ' )
{
// Direct url (hack for lua beginElement)
_Link . push_back ( suri . substr ( 1 ) ) ;
}
else
else
{
{
HTAnchor * dest = HTAnchor_followMainLink ( ( HTAnchor * ) anchor ) ;
HTAnchor * dest = HTAnchor_followMainLink ( ( HTAnchor * ) anchor ) ;
@ -839,6 +847,14 @@ void CGroupHTML::beginElement (uint element_number, const BOOL *present, const c
}
}
}
}
break ;
break ;
case HTML_DIV :
{
if ( present [ MY_HTML_DIV_NAME ] & & value [ MY_HTML_DIV_NAME ] )
{
_DivName = value [ MY_HTML_DIV_NAME ] ;
}
}
break ;
case HTML_FONT :
case HTML_FONT :
{
{
bool found = false ;
bool found = false ;
@ -856,7 +872,7 @@ void CGroupHTML::beginElement (uint element_number, const BOOL *present, const c
_TextColor . push_back ( _TextColor . empty ( ) ? CRGBA : : White : _TextColor . back ( ) ) ;
_TextColor . push_back ( _TextColor . empty ( ) ? CRGBA : : White : _TextColor . back ( ) ) ;
}
}
}
}
break ;
break ;
case HTML_BR :
case HTML_BR :
addString ( ucstring ( " \n " ) ) ;
addString ( ucstring ( " \n " ) ) ;
break ;
break ;
@ -1372,6 +1388,9 @@ void CGroupHTML::beginElement (uint element_number, const BOOL *present, const c
_ObjectAction = value [ HTML_OBJECT_STANDBY ] ;
_ObjectAction = value [ HTML_OBJECT_STANDBY ] ;
_Object = true ;
_Object = true ;
break ;
case HTML_STYLE :
_IgnoreText = true ;
break ;
break ;
}
}
}
}
@ -1409,6 +1428,10 @@ void CGroupHTML::endElement (uint element_number)
case HTML_PRE :
case HTML_PRE :
popIfNotEmpty ( _PRE ) ;
popIfNotEmpty ( _PRE ) ;
break ;
break ;
case HTML_DIV :
_DivName = " " ;
break ;
case HTML_TABLE :
case HTML_TABLE :
popIfNotEmpty ( _CellParams ) ;
popIfNotEmpty ( _CellParams ) ;
popIfNotEmpty ( _TR ) ;
popIfNotEmpty ( _TR ) ;
@ -1493,6 +1516,9 @@ void CGroupHTML::endElement (uint element_number)
popIfNotEmpty ( _UL ) ;
popIfNotEmpty ( _UL ) ;
}
}
break ;
break ;
case HTML_STYLE :
_IgnoreText = false ;
break ;
case HTML_OBJECT :
case HTML_OBJECT :
if ( _ObjectType = = " application/ryzom-data " )
if ( _ObjectType = = " application/ryzom-data " )
{
{
@ -1560,6 +1586,7 @@ CGroupHTML::CGroupHTML(const TCtorParam ¶m)
// init
// init
_ParsingLua = false ;
_ParsingLua = false ;
_IgnoreText = false ;
_BrowseNextTime = false ;
_BrowseNextTime = false ;
_PostNextTime = false ;
_PostNextTime = false ;
_Browsing = false ;
_Browsing = false ;
@ -2506,6 +2533,7 @@ void CGroupHTML::clearContext()
_Cells . clear ( ) ;
_Cells . clear ( ) ;
_TR . clear ( ) ;
_TR . clear ( ) ;
_Forms . clear ( ) ;
_Forms . clear ( ) ;
_Groups . clear ( ) ;
_CellParams . clear ( ) ;
_CellParams . clear ( ) ;
_Title = false ;
_Title = false ;
_TextArea = false ;
_TextArea = false ;
@ -2584,6 +2612,12 @@ void CGroupHTML::addGroup (CInterfaceGroup *group, uint beginSpace)
_Paragraph = NULL ;
_Paragraph = NULL ;
}
}
if ( ! _DivName . empty ( ) )
{
group - > setName ( _DivName ) ;
_Groups . push_back ( group ) ;
}
group - > setSizeRef ( CInterfaceElement : : width ) ;
group - > setSizeRef ( CInterfaceElement : : width ) ;
// Compute begin space between paragraph and tables
// Compute begin space between paragraph and tables
@ -3337,6 +3371,171 @@ int CGroupHTML::luaRefresh(CLuaState &ls)
return 0 ;
return 0 ;
}
}
// ***************************************************************************
int CGroupHTML : : luaRemoveContent ( CLuaState & ls )
{
const char * funcName = " refresh " ;
CLuaIHM : : checkArgCount ( ls , funcName , 0 ) ;
removeContent ( ) ;
return 0 ;
}
// ***************************************************************************
int CGroupHTML : : luaInsertText ( CLuaState & ls )
{
const char * funcName = " insertText " ;
CLuaIHM : : checkArgCount ( ls , funcName , 3 ) ;
CLuaIHM : : checkArgType ( ls , funcName , 1 , LUA_TSTRING ) ;
CLuaIHM : : checkArgType ( ls , funcName , 2 , LUA_TSTRING ) ;
CLuaIHM : : checkArgType ( ls , funcName , 3 , LUA_TBOOLEAN ) ;
string name = ls . toString ( 1 ) ;
ucstring text ;
text . fromUtf8 ( ls . toString ( 2 ) ) ;
if ( ! _Forms . empty ( ) ) {
for ( uint i = 0 ; i < _Forms . back ( ) . Entries . size ( ) ; i + + )
{
if ( _Forms . back ( ) . Entries [ i ] . TextArea & & _Forms . back ( ) . Entries [ i ] . Name = = name )
{
// Get the edit box view
CInterfaceGroup * group = _Forms . back ( ) . Entries [ i ] . TextArea - > getGroup ( " eb " ) ;
if ( group )
{
// Should be a CGroupEditBox
CGroupEditBox * editBox = dynamic_cast < CGroupEditBox * > ( group ) ;
if ( editBox )
editBox - > writeString ( text , false , ls . toBoolean ( 3 ) ) ;
}
}
}
}
return 0 ;
}
// ***************************************************************************
int CGroupHTML : : luaAddString ( CLuaState & ls )
{
const char * funcName = " addString " ;
CLuaIHM : : checkArgCount ( ls , funcName , 1 ) ;
CLuaIHM : : checkArgType ( ls , funcName , 1 , LUA_TSTRING ) ;
addString ( ucstring ( ls . toString ( 1 ) ) ) ;
return 0 ;
}
// ***************************************************************************
int CGroupHTML : : luaAddImage ( CLuaState & ls )
{
const char * funcName = " addImage " ;
CLuaIHM : : checkArgCount ( ls , funcName , 2 ) ;
CLuaIHM : : checkArgType ( ls , funcName , 1 , LUA_TSTRING ) ;
CLuaIHM : : checkArgType ( ls , funcName , 2 , LUA_TBOOLEAN ) ;
if ( ! _Paragraph )
{
newParagraph ( 0 ) ;
paragraphChange ( ) ;
}
string url = getLink ( ) ;
if ( ! url . empty ( ) ) {
string params = " name= " + getId ( ) + " |url= " + getLink ( ) ;
addButton ( CCtrlButton : : PushButton , ls . toString ( 1 ) , ls . toString ( 1 ) , ls . toString ( 1 ) ,
" " , ls . toBoolean ( 2 ) , " browse " , params . c_str ( ) , " " ) ;
} else {
addImage ( ls . toString ( 1 ) , ls . toBoolean ( 2 ) ) ;
}
return 0 ;
}
// ***************************************************************************
int CGroupHTML : : luaBeginElement ( CLuaState & ls )
{
const char * funcName = " beginElement " ;
CLuaIHM : : checkArgCount ( ls , funcName , 2 ) ;
CLuaIHM : : checkArgType ( ls , funcName , 1 , LUA_TNUMBER ) ;
CLuaIHM : : checkArgType ( ls , funcName , 2 , LUA_TTABLE ) ;
uint element_number = ( uint ) ls . toNumber ( 1 ) ;
std : : vector < BOOL > present ;
std : : vector < const char * > value ;
present . resize ( 30 , false ) ;
value . resize ( 30 ) ;
CLuaObject params ;
params . pop ( ls ) ;
uint max_idx = 0 ;
ENUM_LUA_TABLE ( params , it )
{
if ( ! it . nextKey ( ) . isNumber ( ) )
{
nlwarning ( " %s : bad key encountered with type %s, number expected. " , funcName , it . nextKey ( ) . getTypename ( ) ) ;
continue ;
}
if ( ! it . nextValue ( ) . isString ( ) )
{
nlwarning ( " %s : bad value encountered with type %s for key %s, string expected. " , funcName , it . nextValue ( ) . getTypename ( ) , it . nextKey ( ) . toString ( ) . c_str ( ) ) ;
continue ;
}
uint idx = ( uint ) it . nextKey ( ) . toNumber ( ) ;
present . insert ( present . begin ( ) + ( uint ) it . nextKey ( ) . toNumber ( ) , true ) ;
string str = it . nextValue ( ) . toString ( ) ;
size_t size = str . size ( ) + 1 ;
char * buffer = new char [ size ] ;
strncpy ( buffer , str . c_str ( ) , size ) ;
value . insert ( value . begin ( ) + ( uint ) it . nextKey ( ) . toNumber ( ) , buffer ) ;
}
beginElement ( element_number , & present [ 0 ] , & value [ 0 ] ) ;
if ( element_number = = HTML_A )
addLink ( element_number , 0 , NULL , & present [ 0 ] , & value [ 0 ] ) ;
return 0 ;
}
// ***************************************************************************
int CGroupHTML : : luaEndElement ( CLuaState & ls )
{
const char * funcName = " endElement " ;
CLuaIHM : : checkArgCount ( ls , funcName , 1 ) ;
CLuaIHM : : checkArgType ( ls , funcName , 1 , LUA_TNUMBER ) ;
uint element_number = ( uint ) ls . toNumber ( 1 ) ;
endElement ( element_number ) ;
return 0 ;
}
// ***************************************************************************
int CGroupHTML : : luaShowDiv ( CLuaState & ls )
{
const char * funcName = " showDiv " ;
CLuaIHM : : checkArgCount ( ls , funcName , 2 ) ;
CLuaIHM : : checkArgType ( ls , funcName , 1 , LUA_TSTRING ) ;
CLuaIHM : : checkArgType ( ls , funcName , 2 , LUA_TBOOLEAN ) ;
if ( ! _Groups . empty ( ) ) {
for ( uint i = 0 ; i < _Groups . size ( ) ; i + + )
{
CInterfaceGroup * group = _Groups [ i ] ;
if ( group - > getName ( ) = = ls . toString ( 1 ) )
{
group - > setActive ( ls . toBoolean ( 2 ) ) ;
}
}
}
return 0 ;
}
// ***************************************************************************
// ***************************************************************************
void CGroupHTML : : setURL ( const std : : string & url )
void CGroupHTML : : setURL ( const std : : string & url )
{
{