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
)
98 local newtext
= (quest
or"???")..(self
:GetObjectiveTag("N") 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()
126 function TourGuide
:UpdateStatusFrame()
128 self
.updatedelay
= nil
130 for i
in ipairs(self
.actions
) do
131 local name
= self
.quests
[i
]
132 if not self
.turnedin
[name
] and not nextstep
then
133 local action
, name
, quest
= self
:GetObjectiveInfo(i
)
134 local turnedin
, logi
, complete
= self
:GetObjectiveStatus(i
)
135 local note
, useitem
, optional
, lootitem
, lootqty
= self
:GetObjectiveTag("N", i
), self
:GetObjectiveTag("U", i
), self
:GetObjectiveTag("O", i
), self
:GetObjectiveTag("L", i
)
136 local level
= self
:GetObjectiveTag("LV", i
)
137 local needlevel
= level
and level
> UnitLevel("player")
138 self
:Debug(11, "UpdateStatusFrame", i
, action
, name
, note
, logi
, complete
, turnedin
, quest
, useitem
, optional
, lootitem
, lootqty
, lootitem
and GetItemCount(lootitem
) or 0, level
, needlevel
)
139 local hasuseitem
= useitem
and self
:FindBagSlot(useitem
)
141 if action
== "NOTE" and not optional
and lootitem
and GetItemCount(lootitem
) >= lootqty
then return self
:SetTurnedIn(i
, true) end
144 if action
== "ACCEPT" then incomplete
= (not optional
or hasuseitem
) and not logi
145 elseif action
== "TURNIN" then incomplete
= not optional
or logi
and complete
146 elseif action
== "COMPLETE" then incomplete
= not complete
and (not optional
or logi
)
147 elseif action
== "NOTE" then incomplete
= not optional
or lootitem
and GetItemCount(lootitem
) >= lootqty
or needlevel
148 elseif action
== "GRIND" then incomplete
= needlevel
149 else incomplete
= not logi
end
151 if incomplete
then nextstep
= i
end
153 if action
== "COMPLETE" and logi
then
156 action
= self
:GetObjectiveInfo(j
)
157 turnedin
, logi
, complete
= self
:GetObjectiveStatus(j
)
158 if action
== "COMPLETE" and logi
and not complete
then AddQuestWatch(logi
) -- Watch if we're in a 'COMPLETE' block
159 elseif action
== "COMPLETE" and logi
then RemoveQuestWatch(logi
) end -- or unwatch if done
161 until action
~= "COMPLETE"
168 if not nextstep
and self
:LoadNextGuide() then return self
:UpdateStatusFrame() end
170 if not nextstep
then return end
172 self
:SetText(nextstep
)
173 self
.current
= nextstep
174 local action
, quest
, fullquest
= self
:GetObjectiveInfo(nextstep
)
175 local turnedin
, logi
, complete
= self
:GetObjectiveStatus(nextstep
)
176 local note
, useitem
, optional
= self
:GetObjectiveTag("N", nextstep
), self
:GetObjectiveTag("U", nextstep
), self
:GetObjectiveTag("O", nextstep
)
179 -- TomTom coord mapping
180 if note
and (TomTom
or Cartographer_Waypoints
) and not mapped
[action
..quest
] then
181 mapped
[action
..quest
] = true
182 for x
,y
in note
:gmatch("%(([%d.]+),%s?([%d.]+)%)") do
183 if TomTom
then TomTom
:AddWaypoint(tonumber(x
), tonumber(y
), quest
)
184 elseif Cartographer_Waypoints
then Cartographer_Waypoints
:AddLHWaypoint(nil, nil, tonumber(x
), tonumber(y
), quest
) end
189 local newtext
= (quest
or "???")..(note
and " [?]" or "")
191 if text
:GetText() ~= newtext
or icon
:GetTexture() ~= self
.icons
[action
] then
192 oldsize
= f
:GetWidth()
196 f2
:SetWidth(f
:GetWidth())
197 f2anchor
= select(3, GetQuadrant(f
))
199 f2
:SetPoint(f2anchor
, f
, f2anchor
, 0, 0)
201 icon2
:SetTexture(icon
:GetTexture())
202 text2
:SetText(text
:GetText())
206 icon
:SetTexture(self
.icons
[action
])
207 text
:SetText(newtext
)
208 check
:SetChecked(false)
209 if not f2
:IsVisible() then f
:SetWidth(FIXEDWIDTH
+ text
:GetWidth()) end
210 newsize
= FIXEDWIDTH
+ text
:GetWidth()
212 local tex
= useitem
and select(10, GetItemInfo(tonumber(useitem
)))
214 itemicon
:SetTexture(tex
)
215 item
:SetAttribute("type1", "item")
216 item
:SetAttribute("item1", "item:"..useitem
)
224 f
:SetScript("OnClick", function(self
, btn
)
225 if btn
== "RightButton" then
226 OptionHouse
:Open("Tour Guide", "Objectives")
228 local i
= TourGuide
:GetQuestLogIndexByName()
229 if i
then SelectQuestLogEntry(i
) end
230 ShowUIPanel(QuestLogFrame
)
235 check
:SetScript("OnClick", function(self
, btn
) TourGuide
:SetTurnedIn() end)
238 item
:HookScript("OnClick", function()
239 if TourGuide
:GetObjectiveInfo() == "USE" then TourGuide
:SetTurnedIn() end
243 local function ShowTooltip(self
)
244 local tip
= TourGuide
.notes
[TourGuide
.current
]
245 if not tip
then return end
247 GameTooltip
:SetOwner(self
, "ANCHOR_NONE")
248 local quad
, vhalf
, hhalf
= GetQuadrant(self
)
249 local anchpoint
= (vhalf
== "TOP" and "BOTTOM" or "TOP")..hhalf
250 TourGuide
:Debug(11, "Setting tooltip anchor", anchpoint
, quad
, hhalf
, vhalf
)
251 GameTooltip
:SetPoint(quad
, self
, anchpoint
)
252 GameTooltip
:SetText(tip
, nil, nil, nil, nil, true)
256 f
:SetScript("OnLeave", function() GameTooltip
:Hide() end)
257 f
:SetScript("OnEnter", ShowTooltip
)
260 local function GetUIParentAnchor(frame
)
261 local w
, h
, x
, y
= UIParent
:GetWidth(), UIParent
:GetHeight(), frame
:GetCenter()
262 local hhalf
, vhalf
= (x
> w
/2) and "RIGHT" or "LEFT", (y
> h
/2) and "TOP" or "BOTTOM"
263 local dx
= hhalf
== "RIGHT" and math
.floor(frame
:GetRight() + 0.5) - w
or math
.floor(frame
:GetLeft() + 0.5)
264 local dy
= vhalf
== "TOP" and math
.floor(frame
:GetTop() + 0.5) - h
or math
.floor(frame
:GetBottom() + 0.5)
266 return vhalf
..hhalf
, dx
, dy
270 f
:RegisterForDrag("LeftButton")
272 f
:SetClampedToScreen(true)
273 f
:SetScript("OnDragStart", function(frame
)
277 f
:SetScript("OnDragStop", function(frame
)
278 frame
:StopMovingOrSizing()
279 TourGuide
:Debug(1, "Status frame moved", GetUIParentAnchor(frame
))
280 TourGuide
.db
.profile
.statusframepoint
, TourGuide
.db
.profile
.statusframex
, TourGuide
.db
.profile
.statusframey
= GetUIParentAnchor(frame
)
281 frame
:ClearAllPoints()
282 frame
:SetPoint(TourGuide
.db
.profile
.statusframepoint
, TourGuide
.db
.profile
.statusframex
, TourGuide
.db
.profile
.statusframey
)
287 item
:RegisterForDrag("LeftButton")
288 item
:SetMovable(true)
289 item
:SetClampedToScreen(true)
290 item
:SetScript("OnDragStart", item
.StartMoving
)
291 item
:SetScript("OnDragStop", function(frame
)
292 frame
:StopMovingOrSizing()
293 TourGuide
:Debug(1, "Item frame moved", GetUIParentAnchor(frame
))
294 TourGuide
.db
.profile
.itemframepoint
, TourGuide
.db
.profile
.itemframex
, TourGuide
.db
.profile
.itemframey
= GetUIParentAnchor(frame
)