-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathZygorGuidesViewerOptions.lua
More file actions
388 lines (338 loc) · 12.9 KB
/
ZygorGuidesViewerOptions.lua
File metadata and controls
388 lines (338 loc) · 12.9 KB
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
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
local ZGV = ZygorGuidesViewer
local L = ZygorGuidesViewer_L("Main")
function toboolean(value)
if value then return true else return false end
end
function MakeOptionsControls(self,options,host)
local ctrl,pctrl,pctrly
if type(options)~="table" then error("Parameter 1 must be an Ace-style 'options' table.") end
if host and type(host)~="table" then error("Parameter 2 must be an object hosting callback methods.") end
if type(options.args)~="table" then error("Parameter 1 must be an Ace-style 'options' table, with an 'args' field.") end
local title, subText = self:MakeTitleTextAndSubText(options.name, options.desc)
pctrl = subText
pctrly = 16
for k,v in pairs(options.args) do
if (v.type=="group") then
--AddSuboptionsPanel(v.name, function(self)
elseif (v.type=="range") then
ctrl = self:MakeSlider(
'name', v.name,
'description', v.desc,
'minText', v.minText or tostring(v.min),
'maxText', v.maxText or tostring(v.max),
'minValue', v.min, -- v.isPercent and ... * 100 ...
'maxValue', v.max,
'step', v.step,
'bigstep', v.bigstep,
'default', v.max,
'setFunc', function(value) return host[v.set](host,value) end,
'getFunc', function() return host[v.get](host) end
)
ctrl:SetPoint("TOPLEFT", pctrl, "BOTTOMLEFT", 0, -pctrly - 15)
pctrl = ctrl
pctrly = 10
elseif (v.type=="toggle") then
ctrl = self:MakeToggle(
'name', v.name,
'description', v.desc,
'default', toboolean(v.default),
'setFunc', function(value) return host[v.set](host,value) end,
'getFunc', function() return host[v.get](host) end
)
ctrl:SetPoint("TOPLEFT", pctrl, "BOTTOMLEFT", 0, -pctrly)
pctrl = ctrl
pctrly = 0
end
end
end
--ZGVLSO = {}
--ZGVLSO[options_title]['optiongroups'] = {}
--[[
AddOptionsPanel(function(self)
if 1 then return end
local versionText = self:CreateFontString(nil, "ARTWORK", "GameFontHighlightSmall")
local format, height, website
format = L["Version %s. There may be more up-to-date versions on %s"]
height = 20
website = "zygorguides.com"
versionText:SetText(format:format(Cartographer3.version, website))
versionText:SetNonSpaceWrap(true)
versionText:SetJustifyH("LEFT")
versionText:SetJustifyV("TOP")
versionText:SetPoint("TOPLEFT", subText, "BOTTOMLEFT", 0, -8)
versionText:SetPoint("RIGHT", -32, 0)
-- versionText:SetHeight(height)
local openReportIssueBox, openDonateBox
do
local url
local function makeURLFrame()
makeURLFrame = nil
local function bumpFrameLevels(frame, amount)
frame:SetFrameLevel(frame:GetFrameLevel()+amount)
local children = newList(frame:GetChildren())
for _,v in ipairs(children) do
bumpFrameLevels(v, amount)
end
children = del(children)
end
-- some code borrowed from Prat here
StaticPopupDialogs["CARTOGRAPHER3_SHOW_URL"] = {
text = not IsMacClient() and L["Press Ctrl-C to copy, then Alt-Tab out of the game, open your favorite web browser, and paste the link into the address bar."] or L["Press Cmd-C to copy, then Cmd-Tab out of the game, open your favorite web browser, and paste the link into the address bar."],
button2 = ACCEPT,
hasEditBox = 1,
hasWideEditBox = 1,
showAlert = 1, -- HACK : it's the only way I found to make de StaticPopup have sufficient width to show WideEditBox :(
OnShow = function()
local editBox = _G[this:GetName() .. "WideEditBox"]
editBox:SetText(url)
editBox:SetFocus()
editBox:HighlightText(0)
editBox:SetScript("OnTextChanged", function() StaticPopup_EditBoxOnTextChanged() end)
local button = _G[this:GetName() .. "Button2"]
button:ClearAllPoints()
button:SetWidth(200)
button:SetPoint("CENTER", editBox, "CENTER", 0, -30)
_G[this:GetName() .. "AlertIcon"]:Hide() -- HACK : we hide the false AlertIcon
this:SetFrameStrata("FULLSCREEN_DIALOG")
this:SetFrameLevel(this:GetFrameLevel()+30)
end,
OnHide = function()
local editBox = _G[this:GetName() .. "WideEditBox"]
editBox:SetScript("OnTextChanged", nil)
this:SetFrameStrata("DIALOG")
this:SetFrameLevel(this:GetFrameLevel()-30)
end,
OnAccept = function() end,
OnCancel = function() end,
EditBoxOnEscapePressed = function() this:GetParent():Hide() end,
EditBoxOnTextChanged = function()
this:SetText(url)
this:SetFocus()
this:HighlightText(0)
end,
timeout = 0,
whileDead = 1,
hideOnEscape = 1
}
end
function openReportIssueBox()
if makeURLFrame then
makeURLFrame()
end
url = "http://wow.curseforge.com/projects/cartographer3/tickets/"
StaticPopup_Show("CARTOGRAPHER3_SHOW_URL")
end
function openDonateBox()
if makeURLFrame then
makeURLFrame()
end
url = "https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=ckknight%40gmail%2ecom&item_name=Cartographer3"
StaticPopup_Show("CARTOGRAPHER3_SHOW_URL")
end
end
local reportButton = self:MakeButton(
'name', L["Report Issue"],
'description', L["Report a defect or a possible enhancement you see with Cartographer3."],
'func', openReportIssueBox)
reportButton:SetPoint("TOPLEFT", versionText, "BOTTOMLEFT", 0, -16)
local donateButton = self:MakeButton(
'name', L["Donate"],
'description', L["Give a much-needed donation to ckknight, the author of Cartographer3."],
'func', openDonateBox)
donateButton:SetPoint("TOPRIGHT", versionText, "BOTTOMRIGHT", 0, -16)
local zoomToMinimapTextureSlider = self:MakeSlider(
'name', L["Texture Change Zoom"],
'description', L["The amount to zoom in before the map changes from minimap-style textures to artwork.\n\nNote: Setting this too far may cause severe framerate issues."],
'minText', L["Far"],
'maxText', L["Near"],
'minValue', 0,
'maxValue', 120,
'step', 1,
'default', Cartographer3.Data.DEFAULT_ZOOM_TO_MINIMAP_TEXTURE,
'current', Cartographer3.db.zoomToMinimapTexture,
'setFunc', function(value)
Cartographer3.db.zoomToMinimapTexture = value
end)
zoomToMinimapTextureSlider:SetPoint("TOPLEFT", reportButton, "BOTTOMLEFT", 0, -32)
local strataDropDown = self:MakeDropDown(
'name', L["Strata"],
'description', L["What level on the interface the map will show up on. 'Fullscreen' is the highest possible level and 'Background' is the lowest."],
'values', {
"FULLSCREEN", L["Fullscreen"],
"DIALOG", L["Dialog"],
"HIGH", L["High"],
"MEDIUM", L["Medium"],
"LOW", L["Low"],
"BACKGROUND", L["Background"]
},
'default', "FULLSCREEN",
'current', Cartographer3.db.strata,
'setFunc', function(value)
Cartographer3.SetFrameStrata(value)
end)
strataDropDown:SetPoint("TOPRIGHT", donateButton, "BOTTOMRIGHT", 13, -28)
local closeWithEscapeToggle = self:MakeToggle(
'name', L["Close map with escape key"],
'description', L["Set whether pressing the escape key will close the map or not."],
'default', true,
'current', Cartographer3.db.closeWithEscape,
'setFunc', function(value)
Cartographer3.db.closeWithEscape = value
end)
closeWithEscapeToggle:SetPoint("TOPLEFT", zoomToMinimapTextureSlider, "BOTTOMLEFT", 0, -24)
local opacitySlider = self:MakeSlider(
'name', L["Opacity"],
'description', L["The opacity of the Cartographer3 map"],
'minText', "10%",
'maxText', "100%",
'minValue', 0.1,
'maxValue', 1,
'step', 0.05,
'default', 1,
'current', Cartographer3.db.opacity,
'setFunc', function(value)
Cartographer3.SetOpacity(value)
end,
'currentTextFunc', function(value)
return ("%.0f%%"):format(value * 100)
end)
opacitySlider:SetPoint("TOPLEFT", closeWithEscapeToggle, "BOTTOMLEFT", 0, -24)
local unexploredColorPicker = self:MakeColorPicker(
'name', L["Unexplored color"],
'description', L["Set the color of unexplored areas on the Cartographer3 map. White shows everything and black obscures everything."],
'hasAlpha', true,
'defaultR', 1,
'defaultG', 1,
'defaultB', 1,
'defaultA', 1,
'getFunc', function()
return unpack(Cartographer3.db.unexploredColor)
end,
'setFunc', function(r, g, b, a)
Cartographer3.SetUnexploredColor(r, g, b, a)
end)
unexploredColorPicker:SetPoint("TOPLEFT", opacitySlider, "BOTTOMLEFT", 0, -32)
local alwaysShowBorderToggle = self:MakeToggle(
'name', L["Always show border"],
'description', L["Set whether the border should always show or whether it should fade out when not hovering over it."],
'default', false,
'current', Cartographer3.db.alwaysShowBorder,
'setFunc', function(value)
Cartographer3.db.alwaysShowBorder = value
end)
alwaysShowBorderToggle:SetPoint("TOPLEFT", unexploredColorPicker, "BOTTOMLEFT", 0, -16)
end)
AddSuboptionsPanel(L["POIs"], function(self)
local title, subText = self:MakeTitleTextAndSubText(L["POIs"], L["These are options to change how points of interest (POIs) look"])
local scrollFrame, scrollChild = self:MakeScrollFrame()
scrollFrame:SetPoint("TOPLEFT", subText, "BOTTOMLEFT", 0, -16)
scrollFrame:SetPoint("BOTTOMRIGHT", self, "BOTTOMRIGHT", -32, 16)
local t = {}
for id in pairs(Cartographer3.Data.poiTypes) do
t[#t+1] = id
end
table.sort(t)
local last
for _, id in ipairs(t) do
local localizedName = Cartographer3.Data.poiTypes[id]
local exampleFrame = Cartographer3.Data.poiTypeExampleFrames[id]()
Cartographer3.Data.poiTypeExampleFrames[id] = nil
local function resize(value)
local scale = Cartographer3.Data.poiTypeScales[id]
exampleFrame:SetWidth(scale * 20 * value)
exampleFrame:SetHeight(scale * 20 * value)
end
local sizeSlider = self:MakeSlider(
'name', localizedName,
'description', L["The size that %s appears on the map"]:format(localizedName),
'minText', "25%",
'maxText', "400%",
'minValue', 0.25,
'maxValue', 4,
'step', 0.05,
'default', 1,
'current', Cartographer3.db.pois[id],
'setFunc', function(value)
Cartographer3.db.pois[id] = value
for poi in pairs(Cartographer3.Data.shownPOIs) do
poi:Resize()
end
resize(value)
end,
'currentTextFunc', function(value)
return ("%.0f%%"):format(value * 100)
end)
sizeSlider:SetParent(scrollChild)
if not last then
sizeSlider:SetPoint("TOPLEFT", scrollChild, "TOPLEFT", 16, -24)
else
sizeSlider:SetPoint("TOPLEFT", last, "BOTTOMLEFT", 0, -32)
end
exampleFrame:SetParent(scrollChild)
exampleFrame:SetPoint("CENTER", sizeSlider, "RIGHT", 100, 0)
resize(Cartographer3.db.pois[id])
last = sizeSlider
end
end)
AddSuboptionsPanel(L["Advanced"], function(self)
local title, subText = self:MakeTitleTextAndSubText(L["Advanced"], L["These are advanced options for Cartographer3"])
local okayFunc = function()
if Cartographer3.db.hijackWorldMap ~= Cartographer3.hijackingWorldMap then
ReloadUI()
end
end
local hijackWorldMapToggle = self:MakeToggle(
'name', L["Separate Cartographer3 from the World Map"],
'description', L["Set whether to separate Cartographer3 from the World Map.\n\nNote: This will prevent most third-party addons from working properly.\n\nYou can set the keybinding to open and close Cartographer3 in the Keybindings menu.\n\nChanging this initiates a |cffff0000ReloadUI|r"],
'default', false,
'current', not Cartographer3.db.hijackWorldMap,
'setFunc', function(value)
Cartographer3.db.hijackWorldMap = not value
end,
'okayFunc', okayFunc,
'cancelFunc', okayFunc,
'defaultFunc', okayFunc)
hijackWorldMapToggle:SetPoint("TOPLEFT", subText, "BOTTOMLEFT", 0, -16)
end)
AddSuboptionsPanel(L["Modules"], function(self)
local title, subText = self:MakeTitleTextAndSubText(L["Modules"], L["Enable or disable the modules you want"])
local scrollFrame, scrollChild = self:MakeScrollFrame()
scrollFrame:SetPoint("TOPLEFT", subText, "BOTTOMLEFT", 0, -16)
scrollFrame:SetPoint("BOTTOMRIGHT", self, "BOTTOMRIGHT", -32, 16)
local modules = {}
for k in pairs(Cartographer3.modules) do
modules[#modules+1] = k
end
for k in pairs(Cartographer3.potentialModules) do
modules[#modules+1] = k
end
table.sort(modules, function(alpha, bravo)
local alpha_name = Cartographer3.modules[alpha] and Cartographer3.modules[alpha].name or Cartographer3.potentialModules[alpha][1]
local bravo_name = Cartographer3.modules[bravo] and Cartographer3.modules[bravo].name or Cartographer3.potentialModules[bravo][1]
return alpha_name < bravo_name
end)
local last = nil
for _, name in ipairs(modules) do
local enableStatusToggle = self:MakeToggle(
'name', Cartographer3.modules[name] and Cartographer3.modules[name].name or Cartographer3.potentialModules[name][1],
'description', Cartographer3.modules[name] and Cartographer3.modules[name].desc or Cartographer3.potentialModules[name][2],
'default', true,
'getFunc', function()
return not Cartographer3.db[name] or not Cartographer3.db[name].disabled
end,
'setFunc', function(value)
if value then
Cartographer3.EnableModule(name)
else
Cartographer3.DisableModule(name)
end
end)
if not last then
enableStatusToggle:SetPoint("TOPLEFT", scrollChild, "TOPLEFT", 16, -16)
else
enableStatusToggle:SetPoint("TOPLEFT", last, "BOTTOMLEFT", 0, -8)
end
last = enableStatusToggle
end
end)
--]]