TourGuide
[WoW-TourGuide.git] / StatusFrame.lua
blob2dea37eb0e1b813749ee895ca53feefe5e6b6030
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 action, quest, note, logi, complete, hasitem = self:GetObjectiveInfo(i)
56 local newtext = (quest or"???")..(note and " [?]" or "")
58 if text:GetText() ~= newtext or icon:GetTexture() ~= self.icons[action] then
59 oldsize = f:GetWidth()
60 icon:SetAlpha(0)
61 text:SetAlpha(0)
62 elapsed = 0
63 f2:SetPoint("RIGHT", f, "RIGHT", 0, 0)
64 f2:SetAlpha(1)
65 icon2:SetTexture(icon:GetTexture())
66 text2:SetText(text:GetText())
67 f2:Show()
68 end
70 icon:SetTexture(self.icons[action])
71 text:SetText(newtext)
72 check:SetChecked(false)
73 if i == 1 then f:SetWidth(72 + text:GetWidth()) end
74 newsize = 72 + text:GetWidth()
75 end
78 function TourGuide:UpdateStatusFrame()
79 local nextstep
81 for i in ipairs(self.actions) do
82 local name = self.quests[i]
83 if not self.turnedin[name] and not nextstep then
84 local action, name, note, logi, complete, hasitem = self:GetObjectiveInfo(i)
85 if not nextstep then
86 local incomplete
87 if action == "ITEM" then incomplete = hasitem
88 elseif action == "TURNIN" then incomplete = true
89 elseif action == "COMPLETE" then incomplete = not complete
90 else incomplete = not logi end
91 if incomplete then nextstep = i end
92 end
94 if action == "COMPLETE" and logi then
95 local j = i
96 repeat
97 action, _, _, logi, complete = self:GetObjectiveInfo(j)
98 if action == "COMPLETE" and logi and not complete then AddQuestWatch(logi) -- Watch if we're in a 'COMPLETE' block
99 elseif action == "COMPLETE" and logi then RemoveQuestWatch(logi) end -- or unwatch if done
100 j = j + 1
101 until action ~= "COMPLETE"
105 QuestLog_Update()
106 QuestWatch_Update()
108 self:SetText(nextstep or 1)
109 self.current = nextstep or 1
110 local action, quest, note, logi, complete, hasitem = self:GetObjectiveInfo(nextstep or 1)
112 local newtext = (quest or"???")..(note and " [?]" or "")
114 if text:GetText() ~= newtext or icon:GetTexture() ~= self.icons[action] then
115 oldsize = f:GetWidth()
116 icon:SetAlpha(0)
117 text:SetAlpha(0)
118 elapsed = 0
119 f2:SetPoint("RIGHT", f, "RIGHT", 0, 0)
120 f2:SetAlpha(1)
121 icon2:SetTexture(icon:GetTexture())
122 text2:SetText(text:GetText())
123 f2:Show()
126 icon:SetTexture(self.icons[action])
127 text:SetText(newtext)
128 check:SetChecked(false)
129 if not f2:IsVisible() then f:SetWidth(72 + text:GetWidth()) end
130 newsize = 72 + text:GetWidth()
132 self:UpdateOHPanel()
136 f:SetScript("OnClick", function(self, btn)
137 if btn == "RightButton" then
138 OptionHouse:Open("Tour Guide", "Eversong Woods")
139 else
140 local i = TourGuide:GetQuestLogIndexByName()
141 if not i then return end
142 SelectQuestLogEntry(i)
143 ShowUIPanel(QuestLogFrame)
145 end)
148 check:SetScript("OnClick", function(self, btn) TourGuide:SetTurnedIn() end)
151 f:SetScript("OnDragStart", function(self) self:StartMoving() end)
152 f:SetScript("OnDragStop", function(self) self:StopMovingOrSizing() end)
155 f:SetScript("OnLeave", function() GameTooltip:Hide() end)
156 f:SetScript("OnEnter", function(self)
157 local tip = TourGuide.notes[TourGuide.current]
158 if not tip then return end
160 GameTooltip:SetOwner(self, "ANCHOR_NONE")
161 GameTooltip:SetPoint("TOPRIGHT", self, "TOPLEFT")
162 GameTooltip:SetText(tip, nil, nil, nil, nil, true)
163 end)