3 bgFile
= "Interface\\Tooltips\\UI-Tooltip-Background",
4 edgeFile
= "Interface\\Tooltips\\UI-Tooltip-Border",
6 insets
= {left
= 5, right
= 5, top
= 5, bottom
= 5},
7 tile
= true, tileSize
= 16,
10 local ICONSIZE
, CHECKSIZE
, GAP
= 16, 16, 8
11 local FIXEDWIDTH
= ICONSIZE
+ CHECKSIZE
+ GAP
*4 - 4
13 local TourGuide
= TourGuide
14 local OptionHouse
= LibStub("OptionHouse-1.1")
15 local ww
= WidgetWarlock
18 local function GetQuadrant(frame
)
19 local x
,y
= frame
:GetCenter()
20 if not x
or not y
then return "BOTTOMLEFT", "BOTTOM", "LEFT" end
21 local hhalf
= (x
> UIParent
:GetWidth()/2) and "RIGHT" or "LEFT"
22 local vhalf
= (y
> UIParent
:GetHeight()/2) and "TOP" or "BOTTOM"
23 return vhalf
..hhalf
, vhalf
, hhalf
27 local f
= CreateFrame("Button", nil, UIParent
)
28 f
:SetPoint("BOTTOMRIGHT", QuestWatchFrame
, "TOPRIGHT", 0, -15)
30 f
:SetFrameStrata("LOW")
32 f
:RegisterForClicks("anyUp")
34 f
:SetBackdropColor(0.09, 0.09, 0.19, 0.5)
35 f
:SetBackdropBorderColor(0.5, 0.5, 0.5, 0.5)
37 local check
= ww
.SummonCheckBox(CHECKSIZE
, f
, "LEFT", GAP
, 0)
38 local icon
= ww
.SummonTexture(f
, "ARTWORK", ICONSIZE
, ICONSIZE
, nil, "LEFT", check
, "RIGHT", GAP
-4, 0)
39 local text
= ww
.SummonFontString(f
, "OVERLAY", "GameFontNormalSmall", nil, "RIGHT", -GAP
-4, 0)
40 text
:SetPoint("LEFT", icon
, "RIGHT", GAP
-4, 0)
42 local item
= CreateFrame("Button", nil, UIParent
, "SecureActionButtonTemplate")
43 item
:SetFrameStrata("LOW")
46 item
:SetPoint("BOTTOMRIGHT", QuestWatchFrame
, "TOPRIGHT", 0, 18)
47 item
:RegisterForClicks("anyUp")
48 local itemicon
= ww
.SummonTexture(item
, "ARTWORK", 24, 24, "Interface\\Icons\\INV_Misc_Bag_08")
49 itemicon
:SetAllPoints(item
)
52 local f2
= CreateFrame("Frame", nil, UIParent
)
53 local f2anchor
= "RIGHT"
56 local text2
= ww
.SummonFontString(f2
, "OVERLAY", "GameFontNormalSmall", nil, "RIGHT", -GAP
-4, 0)
57 local icon2
= ww
.SummonTexture(f2
, "ARTWORK", ICONSIZE
, ICONSIZE
, nil, "RIGHT", text2
, "LEFT", -GAP
+4, 0)
58 local check2
= ww
.SummonCheckBox(CHECKSIZE
, f2
, "RIGHT", icon2
, "LEFT", -GAP
+4, 0)
59 check2
:SetChecked(true)
63 local elapsed
, oldsize
, newsize
64 f2
:SetScript("OnUpdate", function(self
, el
)
65 elapsed
= elapsed
+ el
72 self
:SetPoint(f2anchor
, f
, f2anchor
, 0, elapsed
*40)
73 self
:SetAlpha(1 - elapsed
)
74 text
:SetAlpha(elapsed
)
75 icon
:SetAlpha(elapsed
)
76 f
:SetWidth(oldsize
+ (newsize
-oldsize
)*elapsed
)
81 function TourGuide
:PositionStatusFrame()
82 if self
.db
.profile
.statusframepoint
then
84 f
:SetPoint(self
.db
.profile
.statusframepoint
, self
.db
.profile
.statusframex
, self
.db
.profile
.statusframey
)
87 if self
.db
.profile
.itemframepoint
then
89 item
:SetPoint(self
.db
.profile
.itemframepoint
, self
.db
.profile
.itemframex
, self
.db
.profile
.itemframey
)
94 function TourGuide
:SetText(i
)
96 local action
, quest
= self
:GetObjectiveInfo(i
)
97 local note
= self
:GetObjectiveTag("N")
98 local newtext
= (quest
or"???")..(note
and " [?]" or "")
100 if text
:GetText() ~= newtext
or icon
:GetTexture() ~= self
.icons
[action
] then
101 oldsize
= f
:GetWidth()
105 f2
:SetWidth(f
:GetWidth())
106 f2anchor
= select(3, GetQuadrant(f
))
108 f2
:SetPoint(f2anchor
, f
, f2anchor
, 0, 0)
110 icon2
:SetTexture(icon
:GetTexture())
111 icon2
:SetTexCoord(4/48, 44/48, 4/48, 44/48)
112 text2
:SetText(text
:GetText())
116 icon
:SetTexture(self
.icons
[action
])
117 if action
~= "ACCEPT" and action
~= "TURNIN" then icon
:SetTexCoord(4/48, 44/48, 4/48, 44/48) end
118 text
:SetText(newtext
)
119 check
:SetChecked(false)
120 if i
== 1 then f
:SetWidth(FIXEDWIDTH
+ text
:GetWidth()) end
121 newsize
= FIXEDWIDTH
+ text
:GetWidth()
123 if self
.UpdateFubarPlugin
then self
.UpdateFubarPlugin(quest
, self
.icons
[action
], note
) end
128 function TourGuide
:UpdateStatusFrame()
130 self
.updatedelay
= nil
132 for i
in ipairs(self
.actions
) do
133 local name
= self
.quests
[i
]
134 if not self
.turnedin
[name
] and not nextstep
then
135 local action
, name
, quest
= self
:GetObjectiveInfo(i
)
136 local turnedin
, logi
, complete
= self
:GetObjectiveStatus(i
)
137 local note
, useitem
, optional
, lootitem
, lootqty
= self
:GetObjectiveTag("N", i
), self
:GetObjectiveTag("U", i
), self
:GetObjectiveTag("O", i
), self
:GetObjectiveTag("L", i
)
138 local level
= tonumber((self
:GetObjectiveTag("LV", i
)))
139 local needlevel
= level
and level
> UnitLevel("player")
140 self
:Debug(11, "UpdateStatusFrame", i
, action
, name
, note
, logi
, complete
, turnedin
, quest
, useitem
, optional
, lootitem
, lootqty
, lootitem
and GetItemCount(lootitem
) or 0, level
, needlevel
)
141 local hasuseitem
= useitem
and self
:FindBagSlot(useitem
)
143 -- Test for completed objectives and mark them done
144 if (action
== "RUN" or action
== "FLY" or action
== "HEARTH" or action
== "BOAT") and (GetSubZoneText() == name
or GetZoneText() == name
) then return self
:SetTurnedIn(i
, true) end
146 if action
== "KILL" or action
== "NOTE" then
147 if not optional
and lootitem
and GetItemCount(lootitem
) >= lootqty
then return self
:SetTurnedIn(i
, true) end
149 local quest
, questtext
= self
:GetObjectiveTag("Q", i
), self
:GetObjectiveTag("QO", i
)
150 if quest
and questtext
then
151 local qi
= self
:GetQuestLogIndexByName(quest
)
152 for lbi
=1,GetNumQuestLeaderBoards(qi
) do
153 self
:Debug(1, quest
, questtext
, qi
, GetQuestLogLeaderBoard(lbi
, qi
))
154 if GetQuestLogLeaderBoard(lbi
, qi
) == questtext
then return self
:SetTurnedIn(i
, true) end
160 if action
== "ACCEPT" then incomplete
= (not optional
or hasuseitem
) and not logi
161 elseif action
== "TURNIN" then incomplete
= not optional
or logi
and complete
162 elseif action
== "COMPLETE" then incomplete
= not complete
and (not optional
or logi
)
163 elseif action
== "NOTE" or action
== "KILL" then incomplete
= not optional
or lootitem
and GetItemCount(lootitem
) >= lootqty
or needlevel
164 elseif action
== "GRIND" then incomplete
= needlevel
165 else incomplete
= not logi
end
167 if incomplete
then nextstep
= i
end
169 if action
== "COMPLETE" and logi
then
172 action
= self
:GetObjectiveInfo(j
)
173 turnedin
, logi
, complete
= self
:GetObjectiveStatus(j
)
174 if action
== "COMPLETE" and logi
and not complete
then AddQuestWatch(logi
) -- Watch if we're in a 'COMPLETE' block
175 elseif action
== "COMPLETE" and logi
then RemoveQuestWatch(logi
) end -- or unwatch if done
177 until action
~= "COMPLETE"
184 if not nextstep
and self
:LoadNextGuide() then return self
:UpdateStatusFrame() end
186 if not nextstep
then return end
188 self
:SetText(nextstep
)
189 self
.current
= nextstep
190 local action
, quest
, fullquest
= self
:GetObjectiveInfo(nextstep
)
191 local turnedin
, logi
, complete
= self
:GetObjectiveStatus(nextstep
)
192 local note
, useitem
, optional
= self
:GetObjectiveTag("N", nextstep
), self
:GetObjectiveTag("U", nextstep
), self
:GetObjectiveTag("O", nextstep
)
193 local zonename
= self
:GetObjectiveTag("Z", nextstep
) or self
.zonename
196 if note
and (TomTom
or Cartographer_Waypoints
) and not mapped
[action
..quest
] then
197 mapped
[action
..quest
] = true
198 self
:ParseAndMapCoords(note
, quest
, zonename
) --, zone)
202 local newtext
= (quest
or "???")..(note
and " [?]" or "")
204 if text
:GetText() ~= newtext
or icon
:GetTexture() ~= self
.icons
[action
] then
205 oldsize
= f
:GetWidth()
209 f2
:SetWidth(f
:GetWidth())
210 f2anchor
= select(3, GetQuadrant(f
))
212 f2
:SetPoint(f2anchor
, f
, f2anchor
, 0, 0)
214 icon2
:SetTexture(icon
:GetTexture())
215 text2
:SetText(text
:GetText())
219 icon
:SetTexture(self
.icons
[action
])
220 text
:SetText(newtext
)
221 check
:SetChecked(false)
222 if not f2
:IsVisible() then f
:SetWidth(FIXEDWIDTH
+ text
:GetWidth()) end
223 newsize
= FIXEDWIDTH
+ text
:GetWidth()
225 local tex
= useitem
and select(10, GetItemInfo(tonumber(useitem
)))
227 itemicon
:SetTexture(tex
)
228 item
:SetAttribute("type1", "item")
229 item
:SetAttribute("item1", "item:"..useitem
)
237 f
:SetScript("OnClick", function(self
, btn
)
238 if btn
== "RightButton" then
239 OptionHouse
:Open("Tour Guide", "Objectives")
241 local i
= TourGuide
:GetQuestLogIndexByName()
242 if i
then SelectQuestLogEntry(i
) end
243 ShowUIPanel(QuestLogFrame
)
248 check
:SetScript("OnClick", function(self
, btn
) TourGuide
:SetTurnedIn() end)
251 item
:HookScript("OnClick", function()
252 if TourGuide
:GetObjectiveInfo() == "USE" then TourGuide
:SetTurnedIn() end
256 local function ShowTooltip(self
)
257 local tip
= TourGuide
:GetObjectiveTag("N")
258 if not tip
then return end
260 GameTooltip
:SetOwner(self
, "ANCHOR_NONE")
261 local quad
, vhalf
, hhalf
= GetQuadrant(self
)
262 local anchpoint
= (vhalf
== "TOP" and "BOTTOM" or "TOP")..hhalf
263 TourGuide
:Debug(11, "Setting tooltip anchor", anchpoint
, quad
, hhalf
, vhalf
)
264 GameTooltip
:SetPoint(quad
, self
, anchpoint
)
265 GameTooltip
:SetText(tip
, nil, nil, nil, nil, true)
269 f
:SetScript("OnLeave", function() GameTooltip
:Hide() end)
270 f
:SetScript("OnEnter", ShowTooltip
)
273 local function GetUIParentAnchor(frame
)
274 local w
, h
, x
, y
= UIParent
:GetWidth(), UIParent
:GetHeight(), frame
:GetCenter()
275 local hhalf
, vhalf
= (x
> w
/2) and "RIGHT" or "LEFT", (y
> h
/2) and "TOP" or "BOTTOM"
276 local dx
= hhalf
== "RIGHT" and math
.floor(frame
:GetRight() + 0.5) - w
or math
.floor(frame
:GetLeft() + 0.5)
277 local dy
= vhalf
== "TOP" and math
.floor(frame
:GetTop() + 0.5) - h
or math
.floor(frame
:GetBottom() + 0.5)
279 return vhalf
..hhalf
, dx
, dy
283 f
:RegisterForDrag("LeftButton")
285 f
:SetClampedToScreen(true)
286 f
:SetScript("OnDragStart", function(frame
)
290 f
:SetScript("OnDragStop", function(frame
)
291 frame
:StopMovingOrSizing()
292 TourGuide
:Debug(1, "Status frame moved", GetUIParentAnchor(frame
))
293 TourGuide
.db
.profile
.statusframepoint
, TourGuide
.db
.profile
.statusframex
, TourGuide
.db
.profile
.statusframey
= GetUIParentAnchor(frame
)
294 frame
:ClearAllPoints()
295 frame
:SetPoint(TourGuide
.db
.profile
.statusframepoint
, TourGuide
.db
.profile
.statusframex
, TourGuide
.db
.profile
.statusframey
)
300 item
:RegisterForDrag("LeftButton")
301 item
:SetMovable(true)
302 item
:SetClampedToScreen(true)
303 item
:SetScript("OnDragStart", item
.StartMoving
)
304 item
:SetScript("OnDragStop", function(frame
)
305 frame
:StopMovingOrSizing()
306 TourGuide
:Debug(1, "Item frame moved", GetUIParentAnchor(frame
))
307 TourGuide
.db
.profile
.itemframepoint
, TourGuide
.db
.profile
.itemframex
, TourGuide
.db
.profile
.itemframey
= GetUIParentAnchor(frame
)