-
Notifications
You must be signed in to change notification settings - Fork 0
/
init.lua
executable file
·362 lines (290 loc) · 13.3 KB
/
init.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
--[[
--]]
local addon, DraeUI = ...
LibStub("AceAddon-3.0"):NewAddon(DraeUI, addon, "AceEvent-3.0")
local LSM = LibStub("LibSharedMedia-3.0")
--
local CreateFrame = CreateFrame
local UnitClass, UnitName, GetRealmName, UnitGUID, GetScreenHeight, GetScreenWidth, GetCVar = UnitClass, UnitName, GetRealmName, UnitGUID, GetScreenHeight, GetScreenWidth, GetCVar
local select, mfloor, tonumber, smatch = select, math.floor, tonumber, string.match
local OrderHallCommandBar, ArenaPrepFrames, ArenaEnemyFrames = OrderHallCommandBar, ArenaPrepFrames, ArenaEnemyFrames
local ReloadUI, DoReadyCheck = ReloadUI, DoReadyCheck
local CHAT_FONT_HEIGHTS = CHAT_FONT_HEIGHTS
--
DraeUI.defaults = {
global = {},
}
--[[
OnInitialize fires after ADDON_LOADED
OnEnabled fires after PLAYER_LOGIN
--]]
DraeUI.OnInitialize = function(self)
self.playerClass = select(2, UnitClass("player"))
self.playerName = UnitName("player")
self.playerRealm = GetRealmName()
self.playerGuid = UnitGUID("player")
--[[
.db -> (profile) -> data stored under "name-realm" tables and available to all chars on this account
.dbGlobal -> (global) -> data stored under single table available to all chars on this account
.dbClass -> (class) -> data stored under class name
.dbChar -> (profile) -> data stored under "name-realm" tables and accessible to only this char
--]]
--]]
local db = LibStub("AceDB-3.0"):New("draeUIDB") -- Default to our defaults (C. setup)
self.dbGlobal = db.global
self.media = {
font = LSM:Fetch("font", self.config["general"].font) or "Interface\\AddOns\\draeUI\\media\\fonts\\prozaregular-regular.ttf",
fontSmall = LSM:Fetch("font", self.config["general"].fontSmall) or "Interface\\AddOns\\draeUI\\media\\fonts\\liberationsans.ttf",
fontTitles = LSM:Fetch("font", self.config["general"].fontTitles) or "Interface\\AddOns\\draeUI\\media\\fonts\\vollkorn-medium.ttf",
statusbar = LSM:Fetch("statusbar", self.config["general"].statusbar) or "Interface\\AddOns\\draeUI\\media\\statusbars\\striped",
statusbar_power = LSM:Fetch("statusbar", self.config["general"].statusbar_power) or "Interface\\AddOns\\draeUI\\media\\statusbars\\striped",
statusbar_raid = LSM:Fetch("statusbar", self.config["general"].statusbar_raid) or "Interface\\AddOns\\draeUI\\media\\statusbars\\hgrad",
statusbar_raid_power = LSM:Fetch("statusbar", self.config["general"].statusbar_raid_power) or "Interface\\AddOns\\draeUI\\media\\statusbars\\hgrad",
sound1 = LSM:Fetch("sound", self.config["general"].sound1) or "Interface\\AddOns\\draeUI\\media\\sounds\\heart.ogg"
}
end
DraeUI.OnEnable = function(self)
self.screenHeight = mfloor(GetScreenHeight() * 100 + .5) / 100
self.screenWidth = mfloor(GetScreenWidth() * 100 + .5) / 100
self.uiScale = tonumber(GetCVar("uiScale"))
self:RegisterEvent("ADDON_LOADED", "ADDON_LOADED")
self:RegisterEvent("PLAYER_ENTERING_WORLD", "UpdateFonts")
self:ADDON_LOADED()
end
do
local ChangeFont = function(obj, font, size, style, r, g, b, sr, sg, sb, sa, sox, soy)
if (obj == nil) then return end
local oldFont, oldSize, oldStyle = obj:GetFont()
if (not size) then
size = oldSize
end
if (not style) then
style = (oldStyle == "OUTLINE") and "THINOUTLINE" or oldStyle -- keep outlines thin
end
obj:SetFont(font, size, style)
if (sox and soy) then
obj:SetShadowOffset(sox, soy)
obj:SetShadowColor(sr or 0, sg or 0, sb or 0, sa or 1)
end
if (r and g and b) then
obj:SetTextColor(r, g, b)
end
return obj
end
local UpdateChatFontSizes = function()
CHAT_FONT_HEIGHTS = { 8, 9, 10, 11, 12, 13, 14, 15, 16, 18, 20 }
end
DraeUI.UpdateFonts = function(self)
-- Change fonts
local FontStandard = self.media.font
local FontSmall = self.media.fontSmall
local FontTitles = self.media.fontTitles
local SizeSmall = 10.5
local SizeMedium = 12.5
local SizeLarge = 16.5
local SizeHuge = 18.5
local SizeInsane = 22.5
-- Game engine fonts
STANDARD_TEXT_FONT = FontStandard
NAMEPLATE_FONT = FontStandard
UIDROPDOWNMENU_DEFAULT_TEXT_HEIGHT = 14
-- Base fonts
ChangeFont(SystemFont_Tiny , FontSmall , SizeSmall , nil)
ChangeFont(SystemFont_Small , FontSmall , SizeSmall , nil)
ChangeFont(SystemFont_Outline_Small , FontSmall , SizeSmall , "THINOUTLINE")
ChangeFont(SystemFont_Shadow_Small , FontSmall , SizeSmall , nil)
ChangeFont(SystemFont_InverseShadow_Small , FontSmall , SizeSmall , nil)
ChangeFont(SystemFont_Med1 , FontStandard , SizeMedium , nil)
ChangeFont(SystemFont_Shadow_Med1 , FontStandard , SizeMedium , nil)
ChangeFont(SystemFont_Med2 , FontStandard , SizeMedium , nil)
ChangeFont(SystemFont_Med3 , FontStandard , SizeMedium , nil)
ChangeFont(SystemFont_Shadow_Med3 , FontStandard , SizeMedium , nil)
ChangeFont(SystemFont_Large , FontStandard , SizeLarge , nil)
ChangeFont(SystemFont_Shadow_Large , FontStandard , SizeLarge , nil)
ChangeFont(SystemFont_Shadow_Huge1 , FontStandard , SizeHuge , nil)
ChangeFont(SystemFont_Shadow_Outline_Large , FontStandard , SizeHuge , "THICKOUTLINE")
ChangeFont(SystemFont_OutlineThick_Huge2 , FontStandard , SizeHuge , "THICKOUTLINE")
ChangeFont(SystemFont_Shadow_Huge3 , FontStandard , SizeHuge , nil)
ChangeFont(SystemFont_Shadow_Outline_Huge2 , FontStandard , SizeHuge , "THICKOUTLINE")
ChangeFont(SystemFont_OutlineThick_Huge4 , FontStandard , SizeHuge , "THICKOUTLINE")
ChangeFont(SystemFont_OutlineThick_WTF , FontStandard , SizeInsane , "THICKOUTLINE")
ChangeFont(GameFontNormal , FontStandard , SizeMedium , nil)
ChangeFont(GameFontWhite , FontStandard , SizeMedium , nil)
ChangeFont(GameFontWhiteSmall , FontSmall , SizeSmall , nil)
ChangeFont(GameFontBlack , FontStandard , SizeMedium , nil)
ChangeFont(GameFontBlackSmall , FontSmall , SizeSmall , nil)
ChangeFont(GameFontNormalMed2 , FontTitles , SizeMedium , nil)
ChangeFont(GameFontNormalLarge , FontStandard , SizeLarge , nil)
ChangeFont(GameFontNormalLargeOutline , FontStandard , SizeLarge , "THINOUTLINE")
ChangeFont(GameFontHighlightSmall , FontStandard , SizeSmall , nil)
ChangeFont(GameFontHighlight , FontStandard , SizeMedium , nil)
ChangeFont(GameFontHighlightLeft , FontStandard , SizeMedium , nil)
ChangeFont(GameFontHighlightRight , FontStandard , SizeMedium , nil)
ChangeFont(GameFontHighlightLarge2 , FontStandard , SizeMedium , nil)
ChangeFont(GameFont_Gigantic , FontStandard , SizeHuge , nil)
ChangeFont(GameFontNormalSmall , FontSmall , SizeSmall , nil)
ChangeFont(GameFontNormalSmall2 , FontSmall , SizeSmall , nil)
ChangeFont(GameTooltipHeader , FontTitles , SizeMedium , nil)
ChangeFont(NumberFont_Shadow_Small , FontSmall , SizeSmall , nil)
ChangeFont(NumberFont_OutlineThick_Mono_Small , FontStandard , SizeMedium , "OUTLINE")
ChangeFont(NumberFont_Shadow_Med , FontStandard , SizeMedium , nil)
ChangeFont(NumberFont_Outline_Med , FontStandard , SizeMedium , "THINOUTLINE")
ChangeFont(NumberFont_Outline_Large , FontStandard , SizeLarge , "THINOUTLINE")
ChangeFont(NumberFont_Outline_Huge , FontStandard , SizeHuge , "THINOUTLINE")
ChangeFont(WhiteNormalNumberFont , FontStandard , SizeMedium , "THINOUTLINE")
ChangeFont(QuestFont , FontStandard , SizeMedium , nil)
ChangeFont(QuestFont_Large , FontTitles , SizeLarge , nil)
ChangeFont(QuestFont_Huge , FontTitles , SizeHuge , nil)
ChangeFont(QuestFont_Super_Huge , FontTitles , SizeHuge , nil)
ChangeFont(QuestFont_Shadow_Huge , FontTitles , SizeHuge , nil)
ChangeFont(QuestFont_Enormous , FontTitles , SizeInsane , nil)
ChangeFont(ObjectiveFont , FontStandard , SizeMedium , nil)
ChangeFont(GameTooltipHeader , FontStandard , SizeMedium , nil)
ChangeFont(MailFont_Large , FontTitles , SizeMedium , nil)
ChangeFont(SpellFont_Small , FontSmall , SizeSmall , nil)
ChangeFont(InvoiceFont_Med , FontStandard , SizeMedium , nil)
ChangeFont(InvoiceFont_Small , FontSmall , SizeSmall , nil)
ChangeFont(Tooltip_Med , FontStandard , SizeMedium , nil)
ChangeFont(Tooltip_Small , FontSmall , SizeSmall , nil)
ChangeFont(AchievementFont_Small , FontSmall , SizeSmall , nil)
ChangeFont(ReputationDetailFont , FontSmall , SizeSmall , nil)
ChangeFont(FriendsFont_UserText , FontSmall , SizeSmall , nil)
ChangeFont(FriendsFont_Normal , FontStandard , SizeMedium , nil)
ChangeFont(FriendsFont_Small , FontSmall , SizeSmall , nil)
ChangeFont(FriendsFont_Large , FontStandard , SizeLarge , nil)
UpdateChatFontSizes()
hooksecurefunc("FCF_ResetChatWindows", UpdateChatFontSizes)
end
end
DraeUI.ADDON_LOADED = function(self)
if (IsAddOnLoaded("Blizzard_OrderHallUI") and OrderHallCommandBar ~= nil) then
OrderHallCommandBar:Hide()
OrderHallCommandBar:UnregisterAllEvents()
OrderHallCommandBar.Show = OrderHallCommandBar.Hide
end
-- Hide ArenaUI
if (IsAddOnLoaded("Blizzard_ArenaUI") and self.db.frames.showArena) then
SetCVar('showArenaEnemyFrames', '0', 'SHOW_ARENA_ENEMY_FRAMES_TEXT')
ArenaPrepFrames.Show = ArenaPrepFrames.Hide
ArenaPrepFrames:UnregisterAllEvents()
ArenaPrepFrames:Hide()
ArenaEnemyFrames.Show = ArenaEnemyFrames.Hide
ArenaEnemyFrames:UnregisterAllEvents()
ArenaEnemyFrames:Hide()
end
end
-- Console commands
do
-- /rl - ReloadUI end
local UIReload = function()
ReloadUI()
end
-- /rar - ReadyCheck
local ReadyCheck = function()
DoReadyCheck()
end
-- /draeui grid X - Draw a grid, default or at X "pixels"
local ConsoleGrid
do
local grid
local AlignGridCreate = function(gridSize)
if (not grid or (gridSize and grid.gridSize ~= gridSize)) then
grid = nil
grid = CreateFrame("Frame", nil, UIParent)
grid:SetAllPoints(UIParent)
end
gridSize = gridSize or 128
grid.gridSize = gridSize
local size = 2
local width = DraeUI.screenWidth
local ratio = width / DraeUI.screenHeight
local height = DraeUI.screenHeight * ratio
local wStep = width / gridSize
local hStep = height / gridSize
for i = 0, gridSize do
local tx = grid:CreateTexture(nil, "BACKGROUND")
if (i == gridSize / 2 ) then
tx:SetColorTexture(1, 0, 0, 0.5)
else
tx:SetColorTexture(0, 0, 0, 0.5)
end
tx:SetPoint("TOPLEFT", grid, "TOPLEFT", i * wStep - (size / 2), 0)
tx:SetPoint("BOTTOMRIGHT", grid, "BOTTOMLEFT", i * wStep + (size / 2), 0)
end
height = DraeUI.screenHeight
do
local tx = grid:CreateTexture(nil, "BACKGROUND")
tx:SetColorTexture(1, 0, 0, 0.5)
tx:SetPoint("TOPLEFT", grid, "TOPLEFT", 0, -(height / 2) + (size / 2))
tx:SetPoint("BOTTOMRIGHT", grid, "TOPRIGHT", 0, -(height / 2 + size / 2))
end
for i = 1, mfloor((height / 2) / hStep) do
local tx = grid:CreateTexture(nil, "BACKGROUND")
tx:SetColorTexture(0, 0, 0, 0.5)
tx:SetPoint("TOPLEFT", grid, "TOPLEFT", 0, -(height / 2 + i * hStep) + (size / 2))
tx:SetPoint("BOTTOMRIGHT", grid, "TOPRIGHT", 0, -(height / 2 + i * hStep + size / 2))
tx = grid:CreateTexture(nil, "BACKGROUND")
tx:SetColorTexture(0, 0, 0, 0.5)
tx:SetPoint("TOPLEFT", grid, "TOPLEFT", 0, -(height / 2 - i * hStep) + (size / 2))
tx:SetPoint("BOTTOMRIGHT", grid, "TOPRIGHT", 0, -(height / 2 - i * hStep + size / 2))
end
end
local AlignGridShow = function(gridSize)
if (not grid or (gridSize and grid.gridSize ~= gridSize)) then
AlignGridCreate(gridSize)
end
grid:Show()
end
local AlignGridHide = function(gridSize)
if (not grid) then return end
grid:Hide()
if (gridSize and grid.gridSize ~= gridSize) then
AlignGridCreate(gridSize)
end
end
local AlignGridToggle = function(gridSize)
if (grid and grid:IsVisible()) then
AlignGridHide(gridSize)
else
AlignGridShow(gridSize)
end
end
ConsoleGrid = function(grid_size)
if (grid_size and type(tonumber(grid_size)) == "number" and tonumber(grid_size) <= 256 and tonumber(grid_size) >= 4) then
AlignGridToggle(grid_size)
else
AlignGridToggle()
end
end
end
-- /draeui hide - Hide the UI and show friendly names (photos!)
local DraeHideUI = function()
if (InCombatLockdown()) then return end
if (UIParent:IsShown())then
UIParent:Hide()
SetCVar("UnitNameOwn", 1)
SetCVar("UnitNameFriendlyPlayerName", 1)
else
UIParent:Show()
SetCVar("UnitNameOwn", 0)
SetCVar("UnitNameFriendlyPlayerName", 0)
end
end
-- Setup the commands
SLASH_DRAEUI_RELOADUI1 = "/rl"
SlashCmdList["DRAEUI_RELOADUI"] = UIReload
SLASH_DRAEUI_RAR1 = "/rar"
SlashCmdList["DRAEUI_RAR"] = ReadyCheck
SLASH_DRAEUI1 = "/draeui"
SlashCmdList["DRAEUI"] = function(msg)
if (msg) then
msg = string.lower(msg)
if (msg == "hide") then
DraeHideUI()
elseif (smatch(msg, "^grid ?[0-9]*")) then
local grid_size = smatch(msg, "^grid ?([0-9]*)")
ConsoleGrid(grid_size)
end
end
end
end