forked from TekNoLogic/TourGuide
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathGuideList.lua
More file actions
104 lines (84 loc) · 3.59 KB
/
GuideList.lua
File metadata and controls
104 lines (84 loc) · 3.59 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
local TourGuide = TourGuide
local L = TourGuide.Locale
local NUMROWS, ROWHEIGHT, GAP, EDGEGAP = 18, 17, 8, 16
local offset, rows = 0, {}
local frame = CreateFrame("Frame", nil, InterfaceOptionsFramePanelContainer)
TourGuide.guidespanel = frame
frame.name = L["Guides"]
frame.parent = "Tour Guide"
frame:Hide()
frame:SetScript("OnShow", function()
local title, subtitle = LibStub("tekKonfig-Heading").new(frame, L["Tour Guide - Guides"], L["This panel lets you choose a guide to load. Upon completion the next guide will load automatically. Completed guides can be reset by shift-clicking."])
local group = LibStub("tekKonfig-Group").new(frame, nil, "TOP", subtitle, "BOTTOM", 0, -EDGEGAP-GAP)
group:SetPoint("LEFT", EDGEGAP, 0)
group:SetPoint("BOTTOMRIGHT", -EDGEGAP, EDGEGAP)
local scrollbar = LibStub("tekKonfig-Scroll").new(group, 6, NUMROWS/3)
local function OnClick(self)
if IsShiftKeyDown() then
TourGuide.db.char.completion[self.guide] = nil
TourGuide.db.char.turnins[self.guide] = {}
for qid in string.gmatch(TourGuide.guides[self.guide](), "|QID|(%d+)|") do TourGuide.turnedinquests[tonumber(qid)] = nil end
TourGuide:UpdateGuidesPanel()
GameTooltip:Hide()
else
local text = self.guide
if not text then self:SetChecked(false)
else
TourGuide:LoadGuide(text)
TourGuide:UpdateStatusFrame()
TourGuide:UpdateGuidesPanel()
end
end
end
rows = {}
for i=1,NUMROWS do
local row = CreateFrame("CheckButton", nil, group)
if i == 1 then row:SetPoint("TOP", 0, -4)
else row:SetPoint("TOP", rows[i-1], "BOTTOM") end
row:SetPoint("LEFT", 4, 0)
row:SetPoint("RIGHT", scrollbar, "LEFT", -4, 0)
row:SetHeight(ROWHEIGHT)
local highlight = row:CreateTexture()
highlight:SetTexture("Interface\\HelpFrame\\HelpFrameButton-Highlight")
highlight:SetTexCoord(0, 1, 0, 0.578125)
highlight:SetAllPoints()
row:SetHighlightTexture(highlight)
row:SetCheckedTexture(highlight)
local text = row:CreateFontString(nil, nil, "GameFontWhite")
text:SetPoint("LEFT", GAP, 0)
local complete = row:CreateFontString(nil, nil, "GameFontWhite")
complete:SetPoint("RIGHT", -GAP, 0)
row:SetScript("OnClick", OnClick)
row.text = text
row.complete = complete
rows[i] = row
end
local f = scrollbar:GetScript("OnValueChanged")
scrollbar:SetMinMaxValues(0, math.max(0, #TourGuide.guidelist - NUMROWS - 1))
scrollbar:SetScript("OnValueChanged", function(self, value, ...)
offset = math.floor(value)
TourGuide:UpdateGuidesPanel()
return f(self, value, ...)
end)
frame:EnableMouseWheel()
frame:SetScript("OnMouseWheel", function(self, val) scrollbar:SetValue(scrollbar:GetValue() - val*NUMROWS/3) end)
local function newoffset() for i,name in ipairs(TourGuide.guidelist) do if name == TourGuide.db.char.currentguide then return i - (NUMROWS/2) - 1 end end end
local function OnShow(self) scrollbar:SetValue(newoffset() or 0) end
frame:SetScript("OnShow", OnShow)
OnShow(frame)
end)
function TourGuide:UpdateGuidesPanel()
if not frame:IsVisible() then return end
for i,row in ipairs(rows) do
row.i = i + offset + 1
local name = self.guidelist[i + offset + 1]
row.text:SetText(TourGuide:GuideTitleTranslator(name))
row.guide = name
row:SetChecked(self.db.char.currentguide == name)
local complete = self.db.char.currentguide == name and (self.current-1)/#self.actions or self.db.char.completion[name]
local r,g,b = self.ColorGradient(complete or 0)
local completetext = complete and complete ~= 0 and string.format(L["|cff%02x%02x%02x%d%% complete"], r*255, g*255, b*255, complete*100)
row.complete:SetText(completetext)
end
end
InterfaceOptions_AddCategory(frame)