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

Speedo.HUDSpeedo


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
//
// Shows a speedo in the hud
//
class HUDSpeedo extends TribesGUI.HUDContainer;

// sub components
var HUDNumericTextureLabel	SpeedLabel;
var LabelElement			UnitsLabel;

// unit configuration
var config String	UnitsText;				// text displayed after the value (eg: KM/h)
var config float	UnitsRatio;				// ratio of these units to unreal units
var config int		VisibleThreshold;		// Speed you have to be travelling for the speedo to be visible
var config int		VisibleThresholdRange;	// range below VisibleThreshold through which the speedo will fade in

var int Velocity;

function InitElement()
{
	SpeedLabel = HUDNumericTextureLabel(AddElement("TribesGUI.HUDNumericTextureLabel", "ext_Speedo_SpeedLabel"));
	UnitsLabel = LabelElement(AddElement("TribesGUI.LabelElement", "ext_Speedo_UnitsLabel"));
}

function UpdateData(ClientSideCharacter csc)
{
	local String VelocityText;

	Velocity = int(csc.Velocity) * UnitsRatio;
	if( Velocity < 10 )
		VelocityText = "00"$string(Velocity);
	else if( Velocity < 100 )
		VelocityText = "0"$string(Velocity);
	else
		VelocityText = string(Velocity);

	SetAlpha(FClamp((Velocity - VisibleThreshold - VisibleThresholdRange) / VisibleThresholdRange, 0.0, 1.0));

	SpeedLabel.SetDataString(VelocityText);
	UnitsLabel.SetText(UnitsText);
}

defaultproperties
{
	UnitsText="KM/h"
	UnitsRatio=1.0
	VisibleThreshold=30
	VisibleThresholdRange=10
}

Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames
Class file time: ne 5.9.2004 15:53:46.000 - Creation time: st 23.5.2018 00:10:44.471 - Created with UnCodeX