vanilla-wow-addons – Blame information for rev 1

Subversion Repositories:
Rev:
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("oRAOPlayerTarget")
8 local roster = AceLibrary("RosterLib-2.0")
9 local paintchips = AceLibrary("PaintChips-2.0")
10 local tablet = AceLibrary("Tablet-2.0")
11  
12 ----------------------------
13 -- Localization --
14 ----------------------------
15  
16 L:RegisterTranslations("enUS", function() return {
17 ["playertargetoptional"] = true,
18 ["pt"] = true,
19 ["Player"] = true,
20 ["PlayerTarget"] = true,
21 ["Optional/PlayerTarget"] = true,
22 ["Options for the playertargets."] = true,
23 ["Targettarget"] = true,
24 ["Toggle TargetTarget frames."] = true,
25 ["Scale"] = true,
26 ["Set frame scale."] = true,
27 ["Alpha"] = true,
28 ["Set frame alpha."] = true,
29 ["Raidicon"] = true,
30 ["Toggle raid icons."] = true,
31 ["Frames"] = true,
32 ["Options for the playertarget frames."] = true,
33 ["Growup"] = true,
34 ["Toggle growup."] = true,
35 ["Inverse"] = true,
36 ["Toggle inverse healthbar."] = true,
37 ["Deficit"] = true,
38 ["Toggle deficit health."] = true,
39 ["Clickcast"] = true,
40 ["Toggle clickcast support."] = true,
41 ["Clicktarget"] = true,
42 ["Define clicktargets."] = true,
43 ["Define the clicktarget for player."] = true,
44 ["Define the clicktarget for target."] = true,
45 ["Define the clicktarget for targettarget."] = true,
46 ["Target"] = true,
47 ["TargetTarget"] = true,
48 ["Nr of Players shown."] = true,
49 ["Nr Players"] = true,
50 ["Nr"] = true,
51 ["Classcolor"] = true,
52 ["Color healthbars by class."] = true,
53 ["Enemycolor"] = true,
54 ["Set the color for enemies. (used when classcolor is enabled)"] = true,
55 ["Coloraggro"] = true,
56 ["Color Aggro"] = true,
57 ["Color aggro status for PTs on their names. Orange has target, Green is tanking, Red has no aggro."] = true,
58 ["Backdrop"] = true,
59 ["Toggle the backdrop."] = true,
60 ["Highlight"] = true,
61 ["Toggle highlighting your target."] = true,
62 ["Reverse"] = true,
63 ["Toggle reverse order PT|PTT|PTTT or PTTT|PTT|PT."] = true,
64 ["Numbers"] = true,
65 ["Toggle showing of PT numbers."] = true,
66 ["Tooltips"] = true,
67 ["Toggle showing of tooltips."] = true,
68 ["Show"] = true,
69 ["Show player."] = true,
70 ["Show target."] = true,
71 ["Show targettarget."] = true,
72 ["Define which frames you want to see."] = true,
73 ["Layout"] = true,
74 ["Set the layout for the PT frames."] = true,
75 ["Vertical"] = true,
76 ["Horizontal"] = true,
77  
78 ["set"] = true,
79 ["Set Player"] = true,
80 ["Set a player."]= true,
81 ["<nr> <name>"] = true,
82 ["<nr>"] = true,
83 ["<name>"] = true,
84 ["Remove Player"] = true,
85 ["remove"] = true,
86 ["Remove a player."] = true,
87 ["Removed player: "] = true,
88 ["Set player: "] = true,
89  
90 ["(%S+)%s*(.*)"] = true,
91  
92 ["<Not Assigned>"] = true,
93  
94 } end )
95  
96  
97 L:RegisterTranslations("koKR", function() return {
98 ["Player"] = "플레이어탱커",
99 ["PlayerTarget"] = "플레이어탱커대상",
100 ["Optional/PlayerTarget"] = "부가/플레이어탱커",
101 ["Options for the playertargets."] = "플레이어 탱커에 대한 설정을 변경합니다.",
102 ["Targettarget"] = "대상의대상",
103 ["Toggle TargetTarget frames."] = "대상의 대상창을 토글합니다.",
104 ["Scale"] = "크기",
105 ["Set frame scale."] = "창의 크기를 설정합니다.",
106 ["Alpha"] = "투명도",
107 ["Set frame alpha."] = "창의 투명도를 설정합니다.",
108 ["Raidicon"] = "공격대아이콘",
109 ["Toggle raid icons."] = "공격대 아이콘 표시를 토글합니다.",
110 ["Frames"] = "창",
111 ["Options for the playertarget frames."] = "플레이어탱커 창에 관한 설정을 변경합니다.",
112 ["Growup"] = "방향",
113 ["Toggle growup."] = "창의 진행 방향을 토글합니다.",
114 ["Inverse"] = "반전",
115 ["Toggle inverse healthbar."] = "생명력바 반전기능을 토글합니다.",
116 ["Deficit"] = "결손치",
117 ["Toggle deficit health."] = "생명력바 결손치 표시기능을 토글합니다.",
118 ["Clickcast"] = "시전",
119 ["Toggle clickcast support."] = "클릭캐스트 기능 지원을 토글합니다.",
120 ["Clicktarget"] = "클릭시대상선정",
121 ["Define clicktargets."] = "클릭시 선택 대상을 정의합니다.",
122 ["Define the clicktarget for player."] = "플레이어탱커를 클릭시 선택 대상을 정의힙니다.",
123 ["Define the clicktarget for target."] = "대상 클릭시 선택 대상을 정의합니다.",
124 ["Define the clicktarget for targettarget."] = "대상의 대상을 클릭시 선택 대상을 정의합니다.",
125 ["Target"] = "대상",
126 ["TargetTarget"] = "대상의대상",
127 ["Nr of Players shown."] = "플레이어탱커의 번호를 표시힙니다.",
128 ["Nr Players"] = "플레이어탱커의 수",
129 ["Nr"] = "수",
130 ["Classcolor"] = "직업별색상",
131 ["Color healthbars by class."] = "직업별로 생명력바의 색상을 변경합니다.",
132 ["Enemycolor"] = "적색상",
133 ["Set the color for enemies. (used when classcolor is enabled)"] = "적의 경우의 색상을 설정합니다. (직업별색상 기능을 사용할 때)",
134 ["Color Aggro"] = "어그로 색상",
135 ["Color aggro status for PTs on their names. Orange has target, Green is tanking, Red has no aggro."] = "현재 상태에 따라서 플레이어 탱커를 위한 어그로 색상을 표시힙니다. 오렌지는 대상, 녹색은 탱커, 적색은 어그로 없읍니다.",
136 ["Backdrop"] = "배경",
137 ["Toggle the backdrop."] = "배경 토글",
138 ["Highlight"] = "강조",
139 ["Toggle highlighting your target."] = "대상 강조 기능 토글",
140 ["Reverse"] = "반전",
141 ["Toggle reverse order PT|PTT|PTTT or PTTT|PTT|PT."] = "플레이어탱커목록의 순서를 반대로표시합니다.",
142 ["Numbers"] = "플레이어탱커번호",
143 ["Toggle showing of PT numbers."] = "플레이어탱커의 번호의 표시를 토글합니다.",
144 ["Tooltips"] = "툴팁",
145 ["Toggle showing of tooltips."] = "툴팁의 표시를 토글합니다.",
146 ["Show"] = "표시",
147 ["Show player."] = "플레이어탱커 표시",
148 ["Show target."] = "대상 표시",
149 ["Show targettarget."] = "대상의 대상 표시",
150 ["Define which frames you want to see."] = "표시하길 원하는 창을 정의합니다.",
151 ["Layout"] = "레이아웃",
152 ["Set the layout for the PT frames."] = "플레이어탱커창의 레이아웃을 설정합니다.",
153 ["Vertical"] = "수직",
154 ["Horizontal"] = "수평",
155  
156 -- ["set"] = true,
157 ["Set Player"] = "플레이어 선택",
158 ["Set a player."]= "플레이어를 선택합니다",
159 ["<nr> <name>"] = "<번호> <이름>",
160 ["<nr>"] = "<번호>",
161 ["<name>"] = "<이름>",
162 ["Remove Player"] = "플레이어 삭제",
163 ["remove"] = "삭제",
164 ["Remove a player."] = "플레이어를 목록에서 삭제합니다.",
165 ["Removed player: "] = "삭제된 플레이어: ",
166 ["Set player: "] = "설정된 플레이어: ",
167  
168 ["(%S+)%s*(.*)"] = "(%S+)%s*(.*)",
169  
170 ["<Not Assigned>"] = "<미정의됨>",
171  
172 } end )
173  
174 L:RegisterTranslations("zhCN", function() return {
175 ["playertargetoptional"] = "playertargetoptional",
176 ["pt"] = "玩家目标",
177 ["Player"] = "玩家",
178 ["PlayerTarget"] = "玩家目标",
179 ["Optional/PlayerTarget"] = "Optional/PlayerTarget",
180 ["Options for the playertargets."] = "玩家目标选项",
181 ["Targettarget"] = "目标的目标",
182 ["Toggle TargetTarget frames."] = "显示目标的目标框体",
183 ["Scale"] = "大小",
184 ["Set frame scale."] = "设定框体大小",
185 ["Alpha"] = "透明度",
186 ["Set frame alpha."] = "设置框体透明度",
187 ["Raidicon"] = "raid图标",
188 ["Toggle raid icons."] = "显示raid图标",
189 ["Frames"] = "框体",
190 ["Options for the playertarget frames."] = "玩家目标框体选项",
191 ["Growup"] = "往上增添",
192 ["Toggle growup."] = "选择往上增添",
193 ["Inverse"] = "翻转",
194 ["Toggle inverse healthbar."] = "选择翻转血条",
195 ["Deficit"] = "亏损血量",
196 ["Toggle deficit health."] = "显示亏损血量",
197 ["Clickcast"] = "点击施法",
198 ["Toggle clickcast support."] = "选择点击施法支持",
199 ["Clicktarget"] = "点击设定目标",
200 ["Define clicktargets."] = "定义点击设定目标",
201 ["Define the clicktarget for player."] = "定义点击PT设定的目标",
202 ["Define the clicktarget for target."] = "定义点击PTT设定的目标",
203 ["Define the clicktarget for targettarget."] = "定义点击PTTT设定的目标",
204 ["Target"] = "目标",
205 ["TargetTarget"] = "目标的目标",
206 ["Nr of Players shown."] = "显示的PT数量",
207 ["Nr Players"] = "PT数量",
208 ["Nr"] = "数量",
209 ["Classcolor"] = "职业颜色",
210 ["Color healthbars by class."] = "把血条着色为职业颜色",
211 ["Enemycolor"] = "敌人颜色",
212 ["Set the color for enemies. (used when classcolor is enabled)"] = "为敌人设置颜色(需要激活职业颜色)",
213 ["Coloraggro"] = "仇恨颜色",
214 ["Color Aggro"] = "仇恨颜色",
215 ["Color aggro status for PTs on their names. Orange has target, Green is tanking, Red has no aggro."] = "PT的名字边框用颜色来显示仇恨的状态。橘红是有目标,绿色是正在坦克,红色是没有仇恨",
216 ["Backdrop"] = "背景",
217 ["Toggle the backdrop."] = "显示背景",
218 ["Highlight"] = "高亮",
219 ["Toggle highlighting your target."] = "高亮显示你的目标",
220 ["Reverse"] = "逆转",
221 ["Toggle reverse order PT|PTT|PTTT or PTTT|PTT|PT."] = "逆转顺序:MT|MTT|MTTT 或 MTTT|MTT|MT",
222 ["Numbers"] = "数量",
223 ["Toggle showing of PT numbers."] = "显示PT的数量",
224 ["Tooltips"] = "提示",
225 ["Toggle showing of tooltips."] = "顯示提示",
226 ["Show"] = "显示",
227 ["Show player."] = "显示PT",
228 ["Show target."] = "显示目标",
229 ["Show targettarget."] = "显示目标的目标",
230 ["Define which frames you want to see."] = "定义想要看到的框架",
231 ["Layout"] = "布局",
232 ["Set the layout for the PT frames."] = "设置PT框架的布局",
233 ["Vertical"] = "垂直",
234 ["Horizontal"] = "水平",
235  
236 ["set"] = "设置",
237 ["Set Player"] = "设定PT",
238 ["Set a player."]= "设定PT",
239 ["<nr> <name>"] = "<数量> <名字>",
240 ["<nr>"] = "<数量>",
241 ["<name>"] = "<姓名>",
242 ["Remove Player"] = "移除PT",
243 ["remove"] = "移除",
244 ["Remove a player."] = "移除PT",
245 ["Removed player: "] = "移除PT:",
246 ["Set player: "] = "设置PT:",
247  
248 ["(%S+)%s*(.*)"] = "(%d+)%s*(.*)",
249  
250 ["<Not Assigned>"] = "<还未设定>",
251 } end )
252  
253 L:RegisterTranslations("zhTW", function() return {
254 ["playertargetoptional"] = "玩家自訂目標",
255 ["pt"] = "玩家目標",
256 ["Player"] = "玩家",
257 ["PlayerTarget"] = "玩家目標",
258 ["Optional/PlayerTarget"] = "可選/玩家目標",
259 ["Options for the playertargets."] = "玩家目標選項",
260 ["Targettarget"] = "目標的目標",
261 ["Toggle TargetTarget frames."] = "顯示目標的目標框架",
262 ["Scale"] = "大小",
263 ["Set frame scale."] = "設定框架大小",
264 ["Alpha"] = "透明度",
265 ["Set frame alpha."] = "設定框架的透明度",
266 ["Raidicon"] = "團隊圖示",
267 ["Toggle raid icons."] = "切換團隊圖示",
268 ["Frames"] = "框架",
269 ["Options for the playertarget frames."] = "玩家目標的框架選項",
270 ["Growup"] = "往上排列",
271 ["Toggle growup."] = "切換往上排列",
272 ["Inverse"] = "倒轉",
273 ["Toggle inverse healthbar."] = "切換倒轉血條",
274 ["Deficit"] = "減少血量",
275 ["Toggle deficit health."] = "顯示減少血量",
276 ["Clickcast"] = "點擊施法",
277 ["Toggle clickcast support."] = "切換點擊施法支援",
278 ["Clicktarget"] = "點擊設定目標",
279 ["Define clicktargets."] = "定義點擊設定目標",
280 ["Define the clicktarget for player."] = "定義點擊PT設定的目標",
281 ["Define the clicktarget for target."] = "定義點擊PTT設定的目標",
282 ["Define the clicktarget for targettarget."] = "定義點擊PTTT設定的目標",
283 ["Target"] = "目標",
284 ["TargetTarget"] = "目標的目標",
285 ["Nr of Players shown."] = "顯示的玩家數量",
286 ["Nr Players"] = "玩家數量",
287 ["Nr"] = "數量",
288 ["Classcolor"] = "職業顏色",
289 ["Color healthbars by class."] = "依職業設定血條顏色",
290 ["Enemycolor"] = "敵人顏色",
291 ["Set the color for enemies. (used when classcolor is enabled)"] = "為敵人設定顏色(需要使用職業顏色)",
292 ["Coloraggro"] = "仇恨顏色",
293 ["Color Aggro"] = "仇恨顏色",
294 ["Color aggro status for PTs on their names. Orange has target, Green is tanking, Red has no aggro."] = "玩家目標的名字邊框用顏色來顯示仇恨的狀態。橘紅是有目標,綠色是正在坦怪,紅色是沒有仇恨。",
295 ["Backdrop"] = "背景",
296 ["Toggle the backdrop."] = "顯示背景",
297 ["Highlight"] = "高亮度",
298 ["Toggle highlighting your target."] = "高亮度顯示你的目標",
299 ["Reverse"] = "反轉",
300 ["Toggle reverse order PT|PTT|PTTT or PTTT|PTT|PT."] = "反轉順序:PT|PTT|PTTT 或 PTTT|PTT|PT",
301 ["Numbers"] = "數量",
302 ["Toggle showing of PT numbers."] = "顯示玩家目標的數量",
303 ["Tooltips"] = "提示",
304 ["Toggle showing of tooltips."] = "顯示提示",
305 ["Show"] = "顯示",
306 ["Show player."] = "顯示玩家",
307 ["Show target."] = "顯示目標",
308 ["Show targettarget."] = "顯示目標的目標",
309 ["Define which frames you want to see."] = "定義想要看到的框架",
310 ["Layout"] = "佈置",
311 ["Set the layout for the PT frames."] = "設定玩家目標框架的佈置",
312 ["Vertical"] = "垂直",
313 ["Horizontal"] = "水平",
314  
315 ["set"] = "設置",
316 ["Set Player"] = "設置玩家",
317 ["Set a player."]= "設置一位玩家",
318 ["<nr> <name>"] = "<數量> <姓名>",
319 ["<nr>"] = "<數量>",
320 ["<name>"] = "<姓名>",
321 ["Remove Player"] = "移除玩家",
322 ["remove"] = "移除",
323 ["Remove a player."] = "移除一位玩家",
324 ["Removed player: "] = "移除玩家:",
325 ["Set player: "] = "設置玩家:",
326  
327 ["(%S+)%s*(.*)"] = "(%S+)%s*(.*)",
328  
329 ["<Not Assigned>"] = "<尚未設置>",
330  
331 } end )
332  
333 L:RegisterTranslations("frFR", function() return {
334 --["playertargetoptional"] = true,
335 --["pt"] = true,
336 ["Player"] = "Joueur",
337 ["PlayerTarget"] = "Cibles Joueurs (PT)",
338 ["Optional/PlayerTarget"] = "Optionnel/Cibles Joueurs",
339 ["Options for the playertargets."] = "Optons concernant les cibles des joueurs.",
340 --["Targettarget"] = true,
341 ["Toggle TargetTarget frames."] = "Affiche ou non les cadres de la cible de la cible.",
342 ["Scale"] = "Taille",
343 ["Set frame scale."] = "D\195\169termine la taille des cadres.",
344 ["Alpha"] = "Transparence",
345 ["Set frame alpha."] = "D\195\169termine la transparence des cadres.",
346 ["Raidicon"] = "Ic\195\180nedeRaid",
347 ["Toggle raid icons."] = "Affiche ou non les ic\195\180nes de raid.",
348 ["Frames"] = "Cadres",
349 ["Options for the playertarget frames."] = "Options concernant les cadres des cibles des joueurs.",
350 ["Growup"] = "VersleHaut",
351 ["Toggle growup."] = "Ajoute ou non les PTs vers le haut.",
352 ["Inverse"] = "Inverser",
353 ["Toggle inverse healthbar."] = "Inverse ou non le sens de remplissage des barres de vie.",
354 ["Deficit"] = "D\195\169ficit",
355 ["Toggle deficit health."] = "Affiche ou non le d\195\169ficit en vie.",
356 --["Clickcast"] = true,
357 ["Toggle clickcast support."] = "Active ou non le support des addons de \"clickcasting\".",
358 --["Clicktarget"] = true,
359 ["Define clicktargets."] = "D\195\169termine la cible des clics.",
360 ["Define the clicktarget for player."] = "D\195\169termine la cible lors du clic sur le cadre du joueur.",
361 ["Define the clicktarget for target."] = "D\195\169termine la cible lors du clic sur le cadre de la cible.",
362 ["Define the clicktarget for targettarget."] = "D\195\169termine la cible lors du clic sur le cadre de la cible de la cible.",
363 ["Target"] = "Cible",
364 ["TargetTarget"] = "CibledelaCible",
365 ["Nr of Players shown."] = "Nombre de joueurs \195\160 afficher.",
366 ["Nr Players"] = "Nbre de joueurs",
367 ["Nr"] = "N\194\176",
368 ["Classcolor"] = "CouleurdeClasse",
369 ["Color healthbars by class."] = "Colore les barres de vie selon la classe.",
370 ["Enemycolor"] = "CouleurEnnemi",
371 ["Set the color for enemies. (used when classcolor is enabled)"] = "D\195\169termine la couleur pour les ennemis. (utilis\195\169 si CouleurdeClasse est activ\195\169)",
372 --["Coloraggro"] = true,
373 ["Color Aggro"] = "Couleur d'aggro",
374 ["Color aggro status for PTs on their names. Orange has target, Green is tanking, Red has no aggro."] = "Indique le statut de l'aggro des PTs selon la couleur de leurs noms. Orange s'ils ont la cible, Vert s'ils tankent, Rouge s'ils n'ont pas l'aggro.",
375 ["Backdrop"] = "Fond",
376 ["Toggle the backdrop."] = "Affiche ou non le fond.",
377 ["Highlight"] = "Surbrillance",
378 ["Toggle highlighting your target."] = "Met ou non en surbrillance votre cible.",
379 ["Reverse"] = "Inverser",
380 ["Toggle reverse order PT|PTT|PTTT or PTTT|PTT|PT."] = "Inverse ou non l'ordre d'affichage. (PT|PTT|PTTT ou PTTT|PTT|PT)",
381 ["Numbers"] = "Num\195\169ros",
382 ["Toggle showing of PT numbers."] = "Affiche ou non les num\195\169ros des PTs.",
383 ["Tooltips"] = "Infobulles",
384 ["Toggle showing of tooltips."] = "Affiche ou non les infobulles.",
385 ["Show"] = "Afficher",
386 ["Show player."] = "Affiche le joueur.",
387 ["Show target."] = "Affiche la cible.",
388 ["Show targettarget."] = "Affiche la cible de la cible.",
389 ["Define which frames you want to see."] = "D\195\169termine les cadres que vous souhaitez voir.",
390 ["Layout"] = "Style",
391 ["Set the layout for the PT frames."] = "D\195\169termine le style des cadres des PTs.",
392 --["Vertical"] = true,
393 --["Horizontal"] = true,
394  
395 --["set"] = true,
396 ["Set Player"] = "Ajouter un joueur",
397 ["Set a player."]= "Ajoute un joueur.",
398 ["<nr> <name>"] = "<n\194\176> <nom>",
399 ["<nr>"] = "<n\194\176>",
400 ["<name>"] = "<nom>",
401 ["Remove Player"] = "Enlever un joueur",
402 --["remove"] = true,
403 ["Remove a player."] = "Enl\195\168ve un joueur",
404 ["Removed player: "] = "Joueur enlev\195\169 : ",
405 ["Set player: "] = "Joueur ajout\195\169 : ",
406  
407 --["(%S+)%s*(.*)"] = true,
408  
409 ["<Not Assigned>"] = "<Non assign\195\169>",
410 } end )
411  
412 ----------------------------------
413 -- Module Declaration --
414 ----------------------------------
415  
416 oRAOPlayerTarget = oRA:NewModule(L["playertargetoptional"])
417 oRAOPlayerTarget.defaults = {
418 raidicon = true,
419 alpha = 1,
420 scale = 1,
421 growup = false,
422 inverse = false,
423 deficit = false,
424 clickcast = true,
425 ctplayer = L["Player"],
426 cttarget = L["Target"],
427 cttargettarget = L["TargetTarget"],
428 nrpts = 10,
429 classcolor = true,
430 enemycolor = "cc2200",
431 coloraggro = true,
432 backdrop = true,
433 highlight = true,
434 reverse = false,
435 numbers = true,
436 tooltips = true,
437 showpt = true,
438 showptt = true,
439 showpttt = true,
440 layout = L["Vertical"],
441 playertable = {},
442 }
443 oRAOPlayerTarget.optional = true
444 oRAOPlayerTarget.name = L["Optional/PlayerTarget"]
445 oRAOPlayerTarget.consoleCmd = L["pt"]
446 oRAOPlayerTarget.consoleOptions = {
447 type = "group",
448 desc = L["Options for the playertargets."],
449 name = L["PlayerTarget"],
450 args = {
451 [L["Nr"]] = {
452 type = "range",
453 name = L["Nr Players"],
454 desc = L["Nr of Players shown."],
455 get = function() return oRAOPlayerTarget.db.profile.nrpts end,
456 set = function(v) oRAOPlayerTarget:SetNrPlayers(v) end,
457 min = 0, max = 10, step = 1,
458 },
459 [L["set"]] = {
460 name = L["Set Player"], type = "group",
461 desc = L["Set a player."],
462 -- disabled = function() return not oRAOPlayerTarget:IsValidRequest(UnitName("player"), true) end,
463 disabled = function() return not oRA:IsModuleActive(oRAOPlayerTarget) end,
464 args = {
465 ["1"] = {
466 name = "1.", type = "text", desc = L["Set Player"].." 1",
467 get = function()
468 if oRAOPlayerTarget.db.profile.playertable[1] then return oRAOPlayerTarget.db.profile.playertable[1]
469 else return "" end
470 end,
471 set = function(v) oRAOPlayerTarget:Set(1, v) end,
472 validate = function(v) return string.find(v, "^(%S+)$") end,
473 usage = L["<name>"],
474 order = 1,
475 },
476 ["2"] = {
477 name = "2.", type = "text", desc = L["Set Player"].." 2",
478 get = function()
479 if oRAOPlayerTarget.db.profile.playertable[2] then return oRAOPlayerTarget.db.profile.playertable[2]
480 else return "" end
481 end,
482 set = function(v) oRAOPlayerTarget:Set(2, v) end,
483 validate = function(v) return string.find(v, "^(%S+)$") end,
484 usage = L["<name>"],
485 order = 2,
486 },
487 ["3"] = {
488 name = "3.", type = "text", desc = L["Set Player"].." 3",
489 get = function()
490 if oRAOPlayerTarget.db.profile.playertable[3] then return oRAOPlayerTarget.db.profile.playertable[3]
491 else return "" end
492 end,
493 set = function(v) oRAOPlayerTarget:Set(3, v) end,
494 validate = function(v) return string.find(v, "^(%S+)$") end,
495 usage = L["<name>"],
496 order = 3,
497 },
498 ["4"] = {
499 name = "4.", type = "text", desc = L["Set Player"].." 4",
500 get = function()
501 if oRAOPlayerTarget.db.profile.playertable[4] then return oRAOPlayerTarget.db.profile.playertable[4]
502 else return "" end
503 end,
504 set = function(v) oRAOPlayerTarget:Set(4, v) end,
505 validate = function(v) return string.find(v, "^(%S+)$") end,
506 usage = L["<name>"],
507 order = 4,
508 },
509 ["5"] = {
510 name = "5.", type = "text", desc = L["Set Player"].." 5",
511 get = function()
512 if oRAOPlayerTarget.db.profile.playertable[5] then return oRAOPlayerTarget.db.profile.playertable[5]
513 else return "" end
514 end,
515 set = function(v) oRAOPlayerTarget:Set(5, v) end,
516 validate = function(v) return string.find(v, "^(%S+)$") end,
517 usage = L["<name>"],
518 order = 5,
519 },
520 ["6"] = {
521 name = "6.", type = "text", desc = L["Set Player"].." 6",
522 get = function()
523 if oRAOPlayerTarget.db.profile.playertable[6] then return oRAOPlayerTarget.db.profile.playertable[6]
524 else return "" end
525 end,
526 set = function(v) oRAOPlayerTarget:Set(6, v) end,
527 validate = function(v) return string.find(v, "^(%S+)$") end,
528 usage = L["<name>"],
529 order = 6,
530 },
531 ["7"] = {
532 name = "7.", type = "text", desc = L["Set Player"].." 7",
533 get = function()
534 if oRAOPlayerTarget.db.profile.playertable[7] then return oRAOPlayerTarget.db.profile.playertable[7]
535 else return "" end
536 end,
537 set = function(v) oRAOPlayerTarget:Set(7, v) end,
538 validate = function(v) return string.find(v, "^(%S+)$") end,
539 usage = L["<name>"],
540 order = 7,
541 },
542 ["8"] = {
543 name = "8.", type = "text", desc = L["Set Player"].." 8",
544 get = function()
545 if oRAOPlayerTarget.db.profile.playertable[8] then return oRAOPlayerTarget.db.profile.playertable[8]
546 else return "" end
547 end,
548 set = function(v) oRAOPlayerTarget:Set(8, v) end,
549 validate = function(v) return string.find(v, "^(%S+)$") end,
550 usage = L["<name>"],
551 order = 8,
552 },
553 ["9"] = {
554 name = "9.", type = "text", desc = L["Set Player"].." 9",
555 get = function()
556 if oRAOPlayerTarget.db.profile.playertable[9] then return oRAOPlayerTarget.db.profile.playertable[9]
557 else return "" end
558 end,
559 set = function(v) oRAOPlayerTarget:Set(9, v) end,
560 validate = function(v) return string.find(v, "^(%S+)$") end,
561 usage = L["<name>"],
562 order = 9,
563 },
564 ["10"] = {
565 name = "10.", type = "text", desc = L["Set Player"].." 10",
566 get = function()
567 if oRAOPlayerTarget.db.profile.playertable[10] then return oRAOPlayerTarget.db.profile.playertable[10]
568 else return "" end
569 end,
570 set = function(v) oRAOPlayerTarget:Set(10, v) end,
571 validate = function(v) return string.find(v, "^(%S+)$") end,
572 usage = L["<name>"],
573 order = 10,
574 },
575 }
576 },
577 [L["remove"]] = {
578 name = L["Remove Player"], type = "group",
579 desc = L["Remove a player."],
580 -- disabled = function() return not oRAOPlayerTarget:IsValidRequest(UnitName("player"), true) end,
581 disabled = function() return not oRA:IsModuleActive(oRAOPlayerTarget) end,
582 args = {
583 ["1"] = {
584 name = "1.", type = "execute", desc = L["Remove Player"].." 1",
585 func = function() oRAOPlayerTarget:Remove("1") end,
586 disabled = function() return not oRAOPlayerTarget.db.profile.playertable[1] end,
587 order = 1,
588 },
589 ["2"] = {
590 name = "2.", type = "execute", desc = L["Remove Player"].." 2",
591 func = function() oRAOPlayerTarget:Remove("2") end,
592 disabled = function() return not oRAOPlayerTarget.db.profile.playertable[2] end,
593 order = 2,
594 },
595 ["3"] = {
596 name = "3.", type = "execute", desc = L["Remove Player"].." 3",
597 func = function() oRAOPlayerTarget:Remove("3") end,
598 disabled = function() return not oRAOPlayerTarget.db.profile.playertable[3] end,
599 order = 3,
600 },
601 ["4"] = {
602 name = "4.", type = "execute", desc = L["Remove Player"].." 4",
603 func = function() oRAOPlayerTarget:Remove("4") end,
604 disabled = function() return not oRAOPlayerTarget.db.profile.playertable[4] end,
605 order = 4,
606 },
607 ["5"] = {
608 name = "5.", type = "execute", desc = L["Remove Player"].." 5",
609 func = function() oRAOPlayerTarget:Remove("5") end,
610 disabled = function() return not oRAOPlayerTarget.db.profile.playertable[5] end,
611 order = 5,
612 },
613 ["6"] = {
614 name = "6.", type = "execute", desc = L["Remove Player"].." 6",
615 func = function() oRAOPlayerTarget:Remove("6") end,
616 disabled = function() return not oRAOPlayerTarget.db.profile.playertable[6] end,
617 order = 6,
618 },
619 ["7"] = {
620 name = "7.", type = "execute", desc = L["Remove Player"].." 7",
621 func = function() oRAOPlayerTarget:Remove("7") end,
622 disabled = function() return not oRAOPlayerTarget.db.profile.playertable[7] end,
623 order = 7,
624 },
625 ["8"] = {
626 name = "8.", type = "execute", desc = L["Remove Player"].." 8",
627 func = function() oRAOPlayerTarget:Remove("8") end,
628 disabled = function() return not oRAOPlayerTarget.db.profile.playertable[8] end,
629 order = 8,
630 },
631 ["9"] = {
632 name = "9.", type = "execute", desc = L["Remove Player"].." 9",
633 func = function() oRAOPlayerTarget:Remove("9") end,
634 disabled = function() return not oRAOPlayerTarget.db.profile.playertable[9] end,
635 order = 9,
636 },
637 ["10"] = {
638 name = "10.", type = "execute", desc = L["Remove Player"].." 10",
639 func = function() oRAOPlayerTarget:Remove("10") end,
640 disabled = function() return not oRAOPlayerTarget.db.profile.playertable[10] end,
641 order = 10,
642 },
643 }
644 },
645 [L["Frames"]] = {
646 type = "group",
647 desc = L["Options for the playertarget frames."],
648 name = L["Frames"],
649 args = {
650 [L["Classcolor"]] = {
651 type = "toggle",
652 name = L["Classcolor"],
653 desc = L["Color healthbars by class."],
654 get = function() return oRAOPlayerTarget.db.profile.classcolor end,
655 set = function(v) oRAOPlayerTarget:SetClassColor(v) end,
656 },
657 [L["Enemycolor"]] = {
658 type = "color",
659 name = L["Enemycolor"],
660 desc = L["Set the color for enemies. (used when classcolor is enabled)"],
661 get = function()
662 local _, r, g, b = paintchips:GetRGBPercent( oRAOPlayerTarget.db.profile.enemycolor )
663 return r, g, b
664 end,
665 set = function(r, g, b)
666 local hex = format("%02x%02x%02x", r*255, g*255, b*255)
667 paintchips:RegisterHex( hex )
668 oRAOPlayerTarget.db.profile.enemycolor = hex
669 end,
670 disabled = function() return not oRAOPlayerTarget.db.profile.classcolor end,
671 },
672 [L["Coloraggro"]] = {
673 type = "toggle",
674 name = L["Color Aggro"],
675 desc = L["Color aggro status for PTs on their names. Orange has target, Green is tanking, Red has no aggro."],
676 get = function() return oRAOPlayerTarget.db.profile.coloraggro end,
677 set = function(v) oRAOPlayerTarget.db.profile.coloraggro = v end,
678 },
679 [L["Backdrop"]] = {
680 type = "toggle",
681 name = L["Backdrop"],
682 desc = L["Toggle the backdrop."],
683 get = function() return oRAOPlayerTarget.db.profile.backdrop end,
684 set = function(v) oRAOPlayerTarget.db.profile.backdrop = v end,
685 },
686 [L["Highlight"]] = {
687 type = "toggle",
688 name = L["Highlight"],
689 desc = L["Toggle highlighting your target."],
690 get = function() return oRAOPlayerTarget.db.profile.highlight end,
691 set = function(v) oRAOPlayerTarget.db.profile.highlight = v end,
692 },
693  
694 [L["Scale"]] = {
695 type = "range",
696 name = L["Scale"],
697 desc = L["Set frame scale."],
698 get = function() return oRAOPlayerTarget.db.profile.scale end,
699 set = function(v) oRAOPlayerTarget:SetScale(v) end,
700 min = 0.1,
701 max = 2,
702 },
703  
704 [L["Alpha"]] = {
705 type = "range",
706 name = L["Alpha"],
707 desc = L["Set frame alpha."],
708 get = function() return oRAOPlayerTarget.db.profile.alpha end,
709 set = function(v) oRAOPlayerTarget:SetAlpha(v) end,
710 min = 0.1,
711 max = 1,
712 },
713  
714 [L["Raidicon"]] = {
715 type = "toggle",
716 name = L["Raidicon"],
717 desc = L["Toggle raid icons."],
718 get = function() return oRAOPlayerTarget.db.profile.raidicon end,
719 set = function(v) oRAOPlayerTarget:ToggleRaidIcon(v) end,
720 },
721  
722 [L["Growup"]] = {
723 type = "toggle",
724 name = L["Growup"],
725 desc = L["Toggle growup."],
726 get = function() return oRAOPlayerTarget.db.profile.growup end,
727 set = function(v) oRAOPlayerTarget:ToggleGrowup(v) end,
728 },
729  
730 [L["Inverse"]] = {
731 type = "toggle",
732 name = L["Inverse"],
733 desc = L["Toggle inverse healthbar."],
734 get = function() return oRAOPlayerTarget.db.profile.inverse end,
735 set = function(v) oRAOPlayerTarget:ToggleInverse(v) end,
736 },
737 [L["Reverse"]] = {
738 type = "toggle",
739 name = L["Reverse"],
740 desc = L["Toggle reverse order PT|PTT|PTTT or PTTT|PTT|PT."],
741 get = function() return oRAOPlayerTarget.db.profile.reverse end,
742 set = function(v) oRAOPlayerTarget:ToggleReverse(v) end,
743 },
744 [L["Numbers"]] = {
745 type = "toggle",
746 name = L["Numbers"],
747 desc = L["Toggle showing of PT numbers."],
748 get = function() return oRAOPlayerTarget.db.profile.numbers end,
749 set = function(v) oRAOPlayerTarget:ToggleNumbers(v) end,
750 },
751 [L["Tooltips"]] = {
752 type = "toggle",
753 name = L["Tooltips"],
754 desc = L["Toggle showing of tooltips."],
755 get = function() return oRAOPlayerTarget.db.profile.tooltips end,
756 set = function(v) oRAOPlayerTarget.db.profile.tooltips = v end,
757 },
758 [L["Deficit"]] = {
759 type = "toggle",
760 name = L["Deficit"],
761 desc = L["Toggle deficit health."],
762 get = function() return oRAOPlayerTarget.db.profile.deficit end,
763 set = function(v) oRAOPlayerTarget:ToggleDeficit(v) end,
764 },
765  
766 [L["Clickcast"]] = {
767 type = "toggle",
768 name = L["Clickcast"],
769 desc = L["Toggle clickcast support."],
770 get = function() return oRAOPlayerTarget.db.profile.clickcast end,
771 set = function(v) oRAOPlayerTarget.db.profile.clickcast = v end,
772 },
773 [L["Layout"]] = {
774 type = "text",
775 name = L["Layout"],
776 desc = L["Set the layout for the PT frames."],
777 get = function() return oRAOPlayerTarget.db.profile.layout end,
778 set = function(v) oRAOPlayerTarget:SetLayout(v) end,
779 validate = {L["Vertical"], L["Horizontal"]}
780 },
781 [L["Clicktarget"]] = {
782 type = "group", name = L["Clicktarget"], desc = L["Define clicktargets."],
783 args = {
784 [L["Player"]] = {
785 name = L["Player"], type = "text", desc = L["Define the clicktarget for player."],
786 get = function() return oRAOPlayerTarget.db.profile.ctplayer end,
787 set = function(v) oRAOPlayerTarget.db.profile.ctplayer = v end,
788 validate = { L["Player"], L["Target"], L["TargetTarget"] }
789 },
790 [L["Target"]] = {
791 name = L["Target"], type = "text", desc = L["Define the clicktarget for target."],
792 get = function() return oRAOPlayerTarget.db.profile.cttarget end,
793 set = function(v) oRAOPlayerTarget.db.profile.cttarget = v end,
794 validate = { L["Player"], L["Target"], L["TargetTarget"] }
795 },
796 [L["TargetTarget"]] = {
797 name = L["TargetTarget"], type = "text", desc = L["Define the clicktarget for targettarget."],
798 get = function() return oRAOPlayerTarget.db.profile.cttargettarget end,
799 set = function(v) oRAOPlayerTarget.db.profile.cttargettarget = v end,
800 validate = { L["Player"], L["Target"], L["TargetTarget"] }
801 },
802 },
803 },
804 [L["Show"]] = {
805 type = "group", name = L["Show"], desc = L["Define which frames you want to see."],
806 args = {
807 [L["Player"]] = {
808 name = L["Player"], type = "toggle", desc = L["Show player."],
809 get = function() return oRAOPlayerTarget.db.profile.showpt end,
810 set = function(v)
811 oRAOPlayerTarget.db.profile.showpt = v
812 oRAOPlayerTarget:UpdateFrameShow()
813 end,
814 },
815 [L["Target"]] = {
816 name = L["Target"], type = "toggle", desc = L["Show target."],
817 get = function() return oRAOPlayerTarget.db.profile.showptt end,
818 set = function(v)
819 oRAOPlayerTarget.db.profile.showptt = v
820 oRAOPlayerTarget:UpdateFrameShow()
821 end,
822 },
823 [L["TargetTarget"]] = {
824 name = L["TargetTarget"], type = "toggle", desc = L["Show targettarget."],
825 get = function() return oRAOPlayerTarget.db.profile.showpttt end,
826 set = function(v)
827 oRAOPlayerTarget.db.profile.showpttt = v
828 oRAOPlayerTarget:UpdateFrameShow()
829 end,
830 },
831 },
832 },
833  
834 },
835 },
836 }
837 }
838  
839  
840 ------------------------------
841 -- Initialization --
842 ------------------------------
843  
844 function oRAOPlayerTarget:OnEnable()
845 self.ptf = {}
846 self.pttf = {}
847 self.ptttf = {}
848 self.enabled = nil
849  
850 if not self.db.profile.playertable then self.db.profile.playertable = {} end
851  
852 paintchips:RegisterHex(self.db.profile.enemycolor or "cc2200" )
853  
854 self:SetupFrames()
855  
856 self:RegisterEvent("oRA_LeftRaid")
857 self:RegisterEvent("oRA_JoinedRaid")
858 self:RegisterEvent("RosterLib_RosterChanged", function() self:oRA_PlayerTargetUpdate() end)
859  
860 self:RegisterEvent("oRA_BarTexture")
861  
862 -- Check for Watchdog
863 if (WatchDog_OnClick) then
864 oRA_PlayerTargetFramesCustomClick = WatchDog_OnClick
865 end
866 end
867  
868  
869 function oRAOPlayerTarget:OnDisable()
870 self:UnregisterAllEvents()
871 end
872  
873  
874  
875 ------------------------------
876 -- Event Handlers --
877 ------------------------------
878  
879 function oRAOPlayerTarget:oRA_LeftRaid()
880 self.enabled = nil
881 self.mainframe:Hide()
882 end
883  
884 function oRAOPlayerTarget:oRA_JoinedRaid()
885 if not self.enabled then
886 self.enabled = true
887 self:oRA_PlayerTargetUpdate()
888 end
889 end
890  
891  
892 function oRAOPlayerTarget:oRA_PlayerTargetUpdate()
893  
894 if not self.db.profile.playertable then return end
895 if not self.enabled then return end
896  
897 self:UpdateConsole()
898  
899 local showpt, unitid
900  
901 for i = 1, self.db.profile.nrpts do
902 unitid = roster:GetUnitIDFromName(self.db.profile.playertable[i])
903  
904 if unitid then
905 if self.db.profile.showpt then
906 if not self.ptf[i] then self.ptf[i] = self:CreateUnitFrame( self.mainframe, i, "pt" ) end
907 self.ptf[i].unit = unitid
908 end
909 if self.db.profile.showptt then
910 if not self.pttf[i] then self.pttf[i] = self:CreateUnitFrame( self.mainframe, i, "ptt" ) end
911 self.pttf[i].unit = unitid
912 end
913  
914 if self.db.profile.showpttt then
915 if not self.ptttf[i] then self.ptttf[i] = self:CreateUnitFrame( self.mainframe, i, "pttt" ) end
916 self.ptttf[i].unit = unitid
917 end
918  
919 showpt = true
920  
921 else -- unit nolonger in the raid or unknown
922 if self.ptf[i] then self.ptf[i].unit = nil end
923 if self.pttf[i] then self.pttf[i].unit = nil end
924 if self.ptttf[i] then self.ptttf[i].unit = nil end
925 end
926 end
927  
928  
929 if showpt then
930 self.mainframe:Show()
931 else
932 self.mainframe:Hide()
933 end
934 end
935  
936 function oRAOPlayerTarget:oRA_BarTexture( texture )
937 for _, f in pairs({ self.ptf, self.pttf, self.ptttf }) do
938 for _, f in pairs(f) do
939 f.bar:SetStatusBarTexture(self.core.bartextures[texture])
940 f.bar.texture:SetTexture(self.core.bartextures[texture])
941 end
942 end
943 end
944  
945 ------------------------------
946 -- ConsoleOption Functions --
947 ------------------------------
948  
949 function oRAOPlayerTarget:SetScale(scale)
950 self.db.profile.scale = scale
951  
952 if self.mainframe then
953 self.mainframe:SetScale(scale)
954 end
955 self:RestorePosition()
956 end
957  
958  
959 function oRAOPlayerTarget:SetAlpha(alpha)
960 self.db.profile.alpha = alpha
961  
962 if self.mainframe then
963 self.mainframe:SetAlpha(alpha)
964 end
965 end
966  
967 function oRAOPlayerTarget:SetClassColor(state)
968 self.db.profile.classcolor = state
969 if self.ptf then
970 for _, f in pairs(self.ptf) do
971 self:UpdateHealthBar(f.bar, self:GetUnit(f))
972 end
973 end
974 if self.pttf then
975 for _, f in pairs(self.pttf) do
976 self:UpdateHealthBar(f.bar, self:GetUnit(f))
977 end
978 end
979 if self.ptttf then
980 for _, f in pairs(self.ptttf) do
981 self:UpdateHealthBar(f.bar, self:GetUnit(f))
982 end
983 end
984 end
985  
986  
987 function oRAOPlayerTarget:UpdateFrameShow()
988 for _, f in pairs({self.ptf, self.pttf, self.ptttf}) do
989 if f then
990 for _, f in pairs(f) do
991 if f then
992 self:SetStyle(f)
993 if f.type == "pt" then
994 if self.db.profile.showpt then f:Show() else f:Hide() end
995 elseif f.type == "ptt" then
996 if self.db.profile.showptt then f:Show() else f:Hide() end
997 else
998 if self.db.profile.showpttt then f:Show() else f:Hide() end
999 end
1000 end
1001 end
1002 end
1003 end
1004 self:ToggleNumbers(self.db.profile.numbers)
1005 end
1006  
1007  
1008 function oRAOPlayerTarget:ToggleRaidIcon(state)
1009 self.db.profile.raidicon = state
1010  
1011 if state then return end
1012  
1013 for _, f in pairs({ self.ptf, self.pttf, self.ptttf }) do
1014 if f then
1015 for _, f in pairs(f) do
1016 if f then f.raidicon:Hide() end
1017 end
1018 end
1019 end
1020 end
1021  
1022 function oRAOPlayerTarget:ToggleNumbers(state)
1023 self.db.profile.numbers = state
1024  
1025 local ff = self.ptttf
1026  
1027 if self.db.profile.showptt then ff = self.pttf end
1028 if self.db.profile.showpt then ff = self.ptf end
1029  
1030 if not ff then return end
1031  
1032 for _, f in pairs(ff) do
1033 if state and f.number then
1034 f.number:Show()
1035 elseif f.number then
1036 f.number:Hide()
1037 end
1038 end
1039 end
1040  
1041 function oRAOPlayerTarget:SetLayout(state)
1042 self.db.profile.layout = state
1043 for _, f in pairs({self.ptf, self.pttf, self.ptttf}) do
1044 if f then
1045 for _, f in pairs(f) do
1046 if f then self:SetStyle(f) end
1047 end
1048 end
1049 end
1050 end
1051  
1052  
1053 function oRAOPlayerTarget:ToggleGrowup(state)
1054 self.db.profile.growup = state
1055 for _, f in pairs({self.ptf, self.pttf, self.ptttf}) do
1056 if f then
1057 for _, f in pairs(f) do
1058 if f then self:SetStyle(f) end
1059 end
1060 end
1061 end
1062 end
1063  
1064 function oRAOPlayerTarget:ToggleInverse(state)
1065 self.db.profile.inverse = state
1066 end
1067  
1068 function oRAOPlayerTarget:ToggleReverse(state)
1069 self.db.profile.reverse = state
1070  
1071 for _, f in pairs({self.ptf, self.pttf, self.ptttf}) do
1072 if f then
1073 for _, f in pairs(f) do
1074 if f then self:SetStyle(f) end
1075 end
1076 end
1077 end
1078 end
1079  
1080 function oRAOPlayerTarget:ToggleDeficit(state)
1081 self.db.profile.deficit = state
1082  
1083 for _, f in pairs({self.ptf, self.pttf, self.ptttf}) do
1084 if f then
1085 for _, f in pairs(f) do
1086 if f then self:UpdateHealthBar(f.bar, self:GetUnit(f)) end
1087 end
1088 end
1089 end
1090  
1091 end
1092  
1093 function oRAOPlayerTarget:SetNrPlayers( nr )
1094 self.db.profile.nrpts = nr
1095  
1096 for i = ( nr + 1 ), 10 do
1097 if self.ptf and self.ptf[i] then self.ptf[i].unit = nil end
1098 if self.pttf and self.pttf[i] then self.pttf[i].unit = nil end
1099 if self.ptttf and self.ptttf[i] then self.ptttf[i].unit = nil end
1100 end
1101  
1102 -- Make sure to update the tablet in case it's detached.
1103 self:TriggerEvent("oRA_UpdateConfigGUI")
1104 self:oRA_PlayerTargetUpdate()
1105 end
1106  
1107 ------------------------------
1108 -- Utility Functions --
1109 ------------------------------
1110  
1111 function oRAOPlayerTarget:SavePosition()
1112 local f = self.mainframe
1113 if not f then return end
1114  
1115 local s = f:GetEffectiveScale()
1116  
1117 self.db.profile.posx = f:GetLeft() * s
1118 self.db.profile.posy = f:GetTop() * s
1119 end
1120  
1121  
1122 function oRAOPlayerTarget:RestorePosition()
1123 local x = self.db.profile.posx
1124 local y = self.db.profile.posy
1125  
1126 if not x or not y then return end
1127  
1128 local f = self.mainframe
1129 if not f then return end
1130 local s = f:GetEffectiveScale()
1131  
1132 f:ClearAllPoints()
1133 f:SetPoint("TOPLEFT", UIParent, "BOTTOMLEFT", x / s, y / s)
1134 end
1135  
1136  
1137 function oRAOPlayerTarget:SetupFrames()
1138 local f = CreateFrame("Frame", nil, UIParent)
1139 f:Hide()
1140 f:SetMovable(true)
1141 f:SetScript("OnUpdate", function() self:OnUpdate() end)
1142 f:SetWidth(100)
1143 f:SetHeight(100)
1144 f:SetPoint("CENTER", UIParent, "CENTER", 0, 0)
1145 f:SetAlpha(self.db.profile.alpha)
1146 f:SetScale(self.db.profile.scale)
1147  
1148 f.update = 0
1149  
1150 self.mainframe = f
1151 self:RestorePosition()
1152 end
1153  
1154  
1155 function oRAOPlayerTarget:CreateUnitFrame( parent, id, type )
1156 -- Main frame
1157 -- local f = CreateFrame("Button", "oRA_PlayerTargetFrames_" .. type .. id, parent)
1158 local f = CreateFrame("Button", nil, parent)
1159 f:Hide()
1160 f:EnableMouse(true)
1161 f:SetMovable(true)
1162 f:RegisterForClicks("LeftButtonUp", "RightButtonUp", "MiddleButtonUp", "Button4Up", "Button5Up")
1163 f:RegisterForDrag("LeftButton")
1164 f:SetScript("OnEnter", function() self:OnEnter() end)
1165 f:SetScript("OnLeave", function() GameTooltip:Hide() end)
1166 f:SetScript("OnClick", function() self:OnClick() end)
1167 f:SetScript("OnDragStart", function() if IsAltKeyDown() then parent:StartMoving() end end)
1168 f:SetScript("OnDragStop", function() parent:StopMovingOrSizing() self:SavePosition() end)
1169  
1170 -- Tank Statusbar
1171 f.bar = CreateFrame("StatusBar", nil, f)
1172 f.bar:SetMinMaxValues(0,100)
1173  
1174 -- Tank Statusbar background texture, visible when the bar depleats
1175 f.bar.texture = f.bar:CreateTexture(nil, "BORDER")
1176 f.bar.texture:SetVertexColor(1, 0, 0, 0.5)
1177  
1178 -- Tank Statusbar text
1179 f.bar.text = f.bar:CreateFontString(nil, "OVERLAY")
1180 f.bar.text:SetFontObject(GameFontHighlightSmall)
1181 f.bar.text:SetJustifyH("RIGHT")
1182  
1183 -- Tank Number
1184 f.number = f.bar:CreateFontString(nil, "OVERLAY")
1185 f.number:SetFontObject(GameFontHighlightSmall)
1186 f.number:SetJustifyH("RIGHT")
1187  
1188 -- Tank Name
1189 f.name = f.bar:CreateFontString(nil, "OVERLAY")
1190 f.name:SetFontObject(GameFontHighlightSmall)
1191 f.name:SetJustifyH("LEFT")
1192  
1193 -- Raid Icons
1194 f.raidicon = f.bar:CreateTexture(nil, "OVERLAY")
1195 f.raidicon:SetTexture("Interface\\TargetingFrame\\UI-RaidTargetingIcons")
1196 f.raidicon:Hide()
1197  
1198 -- Set static stuff and style
1199 f.number:SetText(id..".")
1200 f.type = type
1201 f:SetID(id)
1202  
1203 self:SetStyle(f)
1204  
1205 return f
1206 end
1207  
1208 function oRAOPlayerTarget:GetPosition( f )
1209 local relframe, relx, rely
1210  
1211 if self.db.profile.layout == L["Horizontal"] then -- HORIZONTAL POSITIONING
1212 -- default positioning
1213 relframe = self.mainframe
1214 relx = 136 * (f:GetID() - 1)
1215 if self.db.profile.reverse then relx = relx * -1 end
1216 rely = 0
1217  
1218 if f.type == "ptt" and self.db.profile.showpt then
1219 relframe = self.ptf[f:GetID()]
1220 relx = 0
1221 rely = -21
1222 if self.db.profile.growup then rely = 21 end
1223 end
1224  
1225 -- same deal for pttt adjust if ptt or pt is shown
1226 if f.type == "pttt" then
1227 if self.db.profile.showptt then
1228 relframe = self.pttf[f:GetID()]
1229 relx = 0
1230 rely = -21
1231 if self.db.profile.growup then rely = 21 end
1232 elseif self.db.profile.showpt then
1233 relframe = self.ptf[f:GetID()]
1234 relx = 0
1235 rely = -21
1236 if self.db.profile.growup then rely = 21 end
1237 end
1238 end
1239  
1240 else -- VERTICAL POSITIONING
1241 -- default positioning
1242 relframe = self.mainframe
1243 relx = 0
1244 if self.db.profile.growup then
1245 rely = 21 * (f:GetID() - 1)
1246 else
1247 rely = -21 * (f:GetID() - 1)
1248 end
1249  
1250 -- adjust positioning for ptt if pt is shown
1251 if f.type == "ptt" and self.db.profile.showpt then
1252 relframe = self.ptf[f:GetID()]
1253 relx = 120
1254 if self.db.profile.reverse then relx = -120 end
1255 rely = 0
1256 end
1257  
1258 -- same deal for pttt adjust if ptt or pt is shown
1259 if f.type == "pttt" then
1260 if self.db.profile.showptt then
1261 relframe = self.pttf[f:GetID()]
1262 relx = 120
1263 if self.db.profile.reverse then relx = -120 end
1264 rely = 0
1265 elseif self.db.profile.showpt then
1266 relframe = self.ptf[f:GetID()]
1267 relx = 120
1268 if self.db.profile.reverse then relx = -120 end
1269 rely = 0
1270 end
1271 end
1272 end
1273 return relframe, relx, rely
1274 end
1275  
1276  
1277 function oRAOPlayerTarget:SetStyle(f)
1278 local relframe, relx, rely = self:GetPosition(f)
1279  
1280 self:SetWHP(f, 120, 21, "TOPLEFT", relframe, "TOPLEFT", relx , rely)
1281  
1282 f:SetBackdrop({ bgFile = "Interface\\Tooltips\\UI-Tooltip-Background", tile = true, tileSize = 16})
1283  
1284 if self.db.profile.backdrop then
1285 f:SetBackdropColor(0, 0, 0, .5)
1286 else
1287 f:SetBackdropColor(0, 0, 0, 0)
1288 end
1289  
1290 f.bar:SetStatusBarTexture(self.core.bartextures[self.core.db.profile.bartexture])
1291 f.bar.texture:SetTexture(self.core.bartextures[self.core.db.profile.bartexture])
1292 f.bar.texture:SetVertexColor(.5, .5, .5, .5)
1293  
1294 self:SetWHP(f.bar, 112, 16, "LEFT", f, "LEFT", 4, 0)
1295 self:SetWHP(f.bar.texture, 112, 16, "CENTER", f.bar, "CENTER", 0, 0)
1296 if self.db.profile.reverse then
1297 f.number:SetJustifyH("LEFT")
1298 else
1299 f.number:SetJustifyH("RIGHT")
1300 end
1301  
1302 self:SetWHP(f.number, 32, 14, self.db.profile.reverse and "LEFT" or "RIGHT", f, self.db.profile.reverse and "RIGHT" or "LEFT", 0, 0)
1303  
1304 if not self.db.profile.numbers then
1305 f.number:Hide()
1306 else
1307 if f.type == "pt" and self.db.profile.showpt then
1308 f.number:Show()
1309 elseif f.type == "ptt" and not self.db.profile.showpt and self.db.profile.showptt then
1310 f.number:Show()
1311 elseif f.type == "pttt" and not self.db.profile.showpt and not self.db.profile.showptt and self.db.profile.showpttt then
1312 f.number:Show()
1313 else
1314 f.number:Hide()
1315 end
1316 end
1317  
1318 self:SetWHP(f.raidicon, 14, 14, "LEFT", f.bar, "LEFT", 1, 0)
1319 self:SetWHP(f.name, 62, 14, "LEFT", f.bar, "LEFT", 18, 0)
1320 self:SetWHP(f.bar.text, 32, 14, "RIGHT", f.bar, "RIGHT", 0, 0)
1321  
1322 end
1323  
1324  
1325 function oRAOPlayerTarget:SetWHP(f, width, height, p1, relative, p2, x, y)
1326 if not f then return end
1327  
1328 f:SetWidth(width)
1329 f:SetHeight(height)
1330  
1331 if p1 then
1332 f:ClearAllPoints()
1333 f:SetPoint(p1, relative, p2, x, y)
1334 end
1335 end
1336  
1337  
1338 function oRAOPlayerTarget:GetUnit(f, click)
1339 if not f or not f.type then return end
1340  
1341 if not click then
1342 if f.type == "pt" then return f.unit end
1343 if f.type == "ptt" then return f.unit .. "target" end
1344 if f.type == "pttt" then return f.unit .. "targettarget" end
1345 else
1346 local c
1347 if f.type == "pt" then c = self.db.profile.ctplayer end
1348 if f.type == "ptt" then c = self.db.profile.cttarget end
1349 if f.type == "pttt" then c = self.db.profile.cttargettarget end
1350 if c == L["Player"] then return f.unit end
1351 if c == L["Target"] then return f.unit .. "target" end
1352 if c == L["TargetTarget"] then return f.unit .. "targettarget" end
1353 end
1354 end
1355  
1356  
1357 function oRAOPlayerTarget:UpdateFrames(f)
1358 for _, f in pairs(f) do
1359 if f.unit then
1360 local unit = self:GetUnit(f)
1361  
1362 if UnitExists(unit) then
1363 f.name:SetText(UnitName(unit))
1364  
1365 self:UpdateHealthBar(f.bar, unit)
1366  
1367 if self.db.profile.raidicon then
1368 self:UpdateRaidIcon(f, unit)
1369 end
1370  
1371 if f.type == "pt" and self.db.profile.coloraggro then
1372 if UnitExists( unit .. "target" ) then
1373 f.name:SetTextColor( 1, 0.5, 0.25, 1 )
1374 if UnitExists( unit .. "targettarget") then
1375 if UnitIsUnit(unit, unit .. "targettarget") then
1376 f.name:SetTextColor(0.5, 1, 0.5, 1)
1377 else
1378 f.name:SetTextColor(1, 0, 0, 1)
1379 end
1380 end
1381 else
1382 f.name:SetTextColor( 1, 1, 1, 1)
1383 end
1384 else
1385 if UnitIsEnemy(unit, "player") then f.name:SetTextColor( 1, 0, 0, 1)
1386 else f.name:SetTextColor( 1, 1, 1, 1) end
1387 end
1388  
1389 if UnitIsUnit( unit, "target") and self.db.profile.highlight then
1390 f:SetBackdropColor(1, .84, 0, 1 )
1391 elseif self.db.profile.backdrop then
1392 f:SetBackdropColor(0, 0, 0, .5)
1393 else
1394 f:SetBackdropColor(0, 0, 0, 0)
1395 end
1396  
1397 f:Show()
1398 else
1399 f:Hide()
1400 end
1401  
1402 else
1403 f:Hide()
1404 end
1405 end
1406 end
1407  
1408  
1409 function oRAOPlayerTarget:UpdateHealthBar(bar, unit)
1410 if not unit then return end
1411 local cur, max = UnitHealth(unit) or 0, UnitHealthMax(unit) or 0
1412 local perc = cur / max
1413  
1414 bar:SetMinMaxValues(0, max)
1415  
1416 if self.db.profile.inverse then
1417 bar:SetValue(max - cur)
1418 else
1419 bar:SetValue(cur)
1420 end
1421  
1422 if self.db.profile.classcolor then
1423 if not UnitIsEnemy(unit, "player") then
1424 local _, class = UnitClass( unit )
1425 local _, r,g,b = paintchips:GetRGBPercent( class )
1426 bar:SetStatusBarColor(r,g,b)
1427 else
1428 local _, r,g,b = paintchips:GetRGBPercent( self.db.profile.enemycolor )
1429 bar:SetStatusBarColor(r,g,b)
1430 end
1431 else
1432 bar:SetStatusBarColor(self:GetHealthBarColor(perc))
1433 end
1434  
1435 if self.db.profile.deficit then
1436 local val = max - cur
1437 if val > 1000 then
1438 val = ceil(val/100)/10 .. "k"
1439 elseif val == 0 then
1440 val = ""
1441 end
1442  
1443 bar.text:SetText(val)
1444 else
1445 bar.text:SetText(ceil(perc * 100) .. "%")
1446 end
1447  
1448 bar:Show()
1449 end
1450  
1451  
1452 function oRAOPlayerTarget:GetHealthBarColor(perc)
1453 local r, g
1454  
1455 if perc > 0.5 then
1456 r = (1.0 - perc) * 2
1457 g = 1.0
1458 else
1459 r = 1.0
1460 g = perc * 2
1461 end
1462  
1463 return r, g, 0
1464 end
1465  
1466  
1467 function oRAOPlayerTarget:UpdateRaidIcon(f, unit)
1468 local icon = GetRaidTargetIndex(unit)
1469  
1470 if icon then
1471 SetRaidTargetIconTexture(f.raidicon, icon)
1472 f.raidicon:Show()
1473 else
1474 f.raidicon:Hide()
1475 end
1476 end
1477  
1478 -------------------------------
1479 -- Key Binding Handlers --
1480 -------------------------------
1481  
1482 function oRAOPlayerTarget:BindingAssist( nr )
1483 if self.ptf and self.ptf[nr] and self.ptf[nr].unit then
1484 local unit = self:GetUnit( self.ptf[nr] )
1485 if unit and UnitExists( unit .."target") then
1486 AssistUnit(unit)
1487 end
1488 end
1489 end
1490  
1491 function oRAOPlayerTarget:BindingTarget( nr )
1492 if self.ptf and self.ptf[nr] and self.ptf[nr].unit then
1493 local unit = self:GetUnit( self.ptf[nr] )
1494 if unit then
1495 TargetUnit(unit)
1496 end
1497 end
1498 end
1499  
1500 -------------------------------
1501 -- Frame Script Functions --
1502 -------------------------------
1503  
1504 function oRAOPlayerTarget:OnUpdate()
1505 this.update = this.update + arg1
1506  
1507 if this.update >= 0.3 then
1508 if self.db.profile.showpt then self:UpdateFrames(self.ptf) end
1509 if self.db.profile.showptt then self:UpdateFrames(self.pttf) end
1510 if self.db.profile.showpttt then self:UpdateFrames(self.ptttf) end
1511  
1512 this.update = 0
1513 end
1514 end
1515  
1516  
1517 function oRAOPlayerTarget:OnEnter()
1518 if not self.db.profile.tooltips then return end
1519 local unit = self:GetUnit(this)
1520  
1521 GameTooltip_SetDefaultAnchor(GameTooltip, this)
1522  
1523 if unit and GameTooltip:SetUnit(unit) then
1524 this.updateTooltip = TOOLTIP_UPDATE_TIME
1525 else
1526 this.updateTooltip = nil
1527 end
1528 end
1529  
1530  
1531 function oRAOPlayerTarget:OnClick()
1532 local unit = self:GetUnit(this,true)
1533 if self.db.profile.clickcast and oRA_PlayerTargetFramesCustomClick then
1534 oRA_PlayerTargetFramesCustomClick(arg1, unit)
1535 elseif UnitExists(unit) then
1536 TargetUnit(unit)
1537 end
1538 -- this following piece of code is specifically for attack on assist.
1539 -- if unit == this.unit .. "target" and UnitExists( this.unit ) then
1540 -- AssistUnit("player")
1541 -- end
1542  
1543 end
1544  
1545 ---------------------------
1546 -- Setting and Removing --
1547 ---------------------------
1548  
1549  
1550 function oRAOPlayerTarget:Set( num, name )
1551 if not num then return end
1552 if not name or name == "" then name = UnitName("target") end
1553  
1554 -- lower the name and upper the first letter, not for chinese and korean though
1555 if GetLocale() ~= "zhTW" and GetLocale() ~= "zhCN" and GetLocale() ~= "koKR" then
1556 local _, len = string.find(name, "[%z\1-\127\194-\244][\128-\191]*")
1557 name = string.upper(string.sub(name, 1, len)) .. string.lower(string.sub(name, len + 1))
1558 end
1559  
1560 if not self:IsValidRequest(name, true) then return end
1561  
1562 for k,v in pairs( self.db.profile.playertable ) do
1563 if v == name then self.db.profile.playertable[k] = nil end
1564 end
1565  
1566 self.db.profile.playertable[num] = name
1567 self:UpdateConsole()
1568 self:oRA_PlayerTargetUpdate()
1569  
1570 self:Print(L["Set player: "] .. "[".. num .. "] [" .. name .."]")
1571 end
1572  
1573 function oRAOPlayerTarget:Remove( num )
1574 if not num then return end
1575 num = tonumber(num)
1576 local name = self.db.profile.playertable[num]
1577 if not name then return end
1578 self.db.profile.playertable[num] = nil
1579 self:UpdateConsole()
1580 self:oRA_PlayerTargetUpdate()
1581 self:Print(L["Removed player: "] .. num .." "..name )
1582 end
1583  
1584 function oRAOPlayerTarget:TooltipClick( num )
1585 if not num then return end
1586 num = tonumber(num)
1587 local name = UnitName("target")
1588 if self.db.profile.playertable[num] then
1589 if not name then self:Remove(num)
1590 else self:Set( num, name ) end
1591 else
1592 if name then self:Set( num, name ) end
1593 end
1594 end
1595  
1596 function oRAOPlayerTarget:UpdateConsole()
1597 for k = 1, 10, 1 do
1598 self.core.consoleOptions.args[L["pt"]].args[L["remove"]].args[tostring(k)].name = tostring(k).."."
1599 self.core.consoleOptions.args[L["pt"]].args[L["set"]].args[tostring(k)].name = tostring(k).."."
1600 end
1601 for k,v in pairs(self.db.profile.playertable) do
1602 if self:IsValidRequest(v,true) then
1603 self.core.consoleOptions.args[L["pt"]].args[L["remove"]].args[tostring(k)].name = tostring(k)..". "..v
1604 self.core.consoleOptions.args[L["pt"]].args[L["set"]].args[tostring(k)].name = tostring(k)..". "..v
1605 end
1606 end
1607 end
1608  
1609 ------------------------------
1610 -- Tooltip Updating --
1611 ------------------------------
1612  
1613 function oRAOPlayerTarget:OnTooltipUpdate()
1614 local cat = tablet:AddCategory("columns", 2, "text", "#", "justify", "LEFT", "text2", L["PlayerTarget"], "justify2", "LEFT", "child_justify", "LEFT", "child_justify2", "LEFT" )
1615 local p
1616 for k = 1, self.db.profile.nrpts, 1 do
1617 p = self.db.profile.playertable[k]
1618 if p then
1619 if self:IsValidRequest( p, true ) then
1620 local unit = self.core.roster:GetUnitIDFromName(p)
1621 local _, class = UnitClass( unit )
1622 cat:AddLine( "text", tostring(k)..". ", "text2", "|cff"..paintchips:GetHex(class) .. p.."|r", "func", self.TooltipClick, "arg1", self, "arg2", k)
1623 else
1624 cat:AddLine( "text", tostring(k)..". ", "text2", "|cffcccccc<"..p..">|r", "func", self.TooltipClick, "arg1", self, "arg2", k)
1625 end
1626 else
1627 cat:AddLine( "text", tostring(k)..". ", "text2", "|cffcccccc"..L["<Not Assigned>"].."|r", "func", self.TooltipClick, "arg1", self, "arg2", k)
1628 end
1629 end
1630 end
1631