3 local TourGuide
= TourGuide
4 local OptionHouse
= DongleStub("OptionHouse-1.0")
5 local ww
= WidgetWarlock
8 local f
= CreateFrame("Button", nil, UIParent
)
9 f
:SetPoint("BOTTOMRIGHT", QuestWatchFrame
, "TOPRIGHT", 0, -15)
12 f
:RegisterForDrag("LeftButton")
13 f
:RegisterForClicks("anyUp")
15 f
:SetClampedToScreen(true)
16 f
:SetBackdrop(ww
.TooltipBorderBG
)
17 f
:SetBackdropColor(0,0,0,0.3)
18 f
:SetBackdropBorderColor(0,0,0,0.7)
20 local check
= ww
.SummonCheckBox(20, f
, "LEFT", 8, 0)
21 local icon
= ww
.SummonTexture(f
, 24, 24, nil, "LEFT", check
, "RIGHT", 4, 0)
22 local text
= ww
.SummonFontString(f
, nil, nil, "GameFontNormal", nil, "RIGHT", -12, 0)
23 text
:SetPoint("LEFT", icon
, "RIGHT", 4, 0)
25 local item
= CreateFrame("Button", nil, f
, "SecureActionButtonTemplate")
28 item
:SetPoint("BOTTOMLEFT", QuestWatchFrame
, "TOPRIGHT", 0, 10)
29 item
:RegisterForClicks("anyUp")
30 local itemicon
= ww
.SummonTexture(item
, 24, 24, "Interface\\Icons\\INV_Misc_Bag_08")
31 itemicon
:SetAllPoints(item
)
34 local f2
= CreateFrame("Frame", nil, UIParent
)
37 local text2
= ww
.SummonFontString(f2
, nil, nil, "GameFontNormal", nil, "RIGHT", -12, 0)
38 local icon2
= ww
.SummonTexture(f2
, 24, 24, nil, "RIGHT", text2
, "LEFT", -4, 0)
39 local check2
= ww
.SummonCheckBox(20, f2
, "RIGHT", icon2
, "LEFT", -4, 0)
40 check2
:SetChecked(true)
44 local elapsed
, oldsize
, newsize
45 f2
:SetScript("OnUpdate", function(self
, el
)
46 elapsed
= elapsed
+ el
53 self
:SetPoint("RIGHT", f
, "RIGHT", 0, elapsed
*40)
54 self
:SetAlpha(1 - elapsed
)
55 text
:SetAlpha(elapsed
)
56 icon
:SetAlpha(elapsed
)
57 f
:SetWidth(oldsize
+ (newsize
-oldsize
)*elapsed
)
61 function TourGuide
:SetText(i
)
63 local action
, quest
, note
, logi
, complete
, hasitem
= self
:GetObjectiveInfo(i
)
65 local newtext
= (quest
or"???")..(note
and " [?]" or "")
67 if text
:GetText() ~= newtext
or icon
:GetTexture() ~= self
.icons
[action
] then
68 oldsize
= f
:GetWidth()
72 f2
:SetPoint("RIGHT", f
, "RIGHT", 0, 0)
74 icon2
:SetTexture(icon
:GetTexture())
75 text2
:SetText(text
:GetText())
79 icon
:SetTexture(self
.icons
[action
])
81 check
:SetChecked(false)
82 if i
== 1 then f
:SetWidth(72 + text
:GetWidth()) end
83 newsize
= 72 + text
:GetWidth()
88 function TourGuide
:UpdateStatusFrame()
91 for i
in ipairs(self
.actions
) do
92 local name
= self
.quests
[i
]
93 if not self
.turnedin
[name
] and not nextstep
then
94 local action
, name
, note
, logi
, complete
, hasitem
, turnedin
, quest
, useitem
, optional
= self
:GetObjectiveInfo(i
)
97 if action
== "ITEM" then incomplete
= hasitem
98 elseif action
== "ACCEPT" then incomplete
= (not optional
or hasitem
) and not logi
99 elseif action
== "TURNIN" then incomplete
= not optional
100 elseif action
== "COMPLETE" then incomplete
= not complete
and (not optional
or logi
)
101 else incomplete
= not logi
end
102 if incomplete
then nextstep
= i
end
105 if action
== "COMPLETE" and logi
then
108 action
, _
, _
, logi
, complete
= self
:GetObjectiveInfo(j
)
109 if action
== "COMPLETE" and logi
and not complete
then AddQuestWatch(logi
) -- Watch if we're in a 'COMPLETE' block
110 elseif action
== "COMPLETE" and logi
then RemoveQuestWatch(logi
) end -- or unwatch if done
112 until action
~= "COMPLETE"
119 if not nextstep
and self
:LoadNextGuide() then return self
:UpdateStatusFrame() end
121 if not nextstep
then return end
123 self
:SetText(nextstep
)
124 self
.current
= nextstep
125 local action
, quest
, note
, logi
, complete
, hasitem
, turnedin
, fullquest
, useitem
, optional
= self
:GetObjectiveInfo(nextstep
)
128 -- TomTom coord mapping
129 if note
and TomTom
and not mapped
[action
..quest
] then
130 mapped
[action
..quest
] = true
131 for x
,y
in note
:gmatch("%(([%d.]+),([%d.]+)%)") do
132 TomTom
:AddWaypoint(tonumber(x
), tonumber(y
), quest
)
137 local newtext
= (quest
or "???")..(note
and " [?]" or "")
139 if text
:GetText() ~= newtext
or icon
:GetTexture() ~= self
.icons
[action
] then
140 oldsize
= f
:GetWidth()
144 f2
:SetPoint("RIGHT", f
, "RIGHT", 0, 0)
146 icon2
:SetTexture(icon
:GetTexture())
147 text2
:SetText(text
:GetText())
151 icon
:SetTexture(self
.icons
[action
])
152 text
:SetText(newtext
)
153 check
:SetChecked(false)
154 if not f2
:IsVisible() then f
:SetWidth(72 + text
:GetWidth()) end
155 newsize
= 72 + text
:GetWidth()
157 local tex
= useitem
and select(10, GetItemInfo(tonumber(useitem
)))
159 itemicon
:SetTexture(tex
)
160 item
:SetAttribute("type1", "item")
161 item
:SetAttribute("item1", "item:"..useitem
)
169 f
:SetScript("OnClick", function(self
, btn
)
170 if btn
== "RightButton" then
171 OptionHouse
:Open("Tour Guide", "Objectives")
173 local i
= TourGuide
:GetQuestLogIndexByName()
174 if i
then SelectQuestLogEntry(i
) end
175 ShowUIPanel(QuestLogFrame
)
180 check
:SetScript("OnClick", function(self
, btn
) TourGuide
:SetTurnedIn() end)
183 f
:SetScript("OnDragStart", function(self
) self
:StartMoving() end)
184 f
:SetScript("OnDragStop", function(self
) self
:StopMovingOrSizing() end)
187 f
:SetScript("OnLeave", function() GameTooltip
:Hide() end)
188 f
:SetScript("OnEnter", function(self
)
189 local tip
= TourGuide
.notes
[TourGuide
.current
]
190 if not tip
then return end
192 GameTooltip
:SetOwner(self
, "ANCHOR_NONE")
193 GameTooltip
:SetPoint("TOPRIGHT", self
, "TOPLEFT")
194 GameTooltip
:SetText(tip
, nil, nil, nil, nil, true)
198 item
:HookScript("OnClick", function()
199 if self
:GetCurrentObjectiveInfo() == "USE" then self
:SetTurnedIn() end