Skip to content

Commit 089e61b

Browse files
committed
best documentation i can muster
1 parent a926d28 commit 089e61b

File tree

2 files changed

+81
-4
lines changed

2 files changed

+81
-4
lines changed

Data/Base.rte/Activities/Utility/HUDHandler.lua

Lines changed: 76 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,76 @@
11
--------------------------------------- Instructions ---------------------------------------
22

3-
--
3+
------- Require this in your script like so:
4+
5+
-- self.HUDHandler = require("Activities/Utility/HUDHandler");
6+
-- self.HUDHandler:Initialize(Activity, bool newGame, bool verboseLogging);
7+
8+
-- Call self.HUDHandler:UpdateHUDHandler() every frame.
9+
10+
-- This utility lets you queue up camera panning events and set objectives to display on players' screens.
11+
12+
------- Camera stuff
13+
14+
-- HUDHandler:QueueCameraPanEvent(team, name, pos, speed, holdTime, notCancellable, cinematicBars, disableHUDFully, callback)
15+
-- Only team, name, and pos are required.
16+
-- pos is the destination of the camera pan event - note that it will start from wherever player screens happen to be just then.
17+
-- If you want to pan between two positions specifically, you will need one pan event to set up the position (with a fast speed and low holdTime) first.
18+
-- A speed of 0.05 is about average.
19+
-- holdTime is the total time this event will go on, whether it reaches its destination at the given speed or not.
20+
-- notCancellable == true will make the event unskippable, otherwise it can be skipped by pressing any button.
21+
-- cinematicBars will enable or disable animated cinematic bars for this event.
22+
-- disableHUDFully will disable all HUD elements, including things like the gold fund counter. However, even with this false, the HUDHandler objective list is disabled.
23+
-- callback is a function to call when this event ends, in case you want to sync some code up with a camera pan. This will also happen if the event is skipped.
24+
25+
-- There is also GetCameraPanEventCount(int team), RemoveCameraPanEvent(int team, string name) and RemoveAllCameraPanEvents(int team) which are self-explanatory.
26+
27+
-- Manual cinematic bar operation can happen with HUDHandler:SetCinematicBars(int team, bool toggle, int thickness).
28+
-- Note that this toggle state WILL be overriden by pan events, but your set thickness is permanent.
29+
30+
-- HUDHandler:SetCameraMinimumAndMaximumX(team, minimumX, maximumX) lets you set a minimum and maximum absolute X value for a particular team's players' cameras to go.
31+
-- Use this to limit view in scripted missions, for example.
32+
33+
------- Objectives
34+
35+
-- Objectives are rather robust in how they display.
36+
37+
-- HUDHandler:AddObjective(objTeam, objInternalNameOrFullTable, objShortName, objType, objLongName, objDescription, objPos,
38+
-- doNotShowInList, showArrowOnlyOnSpectatorView, showDescEvenWhenNotFirst, showDescOnlyOnSpectatorView)
39+
40+
-- Only team and internal name are required for a very basic objective display - the internal name will also be the objective's short name.
41+
42+
-- Internal name does not display on the list visually but is just there to keep track of objectives easier in code.
43+
-- Short name displays when the objective doesn't fulfill the criteria to have its long name displayed, and also on in-game objective arrows if applicable.
44+
-- objType is currently unused.
45+
-- Long name is displayed if criteria is fulfilled, alongside the description if applicable.
46+
-- Objective description is displayed if the objective is first in the list (the primary objective) or has showDescEvenWhenNotFirst set to true.
47+
-- objPos will enable an in-game arrow and short name display at a position in the world. You can also set an MO here to have the objective follow it.
48+
-- doNotShowInList will not show this objective in the HUD. Use it for internal objectives that only display in-game arrows, like a bunch of "kill actor" objectives.
49+
-- showArrowOnlyOnSpectatorView will show the in-game arrow only while a player is in actor select mode, i.e. holding q or e.
50+
-- showDescEvenWhenNotFirst will override description showing behavior and show this objective's description even if it's not first in the list.
51+
-- showDescOnlyOnSpectatorView is self-explanatory.
52+
53+
-- Instead of an internal name, you can give this function a pre-constructed table. It should contain these keys:
54+
55+
-- internalName
56+
-- shortName
57+
-- Type
58+
-- longName
59+
-- Description
60+
-- Position
61+
-- doNotShowInList
62+
-- showArrowOnlyOnSpectatorView
63+
-- showDescEvenWhenNotFirst
64+
-- showDescOnlyOnSpectatorView
65+
66+
-- RemoveObjective(team, internalName) to remove an objective. There is also RemoveAllObjectives(team).
67+
68+
-- MakeObjectivePrimary(team, internalName) will move an objective to the top of the list, displaying its long name and description if it has any.
69+
70+
------- Saving/Loading
71+
72+
-- Saving and loading requires you to also have the SaveLoadHandler ready.
73+
-- Simply run OnSave(instancedSaveLoadHandler) and OnLoad(instancedSaveLoadHandler) when appropriate.
474

575
--------------------------------------- Misc. Information ---------------------------------------
676

@@ -357,6 +427,10 @@ function HUDHandler:UpdateHUDHandler()
357427
self.Activity:ClearObjectivePoints();
358428

359429
for team = 0, #self.saveTable.teamTables do
430+
431+
-- Cinematic bars
432+
local disableDrawingObjectives = self:DrawCinematicBars(team);
433+
360434
local cameraTable = self.saveTable.teamTables[team].cameraQueue[1];
361435

362436
if cameraTable then
@@ -369,6 +443,7 @@ function HUDHandler:UpdateHUDHandler()
369443
self.Activity:SetViewState(Activity.OBSERVE, player);
370444
if cameraTable.disableHUDFully then
371445
FrameMan:SetHudDisabled(true, self.Activity:ScreenOfPlayer(player));
446+
disableDrawingObjectives = true;
372447
end
373448
end
374449
end
@@ -421,9 +496,6 @@ function HUDHandler:UpdateHUDHandler()
421496
end
422497
end
423498
end
424-
425-
-- Cinematic bars
426-
local disableDrawingObjectives = self:DrawCinematicBars(team);
427499

428500
-- Objectives
429501
if not PerformanceMan.ShowPerformanceStats == true and not disableDrawingObjectives then

Data/Base.rte/Scripts/Utility/MOUtility.lua

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@
77
-- This is a bunch of MO-related utilities. See each function for instructions.
88
-- For some functions to work you must call self.MOUtility:Update() every frame.
99

10+
------- Saving/Loading
11+
12+
-- Saving and loading requires you to also have the SaveLoadHandler ready.
13+
-- Simply run OnSave(instancedSaveLoadHandler) and OnLoad(instancedSaveLoadHandler) when appropriate.
14+
1015
--------------------------------------- Misc. Information ---------------------------------------
1116

1217
--

0 commit comments

Comments
 (0)