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

TribesGUI.HUDObjectiveList


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
class HUDObjectiveList extends HUDList;

import enum EObjectiveStatus from ObjectiveInfo;
import enum EObjectiveType from ObjectiveInfo;
import enum EIconType from RadarInfo;

var() config HUDMaterial completedObjectiveIconOverlay;

var() config EObjectiveType typeMask;
var() config Color completedDrawColor;
var() config Color failedDrawColor;
var() config Color activeDrawColor;

// columns
var HUDList iconList;
var HUDList textList;

function InitElement()
{
	super.InitElement();

	iconList = HUDList(AddClonedElement("TribesGUI.HUDList", "default_objectiveIconColumn"));

	textList = HUDList(AddClonedElement("TribesGUI.HUDList", "default_objectiveTextColumn"));
}

function SetObjective(EObjectiveStatus status, class<RadarInfo> radarInfo, String text, int index, int state, bool isFriendly, bool bForceFlash, class<TeamInfo> teamInfoClass)
{
	local LabelElement newLabel;
	local HUDIcon objectiveIcon;

	if(textList.children.Length > index)
	{
		objectiveIcon = HUDIcon(iconList.children[index]);

		if(radarInfo != None)
		{
			if(teamInfoClass != None)
				HUDIcon(iconList.children[index]).iconMaterial = class'HUDRadarBase'.static.GetHUDMaterial(radarInfo, state, isFriendly, ICON_Radar, TeamInfoClass.default.TeamColor, LocalData.UserPrefColorType, bForceFlash);
			else
				HUDIcon(iconList.children[index]).iconMaterial = class'HUDRadarBase'.static.GetHUDMaterial(radarInfo, state, isFriendly, ICON_Radar, LocalData.ownTeamColor, COLOR_Neutral, bForceFlash);
		}
		else
			HUDIcon(iconList.children[index]).iconMaterial.Material = None;

		LabelElement(textList.children[index]).SetText(text);

		switch(status)
		{
		case ObjectiveStatus_Active:
			LabelElement(textList.children[index]).textColor = activeDrawColor;
			break;
		case ObjectiveStatus_Completed:
			LabelElement(textList.children[index]).textColor = completedDrawColor;
			HUDIcon(iconList.children[index]).iconMaterial.drawColor = completedDrawColor;
			HUDIcon(iconList.children[index]).foregroundTexture = completedObjectiveIconOverlay;
			break;
		case ObjectiveStatus_Failed:
			LabelElement(textList.children[index]).textColor = failedDrawColor;
			HUDIcon(iconList.children[index]).iconMaterial.drawColor = failedDrawColor;
			break;
		}
	}
	else
	{
		objectiveIcon = HUDIcon(iconList.AddClonedElement("TribesGUI.HUDIcon", "default_ObjectiveIcon"));
		if(radarInfo != None)
		{
			if(teamInfoClass != None)
				objectiveIcon.iconMaterial = class'HUDRadarBase'.static.GetHUDMaterial(radarInfo, state, isFriendly, ICON_Radar, TeamInfoClass.default.TeamColor, LocalData.UserPrefColorType, bForceFlash);
			else
				objectiveIcon.iconMaterial = class'HUDRadarBase'.static.GetHUDMaterial(radarInfo, state, isFriendly, ICON_Radar, LocalData.ownTeamColor, COLOR_Neutral, bForceFlash);
		}

		newLabel = LabelElement(textList.AddClonedElement("TribesGUI.LabelElement", "default_ObjectiveTextLabel"));
		newLabel.bAutoSize = false;
		newLabel.SetText(text);

		switch(status)
		{
		case ObjectiveStatus_Active:
			newLabel.textColor = activeDrawColor;
			break;
		case ObjectiveStatus_Completed:
			newLabel.textColor = completedDrawColor;
			objectiveIcon.iconMaterial.DrawColor = completedDrawColor;
			objectiveIcon.foregroundTexture = completedObjectiveIconOverlay;
			break;
		case ObjectiveStatus_Failed:
			newLabel.textColor = failedDrawColor;
			objectiveIcon.iconMaterial.DrawColor = failedDrawColor;
			break;
		}

		SetNeedsLayout();
	}

	// flash the material, if neccesary
	if(objectiveIcon.IconMaterial.bFading)
	{
		objectiveIcon.IconMaterial.fadeStartTime = TimeSeconds - (TimeSeconds % objectiveIcon.IconMaterial.fadeDuration);
		objectiveIcon.IconMaterial.fadeProgress = FClamp((TimeSeconds - objectiveIcon.IconMaterial.fadeStartTime) / objectiveIcon.IconMaterial.fadeDuration, 0.f, 1.f);
	}
}

function RemoveObjective(int index)
{
	iconList.RemoveElementAt(index);
	textList.RemoveElementAt(index);
}

function UpdateData(ClientSideCharacter c)
{
	local int i, listIndex;
	local class<RadarInfo> radarInfoClass;
	local ClientSideCharacter.ClientObjectiveInfo nextObjective;

	super.UpdateData(c);

	// add the objectives
	for(i = 0; i < c.ObjectiveData.Length; ++i)
	{
		nextObjective = c.ObjectiveData[i]; 

		// only add objectives with the same type as the mask
		if(typeMask == nextObjective.type)
		{
			radarInfoClass = class<RadarInfo>(nextObjective.RadarInfoClass);
			SetObjective(nextObjective.Status, radarInfoClass, nextObjective.Description, listIndex++, nextObjective.State, nextObjective.IsFriendly, nextObjective.bFlashing, nextObjective.TeamInfoClass);
		}
	}

	// have to dump any objectives which are remaining in the list:
	for(i = textList.children.Length - 1; i >= listIndex; --i)
		RemoveObjective(i);

	bVisible = (textList.children.Length > 0);
}

defaultproperties
{
	completedDrawColor=(R=135,G=135,B=135,A=255)
	failedDrawColor=(R=255,G=0,B=0,A=255)
	activeDrawColor=(R=255,G=255,B=255,A=255)

	completedObjectiveIconOverlay=(Material=texture'HUD.Radar',Coords=(U=49,V=218,UL=22,VL=22),style=1,drawColor=(R=0,G=255,B=0,A=255))

	bAutoHeight=true
}

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.388 - Created with UnCodeX