-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLCD4WoW.lua
141 lines (120 loc) · 3.55 KB
/
LCD4WoW.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
LCD4WoW = LibStub("AceAddon-3.0"):NewAddon("LCD4WoW: 1.1.15b", "AceConsole-3.0", "AceHook-3.0", "AceEvent-3.0", "AceComm-3.0", "AceSerializer-3.0")
LCD4WoW.version = GetAddOnMetadata("LCD4WoW", "X-LCD4WoW-Version") or ""
local LibDBIcon = LibStub("LibDBIcon-1.0")
local LSM = _G.LibStub("LibSharedMedia-3.0")
local LDB = LibStub:GetLibrary("LibDataBroker-1.1")
local AceConfigDialog = LibStub("AceConfigDialog-3.0")
local LibError = LibStub("LibScriptableUtilsError-1.0")
local LibQTip = LibStub("LibQTip-1.0")
local _G = _G
local GameTooltip = _G.GameTooltip
local ipairs, pairs = _G.ipairs, _G.pairs
local LDB = LibStub("LibDataBroker-1.1"):NewDataObject("LCD4WoW", {
type = "data source",
text = "LCD4WoW",
icon = "Interface\\Icons\\INV_Chest_Cloth_17",
OnClick = function() LCD4WoW:OpenConfig() end
})
local defaults = {profile={minimap={}, modules={}, errorLevel=1}}
local options = {
name = "LCD4WoW",
type = "group",
args = {}
}
function LCD4WoW:OnInitialize()
self.db = LibStub("AceDB-3.0"):New("LCD4WoWDB", defaults, "Default")
LibStub("AceConfig-3.0"):RegisterOptionsTable("LCD4WoW", options)
self:RegisterChatCommand("lcd4wow", "OpenConfig")
AceConfigDialog:AddToBlizOptions("LCD4WoW")
LibDBIcon:Register("LCD4WoWLDB", LDB, self.db.profile.minimap)
end
function LCD4WoW:OnEnable()
if self.db.profile.minimap.hide then
LibDBIcon:Hide("LCD4WoWLDB")
else
LibDBIcon:Show("LCD4WoWLDB")
end
for k,v in self:IterateModules() do
if (self.db.profile.modules[k] == nil and not v.defaultOff) or self.db.profile.modules[k] then
v:Enable()
end
end
self:RebuildOpts()
self:RegisterEvent("MODIFIER_STATE_CHANGED")
end
function LCD4WoW:OnDisable()
for k, v in self:IterateModules() do
v:Disable()
end
self:UnRegisterEvent("MODIFIER_STATE_CHANGED")
end
function LCD4WoW:OpenConfig()
AceConfigDialog:SetDefaultSize("LCD4WoW", 800, 450)
AceConfigDialog:Open("LCD4WoW")
end
function LCD4WoW:RebuildOpts()
local driver = self:GetModule("LCD4WoW")
options.args = driver:GetOptions()
options.args.errorLevel = {
name = "Error Verbosity",
type = "select",
values = LibError.defaultTexts,
get = function()
return self.db.profile.errorLevel
end,
set = function(info, v)
self.db.profile.errorLevel = v
end,
order = 100
}
end
-- Taken from CowTip and modified a bit
function LCD4WoW:MODIFIER_STATE_CHANGED(ev, modifier, up, ...)
for i, v in self:IterateModules() do
if v.MODIFIER_STATE_CHANGED then
v:MODIFIER_STATE_CHANGED(ev, modifier, up, ...)
end
end
local mod
if self.db.profile.modifier == 2 then
mod = (modifier == "LCTRL" or modifier == "RCTRL") and "LCTRL"
modifier = "LCTRL"
elseif self.db.profile.modifier == 3 then
mod = (modifier == "LALT" or modifier == "RALT") and "LALT"
modifier = "LALT"
elseif self.db.profilemodifier == 4 then
mod = (modifier == "LSHIFT" or modifier == "RSHIFT") and "LSHIFT"
modifier = "LSHIFT"
end
if mod ~= modifier then
return
end
if up == 0 then
GameTooltip:Hide()
return
end
local mouseover_unit = StarTip:GetMouseoverUnit()
local frame = GetMouseFocus()
if frame == WorldFrame or frame == UIParent then
if not UnitExists(mouseover_unit) then
GameTooltip:Hide()
return
end
GameTooltip:Hide()
GameTooltip_SetDefaultAnchor(GameTooltip, UIParent)
GameTooltip:SetUnit(mouseover_unit)
GameTooltip:Show()
else
local OnLeave, OnEnter = frame:GetScript("OnLeave"), frame:GetScript("OnEnter")
if OnLeave then
_G.this = frame
OnLeave(frame)
_G.this = nil
end
if OnEnter then
_G.this = frame
OnEnter(frame)
_G.this = nil
end
end
end