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 text2
:SetText(text
:GetText())
115 icon
:SetTexture(self
.icons
[action
])
116 text
:SetText(newtext
)
117 check
:SetChecked(false)
118 if i
== 1 then f
:SetWidth(FIXEDWIDTH
+ text
:GetWidth()) end
119 newsize
= FIXEDWIDTH
+ text
:GetWidth()
124 function TourGuide
:UpdateStatusFrame()
126 self
.updatedelay
= nil
128 for i
in ipairs(self
.actions
) do
129 local name
= self
.quests
[i
]
130 if not self
.turnedin
[name
] and not nextstep
then
131 local action
, name
, quest
= self
:GetObjectiveInfo(i
)
132 local turnedin
, logi
, complete
= self
:GetObjectiveStatus(i
)
133 local note
, useitem
, optional
, lootitem
, lootqty
= self
:GetObjectiveTag("N", i
), self
:GetObjectiveTag("U", i
), self
:GetObjectiveTag("O", i
), self
:GetObjectiveTag("L", i
)
134 local level
= self
:GetObjectiveTag("LV", i
)
135 local needlevel
= level
and level
> UnitLevel("player")
136 self
:Debug(11, "UpdateStatusFrame", i
, action
, name
, note
, logi
, complete
, turnedin
, quest
, useitem
, optional
, lootitem
, lootqty
, lootitem
and GetItemCount(lootitem
) or 0, level
, needlevel
)
137 local hasuseitem
= useitem
and self
:FindBagSlot(useitem
)
139 if action
== "NOTE" and not optional
and lootitem
and GetItemCount(lootitem
) >= lootqty
then return self
:SetTurnedIn(i
, true) end
142 if action
== "ACCEPT" then incomplete
= (not optional
or hasuseitem
) and not logi
143 elseif action
== "TURNIN" then incomplete
= not optional
or logi
and complete
144 elseif action
== "COMPLETE" then incomplete
= not complete
and (not optional
or logi
)
145 elseif action
== "NOTE" then incomplete
= not optional
or lootitem
and GetItemCount(lootitem
) >= lootqty
or needlevel
146 elseif action
== "GRIND" then incomplete
= needlevel
147 else incomplete
= not logi
end
149 if incomplete
then nextstep
= i
end
151 if action
== "COMPLETE" and logi
then
154 action
= self
:GetObjectiveInfo(j
)
155 turnedin
, logi
, complete
= self
:GetObjectiveStatus(j
)
156 if action
== "COMPLETE" and logi
and not complete
then AddQuestWatch(logi
) -- Watch if we're in a 'COMPLETE' block
157 elseif action
== "COMPLETE" and logi
then RemoveQuestWatch(logi
) end -- or unwatch if done
159 until action
~= "COMPLETE"
166 if not nextstep
and self
:LoadNextGuide() then return self
:UpdateStatusFrame() end
168 if not nextstep
then return end
170 self
:SetText(nextstep
)
171 self
.current
= nextstep
172 local action
, quest
, fullquest
= self
:GetObjectiveInfo(nextstep
)
173 local turnedin
, logi
, complete
= self
:GetObjectiveStatus(nextstep
)
174 local note
, useitem
, optional
= self
:GetObjectiveTag("N", nextstep
), self
:GetObjectiveTag("U", nextstep
), self
:GetObjectiveTag("O", nextstep
)
177 -- TomTom coord mapping
178 if note
and (TomTom
or Cartographer_Waypoints
) and not mapped
[action
..quest
] then
179 mapped
[action
..quest
] = true
180 for x
,y
in note
:gmatch("%(([%d.]+),([%d.]+)%)") do
181 if TomTom
then TomTom
:AddWaypoint(tonumber(x
), tonumber(y
), quest
)
182 elseif Cartographer_Waypoints
then Cartographer_Waypoints
:AddLHWaypoint(nil, nil, tonumber(x
), tonumber(y
), quest
) end
187 local newtext
= (quest
or "???")..(note
and " [?]" or "")
189 if text
:GetText() ~= newtext
or icon
:GetTexture() ~= self
.icons
[action
] then
190 oldsize
= f
:GetWidth()
194 f2
:SetWidth(f
:GetWidth())
195 f2anchor
= select(3, GetQuadrant(f
))
197 f2
:SetPoint(f2anchor
, f
, f2anchor
, 0, 0)
199 icon2
:SetTexture(icon
:GetTexture())
200 text2
:SetText(text
:GetText())
204 icon
:SetTexture(self
.icons
[action
])
205 text
:SetText(newtext
)
206 check
:SetChecked(false)
207 if not f2
:IsVisible() then f
:SetWidth(FIXEDWIDTH
+ text
:GetWidth()) end
208 newsize
= FIXEDWIDTH
+ text
:GetWidth()
210 local tex
= useitem
and select(10, GetItemInfo(tonumber(useitem
)))
212 itemicon
:SetTexture(tex
)
213 item
:SetAttribute("type1", "item")
214 item
:SetAttribute("item1", "item:"..useitem
)
222 f
:SetScript("OnClick", function(self
, btn
)
223 if btn
== "RightButton" then
224 OptionHouse
:Open("Tour Guide", "Objectives")
226 local i
= TourGuide
:GetQuestLogIndexByName()
227 if i
then SelectQuestLogEntry(i
) end
228 ShowUIPanel(QuestLogFrame
)
233 check
:SetScript("OnClick", function(self
, btn
) TourGuide
:SetTurnedIn() end)
236 item
:HookScript("OnClick", function()
237 if TourGuide
:GetObjectiveInfo() == "USE" then TourGuide
:SetTurnedIn() end
241 local function ShowTooltip(self
)
242 local tip
= TourGuide
.notes
[TourGuide
.current
]
243 if not tip
then return end
245 GameTooltip
:SetOwner(self
, "ANCHOR_NONE")
246 local quad
, vhalf
, hhalf
= GetQuadrant(self
)
247 local anchpoint
= (vhalf
== "TOP" and "BOTTOM" or "TOP")..hhalf
248 TourGuide
:Debug(11, "Setting tooltip anchor", anchpoint
, quad
, hhalf
, vhalf
)
249 GameTooltip
:SetPoint(quad
, self
, anchpoint
)
250 GameTooltip
:SetText(tip
, nil, nil, nil, nil, true)
254 f
:SetScript("OnLeave", function() GameTooltip
:Hide() end)
255 f
:SetScript("OnEnter", ShowTooltip
)
258 local function GetUIParentAnchor(frame
)
259 local w
, h
, x
, y
= UIParent
:GetWidth(), UIParent
:GetHeight(), frame
:GetCenter()
260 local hhalf
, vhalf
= (x
> w
/2) and "RIGHT" or "LEFT", (y
> h
/2) and "TOP" or "BOTTOM"
261 local dx
= hhalf
== "RIGHT" and math
.floor(frame
:GetRight() + 0.5) - w
or math
.floor(frame
:GetLeft() + 0.5)
262 local dy
= vhalf
== "TOP" and math
.floor(frame
:GetTop() + 0.5) - h
or math
.floor(frame
:GetBottom() + 0.5)
264 return vhalf
..hhalf
, dx
, dy
268 f
:RegisterForDrag("LeftButton")
270 f
:SetClampedToScreen(true)
271 f
:SetScript("OnDragStart", function(frame
)
275 f
:SetScript("OnDragStop", function(frame
)
276 frame
:StopMovingOrSizing()
277 TourGuide
:Debug(1, "Status frame moved", GetUIParentAnchor(frame
))
278 TourGuide
.db
.profile
.statusframepoint
, TourGuide
.db
.profile
.statusframex
, TourGuide
.db
.profile
.statusframey
= GetUIParentAnchor(frame
)
279 frame
:ClearAllPoints()
280 frame
:SetPoint(TourGuide
.db
.profile
.statusframepoint
, TourGuide
.db
.profile
.statusframex
, TourGuide
.db
.profile
.statusframey
)
285 item
:RegisterForDrag("LeftButton")
286 item
:SetMovable(true)
287 item
:SetClampedToScreen(true)
288 item
:SetScript("OnDragStart", item
.StartMoving
)
289 item
:SetScript("OnDragStop", function(frame
)
290 frame
:StopMovingOrSizing()
291 TourGuide
:Debug(1, "Item frame moved", GetUIParentAnchor(frame
))
292 TourGuide
.db
.profile
.itemframepoint
, TourGuide
.db
.profile
.itemframex
, TourGuide
.db
.profile
.itemframey
= GetUIParentAnchor(frame
)