Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames

XInterface.GUISubtitleText


00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
//==============================================================================
// A timed label used to display subtitles
//
// Written by Michiel Hendriks
// (c) 2003, Epic Games, Inc.  All Rights Reserved
//==============================================================================

class GUISubtitleText extends GUILabel;

/** each subtitle on a diffirent line */
var() array<string> SubTitles;
/** 
	Visible is the time this subtitle is vissible
	Delay is the time to wait to display the next sub title
*/
struct VisibleDelay
{
	var float Visible;
	var float Delay;
};
/** time to show a single subtitle */
var() array<VisibleDelay> SubTitleTiming;
/** default subtitle visibility, if <= 0 remain visible */
var() float VisibleTime;
/** default delay time */
var() float DelayTime;
/** initial delay */
var() float InitialDelay;
/** use by SetSubTitles to guess the delay, delay = guess time * no. chars */
var() float GuessCharTime;
/** default seperator */
var string Separator;

var protected int CurLine;
var protected enum eDisplayState {
	DS_Delay,
	DS_Visibility,
	DS_Stopped,
} DisplayState;

delegate OnStopped();

function Restart()
{
	CurLine = 0;
	Caption = "";
	DisplayState = DS_Delay;
	if (InitialDelay <= 0.0) SetTimer(0.001, true);
	else SetTimer(InitialDelay, true);
}

function Stop()
{
	Caption="";
	TimerInterval = 0;
	DisplayState = DS_Stopped;
	OnStopped();	
}

/** 
	Set the subtitles, using default timing 
	if bDontGuess == true lengthdata will be used (uses the same seperator)
	Return the number of items added
*/
function int SetSubtitles(string alldata, optional string sep, optional bool bDontGuess, optional string lengthdata)
{
	local array<string> newdata, datalength;
	local int i;
	if (sep == "") sep = Separator;
	split(alldata, sep, newdata);
	if (bDontGuess)	
	{
		split(lengthdata, sep, datalength);
		datalength.length = newdata.length;
	}
	ClearSubtitles();
	for (i = 0; i < newdata.length; i++)
	{
		if (bDontGuess)	AddSubtitle(newdata[i], float(datalength[i]));
			else 	AddSubtitle(newdata[i], GuessCharTime*Len(newdata[i]));
	}
	Restart();
	return i;
}

/** 
	Add a subtitle 
	if delay/visible is omitted or 0 the default value is used
	to have an actual 0 as visible/delay use a negative value
*/
function int AddSubtitle(string NewTitle, optional float delay, optional float Visible)
{
	return InsertSubtitle(SubTitles.length, NewTitle, delay, Visible);
}

/** 
	Insert a subtitle
	If the position is invalid -1 is returned
*/
function int InsertSubtitle(int position, string NewTitle, optional float delay, optional float Visible)
{
	if (position > SubTitles.Length) return -1;
	if (position < 0) return -1;	
	SubTitles.Insert(position, 1);
	SubTitleTiming.Insert(position, 1);
	SubTitles[position] = NewTitle;
	if (delay == 0) delay = DelayTime;
	SubTitleTiming[position].Delay = Max(delay, 0);
	if (visible == 0) visible = VisibleTime;
	if (visible >= delay) visible = 0;
	SubTitleTiming[position].Visible = Max(visible, 0);	
	//Log(":::: Added new subtitle: '"$NewTitle$"'"@delay@Visible@position);
	return position;
}

function ClearSubtitles()
{
	SubTitles.length = 0;
	SubTitleTiming.length = 0;
}

event Timer()
{
	if (CurLine >= SubTitles.length) 
	{
		Caption="";
		TimerInterval = 0;
		DisplayState = DS_Stopped;
		OnStopped();
		return;
	}
	if (DisplayState == DS_Delay)
	{
		Caption = SubTitles[CurLine];
		if (SubTitleTiming[CurLine].Visible > 0)
		{
			DisplayState = DS_Visibility;
			TimerInterval = SubTitleTiming[CurLine].Visible;
		}
		else {
			TimerInterval = SubTitleTiming[CurLine].delay;
			CurLine++;			
		}
	}
	else if (DisplayState == DS_Visibility) {
		Caption = "";
		DisplayState = DS_Delay;
		TimerInterval = SubTitleTiming[CurLine].delay-SubTitleTiming[CurLine].Visible;
		CurLine++;
	}
}

defaultproperties
{
	TextAlign=TXTA_Center
	InitialDelay=0
	GuessCharTime=0.06
	DelayTime=2
	VisibleTime=0
	bTransparent=true
	bMultiLine=true
	Separator="|"
	StyleName="TextLabel"
}

Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames
Class file time: Di 5.9.2006 22:36:28.000 - Creation time: Do 14.8.2014 09:58:40.282 - Created with UnCodeX