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

TribesGUI.HUDExtendableValueBar


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
//
// A HUDValueBar that can be of any length, useful for
// health and energy bars which can be different lengths
//
class HUDExtendableValueBar extends HUDValueBar;

var() config float		pixValueRatio	"Ratio of a pixel to the bar value units";

var() config MatCoords	iconCoords		"texture coordinates (in pixels) of the icon at the start of the bar";
var() config MatCoords	tileCoords		"texture coordinates (in pixels) of the section to tile in the middle of the bar";
var() config MatCoords	capCoords		"texture coordinates (in pixels) of the cap on the end of the bar";

var float oldMaximumValue;

//
// We need to check each time the data changes, because
// if the max value has changed a new layout must be calculated
//
function UpdateData(ClientSideCharacter c)
{
	super.UpdateData(c);
/*
	if(oldMaximumValue != maximumValue)
	{
		SetNeedsLayout();
		oldMaximumValue = maximumValue;
	}
	*/
}
/*
//
// Layout the component
// Overridden to set the width based on the max value and
// the ratio of pixels to value units
//
event DoLayout(Canvas c)
{
	if(ParentElement != None)
		Width = (maximumValue * pixValueRatio);
	else // should never go to the else, but cover it anyway:
		Width = (maximumValue * pixValueRatio);
	initialWidth = Width;

	super.DoLayout(c);
}
*/
//
// Override RenderBarLayer to handle the extended texture
//
function RenderBarLayer(Canvas C, out HUDMaterial mat)
{
	local float capWidth, iconWidth, tileWidth;
	local float oldClipX;

	iconWidth = iconCoords.UL * Height / mat.material.GetVSize();
	capWidth = capCoords.UL * Height / mat.material.GetVSize();
	tileWidth = tileCoords.UL * Height / mat.material.GetVSize();

	// render the start icon
	oldClipX = C.ClipX;
	if(C.ClipX >= iconWidth)
		C.ClipX = iconWidth;
	C.CurX = 0;
	C.CurY = 0;
	mat.coords = iconCoords;
	RenderHUDMaterial(C, mat, iconWidth, Height);
	C.ClipX = oldClipX;

	//
	// Tile the actual bar section as far as it needs to go
	oldClipX = C.ClipX;
	if(C.ClipX >= (Width - capWidth))
		C.ClipX = (Width - capWidth);
	C.CurX = iconWidth;
	C.CurY = 0;
	SetColor(c, mat.drawColor);
	mat.coords = tileCoords;
	RenderHUDMaterial(C, mat, tileWidth, Height, Width, 0); // tile to the width

	//
	// Draw the cap on the end of the bar
	C.ClipX = oldClipX;
	if(C.ClipX >= Width - capWidth)
	{
		C.CurX = Width - capWidth;
		C.CurY = 0;

		// set texture co-ords and render
		mat.coords = capCoords;
		RenderHUDMaterial(C, mat, capWidth, Height);
	}

	mat.coords.U = 0;
	mat.coords.V = 0;
	mat.coords.UL = 0;
	mat.coords.VL = 0;

	C.CurX = 0;
	C.CurY = 0;
}

defaultproperties
{
	iconCoords=(U=0,V=0,UL=60,VL=64)
	tileCoords=(U=60,V=0,UL=800,VL=64)
	capCoords=(U=1000,V=0,UL=24,VL=64)

	pixValueRatio	= 2.1		// 1.25 pixels to a unit
}

Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames
Class file time: st 16.4.2014 10:20:44.000 - Creation time: st 23.5.2018 00:10:44.288 - Created with UnCodeX