2012-11-26 18:58:24 +00:00
/*
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
Doom 3 BFG Edition GPL Source Code
2012-11-28 15:47:07 +00:00
Copyright ( C ) 1993 - 2012 id Software LLC , a ZeniMax Media company .
2012-11-26 18:58:24 +00:00
2012-11-28 15:47:07 +00:00
This file is part of the Doom 3 BFG Edition GPL Source Code ( " Doom 3 BFG Edition Source Code " ) .
2012-11-26 18:58:24 +00:00
Doom 3 BFG Edition Source Code is free software : you can redistribute it and / or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation , either version 3 of the License , or
( at your option ) any later version .
Doom 3 BFG Edition Source Code 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 General Public License for more details .
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code . If not , see < http : //www.gnu.org/licenses/>.
In addition , the Doom 3 BFG Edition Source Code is also subject to certain additional terms . You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code . If not , please request a copy in writing from id Software at the address below .
If you have questions concerning this license or the applicable additional terms , you may contact in writing id Software LLC , c / o ZeniMax Media Inc . , Suite 120 , Rockville , Maryland 20850 USA .
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
*/
# pragma hdrstop
2012-12-22 15:18:19 +00:00
# include "precompiled.h"
2012-11-26 18:58:24 +00:00
# include "../renderer/Font.h"
idSWFScriptObject_TextInstancePrototype textInstanceScriptObjectPrototype ;
idCVar swf_textScrollSpeed ( " swf_textScrollSpeed " , " 80 " , CVAR_INTEGER , " scroll speed for text " ) ;
idCVar swf_textRndLetterSpeed ( " swf_textRndLetterSpeed " , " 8 " , CVAR_INTEGER , " scroll speed for text " ) ;
idCVar swf_textRndLetterDelay ( " swf_textRndLetterDelay " , " 100 " , CVAR_INTEGER , " scroll speed for text " ) ;
idCVar swf_textParagraphSpeed ( " swf_textParagraphSpeed " , " 15 " , CVAR_INTEGER , " scroll speed for text " ) ;
idCVar swf_textParagraphInc ( " swf_textParagraphInc " , " 1.3 " , CVAR_FLOAT , " scroll speed for text " ) ;
idCVar swf_subtitleExtraTime ( " swf_subtitleExtraTime " , " 3500 " , CVAR_INTEGER , " time after subtitles vo is complete " ) ;
idCVar swf_subtitleEarlyTrans ( " swf_subtitleEarlyTrans " , " 3500 " , CVAR_INTEGER , " early time out to switch the line " ) ;
idCVar swf_subtitleLengthGuess ( " swf_subtitleLengthGuess " , " 10000 " , CVAR_INTEGER , " early time out to switch the line " ) ;
idCVar swf_textMaxInputLength ( " swf_textMaxInputLength " , " 104 " , CVAR_INTEGER , " max number of characters that can go into the input line " ) ;
idCVar swf_textStrokeSize ( " swf_textStrokeSize " , " 1.65f " , CVAR_FLOAT , " size of font glyph stroke " , 0.0f , 2.0f ) ;
idCVar swf_textStrokeSizeGlyphSpacer ( " swf_textStrokeSizeGlyphSpacer " , " 1.5f " , CVAR_FLOAT , " additional space for spacing glyphs using stroke " ) ;
/*
= = = = = = = = = = = = = = = = = = = = = = = =
idSWFTextInstance : : idSWFTextInstance
= = = = = = = = = = = = = = = = = = = = = = = =
*/
2012-11-28 15:47:07 +00:00
idSWFTextInstance : : idSWFTextInstance ( )
{
2012-11-26 18:58:24 +00:00
swf = NULL ;
}
/*
= = = = = = = = = = = = = = = = = = = = = = = =
idSWFTextInstance : : ~ idSWFTextInstance
= = = = = = = = = = = = = = = = = = = = = = = =
*/
2012-11-28 15:47:07 +00:00
idSWFTextInstance : : ~ idSWFTextInstance ( )
{
2012-11-26 18:58:24 +00:00
scriptObject . SetText ( NULL ) ;
scriptObject . Clear ( ) ;
scriptObject . Release ( ) ;
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
subtitleTimingInfo . Clear ( ) ;
}
/*
= = = = = = = = = = = = = = = = = = = = = = = =
idSWFTextInstance : : Init
= = = = = = = = = = = = = = = = = = = = = = = =
*/
2012-11-28 15:47:07 +00:00
void idSWFTextInstance : : Init ( idSWFEditText * _editText , idSWF * _swf )
{
2012-11-26 18:58:24 +00:00
editText = _editText ;
swf = _swf ;
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
text = idLocalization : : GetString ( editText - > initialText ) ;
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
lengthCalculated = false ;
variable = editText - > variable ;
color = editText - > color ;
visible = true ;
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
selectionStart = - 1 ;
selectionEnd = - 1 ;
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
scroll = 0 ;
scrollTime = 0 ;
maxscroll = 0 ;
maxLines = 0 ;
linespacing = 0 ;
glyphScale = 1.0f ;
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
shiftHeld = false ;
tooltip = false ;
renderMode = SWF_TEXT_RENDER_NORMAL ;
generatingText = false ;
triggerGenerate = false ;
rndSpotsVisible = 0 ;
textSpotsVisible = 0 ;
startRndTime = 0 ;
charMultiplier = 0 ;
prevReplaceIndex = 0 ;
scrollUpdate = false ;
ignoreColor = false ;
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
isSubtitle = false ;
subLength = 0 ;
subAlign = 0 ;
subUpdating = false ;
subCharStartIndex = 0 ;
subNextStartIndex = 0 ;
subCharEndIndex = 0 ;
subDisplayTime = 0 ;
subStartTime = - 1 ;
subSourceID = - 1 ;
subNeedsSwitch = false ;
subForceKill = false ;
subKillTimeDelay = 0 ;
subSwitchTime = 0 ;
subLastWordIndex = 0 ;
subPrevLastWordIndex = 0 ;
subInitialLine = true ;
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
textLength = 0 ;
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
inputTextStartChar = 0 ;
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
renderDelay = swf_textRndLetterDelay . GetInteger ( ) ;
needsSoundUpdate = false ;
useDropShadow = false ;
useStroke = false ;
strokeStrength = 1.0f ;
strokeWeight = swf_textStrokeSize . GetFloat ( ) ;
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
scriptObject . SetPrototype ( & textInstanceScriptObjectPrototype ) ;
scriptObject . SetText ( this ) ;
scriptObject . SetNoAutoDelete ( true ) ;
}
/*
= = = = = = = = = = = = = = = = = = = = = = = =
idSWFTextInstance : : GetTextLength
= = = = = = = = = = = = = = = = = = = = = = = =
*/
2012-11-28 15:47:07 +00:00
float idSWFTextInstance : : GetTextLength ( )
{
2012-11-26 18:58:24 +00:00
// CURRENTLY ONLY WORKS FOR SINGLE LINE TEXTFIELDS
2012-11-28 15:47:07 +00:00
if ( lengthCalculated & & variable . IsEmpty ( ) )
{
2012-11-26 18:58:24 +00:00
return textLength ;
}
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
idStr txtLengthCheck = " " ;
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
float len = 0.0f ;
2012-11-28 15:47:07 +00:00
if ( verify ( swf ! = NULL ) )
{
if ( ! variable . IsEmpty ( ) )
{
2012-11-26 18:58:24 +00:00
idSWFScriptVar var = swf - > GetGlobal ( variable ) ;
2012-11-28 15:47:07 +00:00
if ( var . IsUndefined ( ) )
{
2012-11-26 18:58:24 +00:00
txtLengthCheck = text ;
2012-11-28 15:47:07 +00:00
}
else
{
2012-11-26 18:58:24 +00:00
txtLengthCheck = var . ToString ( ) ;
}
txtLengthCheck = idLocalization : : GetString ( txtLengthCheck ) ;
2012-11-28 15:47:07 +00:00
}
else
{
2012-11-26 18:58:24 +00:00
txtLengthCheck = idLocalization : : GetString ( text ) ;
}
2012-11-28 15:47:07 +00:00
const idSWFEditText * shape = editText ;
idSWFDictionaryEntry * fontEntry = swf - > FindDictionaryEntry ( shape - > fontID , SWF_DICT_FONT ) ;
idSWFFont * swfFont = fontEntry - > font ;
2012-11-26 18:58:24 +00:00
float width = fabs ( shape - > bounds . br . x - shape - > bounds . tl . x ) ;
float postTrans = SWFTWIP ( shape - > fontHeight ) ;
2012-11-28 15:47:07 +00:00
const idFont * fontInfo = swfFont - > fontID ;
2012-11-26 18:58:24 +00:00
float glyphScale = postTrans / 48.0f ;
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
int tlen = txtLengthCheck . Length ( ) ;
int index = 0 ;
2012-11-28 15:47:07 +00:00
while ( index < tlen )
{
2012-11-26 18:58:24 +00:00
scaledGlyphInfo_t glyph ;
fontInfo - > GetScaledGlyph ( glyphScale , txtLengthCheck . UTF8Char ( index ) , glyph ) ;
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
len + = glyph . xSkip ;
2012-11-28 15:47:07 +00:00
if ( useStroke )
{
2012-11-26 18:58:24 +00:00
len + = ( swf_textStrokeSizeGlyphSpacer . GetFloat ( ) * strokeWeight * glyphScale ) ;
}
2012-11-28 15:47:07 +00:00
if ( ! ( shape - > flags & SWF_ET_AUTOSIZE ) & & len > = width )
{
2012-11-26 18:58:24 +00:00
len = width ;
break ;
}
}
}
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
lengthCalculated = true ;
textLength = len ;
return textLength ;
}
/*
= = = = = = = = = = = = = = = = = = = = = = = =
idSWFTextInstance : : StartParagraphText
= = = = = = = = = = = = = = = = = = = = = = = =
*/
2012-11-28 15:47:07 +00:00
void idSWFTextInstance : : StartParagraphText ( int time )
{
2012-11-26 18:58:24 +00:00
generatingText = true ;
textSpotsVisible = 0 ;
randomtext = " " ;
triggerGenerate = false ;
startRndTime = time ;
rndTime = time ;
rnd . SetSeed ( time ) ;
prevReplaceIndex = 0 ;
rndSpotsVisible = text . Length ( ) ;
indexArray . Clear ( ) ;
charMultiplier = 0 ;
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
text = idLocalization : : GetString ( text ) ;
lengthCalculated = false ;
2012-11-28 15:47:07 +00:00
for ( int index = 0 ; index < text . Length ( ) ; + + index )
{
2012-11-26 18:58:24 +00:00
randomtext . Append ( " " ) ;
indexArray . Append ( index ) ;
}
2012-11-28 15:47:07 +00:00
for ( int index = 0 ; index < indexArray . Num ( ) ; + + index )
{
2012-11-26 18:58:24 +00:00
int swapIndex = rnd . RandomInt ( indexArray . Num ( ) ) ;
int val = indexArray [ index ] ;
indexArray [ index ] = indexArray [ swapIndex ] ;
2012-11-28 15:47:07 +00:00
indexArray [ swapIndex ] = val ;
2012-11-26 18:58:24 +00:00
}
}
/*
= = = = = = = = = = = = = = = = = = = = = = = =
idSWFTextInstance : : GetParagraphText
= = = = = = = = = = = = = = = = = = = = = = = =
*/
2012-11-28 15:47:07 +00:00
idStr idSWFTextInstance : : GetParagraphText ( int time )
{
if ( triggerGenerate )
{
2012-11-26 18:58:24 +00:00
return " " ;
2012-11-28 15:47:07 +00:00
}
else if ( time - startRndTime < renderDelay )
{
2012-11-26 18:58:24 +00:00
return " " ;
2012-11-28 15:47:07 +00:00
}
else if ( generatingText )
{
if ( time - rndTime > = renderDelay )
{
2012-11-26 18:58:24 +00:00
rndTime = time ;
needsSoundUpdate = true ;
2012-11-28 15:47:07 +00:00
if ( prevReplaceIndex > = text . Length ( ) )
{
2012-11-26 18:58:24 +00:00
generatingText = false ;
return text ;
2012-11-28 15:47:07 +00:00
}
2012-11-26 18:58:24 +00:00
randomtext [ prevReplaceIndex ] = text [ prevReplaceIndex ] ;
prevReplaceIndex + + ;
}
2012-11-28 15:47:07 +00:00
}
else
{
2012-11-26 18:58:24 +00:00
scrollUpdate = false ;
return text ;
}
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
return randomtext ;
}
/*
= = = = = = = = = = = = = = = = = = = = = = = =
idSWFTextInstance : : StartRandomText
= = = = = = = = = = = = = = = = = = = = = = = =
*/
2012-11-28 15:47:07 +00:00
bool idSWFTextInstance : : NeedsSoundPlayed ( )
{
if ( soundClip . IsEmpty ( ) )
{
2012-11-26 18:58:24 +00:00
return false ;
}
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
return needsSoundUpdate ;
}
/*
= = = = = = = = = = = = = = = = = = = = = = = =
idSWFTextInstance : : StartRandomText
= = = = = = = = = = = = = = = = = = = = = = = =
*/
2012-11-28 15:47:07 +00:00
void idSWFTextInstance : : StartRandomText ( int time )
{
2012-11-26 18:58:24 +00:00
generatingText = true ;
textSpotsVisible = 0 ;
randomtext = " " ;
triggerGenerate = false ;
startRndTime = time ;
rndTime = time ;
rnd . SetSeed ( time ) ;
rndSpotsVisible = 0 ;
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
text = idLocalization : : GetString ( text ) ;
lengthCalculated = false ;
2012-11-28 15:47:07 +00:00
for ( int index = 0 ; index < text . Length ( ) ; + + index )
{
if ( text [ index ] = = ' ' )
{
2012-11-26 18:58:24 +00:00
randomtext . Append ( " " ) ;
2012-11-28 15:47:07 +00:00
}
else
{
2012-11-26 18:58:24 +00:00
randomtext . Append ( " . " ) ;
rndSpotsVisible + + ;
}
}
}
/*
= = = = = = = = = = = = = = = = = = = = = = = =
idSWFTextInstance : : GetRandomText
= = = = = = = = = = = = = = = = = = = = = = = =
*/
2012-11-28 15:47:07 +00:00
idStr idSWFTextInstance : : GetRandomText ( int time )
{
2012-11-26 18:58:24 +00:00
2012-11-28 15:47:07 +00:00
if ( triggerGenerate )
{
2012-11-26 18:58:24 +00:00
return " " ;
2012-11-28 15:47:07 +00:00
}
else if ( time - startRndTime < renderDelay )
{
2012-11-26 18:58:24 +00:00
return " " ;
2012-11-28 15:47:07 +00:00
}
else if ( generatingText )
{
if ( rndSpotsVisible > 0 )
{
2012-11-26 18:58:24 +00:00
int waitTime = swf_textRndLetterSpeed . GetInteger ( ) ;
2012-11-28 15:47:07 +00:00
if ( randomtext . Length ( ) > = 10 )
{
2012-11-26 18:58:24 +00:00
waitTime = waitTime / 3 ;
2012-11-28 15:47:07 +00:00
}
if ( time - rndTime > = waitTime )
{
2012-11-26 18:58:24 +00:00
rndTime = time ;
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
int spotIndex = rnd . RandomInt ( rndSpotsVisible ) ;
int cIndex = 0 ;
2012-11-28 15:47:07 +00:00
for ( int c = 0 ; c < randomtext . Length ( ) ; + + c )
{
if ( c > = text . Length ( ) )
{
2012-11-26 18:58:24 +00:00
rndSpotsVisible = 0 ;
break ;
}
2012-11-28 15:47:07 +00:00
if ( randomtext [ c ] = = ' . ' )
{
2012-11-26 18:58:24 +00:00
cIndex + + ;
}
2012-11-28 15:47:07 +00:00
if ( cIndex = = spotIndex )
{
2012-11-26 18:58:24 +00:00
bool useCaps = false ;
2012-11-28 15:47:07 +00:00
if ( c - 1 > = 0 & & text [ c - 1 ] = = ' ' )
{
2012-11-26 18:58:24 +00:00
useCaps = true ;
2012-11-28 15:47:07 +00:00
}
else if ( c = = 0 )
{
2012-11-26 18:58:24 +00:00
useCaps = true ;
}
2012-11-28 15:47:07 +00:00
if ( useCaps | | renderMode = = SWF_TEXT_RENDER_RANDOM_APPEAR_CAPS )
{
2012-11-26 18:58:24 +00:00
randomtext [ c ] = rnd . RandomInt ( ' Z ' - ' A ' ) + ' A ' ;
2012-11-28 15:47:07 +00:00
}
else
{
2012-11-26 18:58:24 +00:00
randomtext [ c ] = rnd . RandomInt ( ' z ' - ' a ' ) + ' a ' ;
}
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
rndSpotsVisible - - ;
2012-11-28 15:47:07 +00:00
if ( ! soundClip . IsEmpty ( ) )
{
2012-11-26 18:58:24 +00:00
needsSoundUpdate = true ;
}
break ;
}
}
}
2012-11-28 15:47:07 +00:00
}
else if ( rndSpotsVisible = = 0 & & textSpotsVisible < text . Length ( ) )
{
if ( textSpotsVisible > = randomtext . Length ( ) )
{
2012-11-26 18:58:24 +00:00
textSpotsVisible + + ;
2012-11-28 15:47:07 +00:00
}
else
{
if ( time - rndTime > = swf_textRndLetterSpeed . GetInteger ( ) )
{
2012-11-26 18:58:24 +00:00
rndTime = time ;
randomtext [ textSpotsVisible ] = text [ textSpotsVisible ] ;
textSpotsVisible + + ;
2012-11-28 15:47:07 +00:00
if ( ! soundClip . IsEmpty ( ) )
{
2012-11-26 18:58:24 +00:00
needsSoundUpdate = true ;
}
}
}
2012-11-28 15:47:07 +00:00
}
else
{
2012-11-26 18:58:24 +00:00
return " " ;
}
2012-11-28 15:47:07 +00:00
}
else
{
2012-11-26 18:58:24 +00:00
return text ;
}
2012-11-28 15:47:07 +00:00
if ( rndSpotsVisible = = 0 & & textSpotsVisible = = text . Length ( ) )
{
2012-11-26 18:58:24 +00:00
generatingText = false ;
}
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
return randomtext ;
}
/*
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
SUBTITLE FUNCTIONALITY
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
*/
/*
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
idSWFTextInstance : : SwitchSubtitleText
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
*/
2012-11-28 15:47:07 +00:00
void idSWFTextInstance : : SwitchSubtitleText ( int time )
{
2012-11-26 18:58:24 +00:00
subNeedsSwitch = false ;
}
2012-11-28 15:47:07 +00:00
void idSWFTextInstance : : SetSubNextStartIndex ( int value )
{
2012-11-26 18:58:24 +00:00
subNextStartIndex = value ;
}
/*
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
idSWFTextInstance : : UpdateSubtitle
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
*/
2012-11-28 15:47:07 +00:00
bool idSWFTextInstance : : UpdateSubtitle ( int time )
{
2012-11-26 18:58:24 +00:00
2012-11-28 15:47:07 +00:00
if ( subForceKillQueued )
{
2012-11-26 18:58:24 +00:00
subForceKillQueued = false ;
subForceKill = true ;
subKillTimeDelay = time + swf_subtitleExtraTime . GetInteger ( ) ;
}
2012-11-28 15:47:07 +00:00
if ( subUpdating & & ! subForceKill )
{
if ( ( time > = subSwitchTime & & ! subNeedsSwitch ) | | ( ! subNeedsSwitch & & subInitialLine ) )
{
2012-11-26 18:58:24 +00:00
//idLib::Printf( "SWITCH TIME %d / %d \n", time, subSwitchTime );
2012-11-28 15:47:07 +00:00
if ( subInitialLine & & subtitleTimingInfo . Num ( ) > 0 )
{
if ( subStartTime = = - 1 )
{
2012-11-26 18:58:24 +00:00
subStartTime = time - 600 ;
}
2012-11-28 15:47:07 +00:00
if ( time < subStartTime + subtitleTimingInfo [ 0 ] . startTime )
{
2012-11-26 18:58:24 +00:00
return true ;
2012-11-28 15:47:07 +00:00
}
else
{
2012-11-26 18:58:24 +00:00
text = subtitleText ; //subtitleText = "";
subInitialLine = false ;
2012-11-28 15:47:07 +00:00
}
2012-11-26 18:58:24 +00:00
}
2012-11-28 15:47:07 +00:00
if ( subNextStartIndex + 1 > = text . Length ( ) )
{
2012-11-26 18:58:24 +00:00
subForceKillQueued = true ;
2012-11-28 15:47:07 +00:00
}
else
{
2012-11-26 18:58:24 +00:00
subCharStartIndex = subNextStartIndex ;
//subtitleText.CopyRange( text, subCharStartIndex, subCharEndIndex );
subNeedsSwitch = true ;
}
}
}
2012-11-28 15:47:07 +00:00
if ( subForceKill )
{
if ( time > = subKillTimeDelay )
{
2012-11-26 18:58:24 +00:00
subForceKill = false ;
return false ;
}
}
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
return true ;
}
/*
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
idSWFTextInstance : : SubtitleComplete
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
*/
2012-11-28 15:47:07 +00:00
void idSWFTextInstance : : SetSubEndIndex ( int endChar , int time )
{
2012-11-26 18:58:24 +00:00
subCharEndIndex = endChar ;
2012-11-28 15:47:07 +00:00
if ( subCharEndIndex + 1 > = text . Length ( ) )
{
2012-11-26 18:58:24 +00:00
LastWordChanged ( subtitleTimingInfo . Num ( ) , time ) ;
}
}
/*
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
idSWFTextInstance : : SubtitleComplete
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
*/
2012-11-28 15:47:07 +00:00
void idSWFTextInstance : : SubtitleComplete ( )
{
2012-11-26 18:58:24 +00:00
subInitialLine = true ;
subUpdating = false ;
isSubtitle = false ;
subNeedsSwitch = false ;
subCharDisplayTime = 0 ;
subForceKillQueued = false ;
subForceKill = false ;
subKillTimeDelay = 0 ;
subSwitchTime = 0 ;
subLastWordIndex = 0 ;
subPrevLastWordIndex = 0 ;
subStartTime = - 1 ;
subSpeaker = " " ;
subtitleText = " " ;
text = " " ;
subtitleTimingInfo . Clear ( ) ;
}
/*
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
idSWFTextInstance : : LastWordChanged
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
*/
2012-11-28 15:47:07 +00:00
void idSWFTextInstance : : LastWordChanged ( int wordCount , int time )
{
if ( subPrevLastWordIndex + wordCount > = subtitleTimingInfo . Num ( ) )
{
2012-11-26 18:58:24 +00:00
subLastWordIndex = subtitleTimingInfo . Num ( ) - 1 ;
2012-11-28 15:47:07 +00:00
}
else
{
2012-11-26 18:58:24 +00:00
subLastWordIndex = subPrevLastWordIndex + wordCount - 1 ;
}
2012-11-28 15:47:07 +00:00
if ( subStartTime = = - 1 )
{
if ( subtitleTimingInfo . Num ( ) > 0 )
{
2012-11-26 18:58:24 +00:00
subStartTime = time + subtitleTimingInfo [ 0 ] . startTime ;
2012-11-28 15:47:07 +00:00
}
else
{
2012-11-26 18:58:24 +00:00
subStartTime = time ;
}
}
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
subSwitchTime = subStartTime + subtitleTimingInfo [ subLastWordIndex ] . startTime ; // - swf_subtitleEarlyTrans.GetInteger();
//idLib::Printf( "switchtime set 1 %d last word %d\n", subSwitchTime, subLastWordIndex );
}
/*
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
idSWFTextInstance : : GetSubtitleBreak
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
*/
2012-11-28 15:47:07 +00:00
int idSWFTextInstance : : GetApporoximateSubtitleBreak ( int time )
{
2012-11-26 18:58:24 +00:00
int wordIndex = subLastWordIndex ;
bool setSwitchTime = false ;
2012-11-28 15:47:07 +00:00
if ( subStartTime = = - 1 )
{
2012-11-26 18:58:24 +00:00
subStartTime = time ;
}
2012-11-28 15:47:07 +00:00
if ( time > = subSwitchTime )
{
2012-11-26 18:58:24 +00:00
subPrevLastWordIndex = subLastWordIndex ;
2012-11-28 15:47:07 +00:00
for ( int i = wordIndex ; i < subtitleTimingInfo . Num ( ) ; + + i )
{
if ( subtitleTimingInfo [ i ] . forceBreak )
{
if ( i + 1 < subtitleTimingInfo . Num ( ) )
{
subSwitchTime = subStartTime + subtitleTimingInfo [ i + 1 ] . startTime ; // - swf_subtitleEarlyTrans.GetInteger();
2012-11-26 18:58:24 +00:00
//idLib::Printf( "switchtime set 2 %d\n", subSwitchTime );
subLastWordIndex = i ;
setSwitchTime = true ;
break ;
2012-11-28 15:47:07 +00:00
}
else
{
2012-11-26 18:58:24 +00:00
subSwitchTime = subStartTime + subtitleTimingInfo [ i ] . startTime ; // - swf_subtitleEarlyTrans.GetInteger();
//idLib::Printf( "switchtime set 3 %d\n", subSwitchTime );
subLastWordIndex = i ;
setSwitchTime = true ;
break ;
}
2012-11-28 15:47:07 +00:00
}
else
{
2012-11-26 18:58:24 +00:00
int timeSpan = subtitleTimingInfo [ i ] . startTime - subtitleTimingInfo [ wordIndex ] . startTime ;
2012-11-28 15:47:07 +00:00
if ( timeSpan > swf_subtitleLengthGuess . GetInteger ( ) )
{
if ( i - 1 > = 0 )
{
2012-11-26 18:58:24 +00:00
subSwitchTime = subStartTime + subtitleTimingInfo [ i ] . startTime ; // - swf_subtitleEarlyTrans.GetInteger();
//idLib::Printf( "switchtime set 4 %d\n", subSwitchTime );
subLastWordIndex = i - 1 ;
2012-11-28 15:47:07 +00:00
}
else
{
2012-11-26 18:58:24 +00:00
subSwitchTime = subStartTime + subtitleTimingInfo [ i ] . startTime ; // - swf_subtitleEarlyTrans.GetInteger();
//idLib::Printf( "switchtime set 5 %d\n", subSwitchTime );
subLastWordIndex = i ;
}
setSwitchTime = true ;
break ;
}
}
}
2012-11-28 15:47:07 +00:00
if ( ! setSwitchTime & & subtitleTimingInfo . Num ( ) > 0 )
{
2012-11-26 18:58:24 +00:00
subSwitchTime = subStartTime + subtitleTimingInfo [ subtitleTimingInfo . Num ( ) - 1 ] . startTime ; // - swf_subtitleEarlyTrans.GetInteger();
//idLib::Printf( "switchtime set 6 %d\n", subSwitchTime );
subLastWordIndex = subtitleTimingInfo . Num ( ) ;
}
}
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
return subLastWordIndex ;
}
/*
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
idSWFTextInstance : : SubtitleComplete
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
*/
2012-11-28 15:47:07 +00:00
void idSWFTextInstance : : SubtitleCleanup ( )
{
2012-11-26 18:58:24 +00:00
subSourceID = - 1 ;
subAlign = - 1 ;
text = " " ;
}
/*
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
idSWFTextInstance : : SetStrokeInfo
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
*/
2012-11-28 15:47:07 +00:00
void idSWFTextInstance : : SetStrokeInfo ( bool use , float strength , float weight )
{
2012-11-26 18:58:24 +00:00
useStroke = use ;
2012-11-28 15:47:07 +00:00
if ( use )
{
2012-11-26 18:58:24 +00:00
strokeWeight = weight ;
strokeStrength = strength ;
}
}
/*
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
idSWFTextInstance : : CalcMaxScroll
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
*/
2012-11-28 15:47:07 +00:00
int idSWFTextInstance : : CalcMaxScroll ( int numLines )
{
2012-11-26 18:58:24 +00:00
2012-11-28 15:47:07 +00:00
if ( numLines ! = - 1 )
{
if ( numLines < 0 )
{
2012-11-26 18:58:24 +00:00
numLines = 0 ;
}
maxscroll = numLines ;
return maxscroll ;
}
2012-11-28 15:47:07 +00:00
const idSWFEditText * shape = editText ;
if ( ! ( shape - > flags & SWF_ET_MULTILINE ) )
{
2012-11-26 18:58:24 +00:00
return 0 ;
}
2012-11-28 15:47:07 +00:00
if ( swf = = NULL )
{
2012-11-26 18:58:24 +00:00
return 0 ;
}
2012-11-28 15:47:07 +00:00
idSWFDictionaryEntry * fontEntry = swf - > FindDictionaryEntry ( shape - > fontID , SWF_DICT_FONT ) ;
if ( fontEntry = = NULL )
{
2012-11-26 18:58:24 +00:00
return 0 ;
}
2012-11-28 15:47:07 +00:00
idSWFFont * swfFont = fontEntry - > font ;
if ( swfFont = = NULL )
{
2012-11-26 18:58:24 +00:00
return 0 ;
}
2012-11-28 15:47:07 +00:00
const idFont * fontInfo = swfFont - > fontID ;
if ( fontInfo = = NULL )
{
2012-11-26 18:58:24 +00:00
return 0 ;
}
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
idStr textCheck ;
2012-11-28 15:47:07 +00:00
if ( variable . IsEmpty ( ) )
{
2012-11-26 18:58:24 +00:00
textCheck = idLocalization : : GetString ( text ) ;
2012-11-28 15:47:07 +00:00
}
else
{
2012-11-26 18:58:24 +00:00
textCheck = idLocalization : : GetString ( variable ) ;
}
2012-11-28 15:47:07 +00:00
if ( textCheck . IsEmpty ( ) )
{
2012-11-26 18:58:24 +00:00
return 0 ;
}
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
float x = bounds . tl . x ;
float y = bounds . tl . y ;
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
idList < idStr > textLines ;
2012-11-28 15:47:07 +00:00
idStr * currentLine = & textLines . Alloc ( ) ;
2012-11-26 18:58:24 +00:00
// tracks the last breakable character we found
int lastbreak = 0 ;
float lastbreakX = 0 ;
int charIndex = 0 ;
2012-11-28 15:47:07 +00:00
if ( IsSubtitle ( ) )
{
2012-11-26 18:58:24 +00:00
charIndex = GetSubStartIndex ( ) ;
}
2012-11-28 15:47:07 +00:00
while ( charIndex < textCheck . Length ( ) )
{
if ( textCheck [ charIndex ] = = ' \n ' )
{
if ( shape - > flags & SWF_ET_MULTILINE )
{
2012-11-26 18:58:24 +00:00
currentLine - > Append ( ' \n ' ) ;
x = bounds . tl . x ;
y + = linespacing ;
2012-11-28 15:47:07 +00:00
currentLine = & textLines . Alloc ( ) ;
2012-11-26 18:58:24 +00:00
lastbreak = 0 ;
charIndex + + ;
continue ;
2012-11-28 15:47:07 +00:00
}
else
{
2012-11-26 18:58:24 +00:00
break ;
}
}
int glyphStart = charIndex ;
uint32 tc = textCheck . UTF8Char ( charIndex ) ;
scaledGlyphInfo_t glyph ;
fontInfo - > GetScaledGlyph ( glyphScale , tc , glyph ) ;
float glyphSkip = glyph . xSkip ;
2012-11-28 15:47:07 +00:00
if ( HasStroke ( ) )
{
2012-11-26 18:58:24 +00:00
glyphSkip + = ( swf_textStrokeSizeGlyphSpacer . GetFloat ( ) * GetStrokeWeight ( ) * glyphScale ) ;
}
2012-11-28 15:47:07 +00:00
if ( x + glyphSkip > bounds . br . x )
{
if ( shape - > flags & ( SWF_ET_MULTILINE | SWF_ET_WORDWRAP ) )
{
if ( lastbreak > 0 )
{
2012-11-26 18:58:24 +00:00
int curLineIndex = currentLine - & textLines [ 0 ] ;
2012-11-28 15:47:07 +00:00
idStr * newline = & textLines . Alloc ( ) ;
2012-11-26 18:58:24 +00:00
currentLine = & textLines [ curLineIndex ] ;
2012-11-28 15:47:07 +00:00
if ( maxLines = = 1 )
{
2012-11-26 18:58:24 +00:00
currentLine - > CapLength ( currentLine - > Length ( ) - 3 ) ;
currentLine - > Append ( " ... " ) ;
break ;
2012-11-28 15:47:07 +00:00
}
else
{
2012-11-26 18:58:24 +00:00
* newline = currentLine - > c_str ( ) + lastbreak ;
currentLine - > CapLength ( lastbreak ) ;
currentLine = newline ;
x - = lastbreakX ;
}
2012-11-28 15:47:07 +00:00
}
else
{
2012-11-26 18:58:24 +00:00
currentLine = & textLines . Alloc ( ) ;
x = bounds . tl . x ;
}
lastbreak = 0 ;
2012-11-28 15:47:07 +00:00
}
else
{
2012-11-26 18:58:24 +00:00
break ;
}
}
2012-11-28 15:47:07 +00:00
while ( glyphStart < charIndex & & glyphStart < text . Length ( ) )
{
2012-11-26 18:58:24 +00:00
currentLine - > Append ( text [ glyphStart + + ] ) ;
}
x + = glyphSkip ;
2012-11-28 15:47:07 +00:00
if ( tc = = ' ' | | tc = = ' - ' )
{
2012-11-26 18:58:24 +00:00
lastbreak = currentLine - > Length ( ) ;
lastbreakX = x ;
}
}
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
maxscroll = textLines . Num ( ) - maxLines ;
2012-11-28 15:47:07 +00:00
if ( maxscroll < 0 )
{
2012-11-26 18:58:24 +00:00
maxscroll = 0 ;
}
return maxscroll ;
}
2012-11-28 15:47:07 +00:00
int idSWFTextInstance : : CalcNumLines ( )
{
2012-11-26 18:58:24 +00:00
2012-11-28 15:47:07 +00:00
const idSWFEditText * shape = editText ;
if ( ! ( shape - > flags & SWF_ET_MULTILINE ) )
{
2012-11-26 18:58:24 +00:00
return 1 ;
}
2012-11-28 15:47:07 +00:00
idSWFDictionaryEntry * fontEntry = swf - > FindDictionaryEntry ( shape - > fontID , SWF_DICT_FONT ) ;
if ( fontEntry = = NULL )
{
2012-11-26 18:58:24 +00:00
return 1 ;
}
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
idStr textCheck ;
2012-11-28 15:47:07 +00:00
if ( variable . IsEmpty ( ) )
{
2012-11-26 18:58:24 +00:00
textCheck = idLocalization : : GetString ( text ) ;
2012-11-28 15:47:07 +00:00
}
else
{
2012-11-26 18:58:24 +00:00
textCheck = idLocalization : : GetString ( variable ) ;
}
2012-11-28 15:47:07 +00:00
if ( textCheck . IsEmpty ( ) )
{
2012-11-26 18:58:24 +00:00
return 1 ;
}
2012-11-28 15:47:07 +00:00
if ( swf = = NULL )
{
2012-11-26 18:58:24 +00:00
return 1 ;
}
2012-11-28 15:47:07 +00:00
idSWFFont * swfFont = fontEntry - > font ;
2012-11-26 18:58:24 +00:00
float postTransformHeight = SWFTWIP ( shape - > fontHeight ) ;
2012-11-28 15:47:07 +00:00
const idFont * fontInfo = swfFont - > fontID ;
2012-11-26 18:58:24 +00:00
float glyphScale = postTransformHeight / 48.0f ;
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
swfRect_t bounds ;
bounds . tl . x = ( shape - > bounds . tl . x + SWFTWIP ( shape - > leftMargin ) ) ;
bounds . br . x = ( shape - > bounds . br . x - SWFTWIP ( shape - > rightMargin ) ) ;
bounds . tl . y = ( shape - > bounds . tl . y + ( 1.15f * glyphScale ) ) ;
bounds . br . y = ( shape - > bounds . br . y ) ;
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
float linespacing = fontInfo - > GetAscender ( 1.15f * glyphScale ) ;
2012-11-28 15:47:07 +00:00
if ( shape - > leading ! = 0 )
{
2012-11-26 18:58:24 +00:00
linespacing + = ( glyphScale * SWFTWIP ( shape - > leading ) ) ;
}
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
float x = bounds . tl . x ;
int maxLines = idMath : : Ftoi ( ( bounds . br . y - bounds . tl . y ) / linespacing ) ;
2012-11-28 15:47:07 +00:00
if ( maxLines = = 0 )
{
2012-11-26 18:58:24 +00:00
maxLines = 1 ;
}
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
// tracks the last breakable character we found
int numLines = 1 ;
int lastbreak = 0 ;
int charIndex = 0 ;
2012-11-28 15:47:07 +00:00
while ( charIndex < textCheck . Length ( ) )
{
if ( textCheck [ charIndex ] = = ' \n ' )
{
if ( numLines = = maxLines )
{
2012-11-26 18:58:24 +00:00
return maxLines ;
}
numLines + + ;
lastbreak = 0 ;
x = bounds . tl . x ;
charIndex + + ;
2012-11-28 15:47:07 +00:00
}
else
{
2012-11-26 18:58:24 +00:00
uint32 tc = textCheck [ charIndex + + ] ;
scaledGlyphInfo_t glyph ;
fontInfo - > GetScaledGlyph ( glyphScale , tc , glyph ) ;
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
float glyphSkip = glyph . xSkip ;
2012-11-28 15:47:07 +00:00
if ( useStroke )
{
2012-11-26 18:58:24 +00:00
glyphSkip + = ( swf_textStrokeSizeGlyphSpacer . GetFloat ( ) * strokeWeight * glyphScale ) ;
}
2012-11-28 15:47:07 +00:00
if ( x + glyphSkip > bounds . br . x )
{
if ( numLines = = maxLines )
{
2012-11-26 18:58:24 +00:00
return maxLines ;
2012-11-28 15:47:07 +00:00
}
else
{
2012-11-26 18:58:24 +00:00
numLines + + ;
2012-11-28 15:47:07 +00:00
if ( lastbreak ! = 0 )
{
2012-11-26 18:58:24 +00:00
charIndex = charIndex - ( charIndex - lastbreak ) ;
}
2012-11-28 15:47:07 +00:00
x = bounds . tl . x ;
2012-11-26 18:58:24 +00:00
lastbreak = 0 ;
}
2012-11-28 15:47:07 +00:00
}
else
{
2012-11-26 18:58:24 +00:00
x + = glyphSkip ;
2012-11-28 15:47:07 +00:00
if ( tc = = ' ' | | tc = = ' - ' )
{
2012-11-26 18:58:24 +00:00
lastbreak = charIndex ;
}
}
}
}
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
return numLines ;
}
/*
= = = = = = = = = = = = = = = = = = = = = = = =
idSWFScriptObject_TextInstancePrototype
= = = = = = = = = = = = = = = = = = = = = = = =
*/
# define SWF_TEXT_FUNCTION_DEFINE( x ) idSWFScriptVar idSWFScriptObject_TextInstancePrototype::idSWFScriptFunction_##x::Call( idSWFScriptObject * thisObject, const idSWFParmList & parms )
# define SWF_TEXT_NATIVE_VAR_DEFINE_GET( x ) idSWFScriptVar idSWFScriptObject_TextInstancePrototype::idSWFScriptNativeVar_##x::Get( class idSWFScriptObject * object )
# define SWF_TEXT_NATIVE_VAR_DEFINE_SET( x ) void idSWFScriptObject_TextInstancePrototype::idSWFScriptNativeVar_##x::Set( class idSWFScriptObject * object, const idSWFScriptVar & value )
# define SWF_TEXT_PTHIS_FUNC( x ) idSWFTextInstance * pThis = thisObject ? thisObject->GetText() : NULL; if ( !verify( pThis != NULL ) ) { idLib::Warning( "SWF: tried to call " x " on NULL edittext" ); return idSWFScriptVar(); }
# define SWF_TEXT_PTHIS_GET( x ) idSWFTextInstance * pThis = object ? object->GetText() : NULL; if ( pThis == NULL ) { return idSWFScriptVar(); }
# define SWF_TEXT_PTHIS_SET( x ) idSWFTextInstance * pThis = object ? object->GetText() : NULL; if ( pThis == NULL ) { return; }
# define SWF_TEXT_FUNCTION_SET( x ) scriptFunction_##x.AddRef(); Set( #x, &scriptFunction_##x );
# define SWF_TEXT_NATIVE_VAR_SET( x ) SetNative( #x, &swfScriptVar_##x );
2012-11-28 15:47:07 +00:00
idSWFScriptObject_TextInstancePrototype : : idSWFScriptObject_TextInstancePrototype ( )
{
2012-11-26 18:58:24 +00:00
SWF_TEXT_FUNCTION_SET ( onKey ) ;
SWF_TEXT_FUNCTION_SET ( onChar ) ;
SWF_TEXT_FUNCTION_SET ( generateRnd ) ;
SWF_TEXT_FUNCTION_SET ( calcNumLines ) ;
SWF_TEXT_FUNCTION_SET ( clearTimingInfo ) ;
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
SWF_TEXT_NATIVE_VAR_SET ( text ) ;
SWF_TEXT_NATIVE_VAR_SET ( _textLength ) ; // only works on single lines of text not multiline
SWF_TEXT_NATIVE_VAR_SET ( autoSize ) ;
SWF_TEXT_NATIVE_VAR_SET ( dropShadow ) ;
SWF_TEXT_NATIVE_VAR_SET ( _stroke ) ;
SWF_TEXT_NATIVE_VAR_SET ( _strokeStrength ) ;
SWF_TEXT_NATIVE_VAR_SET ( _strokeWeight ) ;
SWF_TEXT_NATIVE_VAR_SET ( variable ) ;
SWF_TEXT_NATIVE_VAR_SET ( _alpha ) ;
SWF_TEXT_NATIVE_VAR_SET ( textColor ) ;
SWF_TEXT_NATIVE_VAR_SET ( _visible ) ;
SWF_TEXT_NATIVE_VAR_SET ( selectionStart ) ;
SWF_TEXT_NATIVE_VAR_SET ( selectionEnd ) ;
SWF_TEXT_NATIVE_VAR_SET ( scroll ) ;
SWF_TEXT_NATIVE_VAR_SET ( maxscroll ) ;
SWF_TEXT_NATIVE_VAR_SET ( isTooltip ) ;
SWF_TEXT_NATIVE_VAR_SET ( mode ) ;
SWF_TEXT_NATIVE_VAR_SET ( delay ) ;
SWF_TEXT_NATIVE_VAR_SET ( renderSound ) ;
SWF_TEXT_NATIVE_VAR_SET ( updateScroll ) ;
SWF_TEXT_NATIVE_VAR_SET ( subtitle ) ;
SWF_TEXT_NATIVE_VAR_SET ( subtitleAlign ) ;
SWF_TEXT_NATIVE_VAR_SET ( subtitleSourceID ) ;
SWF_TEXT_NATIVE_VAR_SET ( subtitleSpeaker ) ;
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
SWF_TEXT_FUNCTION_SET ( subtitleSourceCheck ) ;
SWF_TEXT_FUNCTION_SET ( subtitleStart ) ;
SWF_TEXT_FUNCTION_SET ( subtitleLength ) ;
SWF_TEXT_FUNCTION_SET ( killSubtitle ) ;
SWF_TEXT_FUNCTION_SET ( forceKillSubtitle ) ;
SWF_TEXT_FUNCTION_SET ( subLastLine ) ;
SWF_TEXT_FUNCTION_SET ( addSubtitleInfo ) ;
SWF_TEXT_FUNCTION_SET ( terminateSubtitle ) ;
}
2012-11-28 15:47:07 +00:00
SWF_TEXT_NATIVE_VAR_DEFINE_GET ( text )
{
2012-11-26 18:58:24 +00:00
SWF_TEXT_PTHIS_GET ( " text " ) ;
return pThis - > text ;
}
2012-11-28 15:47:07 +00:00
SWF_TEXT_NATIVE_VAR_DEFINE_SET ( text )
{
2012-11-26 18:58:24 +00:00
SWF_TEXT_PTHIS_SET ( " text " ) ;
pThis - > text = idLocalization : : GetString ( value . ToString ( ) ) ;
2012-11-28 15:47:07 +00:00
if ( pThis - > text . IsEmpty ( ) )
{
2012-11-26 18:58:24 +00:00
pThis - > selectionEnd = - 1 ;
pThis - > selectionStart = - 1 ;
pThis - > inputTextStartChar = 0 ;
}
pThis - > lengthCalculated = false ;
}
2012-11-28 15:47:07 +00:00
SWF_TEXT_NATIVE_VAR_DEFINE_GET ( autoSize )
{
2012-11-26 18:58:24 +00:00
SWF_TEXT_PTHIS_GET ( " autoSize " ) ;
return ( pThis - > editText - > flags & SWF_ET_AUTOSIZE ) ! = 0 ;
}
2012-11-28 15:47:07 +00:00
SWF_TEXT_NATIVE_VAR_DEFINE_SET ( autoSize )
{
2012-11-26 18:58:24 +00:00
SWF_TEXT_PTHIS_SET ( " autoSize " ) ;
2012-11-28 15:47:07 +00:00
if ( value . ToBool ( ) )
{
2012-11-26 18:58:24 +00:00
pThis - > editText - > flags | = SWF_ET_AUTOSIZE ;
2012-11-28 15:47:07 +00:00
}
else
{
2012-11-26 18:58:24 +00:00
pThis - > editText - > flags & = ~ SWF_ET_AUTOSIZE ;
}
pThis - > lengthCalculated = false ;
}
2012-11-28 15:47:07 +00:00
SWF_TEXT_NATIVE_VAR_DEFINE_GET ( dropShadow )
{
SWF_TEXT_PTHIS_GET ( " dropShadow " ) ;
return pThis - > useDropShadow ;
}
SWF_TEXT_NATIVE_VAR_DEFINE_SET ( dropShadow )
{
SWF_TEXT_PTHIS_SET ( " dropShadow " ) ;
pThis - > useDropShadow = value . ToBool ( ) ;
}
SWF_TEXT_NATIVE_VAR_DEFINE_GET ( _stroke )
{
SWF_TEXT_PTHIS_GET ( " _stroke " ) ;
return pThis - > useStroke ;
}
SWF_TEXT_NATIVE_VAR_DEFINE_SET ( _stroke )
{
SWF_TEXT_PTHIS_SET ( " _stroke " ) ;
pThis - > useStroke = value . ToBool ( ) ;
}
SWF_TEXT_NATIVE_VAR_DEFINE_GET ( _strokeStrength )
{
SWF_TEXT_PTHIS_GET ( " _strokeStrength " ) ;
return pThis - > strokeStrength ;
}
SWF_TEXT_NATIVE_VAR_DEFINE_SET ( _strokeStrength )
{
SWF_TEXT_PTHIS_SET ( " _strokeStrength " ) ;
pThis - > strokeStrength = value . ToFloat ( ) ;
}
SWF_TEXT_NATIVE_VAR_DEFINE_GET ( _strokeWeight )
{
SWF_TEXT_PTHIS_GET ( " _strokeWeight " ) ;
return pThis - > strokeWeight ;
}
SWF_TEXT_NATIVE_VAR_DEFINE_SET ( _strokeWeight )
{
SWF_TEXT_PTHIS_SET ( " _strokeWeight " ) ;
pThis - > strokeWeight = value . ToFloat ( ) ;
}
SWF_TEXT_NATIVE_VAR_DEFINE_GET ( variable )
{
SWF_TEXT_PTHIS_GET ( " variable " ) ;
return pThis - > variable ;
}
SWF_TEXT_NATIVE_VAR_DEFINE_SET ( variable )
{
SWF_TEXT_PTHIS_SET ( " variable " ) ;
pThis - > variable = value . ToString ( ) ;
}
SWF_TEXT_NATIVE_VAR_DEFINE_GET ( _alpha )
{
SWF_TEXT_PTHIS_GET ( " _alpha " ) ;
return pThis - > color . a / 255.0f ;
}
SWF_TEXT_NATIVE_VAR_DEFINE_SET ( _alpha )
{
SWF_TEXT_PTHIS_SET ( " _alpha " ) ;
pThis - > color . a = idMath : : Ftob ( value . ToFloat ( ) * 255.0f ) ;
}
SWF_TEXT_NATIVE_VAR_DEFINE_GET ( _visible )
{
SWF_TEXT_PTHIS_GET ( " _visible " ) ;
return pThis - > visible ;
}
SWF_TEXT_NATIVE_VAR_DEFINE_SET ( _visible )
{
SWF_TEXT_PTHIS_SET ( " _visible " ) ;
pThis - > visible = value . ToBool ( ) ;
}
SWF_TEXT_NATIVE_VAR_DEFINE_GET ( selectionStart )
{
SWF_TEXT_PTHIS_GET ( " selectionStart " ) ;
return pThis - > selectionStart ;
}
SWF_TEXT_NATIVE_VAR_DEFINE_SET ( selectionStart )
{
SWF_TEXT_PTHIS_SET ( " selectionStart " ) ;
pThis - > selectionStart = value . ToInteger ( ) ;
}
SWF_TEXT_NATIVE_VAR_DEFINE_GET ( selectionEnd )
{
SWF_TEXT_PTHIS_GET ( " selectionEnd " ) ;
return pThis - > selectionEnd ;
}
SWF_TEXT_NATIVE_VAR_DEFINE_SET ( selectionEnd )
{
SWF_TEXT_PTHIS_SET ( " selectionEnd " ) ;
pThis - > selectionEnd = value . ToInteger ( ) ;
}
SWF_TEXT_NATIVE_VAR_DEFINE_SET ( isTooltip )
{
SWF_TEXT_PTHIS_SET ( " isTooltip " ) ;
pThis - > tooltip = value . ToBool ( ) ;
}
SWF_TEXT_NATIVE_VAR_DEFINE_GET ( isTooltip )
{
SWF_TEXT_PTHIS_GET ( " isTooltip " ) ;
return pThis - > tooltip ;
}
SWF_TEXT_NATIVE_VAR_DEFINE_SET ( delay )
{
SWF_TEXT_PTHIS_SET ( " delay " ) ;
pThis - > renderDelay = value . ToInteger ( ) ;
}
SWF_TEXT_NATIVE_VAR_DEFINE_GET ( delay )
{
SWF_TEXT_PTHIS_GET ( " delay " ) ;
return pThis - > renderDelay ;
}
SWF_TEXT_NATIVE_VAR_DEFINE_SET ( renderSound )
{
SWF_TEXT_PTHIS_SET ( " renderSound " ) ;
pThis - > soundClip = value . ToString ( ) ;
}
SWF_TEXT_NATIVE_VAR_DEFINE_GET ( renderSound )
{
SWF_TEXT_PTHIS_GET ( " renderSound " ) ;
return pThis - > soundClip ;
}
SWF_TEXT_NATIVE_VAR_DEFINE_SET ( updateScroll )
{
SWF_TEXT_PTHIS_SET ( " updateScroll " ) ;
pThis - > scrollUpdate = value . ToBool ( ) ;
}
SWF_TEXT_NATIVE_VAR_DEFINE_GET ( updateScroll )
{
SWF_TEXT_PTHIS_GET ( " updateScroll " ) ;
return pThis - > scrollUpdate ;
}
SWF_TEXT_NATIVE_VAR_DEFINE_GET ( mode )
{
SWF_TEXT_PTHIS_GET ( " mode " ) ;
return pThis - > renderMode ;
}
SWF_TEXT_NATIVE_VAR_DEFINE_GET ( scroll )
{
SWF_TEXT_PTHIS_GET ( " scroll " ) ;
return pThis - > scroll ;
}
SWF_TEXT_NATIVE_VAR_DEFINE_GET ( maxscroll )
{
SWF_TEXT_PTHIS_GET ( " maxscroll " ) ;
return pThis - > maxscroll ;
}
SWF_TEXT_NATIVE_VAR_DEFINE_GET ( _textLength )
{
2012-11-26 18:58:24 +00:00
SWF_TEXT_PTHIS_GET ( " _textLength " ) ;
return pThis - > GetTextLength ( ) ;
}
2012-11-28 15:47:07 +00:00
SWF_TEXT_NATIVE_VAR_DEFINE_SET ( mode )
{
2012-11-26 18:58:24 +00:00
SWF_TEXT_PTHIS_SET ( " mode " ) ;
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
int mode = value . ToInteger ( ) ;
2012-11-28 15:47:07 +00:00
if ( mode > = ( int ) SWF_TEXT_RENDER_MODE_COUNT | | mode < 0 )
{
2012-11-26 18:58:24 +00:00
mode = SWF_TEXT_RENDER_NORMAL ;
}
2012-11-28 15:47:07 +00:00
pThis - > renderMode = swfTextRenderMode_t ( mode ) ;
2012-11-26 18:58:24 +00:00
}
2012-11-28 15:47:07 +00:00
SWF_TEXT_NATIVE_VAR_DEFINE_SET ( scroll )
{
2012-11-26 18:58:24 +00:00
SWF_TEXT_PTHIS_SET ( " scroll " ) ;
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
int time = Sys_Milliseconds ( ) ;
2012-11-28 15:47:07 +00:00
if ( time > = pThis - > scrollTime )
{
2012-11-26 18:58:24 +00:00
pThis - > scrollTime = Sys_Milliseconds ( ) + swf_textScrollSpeed . GetInteger ( ) ;
pThis - > scroll = value . ToInteger ( ) ;
2012-11-28 15:47:07 +00:00
}
2012-11-26 18:58:24 +00:00
}
2012-11-28 15:47:07 +00:00
SWF_TEXT_NATIVE_VAR_DEFINE_SET ( maxscroll )
{
2012-11-26 18:58:24 +00:00
SWF_TEXT_PTHIS_SET ( " maxscroll " ) ;
pThis - > maxscroll = value . ToInteger ( ) ;
}
2012-11-28 15:47:07 +00:00
SWF_TEXT_NATIVE_VAR_DEFINE_GET ( textColor )
{
2012-11-26 18:58:24 +00:00
SWF_TEXT_PTHIS_GET ( " textColor " ) ;
int r = ( pThis - > color . r < < 16 ) ;
int g = ( pThis - > color . g < < 8 ) ;
int b = pThis - > color . b ;
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
int textColor = r | g | b ;
2012-11-28 15:47:07 +00:00
return textColor ;
2012-11-26 18:58:24 +00:00
}
2012-11-28 15:47:07 +00:00
SWF_TEXT_NATIVE_VAR_DEFINE_SET ( textColor )
{
2012-11-26 18:58:24 +00:00
SWF_TEXT_PTHIS_SET ( " textColor " ) ;
2012-11-28 15:47:07 +00:00
int textColor = value . ToInteger ( ) ;
2012-11-26 18:58:24 +00:00
int r = ( textColor > > 16 ) & 0xFF ;
int g = ( textColor > > 8 ) & 0x00FF ;
int b = textColor & 0x0000FF ;
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
pThis - > color . r = r ;
pThis - > color . g = g ;
2012-11-28 15:47:07 +00:00
pThis - > color . b = b ;
2012-11-26 18:58:24 +00:00
}
2012-11-28 15:47:07 +00:00
SWF_TEXT_FUNCTION_DEFINE ( clearTimingInfo )
{
2012-11-26 18:58:24 +00:00
SWF_TEXT_PTHIS_FUNC ( " clearTimingInfo " ) ;
pThis - > subtitleTimingInfo . Clear ( ) ;
return idSWFScriptVar ( ) ;
}
2012-11-28 15:47:07 +00:00
SWF_TEXT_FUNCTION_DEFINE ( generateRnd )
{
2012-11-26 18:58:24 +00:00
SWF_TEXT_PTHIS_FUNC ( " generateRnd " ) ;
pThis - > triggerGenerate = true ;
pThis - > rndSpotsVisible = - 1 ;
pThis - > generatingText = false ;
return idSWFScriptVar ( ) ;
}
2012-11-28 15:47:07 +00:00
SWF_TEXT_FUNCTION_DEFINE ( calcNumLines )
{
2012-11-26 18:58:24 +00:00
SWF_TEXT_PTHIS_FUNC ( " calcNumLines " ) ;
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
return pThis - > CalcNumLines ( ) ;
}
2012-11-28 15:47:07 +00:00
SWF_TEXT_FUNCTION_DEFINE ( onKey )
{
2012-11-26 18:58:24 +00:00
SWF_TEXT_PTHIS_FUNC ( " onKey " ) ;
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
int keyCode = parms [ 0 ] . ToInteger ( ) ;
bool keyDown = parms [ 1 ] . ToBool ( ) ;
2012-11-28 15:47:07 +00:00
if ( keyDown )
{
switch ( keyCode )
{
2012-11-26 18:58:24 +00:00
case K_LSHIFT :
2012-11-28 15:47:07 +00:00
case K_RSHIFT :
{
2012-11-26 18:58:24 +00:00
pThis - > shiftHeld = true ;
break ;
}
case K_BACKSPACE :
2012-11-28 15:47:07 +00:00
case K_DEL :
{
if ( pThis - > selectionStart = = pThis - > selectionEnd )
{
if ( keyCode = = K_BACKSPACE )
{
2012-11-26 18:58:24 +00:00
pThis - > selectionStart = pThis - > selectionEnd - 1 ;
2012-11-28 15:47:07 +00:00
}
else
{
2012-11-26 18:58:24 +00:00
pThis - > selectionEnd = pThis - > selectionStart + 1 ;
}
}
int start = Min ( pThis - > selectionStart , pThis - > selectionEnd ) ;
int end = Max ( pThis - > selectionStart , pThis - > selectionEnd ) ;
idStr left = pThis - > text . Left ( Max ( start , 0 ) ) ;
idStr right = pThis - > text . Right ( Max ( pThis - > text . Length ( ) - end , 0 ) ) ;
pThis - > text = left + right ;
pThis - > selectionStart = start ;
pThis - > selectionEnd = start ;
break ;
}
2012-11-28 15:47:07 +00:00
case K_LEFTARROW :
{
if ( pThis - > selectionEnd > 0 )
{
2012-11-26 18:58:24 +00:00
pThis - > selectionEnd - - ;
2012-11-28 15:47:07 +00:00
if ( ! pThis - > shiftHeld )
{
2012-11-26 18:58:24 +00:00
pThis - > selectionStart = pThis - > selectionEnd ;
}
}
break ;
}
2012-11-28 15:47:07 +00:00
case K_RIGHTARROW :
{
if ( pThis - > selectionEnd < pThis - > text . Length ( ) )
{
2012-11-26 18:58:24 +00:00
pThis - > selectionEnd + + ;
2012-11-28 15:47:07 +00:00
if ( ! pThis - > shiftHeld )
{
2012-11-26 18:58:24 +00:00
pThis - > selectionStart = pThis - > selectionEnd ;
}
}
break ;
}
2012-11-28 15:47:07 +00:00
case K_HOME :
{
2012-11-26 18:58:24 +00:00
pThis - > selectionEnd = 0 ;
2012-11-28 15:47:07 +00:00
if ( ! pThis - > shiftHeld )
{
2012-11-26 18:58:24 +00:00
pThis - > selectionStart = pThis - > selectionEnd ;
}
break ;
}
2012-11-28 15:47:07 +00:00
case K_END :
{
2012-11-26 18:58:24 +00:00
pThis - > selectionEnd = pThis - > text . Length ( ) ;
2012-11-28 15:47:07 +00:00
if ( ! pThis - > shiftHeld )
{
2012-11-26 18:58:24 +00:00
pThis - > selectionStart = pThis - > selectionEnd ;
}
break ;
}
}
2012-11-28 15:47:07 +00:00
}
else
{
if ( keyCode = = K_LSHIFT | | keyCode = = K_RSHIFT )
{
2012-11-26 18:58:24 +00:00
pThis - > shiftHeld = false ;
}
}
return true ;
}
2012-11-28 15:47:07 +00:00
SWF_TEXT_FUNCTION_DEFINE ( onChar )
{
2012-11-26 18:58:24 +00:00
SWF_TEXT_PTHIS_FUNC ( " onChar " ) ;
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
int keyCode = parms [ 0 ] . ToInteger ( ) ;
2012-11-28 15:47:07 +00:00
if ( keyCode < 32 | | keyCode = = 127 )
{
return false ;
2012-11-26 18:58:24 +00:00
}
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
char letter = ( char ) keyCode ;
// assume ` is meant for the console
2012-11-28 15:47:07 +00:00
if ( letter = = ' ` ' )
{
2012-11-26 18:58:24 +00:00
return false ;
}
2012-11-28 15:47:07 +00:00
if ( pThis - > selectionStart ! = pThis - > selectionEnd )
{
2012-11-26 18:58:24 +00:00
int start = Min ( pThis - > selectionStart , pThis - > selectionEnd ) ;
int end = Max ( pThis - > selectionStart , pThis - > selectionEnd ) ;
idStr left = pThis - > text . Left ( Max ( start , 0 ) ) ;
idStr right = pThis - > text . Right ( Max ( pThis - > text . Length ( ) - end , 0 ) ) ;
pThis - > text = left + right ;
pThis - > selectionStart = start ;
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
pThis - > text . Clear ( ) ;
pThis - > text . Append ( left ) ;
pThis - > text . Append ( letter ) ;
pThis - > text . Append ( right ) ;
pThis - > selectionStart + + ;
2012-11-28 15:47:07 +00:00
}
else if ( pThis - > selectionStart < swf_textMaxInputLength . GetInteger ( ) )
{
if ( pThis - > selectionStart < 0 )
{
2012-11-26 18:58:24 +00:00
pThis - > selectionStart = 0 ;
}
pThis - > text . Insert ( letter , pThis - > selectionStart + + ) ;
}
pThis - > selectionEnd = pThis - > selectionStart ;
return true ;
}
2012-11-28 15:47:07 +00:00
SWF_TEXT_NATIVE_VAR_DEFINE_GET ( subtitle )
{
SWF_TEXT_PTHIS_GET ( " subtitle " ) ;
return pThis - > isSubtitle ;
}
SWF_TEXT_NATIVE_VAR_DEFINE_SET ( subtitle )
{
SWF_TEXT_PTHIS_SET ( " subtitle " ) ;
pThis - > isSubtitle = value . ToBool ( ) ;
}
SWF_TEXT_NATIVE_VAR_DEFINE_GET ( subtitleAlign )
{
SWF_TEXT_PTHIS_GET ( " subtitleAlign " ) ;
return pThis - > subAlign ;
}
SWF_TEXT_NATIVE_VAR_DEFINE_SET ( subtitleAlign )
{
SWF_TEXT_PTHIS_SET ( " subtitleAlign " ) ;
pThis - > subAlign = value . ToInteger ( ) ;
}
SWF_TEXT_NATIVE_VAR_DEFINE_GET ( subtitleSourceID )
{
SWF_TEXT_PTHIS_GET ( " subtitleSourceID " ) ;
return pThis - > subSourceID ;
}
SWF_TEXT_NATIVE_VAR_DEFINE_SET ( subtitleSourceID )
{
SWF_TEXT_PTHIS_SET ( " subtitleSourceID " ) ;
pThis - > subSourceID = value . ToInteger ( ) ;
}
SWF_TEXT_NATIVE_VAR_DEFINE_GET ( subtitleSpeaker )
{
SWF_TEXT_PTHIS_GET ( " subtitleSpeaker " ) ;
return pThis - > subSpeaker . c_str ( ) ;
}
SWF_TEXT_NATIVE_VAR_DEFINE_SET ( subtitleSpeaker )
{
SWF_TEXT_PTHIS_SET ( " subtitleSpeaker " ) ;
pThis - > subSpeaker = value . ToString ( ) ;
}
2012-11-26 18:58:24 +00:00
2012-11-28 15:47:07 +00:00
SWF_TEXT_FUNCTION_DEFINE ( subtitleLength )
{
2012-11-26 18:58:24 +00:00
SWF_TEXT_PTHIS_FUNC ( " subtitleLength " ) ;
pThis - > subLength = parms [ 0 ] . ToInteger ( ) ;
return idSWFScriptVar ( ) ;
}
2012-11-28 15:47:07 +00:00
SWF_TEXT_FUNCTION_DEFINE ( subtitleSourceCheck )
{
2012-11-26 18:58:24 +00:00
SWF_TEXT_PTHIS_FUNC ( " subtitleSourceCheck " ) ;
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
int idCheck = parms [ 0 ] . ToInteger ( ) ;
2012-11-28 15:47:07 +00:00
if ( pThis - > subSourceID = = - 1 )
{
2012-11-26 18:58:24 +00:00
pThis - > subSourceID = idCheck ;
return 1 ;
}
2012-11-28 15:47:07 +00:00
if ( idCheck = = pThis - > subSourceID ) // || pThis->subForceKill ) {
{
2012-11-26 18:58:24 +00:00
pThis - > SubtitleComplete ( ) ;
pThis - > subSourceID = idCheck ;
return - 1 ;
}
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
return 0 ;
}
2012-11-28 15:47:07 +00:00
SWF_TEXT_FUNCTION_DEFINE ( subtitleStart )
{
2012-11-26 18:58:24 +00:00
SWF_TEXT_PTHIS_FUNC ( " subtitleStart " ) ;
pThis - > subUpdating = true ;
pThis - > subNeedsSwitch = false ;
pThis - > subForceKillQueued = false ;
pThis - > subForceKill = false ;
pThis - > subKillTimeDelay = 0 ;
// trickery to swap the text so subtitles don't show until they should
pThis - > subtitleText = pThis - > text ;
pThis - > text = " " ;
pThis - > subCharStartIndex = 0 ;
pThis - > subNextStartIndex = 0 ;
pThis - > subCharEndIndex = 0 ;
pThis - > subSwitchTime = 0 ;
pThis - > subLastWordIndex = 0 ;
pThis - > subPrevLastWordIndex = 0 ;
pThis - > subStartTime = - 1 ;
pThis - > subInitialLine = true ;
return idSWFScriptVar ( ) ;
}
2012-11-28 15:47:07 +00:00
SWF_TEXT_FUNCTION_DEFINE ( forceKillSubtitle )
{
2012-11-26 18:58:24 +00:00
SWF_TEXT_PTHIS_FUNC ( " forceKillSubtitle " ) ;
pThis - > subForceKill = true ;
pThis - > subKillTimeDelay = 0 ;
return idSWFScriptVar ( ) ;
}
2012-11-28 15:47:07 +00:00
SWF_TEXT_FUNCTION_DEFINE ( killSubtitle )
{
2012-11-26 18:58:24 +00:00
SWF_TEXT_PTHIS_FUNC ( " killSubtitle " ) ;
pThis - > subForceKillQueued = true ;
//pThis->SubtitleComplete();
return idSWFScriptVar ( ) ;
}
2012-11-28 15:47:07 +00:00
SWF_TEXT_FUNCTION_DEFINE ( terminateSubtitle )
{
2012-11-26 18:58:24 +00:00
SWF_TEXT_PTHIS_FUNC ( " terminateSubtitle " ) ;
pThis - > SubtitleComplete ( ) ;
pThis - > SubtitleCleanup ( ) ;
return idSWFScriptVar ( ) ;
}
2012-11-28 15:47:07 +00:00
SWF_TEXT_FUNCTION_DEFINE ( subLastLine )
{
2012-11-26 18:58:24 +00:00
SWF_TEXT_PTHIS_FUNC ( " subLastLine " ) ;
idStr lastLine ;
int len = pThis - > subCharEndIndex - pThis - > subCharStartIndex ;
pThis - > text . Mid ( pThis - > subCharStartIndex , len , lastLine ) ;
return lastLine ;
}
2012-11-28 15:47:07 +00:00
SWF_TEXT_FUNCTION_DEFINE ( addSubtitleInfo )
{
2012-11-26 18:58:24 +00:00
SWF_TEXT_PTHIS_FUNC ( " addSubtitleInfo " ) ;
2012-11-28 15:47:07 +00:00
if ( parms . Num ( ) ! = 3 )
{
2012-11-26 18:58:24 +00:00
return idSWFScriptVar ( ) ;
}
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
subTimingWordData_t info ;
info . phrase = parms [ 0 ] . ToString ( ) ;
info . startTime = parms [ 1 ] . ToInteger ( ) ;
info . forceBreak = parms [ 2 ] . ToBool ( ) ;
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
pThis - > subtitleTimingInfo . Append ( info ) ;
return idSWFScriptVar ( ) ;
}