0
@@ -12,6 +12,8 @@ local FIXEDWIDTH = ICONSIZE + CHECKSIZE + GAP*4 - 4
0
local TourGuide = TourGuide
0
local ww = WidgetWarlock
0
+local ldb = LibStub:GetLibrary("LibDataBroker-1.1")
0
+local dataobj = ldb:GetDataObjectByName("TourGuide")
0
local function GetQuadrant(frame)
0
@@ -76,206 +78,44 @@ function TourGuide:PositionStatusFrame()
0
-local dataobj = LibStub:GetLibrary("LibDataBroker-1.1"):NewDataObject("TourGuide", {text = "Bah!", icon = TourGuide.icons.KILL})
0
-function TourGuide:SetText(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
+ f2:SetWidth(f:GetWidth())
0
+ f2anchor = select(3, GetQuadrant(f))
0
+ f2:SetPoint(f2anchor, f, f2anchor, 0, 0)
0
+ text2:SetText(text:GetText())
0
- dataobj.text, dataobj.icon = newtext, self.icons[action]
0
- if text:GetText() ~= newtext or icon:GetTexture() ~= self.icons[action] then
0
- oldsize = f:GetWidth()
0
- f2:SetWidth(f:GetWidth())
0
- f2anchor = select(3, GetQuadrant(f))
0
- f2:SetPoint(f2anchor, f, f2anchor, 0, 0)
0
- icon2:SetTexture(icon:GetTexture())
0
- icon2:SetTexCoord(4/48, 44/48, 4/48, 44/48)
0
- text2:SetText(text:GetText())
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
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
- if self.UpdateFubarPlugin then self.UpdateFubarPlugin(quest, self.icons[action], note) end
0
-local lastmapped, lastmappedaction
0
-function TourGuide:UpdateStatusFrame()
0
- self:Debug(1, "UpdateStatusFrame", self.current)
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
- self.updatedelay = nil
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
- -- 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
- 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
- if action == "KILL" or action == "NOTE" then
0
- if not optional and haslootitem then return self:SetTurnedIn(i, true) end
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
- if action == "PET" and self.db.char.petskills[name] then return self:SetTurnedIn(i, true) end
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
- if incomplete then nextstep = i end
0
- if action == "COMPLETE" and logi and self.db.char.trackquests then
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
- until action ~= "COMPLETE"
0
- if not nextstep and self:LoadNextGuide() then return self:UpdateStatusFrame() end
0
- if not nextstep then return end
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
- 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
- local newtext = (quest or "???")..(note and " [?]" or "")
0
- if text:GetText() ~= newtext or icon:GetTexture() ~= self.icons[action] then
0
- oldsize = f:GetWidth()
0
- f2:SetWidth(f:GetWidth())
0
- f2anchor = select(3, GetQuadrant(f))
0
- f2:SetPoint(f2anchor, f, f2anchor, 0, 0)
0
- icon2:SetTexture(icon:GetTexture())
0
- text2:SetText(text:GetText())
0
- icon:SetTexture(self.icons[action])
0
- check:SetChecked(false)
0
- if not f2:IsVisible() then f:SetWidth(FIXEDWIDTH + text:GetWidth()) end
0
- newsize = FIXEDWIDTH + text:GetWidth()
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
- self:UpdateGuidesPanel()
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
-function dataobj.OnClick(self, btn)
0
- if TourGuide.db.char.currentguide == "No Guide" then InterfaceOptionsFrame_OpenToFrame(TourGuide.guidespanel)
0
- if btn == "RightButton" then
0
- if TourGuide.objectiveframe:IsVisible() then
0
- HideUIPanel(TourGuide.objectiveframe)
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
- local i = TourGuide:GetQuestLogIndexByName()
0
- if i then SelectQuestLogEntry(i) end
0
- ShowUIPanel(QuestLogFrame)
0
f:SetScript("OnClick", dataobj.OnClick)
0
-check:SetScript("OnClick", function(self, btn) TourGuide:SetTurnedIn() end)
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
- 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
f:SetScript("OnLeave", dataobj.OnLeave)
0
f:SetScript("OnEnter", dataobj.OnEnter)
0
+check:SetScript("OnClick", function(self, btn) TourGuide:SetTurnedIn() end)
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
+
dataobj.OnLeave(frame)
0
f:SetScript("OnDragStop", function(frame)
Comments
No one has commented yet.