-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathRotationBuilder.lua
More file actions
3253 lines (2828 loc) · 113 KB
/
RotationBuilder.lua
File metadata and controls
3253 lines (2828 loc) · 113 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
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
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
-- Action Options
-- Adding an Option instructions
-- 1. Add the new option to ROB_NewActionDefaults table below
-- 2. Create the gui control in RotationBuilder.xml search for "ADD_OPTIONS_BELOW_THIS_LINE"
-- 3. Create the on click, on_update functions for new option search IF NEEDED for "ADD_OPTION_FUNCTIONS_BELOW_THIS"
-- 4. Have to retrieve and set gui values search for "RETRIEVE_NEW_OPTIONS_BELOW"
-- 5. Make sure your script calls in XML dont call the wrong functions
-- Rotation Options
-- 1. Create the new option/gui in xml search for "ROB_RotationNameInputBox" as example
-- 2. Update the rotations options when user clicks create button search for "UPDATE_ROTATION_OPTIONS1"
-- 3. Update the rotations options when user clicks modify button search for "UPDATE_ROTATION_OPTIONS2"
-- 4. Create the functions for the xml search for "ROB_RotationNameInputBox_OnTextChanged" as example
-- 5. Add show new widgets in update ui search for "ADD_SHOW_ROTATION_OPTIONS"
-- 6. Add hide new widgeets in update ui search for "ADD_HIDE_ROTATION_OPTIONS"
-- 7. Add retrieve rotation settings search for "RETRIEVE_ROTATION_SETTINGS"
-- 8. Make sure your script calls in XML dont call the wrong functions
-- TODO PEL : Put globals in another file for better code separation.
ROB_VERSION = GetAddOnMetadata(ROB_PROJECT_NAME, "Version");
BINDING_HEADER_ROB = RotationBuilderUtils:localize('ROB_ADDON_NAME');
BINDING_NAME_ROB_OPEN = RotationBuilderUtils:localize('ROB_UI_TOGGLE');
BINDING_NAME_ROB_MULTI_TARGET = RotationBuilderUtils:localize('ui/keybinds/toggleMultiTarget/text');
BINDING_NAME_ROB_CUSTOM_CASE_1 = RotationBuilderUtils:localize('ui/keybinds/toggleCustomCase/text')..1;
BINDING_NAME_ROB_CUSTOM_CASE_2 = RotationBuilderUtils:localize('ui/keybinds/toggleCustomCase/text')..2;
ROB_UPDATE_INTERVAL = 0.2; -- How often the OnUpdate code will run (in seconds)
-- Scroll Frame Lines
local ROB_ROTATION_LIST_LINES = 9;
local ROB_ACTION_LIST_LINES = 21;
ROB_ROTATION_LIST_FRAME_HEIGHT = 16;
ROB_ACTION_LIST_FRAME_HEIGHT = 20;
-- Initial Options
local ROB_Options_Default = {
MiniMap = true;
MiniMapPos = 300;
MiniMapRad = 80;
LockIcons = true;
AllowOverwrite = false;
ExportBinds = false;
OldImportExport = false;
HideCD = false;
Enemy = false;
DisplayOnDeadTarget = true;
OnOff = false;
IconsX = 0;
IconsY = 0;
IconScale = 1;
UIScale = 1;
CurrentIconA = 1;
NextIconA = 1;
NextIconLocation = "BOTTOM";
loaddefault = true;
lastrotation = "";
updaterate = 5;
CABSkin = {};
NABSkin = {};
T1Skin = {};
T2Skin = {};
T3Skin = {};
T4Skin = {};
}
ROB_NewActionDefaults = {
--General Options---------------
v_spellname = "<spell name>",
v_actionicon = "",
b_maxcasts = false,
v_maxcasts = "",
b_lastcasted = false,
v_lastcasted = "",
b_moving = false,
b_notmoving = false,
b_gspellcost = false,
v_gspellcosttype = "",
v_gspellcost = "",
b_gunitpower = false,
v_gunitpowertype = "",
v_gunitpower = "",
b_charges = false,
v_charges = "",
b_othercharges = false,
v_othercharges = "",
v_otherchargesname = "",
b_checkothercd = false,
v_checkothercdname = "",
v_checkothercdvalue = "",
b_checkothercd2 = false,
v_checkothercd2name = "",
v_checkothercd2value = "",
b_duration = false,
v_duration = "",
v_durationstartedtime = 0,
b_notaspell = false,
b_debug = false,
b_disabled = false,
b_hasproc = false,
b_notinspellbook = false,
b_incombat = false,
b_notincombat = false,
b_spellInRange = false,
b_hasMinRange = false,
--Player Options---------------
b_p_hp = false,
v_p_hp = "",
b_p_needbuff = false,
v_p_needbuff = "",
b_p_havebuff = false,
v_p_havebuff = "",
b_p_needdebuff = false,
v_p_needdebuff = "",
b_p_havedebuff = false,
v_p_havedebuff = "",
b_p_unitpower = false,
v_p_unitpower = "",
v_p_unitpowertype = "",
b_p_unitpower2 = false,
v_p_unitpower2 = "",
v_p_unitpower2type = "",
b_p_runes = false,
v_p_runes = "",
b_p_knowspell = false,
v_p_knowspell = "",
b_p_knownotspell = false,
v_p_knownotspell = "",
b_p_isstealthed = false,
b_p_isnotstealthed = false,
--Target Options---------------
b_t_hp = false,
v_t_hp = "",
b_t_needsbuff = false,
v_t_needsbuff = "",
b_t_hasbuff = false,
v_t_hasbuff = "",
b_t_needsdebuff = false,
v_t_needsdebuff = "",
b_t_hasdebuff = false,
v_t_hasdebuff = "",
b_t_boss = false,
b_t_notaboss = false,
b_t_interrupt = false,
b_t_dispel = false,
b_t_spellsteal = false,
b_t_enrage = false,
--Pet Options---------------
b_pet_hp = false,
v_pet_hp = "",
b_pet_needsbuff = false,
v_pet_needsbuff = "",
b_pet_hasbuff = false,
v_pet_hasbuff = "",
b_pet_needstotem = false,
v_pet_needstotem = "",
v_pet_needstotemname = "",
b_pet_hastotem = false,
v_pet_hastotem = "",
v_pet_hastotemname = "",
}
ROB_ActionClipboard = nil;
local ROB_Initialized = false;
local ROB_SortedRotations = {}; -- Sorted rotation table
local ROB_EditingRotationTable = nil; -- Rotation table being edited
ROB_SelectedRotationName = nil; -- Selected Rotation Name
ROB_SelectedRotationSpec = nil; -- Selected Rotation Specialization
ROB_RotationMultiTargetEnabled = false; -- If we are seeking for a multi-target rotation.
local ROB_SelectedRotationIndex = nil; -- Selected Rotation Index
local ROB_SelectedActionIndex = nil; -- Selected Action Index
local ROB_CurrentActionName = nil; -- The current selected ActionName
local ROB_DropDownTableTemp = {}; -- Temporary drop down table to reuse
local ROB_DropDownStoreToTemp = nil; -- Temporary name of where to save dropdown selected value
local ROB_LAST_CASTED = nil; -- Last casted spell
local ROB_LAST_CASTED_TYPE = nil; -- Used to track if we updated the sequential casts on start or succeeded
local ROB_LAST_CASTED_COUNT = 0; -- How many time the last spell casted has been sequentially cast
ROB_CURRENT_ACTION = nil; -- The name of current ready action
local ROB_NEXT_ACTION = nil; -- The name of the next action ready
local ROB_ACTION_CD = nil; -- The cooldown of the current spell being checked
local ROB_ACTION_TIMELEFT = nil; -- The timeleft on the action debuff or buff used to sort which action is next
local ROB_TARGET_LAST_CASTED = nil; -- Used to output what spell was itnerrupted
local ROB_FOCUS_LAST_CASTED = nil; -- Used to output what spell was itnerrupted
local ROB_ACTION_GCD = 0;
local ROB_ACTION_CASTTIME = 0;
local ROB_ACTION_TEXTURE = nil;
local ROB_ACTION_COOLDOWN_COUNTER = 0;
local ROB_IN_COMBAT = false;
--libDataBroker stuff
local ROB_MENU_FRAME = nil;
local ROB_MENU = {};
local ROB_MENU_READY = false; -- The libDataBroker menu
local ROB_LAST_DEBUG = GetTime(); -- Last time we output debug
local ROB_LAST_DEBUG_MSG = nil; -- Last message we output debug
--libMasque stuff
local ROB_LM = nil; -- libMasque formerly called Button Facade
local ROB_LM_BG_CURRENT_ACTION = nil; -- Current action button group for libMasque
local ROB_LM_BG_NEXT_ACTION = nil; -- Next action button group for libMasque
local _InvSlots = {
["AmmoSlot"] = 0,
["HeadSlot"] = 1,
["NeckSlot"] = 2,
["ShoulderSlot"] = 3,
["ShirtSlot"] = 4,
["ChestSlot"] = 5,
["WaistSlot"] = 6,
["LegsSlot"] = 7,
["FeetSlot"] = 8,
["WristSlot"] = 9,
["HandsSlot"] = 10,
["Finger0Slot"] = 11,
["Finger1Slot"] = 12,
["Trinket0Slot"] = 13,
["Trinket1Slot"] = 14,
["BackSlot"] = 15,
["MainHandSlot"] = 16,
["SecondaryHandSlot"] = 17,
["RangedSlot"] = 18,
["TabardSlot"] = 19
}
function ROB_NewRotation()
return { SortedActions = {}, ActionList = {}, bindindex = 0};
end
function ROB_LoadDefaultRotations()
-- Load default rotations for the class.
local localizedClassName, englishClassName, classIndex = UnitClass("player");
RotationBuilder:loadDefaultRotations(englishClassName);
-- TODO PEL : localize this message.
print("Default rotations loaded!");
-- update rotation list
ROB_SortRotationList()
-- update the action list
ROB_ActionList_Update()
-- update rotation modify buttons
ROB_RotationModifyButtons_UpdateUI()
-- update rotation ui stuff
ROB_Rotation_Edit_UpdateUI()
end
------------------------------------------------------------------------
-- Menu functions
------------------------------------------------------------------------
local function ROB_SortMenu(item1, item2)
return item1.id < item2.id
end
local function ROB_MenuChangeRotation(self, _arg1)
ROB_SwitchRotation(_arg1, true)
end
local function ROB_MenuCreate(self, _level)
local level = _level or 1
local id = 1
local info = {}
ROB_MENU = {}
for id = 1, #ROB_SortedRotations, 1 do
info = {}
info.id = id
-- Manage rotation's name localization only for display.
info.text = RotationBuilderUtils:localize(ROB_SortedRotations[id])
info.icon = nil
info.arg1 = ROB_SortedRotations[id]
info.func = ROB_MenuChangeRotation
info.notCheckable = true
ROB_MENU[id] = info
end
table.sort(ROB_MENU, ROB_SortMenu)
end
local function ROB_MenuInit(self, _level)
local level = _level or 1
for _, value in pairs(ROB_MENU) do
UIDropDownMenu_AddButton(value, level)
end
end
-- TODO - ROB icon click for left button to change to on/off
function ROB_MenuOnClick(self, button)
if button == "LeftButton" then
if(ROB_Options.OnOff) then
ROB_Options.OnOff = false;
ROB_OptionsTabOnOffButton:SetChecked(false);
else
ROB_Options.OnOff = true;
ROB_OptionsTabOnOffButton:SetChecked(true);
end
elseif button == "RightButton" then
ROB_OnToggle();
end
end
function ROB_LoadDataBrokerPlugin()
LibStub:GetLibrary('LibDataBroker-1.1'):NewDataObject(RotationBuilderUtils:localize('ROB_ADDON_NAME'), {
type = 'launcher',
text = RotationBuilderUtils:localize('ROB_ADDON_NAME'),
icon = 'Interface\\Icons\\Spell_Arcane_PortalOrgrimmar',
OnClick = ROB_MenuOnClick,
OnTooltipShow = function(tooltip)
if not tooltip or not tooltip.AddLine then return end
tooltip:AddLine(RotationBuilderUtils:localize('ROB_UI_TITLE'))
tooltip:AddLine(RotationBuilderUtils:localize('ROB_UI_LDB_TT1'))
tooltip:AddLine(RotationBuilderUtils:localize('ROB_UI_LDB_TT2'))
end,
})
end
function ROB_OnSkin(_addon, _skinid, _gloss, _backdrop, _group, _button, _colors)
local _ROBSkin = {}
if _group == 'Current Action' then
_ROBSkin = ROB_Options["CABSkin"]
elseif _group == 'Next Action' then
_ROBSkin = ROB_Options["NABSkin"]
end
if _ROBSkin then
_ROBSkin[1] = _skinid
_ROBSkin[2] = _gloss
_ROBSkin[3] = _backdrop
_ROBSkin[4] = _group
_ROBSkin[5] = _button
_ROBSkin[6] = _colors
end
end
function ROB_LoadMasquePlugin()
if (LibMasque) then
ROB_LM = LibMasque("Button")
else
ROB_LM = LibStub('LibButtonFacade', true)
ROB_LM:RegisterSkinCallback(RotationBuilderUtils:localize('ROB_ADDON_NAME'), ROB_OnSkin, _skinid, _gloss, _backdrop, _group, _button, _colors)
end
ROB_LM:Group(RotationBuilderUtils:localize('ROB_ADDON_NAME'), 'Current Action'):AddButton(ROB_CurrentActionButton)
ROB_LM:Group(RotationBuilderUtils:localize('ROB_ADDON_NAME'), 'Current Action'):AddButton(ROB_NextActionButton)
if ROB_Options['CABSkin'] then ROB_LM:Group(RotationBuilderUtils:localize('ROB_ADDON_NAME'), 'Current Action'):Skin(unpack(ROB_Options["CABSkin"])) end
if ROB_Options['NABSkin'] then ROB_LM:Group(RotationBuilderUtils:localize('ROB_ADDON_NAME'), 'Next Action'):Skin(unpack(ROB_Options['NABSkin'])) end
end
function ROB_OnLoad(self)
self:RegisterEvent("ADDON_LOADED");
self:RegisterEvent("PLAYER_ENTERING_WORLD");
self:RegisterEvent("ACTIONBAR_UPDATE_COOLDOWN");
self:RegisterEvent("UNIT_SPELLCAST_SUCCEEDED");
self:RegisterEvent("UNIT_SPELLCAST_START");
self:RegisterEvent("UNIT_SPELLCAST_CHANNEL_START");
self:RegisterEvent("UNIT_SPELLCAST_CHANNEL_STOP");
self:RegisterEvent("ACTIVE_TALENT_GROUP_CHANGED");
self:RegisterEvent("PLAYER_REGEN_ENABLED");
self:RegisterEvent("PLAYER_REGEN_DISABLED");
-- hook command handler
SLASH_ROB1 = "/rob";
SlashCmdList["ROB"] = ROB_OnCommand;
-- create a dialog for list deletion
StaticPopupDialogs["ROB_PROMPT_LIST_DELETE"] =
{
text = RotationBuilderUtils:localize("ROB_PROMPT_LIST_DELETE"),
button1 = RotationBuilderUtils:localize("ROB_UI_YES_BUTTON"),
button2 = RotationBuilderUtils:localize("ROB_UI_CANCEL_BUTTON"),
OnAccept = function(self)
ROB_RotationDelete_OnAccept();
end,
OnCancel = function(self)
ROB_RotationDelete_OnCancel();
end,
timeout = 0,
exclusive = 1,
whileDead = 1,
hideOnEscape = 1
}
print(string.format(RotationBuilderUtils:localize("ROB_LOADED"), ROB_VERSION));
end
function ROB_OnEvent(self, event, ...)
local arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14, arg15, arg16 = ...;
local _spellname = nil
local _channelstart = false
if (event == "ADDON_LOADED") then
ROB_ADDON_Load(...);
elseif (event == "PLAYER_ENTERING_WORLD") then
ROB_PLAYER_Enter();
elseif (event == "ACTIVE_TALENT_GROUP_CHANGED") then
ROB_OnActiveTalentGroupChanged();
elseif (event == "ACTIONBAR_UPDATE_COOLDOWN" and not ROB_Options.HideCD) then
ROB_IconCooldown(arg1);
elseif (event == "PLAYER_REGEN_DISABLED") then
ROB_IN_COMBAT = true;
elseif (event == "PLAYER_REGEN_ENABLED") then
ROB_IN_COMBAT = false;
elseif (event == "UNIT_SPELLCAST_SUCCEEDED" or event == "UNIT_SPELLCAST_START" or event == "UNIT_SPELLCAST_CHANNEL_START" or event == "UNIT_SPELLCAST_CHANNEL_STOP") then
if (arg1 == "player") then
if (ROB_SpellIsInRotation(arg3)) then
if (event == "UNIT_SPELLCAST_START") then
ROB_LAST_CASTED_TYPE = "NORMAL"
end
if (event == "UNIT_SPELLCAST_CHANNEL_START") then
ROB_LAST_CASTED_TYPE = "CHANNEL"
end
if ((event == "UNIT_SPELLCAST_SUCCEEDED" and ROB_LAST_CASTED_TYPE == nil) or (event == "UNIT_SPELLCAST_SUCCEEDED" and ROB_LAST_CASTED_TYPE == "NORMAL") or (event == "UNIT_SPELLCAST_SUCCEEDED" and ROB_LAST_CASTED_TYPE == "CHANNEL" and _channelstart == false)) then
if (arg3 == ROB_LAST_CASTED) then
--increment the last casted count
ROB_LAST_CASTED_COUNT = ROB_LAST_CASTED_COUNT + 1
if (ROB_SpellIsInRotation(arg3)) then ROB_LAST_CASTED = arg3; end
else
--start the count over
ROB_LAST_CASTED_COUNT = 1
if (ROB_SpellIsInRotation(arg3)) then ROB_LAST_CASTED = arg3; end
end
_channelstart = true
if (event == "UNIT_SPELLCAST_SUCCEEDED" and ROB_LAST_CASTED_TYPE and ROB_LAST_CASTED_TYPE == "CHANNEL") then
--If ROB_LAST_CASTED_TYPE was CHANNEL then dont update the last casted because blizzard fires a UNIT_SPELLCAST_SUCCEEDED while channel is still going
else
ROB_LAST_CASTED_TYPE = nil
end
end
if (event == "UNIT_SPELLCAST_CHANNEL_STOP") then
_channelstart = false
end
end
end
end
end
function ROB_ADDON_Load(addon)
local key, value;
if (addon ~= ROB_PROJECT_NAME) then return end
-- Check here if we need to clean up rotation builder installation.
RotationBuilder:cleanUpInstallationOnNeed();
for key, value in pairs(ROB_Options_Default) do
if (ROB_Options[key] == nil) then
ROB_Options[key] = value;
end
end
if (LibStub and LibStub:GetLibrary('LibDataBroker-1.1', true)) then
ROB_LoadDataBrokerPlugin()
end
if (LibStub and LibStub:GetLibrary('LibButtonFacade', true)) then
ROB_LoadMasquePlugin()
end
-- Initialize frame
ROB_FrameVersionFrameVersion:SetText(ROB_VERSION);
end
function ROB_PLAYER_Enter()
if (ROB_Initialized) then
return;
end
ROB_Initialized = true;
-- Load or update default rotations.
ROB_LoadDefaultRotations();
if (ROB_Options["lastrotation"] and ROB_Options["lastrotation"] ~= nil and ROB_Options["lastrotation"] ~= "") then
--Weve loaded once before do we have a last loaded rotation?
ROB_SwitchRotation(ROB_Options["lastrotation"], true);
else
-- If we don't have a previously selected rotation, then select the one which match the specialization if it exist.
ROB_SwitchRotation(RotationBuilder:findRotationBySpecializationID(GetSpecialization()), true);
end
-- Initialize options tab
ROB_OptionsTabMiniMapButton:SetChecked(ROB_Options.MiniMap);
ROB_OptionsTabMiniMapPosSlider:SetValue(ROB_Options.MiniMapPos);
ROB_OptionsTabMiniMapPosSliderText:SetText(ROB_Options.MiniMapPos);
ROB_OptionsTabMiniMapRadSlider:SetValue(ROB_Options.MiniMapRad);
ROB_OptionsTabMiniMapRadSliderText:SetText(ROB_Options.MiniMapRad);
if ROB_Options.LockIcons then
ROB_IconsFrame:SetMovable(false);
ROB_IconsFrame:EnableMouse(false);
ROB_OptionsTabLockIconsButton:SetChecked(true);
else
ROB_IconsFrame:SetMovable(true);
ROB_IconsFrame:EnableMouse(true);
ROB_OptionsTabLockIconsButton:SetChecked(false);
end
ROB_SetNextActionLocation();
if (ROB_Options.IconsX == 0 and ROB_Options.IconsY == 0) then
ROB_IconsFrame:ClearAllPoints();
ROB_IconsFrame:SetPoint("CENTER");
ROB_Options.IconsX = ROB_IconsFrame:GetLeft() * ROB_Options.IconScale
ROB_Options.IconsY = ROB_IconsFrame:GetBottom() * ROB_Options.IconScale
else
ROB_IconsFrame:SetPoint("BOTTOMLEFT", UIParent, "BOTTOMLEFT", ROB_Options.IconsX / ROB_IconsFrame:GetEffectiveScale(), ROB_Options.IconsY / ROB_IconsFrame:GetEffectiveScale())
end
ROB_Frame:SetScale(ROB_Options.UIScale)
ROB_OptionsUIScaleValue:SetText(ROB_Options.UIScale)
ROB_IconsFrame:SetScale(ROB_Options.IconScale)
ROB_CurrentActionButton:SetScale(ROB_Options.IconScale)
ROB_CurrentActionButton:EnableMouse(false)
ROB_NextActionButton:SetScale(ROB_Options.IconScale)
ROB_NextActionButton:EnableMouse(false)
ROB_OptionsTabIconScaleSlider:SetValue(ROB_Options.IconScale);
ROB_OptionsTabIconScaleSliderText:SetText(ROB_Options.IconScale);
ROB_OptionsTabCurrentIconAlpha:SetText(ROB_Options.CurrentIconA);
ROB_CurrentActionButton:SetAlpha(ROB_Options.CurrentIconA);
ROB_OptionsTabNextIconAlpha:SetText(ROB_Options.NextIconA);
ROB_NextActionButton:SetAlpha(ROB_Options.NextIconA);
ROB_CurrentActionButtonNormalTexture:Hide()
ROB_NextActionButtonNormalTexture:Hide()
ROB_OptionsTabAllowOverwriteButton:SetChecked(ROB_Options.AllowOverwrite);
ROB_OptionsTabExportBindsButton:SetChecked(ROB_Options.ExportBinds);
ROB_OptionsTabHideCooldownsButton:SetChecked(ROB_Options.HideCD);
ROB_OptionsTabEnemyButton:SetChecked(ROB_Options.Enemy);
ROB_OptionsTabDisplayOnDeadTargetButton:SetChecked(ROB_Options.DisplayOnDeadTarget);
ROB_UPDATE_INTERVAL = 1 / ROB_Options.updaterate
ROB_OptionsTabUpdateRateSlider:SetValue(ROB_Options.updaterate);
ROB_OptionsTabUpdateRateSliderText:SetText(ROB_Options.updaterate);
ROB_OptionsTabOnOffButton:SetChecked(ROB_Options.OnOff);
ROB_MiniMapButton_Update();
-- sort rotation list
ROB_SortRotationList();
-- get the character GCD
ROB_ACTION_GCD = ROB_GetGCD();
-- update the action list
ROB_ActionList_Update();
-- update rotation modify buttons
ROB_RotationModifyButtons_UpdateUI();
-- update rotation ui stuff
ROB_Rotation_Edit_UpdateUI();
end
--- Change the rotation to match the specialization.
function ROB_OnActiveTalentGroupChanged()
ROB_SwitchRotation(RotationBuilder:findRotationBySpecializationID(GetSpecialization()), true);
end
--- Change the selected rotation to match the one with the correct specialization and multi-target enable.
function ROB_ToggleMultiTargetRotation()
RotationBuilder["multiTargetEnabled"] = not RotationBuilder["multiTargetEnabled"];
if (RotationBuilder["multiTargetEnabled"]) then
print(RotationBuilderUtils:localize('msg/action/keybinds/multiTarget/enabled'));
else
print(RotationBuilderUtils:localize('msg/action/keybinds/multiTarget/disabled'));
end
ROB_SwitchRotation(RotationBuilder:findRotationBySpecializationID(GetSpecialization()), true);
end
function ROB_ToggleCustomCase(toggle)
RotationBuilder["customCase"]["case"..toggle] = not RotationBuilder["customCase"]["case"..toggle];
if(RotationBuilder["customCase"]["case"..toggle]) then
print(RotationBuilderUtils:localize('msg/action/keybinds/customCase/enabled')..toggle)
else
print(RotationBuilderUtils:localize('msg/action/keybinds/customCase/disabled')..toggle)
end
end
function ROB_OnCommand(cmd)
local help, helpIx, msg;
if (cmd == "") then
help = true;
elseif (cmd == "help") then
help = true;
elseif (cmd == "show") then
ROB_OnToggle(self, true);
elseif (cmd == "on") then
ROB_Options.OnOff = false;
ROB_OptionsTabOnOffButton:SetChecked(false);
elseif (cmd == "off") then
ROB_Options.OnOff = true;
ROB_OptionsTabOnOffButton:SetChecked(true);
elseif (string.sub(cmd, 1, 2) == "r ") then
ROB_SwitchRotation(string.sub(cmd, 3), true);
elseif (cmd == "hide") then
ROB_OnToggle(self, false);
elseif (cmd == "resetui") then
ROB_Options_ResetUI_OnClick(self);
else
help = true;
end
if (help == true) then
print("Rotation Builder commands:")
print(" help - display this help")
print(" show - show Rotation Builder")
print(" on - activate Rotation Builder")
print(" off - deactivate Rotation Builder")
print(" r ShadowMelt - Selects the ShadowMelt rotation")
print(" hide - hide Rotation Builder")
print(" resetui - reset Rotation Builder window positions")
end
end
function ROB_OnToggle(self, visible)
_G["ROB_SpellNameInputBox"]:SetFocus()
_G["ROB_SpellNameInputBox"]:ClearFocus()
if ((visible == false) or ((visible == nil) and ROB_Frame:IsVisible())) then
PlaySound(822, "SFX");
ROB_Frame:Hide();
elseif ((visible == true) or ((visible == nil) and not ROB_Frame:IsVisible())) then
PlaySound(821, "SFX");
ROB_Frame:Show();
ROB_RotationTab:Show()
ROB_MainWindowSwitchToTab(ROB_FrameTab1)
ROB_OptionsTab:Hide()
end
end
function ROB_MainWindowSwitchToTab(self)
ROB_RotationTab:Hide()
ROB_OptionsTab:Hide()
ROB_FrameTab1:UnlockHighlight()
ROB_FrameTab2:UnlockHighlight()
self:LockHighlight()
if (self:GetName() == "ROB_FrameTab1") then ROB_RotationTab:Show() end
if (self:GetName() == "ROB_FrameTab2") then ROB_OptionsTab:Show() end
end
function ROB_ActionOptionsSwitchToTab(self)
ROB_GeneralActionOptionsTab:Hide()
ROB_PlayerActionOptionsTab:Hide()
ROB_TargetActionOptionsTab:Hide()
ROB_PetActionOptionsTab:Hide()
ROB_RotationTabTab1:UnlockHighlight()
ROB_RotationTabTab2:UnlockHighlight()
ROB_RotationTabTab3:UnlockHighlight()
ROB_RotationTabTab4:UnlockHighlight()
self:LockHighlight()
if (self:GetName() == "ROB_RotationTabTab1") then ROB_GeneralActionOptionsTab:Show(); end
if (self:GetName() == "ROB_RotationTabTab2") then ROB_PlayerActionOptionsTab:Show(); end
if (self:GetName() == "ROB_RotationTabTab3") then ROB_TargetActionOptionsTab:Show(); end
if (self:GetName() == "ROB_RotationTabTab4") then ROB_PetActionOptionsTab:Show(); end
end
function ROB_Close_OnClick(self)
ROB_OnToggle(self, false);
end
function ROB_RotationListButton_OnClick(self)
-- ignore if we are editing
if (ROB_EditingRotationTable ~= nil) then
return;
end
ROB_SelectedRotationIndex = self:GetID() + FauxScrollFrame_GetOffset(ROB_RotationScrollFrame);
ROB_SelectedRotationName = ROB_SortedRotations[ROB_SelectedRotationIndex];
ROB_SelectedRotationSpec = tonumber(ROB_Rotations[ROB_SortedRotations[ROB_SelectedRotationIndex]]["specID"]);
ROB_RotationMultiTargetEnabled = ROB_Rotations[ROB_SortedRotations[ROB_SelectedRotationIndex]]["isMultiTarget"];
ROB_SwitchRotation(ROB_SelectedRotationName, true);
-- update rotation list
ROB_SortRotationList();
-- update the action list
ROB_ActionList_Update();
-- update rotation modify buttons
ROB_RotationModifyButtons_UpdateUI();
-- update rotation ui stuff
ROB_Rotation_Edit_UpdateUI();
end
function ROB_SwitchRotation(RotationID, _byName)
local _MatchingRotationName;
if(not RotationID or RotationID == "") then
return;
end
--if we are modififying a rotation dont switch to a different one
if (ROB_EditingRotationTable ~= nil) then
--just force a save and switch the rotation
ROB_Save_OnClick(self)
end
-- Select a rotation by its name or its index.
if (_byName) then
ROB_SelectedRotationName = RotationID
else
local index = 1;
for key, value in pairs(ROB_Rotations) do
if (index == RotationID) then
_MatchingRotationName = key
break
end
index = index + 1;
end
if (not _MatchingRotationName) then
print(RotationBuilderUtils:localize('ROB_UI_DEBUG_PREFIX')..RotationBuilderUtils:localize('ROB_UI_ROTATION_E1'))
return;
end
ROB_SelectedRotationName = _MatchingRotationName
end
if (ROB_Rotations[ROB_SelectedRotationName] ~= nil and ROB_Rotations[ROB_SelectedRotationName].SortedActions ~= nil) then
for key, value in pairs(ROB_Rotations[ROB_SelectedRotationName].SortedActions) do
--reset the last casted time for spells that wait specified durations
ROB_Rotations[ROB_SelectedRotationName].ActionList[value].v_durationstartedtime = 0
end
print(RotationBuilderUtils:localize('msg/action/switch_rotation')..RotationBuilderUtils:localize(ROB_SelectedRotationName))
ROB_CURRENT_ACTION = nil
ROB_NEXT_ACTION = nil
ROB_SetButtonTexture(ROB_CurrentActionButton, GetSpellTexture(""))
ROB_CurrentActionButtonHotKey:SetText("")
ROB_CurrentActionButton:Show()
ROB_SetButtonTexture(ROB_NextActionButton, GetSpellTexture(""))
ROB_NextActionButtonHotKey:SetText("")
ROB_NextActionButton:Show()
ROB_Options["lastrotation"] = ROB_SelectedRotationName
else
print(RotationBuilderUtils:localize('ROB_UI_DEBUG_PREFIX')..RotationID.." "..RotationBuilderUtils:localize('ROB_UI_ROTATION_E2'))
end
ROB_RotationModifyButtons_UpdateUI()
-- update rotation list
ROB_SortRotationList();
-- update the action list
ROB_ActionList_Update();
-- update rotation ui stuff
ROB_Rotation_Edit_UpdateUI();
end
function ROB_RotationCreateButton_OnClick(self)
-- start a new empty list
ROB_EditingRotationTable = ROB_NewRotation();
ROB_RotationMultiTargetCheckbox:Show();
-- new name prompt
ROB_SelectedRotationName = "<rotation name>";
ROB_SelectedRotationSpec = ""
ROB_RotationMultiTargetEnabled = false;
-- UPDATE_ROTATION_OPTIONS1
ROB_RotationNameInputBox:SetText(ROB_SelectedRotationName);
ROB_RotationSpecInputBox:SetText(ROB_SelectedRotationSpec);
ROB_RotationMultiTargetCheckbox:SetChecked(ROB_RotationMultiTargetEnabled);
-- update the action list
ROB_ActionList_Update();
-- update rotation modify buttons
ROB_RotationModifyButtons_UpdateUI();
-- update rotation ui stuff
ROB_Rotation_Edit_UpdateUI();
-- set focus to name and highlight current text
ROB_RotationNameInputBox:SetFocus(true);
ROB_RotationNameInputBox:HighlightText();
end
function ROB_ModifyRotationButton_OnClick(self)
-- copy the selected list
ROB_SelectedRotationName = ROB_SortedRotations[ROB_SelectedRotationIndex];
ROB_SelectedRotationSpec = tonumber(ROB_Rotations[ROB_SelectedRotationName]["specID"]);
if not ROB_SelectedRotationSpec then
ROB_SelectedRotationSpec = ""
end
ROB_RotationMultiTargetCheckbox:Show();
ROB_RotationMultiTargetEnabled = ROB_Rotations[ROB_SelectedRotationName]["isMultiTarget"];
ROB_EditingRotationTable = ROB_CopyTable(ROB_Rotations[ROB_SelectedRotationName]);
-- UPDATE_ROTATION_OPTIONS2
ROB_RotationNameInputBox:SetText(ROB_SelectedRotationName);
ROB_RotationSpecInputBox:SetText(ROB_SelectedRotationSpec);
ROB_RotationMultiTargetCheckbox:SetChecked(ROB_RotationMultiTargetEnabled);
--Always clear the current action because it may be leftover from a previous rotation
ROB_CurrentActionName = nil
-- update the action list
ROB_ActionList_Update();
-- update rotation modify buttons
ROB_RotationModifyButtons_UpdateUI();
-- update rotation ui stuff
ROB_Rotation_Edit_UpdateUI();
end
function ROB_RotationListDeleteButton_OnClick(self)
StaticPopup_Show("ROB_PROMPT_LIST_DELETE");
end
function ROB_RotationDelete_OnAccept()
ROB_Rotations[ROB_SortedRotations[ROB_SelectedRotationIndex]] = nil;
ROB_SelectedRotationIndex = nil;
ROB_SelectedRotationName = nil;
-- update rotation list
ROB_SortRotationList();
-- update the action list
ROB_ActionList_Update();
-- update rotation modify buttons
ROB_RotationModifyButtons_UpdateUI();
-- update rotation ui stuff
ROB_Rotation_Edit_UpdateUI();
-- recreate the menu
ROB_MenuCreate()
end
function ROB_RotationDelete_OnCancel()
end
function ROB_RotationNameInputBox_OnTextChanged(self)
local _text = self:GetText()
if (string.find(_text, "%[") or string.find(_text, "%]") or string.find(_text, ",")) then
print(RotationBuilderUtils:localize('ROB_UI_ADD_ROTATION_CFAIL'))
return
end
ROB_SelectedRotationName = ROB_RotationNameInputBox:GetText();
ROB_Rotation_Edit_UpdateUI();
end
function ROB_RotationSpecInputBox_OnTextChanged(self)
ROB_SelectedRotationSpec = tonumber(ROB_RotationSpecInputBox:GetText())
ROB_Rotation_Edit_UpdateUI();
end
function ROB_RotationMultiTargetCheckbox_OnToggle(self)
ROB_RotationMultiTargetEnabled = self:GetChecked();
ROB_Rotation_Edit_UpdateUI();
end
function ROB_Save_OnClick(self)
local _lastEditedRotation = ROB_SelectedRotationName
-- Replace the old rotation with the new one.
ROB_Rotations[ROB_SelectedRotationName] = ROB_EditingRotationTable;
ROB_Rotations[ROB_SelectedRotationName]["specID"] = ROB_SelectedRotationSpec;
ROB_Rotations[ROB_SelectedRotationName]["isMultiTarget"] = ROB_RotationMultiTargetEnabled;
-- update rotation list
ROB_SortRotationList();
-- and discard to reset editing
ROB_Discard_OnClick(self);
ROB_RotationMultiTargetCheckbox:Hide();
ROB_SwitchRotation(_lastEditedRotation, true)
end
function ROB_Discard_OnClick(self)
-- smoke the edit list and edit name
ROB_EditingRotationTable = nil;
ROB_SelectedActionIndex = nil;
ROB_SelectedRotationName = nil;
table.wipe(ROB_DropDownTableTemp)
ROB_DropDownStoreToTemp = nil;
-- update lists edit
ROB_ActionList_Update();
-- update rotation modify buttons
ROB_RotationModifyButtons_UpdateUI();
-- update rotation ui stuff
ROB_Rotation_Edit_UpdateUI();
end
function ROB_ActionListButton_OnClick(self, button)
if (ROB_EditingRotationTable == nil) then
return
end
ROB_SelectedActionIndex = self:GetID() + FauxScrollFrame_GetOffset(ROB_ActionListScrollFrame);
ROB_CurrentActionName = ROB_EditingRotationTable["SortedActions"][ROB_SelectedActionIndex]
-- update the action list
ROB_ActionList_Update();
-- update the ui stuff
ROB_Rotation_Edit_UpdateUI();
end
function ROB_ActionListButton_OnLeave(self)
-- hide tooltips
GameTooltip:Hide();
ROB_Tooltip:Hide();
end
function ROB_ActionListTrash_OnClick(self)
local ActionID;
if (ROB_EditingRotationTable == nil) then
return;
end
-- calculate selected item
ActionID = self:GetParent():GetID() + FauxScrollFrame_GetOffset(ROB_ActionListScrollFrame);
-- first, kill the list's item selectedrotation
ROB_EditingRotationTable.ActionList[ROB_EditingRotationTable["SortedActions"][ActionID]] = nil;
-- and remove from the sort
table.remove(ROB_EditingRotationTable.SortedActions, ActionID);
ROB_SelectedActionIndex = nil
ROB_CurrentActionName = nil
-- update the action list
ROB_ActionList_Update();
-- update rotation ui stuff
ROB_Rotation_Edit_UpdateUI();
end
function ROB_Lists_Edit_MoveUp(self)
local itemID;
-- cannot move above first row
if (ROB_SelectedActionIndex > 1) then
-- swap the item order in the edit list
itemID = ROB_EditingRotationTable["SortedActions"][ROB_SelectedActionIndex];
ROB_EditingRotationTable["SortedActions"][ROB_SelectedActionIndex] = ROB_EditingRotationTable["SortedActions"][ROB_SelectedActionIndex - 1];
ROB_EditingRotationTable["SortedActions"][ROB_SelectedActionIndex - 1] = itemID;
-- decrement selected item
ROB_SelectedActionIndex = ROB_SelectedActionIndex - 1;
-- update ui stuff
ROB_ActionList_Update();
ROB_Rotation_Edit_UpdateUI();
end
end
function ROB_Lists_Edit_MoveDown(self)
local itemID;
-- cannot move below last row
if (ROB_SelectedActionIndex < #ROB_EditingRotationTable.SortedActions) then
-- swap the item order in the edit list
itemID = ROB_EditingRotationTable["SortedActions"][ROB_SelectedActionIndex];
ROB_EditingRotationTable["SortedActions"][ROB_SelectedActionIndex] = ROB_EditingRotationTable["SortedActions"][ROB_SelectedActionIndex + 1];
ROB_EditingRotationTable["SortedActions"][ROB_SelectedActionIndex + 1] = itemID;
-- increment selected item
ROB_SelectedActionIndex = ROB_SelectedActionIndex + 1;
-- update ui stuff
ROB_ActionList_Update();
ROB_Rotation_Edit_UpdateUI();
end
end
function ROB_PasteActionOnAccept(_text)
local NewActionAlreadyExists = false