-
-
Notifications
You must be signed in to change notification settings - Fork 9
/
HudMap.lua
457 lines (408 loc) · 11.5 KB
/
HudMap.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
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
local _, sm = ...
sm.hudmap = {}
if sm then return end -- XXX disable for now
local mod = sm.hudmap
local L = sm.L
local updateFrame = CreateFrame("Frame")
local updateRotations, HudMapCluster, SexyMapHudMap
local onShow = function(self)
self.rotSettings = GetCVar("rotateMinimap")
SetCVar("rotateMinimap", "1")
if mod.db.useGatherMate ~= false and GatherMate2 then
GatherMate2:GetModule("Display"):ReparentMinimapPins(HudMapCluster)
GatherMate2:GetModule("Display"):ChangedVars(nil, "ROTATE_MINIMAP", "1")
end
if mod.db.useQuestHelper ~= false and QuestHelper then
QuestHelper:SetMinimapObject(HudMapCluster)
end
if mod.db.useRoutes ~= false and Routes then
Routes:ReparentMinimap(HudMapCluster)
Routes:CVAR_UPDATE(nil, "ROTATE_MINIMAP", "1")
end
--[[if mod.db.useTomTom ~= false and TomTom then
TomTom:ReparentMinimap(HudMapCluster)
local Astrolabe = DongleStub("Astrolabe-1.0") -- Astrolabe is bundled with TomTom (it's not packaged with SexyMap)
Astrolabe.processingFrame:SetParent(HudMapCluster)
end]]
if mod.db.useNpcScan ~= false and _NPCScan and _NPCScan.Overlay then
_NPCScan.Overlay.Modules.List["Minimap"]:SetMinimapFrame(HudMapCluster)
end
updateFrame:SetScript("OnUpdate", updateRotations)
Minimap:Hide()
mod:SetScales()
end
local onHide = function(self, force)
updateFrame:SetScript("OnUpdate", nil)
SetCVar("rotateMinimap", self.rotSettings)
if (force or mod.db.useGatherMate ~= false) and GatherMate2 then
GatherMate2:GetModule("Display"):ReparentMinimapPins(Minimap)
GatherMate2:GetModule("Display"):ChangedVars(nil, "ROTATE_MINIMAP", self.rotSettings)
end
if (force or mod.db.useQuestHelper ~= false) and QuestHelper then
QuestHelper:SetMinimapObject(Minimap)
end
if (force or mod.db.useRoutes ~= false) and Routes then
Routes:ReparentMinimap(Minimap)
Routes:CVAR_UPDATE(nil, "ROTATE_MINIMAP", self.rotSettings)
end
--[[if (force or mod.db.useTomTom ~= false) and TomTom then
TomTom:ReparentMinimap(Minimap)
local Astrolabe = DongleStub("Astrolabe-1.0") -- Astrolabe is bundled with TomTom (it's not packaged with SexyMap)
Astrolabe.processingFrame:SetParent(Minimap)
end]]
if (force or mod.db.useNpcScan ~= false) and _NPCScan and _NPCScan.Overlay then
_NPCScan.Overlay.Modules.List["Minimap"]:SetMinimapFrame(Minimap)
end
Minimap:Show()
end
local options = {
type = "group",
name = "HudMap",
args = {
desc = {
type = "description",
order = 0,
name = L["Enable a HUD minimap. This is very useful for gathering resources, but for technical reasons, the HUD map and the normal minimap can't be shown at the same time. Showing the HUD map will turn off the normal minimap."]
},
enable = {
type = "toggle",
name = L["Enable Hudmap"],
order = 1,
get = function()
return HudMapCluster:IsVisible()
end,
set = function(info, v)
mod:Toggle(v)
end,
},
binding = {
type = "keybinding",
name = L["Keybinding"],
order = 2,
get = function()
return GetBindingKey("TOGGLESEXYMAPGATHERMAP")
end,
set = function(info, v)
SetBinding(v, "TOGGLESEXYMAPGATHERMAP")
SaveBindings(GetCurrentBindingSet())
end
},
color = {
type = "color",
hasAlpha = true,
order = 3,
name = L["HUD Color"],
get = function()
local c = mod.db.hudColor
return c.r or 0, c.g or 1, c.b or 0, c.a or 1
end,
set = function(info, r, g, b, a)
local c = mod.db.hudColor
c.r, c.g, c.b, c.a = r, g, b, a
mod:UpdateColors()
end
},
textcolor = {
type = "color",
hasAlpha = true,
name = L["Text Color"],
order = 4,
get = function()
local c = mod.db.textColor
return c.r or 0, c.g or 1, c.b or 0, c.a or 1
end,
set = function(info, r, g, b, a)
local c = mod.db.textColor
c.r, c.g, c.b, c.a = r, g, b, a
mod:UpdateColors()
end
},
scale = {
type = "range",
name = L["Scale"],
order = 5,
min = 1.0,
max = 3.0,
step = 0.1,
bigStep = 0.1,
get = function()
return mod.db.scale
end,
set = function(info, v)
mod.db.scale = v
mod:SetScales()
end
},
alpha = {
type = "range",
name = L["Opacity"],
order = 6,
min = 0,
max = 1,
step = 0.01,
bigStep = 0.01,
get = function()
return mod.db.alpha
end,
set = function(info, v)
mod.db.alpha = v
HudMapCluster:SetAlpha(v)
end
},
addonsHeader = {
order = 7,
type = "header",
name = ADDONS,
},
addonDesc = {
type = "description",
name = L["The HudMap supports several addons. If you have any of the addons below installed, they will be shown on the HudMap."],
order = 8
},
npcscan = {
type = "toggle",
order = 100,
name = "_NPCScan.Overlay",
width = "full",
disabled = function()
return _NPCScan == nil or _NPCScan.Overlay == nil
end,
get = function()
return mod.db.useNpcScan ~= false
end,
set = function(info, v)
mod.db.useNpcScan = v
if HudMapCluster:IsVisible() then
onHide(HudMapCluster, true)
onShow(HudMapCluster)
end
end
},
gathermate = {
type = "toggle",
order = 105,
name = "Gathermate",
width = "full",
disabled = function()
return GatherMate2 == nil
end,
get = function()
return mod.db.useGatherMate ~= false
end,
set = function(info, v)
mod.db.useGatherMate = v
if HudMapCluster:IsVisible() then
onHide(HudMapCluster, true)
onShow(HudMapCluster)
end
end
},
questhelper = {
type = "toggle",
order = 106,
name = "QuestHelper",
width = "full",
disabled = function()
return QuestHelper == nil
end,
get = function()
return mod.db.useQuestHelper ~= false
end,
set = function(info, v)
mod.db.useQuestHelper = v
if HudMapCluster:IsVisible() then
onHide(HudMapCluster, true)
onShow(HudMapCluster)
end
end
},
routes = {
type = "toggle",
name = "Routes",
width = "full",
order = 110,
disabled = function()
return Routes == nil
end,
get = function()
return mod.db.useRoutes ~= false
end,
set = function(info, v)
mod.db.useRoutes = v
if HudMapCluster:IsVisible() then
onHide(HudMapCluster, true)
onShow(HudMapCluster)
end
end
},
tomtom = {
type = "toggle",
name = "TomTom",
width = "full",
order = 115,
disabled = function()
return true
end,
get = function()
return mod.db.useTomTom ~= false
end,
set = function(info, v)
mod.db.useTomTom = v
if HudMapCluster:IsVisible() then
onHide(HudMapCluster, true)
onShow(HudMapCluster)
end
end
},
}
}
local directions = {}
local playerDot
local coloredTextures = {}
local gatherCircle, gatherLine
local indicators = {"N", "NE", "E", "SE", "S", "SW", "W", "NW"}
do
local target = 1 / 90
local total = 0
function updateRotations(self, t)
total = total + t
if total < target then return end
-- Sometimes, somehow, rotating gets turned off, so force it on when HudMap is on
if GetCVar("rotateMinimap") == "0" then
SetCVar("rotateMinimap", "1")
end
while total > target do total = total - target end
local bearing = GetPlayerFacing()
for k, v in ipairs(directions) do
local x, y = math.sin(v.rad + bearing), math.cos(v.rad + bearing)
v:ClearAllPoints()
v:SetPoint("CENTER", HudMapCluster, "CENTER", x * v.radius, y * v.radius)
end
end
end
function mod:OnInitialize(profile)
if type(profile.hudmap) ~= "table" then
profile.hudmap = {
hudColor = {},
textColor = {r = 0.5, g = 1, b = 0.5, a = 1},
scale = 1.4,
alpha = 0.7
}
end
self.db = profile.hudmap
end
function mod:OnEnable()
sm.core:RegisterModuleOptions("HudMap", options, "HudMap")
HudMapCluster = CreateFrame("Frame", "HudMapCluster", UIParent)
HudMapCluster:SetWidth(140)
HudMapCluster:SetHeight(140)
HudMapCluster:SetPoint("CENTER", UIParent, "CENTER")
SexyMapHudMap = CreateFrame("Minimap", "SexyMapHudMap", HudMapCluster)
SexyMapHudMap:SetWidth(140)
SexyMapHudMap:SetHeight(140)
SexyMapHudMap:SetPoint("CENTER", HudMapCluster, "CENTER")
-- Removes the circular "waffle-like" texture that shows when using a non-circular minimap in the blue quest objective area.
SexyMapHudMap:SetArchBlobRingScalar(0)
SexyMapHudMap:SetArchBlobRingAlpha(0)
SexyMapHudMap:SetQuestBlobRingScalar(0)
SexyMapHudMap:SetQuestBlobRingAlpha(0)
HudMapCluster:SetFrameStrata("BACKGROUND")
HudMapCluster:SetAlpha(mod.db.alpha)
SexyMapHudMap:SetAlpha(0)
SexyMapHudMap:EnableMouse(false)
setmetatable(HudMapCluster, { __index = SexyMapHudMap })
BINDING_HEADER_SexyMap = "SexyMap"
BINDING_NAME_TOGGLESEXYMAPGATHERMAP = L["Toggle HudMap On/Off"]
gatherCircle = HudMapCluster:CreateTexture()
gatherCircle:SetTexture([[SPELLS\CIRCLE.BLP]])
gatherCircle:SetBlendMode("ADD")
gatherCircle:SetPoint("CENTER")
local radius = SexyMapHudMap:GetWidth() * 0.45
gatherCircle:SetWidth(radius)
gatherCircle:SetHeight(radius)
gatherCircle.alphaFactor = 0.5
tinsert(coloredTextures, gatherCircle)
gatherLine = HudMapCluster:CreateTexture("GatherLine")
gatherLine:SetTexture(130871) --Interface\\BUTTONS\\WHITE8X8
gatherLine:SetBlendMode("ADD")
local nudge = 0.65
gatherLine:SetPoint("BOTTOM", HudMapCluster, "CENTER", 0, nudge)
gatherLine:SetWidth(0.2)
gatherLine:SetHeight((SexyMapHudMap:GetWidth() * 0.214) - nudge)
tinsert(coloredTextures, gatherLine)
playerDot = HudMapCluster:CreateTexture()
playerDot:SetTexture([[Interface\GLUES\MODELS\UI_Tauren\gradientCircle.blp]])
playerDot:SetBlendMode("ADD")
playerDot:SetPoint("CENTER")
playerDot.alphaFactor = 2
tinsert(coloredTextures, playerDot)
local indicators = {"N", "NE", "E", "SE", "S", "SW", "W", "NW"}
local radius = SexyMapHudMap:GetWidth() * 0.214
for k, v in ipairs(indicators) do
local rot = (0.785398163 * (k-1))
local ind = HudMapCluster:CreateFontString(nil, nil, "GameFontNormalSmall")
local x, y = math.sin(rot), math.cos(rot)
ind:SetPoint("CENTER", HudMapCluster, "CENTER", x * radius, y * radius)
ind:SetText(v)
ind:SetShadowOffset(0.2,-0.2)
ind.rad = rot
ind.radius = radius
tinsert(directions, ind)
end
HudMapCluster:Hide()
HudMapCluster:SetScript("OnShow", onShow)
HudMapCluster:SetScript("OnHide", onHide)
Minimap:HookScript("OnShow", self.Minimap_OnShow)
self:UpdateColors()
self:SetScales()
HudMapCluster._GetScale = HudMapCluster.GetScale
HudMapCluster.GetScale = function()
return 1
end
updateFrame:RegisterEvent("PLAYER_LOGOUT")
end
updateFrame:SetScript("OnEvent", function()
mod:Toggle(false)
end)
function mod:Minimap_OnShow()
if HudMapCluster:IsVisible() then
HudMapCluster:Hide()
end
end
function mod:Toggle(flag)
if flag then
HudMapCluster:Show()
else
HudMapCluster:Hide()
end
end
function mod:UpdateColors()
local c = mod.db.hudColor
for k, v in ipairs(coloredTextures) do
v:SetVertexColor(c.r or 0, c.g or 1, c.b or 0, (c.a or 1) * (v.alphaFactor or 1) / HudMapCluster:GetAlpha())
end
c = mod.db.textColor
for k, v in ipairs(directions) do
v:SetTextColor(c.r, c.g, c.b, c.a)
end
end
function mod:SetScales()
SexyMapHudMap:ClearAllPoints()
SexyMapHudMap:SetPoint("CENTER", UIParent, "CENTER")
HudMapCluster:ClearAllPoints()
HudMapCluster:SetPoint("CENTER")
local size = UIParent:GetHeight() / mod.db.scale
SexyMapHudMap:SetWidth(size)
SexyMapHudMap:SetHeight(size)
HudMapCluster:SetHeight(size)
HudMapCluster:SetWidth(size)
gatherCircle:SetWidth(size * 0.45)
gatherCircle:SetHeight(size * 0.45)
gatherLine:SetHeight((SexyMapHudMap:GetWidth() * 0.214) - 0.65)
HudMapCluster:SetScale(mod.db.scale)
playerDot:SetWidth(15)
playerDot:SetHeight(15)
for k, v in ipairs(directions) do
v.radius = SexyMapHudMap:GetWidth() * 0.214
end
end