TourGuide - Starting GUI for guide selection
[WoW-TourGuide.git] / OHGuides.lua
blobdf65fa898fa70d7379a9a670569768e3b61605c7
3 local TourGuide = TourGuide
4 local OptionHouse = DongleStub("OptionHouse-1.0")
5 local ww = WidgetWarlock
6 WidgetWarlock = nil
9 local ROWHEIGHT = 26
10 local ROWOFFSET = 4
11 local NUMROWS = math.floor(305/(ROWHEIGHT+4))
14 local offset = 0
18 local function OnShow()
19 --~ offset = TourGuide.current - NUMROWS/2 - 1
20 --~ if offset < 0 then offset = 0
21 --~ elseif (offset + NUMROWS) > #TourGuide.actions then offset = #TourGuide.actions - NUMROWS end
22 TourGuide:UpdateGuidesPanel()
23 end
26 function TourGuide:CreateGuidesPanel()
27 local frame = ww.SummonOptionHouseBaseFrame()
28 local w = frame:GetWidth()
30 frame.rows = {}
31 for i=1,NUMROWS do
32 local row = CreateFrame("Button", nil, frame)
33 row:SetPoint("TOPLEFT", i == 1 and frame or frame.rows[i-1], i == 1 and "TOPLEFT" or "BOTTOMLEFT", 0, -ROWOFFSET)
34 row:SetWidth(w/2)
35 row:SetHeight(ROWHEIGHT)
37 local check = ww.SummonCheckBox(ROWHEIGHT, row, "TOPLEFT", ROWOFFSET, 0)
38 local text = ww.SummonFontString(row, nil, nil, "GameFontNormal", nil, "LEFT", check, "RIGHT", ROWOFFSET, 0)
40 --~ check:SetScript("OnClick", function(f) self:SetTurnedIn(row.i, f:GetChecked()) end)
42 row.text = text
43 --~ row.detail = detail
44 row.check = check
45 --~ row.icon = icon
46 frame.rows[i] = row
47 end
49 --~ frame:EnableMouseWheel()
50 --~ frame:SetScript("OnMouseWheel", function(f, val)
51 --~ offset = offset - val
52 --~ if offset < 0 then offset = 0
53 --~ elseif (offset + NUMROWS) > #self.actions then offset = #self.actions - NUMROWS end
54 --~ self:UpdateOHPanel()
55 --~ end)
57 self.OHGuidesFrame = frame
58 frame:SetScript("OnShow", OnShow)
59 OnShow()
60 --~ self:UpdateGuidesPanel()
61 return frame
62 end
65 function TourGuide:UpdateGuidesPanel()
66 if not self.OHGuidesFrame or not self.OHGuidesFrame:IsVisible() then return end
67 for i,row in ipairs(self.OHGuidesFrame.rows) do
68 --~ row.i = i + offset
70 local name = self.guidelist[i]
72 row.text:SetText(name)
73 row.check:SetChecked(self.db.char.currentguide == name)
74 end
75 end