forked from Jabberie/Jamba
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJambaCore.lua
848 lines (789 loc) · 29.3 KB
/
JambaCore.lua
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
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
--[[
Jamba - Jafula's Awesome Multi-Boxer Assistant
Copyright 2008 - 2017 Michael "Jafula" Miller
License: The MIT License
]]--
-- The global private table for Jamba.
JambaPrivate = {}
JambaPrivate.Core = {}
JambaPrivate.Communications = {}
JambaPrivate.Message = {}
JambaPrivate.Team = {}
JambaPrivate.Tag = {}
-- The global public API table for Jamba.
JambaApi = {}
local AJM = LibStub( "AceAddon-3.0" ):NewAddon(
"JambaCore",
"AceConsole-3.0"
)
-- JambaCore is not a module, but the same naming convention for these values is convenient.
AJM.moduleName = "Jamba-Core"
local L = LibStub( "AceLocale-3.0" ):GetLocale( AJM.moduleName )
AJM.moduleDisplayName = L["Jamba"]
AJM.settingsDatabaseName = "JambaCoreProfileDB"
AJM.parentDisplayName = "Jamba"
AJM.chatCommand = "jamba"
AJM.teamModuleName = "Jamba-Team"
-- Load libraries.
local JambaUtilities = LibStub:GetLibrary( "JambaUtilities-1.0" )
local JambaHelperSettings = LibStub:GetLibrary( "JambaHelperSettings-1.0" )
local AceGUI = LibStub("AceGUI-3.0")
-- Create frame for Jamba Settings.
JambaPrivate.SettingsFrame = {}
JambaPrivate.SettingsFrame.Widget = AceGUI:Create( "JambaWindow" )
--JambaPrivate.SettingsFrame.Widget = AceGUI:Create( "Frame" )
JambaPrivate.SettingsFrame.Widget:SetTitle( L["Jamba"].." "..L["Version"] )
JambaPrivate.SettingsFrame.Widget:SetStatusText(L["The Awesome Multi-Boxer Assistant"])
JambaPrivate.SettingsFrame.Widget:SetWidth(800)
JambaPrivate.SettingsFrame.Widget:SetHeight(650)
JambaPrivate.SettingsFrame.Widget:SetLayout( "Fill" )
JambaPrivate.SettingsFrame.WidgetTree = AceGUI:Create( "TreeGroup" )
JambaPrivate.SettingsFrame.TreeGroupStatus = { treesizable = false, groups = {} }
JambaPrivate.SettingsFrame.WidgetTree:SetStatusTable( JambaPrivate.SettingsFrame.TreeGroupStatus )
JambaPrivate.SettingsFrame.WidgetTree:EnableButtonTooltips( false )
JambaPrivate.SettingsFrame.Widget:AddChild( JambaPrivate.SettingsFrame.WidgetTree )
JambaPrivate.SettingsFrame.WidgetTree:SetLayout( "Fill" )
function AJM:OnEnable()
if AJM.db.showStartupMessage4000 then
JambaStartupMessageFrameTitle:SetText( L["Jamba"].." "..GetAddOnMetadata("Jamba", "version").." - "..L["Full Change Log"] )
--JambaStartupMessageFrame:Show()
AJM.db.showStartupMessage4000 = false
end
end
function AJM:OnDisable()
end
function AJM:ShowChangeLog()
JambaStartupMessageFrameTitle:SetText( L["Jamba"].." "..GetAddOnMetadata("Jamba", "version").." - "..L["Full Change Log"] )
JambaStartupMessageFrame:Show()
end
local function JambaSettingsTreeSort( a, b )
local aText = ""
local bText = ""
local aJambaOrder = 0
local bJambaOrder = 0
if a ~= nil then
aText = a.text
aJambaOrder = a.jambaOrder
end
if b ~= nil then
bText = b.text
bJambaOrder = b.jambaOrder
end
if aText == L["Jamba"] or bText == L["Jamba"] then
if aText == L["Jamba"] then
return true
end
if bText == L["Jamba"] then
return false
end
end
if aJambaOrder == bJambaOrder then
return aText < bText
end
return aJambaOrder < bJambaOrder
end
local function JambaTreeGroupTreeGetParent( parentName )
local parent
for index, tableInfo in ipairs( JambaPrivate.SettingsFrame.Tree.Data ) do
if tableInfo.value == parentName then
parent = tableInfo
end
end
return parent
end
local function GetTreeGroupParentJambaOrder( parentName )
local order = 1000
if parentName == L["Team"] then
order = 10
end
if parentName == L["Quest"] then
order = 20
end
if parentName == L["Merchant"] then
order = 30
end
if parentName == L["Interaction"] then
order = 40
end
if parentName == L["Combat"] then
order = 50
end
if parentName == L["Toon"] then
order = 60
end
if parentName == L["Chat"] then
order = 70
end
if parentName == L["Macro"] then
order = 80
end
if parentName == L["Profiles"] then
order = 90
end
if parentName == L["Advanced"] then
order = 100
end
return order
end
local function GetTreeGroupParentIcon( parentName )
local icon = "Interface\\Icons\\Temp"
if parentName == L["Team"] then
icon = "Interface\\Icons\\INV_Misc_FireDancer_01"
end
if parentName == L["Quest"] then
icon = "Interface\\Icons\\Achievement_Quests_Completed_08"
end
if parentName == L["Merchant"] then
icon = "Interface\\Icons\\INV_Drink_05"
end
if parentName == L["Interaction"] then
icon = "Interface\\Icons\\Achievement_Reputation_01"
end
if parentName == L["Combat"] then
icon = "Interface\\Icons\\INV_Sword_11"
end
if parentName == L["Toon"] then
icon = "Interface\\Icons\\Achievement_Character_Bloodelf_Female"
end
if parentName == L["Chat"] then
icon = "Interface\\Icons\\Ability_Warrior_RallyingCry"
end
if parentName == L["Macro"] then
icon = "Interface\\Icons\\Spell_Holy_Dizzy"
end
if parentName == L["Profiles"] then
icon = "Interface\\Icons\\INV_Misc_Dice_01"
end
if parentName == L["Advanced"] then
icon = "Interface\\Icons\\Trade_Engineering"
end
return icon
end
local function JambaAddModuleToSettings( childName, parentName, moduleFrame, tabGroup )
local parent = JambaTreeGroupTreeGetParent( parentName )
if parent == nil then
local order = GetTreeGroupParentJambaOrder( parentName )
table.insert( JambaPrivate.SettingsFrame.Tree.Data, { value = parentName, text = parentName, jambaOrder = order, icon = GetTreeGroupParentIcon( parentName ) } )
parent = JambaTreeGroupTreeGetParent( parentName )
end
if parent.children == nil then
parent.children = {}
end
table.insert( parent.children, { value = childName, text = childName } )
table.sort( JambaPrivate.SettingsFrame.Tree.Data, JambaSettingsTreeSort )
JambaPrivate.SettingsFrame.Tree.ModuleFrames[childName] = moduleFrame
JambaPrivate.SettingsFrame.Tree.ModuleFramesTabGroup[childName] = tabGroup
end
local function JambaModuleSelected( tree, event, treeValue, selected )
local parentValue, value = strsplit( "\001", treeValue )
if tree == nil and event == nil then
-- Came from chat command.
value = treeValue
end
JambaPrivate.SettingsFrame.Widget:Show()
if JambaPrivate.SettingsFrame.Tree.CurrentChild ~= nil then
JambaPrivate.SettingsFrame.Tree.CurrentChild.frame:Hide()
JambaPrivate.SettingsFrame.Tree.CurrentChild = nil
end
for moduleValue, moduleFrame in pairs( JambaPrivate.SettingsFrame.Tree.ModuleFrames ) do
if moduleValue == value then
moduleFrame:SetParent( JambaPrivate.SettingsFrame.WidgetTree )
moduleFrame:SetWidth( JambaPrivate.SettingsFrame.WidgetTree.content:GetWidth() or 0 )
moduleFrame:SetHeight( JambaPrivate.SettingsFrame.WidgetTree.content:GetHeight() or 0 )
moduleFrame.frame:SetAllPoints() -- JambaPrivate.SettingsFrame.WidgetTree.content
moduleFrame.frame:Show()
JambaPrivate.SettingsFrame.Tree.CurrentChild = moduleFrame
-- Hacky hack hack.
if JambaPrivate.SettingsFrame.Tree.ModuleFramesTabGroup[value] ~= nil then
JambaPrivate.SettingsFrame.Tree.ModuleFramesTabGroup[value]:SelectTab( "options" )
else
-- Hacky hack hack.
LibStub( "AceConfigDialog-3.0" ):Open( AJM.moduleName.."-Profiles", moduleFrame )
end
return
end
end
end
JambaPrivate.SettingsFrame.Tree = {}
JambaPrivate.SettingsFrame.Tree.Data = {}
JambaPrivate.SettingsFrame.Tree.ModuleFrames = {}
JambaPrivate.SettingsFrame.Tree.ModuleFramesTabGroup = {}
JambaPrivate.SettingsFrame.Tree.CurrentChild = nil
JambaPrivate.SettingsFrame.Tree.Add = JambaAddModuleToSettings
JambaPrivate.SettingsFrame.Tree.ButtonClick = JambaModuleSelected
JambaPrivate.SettingsFrame.WidgetTree:SetTree( JambaPrivate.SettingsFrame.Tree.Data )
JambaPrivate.SettingsFrame.WidgetTree:SetCallback( "OnClick", JambaPrivate.SettingsFrame.Tree.ButtonClick )
JambaPrivate.SettingsFrame.Widget:Hide()
table.insert( UISpecialFrames, "JambaSettingsWindowsFrame" )
-- Settings - the values to store and their defaults for the settings database.
AJM.settings = {
profile = {
showMinimapIcon = true,
showStartupMessage4000 = true,
},
}
-- Configuration.
local function GetConfiguration()
local configuration = {
name = "Jamba",
handler = AJM,
type = 'group',
childGroups = "tab",
get = "ConfigurationGetSetting",
set = "ConfigurationSetSetting",
args = {
push = {
type = "input",
name = L["Push Settings"],
desc = L["Push Settings"],
usage = "/jamba push",
get = false,
set = "SendSettingsAllModules",
order = 4,
guiHidden = true,
},
resetsettingsframe = {
type = "input",
name = L["Reset Settings Frame"],
desc = L["Reset Settings Frame"],
usage = "/jamba resetsettingsframe",
get = false,
set = "ResetSettingsFrame",
order = 5,
guiHidden = true,
},
},
}
return configuration
end
-- Get a settings value.
function AJM:ConfigurationGetSetting( key )
return AJM.db[key[#key]]
end
-- Set a settings value.
function AJM:ConfigurationSetSetting( key, value )
AJM.db[key[#key]] = value
end
local function DebugMessage( ... )
AJM:Print( ... )
end
-------------------------------------------------------------------------------------------------------------
-- Module management.
-------------------------------------------------------------------------------------------------------------
-- Register a Jamba module.
local function RegisterModule( moduleAddress, moduleName )
if AJM.registeredModulesByName == nil then
AJM.registeredModulesByName = {}
end
if AJM.registeredModulesByAddress == nil then
AJM.registeredModulesByAddress = {}
end
AJM.registeredModulesByName[moduleName] = moduleAddress
AJM.registeredModulesByAddress[moduleAddress] = moduleName
end
-------------------------------------------------------------------------------------------------------------
-- Settings sending and receiving.
-------------------------------------------------------------------------------------------------------------
-- Send the settings for the module specified (using its address) to other Jamba Team characters.
local function SendSettings( moduleAddress, settings )
-- Get the name of the module.
local moduleName = AJM.registeredModulesByAddress[moduleAddress]
-- Send the settings identified by the module name.
JambaPrivate.Communications.SendSettings( moduleName, settings )
end
-- Settings are received, pass them to the relevant module.
local function OnSettingsReceived( sender, moduleName, settings )
sender = JambaUtilities:AddRealmToNameIfMissing( sender )
--AJM:Print("onsettings", sender, moduleName )
-- Get the address of the module.
local moduleAddress = AJM.registeredModulesByName[moduleName]
-- can not receive a message from a Module not Loaded so ignore it. Better tell them its not loaded --ebony.
if moduleAddress == nil then
AJM:Print(L["Module Not Loaded:"], moduleName)
return
else
-- loaded? Pass the module its settings.
moduleAddress:JambaOnSettingsReceived( sender, settings )
end
end
function AJM:SendSettingsAllModules()
AJM:Print( "Sending settings for all modules." )
for moduleName, moduleAddress in pairs( AJM.registeredModulesByName ) do
AJM:Print( "Sending settings for: ", moduleName )
moduleAddress:JambaSendSettings()
end
end
-------------------------------------------------------------------------------------------------------------
-- Commands sending and receiving.
-------------------------------------------------------------------------------------------------------------
-- Send a command for the module specified (using its address) to other Jamba Team characters.
local function SendCommandToTeam( moduleAddress, commandName, ... )
-- Get the name of the module.
local moduleName = AJM.registeredModulesByAddress[moduleAddress]
-- Send the command identified by the module name.
if moduleAddress == nil then
AJM:Print(L["Module Not Loaded:"], moduleName)
return
else
JambaPrivate.Communications.SendCommandAll( moduleName, commandName, ... )
end
end
-- Send a command for the module specified (using its address) to the master character.
local function SendCommandToMaster( moduleAddress, commandName, ... )
-- Get the name of the module.
local moduleName = AJM.registeredModulesByAddress[moduleAddress]
-- Send the command identified by the module name.
if moduleAddress == nil then
AJM:Print(L["Module Not Loaded:"], moduleName)
return
else
JambaPrivate.Communications.SendCommandMaster( moduleName, commandName, ... )
end
end
local function SendCommandToToon( moduleAddress, characterName, commandName, ... )
-- Get the name of the module.
local moduleName = AJM.registeredModulesByAddress[moduleAddress]
-- Send the command identified by the module name.
if moduleAddress == nil then
AJM:Print(L["Module Not Loaded:"], moduleName)
return
else
JambaPrivate.Communications.SendCommandToon( moduleName, characterName, commandName, ... )
end
end
-- A command is received, pass it to the relevant module.
local function OnCommandReceived( sender, moduleName, commandName, ... )
sender = JambaUtilities:AddRealmToNameIfMissing( sender )
-- Get the address of the module.
local moduleAddress = AJM.registeredModulesByName[moduleName]
-- Pass the module its settings.
if moduleAddress == nil then
AJM:Print(L["Module Not Loaded:"], moduleName)
return
else
moduleAddress:JambaOnCommandReceived( sender, commandName, ... )
end
end
-------------------------------------------------------------------------------------------------------------
-- Jamba Core Profile Support.
-------------------------------------------------------------------------------------------------------------
function AJM:FireBeforeProfileChangedEvent()
for moduleName, moduleAddress in pairs( AJM.registeredModulesByName ) do
if moduleName ~= AJM.moduleName then
moduleAddress:BeforeJambaProfileChanged()
end
end
end
function AJM:CanChangeProfileForModule( moduleName )
if (moduleName ~= AJM.moduleName) and (moduleName ~= AJM.teamModuleName) then
return true
end
return false
end
function AJM:FireOnProfileChangedEvent( moduleAddress )
moduleAddress.db = moduleAddress.completeDatabase.profile
moduleAddress:OnJambaProfileChanged()
end
function AJM:OnProfileChanged( event, database, newProfileKey, ... )
AJM:Print( "Profile changed - iterating all modules." )
AJM:FireBeforeProfileChangedEvent()
-- Do the team module before all the others.
local teamModuleAddress = AJM.registeredModulesByName[AJM.teamModuleName]
AJM:Print( "Changing profile: ", AJM.teamModuleName )
teamModuleAddress.completeDatabase:SetProfile( newProfileKey )
AJM:FireOnProfileChangedEvent( teamModuleAddress )
-- Do the other modules.
for moduleName, moduleAddress in pairs( AJM.registeredModulesByName ) do
if AJM:CanChangeProfileForModule( moduleName ) == true then
AJM:Print( "Changing profile: ", moduleName )
moduleAddress.completeDatabase:SetProfile( newProfileKey )
AJM:FireOnProfileChangedEvent( moduleAddress )
end
end
end
function AJM:OnProfileCopied( event, database, sourceProfileKey )
AJM:Print( "Profile copied - iterating all modules." )
AJM:FireBeforeProfileChangedEvent()
-- Do the team module before all the others.
local teamModuleAddress = AJM.registeredModulesByName[AJM.teamModuleName]
AJM:Print( "Copying profile: ", AJM.teamModuleName )
teamModuleAddress.completeDatabase:CopyProfile( sourceProfileKey, true )
AJM:FireOnProfileChangedEvent( teamModuleAddress )
-- Do the other modules.
for moduleName, moduleAddress in pairs( AJM.registeredModulesByName ) do
if AJM:CanChangeProfileForModule( moduleName ) == true then
AJM:Print( "Copying profile: ", moduleName )
moduleAddress.completeDatabase:CopyProfile( sourceProfileKey, true )
AJM:FireOnProfileChangedEvent( moduleAddress )
end
end
end
function AJM:OnProfileReset( event, database )
AJM:Print( "Profile reset - iterating all modules." )
AJM:FireBeforeProfileChangedEvent()
-- Do the team module before all the others.
local teamModuleAddress = AJM.registeredModulesByName[AJM.teamModuleName]
AJM:Print( "Resetting profile: ", AJM.teamModuleName )
teamModuleAddress.completeDatabase:ResetProfile()
AJM:FireOnProfileChangedEvent( teamModuleAddress )
-- Do the other modules.
for moduleName, moduleAddress in pairs( AJM.registeredModulesByName ) do
if AJM:CanChangeProfileForModule( moduleName ) == true then
AJM:Print( "Resetting profile: ", moduleName )
moduleAddress.completeDatabase:ResetProfile()
AJM:FireOnProfileChangedEvent( moduleAddress )
end
end
end
function AJM:OnProfileDeleted( event, database, profileKey )
AJM:Print( "Profile deleted - iterating all modules." )
AJM:FireBeforeProfileChangedEvent()
-- Do the team module before all the others.
local teamModuleAddress = AJM.registeredModulesByName[AJM.teamModuleName]
AJM:Print( "Deleting profile: ", AJM.teamModuleName )
teamModuleAddress.completeDatabase:DeleteProfile( profileKey, true )
AJM:FireOnProfileChangedEvent( teamModuleAddress )
-- Do the other modules.
for moduleName, moduleAddress in pairs( AJM.registeredModulesByName ) do
if AJM:CanChangeProfileForModule( moduleName ) == true then
AJM:Print( "Deleting profile: ", moduleName )
moduleAddress.completeDatabase:DeleteProfile( profileKey, true )
AJM:FireOnProfileChangedEvent( moduleAddress )
end
end
end
-------------------------------------------------------------------------------------------------------------
-- Jamba Core Initialization.
-------------------------------------------------------------------------------------------------------------
-- Initialize the addon.
function AJM:OnInitialize()
-- Tables to hold registered modules - lookups by name and by address.
-- By name is used for communication between clients and by address for communication between addons on the same client.
AJM.registeredModulesByName = {}
AJM.registeredModulesByAddress = {}
-- Create the settings database supplying the settings values along with defaults.
AJM.completeDatabase = LibStub( "AceDB-3.0" ):New( AJM.settingsDatabaseName, AJM.settings )
AJM.completeDatabase.RegisterCallback( AJM, "OnProfileChanged", "OnProfileChanged" )
AJM.completeDatabase.RegisterCallback( AJM, "OnProfileCopied", "OnProfileCopied" )
AJM.completeDatabase.RegisterCallback( AJM, "OnProfileReset", "OnProfileReset" )
AJM.completeDatabase.RegisterCallback( AJM, "OnProfileDeleted", "OnProfileDeleted" )
AJM.db = AJM.completeDatabase.profile
-- Create the settings.
LibStub( "AceConfig-3.0" ):RegisterOptionsTable(
AJM.moduleName,
GetConfiguration()
)
-- Create the settings frame.
AJM:CoreSettingsCreate()
AJM.settingsFrame = AJM.settingsControl.widgetSettings.frame
-- Blizzard options frame.
local frame = CreateFrame( "Frame" )
frame.name = L["Jamba"]
local button = CreateFrame( "Button", nil, frame, "OptionsButtonTemplate" )
button:SetPoint( "CENTER" )
button:SetText( "/jamba" )
button:SetScript( "OnClick", AJM.LoadJambaSettings )
InterfaceOptions_AddCategory( frame )
-- Create the settings profile support.
LibStub( "AceConfig-3.0" ):RegisterOptionsTable(
AJM.moduleName.."-Profiles",
LibStub( "AceDBOptions-3.0" ):GetOptionsTable( AJM.completeDatabase )
)
local profileContainerWidget = AceGUI:Create( "SimpleGroup" )
profileContainerWidget:SetLayout( "Fill" )
JambaPrivate.SettingsFrame.Tree.Add( L["Core"]..L[": Profiles"], L["Profiles"], profileContainerWidget, nil )
-- Register the core as a module.
RegisterModule( AJM, AJM.moduleName )
-- Register the chat command.
AJM:RegisterChatCommand( AJM.chatCommand, "JambaChatCommand" )
-- Attempt to load modules, if they are disabled, they won't be loaded.
-- TODO: This kinda defeats the purpose of the module system if we have to update core each time a module is added.
AJM:LoadJambaModule( "Jamba-AdvancedLoot" )
AJM:LoadJambaModule( "Jamba-DisplayTeam" )
AJM:LoadJambaModule( "Jamba-Follow" )
AJM:LoadJambaModule( "Jamba-FTL" )
AJM:LoadJambaModule( "Jamba-ItemUse" )
AJM:LoadJambaModule( "Jamba-Macro" )
AJM:LoadJambaModule( "Jamba-Proc" )
AJM:LoadJambaModule( "Jamba-Purchase" )
AJM:LoadJambaModule( "Jamba-Quest" )
AJM:LoadJambaModule( "Jamba-QuestWatcher" )
AJM:LoadJambaModule( "Jamba-Sell" )
AJM:LoadJambaModule( "Jamba-Talk" )
AJM:LoadJambaModule( "Jamba-Target" )
AJM:LoadJambaModule( "Jamba-Taxi" )
AJM:LoadJambaModule( "Jamba-Toon" )
AJM:LoadJambaModule( "Jamba-Trade" )
AJM:LoadJambaModule( "Jamba-Video" )
AJM:LoadJambaModule( "Jamba-Curr" )
AJM:LoadJambaModule( "Jamba-Mount" )
end
function AJM:LoadJambaModule( moduleName )
local loaded, reason = LoadAddOn( moduleName )
if not loaded then
if reason ~= "DISABLED" and reason ~= "MISSING" then
AJM:Print("Failed to load Jamba Module '"..moduleName.."' ["..reason.."]." )
end
end
end
function AJM:CoreSettingsCreateInfo( top )
-- Get positions and dimensions.
local buttonPushAllSettingsWidth = 200
local buttonHeight = JambaHelperSettings:GetButtonHeight()
local checkBoxHeight = JambaHelperSettings:GetCheckBoxHeight()
local radioBoxHeight = JambaHelperSettings:GetRadioBoxHeight()
local labelHeight = JambaHelperSettings:GetLabelHeight()
local labelContinueHeight = JambaHelperSettings:GetContinueLabelHeight()
local left = JambaHelperSettings:LeftOfSettings()
local headingHeight = JambaHelperSettings:HeadingHeight()
local headingWidth = JambaHelperSettings:HeadingWidth( false )
local horizontalSpacing = JambaHelperSettings:GetHorizontalSpacing()
local verticalSpacing = JambaHelperSettings:GetVerticalSpacing()
local indent = horizontalSpacing * 10
local indentContinueLabel = horizontalSpacing * 18
local indentSpecial = indentContinueLabel + 9
local checkBoxThirdWidth = (headingWidth - indentContinueLabel) / 3
local column1Left = left
local column2Left = column1Left + checkBoxThirdWidth + horizontalSpacing
local column1LeftIndent = left + indentContinueLabel
local column2LeftIndent = column1LeftIndent + checkBoxThirdWidth + horizontalSpacing
local column3LeftIndent = column2LeftIndent + checkBoxThirdWidth + horizontalSpacing
local movingTop = top
--Main Heading
JambaHelperSettings:CreateHeading( AJM.settingsControl, L["The Awesome Multi-Boxer Assistant"], movingTop, false )
movingTop = movingTop - headingHeight
AJM.settingsControl.labelInformation1 = JambaHelperSettings:CreateContinueLabel(
AJM.settingsControl,
headingWidth,
column1Left,
movingTop,
L["Current Project Manager - Jennifer 'Ebony'"]
)
movingTop = movingTop + movingTop * 2
JambaHelperSettings:CreateHeading( AJM.settingsControl, L["Release Notes / News: "]..GetAddOnMetadata("jamba", "version") , movingTop, false )
movingTop = movingTop - headingHeight
AJM.settingsControl.labelInformation10 = JambaHelperSettings:CreateContinueLabel(
AJM.settingsControl,
headingWidth,
column1Left,
movingTop,
L["Text1"]
)
movingTop = movingTop - labelContinueHeight
AJM.settingsControl.labelInformation11 = JambaHelperSettings:CreateContinueLabel(
AJM.settingsControl,
headingWidth,
column1Left,
movingTop,
L["Text2"]
)
movingTop = movingTop - labelContinueHeight
AJM.settingsControl.labelInformation12 = JambaHelperSettings:CreateContinueLabel(
AJM.settingsControl,
headingWidth,
column1Left,
movingTop,
L["Text3"]
)
movingTop = movingTop - labelContinueHeight
AJM.settingsControl.labelInformation13 = JambaHelperSettings:CreateContinueLabel(
AJM.settingsControl,
headingWidth,
column1Left,
movingTop,
L["Text4"]
)
movingTop = movingTop - labelContinueHeight
AJM.settingsControl.labelInformation14 = JambaHelperSettings:CreateContinueLabel(
AJM.settingsControl,
headingWidth,
column1Left,
movingTop,
L["Text5"]
)
movingTop = movingTop - labelContinueHeight
AJM.settingsControl.labelInformation15 = JambaHelperSettings:CreateContinueLabel(
AJM.settingsControl,
headingWidth,
column1Left,
movingTop,
L["Text6"]
)
movingTop = movingTop - labelContinueHeight
AJM.settingsControl.labelInformation16 = JambaHelperSettings:CreateContinueLabel(
AJM.settingsControl,
headingWidth,
column1Left,
movingTop,
L["Text7"]
)
movingTop = movingTop - labelContinueHeight
AJM.settingsControl.labelInformation17 = JambaHelperSettings:CreateContinueLabel(
AJM.settingsControl,
headingWidth,
column1Left,
movingTop,
L["Text8"]
)
movingTop = movingTop - labelContinueHeight
AJM.settingsControl.labelInformation18 = JambaHelperSettings:CreateContinueLabel(
AJM.settingsControl,
headingWidth,
column1Left,
movingTop,
L["Text9"]
)
movingTop = movingTop - labelContinueHeight
AJM.settingsControl.labelInformation19 = JambaHelperSettings:CreateContinueLabel(
AJM.settingsControl,
headingWidth,
column1Left,
movingTop,
L["Text10"]
)
--movingTop = movingTop - labelContinueHeight
--[[ movingTop = movingTop - buttonHeight * 3
AJM.settingsControl.buttonPushSettingsForAllModules = JambaHelperSettings:CreateButton(
AJM.settingsControl,
buttonPushAllSettingsWidth,
column2Left,
movingTop,
L["Full ChangeLog"],
AJM.ShowChangeLog,
L["Shows the Full changelog\nOpens a new Frame."]
)
--]]
-- Special thanks Heading
movingTop = movingTop - buttonHeight
JambaHelperSettings:CreateHeading( AJM.settingsControl, L["Special thanks:"], movingTop, false )
movingTop = movingTop - headingHeight
AJM.settingsControl.labelInformation20 = JambaHelperSettings:CreateContinueLabel(
AJM.settingsControl,
headingWidth,
column1Left,
movingTop,
L["To Michael 'Jafula' Miller who made Jamba"]
)
movingTop = movingTop - labelContinueHeight
AJM.settingsControl.labelInformation21 = JambaHelperSettings:CreateContinueLabel(
AJM.settingsControl,
headingWidth,
column1Left,
movingTop,
L["To Olipcs on dual-boxing.com for writing the FTL Helper module."]
)
movingTop = movingTop - labelContinueHeight
AJM.settingsControl.labelInformation22 = JambaHelperSettings:CreateContinueLabel(
AJM.settingsControl,
headingWidth,
column1Left,
movingTop,
L["To Schilm (Max Schilling) for Advanced Loot"]
)
-- Useful websites Heading
movingTop = movingTop - labelContinueHeight * 2
JambaHelperSettings:CreateHeading( AJM.settingsControl, L["Useful websites:"], movingTop, false )
movingTop = movingTop - headingHeight
AJM.settingsControl.labelInformation30 = JambaHelperSettings:CreateContinueLabel(
AJM.settingsControl,
headingWidth,
column2Left,
movingTop,
L["www.twitter.com/jenn_ebony"]
)
movingTop = movingTop - labelContinueHeight
AJM.settingsControl.labelInformation21 = JambaHelperSettings:CreateContinueLabel(
AJM.settingsControl,
headingWidth,
column2Left,
movingTop,
L["www.dual-boxing.com"]
)
movingTop = movingTop - labelContinueHeight
AJM.settingsControl.labelInformation22 = JambaHelperSettings:CreateContinueLabel(
AJM.settingsControl,
headingWidth,
column2Left,
movingTop,
L["www.isboxer.com"]
)
--CopyRight heading
movingTop = movingTop - labelContinueHeight * 4
AJM.settingsControl.labelInformation30 = JambaHelperSettings:CreateContinueLabel(
AJM.settingsControl,
headingWidth,
column1Left,
movingTop,
L["Copyright 2008-2016 Michael 'Jafula' Miller, Released Under The MIT License"]
)
return movingTop
end
function AJM:CoreSettingsCreate()
AJM.settingsControl = {}
-- Create the settings panel.
JambaHelperSettings:CreateSettings(
AJM.settingsControl,
AJM.moduleDisplayName,
AJM.parentDisplayName,
AJM.SendSettingsAllModules
)
local bottomOfInfo = AJM:CoreSettingsCreateInfo( JambaHelperSettings:TopOfSettings() )
AJM.settingsControl.widgetSettings.content:SetHeight( -bottomOfInfo )
end
-- Send core settings.
function AJM:JambaSendSettings()
JambaPrivate.Communications.SendSettings( AJM.moduleName, AJM.db )
end
function AJM:OnJambaProfileChanged()
AJM:SettingsRefresh()
end
function AJM:SettingsRefresh()
end
-- Core settings received.
function AJM:JambaOnSettingsReceived( characterName, settings )
--Checks character is not the the character that send the settings. Now checks the character has a realm on there name to match Jamba team list.
--characterName = JambaUtilities:AddRealmToNameIfMissing( characterName )
if characterName ~= AJM.characterName then
-- Update the settings.
-- TODO: What is this minimap icon?
AJM.db.showMinimapIcon = settings.showMinimapIcon
-- Refresh the settings.
AJM:SettingsRefresh()
-- Tell the player.
AJM:Print( L["Settings received from A."]( characterName ) )
-- Tell the team?
--AJM:JambaSendMessageToTeam( AJM.db.messageArea, L["Settings received from A."]( characterName ), false )
end
end
function AJM:LoadJambaSettings()
InterfaceOptionsFrameCancel_OnClick()
HideUIPanel( GameMenuFrame )
AJM:JambaChatCommand( "" )
end
-- Handle the chat command.
function AJM:JambaChatCommand( input )
if not input or input:trim() == "" then
JambaPrivate.SettingsFrame.Widget:Show()
JambaPrivate.SettingsFrame.WidgetTree:SelectByValue( AJM.moduleDisplayName )
JambaPrivate.SettingsFrame.Tree.ButtonClick( nil, nil, AJM.moduleDisplayName, false)
else
LibStub( "AceConfigCmd-3.0" ):HandleCommand( AJM.chatCommand, AJM.moduleName, input )
end
end
function AJM:ResetSettingsFrame()
AJM:Print( L["Attempting to reset the Jamba Settings Frame."] )
JambaPrivate.SettingsFrame.Widget:SetPoint("TOPLEFT", 0, 0)
JambaPrivate.SettingsFrame.Widget:SetWidth(770)
JambaPrivate.SettingsFrame.Widget:SetHeight(650)
JambaPrivate.SettingsFrame.Widget:Show()
end
-- Functions available from Jamba Core for other Jamba internal objects.
JambaPrivate.Core.RegisterModule = RegisterModule
JambaPrivate.Core.SendSettings = SendSettings
JambaPrivate.Core.OnSettingsReceived = OnSettingsReceived
JambaPrivate.Core.SendCommandToTeam = SendCommandToTeam
JambaPrivate.Core.SendCommandToMaster = SendCommandToMaster
JambaPrivate.Core.SendCommandToToon = SendCommandToToon
-- TODO: Remove send command to minions?
--JambaPrivate.Core.SendCommandToMinions = SendCommandToMinions
JambaPrivate.Core.OnCommandReceived = OnCommandReceived