-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.lua
More file actions
74 lines (63 loc) · 2.6 KB
/
Copy pathmain.lua
File metadata and controls
74 lines (63 loc) · 2.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
-- =========================================================
-- FS25_MasterHUD - mod entry point
-- =========================================================
-- Author: TisonK
-- =========================================================
-- Loads the MasterHUD modules, publishes the g_masterHUD handle, and hooks
-- the FS25 mission lifecycle:
-- Mission00.load -> publish the cross-mod bridge handle
-- FSBaseMission.draw -> the single ecosystem draw loop
-- FSBaseMission.mouseEvent -> route clicks to interactive panels
-- FSBaseMission.delete -> free the shared overlay + drop the handle
--
-- Load order: MasterHUD is mod 3 (after StateLedger and NetworkSync). The
-- handle is published as soon as this file runs so companions loading after
-- it can register during their own module load.
-- =========================================================
local modDirectory = g_currentModDirectory
source(modDirectory .. "src/Logger.lua")
source(modDirectory .. "src/OverlayRenderer.lua")
source(modDirectory .. "src/MasterHUD.lua")
local masterHUD = MasterHUD.new()
getfenv(0)["g_masterHUD"] = masterHUD
local function onMissionLoad(mission)
if mission ~= nil then
mission.masterHUD = masterHUD
end
MHLogger.info("MasterHUD active (mod 3, UI renderer)")
end
local function onMissionDelete()
masterHUD:delete()
getfenv(0)["g_masterHUD"] = nil
if g_currentMission ~= nil then
g_currentMission.masterHUD = nil
end
end
Mission00.load = Utils.appendedFunction(Mission00.load, onMissionLoad)
-- Draw after the base game HUD so overlays sit on top.
FSBaseMission.draw = Utils.appendedFunction(FSBaseMission.draw, function(mission)
masterHUD:onDraw()
end)
-- Route mouse events to interactive panels (guarded: only if the hook exists).
if FSBaseMission.mouseEvent ~= nil then
FSBaseMission.mouseEvent = Utils.appendedFunction(
FSBaseMission.mouseEvent,
function(mission, posX, posY, isDown, isUp, button)
masterHUD:onMouseEvent(posX, posY, isDown, isUp, button)
end
)
end
-- Route key events to interactive panels (guarded: only if the hook exists).
if FSBaseMission.keyEvent ~= nil then
FSBaseMission.keyEvent = Utils.appendedFunction(
FSBaseMission.keyEvent,
function(mission, action, value)
masterHUD:onKeyEvent(action, value)
end
)
end
FSBaseMission.delete = Utils.prependedFunction(FSBaseMission.delete, onMissionDelete)
if addConsoleCommand ~= nil then
addConsoleCommand("mhStatus", "Show MasterHUD registered overlays and panels",
"consoleCommandStatus", masterHUD)
end