Details | Compare with Previous | View Log
Line No. | Rev | Author | Line |
---|---|---|---|
1 | 10 | Seerah-7 | local LAM = LibStub("LibAddonMenu-2.0") |
2 | Seerah-7 | local LMP = LibStub("LibMediaProvider-1.0") |
|
3 | Seerah-7 | local fonts = LMP:List("font") |
|
4 | Seerah-7 | local fontStyles = {"normal", "outline", "thick-outline", "shadow", "soft-shadow-thick", "soft-shadow-thin"} |
|
5 | Seerah-7 | local alignments = {"CENTER", "LEFT", "RIGHT"} |
|
6 | Seerah-7 | local modules = ZAM_Stats.modules |
|
7 | Seerah-7 | local RGBPercToHex = ZAM_Stats.RGBPercToHex |
|
8 | Seerah-7 | local ConfigModule = ZAM_Stats.ConfigModule |
|
9 | Seerah-7 | local db |
|
10 | Seerah-7 | ||
11 | Seerah-7 | local defaults = { |
|
12 | Seerah-7 | locked = false, |
|
13 | Seerah-7 | font = "Arial Narrow", |
|
14 | Seerah-7 | fsize = 18, |
|
15 | Seerah-7 | fstyle = "soft-shadow-thin", |
|
16 | Seerah-7 | align = "CENTER", |
|
17 | Seerah-7 | preColor = {r=1, g=1, b=1}, |
|
18 | Seerah-7 | sufColor = {r=1, g=1, b=1}, |
|
19 | Seerah-7 | } |
|
20 | Seerah-7 | ||
21 | Seerah-7 | ||
22 | Seerah-7 | local panelData = { |
|
23 | Seerah-7 | type = "panel", |
|
24 | Seerah-7 | name = "ZAM Stats", |
|
25 | Seerah-7 | displayName = "|t72:36:ZAM_Stats\\ZAM_Logo.dds|t Stats", |
|
26 | Seerah-7 | author = "Seerah", |
|
27 | 14 | Seerah-7 | version = "1.1.3", |
28 | 10 | Seerah-7 | slashCommand = "/zamstats", |
29 | Seerah-7 | registerForDefaults = true, |
|
30 | Seerah-7 | resetFunc = function() |
|
31 | Seerah-7 | for _,frame in pairs(modules) do |
|
32 | Seerah-7 | frame:ClearAnchors() |
|
33 | Seerah-7 | frame:SetAnchor(CENTER, GuiRoot, CENTER, 0, 0) |
|
34 | Seerah-7 | db[frame:GetName()].point = {["a"]=CENTER, ["b"]=CENTER, ["x"]=0, ["y"]=0} |
|
35 | Seerah-7 | end |
|
36 | Seerah-7 | CALLBACK_MANAGER:FireCallbacks("ZAM_Stats_Force_Refresh") |
|
37 | Seerah-7 | end, |
|
38 | Seerah-7 | } |
|
39 | Seerah-7 | ||
40 | Seerah-7 | local optionsData = { |
|
41 | Seerah-7 | [1] = { |
|
42 | Seerah-7 | type = "checkbox", |
|
43 | Seerah-7 | name = "Lock Modules", |
|
44 | Seerah-7 | tooltip = "Lock or unlock the modules to move them.", |
|
45 | Seerah-7 | getFunc = function() return db.locked end, |
|
46 | Seerah-7 | setFunc = function(value) |
|
47 | Seerah-7 | db.locked = value |
|
48 | Seerah-7 | for _,frame in pairs(modules) do |
|
49 | Seerah-7 | frame:SetMovable(not db.locked) |
|
50 | Seerah-7 | frame.bg:SetCenterColor(0,0,0, db.locked and 0 or .4) |
|
51 | Seerah-7 | end |
|
52 | Seerah-7 | end, |
|
53 | Seerah-7 | default = defaults.locked, |
|
54 | Seerah-7 | }, |
|
55 | Seerah-7 | [2] = { |
|
56 | Seerah-7 | type = "header", |
|
57 | Seerah-7 | name = "Font Settings", |
|
58 | Seerah-7 | }, |
|
59 | Seerah-7 | [3] = { |
|
60 | Seerah-7 | type = "dropdown", |
|
61 | Seerah-7 | name = "Font", |
|
62 | Seerah-7 | tooltip = "Set the font for the text.", |
|
63 | Seerah-7 | choices = fonts, |
|
64 | Seerah-7 | getFunc = function() return db.font end, |
|
65 | Seerah-7 | setFunc = function(font) |
|
66 | Seerah-7 | db.font = font |
|
67 | Seerah-7 | for k,v in pairs(modules) do |
|
68 | Seerah-7 | ConfigModule(v) |
|
69 | Seerah-7 | end |
|
70 | Seerah-7 | end, |
|
71 | Seerah-7 | default = defaults.font, |
|
72 | Seerah-7 | }, |
|
73 | Seerah-7 | [4] = { |
|
74 | Seerah-7 | type = "slider", |
|
75 | Seerah-7 | name = "Font Size", |
|
76 | Seerah-7 | tooltip = "Set the size of the modules' text.", |
|
77 | Seerah-7 | min = 8, |
|
78 | Seerah-7 | max = 30, |
|
79 | Seerah-7 | step = 1, |
|
80 | Seerah-7 | getFunc = function() return db.fsize end, |
|
81 | Seerah-7 | setFunc = function(value) |
|
82 | Seerah-7 | db.fsize = value |
|
83 | Seerah-7 | for k,v in pairs(modules) do |
|
84 | Seerah-7 | ConfigModule(v) |
|
85 | Seerah-7 | end |
|
86 | Seerah-7 | end, |
|
87 | Seerah-7 | default = defaults.fsize, |
|
88 | Seerah-7 | }, |
|
89 | Seerah-7 | [5] = { |
|
90 | Seerah-7 | type = "dropdown", |
|
91 | Seerah-7 | name = "Font Style", |
|
92 | Seerah-7 | tooltip = "Set the style to apply to the text.", |
|
93 | Seerah-7 | choices = fontStyles, |
|
94 | Seerah-7 | getFunc = function() return db.fstyle end, |
|
95 | Seerah-7 | setFunc = function(style) |
|
96 | Seerah-7 | db.fstyle = style |
|
97 | Seerah-7 | for k,v in pairs(modules) do |
|
98 | Seerah-7 | ConfigModule(v) |
|
99 | Seerah-7 | end |
|
100 | Seerah-7 | end, |
|
101 | Seerah-7 | default = defaults.fstyle, |
|
102 | Seerah-7 | }, |
|
103 | Seerah-7 | [6] = { |
|
104 | Seerah-7 | type = "dropdown", |
|
105 | Seerah-7 | name = "Text Alignment", |
|
106 | Seerah-7 | tooltip = "Set the text's horizontal alignment.", |
|
107 | Seerah-7 | choices = alignments, |
|
108 | Seerah-7 | getFunc = function() return db.align end, |
|
109 | Seerah-7 | setFunc = function(align) |
|
110 | Seerah-7 | db.align = align |
|
111 | Seerah-7 | for k,v in pairs(modules) do |
|
112 | Seerah-7 | ConfigModule(v) |
|
113 | Seerah-7 | end |
|
114 | Seerah-7 | end, |
|
115 | Seerah-7 | default = defaults.align, |
|
116 | Seerah-7 | }, |
|
117 | Seerah-7 | [7] = { |
|
118 | Seerah-7 | type = "header", |
|
119 | Seerah-7 | name = "Color Settings", |
|
120 | Seerah-7 | }, |
|
121 | Seerah-7 | [8] = { |
|
122 | Seerah-7 | type = "colorpicker", |
|
123 | Seerah-7 | name = "Prefix Color", |
|
124 | Seerah-7 | tooltip = "The color of the module's value.", |
|
125 | Seerah-7 | getFunc = function() return db.preColor.r, db.preColor.g, db.preColor.b end, |
|
126 | Seerah-7 | setFunc = function(r,g,b,a) |
|
127 | Seerah-7 | db.preColor.r = r |
|
128 | Seerah-7 | db.preColor.g = g |
|
129 | Seerah-7 | db.preColor.b = b |
|
130 | Seerah-7 | ZAM_Stats.preHex = RGBPercToHex(r,g,b) |
|
131 | Seerah-7 | end, |
|
132 | Seerah-7 | width = "half", |
|
133 | Seerah-7 | default = defaults.preColor, |
|
134 | Seerah-7 | }, |
|
135 | Seerah-7 | [9] = { |
|
136 | Seerah-7 | type = "colorpicker", |
|
137 | Seerah-7 | name = "Suffix Color", |
|
138 | Seerah-7 | tooltip = "The color of the module's suffix text.", |
|
139 | Seerah-7 | getFunc = function() return db.sufColor.r, db.sufColor.g, db.sufColor.b end, |
|
140 | Seerah-7 | setFunc = function(r,g,b,a) |
|
141 | Seerah-7 | db.sufColor.r = r |
|
142 | Seerah-7 | db.sufColor.g = g |
|
143 | Seerah-7 | db.sufColor.b = b |
|
144 | Seerah-7 | ZAM_Stats.sufHex = RGBPercToHex(r,g,b) |
|
145 | Seerah-7 | end, |
|
146 | Seerah-7 | width = "half", |
|
147 | Seerah-7 | default = defaults.sufColor, |
|
148 | Seerah-7 | }, |
|
149 | Seerah-7 | [10] = { |
|
150 | Seerah-7 | type = "button", |
|
151 | Seerah-7 | name = "Force Color Refresh", |
|
152 | Seerah-7 | tooltip = "Some modules may not change their text color until the data next updates. Click the button to force a refresh if you have a module like this enabled.", |
|
153 | Seerah-7 | func = function() CALLBACK_MANAGER:FireCallbacks("ZAM_Stats_Force_Refresh") end, |
|
154 | Seerah-7 | }, |
|
155 | Seerah-7 | } |
|
156 | Seerah-7 | ||
157 | Seerah-7 | ||
158 | Seerah-7 | function ZAM_Stats.SetUpSavedVars() |
|
159 | Seerah-7 | ZAM_StatsDB = ZAM_StatsDB or {} |
|
160 | Seerah-7 | for k,v in pairs(defaults) do |
|
161 | Seerah-7 | if type(ZAM_StatsDB[k]) == "nil" then |
|
162 | Seerah-7 | ZAM_StatsDB[k] = v |
|
163 | Seerah-7 | end |
|
164 | Seerah-7 | end |
|
165 | Seerah-7 | db = ZAM_StatsDB |
|
166 | Seerah-7 | ||
167 | Seerah-7 | local name |
|
168 | Seerah-7 | for k,v in pairs(modules) do |
|
169 | Seerah-7 | name = v:GetName() |
|
170 | Seerah-7 | db[name] = db[name] or {} |
|
171 | Seerah-7 | end |
|
172 | Seerah-7 | ||
173 | Seerah-7 | return db |
|
174 | Seerah-7 | end |
|
175 | Seerah-7 | ||
176 | Seerah-7 | function ZAM_Stats.RegisterOptions() |
|
177 | Seerah-7 | LAM:RegisterAddonPanel("ZAMStatsOptions", panelData) |
|
178 | Seerah-7 | LAM:RegisterOptionControls("ZAMStatsOptions", optionsData) |
|
179 | Seerah-7 | end |