-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCore.lua
128 lines (110 loc) · 3.46 KB
/
Core.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
local name,addon = ...;
local tsv = LibStub("AceAddon-3.0"):NewAddon("TrueStatValues", "AceConsole-3.0", "AceEvent-3.0")
--[[----------------------------------------------------------------------------
Defaults
------------------------------------------------------------------------------]]
local function Color(r,g,b,a)
local t = {};
t.r = r;
t.g = g;
t.b = b;
t.a = a or 1;
return t;
end
local defaults = {
global = {
showStatTooltips=true,
showItemTooltips=true,
fontColor=Color(68/255,173/255,255/255,1),
}
}
local num_pattern = "%.2f";
--[[----------------------------------------------------------------------------
Options
------------------------------------------------------------------------------]]
local _TEST=nil;
local options = {
name = "True Stat Values",
handler = tsv,
childGroups = "tab",
type = "group",
args = {
optionsTab = {
name = "Options",
type = "group",
order = 1,
args = {
headerSettings = {
name = "True Stat Value Settings",
desc = "",
type = "header",
order = 1
},
showStatTooltips = {
name = "Stat Tooltips",
desc = "When checked, displays True Stat Rating information on Secondary-Stat tooltips.",
type = "toggle",
order = 3,
width = "full",
get = function(info) return tsv.db.global.showStatTooltips end,
set = function(info,val) tsv.db.global.showStatTooltips = val; end
},
showItemTooltips = {
name = "Item Tooltips",
desc = "When checked, displays True Stat Rating information on Item tooltips.",
type = "toggle",
order = 5,
width = "full",
get = function(info) return tsv.db.global.showItemTooltips end,
set = function(info,val) tsv.db.global.showItemTooltips = val; end
},
fontColor = {
name = "Font Color",
type = "color",
order = 7,
get = function(info) return tsv.db.global.fontColor.r,tsv.db.global.fontColor.g,tsv.db.global.fontColor.b,tsv.db.global.fontColor.a end,
set = function(info,r,g,b,a)
tsv.db.global.fontColor = Color(r,g,b,a); --ignore alpha?
end
},
}
},
}
}
local BlizOptionsTable = {
name = "True Stat Values",
type = "group",
args = options
}
--[[----------------------------------------------------------------------------
Addon Initialized
------------------------------------------------------------------------------]]
function tsv:OnInitialize()
self.db = LibStub("AceDB-3.0"):New("TSV_DB", defaults)
LibStub("AceConfigRegistry-3.0"):RegisterOptionsTable("TSV_Bliz",options);
self.optionsFrame = LibStub("AceConfigDialog-3.0"):AddToBlizOptions("TSV_Bliz", "True Stat Values");
local tooltipEvents = {
"OnShow"
};
C_Timer.After(0.2,function()
for k,v in ipairs(tooltipEvents) do
GameTooltip:HookScript(v,function(tooltip,...)
tsv:OnTooltip(v,tooltip,...)
end);
end
end);
end
local function OnTooltipSetItem(tooltip, data)
if tooltip == GameTooltip then
tsv:OnTooltip("OnTooltipSetItem", tooltip)
end
end
local function OnTooltipSetSpell(tooltip, data)
if tooltip == GameTooltip then
tsv:OnTooltip("OnTooltipSetSpell",tooltip)
end
end
TooltipDataProcessor.AddTooltipPostCall(Enum.TooltipDataType.Item, OnTooltipSetItem)
TooltipDataProcessor.AddTooltipPostCall(Enum.TooltipDataType.Spell, OnTooltipSetSpell)
addon.SegmentLabels = SegmentLabels;
addon.tsv = tsv;