-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCore.lua
More file actions
712 lines (594 loc) · 21.9 KB
/
Core.lua
File metadata and controls
712 lines (594 loc) · 21.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
------------------------------
-- Are you local? --
------------------------------
local L = AceLibrary("AceLocale-2.2"):new("oRA")
local CTRAversion = "1.541"
local waterfall = AceLibrary("Waterfall-1.0")
local surface = AceLibrary("Surface-1.0")
surface:Register("Otravi", "Interface\\AddOns\\oRA2\\Textures\\otravi")
surface:Register("Smooth", "Interface\\AddOns\\oRA2\\Textures\\smooth")
surface:Register("Smudge", "Interface\\AddOns\\oRA2\\Textures\\smudge")
surface:Register("Charcoal", "Interface\\AddOns\\oRA2\\textures\\charcoal")
surface:Register("BantoBar", "Interface\\AddOns\\oRA2\\textures\\bantobar")
surface:Register("Perl", "Interface\\AddOns\\oRA2\\textures\\perl")
surface:Register("Striped", "Interface\\AddOns\\oRA2\\textures\\striped")
surface:Register("glaze", "Interface\\AddOns\\oRA2\\Textures\\glaze" )
surface:Register("litestep", "Interface\\AddOns\\oRA2\\Textures\\litestep")
----------------------------
-- Localization --
----------------------------
L:RegisterTranslations("enUS", function() return {
["You are now AFK"] = true,
["You are now DND"] = true,
["You have to be Raid Leader or Assistant to do that."] = true,
["Requested a status update."] = true,
["useshorthands"] = true,
["Use shorthands"] = true,
["Toggle using of CTRA shorthands"] = true,
[" ...hic!"] = true,
["status"] = true,
["Request status"] = true,
["Request a status update"] = true,
["Textures"] = true,
["Set all statusbar textures."] = true,
["debug"] = true,
["Debugging"] = true,
["Show debug messages."] = true,
} end)
L:RegisterTranslations("ruRU", function() return {
["You are now AFK"] = "Вы временно отсутствуете",
["You are now DND"] = "Вы заняты",
["You have to be Raid Leader or Assistant to do that."] = "Вы должны быть Рейд лидером или помощником, чтобы сделать это.",
["Requested a status update."] = "Требуется обновление данных.",
["Use shorthands"] = "Использовать сокращения",
["Toggle using of CTRA shorthands"] = "Вкл./Выкл. использования CTRA сокращений.",
[" ...hic!"] = " ...ик!",
["Request status"] = "Запрос статуса",
["Request a status update"] = "Запрос на обновление данных.",
["Textures"] = "Текстуры",
["Set all statusbar textures."] = "Установить все statusbar текстуры.",
["Debugging"] = "Отладка",
["Show debug messages."] = "Показывать отладочные сообщения.",
} end)
L:RegisterTranslations("deDE", function() return {
["You are now AFK"] = "Ihr seid jetzt AFK",
["You are now DND"] = "Ihr seid jetzt DND",
["You have to be Raid Leader or Assistant to do that."] = "Ihr m\195\188sst Raid Leiter oder Assistent sein, um das zu machen.",
["Requested a status update."] = "Status-Aktualisierung wurde angefordert.",
["Use shorthands"] = "K\195\188rzel verwenden",
["Toggle using of CTRA shorthands"] = "Verwendung von CTRA K\195\188rzel umschalten",
[" ...hic!"] = " ...hic!",
["Request status"] = "Status anfordern",
["Request a status update"] = "Eine Status-Aktualisierung anfordern",
["Textures"] = "Texturen",
["Set all statusbar textures."] = "Texturen der StatusBars festlegen.",
} end)
L:RegisterTranslations("koKR", function() return {
["You are now AFK"] = "자리 비움으로 설정되었습니다",
["You are now DND"] = "|1으로;로; 설정되었습니다",
["You have to be Raid Leader or Assistant to do that."] = "공격대장이거나 승급된 사람만 사용 가능합니다.",
["Requested a status update."] = "상태 갱신을 요청합니다.",
["useshorthands"] = "단축명령어사용",
["Use shorthands"] = "단축 명령어 사용",
["Toggle using of CTRA shorthands"] = "공격대 도우미 단축 명령어 사용 토글",
[" ...hic!"] = " ...딸꾹!",
["status"] = "상태",
["Request status"] = "상태 갱신 요청",
["Request a status update"] = "상태 갱신을 요청",
["Textures"] = "텍스쳐",
["Set all statusbar textures."] = "모든 바의 텍스쳐로 설정합니다.",
} end)
L:RegisterTranslations("zhCN", function() return {
["You are now AFK"] = "你正在AFK状态",
["You are now DND"] = "你正在DND状态",
["You have to be Raid Leader or Assistant to do that."] = "只有团队领袖/队长才可以",
["Requested a status update."] = "请求更新状态",
["useshorthands"] = "使用缩略",
["Use shorthands"] = "使用缩略",
["Toggle using of CTRA shorthands"] = "使用CTRA缩略",
["Toggle using of CTRA shorthands"] = "使用CTRA缩略",
[" ...hic!"] = "...嗝!",
["status"] = "状态",
["Request status"] = "获取状态",
["Request a status update"] = "获取状态更新",
["Textures"] = "材质",
["Set all statusbar textures."] = "设置所有状态条的材质"
} end)
L:RegisterTranslations("zhTW", function() return {
["You are now AFK"] = "你現在處於離開狀態",
["You are now DND"] = "你現在處於勿打擾狀態",
["You have to be Raid Leader or Assistant to do that."] = "只有領隊/隊長才可以",
["Requested a status update."] = "請求更新狀態",
["useshorthands"] = "使用縮略",
["Use shorthands"] = "使用縮略",
["Toggle using of CTRA shorthands"] = "使用CTRA縮略",
["Toggle using of CTRA shorthands"] = "使用CTRA縮略",
[" ...hic!"] = "...啊!",
["status"] = "狀態",
["Request status"] = "請求狀態",
["Request a status update"] = "請求狀態更新",
["Textures"] = "材質",
["Set all statusbar textures."] = "設置所有狀態條的材質"
} end)
L:RegisterTranslations("frFR", function() return {
["You are now AFK"] = "Vous \195\170tes maintenant ABS",
["You are now DND"] = "Vous \195\170tes maintenant en mode NPD",
["You have to be Raid Leader or Assistant to do that."] = "Vous devez \195\170tre le chef du raid ou un de ses assistants pour faire cela.",
["Requested a status update."] = "Mise \195\160 jour du statut demand\195\169.",
["Use shorthands"] = "Utiliser les commandes courtes",
["Toggle using of CTRA shorthands"] = "Utilise ou non les commandes courtes de CTRA.",
[" ...hic!"] = " ... hic !",
--["status"] = true,
["Request status"] = "Demander le statut",
["Request a status update"] = "Demande une mise \195\160 jour du statut.",
--["Textures"] = true,
["Set all statusbar textures."] = "D\195\169termine la texture de toutes les barres de statut.",
} end)
---------------------------------
-- Addon Declaration --
---------------------------------
oRA = AceLibrary("AceAddon-2.0"):new("AceEvent-2.0", "AceModuleCore-2.0", "AceConsole-2.0", "AceDB-2.0")
oRA:SetModuleMixins("AceEvent-2.0")
oRA.defaults = {
bartexture = "BantoBar",
useshorthands = true,
}
oRA.version = 20002
oRA.CTRAversion = CTRAversion
oRA.consoleOptions = {
type = "group",
handler = oRA,
args = {
[L["useshorthands"]] = {
name = L["Use shorthands"], type = "toggle",
desc = L["Toggle using of CTRA shorthands"],
get = function() return oRA.db.profile.useshorthands end,
set = function(v)
oRA.db.profile.useshorthands = v
oRA:UpdateShorthands()
end,
order = 1000,
},
[L["status"]] = {
name = L["Request status"], type = "execute",
desc = L["Request a status update"],
func = function()
oRA:RequestStatus()
end,
order = 1000,
disabled = function() return not oRA:IsActive() end,
},
[L["Textures"]] = {
type = "text",
name = L["Textures"],
desc = L["Set all statusbar textures."],
get = function() return oRA.db.profile.bartexture end,
set = function(v) oRA:SetBarTexture(v) end,
validate = surface:List(),
},
[L["debug"]] = {
type = "toggle",
name = L["Debugging"],
desc = L["Show debug messages."],
order = 4,
get = function() return oRA:IsDebugging() end,
set = function(v) oRA:SetDebugging(v) end,
hidden = function() return not oRA:IsDebugging() and not oRA:IsDebugging() end,
},
}
}
oRA:RegisterDB("oRADB", "oRADBPerChar")
oRA:RegisterDefaults("profile", oRA.defaults)
oRA:RegisterChatCommand({"/oracl", "/oRAcl"}, oRA.consoleOptions )
oRA:RegisterChatCommand({"/ora", "/oRA"}, function() waterfall:Open('oRA') end)
waterfall:Register('oRA', 'aceOptions', oRA.consoleOptions, 'title','oRA 2.0','colorR', 0.2, 'colorG', 0.6, 'colorB', 0.2)
local isDebugging = false
function oRA:IsDebugging()
return isDebugging
end
function oRA:SetDebugging(v)
if type(v) == "boolean" then
isDebugging = v
end
end
function oRA:DebugMessage(msg, module)
if not msg then msg = "" end
local prefix = "|cfB34DFFf[oRA Debug]|r - ";
local core = oRA
local debugFrame = DEFAULT_CHAT_FRAME
if module then
if module.core then
core = module.core
end
if module.debugFrame then
debugFrame = self.debugFrame
end
end
if core:IsDebugging() then
(debugFrame or DEFAULT_CHAT_FRAME):AddMessage(prefix .. msg)
end
end
------------------------------
-- Initialization --
------------------------------
function oRA:OnInitialize()
self.checks = {}
self.shorthands = {}
self.moduletooltips = {}
self.roster = AceLibrary("RosterLib-2.0")
setglobal("BINDING_HEADER_oRA2", "oRA2")
self.loading = true
self.consoleOptions.args[L["Textures"]].validate = surface:List()
self:RegisterEvent("Surface_Registered", function()
self.consoleOptions.args[L["Textures"]].validate = surface:List()
end)
-- try and enable ourselves
self:ToggleActive(true)
end
function oRA:OnEnable()
if AceLibrary("AceEvent-2.0"):IsFullyInitialized() then
self:AceEvent_FullyInitialized()
else
self:RegisterEvent("AceEvent_FullyInitialized")
end
end
function oRA:AceEvent_FullyInitialized()
if GetNumRaidMembers() > 0 or not self.loading then
self:RegisterEvent("CHAT_MSG_ADDON")
self:RegisterEvent("CHAT_MSG_SYSTEM")
self:RegisterEvent("oRA_SendVersion", "DistributeVersion")
self:RegisterEvent("oRA_JoinedRaid")
self:RegisterEvent("oRA_LeftRaid")
self:RegisterEvent("oRA_UpdateVersion")
self:RegisterEvent("oRA_UpdateAfkDnd")
self:RegisterEvent("oRA_UpdateCTRAVersion")
self:RegisterEvent("oRA_UpdateVersion")
self:RegisterCheck("SR", "oRA_SendVersion")
self:RegisterCheck("AFK", "oRA_UpdateAfkDnd")
self:RegisterCheck("DND", "oRA_UpdateAfkDnd")
self:RegisterCheck("UNAFK", "oRA_UpdateAfkDnd")
self:RegisterCheck("UNDND", "oRA_UpdateAfkDnd")
self:RegisterCheck("V", "oRA_UpdateCTRAVersion")
self:RegisterCheck("oRAV", "oRA_UpdateVersion")
if not self:IsEventRegistered("Surface_Registered") then
self:RegisterEvent("Surface_Registered", function()
self.consoleOptions.args[L["Textures"]].validate = surface:List()
end)
end
self:TriggerEvent("oRA_CoreEnabled")
if GetNumRaidMembers() > 0 then
self:TriggerEvent("oRA_JoinedRaid")
else
self:TriggerEvent("oRA_LeftRaid")
end
self:ScheduleEvent(oRALInvite.AutoPromoteAll, 2)
else
self:ToggleActive(false)
end
self.loading = nil
end
function oRA:OnDisable()
self:TriggerEvent("oRA_LeftRaid")
-- Unconditionally disable all modules, disregarding module.shouldEnable
local name, module = nil, nil
for name, module in self:IterateModules() do
self:ToggleModuleActive(module, false)
end
self:TriggerEvent("oRA_CoreDisabled")
self:UnregisterAllEvents()
end
--------------------------------
-- Module Prototype --
--------------------------------
oRA.modulePrototype.core = oRA
function oRA.modulePrototype:OnInitialize()
-- Unconditionally register, this shouldn't happen from any other place
-- anyway.
self.core:RegisterModule(self.name, self)
end
function oRA.modulePrototype:RegisterCheck( c, e )
self.core:RegisterCheck(c, e)
self:RegisterEvent(e)
end
function oRA.modulePrototype:UnregisterCheck( c )
self.core:UnregisterCheck(c)
end
function oRA.modulePrototype:IsValidRequest( a, i)
return self.core:IsValidRequest(a, i)
end
function oRA.modulePrototype:SendMessage( msg, ora)
self.core:SendMessage(msg, ora)
end
function oRA.modulePrototype:CleanMessage( msg )
return self.core:CleanMessage( msg )
end
function oRA.modulePrototype:IsPromoted( a )
return self.core:IsPromoted( a )
end
function oRA.modulePrototype:RegisterShorthand( s, f, i)
self.core:RegisterShorthand(s, f, i)
end
function oRA.modulePrototype:UnregisterShorthand( s )
self.core:UnregisterShorthand(s)
end
function oRA.modulePrototype:Print( msg )
self.core:Print("(%s) %s", self.name, msg )
end
function oRA.modulePrototype:IsRegistered()
return self.registered
end
-------------------------------
-- Module Handling --
-------------------------------
function oRA:RegisterModule(name, module)
if module:IsRegistered() then
error(string.format("%q is already registered.", name))
return
end
if module.db and module.RegisterDefaults and type(module.RegisterDefaults) == "function" then
module:RegisterDefaults("profile", opts or module.defaults or {})
else
self:RegisterDefaults(name, "profile", opts or module.defaults or {})
end
if not module.db then module.db = self:AcquireDBNamespace(name) end
if module.consoleOptions then
local m = module.consoleCmd or name
-- if the consoleoption already exists we merge in the data otherwise we create a new option
if self.consoleOptions.args[m] then
for k,v in pairs(module.consoleOptions.args) do self.consoleOptions.args[m].args[k] = v end
else
self.consoleOptions.args[m] = module.consoleOptions
end
end
if module.OnTooltipUpdate then
self.moduletooltips[name] = module
end
module.registered = true
if module.OnRegister and type(module.OnRegister) == "function" then
module:OnRegister()
end
end
-------------------------------
-- Core --
-------------------------------
-- Distrubutes your version to the raid
function oRA:DistributeVersion()
self:SendMessage( "V " .. self.CTRAversion)
self:SendMessage( "oRAV "..self.version, true )
end
-- Command handler
-- Updates the shorthands for the current setting
function oRA:UpdateShorthands()
if self.db.profile.useshorthands then
local s,f
for s,f in pairs(self.shorthands) do
self:RegisterShorthand(s, f, true)
end
else
local s,f
for s, f in pairs(self.shorthands) do
local type = "ORA_SHORTHAND_"..strupper(s)
SlashCmdList[type] = nil
setglobal("SLASH_"..type.."1", nil)
end
end
end
-- Command handler
-- Sends a status request.
function oRA:RequestStatus()
self:Print(L["Requested a status update."])
self:SendMessage("SR")
end
function oRA:SetBarTexture( texture )
self.db.profile.bartexture = texture
self:TriggerEvent("oRA_BarTexture", texture )
end
-------------------------------
-- Event Handlers --
-------------------------------
function oRA:oRA_JoinedRaid()
local name, module = nil, nil
local enabledModule = nil
for name, module in self:IterateModules() do
if not self:IsModuleActive(module) then enabledModule = true end
self:ToggleModuleActive(module, true)
end
if enabledModule then
self:TriggerEvent("oRA_JoinedRaid")
end
self:DistributeVersion()
end
function oRA:oRA_LeftRaid()
local name, module = nil, nil
for name, module in self:IterateModules() do
if not module.shouldEnable or (module.shouldEnable ~= nil and type(module.shouldEnable) == "function" and not module:shouldEnable()) then
self:ToggleModuleActive(module, false)
end
end
end
-- Event handler for the CHAT_MSG_ADDON event
-- Parses the info sent over the addon channel
-- Checks for the keywrods and triggers the appropriate events
function oRA:CHAT_MSG_ADDON(prefix, msg, type, author)
if prefix ~= "CTRA" and prefix ~= "oRA" then return end
if type ~= "RAID" then return end
local msgArr = self:SplitMessage(msg, "#")
for _, c in pairs(msgArr) do
cmd = self:SplitMessage(c, " ")
if self.checks[cmd[1]] then
self:TriggerEvent(self.checks[cmd[1]],c, author)
end
end
end
-- Event handler for the CHAT_MSG_SYSTEM event
-- Will send your AFK/DND status to the raid
function oRA:CHAT_MSG_SYSTEM(msg)
if string.find(msg, "^"..ERR_RAID_YOU_LEFT) then
self:TriggerEvent("oRA_LeftRaid")
elseif string.find(msg, ERR_RAID_YOU_JOINED) then
self:TriggerEvent("oRA_JoinedRaid")
elseif string.find(msg, L["You are now AFK"]) then
self:SendMessage("AFK")
elseif string.find(msg, L["You are now DND"]) then
self:SendMessage("DND")
elseif string.find(msg, CLEARED_AFK ) then
self:SendMessage("UNAFK")
elseif string.find(msg, CLEARED_DND ) then
self:SendMessage("UNDND")
end
end
-------------------------------
-- Checks Event Handlers --
-------------------------------
-- Event handler for the AFK/DND/UNAFK/UNDND messages
-- Will update the roster for the player who sent the message
function oRA:oRA_UpdateAfkDnd(msg, author)
if not self:IsValidRequest( author, true) then return end
local u = self.roster:GetUnitObjectFromName(author)
if not u then return end
msg = self:CleanMessage(msg)
if string.find( msg, "^AFK(.*)") then u.ora_afk = true
elseif string.find( msg, "^DND(.*)") then u.ora_dnd = true
elseif string.find( msg, "^UNAFK(.*)") then u.ora_afk = nil
elseif string.find( msg, "^UNDND(.*)") then u.ora_dnd = nil
end
self:TriggerEvent("oRA_AfkDndUpdated", author)
end
-- Event handler for the "V " message
-- Will update the roster for the player who sent the V with his version
function oRA:oRA_UpdateCTRAVersion(msg, author)
if not self:IsValidRequest( author, true ) then return end
local u = self.roster:GetUnitObjectFromName(author)
if not u then return end
msg = self:CleanMessage(msg)
local _,_,version = string.find(msg, "V (.+)")
if version then u.ora_ctraversion = version end
end
-- Event handler for the "oRAV " message
-- Will update the roster for the player who sent the oRAV with his version
function oRA:oRA_UpdateVersion(msg, author)
if not self:IsValidRequest( author, true ) then return end
local u = self.roster:GetUnitObjectFromName(author)
if not u then return end
msg = self:CleanMessage(msg)
local _,_,version = string.find(msg, "oRAV (.+)")
if version then u.ora_version = version end
end
-------------------------------
-- Raid Roster Utils --
-------------------------------
-- Checks if the player is raid leader or raid officer
-- Args: showmsg - when set to true will print out an error when the check fails
-- Returns true when the player is raid leader or raid officer
function oRA:IsPromoted( showmsg )
if IsRaidLeader() or IsRaidOfficer() then return true end
if showmsg then self:Print(L["You have to be Raid Leader or Assistant to do that."]) end
return false
end
-- Checks if a player is in the raid and optionally if he/she has the correct rank
-- Args: name - name of the player
-- ignorerank - flag, when set to true will ignore the rank of the player
-- Returns true when a player is authorized for a request
function oRA:IsValidRequest( name, ignorerank )
if (not name) then name = UnitName("player") end
local u = self.roster:GetUnitObjectFromName( name )
if u then
if ignorerank then return true end
if u.rank > 0 then return true end
end
return false
end
---------------------------
-- Channel checks --
---------------------------
-- Registers a keyword check
-- Args: check - keyword to check on
-- event - event to fire when the keyword is received
function oRA:RegisterCheck(check,event)
self.checks[check] = event
end
-- Unregisters a keyword check
-- Args: check - keyword to remove from the checklist
function oRA:UnregisterCheck(check)
if self.checks[check] then self.checks[check] = nil end
end
---------------------------
-- Messaging --
---------------------------
-- Sends a message
-- Args: msg - message to send
-- returns true when succesful
function oRA:SendMessage( msg, ora )
if ora then
SendAddonMessage("oRA", msg, "RAID")
else
SendAddonMessage("CTRA", msg, "RAID")
end
return true
end
-- Cleans a message replacing escaped characters by their true ones.
-- also removes the drunken ... hic!
-- Args: msg - msg to clean
-- Returns the cleaned up message
function oRA:CleanMessage( msg )
msg = string.gsub(msg, "%$", "s")
msg = string.gsub(msg, "§", "S")
if strsub(msg, strlen(msg)-strlen(L[" ...hic!"]) ) == L[" ...hic!"] then
msg = strsub(msg, 1, strlen(msg)-strlen(L[" ...hic!"]))
end
return msg
end
-- Splits a string on a given character
-- Args: msg - string to split
-- char - character to split on
-- Returns an array with all the pieces this array will contain the total string if
-- the split character was not found.
function oRA:SplitMessage( msg, char )
local arr = { }
while (string.find(msg, char) ) do
local iStart, iEnd = string.find(msg, char)
table.insert(arr, strsub(msg, 1, iStart-1))
msg = strsub(msg, iEnd+1, strlen(msg))
end
if ( strlen(msg) > 0 ) then
table.insert(arr, msg)
end
return arr
end
---------------------------------
-- Short Hand System --
---------------------------------
-- Registers a CTRA shorthand
-- Args: shorthand - shorthand you wish to register: rajoin => /rajoin
-- func - function to execute
-- system - when set to true will only enable the shorthand not register it again.
-- this flag is only used by the core itself.
function oRA:RegisterShorthand(shorthand, func, system)
if shorthand and shorthand ~= "" then
if self.db.profile.useshorthands then
local type = "ORA_SHORTHAND_"..strupper(shorthand)
SlashCmdList[type] = func
setglobal("SLASH_"..type.."1", "/"..strlower(shorthand))
end
if not system then
self.shorthands[shorthand] = func
end
end
end
-- Unregisters a CTRA shorthand
-- Args: shorthand - the shorthand you wish to unregister
-- Returns true when succesful
function oRA:UnregisterShorthand( shorthand )
if shorthand and shorthand ~= "" then
local s, f
for s, f in pairs(self.shorthands) do
if s == shorthand then
local type = "ORA_SHORTHAND_"..strupper(s)
SlashCmdList[type] = nil
setglobal("SLASH_"..type.."1", nil)
self.shorthands[s] = nil
return true
end
end
end
end