-
Notifications
You must be signed in to change notification settings - Fork 2
/
GroupIcons.lua
145 lines (128 loc) · 3.33 KB
/
GroupIcons.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
--[[
Copyright (c) 2009-2016, Hendrik "Nevcairiel" Leppkes < [email protected] >
All rights reserved.
]]
local Mapster = LibStub("AceAddon-3.0"):GetAddon("Mapster")
local L = LibStub("AceLocale-3.0"):GetLocale("Mapster")
local MODNAME = "GroupIcons"
local GroupIcons = Mapster:NewModule(MODNAME, "AceEvent-3.0", "AceHook-3.0")
local fmt = string.format
local _G = _G
local db
local defaults = {
profile = {
size = 24,
sizeBattleMap = 16,
}
}
local DEFAULT_WORLDMAP_SIZE = 16
local DEFAULT_BATTLEMAP_SIZE = 12
local FixWorldMapUnits, FixBattlefieldUnits
local options
local function getOptions()
if not options then
options = {
order = 20,
type = "group",
name = L["Group Icons"],
arg = MODNAME,
args = {
intro = {
order = 1,
type = "description",
name = L["The Group Icons module allows you to resize the raid and party icons on the world map."],
},
enabled = {
order = 2,
type = "toggle",
name = L["Enable Group Icons"],
get = function() return Mapster:GetModuleEnabled(MODNAME) end,
set = function(info, value) Mapster:SetModuleEnabled(MODNAME, value) end,
},
size = {
order = 3,
type = "range",
name = L["Size on the World Map"],
min = 8, max = 48, step = 1,
get = function() return db.size end,
set = function(info, v)
db.size = v
GroupIcons:Refresh()
end
},
sizeBattleMap = {
order = 3,
type = "range",
name = L["Size on the Battle Map"],
min = 8, max = 48, step = 1,
get = function() return db.sizeBattleMap end,
set = function(info, v)
db.sizeBattleMap = v
GroupIcons:Refresh()
end
}
}
}
end
return options
end
function GroupIcons:OnInitialize()
self.db = Mapster.db:RegisterNamespace(MODNAME, defaults)
db = self.db.profile
self:SetEnabledState(Mapster:GetModuleEnabled(MODNAME))
Mapster:RegisterModuleOptions(MODNAME, getOptions, L["Group Icons"])
end
function GroupIcons:OnEnable()
if not C_AddOns.IsAddOnLoaded("Blizzard_BattlefieldMinimap") then
self:RegisterEvent("ADDON_LOADED", function(event, addon)
if addon == "Blizzard_BattlefieldMinimap" then
GroupIcons:UnregisterEvent("ADDON_LOADED")
FixBattlefieldUnits(true)
self:UnregisterEvent("ADDON_LOADED")
end
end)
else
FixBattlefieldUnits(true)
end
FixWorldMapUnits(true)
end
function GroupIcons:Refresh()
db = self.db.profile
FixWorldMapUnits(self:IsEnabled())
FixBattlefieldUnits(self:IsEnabled())
end
function GroupIcons:OnDisable()
FixWorldMapUnits(false)
FixBattlefieldUnits(false)
end
local function FixUnit(unit, state, size, defSize)
local frame = _G[unit]
if not frame then return end
if state then
frame:SetWidth(size)
frame:SetHeight(size)
else
frame:SetWidth(defSize)
frame:SetHeight(defSize)
end
end
function FixWorldMapUnits(state)
local size = db.size
for i = 1, 4 do
FixUnit(fmt("WorldMapParty%d", i), state, size, DEFAULT_WORLDMAP_SIZE)
end
for i = 1,40 do
FixUnit(fmt("WorldMapRaid%d", i), state, size, DEFAULT_WORLDMAP_SIZE)
end
end
function FixBattlefieldUnits(state)
if BattlefieldMinimap then
local size = db.sizeBattleMap
for i = 1, 4 do
FixUnit(fmt("BattlefieldMinimapParty%d", i), state, size, DEFAULT_BATTLEMAP_SIZE)
end
for i = 1, 40 do
FixUnit(fmt("BattlefieldMinimapRaid%d", i), state, size, DEFAULT_BATTLEMAP_SIZE)
end
end
end