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

MojoActions.TsActionSubtitle


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
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
class TsActionSubtitle extends TsCameraAction;

var() string Filename			"Name of the localization file (do not include the .int)";
var() string SectionName		"SectionName under which the text resides";
var() string TextName			"The name of the text to display";
var() string Path				"The path of the localization file. You don't usually need to change this.";
var() string FontName			"Name of font to use";
var() Color ForegroundColor;
var() Color BackgroundColor;
var() int Wrap					"Set to 1 to have the text wrap around";
var() int Center				"Set to 1 to center the text within the draw area";

var() float FadeInTime;
var() float FadeHoldTime;
var() float FadeOutTime;

var() float DrawX				"Choose a value from 0 to 1";
var() float DrawY				"Choose a value from 0 to 1";
var() float DrawSizeX			"Choose a value from 0 to 1";
var() float DrawSizeY			"Choose a value from 0 to 1";

var float totalTime;
var transient MessageRouter Router;
var float alpha;
var string textString;
var Font Font;

function bool OnStart()
{
	local string LocalFontName;
	local Font NewFont;

	textString = Localize(SectionName, TextName, Path $ "/" $ Filename);

	if (Font == None)
	{
		// get the *real* name of the font from the localisation file
		LocalFontName = Localize("Fonts", FontName, "Localisation\\GUI\\Fonts");

		// load the new font
		NewFont = Font(DynamicLoadObject(LocalFontName, class'Font'));
		if(NewFont == None)
			Log("Warning: "$Self$" Couldn't dynamically load font "$LocalFontName);
		else
			font = NewFont;

		// font is still none - give it a fallback
		if(font == None)
			font = Font(DynamicLoadObject("Engine_res.Res_DefaultFont", class'Font'));
	}

	totalTime = 0;
	alpha = 0;
	if (Router == None)
	{
		Router = Actor.spawn(class'MessageRouter');
		Router.Set(self, class'MessagePostRenderFinal', "all");
	}

	return true;
}

function bool OnTick(float delta)
{
	totalTime += delta;

	if (totalTime > fadeInTime + fadeHoldTime + fadeOutTime)
	{
		return false;
	}

	if (totalTime < fadeInTime)
	{
		alpha = totalTime / fadeInTime;
	}
	else if (totalTime < fadeInTime + fadeHoldTime)
	{
		alpha = 1.0;
	}
	else
	{
		alpha = 1.0 - ((totalTime - (fadeInTime + fadeHoldTime)) / fadeOutTime);
	}

	return true;
}

function OnFinish()
{
	if (Router != None)
	{
		Router.Destroy();
		Router = None;
	}
}

function Interrupt()
{
	OnFinish();
}

event OnDelete()
{
	OnFinish();
}

function Message(Message msg)
{
	local MessagePostRenderFinal m;
	local Vector v;
	local Color fore;
	local Color back;
	local float ClipX;
	local float ClipY;

	m = MessagePostRenderFinal(msg);

	ClipX = m.Canvas.ClipX;
	ClipY = m.Canvas.ClipY;

	m.Canvas.CurX = 0;
	m.Canvas.CurY = 0;
	m.Canvas.ClipX = drawSizeX * m.Canvas.SizeX;
	m.Canvas.ClipY = drawSizeY * m.Canvas.SizeY;
	m.Canvas.Style = Actor.ERenderStyle.STY_Alpha;
	m.Canvas.DrawColor.R = 255;
	m.Canvas.DrawColor.G = 255;
	m.Canvas.DrawColor.B = 255;
	m.Canvas.DrawColor.A = 255;
	m.Canvas.Font = Font;

	fore = ForegroundColor;
	fore.A = float(fore.A) * alpha;
	back = BackgroundColor;
	back.A = float(back.A) * alpha;

	v.x = drawX * m.Canvas.SizeX;
	v.y = drawY * m.Canvas.SizeY;

	m.Canvas.DrawTextMultiline(
						textString,
						v,
						fore,
						back,
						Wrap,
						Center
					);

	m.Canvas.ClipX = ClipX;
	m.Canvas.ClipY = ClipY;
}

defaultproperties
{
	DName			="Subtitle"
	Track			="Effects"
	Help			="Draws a text subtitle on the screen."

	SectionName		="Cutscenes"
	Path			="Localisation/Cutscenes/text files"

	Font			=Font'Engine_res.Res_DefaultFont'

	fadeInTime		=1
	fadeHoldTime	=3
	fadeOutTime		=1

	ForegroundColor	=(R=255,G=255,B=255,A=255)
	BackgroundColor	=(R=0,G=0,B=0,A=0)

	drawX			=0.1
	drawY			=0.85
	drawSizeX		=0.8
	drawSizeY		=0.2

	Wrap			=1
	Center			=1
}

Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames
Class file time: čt 7.10.2004 10:30:36.000 - Creation time: st 23.5.2018 00:10:49.431 - Created with UnCodeX