vanilla-wow-addons – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | |
2 | assert( oRA, "oRA not found!") |
||
3 | |||
4 | ------------------------------ |
||
5 | -- Are you local? -- |
||
6 | ------------------------------ |
||
7 | |||
8 | local L = AceLibrary("AceLocale-2.2"):new("oRAPReady") |
||
9 | |||
10 | ---------------------------- |
||
11 | -- Localization -- |
||
12 | ---------------------------- |
||
13 | |||
14 | L:RegisterTranslations("enUS", function() return { |
||
15 | ["ready"] = true, |
||
16 | ["readyparticipant"] = true, |
||
17 | ["Options for ready checks and votes."] = true, |
||
18 | ["sound"] = true, |
||
19 | ["Sound"] = true, |
||
20 | ["Toggle an audio warning upon a ready check or vote."] = true, |
||
21 | ["Ready"] = true, |
||
22 | ["Not Ready"] = true, |
||
23 | ["Are you Ready?"] = true, |
||
24 | ["Yes"] = true, |
||
25 | ["No"] = true, |
||
26 | ["Ready Check"] = true, |
||
27 | ["check"] = true, |
||
28 | ["Vote"] = true, |
||
29 | ["vote"] = true, |
||
30 | ["Perform a vote."] = true, |
||
31 | ["Participant/Ready"] = true, |
||
32 | ["Closing Vote"] = true, |
||
33 | ["Closing Check"] = true, |
||
34 | } end) |
||
35 | |||
36 | L:RegisterTranslations("koKR", function() return { |
||
37 | |||
38 | ["Options for ready checks and votes."] = "준비 확인과 투표 설정", |
||
39 | ["Sound"] = "소리", |
||
40 | ["Toggle an audio warning upon a ready check or vote."] = "투표나 준비 확인시 경고음 토글", |
||
41 | ["Ready"] = "준비완료", |
||
42 | ["Not Ready"] = "준비안됨", |
||
43 | ["Are you Ready?"] = "준비 되셨습니까?", |
||
44 | ["Yes"] = "예", |
||
45 | ["No"] = "아니오", |
||
46 | ["Ready Check"] = "준비 확인", |
||
47 | ["check"] = "확인", |
||
48 | ["Vote"] = "투표", |
||
49 | ["Perform a vote."] = "투표를 실시합니다.", |
||
50 | ["Participant/Ready"] = "부분/준비", |
||
51 | ["Closing Vote"] = "투표 닫기", |
||
52 | ["Closing Check"] = "확인 닫기", |
||
53 | } end) |
||
54 | |||
55 | L:RegisterTranslations("zhCN", function() return { |
||
56 | ["ready"] = "准备", |
||
57 | ["readyparticipant"] = "readyparticipant", |
||
58 | ["Options for ready checks and votes."] = "准备检查和投票的选项", |
||
59 | ["sound"] = "声音", |
||
60 | ["Sound"] = "声音", |
||
61 | ["Toggle an audio warning upon a ready check or vote."] = "准备检查或投票时发声", |
||
62 | ["Ready"] = "准备就绪", |
||
63 | ["Not Ready"] = "未准备好", |
||
64 | ["Are you Ready?"] = "准备好了么?", |
||
65 | ["Yes"] = "是", |
||
66 | ["No"] = "否", |
||
67 | ["Ready Check"] = "准备检查", |
||
68 | ["check"] = "检查", |
||
69 | ["Vote"] = "投票", |
||
70 | ["vote"] = "投票", |
||
71 | ["Perform a vote."] = "进行投票", |
||
72 | ["Participant/Ready"] = "Participant/Ready", |
||
73 | ["Closing Vote"] = "关闭投票", |
||
74 | ["Closing Check"] = "关闭检查", |
||
75 | } end) |
||
76 | |||
77 | L:RegisterTranslations("zhTW", function() return { |
||
78 | ["ready"] = "就位確認", |
||
79 | ["readyparticipant"] = "readyparticipant", |
||
80 | ["Options for ready checks and votes."] = "就位確認與投票選項", |
||
81 | ["sound"] = "聲音", |
||
82 | ["Sound"] = "聲音", |
||
83 | ["Toggle an audio warning upon a ready check or vote."] = "就位確認與投票時播放音效", |
||
84 | ["Ready"] = "已就緒", |
||
85 | ["Not Ready"] = "未就緒", |
||
86 | ["Are you Ready?"] = "準備好了嗎?", |
||
87 | ["Yes"] = "是", |
||
88 | ["No"] = "否", |
||
89 | ["Ready Check"] = "就位確認", |
||
90 | ["check"] = "檢查", |
||
91 | ["Vote"] = "投票", |
||
92 | ["vote"] = "投票", |
||
93 | ["Perform a vote."] = "進行投票", |
||
94 | ["Participant/Ready"] = "隊員/就位確認", |
||
95 | ["Closing Vote"] = "關閉投票", |
||
96 | ["Closing Check"] = "關閉檢查", |
||
97 | } end) |
||
98 | |||
99 | L:RegisterTranslations("frFR", function() return { |
||
100 | --["ready"] = true, |
||
101 | --["readyparticipant"] = true, |
||
102 | ["Options for ready checks and votes."] = "Options concernant les appels et les votes.", |
||
103 | --["sound"] = true, |
||
104 | ["Sound"] = "Son", |
||
105 | ["Toggle an audio warning upon a ready check or vote."] = "Joue ou non un avertissement sonore lors d'un appel ou d'un vote.", |
||
106 | ["Ready"] = "Pr\195\170t", |
||
107 | ["Not Ready"] = "Pas pr\195\170t", |
||
108 | ["Are you Ready?"] = "\195\138tes-vous pr\195\170t ?", |
||
109 | ["Yes"] = "Oui", |
||
110 | ["No"] = "Non", |
||
111 | ["Ready Check"] = "Appel", |
||
112 | --["check"] = true, |
||
113 | ["Vote"] = "Vote", |
||
114 | --["vote"] = true, |
||
115 | ["Perform a vote."] = "Soumet un vote.", |
||
116 | ["Participant/Ready"] = "Participant/Appel", |
||
117 | ["Closing Vote"] = "Cl\195\180ture du vote", |
||
118 | ["Closing Check"] = "Cl\195\180ture de l'appel", |
||
119 | } end) |
||
120 | |||
121 | ---------------------------------- |
||
122 | -- Module Declaration -- |
||
123 | ---------------------------------- |
||
124 | |||
125 | oRAPReady = oRA:NewModule(L["readyparticipant"], "CandyBar-2.0") |
||
126 | oRAPReady.defaults = { |
||
127 | sound = true, |
||
128 | } |
||
129 | oRAPReady.participant = true |
||
130 | oRAPReady.name = L["Participant/Ready"] |
||
131 | oRAPReady.consoleCmd = L["ready"] |
||
132 | oRAPReady.consoleOptions = { |
||
133 | type = "group", |
||
134 | desc = L["Options for ready checks and votes."], |
||
135 | name = L["Ready"], |
||
136 | args = { |
||
137 | [L["sound"]] = { |
||
138 | name = L["Sound"], type = "toggle", |
||
139 | desc = L["Toggle an audio warning upon a ready check or vote."], |
||
140 | get = function() return oRAPReady.db.profile.sound end, |
||
141 | set = function(v) |
||
142 | oRAPReady.db.profile.sound = v |
||
143 | end, |
||
144 | }, |
||
145 | } |
||
146 | } |
||
147 | |||
148 | ------------------------------ |
||
149 | -- Initialization -- |
||
150 | ------------------------------ |
||
151 | |||
152 | function oRAPReady:OnEnable() |
||
153 | |||
154 | self:RegisterCheck("CHECKREADY", "oRA_ReadyCheck") |
||
155 | self:RegisterCheck("VOTE", "oRA_Vote") |
||
156 | self:RegisterEvent( "oRA_BarTexture" ) |
||
157 | |||
158 | self:SetupFrames() |
||
159 | end |
||
160 | |||
161 | function oRAPReady:OnDisable() |
||
162 | self:UnregisterAllEvents() |
||
163 | self:UnregisterCheck("CHECKREADY") |
||
164 | self:UnregisterCheck("VOTE") |
||
165 | end |
||
166 | |||
167 | ------------------------- |
||
168 | -- Command Handlers -- |
||
169 | ------------------------- |
||
170 | |||
171 | |||
172 | ------------------------- |
||
173 | -- Event Handlers -- |
||
174 | ------------------------- |
||
175 | |||
176 | -- Handles an incoming ready check |
||
177 | |||
178 | function oRAPReady:oRA_ReadyCheck(msg, author) |
||
179 | if not self:IsValidRequest(author) then return end |
||
180 | if UnitName("player") ~= author then |
||
181 | if self.db.profile.sound then PlaySoundFile("Sound\\interface\\levelup2.wav") end |
||
182 | self:ShowReady( author ) |
||
183 | end |
||
184 | end |
||
185 | |||
186 | -- Handles an incoming vote |
||
187 | |||
188 | function oRAPReady:oRA_Vote(msg, author) |
||
189 | if not self:IsValidRequest(author) then return end |
||
190 | msg = self:CleanMessage(msg) |
||
191 | local _,_,question = string.find(msg, "^VOTE (.+)$") |
||
192 | if not question then return end |
||
193 | if UnitName("player") ~= author then |
||
194 | if self.db.profile.sound then PlaySoundFile("Sound\\interface\\levelup2.wav") end |
||
195 | self:ShowVote( author, question ) |
||
196 | end |
||
197 | end |
||
198 | |||
199 | function oRAPReady:oRA_BarTexture( texture ) |
||
200 | if self:CandyBarStatus( "oRAPReadyTimeOut" ) then |
||
201 | self:SetCandyBarTexture( "oRAPReadyTimeOut", self.core.bartextures[texture] ) |
||
202 | end |
||
203 | end |
||
204 | |||
205 | -------------------------- |
||
206 | -- Core function -- |
||
207 | -------------------------- |
||
208 | |||
209 | function oRAPReady:Vote( answer ) |
||
210 | if not answer then return end |
||
211 | if answer=="yes" then self:SendMessage("VOTEYES") |
||
212 | elseif answer=="no" then self:SendMessage("VOTENO") |
||
213 | end |
||
214 | end |
||
215 | |||
216 | |||
217 | function oRAPReady:Ready( readystate ) |
||
218 | if not readystate then return end |
||
219 | if readystate == "ready" then self:SendMessage("READY") |
||
220 | elseif readystate == "notready" then self:SendMessage("NOTREADY") |
||
221 | end |
||
222 | end |
||
223 | |||
224 | ------------------------------------ |
||
225 | -- Frame Setup and Handling -- |
||
226 | ------------------------------------ |
||
227 | |||
228 | function oRAPReady:ShowVote( author, question ) |
||
229 | self.frames.cheader:SetText(L["Vote"]) |
||
230 | self.frames.cinfo:SetText("|cffffffff"..author.. "|r: " .. question) |
||
231 | self.frames.leftbuttontext:SetText(L["Yes"]) |
||
232 | self.frames.rightbuttontext:SetText(L["No"]) |
||
233 | |||
234 | self.frames.leftbutton:SetScript("OnClick", |
||
235 | function() |
||
236 | this.owner:Vote("yes") |
||
237 | this.owner:StopCandyBar("oRAPReadyTimeOut") |
||
238 | this.owner.frames.check:Hide() |
||
239 | this.owner:CancelScheduledEvent("oRAPReady_HideCheck") |
||
240 | end ) |
||
241 | self.frames.rightbutton:SetScript("OnClick", |
||
242 | function() |
||
243 | this.owner:Vote("no") |
||
244 | this.owner:StopCandyBar("oRAPReadyTimeOut") |
||
245 | this.owner.frames.check:Hide() |
||
246 | this.owner:CancelScheduledEvent("oRAPReady_HideCheck") |
||
247 | end ) |
||
248 | |||
249 | self.frames.check:Show() |
||
250 | |||
251 | self:RegisterCandyBar( "oRAPReadyTimeOut", 30, L["Closing Vote"], nil, "green", "yellow", "orange", "red") |
||
252 | self:SetCandyBarPoint( "oRAPReadyTimeOut", "BOTTOM", self.frames.check, "BOTTOM", 0, 7 ) |
||
253 | self:SetCandyBarBackgroundColor( "oRAPReadyTimeOut", "black", 0 ) |
||
254 | self:SetCandyBarTexture( "oRAPReadyTimeOut", self.core.bartextures[self.core.db.profile.bartexture] ) |
||
255 | self:StartCandyBar( "oRAPReadyTimeOut", 1) |
||
256 | |||
257 | self:ScheduleEvent( "oRAPReady_HideCheck", function() self.frames.check:Hide() end, 30) |
||
258 | end |
||
259 | |||
260 | |||
261 | function oRAPReady:ShowReady( author ) |
||
262 | self.frames.cheader:SetText(L["Ready Check"]) |
||
263 | self.frames.cinfo:SetText("|cffffffff"..author.. "|r: " .. L["Are you Ready?"] ) |
||
264 | self.frames.leftbuttontext:SetText(L["Ready"]) |
||
265 | self.frames.rightbuttontext:SetText(L["Not Ready"]) |
||
266 | |||
267 | self.frames.leftbutton:SetScript("OnClick", |
||
268 | function() |
||
269 | this.owner:Ready("ready") |
||
270 | this.owner:StopCandyBar("oRAPReadyTimeOut") |
||
271 | this.owner.frames.check:Hide() |
||
272 | this.owner:CancelScheduledEvent("oRAPReady_HideCheck") |
||
273 | end ) |
||
274 | self.frames.rightbutton:SetScript("OnClick", |
||
275 | function() |
||
276 | this.owner:Ready("notready") |
||
277 | this.owner:StopCandyBar("oRAPReadyTimeOut") |
||
278 | this.owner.frames.check:Hide() |
||
279 | this.owner:CancelScheduledEvent("oRAPReady_HideCheck") |
||
280 | end ) |
||
281 | self.frames.check:Show() |
||
282 | |||
283 | self:RegisterCandyBar( "oRAPReadyTimeOut", 30, L["Closing Check"], nil, "green", "yellow", "orange", "red") |
||
284 | self:SetCandyBarPoint( "oRAPReadyTimeOut", "BOTTOM", self.frames.check, "BOTTOM", 0, 7 ) |
||
285 | self:SetCandyBarBackgroundColor( "oRAPReadyTimeOut", "black", 0 ) |
||
286 | self:SetCandyBarTexture( "oRAPReadyTimeOut", self.core.bartextures[self.core.db.profile.bartexture] ) |
||
287 | self:StartCandyBar( "oRAPReadyTimeOut", 1) |
||
288 | |||
289 | self:ScheduleEvent( "oRAPReady_HideCheck", function() self.frames.check:Hide() end, 30) |
||
290 | end |
||
291 | |||
292 | function oRAPReady:SetupFrames() |
||
293 | local f, t |
||
294 | |||
295 | f, _, _ = GameFontNormal:GetFont() |
||
296 | |||
297 | self.frames = {} |
||
298 | self.frames.check = CreateFrame("Frame", nil, UIParent) |
||
299 | self.frames.check:Hide() |
||
300 | self.frames.check:SetWidth(325) |
||
301 | self.frames.check:SetHeight(125) |
||
302 | self.frames.check:SetBackdrop({ |
||
303 | bgFile = "Interface\\DialogFrame\\UI-DialogBox-Background", tile = true, tileSize = 16, |
||
304 | edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border", edgeSize = 16, |
||
305 | insets = {left = 4, right = 4, top = 4, bottom = 4}, |
||
306 | }) |
||
307 | self.frames.check:SetBackdropBorderColor(.5, .5, .5) |
||
308 | self.frames.check:SetBackdropColor(0,0,0) |
||
309 | self.frames.check:ClearAllPoints() |
||
310 | self.frames.check:SetPoint("CENTER", WorldFrame, "CENTER", 0, 0) |
||
311 | |||
312 | self.frames.cfade = self.frames.check:CreateTexture(nil, "BORDER") |
||
313 | self.frames.cfade:SetWidth(319) |
||
314 | self.frames.cfade:SetHeight(25) |
||
315 | self.frames.cfade:SetTexture("Interface\\ChatFrame\\ChatFrameBackground") |
||
316 | self.frames.cfade:SetPoint("TOP", self.frames.check, "TOP", 0, -4) |
||
317 | self.frames.cfade:SetBlendMode("ADD") |
||
318 | self.frames.cfade:SetGradientAlpha("VERTICAL", .1, .1, .1, 0, .25, .25, .25, 1) |
||
319 | self.frames.check.Fade = self.frames.fade |
||
320 | |||
321 | self.frames.cheader = self.frames.check:CreateFontString(nil,"OVERLAY") |
||
322 | self.frames.cheader:SetFont(f, 14) |
||
323 | self.frames.cheader:SetWidth(300) |
||
324 | self.frames.cheader:SetText("header") |
||
325 | self.frames.cheader:SetTextColor(1, .8, 0) |
||
326 | self.frames.cheader:ClearAllPoints() |
||
327 | self.frames.cheader:SetPoint("TOP", self.frames.check, "TOP", 0, -10) |
||
328 | |||
329 | self.frames.cinfo = self.frames.check:CreateFontString(nil,"OVERLAY") |
||
330 | self.frames.cinfo:SetFont(f, 10) |
||
331 | self.frames.cinfo:SetWidth(300) |
||
332 | self.frames.cinfo:SetText("info") |
||
333 | self.frames.cinfo:SetTextColor(1, .8, 0) |
||
334 | self.frames.cinfo:ClearAllPoints() |
||
335 | self.frames.cinfo:SetPoint("TOP", self.frames.cheader, "BOTTOM", 0, -10) |
||
336 | |||
337 | self.frames.leftbutton = CreateFrame("Button", nil, self.frames.check) |
||
338 | self.frames.leftbutton.owner = self |
||
339 | self.frames.leftbutton:SetWidth(125) |
||
340 | self.frames.leftbutton:SetHeight(32) |
||
341 | self.frames.leftbutton:SetPoint("RIGHT", self.frames.check, "CENTER", -10, -20) |
||
342 | |||
343 | t = self.frames.leftbutton:CreateTexture() |
||
344 | t:SetWidth(125) |
||
345 | t:SetHeight(32) |
||
346 | t:SetPoint("CENTER", self.frames.leftbutton, "CENTER") |
||
347 | t:SetTexture("Interface\\Buttons\\UI-Panel-Button-Up") |
||
348 | t:SetTexCoord(0, 0.625, 0, 0.6875) |
||
349 | self.frames.leftbutton:SetNormalTexture(t) |
||
350 | |||
351 | t = self.frames.leftbutton:CreateTexture(nil, "BACKGROUND") |
||
352 | t:SetTexture("Interface\\Buttons\\UI-Panel-Button-Down") |
||
353 | t:SetTexCoord(0, 0.625, 0, 0.6875) |
||
354 | t:SetAllPoints(self.frames.leftbutton) |
||
355 | self.frames.leftbutton:SetPushedTexture(t) |
||
356 | |||
357 | t = self.frames.leftbutton:CreateTexture() |
||
358 | t:SetTexture("Interface\\Buttons\\UI-Panel-Button-Highlight") |
||
359 | t:SetTexCoord(0, 0.625, 0, 0.6875) |
||
360 | t:SetAllPoints(self.frames.leftbutton) |
||
361 | t:SetBlendMode("ADD") |
||
362 | self.frames.leftbutton:SetHighlightTexture(t) |
||
363 | self.frames.leftbuttontext = self.frames.leftbutton:CreateFontString(nil,"OVERLAY") |
||
364 | self.frames.leftbuttontext:SetFontObject(GameFontHighlight) |
||
365 | self.frames.leftbuttontext:SetText("left") |
||
366 | self.frames.leftbuttontext:SetAllPoints(self.frames.leftbutton) |
||
367 | |||
368 | self.frames.rightbutton = CreateFrame("Button", nil, self.frames.check) |
||
369 | self.frames.rightbutton.owner = self |
||
370 | self.frames.rightbutton:SetWidth(125) |
||
371 | self.frames.rightbutton:SetHeight(32) |
||
372 | self.frames.rightbutton:SetPoint("LEFT", self.frames.check, "CENTER", 10, -20) |
||
373 | |||
374 | t = self.frames.rightbutton:CreateTexture() |
||
375 | t:SetWidth(125) |
||
376 | t:SetHeight(32) |
||
377 | t:SetPoint("CENTER", self.frames.rightbutton, "CENTER") |
||
378 | t:SetTexture("Interface\\Buttons\\UI-Panel-Button-Up") |
||
379 | t:SetTexCoord(0, 0.625, 0, 0.6875) |
||
380 | self.frames.rightbutton:SetNormalTexture(t) |
||
381 | |||
382 | t = self.frames.rightbutton:CreateTexture(nil, "BACKGROUND") |
||
383 | t:SetTexture("Interface\\Buttons\\UI-Panel-Button-Down") |
||
384 | t:SetTexCoord(0, 0.625, 0, 0.6875) |
||
385 | t:SetAllPoints(self.frames.rightbutton) |
||
386 | self.frames.rightbutton:SetPushedTexture(t) |
||
387 | |||
388 | t = self.frames.rightbutton:CreateTexture() |
||
389 | t:SetTexture("Interface\\Buttons\\UI-Panel-Button-Highlight") |
||
390 | t:SetTexCoord(0, 0.625, 0, 0.6875) |
||
391 | t:SetAllPoints(self.frames.rightbutton) |
||
392 | t:SetBlendMode("ADD") |
||
393 | self.frames.rightbutton:SetHighlightTexture(t) |
||
394 | self.frames.rightbuttontext = self.frames.rightbutton:CreateFontString(nil,"OVERLAY") |
||
395 | self.frames.rightbuttontext:SetFontObject(GameFontHighlight) |
||
396 | self.frames.rightbuttontext:SetText("right") |
||
397 | self.frames.rightbuttontext:SetAllPoints(self.frames.rightbutton) |
||
398 | |||
399 | end |