vanilla-wow-addons – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 local loc = RecapFu.locals
2 local const = RecapFu.constants
3 local tablet = TabletLib:GetInstance('1.0')
4 local dewdrop = DewdropLib:GetInstance('1.0')
5 local compost = CompostLib:GetInstance('compost-1')
6 local metro = Metrognome:GetInstance('1')
7  
8 compost:Reclaim(RecapFu)
9 RecapFu = nil
10  
11 RecapFu = FuBarPlugin:GetInstance("1.2"):new({
12 name = const.Title,
13 description = loc.Desc,
14 version = "0.5.1",
15 releaseDate = string.sub("$Date: 2006-05-18 19:36:02 -0400 (Thu, 18 May 2006) $", 8, 17),
16 author = "Prandur",
17 website = "http://prandur.wowinterface.com",
18 aceCompatible = 103,
19 category = "combat",
20 db = AceDatabase:new("RecapFuDB"),
21 defaults = {
22 showlabel = true,
23 DPS = true,
24 },
25 cmd = AceChatCmd:new(const.Cmd, const.Cmd_Opt),
26 hasIcon = "Interface\\AddOns\\Recap\\Recap-Status",
27 })
28  
29 function RecapFu:Initialize()
30 end
31  
32 function RecapFu:Enable()
33 self.text = compost:Acquire()
34 metro:Register(self.name, self.Update, 1, self)
35 metro:Start(self.name)
36 end
37  
38 function RecapFu:Disable()
39 self.state = "n/a"
40 self.yourdps = "n/a"
41 self.dpsin = "n/a"
42 self.dpsout = "n/a"
43 self.healing = "n/a"
44 self.overheal = "n/a"
45 self.maxhit = "n/a"
46 self.totaldps = "n/a"
47 self.totaldpsin = "n/a"
48 self.viewtype = "n/a"
49  
50 metro:Unregister(self.name)
51 compost:Reclaim(self.text)
52 end
53  
54 function RecapFu:OnClick()
55 RecapFrame_Toggle()
56 end
57  
58 function RecapFu:UpdateData()
59 self:debug("Update Data")
60 if recap.Opt then
61 if recap.Opt.State then
62 self.state = recap.Opt.State.value or "n/a"
63 else
64 self.state = "n/a"
65 end
66 if recap.Opt.View and recap_temp.Local.LastAll then
67 self.viewtype = recap_temp.Local.LastAll[recap.Opt.View.value] or "n/a"
68 else
69 self.viewtype = "n/a"
70 end
71 else
72 self.state = "n/a"
73 self.viewtype = "n/a"
74 end
75 self.yourdps = RecapMinYourDPS_Text:GetText() or "n/a"
76 self.dpsin = RecapMinDPSIn_Text:GetText() or "n/a"
77 self.dpsout = RecapMinDPSOut_Text:GetText() or "n/a"
78 self.healing = RecapTotals_Heal:GetText() or 0
79 self.overheal = RecapTotals_Over:GetText() or 0
80 self.maxhit = RecapTotals_MaxHit:GetText() or "n/a"
81 self.totaldps = RecapTotals_DPS:GetText() or "n/a"
82 self.totaldpsin = RecapTotals_DPSIn:GetText() or "n/a"
83  
84 self.text.DPS = FuBarUtils.White(self.yourdps)
85 self.text.DPS_IN = FuBarUtils.Red(self.dpsin)
86 self.text.DPS_OUT = FuBarUtils.Green(self.dpsout)
87 self.text.HEALING = FuBarUtils.Colorize("00ffff", self.healing)
88 self.text.OVERHEAL = FuBarUtils.Colorize("00ffff", self.overheal)
89 self.text.MAXHIT = FuBarUtils.Orange(self.maxhit)
90 end
91  
92 function RecapFu:UpdateText()
93 self:debug("Update Text")
94 -- format the colored status bubble
95 if (self:IsIconShown()) then
96 if self.state=="Idle" then
97 self.iconFrame:SetVertexColor(.5,.5,.5)
98 elseif self.state=="Active" then
99 self.iconFrame:SetVertexColor(0,1,0)
100 elseif self.state=="Stopped" then
101 self.iconFrame:SetVertexColor(1,0,0)
102 end
103 end
104  
105 local t = compost:Acquire()
106 table.insert(t, self.data.showlabel and loc.BUTTON.LABEL or "")
107  
108 for i,e in self:pairsByKeys(const.TYPES) do
109 if self.data[e] then
110 table.insert(t, self.text[e])
111 end
112 end
113  
114 self:SetText(table.concat(t, " "))
115 compost:Reclaim(t)
116 end
117  
118 function RecapFu:UpdateTooltip()
119 self:debug("Update Tooltip")
120 local cat = tablet:AddCategory(
121 'columns', 2,
122 'child_textR', 1,
123 'child_textG', 1,
124 'child_textB', 0,
125 'child_text2R', 1,
126 'child_text2G', 1,
127 'child_text2B', 1
128 )
129 cat:AddLine('text', loc.TOOLTIP.STATE, 'text2', self.state)
130 cat:AddLine('text', loc.TOOLTIP.VIEW_TYPE, 'text2', self.viewtype)
131  
132 local cat = tablet:AddCategory(
133 'columns', 2,
134 'child_textR', 1,
135 'child_textG', 1,
136 'child_textB', 0
137 )
138 for i,e in self:pairsByKeys(const.TYPES) do
139 cat:AddLine('text', loc.TOOLTIP[e], 'text2', self.text[e])
140 end
141 tablet:SetHint(loc.BUTTON.HINT_TEXT)
142 end
143  
144 function RecapFu:MenuSettings()
145 for i,e in self:pairsByKeys(const.TYPES) do
146 local my_e = e
147 dewdrop:AddLine(
148 'text', loc.BUTTON[my_e],
149 'func', function() self:ToggleOption(my_e, true) end,
150 'checked', self.data[my_e]
151 )
152 end
153 dewdrop:AddLine()
154 if (recap and recap.Opt and recap.Opt.Paused.value == true) then
155 dewdrop:AddLine(
156 'text', loc.BUTTON.START_TEXT,
157 'func', function()
158 Recap_OnClick("Pause")
159 self:Update()
160 end,
161 'closeWhenClicked', true
162 )
163 else
164 dewdrop:AddLine(
165 'text', loc.BUTTON.PAUSE_TEXT,
166 'func', function()
167 Recap_OnClick("Pause")
168 self:Update()
169 end,
170 'closeWhenClicked', true
171 )
172 end
173 dewdrop:AddLine()
174 dewdrop:AddLine(
175 'text', loc.BUTTON.SHOWLABEL,
176 'func', function()
177 self:ToggleOption("showlabel", true)
178 end,
179 'checked', self.data.showlabel
180 )
181 end
182  
183 function RecapFu:ToggleOption(var, doUpdate)
184 self.data[var] = not self.data[var]
185 if doUpdate then
186 self:Update()
187 end
188 return self.data[var]
189 end
190  
191 function RecapFu:pairsByKeys (t, f)
192 --taken from an example in the Programming in Lua book
193 local a = compost:Acquire()
194 for n in pairs(t) do
195 table.insert(a, n)
196 end
197 table.sort(a, f)
198 local i = 0 -- iterator variable
199 local iter = function () -- iterator function
200 i = i + 1
201 if a[i] == nil then
202 return nil
203 else
204 return a[i], t[a[i]]
205 end
206 end
207 return iter
208 end
209  
210 RecapFu:RegisterForLoad()
211  
212 -- Simulate Titan Panel plugin
213 -- Necessary or updates to dps data on the plugin
214 -- may not occur until after combat ends
215 function TitanPanelRecap_Update()
216 end