3 local TourGuide
= TourGuide
4 local ww
= WidgetWarlock
9 local NUMROWS
= math
.floor(305/(ROWHEIGHT
+4))
14 local frame
, scrollbar
, upbutt
, downbutt
17 local function OnShow(self
)
18 scrollbar
:SetMinMaxValues(0, math
.max(#TourGuide
.actions
- NUMROWS
, 1))
19 scrollbar
:SetValue(TourGuide
.current
- NUMROWS
/2 - 1)
21 if TourGuide
.guidechanged
then TourGuide
:UpdateOHPanel() end
24 self
:SetScript("OnUpdate", ww
.FadeIn
)
28 local function HideTooltip() GameTooltip
:Hide() end
30 local function ShowTooltip(f
)
31 if f
.text
:GetStringWidth() <= f
:GetWidth() then return end
33 GameTooltip
:SetOwner(f
, "ANCHOR_RIGHT")
34 GameTooltip
:SetText(f
.text
:GetText(), nil, nil, nil, nil, true)
38 function TourGuide
:CreateObjectivePanel()
39 frame
= CreateFrame("Frame", nil, UIParent
)
40 frame
:SetFrameStrata("DIALOG")
42 scrollbar
, upbutt
, downbutt
= ww
.ConjureScrollBar(frame
, true)
43 scrollbar
:SetPoint("TOPRIGHT", frame
, "TOPRIGHT", 0, -19)
44 scrollbar
:SetPoint("BOTTOMRIGHT", frame
, "BOTTOMRIGHT", 0, 16)
45 scrollbar
:SetScript("OnValueChanged", function(f
, val
) self
:UpdateOHPanel(val
) end)
47 upbutt
:SetScript("OnClick", function(f
)
48 scrollbar
:SetValue(offset
- NUMROWS
+ 1)
49 PlaySound("UChatScrollButton")
52 downbutt
:SetScript("OnClick", function(f
)
53 scrollbar
:SetValue(offset
+ NUMROWS
- 1)
54 PlaySound("UChatScrollButton")
57 local function LevelCorrection(f
) f
:SetFrameLevel(frame
:GetFrameLevel()+1); f
:SetScript("OnShow", nil) end
59 local row
= CreateFrame("Button", nil, frame
)
60 row
:SetPoint("TOPLEFT", i
== 1 and frame
or rows
[i
-1], i
== 1 and "TOPLEFT" or "BOTTOMLEFT", 0, -ROWOFFSET
)
62 row
:SetHeight(ROWHEIGHT
)
64 local check
= ww
.SummonCheckBox(ROWHEIGHT
, row
, "TOPLEFT", ROWOFFSET
, 0)
65 local icon
= ww
.SummonTexture(row
, nil, ROWHEIGHT
, ROWHEIGHT
, nil, "TOPLEFT", check
, "TOPRIGHT", ROWOFFSET
, 0)
66 local text
= ww
.SummonFontString(row
, nil, "GameFontNormal", nil, "LEFT", icon
, "RIGHT", ROWOFFSET
, 0)
68 local detailhover
= CreateFrame("Button", nil, frame
)
69 detailhover
:SetHeight(ROWHEIGHT
)
70 detailhover
:SetPoint("LEFT", text
, "RIGHT", ROWOFFSET
*3, 0)
71 detailhover
:SetPoint("RIGHT", scrollbar
, "LEFT", -ROWOFFSET
-7, 0)
72 detailhover
:SetScript("OnEnter", ShowTooltip
)
73 detailhover
:SetScript("OnLeave", HideTooltip
)
74 detailhover
:SetScript("OnShow", LevelCorrection
)
76 local detail
= ww
.SummonFontString(detailhover
, nil, "GameFontNormal", nil)
77 detail
:SetAllPoints(detailhover
)
78 detail
:SetJustifyH("RIGHT")
79 detail
:SetTextColor(240/255, 121/255, 2/255)
80 detailhover
.text
= detail
82 check
:SetScript("OnClick", function(f
) self
:SetTurnedIn(row
.i
, f
:GetChecked()) end)
91 frame
:EnableMouseWheel()
92 frame
:SetScript("OnMouseWheel", function(f
, val
)
93 scrollbar
:SetValue(offset
- val
)
96 frame
:SetScript("OnShow", OnShow
)
97 ww
.SetFadeTime(frame
, 0.5)
104 function TourGuide
:UpdateOHPanel(value
)
105 if not frame
or not frame
:IsVisible() then return end
107 self
.guidechanged
= nil
108 if value
then offset
= math
.floor(value
) end
109 if (offset
+ NUMROWS
) > #self
.actions
then offset
= #self
.actions
- NUMROWS
end
110 if offset
< 0 then offset
= 0 end
112 if offset
== 0 then upbutt
:Disable() else upbutt
:Enable() end
113 if offset
== (#self
.actions
- NUMROWS
) then downbutt
:Disable() else downbutt
:Enable() end
115 for i
in pairs(accepted
) do accepted
[i
] = nil end
117 for i
in pairs(self
.actions
) do
118 local action
, name
= self
:GetObjectiveInfo(i
)
119 local _
, _
, quest
, part
= name
:find("(.+)%s%(Part %d+%)")
120 if quest
and not accepted
[quest
] and not self
:GetObjectiveStatus(i
) then accepted
[quest
] = name
end
123 for i
,row
in ipairs(rows
) do
125 local action
, name
= self
:GetObjectiveInfo(i
+ offset
)
126 if not name
then row
:Hide()
128 local turnedin
, logi
, complete
= self
:GetObjectiveStatus(i
+ offset
)
131 local shortname
= name
:gsub("%s%(Part %d+%)", "")
132 logi
= not turnedin
and (not accepted
[shortname
] or (accepted
[shortname
] == name
)) and logi
133 complete
= not turnedin
and (not accepted
[shortname
] or (accepted
[shortname
] == name
)) and complete
134 local checked
= turnedin
or action
== "ACCEPT" and logi
or action
== "COMPLETE" and complete
136 row
.icon
:SetTexture(self
.icons
[action
])
137 if action
~= "ACCEPT" and action
~= "TURNIN" then row
.icon
:SetTexCoord(4/48, 44/48, 4/48, 44/48) end
138 row
.text
:SetText(name
)
139 row
.detail
:SetText(self
:GetObjectiveTag("N", i
+ offset
))
140 row
.check
:SetChecked(checked
)