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

TribesGUI.HUDWeaponReticule


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
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224
00225
00226
00227
00228
00229
00230
00231
00232
00233
00234
00235
00236
00237
00238
00239
00240
00241
00242
00243
00244
00245
00246
00247
00248
00249
00250

//
// class: HUDWeaponReticule
//
// Reticule for a weapon, also indicates when an enemy is damaged.
//
class HUDWeaponReticule extends HUDReticule;

var bool			bZoomed;
var bool			bOutOfAmmo;

// hit feedback
var() config float	reticuleHitFeedbackFlashTime;
var HUDMaterial		reticuleHitFeedbackMaterial;
var float			retHitWidth;
var float			retHitHeight;
var float			hitTime;

// no weapon reticule
var Material		NoWeaponReticuleMaterial;

// no ammo indicator
var() config HUDMaterial	NoAmmoIndicatorMaterial;

// spread info
var() config int	MaxSpreadSize;
var HUDMaterial		ReticuleTopLeft;
var HUDMaterial		ReticuleTopRight;
var HUDMaterial		ReticuleBottomLeft;
var HUDMaterial		ReticuleBottomRight;
var float			SpreadAmount;

// zoom info
var() config HUDMaterial	zoomBlurMaterial;
var() config HUDMaterial	zoomReticuleMaterial;
var() config int			zoomReticuleWidth;
var() config int			zoomReticuleHeight;
var() config int			zoomReticuleCenterX;
var() config int			zoomReticuleCenterY;

var LabelElement	zoomMagnificationLabel;


function InitElement()
{
	super.InitElement();

	reticuleMaterial = MakeHUDMaterial(None);
	
	zoomMagnificationLabel = LabelElement(AddElement("TribesGUI.LabelElement", "default_zoomMagnificationLabel"));
}

function UpdateReticule(ClientSideCharacter c)
{
	local int HalfRetSize;

	// deployable reticule active, dont show weapon reticule
	if(c.bDeployableActive && ! c.bZoomed)
	{
		bOutOfAmmo = false;
		bVisible = false;
		return;
	}

	bVisible = true;
	bZoomed = c.bZoomed;
	zoomMagnificationLabel.bVisible = bZoomed;

	if(c.activeWeapon.type == None)
	{
		// this is the no-weapon reticule
		reticuleMaterial.material = NoWeaponReticuleMaterial;
		retWidth = NoWeaponReticuleMaterial.GetUSize();
		retHeight = NoWeaponReticuleMaterial.GetVSize();
		hotspotX = retWidth * 0.5;
		hotspotY = retHeight * 0.5;
		bOutOfAmmo = false;

		return;
	}


	retWidth = c.activeWeapon.type.default.hudReticuleWidth;
	retHeight = c.activeWeapon.type.default.hudReticuleHeight;
	hotspotX = c.activeWeapon.type.default.hudReticuleCenterX;
	hotspotY = c.activeWeapon.type.default.hudReticuleCenterY;
	if(bZoomed)
	{
		zoomMagnificationLabel.SetText("x"@c.zoomMagnificationLevel);
	}
	else if(c.activeWeapon.type != None)
	{
		// general reticule stuff
		reticuleMaterial.material = c.activeWeapon.type.default.hudReticule;

		SpreadAmount = c.activeWeapon.Spread;
		if(SpreadAmount > 0)
		{
			HalfRetSize = Min(c.ActiveWeapon.type.default.hudReticule.GetUSize(), c.ActiveWeapon.type.default.hudReticule.GetVSize()) * 0.5;

			ReticuleTopLeft.Material = c.ActiveWeapon.type.default.hudReticule;
			ReticuleTopLeft.Coords.U = 0;
			ReticuleTopLeft.Coords.V = 0;
			ReticuleTopLeft.Coords.UL = HalfRetSize - 2;
			ReticuleTopLeft.Coords.VL = HalfRetSize - 2;
			ReticuleTopLeft.fadeProgress = SpreadAmount;

			ReticuleTopRight.Material = c.ActiveWeapon.type.default.hudReticule;
			ReticuleTopRight.Coords.U = HalfRetSize + 2;
			ReticuleTopRight.Coords.V = 0;
			ReticuleTopRight.Coords.UL = HalfRetSize - 2;
			ReticuleTopRight.Coords.VL = HalfRetSize - 2;
			ReticuleTopRight.fadeProgress = SpreadAmount;

			ReticuleBottomLeft.Material = c.ActiveWeapon.type.default.hudReticule;
			ReticuleBottomLeft.Coords.U = 0;
			ReticuleBottomLeft.Coords.V = HalfRetSize + 2;
			ReticuleBottomLeft.Coords.UL = HalfRetSize - 2;
			ReticuleBottomLeft.Coords.VL = HalfRetSize - 2;
			ReticuleBottomLeft.fadeProgress = SpreadAmount;

			ReticuleBottomRight.Material = c.ActiveWeapon.type.default.hudReticule;
			ReticuleBottomRight.Coords.U = HalfRetSize;
			ReticuleBottomRight.Coords.V = HalfRetSize;
			ReticuleBottomRight.Coords.UL = HalfRetSize;
			ReticuleBottomRight.Coords.VL = HalfRetSize;
			ReticuleBottomRight.fadeProgress = SpreadAmount;
		}
	}

	// hit indicator stuff
	retHitWidth = reticuleHitFeedbackMaterial.material.GetUSize() * retWidth / reticuleMaterial.material.GetUSize();
	retHitHeight = reticuleHitFeedbackMaterial.material.GetVSize() * retWidth / reticuleMaterial.material.GetUSize();

	if(c.bHitObject)
	{
		hitTime = timeSeconds;
		ResetHUDMaterial(reticuleHitFeedbackMaterial);
		c.bHitObject = false;
	}

	// show the out of ammo indicator even when zoomed
	if(c.activeWeapon.type != None)
	{
		bOutOfAmmo = (c.activeWeapon.type.default.ammoUsage > 0) && (c.activeWeapon.ammo <= 0);

		if(bOutOfAmmo && c.activeWeapon.refireTime > c.activeWeapon.timeSinceLastFire)
		{
			if(NoAmmoIndicatorMaterial.fadeProgress == 1.0)
			{
				ResetHUDMaterial(NoAmmoIndicatorMaterial);
				NoAmmoIndicatorMaterial.fadeDuration = c.activeWeapon.refireTime;
			}
		}
	}
}

function RenderElement(Canvas c)
{
	local int ReticuleSize, HalfReticuleSize, CurrentSpreadSize;
	local int ReticuleX, ReticuleY;

	ReticuleX = ((Width - retWidth) / 2) + ((retWidth / 2) - HotspotX);
	ReticuleY = ((Height - retHeight) / 2) + ((retHeight / 2) - HotspotY);
	ReticuleSize = Min(retWidth, retHeight);

	if(bZoomed)
	{
		c.CurX = 0;
		c.CurY = 0;
		RenderHUDMaterial(c, zoomBlurMaterial, screenWidth, screenHeight);

		c.CurX = ((Width - retWidth) / 2) + ((retWidth / 2) - zoomReticuleCenterX);
		c.CurY = ((Height - retHeight) / 2) + ((retHeight / 2) - zoomReticuleCenterY);
		RenderHUDMaterial(c, zoomReticuleMaterial, zoomReticuleWidth, zoomReticuleHeight);
	}
	else
	{
		// render the reticule
		super.RenderElement(c);

		ReticuleSize = Min(retWidth, retHeight);
		HalfReticuleSize = ReticuleSize * 0.5;

		// render weapon spread
		if(SpreadAmount > 0)
		{
			CurrentSpreadSize = SpreadAmount * (MaxSpreadSize - ReticuleSize) * 0.5;

			// top left quadrant			
			c.CurX = ReticuleX - CurrentSpreadSize;
			c.CurY = ReticuleY - CurrentSpreadSize;
			RenderHUDMaterial(c, ReticuleTopLeft, HalfReticuleSize, HalfReticuleSize);

			// top right quadrant
			c.CurX = ReticuleX + (ReticuleSize * 0.5) + CurrentSpreadSize;
			c.CurY = ReticuleY - CurrentSpreadSize;
			RenderHUDMaterial(c, ReticuleTopRight, HalfReticuleSize, HalfReticuleSize);

			// bottom left quadrant
			c.CurX = ReticuleX - CurrentSpreadSize;
			c.CurY = ReticuleY + (ReticuleSize * 0.5) + CurrentSpreadSize;
			RenderHUDMaterial(c, ReticuleBottomLeft, HalfReticuleSize, HalfReticuleSize);

			// bottom right quadrant
			c.CurX = ReticuleX + (ReticuleSize * 0.5) + CurrentSpreadSize;
			c.CurY = ReticuleY + (ReticuleSize * 0.5) + CurrentSpreadSize;
			RenderHUDMaterial(c, ReticuleBottomRight, HalfReticuleSize, HalfReticuleSize);
		}
	}

	// render the reticule hit feedback if flash time is still valid
	if(hitTime + reticuleHitFeedbackFlashTime > timeSeconds)
	{
		c.CurX = ((Width - retHitWidth) / 2);
		c.CurY = ((Height - retHitHeight) / 2);
		RenderHUDMaterial(c, reticuleHitFeedbackMaterial, retHitWidth, retHitHeight);
	}

	// render out of ammo indicator
	if(bOutOfAmmo)
	{
		c.CurX = ReticuleX;
		c.CurY = ReticuleY;
		RenderHUDMaterial(c, NoAmmoIndicatorMaterial, ReticuleSize, ReticuleSize);
	}
}

defaultproperties
{
	NoWeaponReticuleMaterial=texture'HUD.ReticuleNone'

	reticuleHitFeedbackMaterial=(material=texture'HUD.Hit',drawColor=(R=255,G=255,B=255,A=255),style=1,fadeDuration=0.2,bFading=true,fadeSourceColor=(R=255,G=255,B=255,A=255),fadeTargetColor=(R=255,G=255,B=255,A=1))
	reticuleHitFeedbackFlashTime=0.2

	NoAmmoIndicatorMaterial=(material=texture'HUD.ReticuleCross',drawColor=(R=255,G=255,B=255,A=75),style=1,fadeDuration=0.2,bFading=true,fadeSourceColor=(R=255,G=255,B=255,A=255),fadeTargetColor=(R=255,G=255,B=255,A=75))

	zoomBlurMaterial=(material=texture'HUD.ZoomBorder',drawColor=(R=255,G=255,B=255,A=255),style=1)
	zoomReticuleMaterial=(material=texture'HUD.Zoom',drawColor=(R=255,G=255,B=255,A=255),style=1)
	zoomReticuleWidth=256
	zoomReticuleHeight=256
	zoomReticuleCenterX=128
	zoomReticuleCenterY=128

	ReticuleTopLeft=(drawColor=(R=255,G=255,B=255,A=255),style=1,bProgressControlled=true,bFading=true,fadeSourceColor=(R=255,G=255,B=255,A=45),fadeTargetColor=(R=255,G=255,B=255,A=255))
	ReticuleTopRight=(drawColor=(R=255,G=255,B=255,A=255),style=1,bProgressControlled=true,bFading=true,fadeSourceColor=(R=255,G=255,B=255,A=45),fadeTargetColor=(R=255,G=255,B=255,A=255))
	ReticuleBottomLeft=(drawColor=(R=255,G=255,B=255,A=255),style=1,bProgressControlled=true,bFading=true,fadeSourceColor=(R=255,G=255,B=255,A=45),fadeTargetColor=(R=255,G=255,B=255,A=255))
	ReticuleBottomRight=(drawColor=(R=255,G=255,B=255,A=255),style=1,bProgressControlled=true,bFading=true,fadeSourceColor=(R=255,G=255,B=255,A=45),fadeTargetColor=(R=255,G=255,B=255,A=255))
	MaxSpreadSize=384
}

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