-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoptions.lua
462 lines (386 loc) · 14.6 KB
/
options.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
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
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
--[[
Sick Of Clicking Dailies? - Options frame
Written By: OrionShock
]]--
local AddonName, AddonParent = ...
local module = AddonParent:NewModule("Options")
local L = LibStub("AceLocale-3.0"):GetLocale(AddonName)
local db
--[===[@debug@--@end-debug@]===]
function module:Debug(...)
local str = string.join(", ", tostringall(...) )
str = str:gsub("([:=>]),", "%1")
str = str:gsub(", ([%-])", " %1")
DEFAULT_CHAT_FRAME:AddMessage("SOCD-OPT: "..str)
return str
end
function module:OnInitialize()
self:CreateInteractionFrame()
self:CreateGossipOptions()
end
function module:OnEnable()
--self:Debug("OnEnable")
db = AddonParent.db
self.frame:RegisterEvent("GOSSIP_SHOW")
self.frame:RegisterEvent("QUEST_GREETING")
self.frame:RegisterEvent("QUEST_PROGRESS")
self.frame:RegisterEvent("QUEST_DETAIL")
self.frame:RegisterEvent("QUEST_COMPLETE")
self.frame:RegisterEvent("QUEST_FINISHED")
end
function module:OnDisable()
--self:Debug("OnDisable")
self.frame:UnregisterEvent("GOSSIP_SHOW")
self.frame:UnregisterEvent("QUEST_GREETING")
self.frame:UnregisterEvent("QUEST_PROGRESS")
self.frame:UnregisterEvent("QUEST_DETAIL")
self.frame:UnregisterEvent("QUEST_COMPLETE")
self.frame:UnregisterEvent("QUEST_FINISHED")
self.frame:Hide()
end
gg = {}
local function CheckButton_OnClick(self, button)
--module:Debug("OnClick, Button:", button, "IsChecked:", self:GetChecked() )
local isChecked = self:GetChecked() and true or false
local title = GetTitleText()
if isChecked then
--module:Debug("Option is checked, clearing from disabled quest list")
db.profile.status[title] = nil
else
--module:Debug("Option !NOT! checked, adding to disabled quest list")
db.profile.status[title] = false
end
end
local showEvents = {
["QUEST_DETAIL"] = true,
["QUEST_COMPLETE"] = true,
["QUEST_FINISHED"] = true,
["QUEST_PROGRESS"] = true,
}
local function GossipButton_OnEvent(self)
if self:GetParent():GetText() == nil then return end
--module:Debug("CheckBox#", self.index,"~Type:", self:GetParent().type, "~Text:", self:GetParent():GetText() )
if self:GetParent().type == "Gossip" then --we're the gossip option
--module:Debug("RealType:", self:GetParent().type )
self:Show()
self:Show()
if self.index == 1 then --if we're the first option we need to off set from the Greeting Text
--module:Debug("FirstIndex, anchor to Greeting Text")
GossipFrame_GetTitleButton(1):SetPoint("TOPLEFT", GossipGreetingText, "BOTTOMLEFT", 10, -20)
else --else we need to check what the last guy was doing..
--module:Debug("Not First Index:", self.index)
local anchorFrame = GossipFrame_GetTitleButton(self.index-1)--_G["GossipTitleButton"..self.index-1]
if anchorFrame.type =="Gossip" then
--module:Debug("AnchorFrame:", anchorFrame:GetName(), "~PreviousIs:", anchorFrame.type, "We're and it is, lineup")
self:GetParent():SetPoint("TOPLEFT", anchorFrame, "BOTTOMLEFT", 0, -5)
elseif anchorFrame.type ~="Gossip" then
--module:Debug("AnchorFrame:", anchorFrame:GetName(), "~PreviousIs:", anchorFrame.type, "We're and it's not, offset to lineup")
self:GetParent():SetPoint("TOPLEFT", anchorFrame, "BOTTOMLEFT", 20, -5)
end
end
else --We're something other than a gossip option...
self:Hide()
if self.index == 1 then --first index, not gossip, reset to GreetingText
GossipFrame_GetTitleButton(1):SetPoint("TOPLEFT", GossipGreetingText, "BOTTOMLEFT", -10, -20)
else --check previous and offset accordingly..
local anchorFrame = GossipFrame_GetTitleButton(self.index-1)--_G["GossipTitleButton"..self.index-1]
if anchorFrame.type =="Gossip" then
self:GetParent():SetPoint("TOPLEFT", anchorFrame, "BOTTOMLEFT", -20, -5)
elseif anchorFrame.type ~="Gossip" then
self:GetParent():SetPoint("TOPLEFT", anchorFrame, "BOTTOMLEFT", 0, -5)
end
end
end
--
local gossipText = self:GetParent():GetText()
if gossipText and db then
gossipText = gossipText:trim()
self:SetChecked( db.profile.enabledGossip[gossipText] )
else
--module:Debug("! Fail")
end
end
local function GossipButton_OnClick(self, button, ...)
--module:Debug("GossipButton_OnClick CheckBox#", self.index, "~Text:", self:GetParent():GetText() )
if not db then return end
self.wtf = 32;
local isChecked = self:GetChecked() and true or nil
local gossipText = self:GetParent():GetText():trim()
db.profile.enabledGossip[gossipText] = isChecked
end
local function StyleNSizeBox(frame)
frame:SetWidth(20)
frame:SetHeight(20)
frame:SetNormalTexture("Interface\\Buttons\\UI-CheckBox-Up");
frame:SetPushedTexture("Interface\\Buttons\\UI-CheckBox-Down");
frame:SetHighlightTexture("Interface\\Buttons\\UI-CheckBox-Highlight", "ADD");
frame:SetCheckedTexture("Interface\\Buttons\\UI-CheckBox-Check");
frame:SetScript("OnClick", GossipButton_OnClick)
--frame:SetScript("OnEvent", GossipButton_OnEvent)
--frame:RegisterEvent("GOSSIP_SHOW")
end
local function processGossip(self)
if self.gossipButtons == nil then
self.gossipButtons = gg
end
local gossipButtons = self.gossipButtons
if (GossipFrame_GetTitleButtonCount() == 0) then
return
end
if (table.getn(gossipButtons) == 0) then
--First Move the Buttons over
-- staring point is -10
local check = CreateFrame("CheckButton", "socdB1", GossipFrame_GetTitleButton(1))
StyleNSizeBox(check)
check.index = 1
tinsert(gossipButtons, check)
end
for i = table.getn(gossipButtons)+1, GossipFrame_GetTitleButtonCount() do
--print("Creating button" .. i)
local check = CreateFrame("CheckButton", "socdB" .. i, GossipFrame_GetTitleButton(i))
check.index = i
StyleNSizeBox(check)
tinsert(gossipButtons, check)
end
for i = 1,table.getn(gossipButtons) do
local button = gossipButtons[i]
button.index = i
button:SetParent(GossipFrame_GetTitleButton(i))
button:Hide()
end
GossipFrame_GetTitleButton(1):SetPoint("TOPLEFT", GossipGreetingText, "BOTTOMLEFT", 10, -20)
gossipButtons[1]:SetPoint("TOPRIGHT", GossipFrame_GetTitleButton(1), "TOPLEFT", 3, 3)
for i = 2,GossipFrame_GetTitleButtonCount() do
local button = gossipButtons[i]
GossipFrame_GetTitleButton(i):SetPoint("TOPLEFT", GossipFrame_GetTitleButton(i-1), "BOTTOMLEFT", 0,0)
button:SetPoint("TOPRIGHT", GossipFrame_GetTitleButton(i), "TOPLEFT", 3, 3)
end
for i = 1,GossipFrame_GetTitleButtonCount() do
local button = gossipButtons[i]
GossipButton_OnEvent(button)
end
end
local function Frame_OnEvent(self, event, ...)
if (event == "GOSSIP_SHOW") then
processGossip(self)
end
if showEvents[event] then
if QuestIsDaily() or QuestIsWeekly() or AddonParent:IsRepeatable(GetTitleText()) or AddonParent:SpecialFixQuest( GetQuestID() ) then
--module:Debug("Daily/Weekly/Repeatable:", QuestIsDaily() or QuestIsWeekly() or AddonParent:IsRepeatable(GetTitleText()) )
self:Show()
else
self:Hide()
end
else
self:Hide()
end
end
local function Frame_OnShow(self)
local title = GetTitleText():trim()
if db.profile.status[title] == false then
self.check:SetChecked(false)
else
self.check:SetChecked(true)
end
end
local backdrop = {
bgFile = "Interface\\DialogFrame\\UI-DialogBox-Background",
edgeFile = "Interface\\DialogFrame\\UI-DialogBox-Border",
edgeSize = 32,
tileSize = 32,
tile = true,
insets = { left = 11, right = 12, top = 12, bottom = 11 },
}
function module:CreateInteractionFrame()
--BaseFrame
local frame = CreateFrame("frame", "SOCD_QuestOptionFrame", QuestFrame, BackdropTemplateMixin and "BackdropTemplate")
frame:SetWidth(200)
frame:SetHeight(50)
frame:SetPoint("BOTTOMRIGHT", QuestFrame, "TOPRIGHT", -30, 10)
frame:SetBackdrop(backdrop)
--CheckBox
local check = CreateFrame("CheckButton", "SOCD_cButton", frame, BackdropTemplateMixin and "BackdropTemplate")
check:SetWidth(35)
check:SetHeight(35)
check:SetPoint("LEFT", frame, "LEFT", 10, 0)
check:SetNormalTexture("Interface\\Buttons\\UI-CheckBox-Up");
check:SetPushedTexture("Interface\\Buttons\\UI-CheckBox-Down");
check:SetHighlightTexture("Interface\\Buttons\\UI-CheckBox-Highlight", "ADD");
check:SetCheckedTexture("Interface\\Buttons\\UI-CheckBox-Check");
--FontString
local text = frame:CreateFontString(nil, "ARTWORK", "GameFontNormalSmall")
text:SetPoint("LEFT", check, "RIGHT", 5, 0)
text:SetText(L["Auto Complete Daily or Weekly?"])
frame:SetWidth( text:GetWidth() + 70 )
--reference on frame
frame.check = check
frame.text = text
frame.addon = self
--Hide it by default, otherwise it might be shown before the addon is ready
frame:Hide()
frame:SetScript("OnEvent", Frame_OnEvent)
frame:SetScript("OnShow", Frame_OnShow)
check:SetScript("OnClick", CheckButton_OnClick)
self.frame = frame
end
--[[==========================================================
Gossip Options
--==========================================================]]--
--=====================================================================
--local old_GossipFrameUpdate = GossipFrameUpdate
--function GossipFrameUpdate()
-- for i=1, GossipFrame_GetTitleButtonCount() do
-- GossipFrame_GetTitleButton(i).realType = nil
-- end
-- return old_GossipFrameUpdate()
--end
--local org = GossipFrameOptionsUpdate
--function GossipFrameOptionsUpdate(...) --Hook Replace the blizzard function :)
-- org(...)
-- local gossipOptions = C_GossipInfo.GetOptions();
--
-- local titleIndex = 1;
-- for titleIndex, optionInfo in ipairs(gossipOptions) do
-- GossipFrame_GetTitleButton(titleIndex).realType = optionInfo.type
-- titleIndex = titleIndex + 1
-- print("Dasdas")
-- end
--
--
--end
-- function Unused_GossipResize(titleButton)
-- print( titleButton:GetName(), "String Height", titleButton:GetFontString():GetHeight() )
-- if titleButton:GetFontString() then
-- print( "Has Font string", titleButton:GetTextHeight() )
-- titleButton:SetHeight( titleButton:GetTextHeight() + 2);
-- else
-- print( "no font string?", titleButton:GetFontString())
-- titleButton:SetHeight( titleButton:GetTextHeight() + 2);
-- end
-- end
--===========================================
function module:CreateGossipOptions()
end
--============================================================================
--Ace Options Table::
--============================================================================
-- All selectable quest rewards need to be scanned here so that the call to GetItemInfo in specialQuestManagement.lua later succeeds.
local rewardItems = {
--== Burning Crusade ==--
--Cooking
[33844] = "Barrel of Fish",
[33857] = "Crate of Meat",
--SSO
[30809] = "Mark of Sargeras",
[30810] = "Sunfury Signet",
--Ata'mal
[34538] = "Blessed Weapon Coating",
[34539] = "Righteous Weapon Coating",
--== Wrath Of the Lich King ==--
--Argent Tourny
[46114] = "Champion's Writ",
[45724] = "Champion's Purse",
--Thx Holliday
[46723] = "Pilgrim's Hat",
[46800] = "Pilgrim's Attire",
[44785] = "Pilgrim's Dress",
[46824] = "Pilgrim's Robe",
[44788] = "Pilgrim's Boots",
[116404] = "Pilgrim's Bounty",
--== Mists of Pandaria ==--
--Path of the Mistwalker
[103643] = "Dew of Eternal Morning",
[103642] = "Book of the Ages",
[103641] = "Singing Crystal",
--== Warlords of Draenor ==--
--Alchemy Experiment
[122453] = "Draenic Agility Potion",
[122451] = "Draenic Invisibility Potion",
[122454] = "Draenic Intellect Potion",
[122452] = "Draenic Swiftness Potion",
[122455] = "Draenic Strength Potion",
[122456] = "Draenic Armor Potion",
--Scrap Meltdown
[120301] = "Armor Enhancement Token",
[120302] = "Weapon Enhancement Token",
}
local function RequestItemInfo()
--module:Debug("Running GetItemInfo for all items")
for k, v in pairs(rewardItems) do
-- We don't need the item name here, we just request it from the server so it's cached in memory.
-- In fact, most of them will be nil on first login.
local itemName = GetItemInfo(k)
--module:Debug("GetItemInfo first try:", k, "-->", itemName)
end
end
local itemInfoWasRequested = false
-- This function is called when the options dialog is opened.
function AddonParent.GetOptionsTable()
if not itemInfoWasRequested then
itemInfoWasRequested = true
-- Request item info of all items that might be shown in the options dialog from the server.
-- If this isn't done, the call to GetItemInfo() that happens later will always return nil on
-- first login (WoW only caches item info in memory, not on hard disk).
-- Usually we would need to wait for GET_ITEM_INFO_RECEIVED, but since the item names for the UI
-- aren't requested unit the user opens the quest rewards category, we don't need to handle that event.
RequestItemInfo()
end
local qtmp = {}
local gtmp = {}
local rtmp = {}
local t = { name = AddonName, type = "group", handler = addon,
args = {
profiles = LibStub("AceDBOptions-3.0"):GetOptionsTable(db),
rewards = { name = L["Quest Reward Choices"], type = "group", order = 10,
args = {
},
},
qstatus = { name = L["Disabled Quests"], type = "group", order = 5,
args = {
desc = { type = "description", name = L["Listed here are disabled quests, when unchecked they will be enabled and will be removed here"], order = 1 },
holder = { name = L["Disabled Quests"], type = "multiselect", width = "full",
get = function(info, arg) return not db.profile.status[arg] end,
set = function(info, arg, value) db.profile.status[arg] = nil end,
values = function(info) wipe(qtmp) for k,v in pairs(db.profile.status) do qtmp[k] = k end return qtmp end,
},
},
},
gstatus = { name = L["Enabled Gossip"], type = "group", order = 5,
args = {
desc = { type = "description", name = L["Listed here are enabled gossip options, when unchecked they will be disabled and will be removed here"], order = 1 },
holder = { name = L["Enabled Gossip"], type = "multiselect", width = "full",
get = function(info, arg) return db.profile.enabledGossip[arg] end,
set = function(info, arg, value) db.profile.enabledGossip[arg] = nil end,
values = function(info) wipe(gtmp) for k,v in pairs(db.profile.enabledGossip) do gtmp[k] = k end return gtmp end,
},
},
},
},
}
t.args.profiles.order = -10
for questName, rewardTable in pairs(db.global.reward) do
t.args.rewards.args[questName] = {
name = function(info) return info[#info] end,
type = "select", width = "double",
get = function(info) return db.profile.reward[info[#info]] end,
set = function(info, value) db.profile.reward[info[#info]] = value end,
values = function(info)
wipe(rtmp)
for k,v in pairs(db.global.reward[info[#info]]) do
local itemName
if k == -1 then
-- v is "None"
itemName = v
else
local itemId = tonumber(v)
itemName = GetItemInfo(itemId) or rewardItems[itemId] or "Unknown item"
end
--module:Debug("Building values for reward options", k, ":", v, "-->", itemName)
rtmp[k] = itemName
end
return rtmp
end,
}
end
return t
end