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

TribesGUI.TribesRespawnHUDScript


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
class TribesRespawnHUDScript extends TribesCommandHUDScript;

var LabelElement PromptLabel;
var LabelElement PromptLabelLarge;
var ClientSideCharacter csc;

var localized string CountdownText;
var localized string PromptText;
var localized string CancelText;
var localized string RespawnLimitText;
var localized string ClickToSeeMapText;
var localized string NoMoreFuelText;
var localized string InstantRespawnText;
var localized string RoundStartText;

var int ExitRespawnKeyBinding;
var bool bShowingRespawnMap;

var ClientSideCharacter localData;
var HUDRespawnAction ActionHandler;

overloaded function Construct()
{
	PromptLabelLarge = LabelElement(AddElement("TribesGUI.LabelElement", "default_PromptLabelLarge"));
	PromptLabelLarge.bAutoSize = true;

	commandHUDContainer = HUDContainer(AddClonedElement("TribesGUI.HUDContainer", "default_CommandHUDContainer"));

	bodyContainer = HUDContainer(commandHUDContainer.AddClonedElement("TribesGUI.HUDContainer", "default_CommandHUDBodyContainer"));

	commandMapContainer = HUDContainer(bodyContainer.AddClonedElement("TribesGUI.HUDContainer", "default_CommandMapContainer"));
	objectivesContainer = HUDContainer(bodyContainer.AddClonedElement("TribesGUI.HUDContainer", "default_objectivesContainer"));

	commandMap = HUDRespawnMap(commandMapContainer.AddClonedElement("TribesGUI.HUDRespawnMap", "default_CommandMap"));

	titleLabel = LabelElement(objectivesContainer.AddClonedElement("TribesGUI.LabelElement", "default_CommandMapTitleLabel"));
	titleLabel.SetText(TitleString);

	mapInfoLabel = LabelElement(objectivesContainer.AddClonedElement("TribesGUI.LabelElement", "default_MapInfoLabel"));
	mapInfoLabel.bAutoSize = true;
	mapInfoLabel.SetText("Map Information");

	primaryObjectivesLabel = LabelElement(objectivesContainer.AddClonedElement("TribesGUI.LabelElement", "default_PrimaryObjectivesLabel"));
	primaryObjectivesLabel.SetText(class'ObjectiveInfo'.static.typeText(ObjectiveType_Primary));
	primaryObjectivesList = HUDObjectiveList(objectivesContainer.AddClonedElement("TribesGUI.HUDObjectiveList", "default_PrimaryObjectivesList"));

	secondaryObjectivesLabel = LabelElement(objectivesContainer.AddClonedElement("TribesGUI.LabelElement", "default_SecondaryObjectivesLabel"));
	secondaryObjectivesLabel.SetText(class'ObjectiveInfo'.static.typeText(ObjectiveType_Secondary));
	secondaryObjectivesList = HUDObjectiveList(objectivesContainer.AddClonedElement("TribesGUI.HUDObjectiveList", "default_SecondaryObjectivesList"));

	PromptLabel = LabelElement(commandMapContainer.AddElement("TribesGUI.LabelElement", "default_PromptLabel"));
	PromptLabel.bAutoSize = true;
	PromptLabel.SetText(PromptText);

	ConstructBaseComponents();
}

function bool KeyEvent(EInputKey Key, EInputAction Action, FLOAT Delta, HUDAction Response)
{
	// do the super first if the respawn map is already showing
	// MJ:  added check for bShowingRespawnMap because mouse clicks were passing through
	// and prematurely clicking respawn markers
	// PCD: now it's been removed, the respawn markers wont act on events untill
	// bShowingRespawnMap is true
	if(Super.KeyEvent(Key, Action, Delta, Response))
		return true;

	ActionHandler = HUDRespawnAction(Response);

	if(Action == EInputAction.IST_Press)	// only on pressed events
	{
		if(! bShowingRespawnMap || localData.bInstantRespawnMode)
		{
			if(Key == EInputKey.IK_LeftMouse)	// left mouse button
			{
				if(localData.bInstantRespawnMode)
					HUDRespawnAction(Response).SelectRespawnBase(-1);
				else
					HUDRespawnAction(Response).DisplayRespawnMap();
				return true;
			}
		}
		else
		{
			if(Key == EInputKey.IK_LeftMouse)	// left mouse button
			{
				// if the user clicked on nothing (checked in super()) then we should send a
				// value to indicate that they want to spawn, if they are allowed to
				HUDRespawnAction(Response).SelectRespawnBase(-3);
			}
			if(Key >= IK_1 && Key <= IK_9) // between 1 & 9 inclusive
			{
				HUDRespawnMap(commandMap).SelectSpawnPointByIndex(Key - IK_1);
				HUDRespawnAction(Response).SelectRespawnBase(HUDRespawnMap(commandMap).positionIndices[Key - IK_1]);	// take the index back to 0 based
				return true;
			}
			else if(Key >= IK_NumPad1 && Key <= IK_NumPad9) // between 1 & 9 inclusive (numpad)
			{
				HUDRespawnMap(commandMap).SelectSpawnPointByIndex(Key - IK_NumPad1);
				HUDRespawnAction(Response).SelectRespawnBase(HUDRespawnMap(commandMap).positionIndices[Key - IK_NumPad1]);	// take the index back to 0 based
				return true;
			}
			else if(Key == ExitRespawnKeyBinding || (Key == IK_Escape && csc.bCanExitRespawnHud))		// Escape at the moment...
			{
				HUDRespawnAction(Response).ExitRespawnHUD();
				return true;
			}
		}
	}

	return false;
}

function SetRespawnMapVisibility(bool value)
{
	bShowingRespawnMap = value;
	commandHUDContainer.bVisible = value;
	PromptLabelLarge.bVisible = ! value;

	commandHUDContainer.SetNeedsLayout();
	commandHUDContainer.ForceNeedsLayout();
}

function UpdateData(ClientSideCharacter c)
{
	local string text, tempText;

	Super.UpdateData(c);

	csc = c;
	localData = c;

	SetRespawnMapVisibility(c.bShowRespawnMap);

	// only force resizing of the chat window when the map is showing.
	if(messageWindow != None && bShowingRespawnMap)
		messageWindow.ForcedMaxVisibleLines = 3;
	else
		messageWindow.ForcedMaxVisibleLines = -1;

	ExitRespawnKeyBinding = c.ExitRespawnKeyBinding;

	if(localData.bInstantRespawnMode)
	{
		PromptLabelLarge.SetText(InstantRespawnText);
	}
	else if(bShowingRespawnMap)
	{
		// print respawn info
		if(c.livesLeft == 0)
		{
			text = RespawnLimitText;
		}
		else if (c.bNoMoreCarryables == true)
		{
			text = NoMoreFuelText;
		}
		else
		{
			if(c.respawnTime > 0)
			{
				tempText = replaceStr(CountdownText, ""$c.respawnTime);
				text $= tempText;
			}
			//else if (c.countdown > 0)
			//{
			//	tempText = replaceStr(RoundStartText, c.countdown);
			//	text $= tempText;
			//}

			text $= PromptText;

			if(c.bCanExitRespawnHUD)
			{
				tempText = replaceStr(CancelText, c.ExitRespawnKeyText);
				text $= tempText;
			}
		}

		PromptLabel.SetText(text);
	}
	else
	{
		if(c.respawnTime > 0)
		{
			tempText = replaceStr(CountdownText, ""$c.respawnTime);
			text $= tempText;
		}

		text $= ClickToSeeMapText;

		PromptLabelLarge.SetText(text);
	}

}

defaultproperties
{
	TitleString			= "Respawn Menu"

	NoMoreFuelText		= "Your team has run out of fuel.¼You can't spawn until they get more."
	RespawnLimitText	= "You have reached your respawn limit. You must wait until the next round"
	CountdownText		= "Respawn in %1 seconds¼"
	PromptText			= "Use the Number keys to select a spawn point¼"
	CancelText			= "Press '%1' to cancel"
	ClickToSeeMapText	= "Press Fire to see respawn map"
	InstantRespawnText	= "Press Fire to respawn"
	RoundStartText		= "You have %1 seconds to select a spawn point and choose equipment"
}

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:48.792 - Created with UnCodeX