vanilla-wow-addons – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | assert( oRA, "oRA not found!") |
2 | |||
3 | ------------------------------ |
||
4 | -- Are you local? -- |
||
5 | ------------------------------ |
||
6 | |||
7 | local L = AceLibrary("AceLocale-2.2"):new("oRAOResurrection") |
||
8 | |||
9 | ---------------------------- |
||
10 | -- Localization -- |
||
11 | ---------------------------- |
||
12 | |||
13 | L:RegisterTranslations("enUS", function() return { |
||
14 | ["Resurrection Monitor"] = true, |
||
15 | ["resurrection"] = true, |
||
16 | ["resurrectionoptional"] = true, |
||
17 | ["Optional/Resurrection"] = true, |
||
18 | ["Options for resurrection."] = true, |
||
19 | ["Toggle"] = true, |
||
20 | ["toggle"] = true, |
||
21 | ["Toggle the Resurrection Monitor."] = true, |
||
22 | } end ) |
||
23 | |||
24 | L:RegisterTranslations("koKR", function() return { |
||
25 | |||
26 | ["Resurrection Monitor"] = "부활상태 모니터", |
||
27 | ["Optional/Resurrection"] = "부가/부활", |
||
28 | ["Options for resurrection."] = "부활 모니터링 설정", |
||
29 | ["Toggle"] = "토글", |
||
30 | ["Toggle the Resurrection Monitor."] = "부활 상태 모니터를 토글합니다.", |
||
31 | } end ) |
||
32 | |||
33 | L:RegisterTranslations("zhCN", function() return { |
||
34 | ["Resurrection Monitor"] = "复活监视器", |
||
35 | ["resurrection"] = "复活", |
||
36 | ["resurrectionoptional"] = "resurrectionoptional", |
||
37 | ["Optional/Resurrection"] = "Optional/Resurrection", |
||
38 | ["Options for resurrection."] = "复活选项", |
||
39 | ["Toggle"] = "激活", |
||
40 | ["toggle"] = "激活", |
||
41 | ["Toggle the Resurrection Monitor."] = "激活复活监视器", |
||
42 | } end ) |
||
43 | |||
44 | L:RegisterTranslations("zhTW", function() return { |
||
45 | ["Resurrection Monitor"] = "復活監視器", |
||
46 | ["resurrection"] = "復活", |
||
47 | ["resurrectionoptional"] = "resurrectionoptional", |
||
48 | ["Optional/Resurrection"] = "可選/復活", |
||
49 | ["Options for resurrection."] = "復活選項", |
||
50 | ["Toggle"] = "顯示", |
||
51 | ["toggle"] = "顯示", |
||
52 | ["Toggle the Resurrection Monitor."] = "顯示復活監視器", |
||
53 | } end ) |
||
54 | |||
55 | L:RegisterTranslations("frFR", function() return { |
||
56 | ["Resurrection Monitor"] = "Surveillance des r\195\169surrections", |
||
57 | --["resurrection"] = true, |
||
58 | --["resurrectionoptional"] = true, |
||
59 | ["Optional/Resurrection"] = "Optionnel/R\195\169surrection", |
||
60 | ["Options for resurrection."] = "Options concernant les r\195\169surrections.", |
||
61 | ["Toggle"] = "Afficher", |
||
62 | --["toggle"] = true, |
||
63 | ["Toggle the Resurrection Monitor."] = "Affiche ou non la surveillance des r\195\169surrections.", |
||
64 | } end ) |
||
65 | |||
66 | ---------------------------------- |
||
67 | -- Module Declaration -- |
||
68 | ---------------------------------- |
||
69 | |||
70 | oRAOResurrection = oRA:NewModule(L["resurrectionoptional"]) |
||
71 | oRAOResurrection.defaults = { |
||
72 | hidden = true, |
||
73 | } |
||
74 | oRAOResurrection.optional = true |
||
75 | oRAOResurrection.name = L["Optional/Resurrection"] |
||
76 | oRAOResurrection.consoleCmd = L["resurrection"] |
||
77 | oRAOResurrection.consoleOptions = { |
||
78 | type = "group", |
||
79 | desc = L["Options for resurrection."], |
||
80 | name = L["Resurrection Monitor"], |
||
81 | args = { |
||
82 | [L["toggle"]] = { |
||
83 | type = "toggle", name = L["Toggle"], |
||
84 | desc = L["Toggle the Resurrection Monitor."], |
||
85 | get = function() return not oRAOResurrection.db.profile.hidden end, |
||
86 | set = function(v) |
||
87 | oRAOResurrection:ToggleView() |
||
88 | end, |
||
89 | } |
||
90 | } |
||
91 | } |
||
92 | |||
93 | ------------------------------ |
||
94 | -- Initialization -- |
||
95 | ------------------------------ |
||
96 | |||
97 | function oRAOResurrection:OnEnable() |
||
98 | self.ressers = {} |
||
99 | self.enabled = nil |
||
100 | |||
101 | self:RegisterEvent("oRA_LeftRaid") |
||
102 | self:RegisterEvent("oRA_JoinedRaid") |
||
103 | end |
||
104 | |||
105 | function oRAOResurrection:OnDisable() |
||
106 | self:UnregisterAllEvents() |
||
107 | self:DisableMonitor() |
||
108 | end |
||
109 | |||
110 | |||
111 | ------------------------ |
||
112 | -- Event Handlers -- |
||
113 | ------------------------ |
||
114 | |||
115 | function oRAOResurrection:oRA_JoinedRaid() |
||
116 | if not self.enabled then |
||
117 | self.enabled = true |
||
118 | self.ressers = {} |
||
119 | if not self.db.profile.hidden then |
||
120 | self:SetupFrames() |
||
121 | self.resframe:Show() |
||
122 | self:UpdateFrame() |
||
123 | end |
||
124 | self:RegisterCheck("RES", "oRA_ResurrectionStart") |
||
125 | self:RegisterCheck("RESNO", "oRA_ResurrectionStop") |
||
126 | self:RegisterCheck("CANRES", "oRA_PlayerCanResurrect") |
||
127 | self:RegisterCheck("RESSED", "oRA_PlayerResurrected") |
||
128 | self:RegisterCheck("NORESSED", "oRA_PlayerNotResurrected") |
||
129 | self:RegisterEvent("RosterLib_RosterChanged", function() self:ScheduleEvent("oRACheckMonitor", self.CheckMonitor, 2, self) end ) |
||
130 | end |
||
131 | end |
||
132 | |||
133 | function oRAOResurrection:oRA_LeftRaid() |
||
134 | self:DisableMonitor() |
||
135 | end |
||
136 | |||
137 | function oRAOResurrection:CheckMonitor() |
||
138 | local u,v |
||
139 | local update = false |
||
140 | for key, val in pairs(self.ressers) do |
||
141 | u = self.core.roster:GetUnitObjectFromName(key) |
||
142 | v = self.core.roster:GetUnitObjectFromName(val) |
||
143 | if not u or not v then |
||
144 | self.ressers[key] = nil |
||
145 | update = true |
||
146 | end |
||
147 | end |
||
148 | if update and self.enabled and not self.db.profile.hidden then self:UpdateFrame() end |
||
149 | end |
||
150 | |||
151 | function oRAOResurrection:oRA_ResurrectionStart(msg, author) |
||
152 | msg = self:CleanMessage(msg) |
||
153 | local _,_,player = string.find(msg, "^RES (.+)$") |
||
154 | if player and author then |
||
155 | if not self.ressers then self.ressers = {} end |
||
156 | self.ressers[author] = player |
||
157 | self:UpdateFrame() |
||
158 | end |
||
159 | end |
||
160 | |||
161 | function oRAOResurrection:oRA_ResurrectionStop(msg, author) |
||
162 | msg = self:CleanMessage(msg) |
||
163 | if not self.ressers then self.ressers = {} end |
||
164 | if author and self.ressers[author] then |
||
165 | self.ressers[author] = nil |
||
166 | self:UpdateFrame() |
||
167 | end |
||
168 | end |
||
169 | |||
170 | function oRAOResurrection:oRA_PlayerCanResurrect( msg, author) |
||
171 | -- we do nothing with these atm. |
||
172 | end |
||
173 | |||
174 | function oRAOResurrection:oRA_PlayerResurrected( msg, author) |
||
175 | -- we do nothing with these atm. |
||
176 | end |
||
177 | |||
178 | function oRAOResurrection:oRA_PlayerNotResurrected( msg, author) |
||
179 | -- we do nothing with these atm. |
||
180 | end |
||
181 | |||
182 | ------------------------- |
||
183 | -- Utility Functions -- |
||
184 | ------------------------- |
||
185 | |||
186 | function oRAOResurrection:DisableMonitor() |
||
187 | self.enabled = nil |
||
188 | if self.resframe and self.resframe:IsVisible() then self.resframe:Hide() end |
||
189 | if self:IsEventRegistered("RosterLib_RosterChanged") then self:UnregisterEvent("RosterLib_RosterChanged") end |
||
190 | self:UnregisterCheck("RES") |
||
191 | self:UnregisterCheck("RESNO") |
||
192 | self:UnregisterCheck("CANRES") |
||
193 | self:UnregisterCheck("RESSED") |
||
194 | self:UnregisterCheck("NORESSED") |
||
195 | end |
||
196 | |||
197 | function oRAOResurrection:SavePosition() |
||
198 | local f = self.resframe |
||
199 | local x,y = f:GetLeft(), f:GetTop() |
||
200 | local s = f:GetEffectiveScale() |
||
201 | |||
202 | x,y = x*s,y*s |
||
203 | |||
204 | self.db.profile.posx = x |
||
205 | self.db.profile.posy = y |
||
206 | end |
||
207 | |||
208 | function oRAOResurrection:RestorePosition() |
||
209 | local x = self.db.profile.posx |
||
210 | local y = self.db.profile.posy |
||
211 | |||
212 | if not x or not y then return end |
||
213 | |||
214 | local f = self.resframe |
||
215 | local s = f:GetEffectiveScale() |
||
216 | |||
217 | x,y = x/s,y/s |
||
218 | |||
219 | f:ClearAllPoints() |
||
220 | f:SetPoint("TOPLEFT", UIParent, "BOTTOMLEFT", x, y) |
||
221 | end |
||
222 | |||
223 | function oRAOResurrection:SetupFrames() |
||
224 | if not self.resframe then |
||
225 | local resframe = CreateFrame("Frame", "oRAResurrectionFrame", UIParent) |
||
226 | resframe:EnableMouse(true) |
||
227 | resframe:SetMovable(true) |
||
228 | resframe:RegisterForDrag("LeftButton") |
||
229 | resframe:SetScript("OnDragStart", function() if IsAltKeyDown() then self["resframe"]:StartMoving() end end) |
||
230 | resframe:SetScript("OnDragStop", function() self["resframe"]:StopMovingOrSizing() self:SavePosition() end) |
||
231 | resframe:SetWidth(175) |
||
232 | resframe:SetHeight(50) |
||
233 | --resframe:SetBackdrop({ |
||
234 | -- bgFile = "Interface\\DialogFrame\\UI-DialogBox-Background", tile = true, tileSize = 16, |
||
235 | -- edgeFile = "Interface\Tooltips\UI-Tooltip-Border", edgeSize = 16, |
||
236 | -- insets = {left = 0, right = 0, top = 0, bottom = 0}, |
||
237 | --}) |
||
238 | --resframe:SetBackdropColor(0,0,0,0.5) |
||
239 | --resframe:SetBackdropBorderColor(1,1,1,.5) |
||
240 | resframe:Hide() |
||
241 | resframe:SetPoint("CENTER", UIParent, "CENTER", 0, 0) |
||
242 | |||
243 | local title = resframe:CreateFontString(nil, "ARTWORK") |
||
244 | title:SetFontObject(GameFontNormalSmall) |
||
245 | title:SetText(L["Resurrection Monitor"]) |
||
246 | title:SetJustifyH("CENTER") |
||
247 | title:SetWidth(160) |
||
248 | title:SetHeight(12) |
||
249 | title:Show() |
||
250 | title:ClearAllPoints() |
||
251 | title:SetPoint("TOP", resframe, "TOP", 0, -5) |
||
252 | |||
253 | local text = resframe:CreateFontString(nil, "ARTWORK") |
||
254 | text:SetFontObject(GameFontHighlightSmall) |
||
255 | text:SetJustifyH("CENTER") |
||
256 | text:SetJustifyV("TOP") |
||
257 | text:SetWidth(160) |
||
258 | --text:SetHeight(25) |
||
259 | text:Show() |
||
260 | text:ClearAllPoints() |
||
261 | text:SetPoint("TOPLEFT", title, "BOTTOMLEFT", 0, -5) |
||
262 | |||
263 | self.resframe = resframe |
||
264 | self.title = title |
||
265 | self.text = text |
||
266 | |||
267 | self:RestorePosition() |
||
268 | end |
||
269 | end |
||
270 | |||
271 | |||
272 | function oRAOResurrection:UpdateFrame() |
||
273 | if self.resframe and self.resframe:IsVisible() then |
||
274 | local text = "" |
||
275 | for key, val in pairs(self.ressers) do |
||
276 | if ( strlen(text) > 0 ) then |
||
277 | text = text.."\n" |
||
278 | end |
||
279 | text = string.format("%s %s: %s",text, key, val) |
||
280 | end |
||
281 | self.text:SetText(text) |
||
282 | self.resframe:SetWidth(max(self.text:GetWidth()+15, 175)) |
||
283 | self.resframe:SetHeight(max(self.text:GetHeight()+25, 50)) |
||
284 | end |
||
285 | end |
||
286 | |||
287 | ------------------------- |
||
288 | -- Command Handlers -- |
||
289 | ------------------------- |
||
290 | |||
291 | function oRAOResurrection:ToggleView() |
||
292 | self.db.profile.hidden = not self.db.profile.hidden |
||
293 | if self.resframe and self.resframe:IsVisible() then |
||
294 | self.resframe:Hide() |
||
295 | end |
||
296 | if self.enabled and not self.db.profile.hidden then |
||
297 | if not self.resframe then self:SetupFrames() end |
||
298 | self.resframe:Show() |
||
299 | end |
||
300 | end |
||
301 |