TourGuide - Starting GUI for guide selection
[WoW-TourGuide.git] / OHFrame.lua
blobb5e7c0cda7b08d99b156bcfaee45e35025333866
3 local TourGuide = TourGuide
4 local ww = WidgetWarlock
7 local ROWHEIGHT = 26
8 local ROWOFFSET = 4
9 local NUMROWS = math.floor(305/(ROWHEIGHT+4))
12 local offset = 0
15 local function OnShow()
16 offset = TourGuide.current - NUMROWS/2 - 1
17 if offset < 0 then offset = 0
18 elseif (offset + NUMROWS) > #TourGuide.actions then offset = #TourGuide.actions - NUMROWS end
19 TourGuide:UpdateOHPanel()
20 end
23 function TourGuide:CreateObjectivePanel()
24 local frame = ww.SummonOptionHouseBaseFrame()
26 frame.rows = {}
27 for i=1,NUMROWS do
28 local row = CreateFrame("Button", nil, frame)
29 row:SetPoint("TOPLEFT", i == 1 and frame or frame.rows[i-1], i == 1 and "TOPLEFT" or "BOTTOMLEFT", 0, -ROWOFFSET)
30 row:SetWidth(630)
31 row:SetHeight(ROWHEIGHT)
33 local check = ww.SummonCheckBox(ROWHEIGHT, row, "TOPLEFT", ROWOFFSET, 0)
34 local icon = ww.SummonTexture(row, ROWHEIGHT, ROWHEIGHT, nil, "TOPLEFT", check, "TOPRIGHT", ROWOFFSET, 0)
35 local text = ww.SummonFontString(row, nil, nil, "GameFontNormal", nil, "LEFT", icon, "RIGHT", ROWOFFSET, 0)
36 local detail = ww.SummonFontString(row, nil, nil, "GameFontNormal", nil, "RIGHT", -ROWOFFSET, 0)
37 detail:SetPoint("LEFT", text, "RIGHT", ROWOFFSET*3, 0)
38 detail:SetJustifyH("RIGHT")
39 detail:SetTextColor(240/255, 121/255, 2/255)
41 check:SetScript("OnClick", function(f) self:SetTurnedIn(row.i, f:GetChecked()) end)
43 row.text = text
44 row.detail = detail
45 row.check = check
46 row.icon = icon
47 frame.rows[i] = row
48 end
50 frame:EnableMouseWheel()
51 frame:SetScript("OnMouseWheel", function(f, val)
52 offset = offset - val
53 if offset < 0 then offset = 0
54 elseif (offset + NUMROWS) > #self.actions then offset = #self.actions - NUMROWS end
55 self:UpdateOHPanel()
56 end)
58 self.OHFrame = frame
59 frame:SetScript("OnShow", OnShow)
60 OnShow()
61 return frame
62 end
65 function TourGuide:UpdateOHPanel()
66 if not self.OHFrame or not self.OHFrame:IsVisible() then return end
67 for i,row in ipairs(self.OHFrame.rows) do
68 row.i = i + offset
69 local action, name, note, logi, complete, hasitem, turnedin, fullquestname = self:GetObjectiveInfo(i + offset)
70 local checked = turnedin or action == "ACCEPT" and logi or action == "COMPLETE" and complete
72 row.icon:SetTexture(self.icons[action])
73 row.text:SetText(name)
74 row.detail:SetText(note)
75 row.check:SetChecked(checked)
76 end
77 end