TourGuide
[WoW-TourGuide.git] / StatusFrame.lua
blob8a4194ad80ad1e7f2d3ebb0c665f519f79502925
3 local TourGuide = TourGuide
4 local OptionHouse = DongleStub("OptionHouse-1.0")
5 local ww = WidgetWarlock
8 local f = CreateFrame("Button", nil, UIParent)
9 f:SetPoint("BOTTOMRIGHT", QuestWatchFrame, "TOPRIGHT", 0, 10)
10 f:SetHeight(32)
11 f:EnableMouse(true)
12 f:RegisterForDrag("LeftButton")
13 f:RegisterForClicks("anyUp")
14 f:SetMovable(true)
15 f:SetClampedToScreen(true)
16 f:SetBackdrop(ww.TooltipBorderBG)
17 f:SetBackdropColor(0,0,0,0.3)
18 f:SetBackdropBorderColor(0,0,0,0.7)
20 local check = ww.SummonCheckBox(20, f, "LEFT", 8, 0)
21 local icon = ww.SummonTexture(f, 24, 24, nil, "LEFT", check, "RIGHT", 4, 0)
22 local text = ww.SummonFontString(f, nil, nil, "GameFontNormal", nil, "RIGHT", -12, 0)
23 text:SetPoint("LEFT", icon, "RIGHT", 4, 0)
25 local f2 = CreateFrame("Frame", nil, UIParent)
26 f2:SetHeight(32)
27 f2:SetWidth(100)
28 local text2 = ww.SummonFontString(f2, nil, nil, "GameFontNormal", nil, "RIGHT", -12, 0)
29 local icon2 = ww.SummonTexture(f2, 24, 24, nil, "RIGHT", text2, "LEFT", -4, 0)
30 local check2 = ww.SummonCheckBox(20, f2, "RIGHT", icon2, "LEFT", -4, 0)
31 check2:SetChecked(true)
32 f2:Hide()
35 local elapsed, oldsize, newsize
36 f2:SetScript("OnUpdate", function(self, el)
37 elapsed = elapsed + el
38 if elapsed > 1 then
39 self:Hide()
40 icon:SetAlpha(1)
41 text:SetAlpha(1)
42 f:SetWidth(newsize)
43 else
44 self:SetPoint("RIGHT", f, "RIGHT", 0, elapsed*40)
45 self:SetAlpha(1 - elapsed)
46 text:SetAlpha(elapsed)
47 icon:SetAlpha(elapsed)
48 f:SetWidth(oldsize + (newsize-oldsize)*elapsed)
49 end
50 end)
52 function TourGuide:SetText(i)
53 self.current = i
54 local newtext = self.quests[i]..(self.notes[i] and " [?]" or "")
56 if text:GetText() ~= newtext or icon:GetTexture() ~= self.icons[self.actions[i]] then
57 oldsize = f:GetWidth()
58 icon:SetAlpha(0)
59 text:SetAlpha(0)
60 elapsed = 0
61 f2:SetPoint("RIGHT", f, "RIGHT", 0, 0)
62 f2:SetAlpha(1)
63 icon2:SetTexture(icon:GetTexture())
64 text2:SetText(text:GetText())
65 f2:Show()
66 end
68 icon:SetTexture(self.icons[self.actions[i]])
69 text:SetText(newtext)
70 check:SetChecked(false)
71 if i == 1 then f:SetWidth(72 + text:GetWidth()) end
72 newsize = 72 + text:GetWidth()
73 end
76 function TourGuide:UpdateStatusFrame()
77 local nextstep
79 for i in ipairs(self.actions) do
80 local name = self.quests[i]
81 if not self.turnedin[name] and not nextstep then
82 local action, name, note, logi, complete, itemstarted = self:GetObjectiveInfo(i)
83 if not nextstep and (not logi or (action == "TURNIN" or action == "COMPLETE" and not complete)) then nextstep = i end
85 if action == "COMPLETE" and logi and complete then RemoveQuestWatch(logi) -- Un-watch if completed quest
86 elseif action == "COMPLETE" and logi then
87 local j = i
88 repeat
89 action, _, _, logi, complete = self:GetObjectiveInfo(j)
90 if action == "COMPLETE" and logi and not complete then AddQuestWatch(logi) -- Watch if we're in a 'COMPLETE' block
91 elseif action == "COMPLETE" and logi then RemoveQuestWatch(logi) end -- or unwatch if done
92 j = j + 1
93 until action ~= "COMPLETE"
94 end
95 end
96 end
98 QuestLog_Update()
99 QuestWatch_Update()
101 self:SetText(nextstep or 1)
105 f:SetScript("OnClick", function(self, btn)
106 if btn == "RightButton" then
107 OptionHouse:Open("Tour Guide", "Eversong Woods")
108 else
109 local i = TourGuide:GetQuestLogIndexByName()
110 if not i then return end
111 SelectQuestLogEntry(i)
112 ShowUIPanel(QuestLogFrame)
114 end)
117 check:SetScript("OnClick", function(self, btn)
118 TourGuide.turnedin[TourGuide.quests[TourGuide.current]] = true
119 TourGuide:UpdateStatusFrame()
120 TourGuide:UpdateOHPanel()
121 end)
124 f:SetScript("OnDragStart", function(self) self:StartMoving() end)
125 f:SetScript("OnDragStop", function(self) self:StopMovingOrSizing() end)