-
Notifications
You must be signed in to change notification settings - Fork 7
/
EnhancedFlightMap.lua
181 lines (147 loc) · 5.75 KB
/
EnhancedFlightMap.lua
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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
--[[
Main program function for Enhanced Flight Map.
Localisation of text should be done in localization.lua.
All other code in here should not be modified unless you know what you are doing,
and if you do modify something, please let me know.
]]
---------------------------------------------------------------------------
-- Functions to deal with the various methods the program can be called
---------------------------------------------------------------------------
EFM_LOADED = 0;
-- What to do when events are seen.
function EnhancedFlightMap_OnEvent( frame, event, ... )
if ((event == "ADDON_LOADED") and (select(1, ...) == "EnhancedFlightMap"))then
-- Register our slash commands
SLASH_EFM1 = EFM_SLASH1;
SLASH_EFM2 = EFM_SLASH2;
SlashCmdList["EFM"] = function(msg)
EFM_SlashCommandHandler(msg);
end
-- Define program Hooks
-- Hook DrawOneHopLines function.
-- We do this to find the direct flight paths from each node.
hooksecurefunc("DrawOneHopLines", EFM_FM_DrawOneHopLines);
-- Hook TaxiNodeOnButtonEnter function.
-- We do this to be able to display the additional data for the blizzard-defined nodes as well as our nodes.
hooksecurefunc("TaxiNodeOnButtonEnter", EFM_FM_TaxiNodeOnButtonEnter);
-- Hook the TakeTaxiNode function.
-- This is done as there is no way (currently) to determine what node we are flying to while in flight.
hooksecurefunc("TakeTaxiNode", EFM_Timer_TakeTaxiNode);
-- Hook the MapCanvasMixin:OnMapChanged function.
-- This is done to allow us to display stuff on the blizzard map screens
hooksecurefunc(MapCanvasMixin, "OnMapChanged", EFM_Map_WorldMapEvent);
-- Hook the GossipTitleButton_OnClick function.
-- This is done due to 1.11 changes to druid flightpaths at nighthaven, might be needed elsewhere in the future also.
hooksecurefunc(_G.GossipOptionButtonMixin, "OnClick", EFM_GossipTitleButton_OnClick);
-- Call various init routines.
EFM_DefineData();
-- Register the events we want to listen for
frame:RegisterEvent("PLAYER_ENTERING_WORLD");
frame:RegisterEvent("PLAYER_LEAVING_WORLD");
frame:RegisterEvent("LOADING_SCREEN_DISABLED");
frame:RegisterEvent("LOADING_SCREEN_ENABLED");
-- Register new config screen
EnhancedFlightMap_RegConfig(); -- Register New Config
-- Additional GUI stuff
EnhancedFlightMap_GUIConfig();
-- Set up the new map window
EFM_MW_Setup();
-- Initial Setup complete, we're done now.
return;
elseif (event == "PLAYER_ENTERING_WORLD") then
local isLogin = select(1, ...);
local isReload = select(2, ...);
if isLogin then
EFM_Shared_DebugMessage("Player entered world for the first time", Lys_Debug);
elseif isReload then
EFM_Shared_DebugMessage("Player entered world reloaded the UI", Lys_Debug);
else
EFM_Shared_DebugMessage("Player entered world zoned between map instances", Lys_Debug);
end
frame:RegisterEvent("TAXIMAP_OPENED");
--EFM_Data_NodeFixup();
return;
elseif (event == "PLAYER_LEAVING_WORLD") then
frame:UnregisterEvent("TAXIMAP_OPENED");
return;
elseif (event == "TAXIMAP_OPENED") then
EFM_FM_TaxiMapOpenEvent();
return;
elseif (event == "LOADING_SCREEN_ENABLED") then
-- Loading screen starts, if it happens due to a portal/teleport while in a flight path the recording won't stop but must be paused until the loading screen ends
EFM_Shared_DebugMessage("Player loading screen enabled", Lys_Debug);
EFM_Timer_PauseTimer();
return;
elseif (event == "LOADING_SCREEN_DISABLED") then
EFM_Shared_DebugMessage("Player loading screen disabled", Lys_Debug);
EFM_Timer_ResumeTimer();
return;
end
end
-- Function: Slashcommand handler
function EFM_SlashCommandHandler(msg)
if (msg == '') then msg = nil end
if (msg) then
--msg = string.lower(msg);
local msgLower = string.lower(msg);
if (msgLower == EFM_CMD_CLEAR) then
EFM_Message("announce", EFM_CLEAR_HELP);
return;
elseif (msgLower == EFM_CMD_CLEAR_ALL) then
EFM_Data = nil;
EFM_Message("announce", EFM_MSG_CLEAR);
return;
elseif (string.find(msgLower, EFM_CMD_CLEAR) ~= nil) then
value = EFM_SF_SlashClean(EFM_CMD_CLEAR, msg);
value = string.lower(value);
if (value == string.lower(FACTION_ALLIANCE)) then
EFM_Data[FACTION_ALLIANCE] = nil;
EFM_Message("announce", format(EFM_MSG_CLEARFACTION, FACTION_ALLIANCE));
elseif (value == string.lower(FACTION_HORDE)) then
EFM_Data[FACTION_HORDE] = nil;
EFM_Message("announce", format(EFM_MSG_CLEARFACTION, FACTION_HORDE));
end
return;
-- Flight map when not at the flight master....
elseif (msgLower == EFM_CMD_MAP) then
EFM_MW_OpenMap();
return;
elseif (string.find(msgLower, EFM_CMD_MAP) ~= nil) then
value = EFM_SF_SlashClean(EFM_CMD_MAP, msg);
if (value == EFM_FMCMD_KALIMDOR) then
EFM_MW_OpenMap(1);
elseif (value == EFM_FMCMD_AZEROTH) then
EFM_MW_OpenMap(2);
elseif (value == EFM_FMCMD_OUTLAND) then
EFM_MW_OpenMap(3);
elseif (value == EFM_FMCMD_NORTHREND) then
EFM_MW_OpenMap(4);
else
EFM_MW_OpenMap();
end
return;
-- Options screen details
elseif (msgLower == EFM_CMD_GUI) then
InterfaceOptionsFrame_OpenToCategory(EFM_GUI);
InterfaceOptionsFrame_OpenToCategory(EFM_GUI);
return;
-- Report on flight times
elseif (string.find(msgLower, EFM_CMD_REPORT)) then
value = EFM_SF_SlashClean(EFM_CMD_REPORT, msg);
EFM_Report_Flight(value);
return;
end
end
-- Display help when all else fails...
local index = 0;
local value = getglobal("EFM_HELP_TEXT"..index);
while( value ) do
EFM_Message("announce", value);
index = index + 1;
value = getglobal("EFM_HELP_TEXT"..index);
end
end
-- Function EFM_TestFunction
function EFM_TestFunction(event, ...)
EFM_Shared_DebugMessage(event, 1);
end