-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmodmain.lua
More file actions
141 lines (123 loc) · 3.53 KB
/
modmain.lua
File metadata and controls
141 lines (123 loc) · 3.53 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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
local _G = GLOBAL
if _G.GetGameModeProperty("level_type") ~= _G.LEVELTYPE.SURVIVAL then
return
end
-- GLOBAL
local rawget = _G.rawget
-- Require
local BossCalendar = _G.require("screens/bosscalendar")
Assets =
{
Asset("ATLAS", "images/skull.xml"),
Asset("ATLAS", "images/npcs.xml"),
Asset("ATLAS", "images/igloo.xml"),
Asset("ATLAS", "images/marble.xml"),
}
AddMinimapAtlas("images/igloo.xml")
AddMinimapAtlas("images/marble.xml")
if GetModConfigData("IGLOO_ICON") then
local function MapWidgetPostConstruct(self)
BossCalendar:AddMapIcons(self)
end
AddClassPostConstruct("widgets/mapwidget", MapWidgetPostConstruct)
end
local function WalrusCampPostInit(inst)
inst:DoTaskInTime(0, function()
BossCalendar:AddCamp(inst)
end)
end
AddPrefabPostInit("walrus_camp", WalrusCampPostInit)
for _, prefab in pairs
{
"yellowgem",
"hivehat",
"shroom_skin",
"klaussackkey",
"blowdart_pipe",
"malbatross_beak",
"skeletonhat",
"singingshell_octave5"
}
do
AddPrefabPostInit(prefab, function(inst)
inst:DoTaskInTime(0, function()
if inst.entity and not inst.entity:GetParent() then
BossCalendar:ValidateDeath(inst)
end
end)
end)
end
if GetModConfigData("MARBLE_ICON") then
for _, prefab in pairs
{
"sculpture_rooknose",
"sculpture_knighthead",
"sculpture_bishophead",
}
do
AddPrefabPostInit(prefab, function(inst)
inst:DoTaskInTime(0, function()
BossCalendar:SculpturePostInit(inst)
end)
end)
end
end
local function GetConfigByte(config)
return rawget(_G, GetModConfigData(config))
end
if GetConfigByte("OPEN_KEY") then
local OPEN_KEY = GetConfigByte("OPEN_KEY")
local TOGGLE_MODE = GetModConfigData("TOGGLE_MODE")
local TheInput = _G.TheInput
local function getActiveScreenName()
local activeScreen = TheFrontEnd:GetActiveScreen()
return activeScreen and activeScreen.name or ""
end
local function validateToggle()
local activeScreenName = getActiveScreenName()
return activeScreenName == "HUD" or activeScreenName == "Boss Calendar"
end
local function displayCalendar()
if validateToggle() then
if BossCalendar:Open() then
TheFrontEnd:PushScreen(BossCalendar)
elseif TOGGLE_MODE then
BossCalendar:Close()
end
end
end
local function closeCalendar()
if validateToggle() then
BossCalendar:Close()
end
end
if TOGGLE_MODE then
TheInput:AddKeyUpHandler(OPEN_KEY, displayCalendar)
else
TheInput:AddKeyDownHandler(OPEN_KEY, displayCalendar)
TheInput:AddKeyUpHandler(OPEN_KEY, closeCalendar)
end
end
local function Init(inst)
inst:DoTaskInTime(0, function()
BossCalendar:Init(inst)
end)
end
AddPlayerPostInit(Init)
AddSimPostInit(function()
BossCalendar:LoadIgloos()
if GetModConfigData("MARBLE_ICON") then
BossCalendar:LoadMarbles()
end
end)
BossCalendar:SetSettings(
{
IGLOO_ICON = GetModConfigData("IGLOO_ICON"),
IGLOO_NUMBERS = GetModConfigData("IGLOO_NUMBERS"),
REMINDER_COLOR = GetModConfigData("REMINDER_COLOR"),
REMINDER_DURATION = GetModConfigData("REMINDER_DURATION"),
CALENDAR_UNITS = GetModConfigData("CALENDAR_UNITS"),
ANNOUNCE_STYLES = GetModConfigData("ANNOUNCE_STYLES"),
ANNOUNCE_UNITS = GetModConfigData("ANNOUNCE_UNITS"),
}
)