TourGuide - I'm so excited, I've got Felwood!
[WoW-TourGuide.git] / OHGuides.lua
blob6593eaf34d1e418a8bac9c6807d6aba63ff3362a
3 local TourGuide = TourGuide
4 local OptionHouse = LibStub("OptionHouse-1.1")
5 local ww = WidgetWarlock
6 WidgetWarlock = nil
9 local NUMROWS, COLWIDTH = 16, 210
10 local ROWHEIGHT = 305/NUMROWS
13 local offset = 0
14 local rows = {}
15 local frame
18 local function OnShow(self)
19 TourGuide:UpdateGuidesPanel()
21 self:SetAlpha(0)
22 self:SetScript("OnUpdate", ww.FadeIn)
23 end
26 local function OnClick(self)
27 local text = self.text:GetText()
28 if not text then self:SetChecked(false)
29 else
30 TourGuide:LoadGuide(text)
31 TourGuide:UpdateGuidesPanel()
32 TourGuide:UpdateStatusFrame()
33 end
34 end
37 function TourGuide:CreateGuidesPanel()
38 frame = CreateFrame("Frame", nil, UIParent)
40 rows = {}
41 for i=1,NUMROWS*3 do
42 local anchor, point = rows[i-1], "BOTTOMLEFT"
43 if i == 1 then anchor, point = frame, "TOPLEFT"
44 elseif i == (NUMROWS + 1) then anchor, point = rows[1], "TOPRIGHT"
45 elseif i == (NUMROWS*2 + 1) then anchor, point = rows[NUMROWS + 1], "TOPRIGHT" end
47 local row = CreateFrame("CheckButton", nil, frame)
48 row:SetPoint("TOPLEFT", anchor, point)
49 row:SetHeight(ROWHEIGHT)
50 row:SetWidth(COLWIDTH)
52 local highlight = ww.SummonTexture(row, nil, nil, nil, "Interface\\HelpFrame\\HelpFrameButton-Highlight")
53 highlight:SetTexCoord(0, 1, 0, 0.578125)
54 highlight:SetAllPoints()
55 row:SetHighlightTexture(highlight)
56 row:SetCheckedTexture(highlight)
58 local text = ww.SummonFontString(row, nil, "GameFontNormal", nil, "LEFT", 6, 0)
60 row:SetScript("OnClick", OnClick)
62 row.text = text
63 rows[i] = row
64 end
66 frame:EnableMouseWheel()
67 frame:SetScript("OnMouseWheel", function(f, val)
68 offset = offset - val*NUMROWS
69 if (offset + NUMROWS*2) > #self.guidelist then offset = offset - NUMROWS end
70 if offset < 0 then offset = 0 end
71 self:UpdateGuidesPanel()
72 end)
74 frame:SetScript("OnShow", OnShow)
75 ww.SetFadeTime(frame, 0.5)
76 OnShow(frame)
77 return frame
78 end
81 function TourGuide:UpdateGuidesPanel()
82 if not frame or not frame:IsVisible() then return end
83 for i,row in ipairs(rows) do
84 row.i = i + offset
86 local name = self.guidelist[i + offset]
88 row.text:SetText(name)
89 row:SetChecked(self.db.char.currentguide == name)
90 end
91 end