public
Description: WoW Powerleveling addon
Homepage: http://www.tekkub.net/
Clone URL: git://github.com/tekkub/tourguide.git
Search Repo:
Click here to lend your support to: tourguide and make a donation at www.pledgie.com !
Split broker stuff off from status frame stuff
tekkub (author)
Thu Jul 10 23:31:17 -0700 2008
commit  e893252f8a7943837ba5327d2b7258d35aa0891c
tree    313a425a5f0ec10d61564f1b9ad99f2782cfcc54
parent  a940aab26ff84b6eb6eadf46d0b45801086c6f35
...
12
13
14
 
 
15
16
17
...
76
77
78
79
80
81
82
83
84
85
 
 
 
 
 
 
 
 
 
 
 
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
 
109
110
111
 
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
 
 
222
223
224
225
226
227
228
229
230
 
 
 
 
231
232
233
234
 
 
 
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
 
279
280
281
...
293
294
295
296
 
297
298
299
...
12
13
14
15
16
17
18
19
...
78
79
80
 
81
 
 
 
 
 
82
83
84
85
86
87
88
89
90
91
92
93
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
94
95
96
 
97
98
99
100
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
101
102
103
 
 
 
 
 
104
 
 
105
106
107
108
109
 
 
 
110
111
112
113
114
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
115
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
116
117
118
119
120
121
...
133
134
135
 
136
137
138
139
0
@@ -12,6 +12,8 @@ local FIXEDWIDTH = ICONSIZE + CHECKSIZE + GAP*4 - 4
0
 
0
 local TourGuide = TourGuide
0
 local ww = WidgetWarlock
0
+local ldb = LibStub:GetLibrary("LibDataBroker-1.1")
0
+local dataobj = ldb:GetDataObjectByName("TourGuide")
0
 
0
 
0
 local function GetQuadrant(frame)
0
@@ -76,206 +78,44 @@ function TourGuide:PositionStatusFrame()
0
   end
0
 end
0
 
0
-local dataobj = LibStub:GetLibrary("LibDataBroker-1.1"):NewDataObject("TourGuide", {text = "Bah!", icon = TourGuide.icons.KILL})
0
 
0
-function TourGuide:SetText(i)
0
- self.current = i
0
- local action, quest = self:GetObjectiveInfo(i)
0
- local note = self:GetObjectiveTag("N")
0
- local newtext = (quest or"???")..(note and " [?]" or "")
0
+ldb.RegisterCallback(TourGuide, "LibDataBroker_AttributeChanged_TourGuide_text", function(event, name, attr, value, dataobj)
0
+ oldsize = f:GetWidth()
0
+ icon:SetAlpha(0)
0
+ text:SetAlpha(0)
0
+ elapsed = 0
0
+ f2:SetWidth(f:GetWidth())
0
+ f2anchor = select(3, GetQuadrant(f))
0
+ f2:ClearAllPoints()
0
+ f2:SetPoint(f2anchor, f, f2anchor, 0, 0)
0
+ f2:SetAlpha(1)
0
+ text2:SetText(text:GetText())
0
 
0
- dataobj.text, dataobj.icon = newtext, self.icons[action]
0
-
0
- if text:GetText() ~= newtext or icon:GetTexture() ~= self.icons[action] then
0
- oldsize = f:GetWidth()
0
- icon:SetAlpha(0)
0
- text:SetAlpha(0)
0
- elapsed = 0
0
- f2:SetWidth(f:GetWidth())
0
- f2anchor = select(3, GetQuadrant(f))
0
- f2:ClearAllPoints()
0
- f2:SetPoint(f2anchor, f, f2anchor, 0, 0)
0
- f2:SetAlpha(1)
0
- icon2:SetTexture(icon:GetTexture())
0
- icon2:SetTexCoord(4/48, 44/48, 4/48, 44/48)
0
- text2:SetText(text:GetText())
0
- f2:Show()
0
- end
0
-
0
- icon:SetTexture(self.icons[action])
0
- if action ~= "ACCEPT" and action ~= "TURNIN" then icon:SetTexCoord(4/48, 44/48, 4/48, 44/48) end
0
- if self:GetObjectiveTag("T") then f:SetBackdropColor(0.09, 0.5, 0.19, 0.5) else f:SetBackdropColor(0.09, 0.09, 0.19, 0.5) end
0
- text:SetText(newtext)
0
+ text:SetText(value)
0
   check:SetChecked(false)
0
   check:SetButtonState("NORMAL")
0
- if self.db.char.currentguide == "No Guide" then check:Disable() else check:Enable() end
0
+ if TourGuide.db.char.currentguide == "No Guide" then check:Disable() else check:Enable() end
0
   if i == 1 then f:SetWidth(FIXEDWIDTH + text:GetWidth()) end
0
   newsize = FIXEDWIDTH + text:GetWidth()
0
 
0
- if self.UpdateFubarPlugin then self.UpdateFubarPlugin(quest, self.icons[action], note) end
0
-end
0
-
0
-
0
-local lastmapped, lastmappedaction
0
-function TourGuide:UpdateStatusFrame()
0
- self:Debug(1, "UpdateStatusFrame", self.current)
0
-
0
- if self.updatedelay then
0
- local _, logi = self:GetObjectiveStatus(self.updatedelay)
0
- self:Debug(1, "Delayed update", self.updatedelay, logi)
0
- if logi then return end
0
- end
0
-
0
- local nextstep
0
- self.updatedelay = nil
0
-
0
- for i in ipairs(self.actions) do
0
- local turnedin, logi, complete = self:GetObjectiveStatus(i)
0
- if not turnedin and not nextstep then
0
- local action, name, quest = self:GetObjectiveInfo(i)
0
- local note, useitem, optional, prereq, lootitem, lootqty = self:GetObjectiveTag("N", i), self:GetObjectiveTag("U", i), self:GetObjectiveTag("O", i), self:GetObjectiveTag("PRE", i), self:GetObjectiveTag("L", i)
0
- self:Debug(11, "UpdateStatusFrame", i, action, name, note, logi, complete, turnedin, quest, useitem, optional, lootitem, lootqty, lootitem and GetItemCount(lootitem) or 0)
0
- local hasuseitem = useitem and self:FindBagSlot(useitem)
0
- local haslootitem = lootitem and GetItemCount(lootitem) >= lootqty
0
- local prereqturnedin = prereq and self.turnedin[prereq]
0
-
0
- -- Test for completed objectives and mark them done
0
- if action == "SETHEARTH" and self.db.char.hearth == name then return self:SetTurnedIn(i, true) end
0
-
0
- local zonetext, subzonetext, subzonetag = GetZoneText(), string.trim(GetSubZoneText()), self:GetObjectiveTag("SZ")
0
- if (action == "RUN" or action == "FLY" or action == "HEARTH" or action == "BOAT") and (subzonetext == name or subzonetext == subzonetag or zonetext == name or zonetext == subzonetag) then return self:SetTurnedIn(i, true) end
0
-
0
- if action == "KILL" or action == "NOTE" then
0
- if not optional and haslootitem then return self:SetTurnedIn(i, true) end
0
-
0
- local quest, questtext = self:GetObjectiveTag("Q", i), self:GetObjectiveTag("QO", i)
0
- if quest and questtext then
0
- local qi = self:GetQuestLogIndexByName(quest)
0
- for lbi=1,GetNumQuestLeaderBoards(qi) do
0
- self:Debug(1, quest, questtext, qi, GetQuestLogLeaderBoard(lbi, qi))
0
- if GetQuestLogLeaderBoard(lbi, qi) == questtext then return self:SetTurnedIn(i, true) end
0
- end
0
- end
0
- end
0
-
0
- if action == "PET" and self.db.char.petskills[name] then return self:SetTurnedIn(i, true) end
0
-
0
- local incomplete
0
- if action == "ACCEPT" then incomplete = (not optional or hasuseitem or haslootitem or prereqturnedin) and not logi
0
- elseif action == "TURNIN" then incomplete = not optional or logi
0
- elseif action == "COMPLETE" then incomplete = not complete and (not optional or logi)
0
- elseif action == "NOTE" or action == "KILL" then incomplete = not optional or haslootitem
0
- else incomplete = not logi end
0
-
0
- if incomplete then nextstep = i end
0
-
0
- if action == "COMPLETE" and logi and self.db.char.trackquests then
0
- local j = i
0
- repeat
0
- action = self:GetObjectiveInfo(j)
0
- turnedin, logi, complete = self:GetObjectiveStatus(j)
0
- if action == "COMPLETE" and logi and not complete then AddQuestWatch(logi) -- Watch if we're in a 'COMPLETE' block
0
- elseif action == "COMPLETE" and logi then RemoveQuestWatch(logi) end -- or unwatch if done
0
- j = j + 1
0
- until action ~= "COMPLETE"
0
- end
0
- end
0
- end
0
- QuestLog_Update()
0
- QuestWatch_Update()
0
-
0
- if not nextstep and self:LoadNextGuide() then return self:UpdateStatusFrame() end
0
-
0
- if not nextstep then return end
0
-
0
- self:SetText(nextstep)
0
- self.current = nextstep
0
- local action, quest, fullquest = self:GetObjectiveInfo(nextstep)
0
- local turnedin, logi, complete = self:GetObjectiveStatus(nextstep)
0
- local note, useitem, optional = self:GetObjectiveTag("N", nextstep), self:GetObjectiveTag("U", nextstep), self:GetObjectiveTag("O", nextstep)
0
- local zonename = self:GetObjectiveTag("Z", nextstep) or self.zonename
0
- self:DebugF(1, "Progressing to objective \"%s %s\"", action, quest)
0
-
0
- -- Mapping
0
- if (TomTom or Cartographer_Waypoints) and (lastmapped ~= quest or lastmappedaction ~= action) then
0
- lastmappedaction, lastmapped = action, quest
0
- self:ParseAndMapCoords(action, quest, zonename, note, self:GetObjectiveTag("QID", nextstep))
0
- end
0
-
0
-
0
- local newtext = (quest or "???")..(note and " [?]" or "")
0
-
0
- if text:GetText() ~= newtext or icon:GetTexture() ~= self.icons[action] then
0
- oldsize = f:GetWidth()
0
- icon:SetAlpha(0)
0
- text:SetAlpha(0)
0
- elapsed = 0
0
- f2:SetWidth(f:GetWidth())
0
- f2anchor = select(3, GetQuadrant(f))
0
- f2:ClearAllPoints()
0
- f2:SetPoint(f2anchor, f, f2anchor, 0, 0)
0
- f2:SetAlpha(1)
0
- icon2:SetTexture(icon:GetTexture())
0
- text2:SetText(text:GetText())
0
- f2:Show()
0
- end
0
+ f2:Show()
0
+end)
0
 
0
- icon:SetTexture(self.icons[action])
0
- text:SetText(newtext)
0
- check:SetChecked(false)
0
- if not f2:IsVisible() then f:SetWidth(FIXEDWIDTH + text:GetWidth()) end
0
- newsize = FIXEDWIDTH + text:GetWidth()
0
 
0
- local usetex = useitem and select(10, GetItemInfo(tonumber(useitem)))
0
- self:SetUseItem(usetex, useitem)
0
+ldb.RegisterCallback(TourGuide, "LibDataBroker_AttributeChanged_TourGuide_icon", function(event, name, attr, value, dataobj)
0
+ local oldtexture = icon:GetTexture()
0
+ icon2:SetTexture(oldtexture)
0
+ if oldtexture and oldtexture:match("Interface\\Icons") then icon2:SetTexCoord(4/48, 44/48, 4/48, 44/48) else icon2:SetTexCoord(0,1,0,1) end
0
 
0
- self:UpdateOHPanel()
0
- self:UpdateGuidesPanel()
0
-end
0
+ icon:SetTexture(value)
0
+ if value and value:match("Interface\\Icons") then icon:SetTexCoord(4/48, 44/48, 4/48, 44/48) else icon:SetTexCoord(0,1,0,1) end
0
+end)
0
 
0
 
0
-function dataobj.OnClick(self, btn)
0
- if TourGuide.db.char.currentguide == "No Guide" then InterfaceOptionsFrame_OpenToFrame(TourGuide.guidespanel)
0
- else
0
- if btn == "RightButton" then
0
- if TourGuide.objectiveframe:IsVisible() then
0
- HideUIPanel(TourGuide.objectiveframe)
0
- else
0
- local quad, vhalf, hhalf = GetQuadrant(self)
0
- local anchpoint = (vhalf == "TOP" and "BOTTOM" or "TOP")..hhalf
0
- TourGuide.objectiveframe:ClearAllPoints()
0
- TourGuide.objectiveframe:SetPoint(quad, self, anchpoint)
0
- ShowUIPanel(TourGuide.objectiveframe)
0
- end
0
- else
0
- local i = TourGuide:GetQuestLogIndexByName()
0
- if i then SelectQuestLogEntry(i) end
0
- ShowUIPanel(QuestLogFrame)
0
- end
0
- end
0
-end
0
 f:SetScript("OnClick", dataobj.OnClick)
0
-
0
-
0
-check:SetScript("OnClick", function(self, btn) TourGuide:SetTurnedIn() end)
0
-
0
-
0
-function dataobj.OnLeave() GameTooltip:Hide() end
0
-function dataobj.OnEnter(self)
0
- local tip = TourGuide:GetObjectiveTag("N")
0
- if not tip then return end
0
-
0
- GameTooltip:SetOwner(self, "ANCHOR_NONE")
0
- local quad, vhalf, hhalf = GetQuadrant(self)
0
- local anchpoint = (vhalf == "TOP" and "BOTTOM" or "TOP")..hhalf
0
- TourGuide:Debug(11, "Setting tooltip anchor", anchpoint, quad, hhalf, vhalf)
0
- GameTooltip:SetPoint(quad, self, anchpoint)
0
- GameTooltip:SetText(tip, nil, nil, nil, nil, true)
0
-end
0
-
0
-
0
 f:SetScript("OnLeave", dataobj.OnLeave)
0
 f:SetScript("OnEnter", dataobj.OnEnter)
0
+check:SetScript("OnClick", function(self, btn) TourGuide:SetTurnedIn() end)
0
 
0
 
0
 local function GetUIParentAnchor(frame)
0
@@ -293,7 +133,7 @@ f:SetMovable(true)
0
 f:SetClampedToScreen(true)
0
 f:SetScript("OnDragStart", function(frame)
0
   if TourGuide.objectiveframe:IsVisible() then HideUIPanel(TourGuide.objectiveframe) end
0
- GameTooltip:Hide()
0
+ dataobj.OnLeave(frame)
0
   frame:StartMoving()
0
 end)
0
 f:SetScript("OnDragStop", function(frame)
...
26
27
28
 
29
30
31
...
26
27
28
29
30
31
32
0
@@ -26,6 +26,7 @@ Locale.lua
0
 TourGuide.lua
0
 Parser.lua
0
 Mapping.lua
0
+Broker.lua
0
 StatusFrame.lua
0
 ItemButton.lua
0
 Config.lua

Comments

    No one has commented yet.