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

Gameplay.TribesHUDManager


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
class TribesHUDManager extends Core.Object
	threaded
	transient;

var PlayerCharacterController Controller;
var TribesHUDBase activeHUD;
var HUDInteraction	interactionHandler;

// persistent HUD cache
var Array<class>			currHUDClasses;
var Array<TribesHUDBase>	hudObjects;

var String ActiveGameplayHUD;	// stores the non-command hud, for switching back to
///////////////////////////////////////////////////////////////////////////////
//
function Initialise(PlayerCharacterController pcc)
{
	local PointOfInterest POI;

	Controller = pcc;

	//
	// add the points of interest array to the controller
	//
	foreach Controller.AllActors(class'PointOfInterest', POI)
	{
		log("added point of interest "$POI);
		Controller.PointsOfInterest[Controller.PointsOfInterest.Length] = POI;
	}
}

function ShowDebugHUD(bool visible)
{
    if (visible)
        GotoState('ShowingDebugHUD');
    else
        GotoState('');
}

function Update()
{
	if(Controller.Level.NetMode == NM_DedicatedServer)
		return;

	if(activeHUD != None && activeHUD.bAllowCommandHUDSwitching)
	{
		if(Controller.bObjectives == 1)
		{
			if (Character(Controller.Pawn) != None && Character(Controller.Pawn).bDontAllowCommandScreen)
				return;

			GotoState('ShowingCommandMapHUD');
		}
	}
}

///////////////////////////////////////////////////////////////////////////////
//
// Cleans up the hud stuffs
function Cleanup()
{
	local int i;

	if(InteractionHandler != None)
	{
		InteractionHandler.hudOwner = None;
		Controller.Player.InteractionMaster.RemoveInteraction(InteractionHandler);
	}

	for(i = 0; i < hudObjects.Length; ++i)
		hudObjects[i].Cleanup();
	hudObjects.Length = 0;
	currHUDClasses.Length = 0;
	ActiveHUD = None;
}

///////////////////////////////////////////////////////////////////////////////
//
function SetHUD(String NewHUDType)
{
	local class<HUD> NewHUDClass;
	local TribesHUDBase NewHUD;
	local int i;

	// empty huds should remove the old one and replace it with nothing
	if(NewHUDType == "")
	{
		if(ActiveHUD != None)
		{
			ActiveHUD.bHideHUD = true;
			ActiveHUD.HUDHidden();
		}

		ActiveGameplayHUD = "";
		ActiveHUD = None;
		Controller.currentHUDClass = newHUDType;
		UpdateHUDData();

		return;
	}

	if(! (Controller.commandHUDClass ~= NewHUDType) && !IsInState('ShowingDebugHUD'))
		ActiveGameplayHUD = NewHUDType;

	// ensure the clientSideChar is available
//	if(clientSideChar == None)
//		clientSideChar = new class'ClientSideCharacter';

	// create the class and set the hud
	NewHUDClass = class<TribesHUDBase>(DynamicLoadObject(newHUDType, class'Class'));

	// Paul: Grabbed the code from PlayerController.ClientSetHUD() and moved it here in order to
	// support persistent caching of HUDs. This is mainly because the changeover time
	// when switching HUDs is waaaay to slow.

	if((activeHUD == None) || ((NewHUDClass != None) && (NewHUDClass != activeHUD.Class)))
	{
		for(i = 0; i < currHUDClasses.Length; ++i)
		{
			if(currHUDClasses[i] == NewHUDClass)
			{
				NewHUD = hudObjects[i];
				break;
			}
		}

		if(NewHUD == None)
		{
			NewHUD = TribesHUDBase(Controller.spawn(NewHUDClass, Controller));
			if(NewHUD != None)
			{
				currHUDClasses[currHUDClasses.Length] = NewHUDClass;
				hudObjects[hudObjects.Length] = NewHUD;
			}
		}

		if(activeHUD != None)
		{
			activeHUD.bHideHUD = true;
			activeHUD.HUDHidden();
		}

		if(NewHUD != None)
		{
			activeHUD = NewHUD;
			activeHUD.bHideHUD = false;

			Controller.myHUD = activeHUD;

			// store the hud name for saving/loading games
			Controller.currentHUDClass = newHUDType;

			activeHUD.HUDShown();
		}
	}
}

//
// Update hud data gets called every tick
//
function UpdateHUDData()
{
	if(Controller.Level.NetMode == NM_DedicatedServer)
		return;

	if(interactionHandler == None)
		interactionHandler = HUDInteraction(Controller.Player.InteractionMaster.AddInteraction("Gameplay.HUDInteraction", Controller.Player));

	if(activeHUD != None && ! activeHUD.bHideHUD)
		activeHUD.UpdateHUDData();

	// any keys not assigned before now will likely be incorrect if
	// the user has modified their bindings while playing!
	Controller.clientSideChar.bHotkeysUpdated = true;

	if(interactionHandler != None)
	{
		if(activeHUD != None && ! activeHUD.bHideHUD && activeHUD.NeedsKeyInput())
		{
			interactionHandler.hudOwner = activeHUD;
			if(! interactionHandler.IsInState('Enabled'))
				interactionHandler.GotoState('Enabled');
		}
		else
		{
			interactionHandler.hudOwner = None;
			interactionHandler.GotoState('');
		}
	}
}

state ShowingDebugHUD
{
	function BeginState()
	{
		SetHUD("TribesGUI.TribesDebugHUD");
	}

	function EndState()
	{
		SetHUD(ActiveGameplayHUD);
	}
}

state ShowingCommandMapHUD
{
	function BeginState()
	{
		SetHUD(Controller.commandHUDClass);
		Controller.serverCommandHUDShown();
	}

	function Update()
	{
		if(Controller.bObjectives != 1)
			GotoState('');
	}

	function EndState()
	{
		SetHUD(ActiveGameplayHUD);
		Controller.serverCommandHUDHidden();
	}
}

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