TourGuide
[WoW-TourGuide.git] / OHGuides.lua
blob5211782db9d39659a7f228fd8a85e00d2966d0eb
3 local TourGuide = TourGuide
4 local OptionHouse = DongleStub("OptionHouse-1.0")
5 local ww = WidgetWarlock
6 WidgetWarlock = nil
9 local ROWHEIGHT = 22
10 local NUMROWS = math.floor(305/(ROWHEIGHT))
13 local offset, elapsed = 0, 0
14 local rows = {}
15 local frame, fader
18 local function OnShow()
19 TourGuide:UpdateGuidesPanel()
21 frame:SetAlpha(0)
22 elapsed = 0
23 fader:Show()
24 end
27 local function OnClick(self)
28 local text = self.text:GetText()
29 if not text then self:SetChecked(false)
30 else
31 TourGuide:LoadGuide(text)
32 TourGuide:UpdateGuidesPanel()
33 TourGuide:UpdateStatusFrame()
34 end
35 end
38 function TourGuide:CreateGuidesPanel()
39 fader = CreateFrame("Frame")
40 fader:Hide()
41 fader:SetScript("OnUpdate", function(self, elap)
42 elapsed = elapsed + elap
43 if elapsed > 1 then
44 self:Hide()
45 frame:SetAlpha(1)
46 else frame:SetAlpha(elapsed) end
47 end)
49 frame = ww.SummonOptionHouseBaseFrame()
50 local w = frame:GetWidth()
52 rows = {}
53 for i=1,NUMROWS*2 do
54 local anchor, point
55 if i == 1 then anchor, point = frame, "TOPLEFT"
56 elseif i <= NUMROWS then anchor, point = rows[i-1], "BOTTOMLEFT"
57 else anchor, point = rows[i-NUMROWS], "TOPRIGHT" end
59 local row = CreateFrame("CheckButton", nil, frame)
60 row:SetPoint("TOPLEFT", anchor, point)
61 row:SetWidth(w/2)
62 row:SetHeight(ROWHEIGHT)
64 local highlight = ww.SummonTexture(row, w/2, ROWHEIGHT, "Interface\\HelpFrame\\HelpFrameButton-Highlight")
65 highlight:SetTexCoord(0, 1, 0, 0.578125)
66 highlight:SetAllPoints()
67 row:SetHighlightTexture(highlight)
68 row:SetCheckedTexture(highlight)
70 local text = ww.SummonFontString(row, nil, nil, "GameFontNormal", nil, "LEFT", 6, 0)
72 row:SetScript("OnClick", OnClick)
74 row.text = text
75 rows[i] = row
76 end
78 --~ frame:EnableMouseWheel()
79 --~ frame:SetScript("OnMouseWheel", function(f, val)
80 --~ offset = offset - val*NUMROWS
81 --~ if (offset + NUMROWS*2) > #self.guidelist then offset = #self.guidelist - NUMROWS*2 end
82 --~ if offset < 0 then offset = 0 end
83 --~ self:UpdateGuidesPanel()
84 --~ end)
86 frame:SetScript("OnShow", OnShow)
87 OnShow()
88 return frame
89 end
92 function TourGuide:UpdateGuidesPanel()
93 if not frame or not frame:IsVisible() then return end
94 for i,row in ipairs(rows) do
95 row.i = i + offset
97 local name = self.guidelist[i]
99 row.text:SetText(name)
100 row:SetChecked(self.db.char.currentguide == name)