-
Notifications
You must be signed in to change notification settings - Fork 4
/
Initialize.lua
191 lines (170 loc) · 5.5 KB
/
Initialize.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
local RUF = LibStub("AceAddon-3.0"):NewAddon("RUF", "AceConsole-3.0", "AceComm-3.0", "AceEvent-3.0", "AceSerializer-3.0", "AceTimer-3.0", "NickTag-1.0")
local _, ns = ...
local oUF = ns.oUF
local L = LibStub('AceLocale-3.0'):GetLocale('RUF')
local ACD = LibStub('AceConfigDialog-3.0')
local LSM = LibStub('LibSharedMedia-3.0')
local includedLayouts = {
"Alidie's Layout",
"Raeli's Layout",
}
local versionFromToc = GetAddOnMetadata('RUF','Version')
local versionFromPackager = "@project-version@"
local isDev = false
--@do-not-package@
if versionFromToc == "@project-version@" then
versionFromToc = 'Dev'
isDev = true
end
--@end-do-not-package@
function RUF.IsRetail()
return WOW_PROJECT_ID == WOW_PROJECT_MAINLINE
end
function RUF.IsClassic()
return WOW_PROJECT_ID == WOW_PROJECT_CLASSIC
end
function RUF.IsBCC()
return WOW_PROJECT_ID == WOW_PROJECT_BURNING_CRUSADE_CLASSIC
end
function RUF.IsWrath()
return WOW_PROJECT_ID == WOW_PROJECT_WRATH_CLASSIC
end
function RUF.GetClientVariant()
if RUF.IsRetail() then return WOW_PROJECT_MAINLINE
elseif RUF.IsWrath() then return WOW_PROJECT_WRATH_CLASSIC
elseif RUF.IsBCC() then return WOW_PROJECT_BURNING_CRUSADE_CLASSIC
elseif RUF.IsClassic() then return WOW_PROJECT_CLASSIC
end
end
local frames = {}
local groupFrames = {}
local headers = {}
if RUF.IsClassic() then
frames = {
'Player',
'Pet',
'PetTarget',
'Target',
'TargetTarget',
'TargetTargetTarget',
}
groupFrames = {
'PartyTarget',
'PartyPet',
}
headers = {
'Party',
}
else
frames = {
'Player',
'Pet',
'PetTarget',
'Focus',
'FocusTarget',
'Target',
'TargetTarget',
'TargetTargetTarget',
}
groupFrames = {
'Boss',
'BossTarget',
'Arena',
'ArenaTarget',
'PartyTarget',
'PartyPet',
}
headers = {
'Party',
}
end
RUF.frameList = {}
RUF.frameList.frames = frames
RUF.frameList.groupFrames = groupFrames
RUF.frameList.headers = headers
function RUF:OnInitialize()
self.db = LibStub('AceDB-3.0'):New('RUFDB', RUF.Layout.cfg, true) -- Setup Saved Variables
if RUF.IsRetail() then
local LibDualSpec = LibStub('LibDualSpec-1.0')
LibDualSpec:EnhanceDatabase(self.db, 'RUF')
else
local LibClassicDurations = LibStub('LibClassicDurations', true)
if LibClassicDurations then
LibClassicDurations:Register(RUF)
end
end
-- Register /RUF command
self:RegisterChatCommand('RUF', 'ChatCommand')
-- Profile Management
self.db.RegisterCallback(self, 'OnProfileChanged', 'RefreshConfig')
self.db.RegisterCallback(self, 'OnProfileCopied', 'RefreshConfig')
self.db.RegisterCallback(self, 'OnProfileReset', 'ResetProfile')
-- Register Media
LSM:Register('font', 'RUF', [[Interface\Addons\RUF\Media\TGL.ttf]],LSM.LOCALE_BIT_ruRU + LSM.LOCALE_BIT_western)
LSM:Register('statusbar', 'RUF 1', [[Interface\Addons\RUF\Media\Raeli 1.tga]])
LSM:Register('statusbar', 'RUF 2', [[Interface\Addons\RUF\Media\Raeli 2.tga]])
LSM:Register('statusbar', 'RUF 3', [[Interface\Addons\RUF\Media\Raeli 3.tga]])
LSM:Register('statusbar', 'RUF 4', [[Interface\Addons\RUF\Media\Raeli 4.tga]])
LSM:Register('statusbar', 'RUF 5', [[Interface\Addons\RUF\Media\Raeli 5.tga]])
LSM:Register('statusbar', 'RUF 6', [[Interface\Addons\RUF\Media\Raeli 6.tga]])
LSM:Register('statusbar', 'Armory',[[Interface\Addons\RUF\Media\Extra\Armory.tga]])
LSM:Register('statusbar', 'Cabaret 2', [[Interface\Addons\RUF\Media\Extra\Cabaret 2.tga]])
LSM:Register('border','RUF Pixel', [[Interface\ChatFrame\ChatFrameBackground]])
LSM:Register('border','RUF Glow', [[Interface\Addons\RUF\Media\InternalGlow.tga]])
LSM:Register('border','RUF Glow Small', [[Interface\Addons\RUF\Media\InternalGlowSmall.tga]])
LSM:Register('font','Overwatch Oblique',[[Interface\Addons\RUF\Media\Extra\BigNoodleTooOblique.ttf]])
LSM:Register('font','Overwatch',[[Interface\Addons\RUF\Media\Extra\BigNoodleToo.ttf]])
LSM:Register('font','Futura',[[Interface\Addons\RUF\Media\Extra\Futura.ttf]])
LSM:Register('font','Semplicita Light',[[Interface\Addons\RUF\Media\Extra\semplicita.light.otf]])
LSM:Register('font','Semplicita Light Italic',[[Interface\Addons\RUF\Media\Extra\semplicita.light-italic.otf]])
LSM:Register('font','Semplicita Medium',[[Interface\Addons\RUF\Media\Extra\semplicita.medium.otf]])
LSM:Register('font','Semplicita Medium Italic',[[Interface\Addons\RUF\Media\Extra\semplicita.medium-italic.otf]])
RUF.db.global.TestMode = false
RUF.db.global.frameLock = true
--project-revision
RUF.db.global.Version = GetAddOnMetadata('RUF','Version')
if not RUFDB.profiles then
RUF.FirstRun = true
RUFDB.profiles = {}
for i = 1,#includedLayouts do
RUFDB.profiles[includedLayouts[i]] = RUF.Layout[includedLayouts[i]]
end
else
for i = 1,#includedLayouts do
if not RUFDB.profiles[includedLayouts[i]] then
RUFDB.profiles[includedLayouts[i]] = RUF.Layout[includedLayouts[i]]
end
end
end
end
function RUF:ChatCommand(input)
if not InCombatLockdown() then
self:EnableModule('Options')
if ACD.OpenFrames['RUF'] then
ACD:Close('RUF')
else
ACD:Open('RUF')
end
else
RUF:Print_Self(L["Cannot configure while in combat."])
end
end
function RUF:ResetProfile()
local currentProfile = self.db:GetCurrentProfile()
for i = 1,#includedLayouts do
if includedLayouts[i] == currentProfile then
local profile = RUF.db.profile
local source = RUF.Layout[includedLayouts[i]]
RUF:copyTable(source, profile)
end
end
RUF:RefreshConfig()
RUF:GetModule('Options'):RefreshConfig()
end
function RUF:RefreshConfig()
if RUF.db.global.TestMode == true then
RUF:TestMode()
end
RUF.db.profile = self.db.profile
RUF:UpdateAllUnitSettings()
end