-
Notifications
You must be signed in to change notification settings - Fork 71
Expand file tree
/
Copy pathGuideWindow.lua
More file actions
2499 lines (2211 loc) · 88.2 KB
/
GuideWindow.lua
File metadata and controls
2499 lines (2211 loc) · 88.2 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
local addonName, addon = ...
local RXPGuides = addon.RXPGuides
local _, class = UnitClass("player")
local _G = _G
local fmt,tinsert = string.format, table.insert
local LibDD = LibStub:GetLibrary("LibUIDropDownMenu-4.0", true)
-- Alias addon.locale.Get
local L = addon.locale.Get
local BackdropTemplate = BackdropTemplateMixin and "BackdropTemplate" or nil
function addon.SetResizeBounds(frame, width, height)
if frame.SetResizeBounds then
frame:SetResizeBounds(width, height)
else
frame:SetMinResize(width, height)
end
end
addon.width, addon.height = 235, 125 -- Default width/height
local RXPFrame = CreateFrame("Frame", "RXPFrame", UIParent, BackdropTemplate)
addon.RXPFrame = RXPFrame
addon.enabledFrames["RXPFrame"] = RXPFrame
RXPFrame.IsFeatureEnabled = function()
return not addon.settings.profile.hideGuideWindow,false
end
local BottomFrame = CreateFrame("Frame", "$parent_bottomFrame", RXPFrame,
BackdropTemplate)
local GuideName = CreateFrame("Frame", "$parentGuideName", RXPFrame,
BackdropTemplate)
local Footer = CreateFrame("Frame", "$parentGuideName", RXPFrame,
BackdropTemplate)
local ScrollFrame = CreateFrame("ScrollFrame", "$parentScrollFrame",
BottomFrame, "UIPanelScrollFrameTemplate")
local CurrentStepFrame = CreateFrame("Frame", nil, RXPFrame)
local ScrollChild = CreateFrame("Frame", "$parent_steps", BottomFrame,
BackdropTemplate)
local MenuFrame = CreateFrame("Frame", "RXPG_MenuFrame", UIParent,
"UIDropDownMenuTemplate")
RXPFrame.BottomFrame = BottomFrame
RXPFrame.GuideName = GuideName
RXPFrame.Footer = Footer
RXPFrame.CurrentStepFrame = CurrentStepFrame
RXPFrame.ScrollFrame = ScrollFrame
RXPFrame.ScrollChild = ScrollChild
RXPFrame.MenuFrame = MenuFrame
function RXPFrame:UpdateVisuals()
BottomFrame:ClearBackdrop()
BottomFrame:SetBackdrop(RXPFrame.backdrop.edge)
BottomFrame:SetBackdropColor(unpack(addon.colors.background))
if RXPFrame.activeItemFrame then
RXPFrame.activeItemFrame:ClearBackdrop()
RXPFrame.activeItemFrame:SetBackdrop(RXPFrame.backdrop.edge)
RXPFrame.activeItemFrame:SetBackdropColor(
unpack(addon.colors.background))
end
GuideName:ClearBackdrop()
GuideName:SetBackdrop(RXPFrame.backdrop.guideName)
GuideName:SetBackdropColor(unpack(addon.colors.background))
Footer:ClearBackdrop()
Footer:SetBackdrop(RXPFrame.backdrop.guideName)
Footer:SetBackdropColor(unpack(addon.colors.background))
Footer.bg:SetTexture(addon.GetTexture("rxp-banner"))
GuideName.bg:SetTexture(addon.GetTexture("rxp-banner"))
GuideName.icon:SetTexture(addon.GetTexture("rxp_logo-64"))
GuideName.classIcon:SetTexture(addon.GetTexture(class))
Footer.cog:SetNormalTexture(addon.GetTexture("rxp_cog-32"))
RXPFrame.UpdateScrollBar()
end
function addon.ReloadStep()
addon.SetStep(RXPCData.currentStep)
end
function addon.RenderFrame(themeUpdate,isLoading)
addon:LoadActiveTheme()
-- TODO better handle themes
addon.colors = addon.activeTheme
--TODO: Add UpdateVisuals function to every frame under enabledFrames
for _,frame in pairs(addon.enabledFrames) do
if frame.UpdateVisuals then
frame:UpdateVisuals(true)
end
end
if not themeUpdate then
RXPFrame.GenerateMenuTable()
end
if addon.currentGuide and not isLoading then
addon:ReloadGuide(true)
end
end
RXPFrame.backdrop = {}
RXPFrame.defaultBackground = {
edge = "Interface/BUTTONS/WHITE8X8",
bottom = "Interface/BUTTONS/WHITE8X8",
}
RXPFrame.defaultEdges = {
edge = "Interface/AddOns/" .. addonName .. "/Textures/rxp-borders",
guideName = "Interface/AddOns/" .. addonName .. "/Textures/rxp-borders",
}
RXPFrame.backdrop.edge = {
bgFile = "Interface/BUTTONS/WHITE8X8",
-- edgeFile = "Interface/BUTTONS/WHITE8X8",
-- edgeFile = "Interface/ARENAENEMYFRAME/UI-Arena-Border",
edgeFile = addon.GetTexture("rxp-borders"),
tile = true,
edgeSize = 8,
tileSize = 8,
insets = {left = 4, right = 2, top = 2, bottom = 4}
}
RXPFrame.backdrop.guideName = {
edgeFile = addon.GetTexture("rxp-borders"),
edgeSize = 8,
insets = {left = 4, right = 2, top = 2, bottom = 4}
}
RXPFrame.backdrop.bottom = {
bgFile = "Interface/BUTTONS/WHITE8X8",
tile = true,
tileSize = 16
--edgeSize = 1,
--insets = {left = 0, right = 0, top = -1, bottom = -1}
}
function addon.SetupGuideWindow()
-- These were in-line, but now rely on settings
BottomFrame:SetBackdrop(RXPFrame.backdrop.edge)
BottomFrame:SetBackdropColor(unpack(addon.colors.background))
GuideName:SetBackdrop(RXPFrame.backdrop.guideName)
GuideName:SetBackdropColor(unpack(addon.colors.background))
GuideName.text:SetFont(addon.font, 11, "")
GuideName.text:SetText(L(
"Welcome to RestedXP Guides\nRight click to pick a guide"))
GuideName.text:SetTextColor(unpack(addon.activeTheme.textColor))
Footer.text:SetFont(addon.font, 9, "")
if addon.player.beta then
Footer.text:SetText(fmt("%s %s", addon.title, addon.release))
else
Footer.text:SetText(fmt("RXP Beta %s %d/%d", addon.release, addon.minGuideVersion ,addon.maxGuideVersion))
end
Footer.text:SetTextColor(unpack(addon.activeTheme.textColor))
GuideName.bg:SetTexture(addon.GetTexture("rxp-banner"))
Footer:SetBackdrop(RXPFrame.backdrop.guideName)
Footer:SetBackdropColor(unpack(addon.colors.background))
Footer.bg:SetTexture(addon.GetTexture("rxp-banner"))
GuideName.icon:SetTexture(addon.GetTexture("rxp_logo-64"))
GuideName.classIcon:SetTexture(addon.GetTexture(class))
Footer.cog:SetNormalTexture(addon.GetTexture("rxp_cog-32"))
RXPFrame.UpdateScrollBar()
end
RXPFrame:SetScript("OnShow", addon.PLAYER_ENTERING_WORLD)
RXPFrame:SetScript("OnHide", addon.PLAYER_LEAVING_WORLD)
RXPFrame:Show()
RXPFrame:SetMovable(true)
RXPFrame:SetClampedToScreen(true)
RXPFrame:SetResizable(true)
addon.SetResizeBounds(RXPFrame, 220, 20)
local IsFrameShown = function(frame,step)
step = step or (frame and frame.step)
if not step then
return true
elseif step.hidewindow or step.hidetip then
return false
elseif step.optional and (frame and frame.bottom) then
return false
end
return true
end
local function SetStepFrameAnchor()
local frame = CurrentStepFrame
local scale = RXPFrame:GetScale()
-- local bars = RXPFrame.BarContainer
local function SetTop()
frame:ClearAllPoints()
frame:SetPoint("BOTTOMLEFT", GuideName, "TOPLEFT", 0, 2)
frame:SetPoint("BOTTOMRIGHT", GuideName, "TOPRIGHT", 0, 2)
--[[if bars then
bars:ClearAllPoints()
bars:SetPoint("TOPLEFT",RXPFrame,"BOTTOMLEFT",7,-5)
bars:SetPoint("TOPRIGHT",RXPFrame,"BOTTOMRIGHT",-7,-5)
end]]
frame.anchor = "TOP"
end
local function SetBottom()
frame:ClearAllPoints()
frame:SetPoint("TOPLEFT", RXPFrame, "BOTTOMLEFT", 3, 0)
frame:SetPoint("TOPRIGHT", RXPFrame, "BOTTOMRIGHT", -3, 0)
--[[if bars then
bars:ClearAllPoints()
bars:SetPoint("TOPLEFT",CurrentStepFrame,"BOTTOMLEFT",3,0)
bars:SetPoint("TOPRIGHT",CurrentStepFrame,"BOTTOMRIGHT",-3,0)
end]]
frame.anchor = "BOTTOM"
end
if addon.settings.profile.anchorOrientation == "top" then
SetTop()
if (frame:GetTop() * scale > GetScreenHeight()) then SetBottom() end
if frame:GetBottom() * scale < 0 then SetTop() end
else
SetBottom()
if frame:GetBottom() * scale < 0 then SetTop() end
if (frame:GetTop() * scale > GetScreenHeight()) then SetBottom() end
end
addon:SortTimers()
end
RXPFrame.SetStepFrameAnchor = SetStepFrameAnchor
local isResizing
RXPFrame.OnMouseDown = function(self, button, resize)
if addon.settings.profile.lockFrames then return end
if resize or IsAltKeyDown() and
not (addon.currentGuide and addon.currentGuide.hidewindow) then
RXPFrame:StartSizing("BOTTOMRIGHT")
RXPFrame:SetScript("OnUpdate", RXPFrame.BottomFrame.UpdateFrame)
isResizing = true
else
RXPFrame:StartMoving()
end
end
RXPFrame.OnMouseUp = function(self, button)
RXPFrame:StopMovingOrSizing()
if isResizing then
addon.settings.profile.frameHeight = RXPFrame:GetHeight()
addon.SetStep(RXPCData.currentStep)
RXPFrame:SetScript("OnUpdate", nil)
end
SetStepFrameAnchor()
addon.UpdateItemFrame()
isResizing = false
addon.settings:SaveFramePositions()
end
RXPFrame:SetScript("OnMouseDown", RXPFrame.OnMouseDown)
RXPFrame:SetScript("OnMouseUp", RXPFrame.OnMouseUp)
RXPFrame:EnableMouse(1)
local stepPos = {}
local lastScrollValue
function BottomFrame:StepScroll(n)
local value
local step = addon.currentGuide.steps[n]
if not step or not IsFrameShown(nil,step) then
return
end
--[[for i, v in ipairs(BottomFrame.stepList) do
if v == n then
n = i
break
end
end]]
local height = ScrollChild.f1:GetHeight()
if n == 1 or not (stepPos[n] and stepPos[0] and height) then
value = 0
else
value = stepPos[n] / stepPos[0] * height - 2
local smax = height - BottomFrame:GetHeight() + 10
if value > smax then value = smax end
end
ScrollFrame.ScrollBar:SetValue(value)
value = math.floor(value+0.5)
if value ~= lastScrollValue then
addon.ScheduleTask(0,BottomFrame.StepScroll,n)
end
lastScrollValue = value
end
RXPFrame:SetWidth(addon.width)
RXPFrame:SetHeight(addon.height)
RXPFrame:SetPoint("LEFT", 0, 35)
RXPFrame:SetFrameStrata("BACKGROUND")
-- RXPFrame.CurrentStepFrame:SetBackdrop(backdrop)
-- RXPFrame.CurrentStepFrame:SetBackdropColor(0.3,0.01,0.01)
CurrentStepFrame:SetPoint("BOTTOMLEFT", GuideName, "TOPLEFT", 0, 2)
CurrentStepFrame:SetPoint("BOTTOMRIGHT", GuideName, "TOPRIGHT", 0, 2)
CurrentStepFrame:SetHeight(25)
CurrentStepFrame:SetScript("OnMouseDown", RXPFrame.OnMouseDown)
CurrentStepFrame:SetScript("OnMouseUp", RXPFrame.OnMouseUp)
CurrentStepFrame:EnableMouse(1)
local CheckStepCompletion = function(self,initialCheck)
local stepCompleted = true
for _,element in pairs(self.elements) do
if initialCheck and element.container and element.container.callback then
--print('ok1',GetTime())
element.container:callback()
end
stepCompleted = stepCompleted and element.completed
end
self.completed = stepCompleted
end
local hiddenFramePool = {}
function addon.RegisterGeneratedSteps()
local i = 1
local stepUnitscan, stepMobs, stepTargets = {}, {}, {}
local events, container
for generatedKind, context in pairs(addon.generatedSteps) do
for _, step in ipairs(context) do
for _, element in ipairs(step.elements or {}) do
if element.tag then
events = element.event or addon.functions.events[element.tag]
container = hiddenFramePool[i] or CreateFrame("Frame", nil, addon.RXPFrame)
hiddenFramePool[i] = container
i = i + 1
container:Show()
container.callback = addon.functions[element.tag]
if type(events) == "string" then
if events == "OnUpdate" then
container:SetScript("OnUpdate", container.callback)
else
container:RegisterEvent(events)
container:SetScript("OnEvent", CurrentStepFrame.EventHandler)
end
elseif type(events) == "table" then
for _, event in ipairs(events) do
if event == "OnUpdate" then
container:SetScript("OnUpdate", container.callback)
else
container:RegisterEvent(event)
container:SetScript("OnEvent", CurrentStepFrame.EventHandler)
end
end
end
container.element = element
element.container = container
-- Crudely disable until coordinate based proxmity is implemented
-- Otherwise Dangerous Mobs bloat Active Targets as a visual macro for all rares/mobs in a zone
if generatedKind ~= "dangerousMobs" then
if element.unitscan then
for _, t in ipairs(element.unitscan) do
tinsert(stepUnitscan, addon.GetCreatureName(t))
end
end
if element.mobs then
for _, t in ipairs(element.mobs) do
tinsert(stepMobs, addon.GetCreatureName(t))
end
end
if element.targets then
for _, t in ipairs(element.targets) do
tinsert(stepTargets, addon.GetCreatureName(t))
end
end
end
end
end
end
end
addon.targeting:UpdateEnemyList(stepUnitscan, stepMobs, true)
addon.targeting:UpdateTargetList(stepTargets, true)
addon.targeting:UpdateUnitList()
-- Don't process new targets if targeting disabled
if addon.settings.profile.enableTargetAutomation then addon.targeting:CheckNameplates() end
for j = i, #hiddenFramePool do
container = hiddenFramePool[j]
container:Hide()
container:SetScript("OnUpdate", nil)
container:SetScript("OnEvent", nil)
container.element = nil
container.callback = nil
end
addon:ScheduleTask(addon.ProcessGeneratedSteps, CheckStepCompletion, true)
addon.UpdateMap()
end
function addon:ProcessGeneratedSteps(func, ...)
if type(func) ~= "function" then func = nil end
for _, context in pairs(addon.generatedSteps) do
for _, step in ipairs(context) do
if step.isActive then
step.active = step:isActive()
-- print(step,GetTime(),step.active)
end
if step.active and func then func(step, ...) end
end
end
end
function addon:ShowTips(state)
if state == "toggle" then
RXPCData.hideTipWindow = not RXPCData.hideTipWindow
else
RXPCData.hideTipWindow = not state
end
addon.updateSteps = true
addon:ScheduleTask(addon.RXPFrame.GenerateMenuTable)
end
local tipMenu = {{
notCheckable = 1,
text = L("Hide tips"),
func = addon.ShowTips,
arg1 = false
}}
local TipWindowMouseDown = function(self,button)
if self.step and self.step.tip then
if (button == "RightButton") then
if _G.EasyMenu then
_G.EasyMenu(tipMenu, MenuFrame, "cursor", 0, 0, "MENU");
else
LibDD:EasyMenu(tipMenu, MenuFrame, "cursor", 0, 0, "MENU");
end
else
self:StartMoving()
end
end
end
local TipWindowMouseUp = function(self)
if self.step and self.step.tip then
self:StopMovingOrSizing()
local point = {self:GetPoint()}
point[2] = nil
RXPCData.tipWindow = point
addon.settings:SaveFramePositions()
end
end
CurrentStepFrame.framePool = {}
local function ClearFrameData()
for i, stepframe in ipairs(CurrentStepFrame.framePool) do
-- frame:SetHeight(0)
stepframe:Hide()
stepframe:SetScript("OnUpdate", nil)
stepframe:SetScript("OnEvent", nil)
stepframe:UnregisterAllEvents()
stepframe.callback = nil
if stepframe.step then
stepframe.step.frame = nil
stepframe.step.active = nil
stepframe.step = nil
stepframe.sticky = nil
stepframe.index = nil
end
for j, frame in ipairs(stepframe.elements) do
-- element:SetHeight(0)
if frame.step then
if not frame.step.sticky then
frame.element.completed = nil
end
frame.element.frame = nil
frame.element.skip = nil
end
frame.step = nil
frame.index = nil
frame.element = nil
frame.callback = nil
frame:Hide()
frame:UnregisterAllEvents()
frame:SetScript("OnUpdate", nil)
frame:SetScript("OnEvent", nil)
frame:SetScript("OnEnter", nil)
frame:SetScript("OnLeave", nil)
frame:SetScript("OnMouseDown", nil)
frame:SetMouseClickEnabled(false)
frame.button:SetChecked(false)
frame.highlight:Hide()
end
end
end
local activeSteps = {}
RXPFrame.activeSteps = activeSteps
function addon.UpdateStepCompletion()
addon.updateSteps = false
if addon.currentGuide.empty then return end
addon:ScheduleTask(addon.ProcessGeneratedSteps,CheckStepCompletion)
local update
for i, step in ipairs(activeSteps) do
local completed = true
if not (step.completed or step.tip) then
for j, element in ipairs(step.elements) do
if not (element.completed or element.skip or element.textOnly) then
completed = false
break
end
end
end
local c
local completewith = step.completewith
if completewith and (not completed or step.tip) then
local guide = addon.currentGuide
if completewith == "next" then
completewith = step.index and (step.index + 1)
else
completewith = guide.labels[completewith]
end
if completewith then
if guide.steps[completewith] and
guide.steps[completewith].sticky then
if RXPCData.stepSkip[completewith] then
completed = true
c = true
end
else
if RXPCData.currentStep > completewith then
completed = true
c = true
end
end
end
end
if step.tip then
c = c or RXPCData.hideTipWindow
if step.hidetip ~= c then
update = true
end
step.hidetip = c
step.active = not c
elseif completed and step.index then
if step.active and GetTime() - addon.lastStepUpdate > 1 then
addon:QueueMessage("RXP_STEP_COMPLETE",step,addon.currentGuide)
end
if step.sticky then
RXPCData.stepSkip[step.index] = true
update = true
step.active = nil
elseif step.index >= RXPCData.currentStep then
step.completed = true
RXPFrame.BottomFrame.UpdateFrame(nil, step.index)
if step.index == RXPCData.currentStep or
(step.index > RXPCData.currentStep and not step.sticky) then
addon.loadNextStep = true
end
return
end
end
end
if update then return addon.SetStep(RXPCData.currentStep) end
end
function addon.SetStep(n, n2, loopback)
if type(n) == "table" then n = n2 end
local guide = addon.currentGuide
if not guide then return end
local group = guide.group
addon.lastStepUpdate = GetTime()
-- print(n)
if n > #guide.steps then
if guide.loop then
if loopback then
return
else
return addon.SetStep(1, nil, true)
end
end
local isComplete = true
--local completedStep
for i, step in ipairs(activeSteps) do
if step.sticky and not RXPCData.stepSkip[i] then
isComplete = false
end
end
if isComplete then
return addon.functions.next()
else
n = #guide.steps
end
end
RXPCData.currentStep = n
RXPCData.currentStepId = guide.steps[n].stepId
-- isUpdating = true
if not guide.steps[n].active then
local step = guide.steps[n]
for _, element in ipairs(step) do
if element.OnStepActivation then
element:OnStepActivation()
end
end
local trackId = tonumber(step.track)
if C_SuperTrack and trackId then
C_SuperTrack.SetSuperTrackedQuestID(trackId)
end
addon:SendEvent("RXP_STEP_ACTIVATED",step,guide)
end
RXPCData.stepSkip[n + 1] = nil
if guide.steps[n].sticky and n < #guide.steps then
return addon.SetStep(n + 1)
end
local previousSteps = {}
for i, step in ipairs(activeSteps) do
step.active = nil
tinsert(previousSteps,step)
if n < #guide.steps then step.completed = nil end
end
addon:ScheduleTask(addon.RegisterGeneratedSteps)
table.wipe(activeSteps)
table.wipe(addon.questAccept)
table.wipe(addon.questTurnIn)
table.wipe(addon.activeItems)
table.wipe(addon.activeSpells)
table.wipe(addon.activeMacros)
table.wipe(addon.inventoryManager.itemsToOpen)
ClearFrameData()
local level = UnitLevel("player")
local scrollHeight = 1
local activeTargets = {}
for i = 1, n - 1 do
local step = guide.steps[i]
if step.sticky then
local req = guide.labels[step.requires]
if step.requires and req then
local requiredSteps = {}
req = guide.steps[req]
while req and req.requires and not RXPCData.stepSkip[req.index] and
not req.active do
if requiredSteps[req] then
addon.comms.PrettyPrint('ERROR: Step requirement loop at steps %d and %d',
step.index or 0, req.index or 0)
break
end
requiredSteps[req] = true
req = guide.steps[guide.labels[req.requires]]
end
end
step.reqFulfilled = not (req and
(req.active or
(req.sticky and
not RXPCData.stepSkip[req.index])))
if not RXPCData.stepSkip[i] and step.reqFulfilled and level >=
step.level then
tinsert(activeSteps, step)
if n > 1 then scrollHeight = n - 1 end
-- ScrollChild.framePool[i]:SetAlpha(0.66)
step.active = true
end
end
end
local lastTip = addon.currentTip
local step = guide.steps[n]
local req = step.requires and guide.labels[step.requires] and
guide.steps[guide.labels[step.requires]]
if step.completed and n < #guide.steps then
return addon.SetStep(n + 1)
elseif step and not step.completed and
not (req and #activeSteps > 0 and (req.active or not (req.reqFulfilled))) and
level >= step.level then
step.completed = false
addon.settings.ReplaceColors(step)
tinsert(activeSteps, step)
ScrollChild.framePool[n]:SetAlpha(1)
step.active = true
scrollHeight = n
if step.tipWindow then
step.tipWindow.completed = false
tinsert(activeSteps,step.tipWindow)
step.tipWindow.active = true
end
end
if #activeSteps == 0 then
if n >= #guide.steps then
return addon.functions.next()
else
return addon.SetStep(n + 1)
end
end
for _,prevstep in pairs(previousSteps) do
if not prevstep.active then
addon:SendEvent("RXP_STEP_DEACTIVATED",prevstep,guide)
end
end
--local totalHeight = 0
local c = 0
local anchor = 0
--local heightDiff = RXPFrame:GetHeight() - CurrentStepFrame:GetHeight()
local stepUnitscan = {}
local stepMobs = {}
local stepTargets = {}
for i, step in ipairs(activeSteps) do
local index = step.index
c = c + 1
local stepframe = CurrentStepFrame.framePool[c]
if not stepframe then
CurrentStepFrame.framePool[c] =
CreateFrame("Frame", "$parent_frame" .. c, CurrentStepFrame,
BackdropTemplate)
stepframe = CurrentStepFrame.framePool[c]
-- stepframe:SetBackdropBorderColor(0.1,0.5,0.1)
stepframe.elements = {}
-- addon.CreateActiveItemFrame(stepframe)
end
if step.tip then
--stepframe:SetParent(UIParent)
stepframe:ClearAllPoints()
local pos = RXPCData.tipWindow
stepframe:SetFrameStrata("MEDIUM")
if pos then
stepframe:SetPoint(pos[1], UIParent, pos[3], pos[4], pos[5])
else
stepframe:SetPoint("BOTTOMLEFT", UIParent, 0, 0)
end
--TODO: Save window position
stepframe:SetWidth(230)
stepframe:SetMovable(true)
stepframe:EnableMouse(true)
stepframe:SetClampedToScreen(true)
--stepframe:SetPoint("TOPRIGHT", CurrentStepFrame, 0, 0)
anchor = c - 1
stepframe:SetScript("OnMouseDown",TipWindowMouseDown)
stepframe:SetScript("OnMouseUp",TipWindowMouseUp)
addon.currentTip = step
else
stepframe:SetFrameStrata(RXPFrame:GetFrameStrata())
stepframe:ClearAllPoints()
stepframe:SetScript("OnMouseDown",nil)
stepframe:SetScript("OnMouseUp",nil)
if anchor < 1 then
stepframe:SetPoint("TOPLEFT", CurrentStepFrame, 0, 0)
stepframe:SetPoint("TOPRIGHT", CurrentStepFrame, 0, 0)
else
stepframe:SetPoint("TOPLEFT", CurrentStepFrame.framePool[anchor],
"BOTTOMLEFT", 0, -5)
stepframe:SetPoint("TOPRIGHT", CurrentStepFrame.framePool[anchor],
"BOTTOMRIGHT", 0, -5)
end
anchor = c
stepframe:SetMovable(false)
end
if not stepframe.number then
stepframe.number = CreateFrame("Frame", "$parent_number", stepframe,
BackdropTemplate)
stepframe.number:SetPoint("TOPLEFT", stepframe, 7, 5)
stepframe.number.text = stepframe.number:CreateFontString(nil,
"OVERLAY")
-- stepframe.number.text:SetFontObject(GameFontNormalSmall)
stepframe.number.text:ClearAllPoints()
stepframe.number.text:SetPoint("CENTER", stepframe.number, 2, 1)
stepframe.number.text:SetJustifyH("CENTER")
stepframe.number.text:SetJustifyV("MIDDLE")
stepframe.number.text:SetTextColor(
unpack(addon.activeTheme.textColor))
stepframe.number.text:SetFont(addon.font, addon.settings.profile
.guideFontSize, "")
end
if stepframe.theme ~= addon.activeTheme then
stepframe.theme = addon.activeTheme
stepframe:ClearBackdrop()
stepframe:SetBackdrop(RXPFrame.backdrop.edge)
stepframe:SetBackdropColor(unpack(addon.colors.background))
stepframe.number:ClearBackdrop()
stepframe.number:SetBackdrop(RXPFrame.backdrop.edge)
stepframe.number:SetBackdropColor(unpack(addon.colors.background))
end
local titletext
if step.sticky then
titletext = step.title or ""
else
titletext = step.title or (fmt(L("Step %d"), index))
end
if titletext == "" then
stepframe.number:SetAlpha(0)
stepframe.number:SetSize(10, 17)
else
stepframe.number:SetAlpha(1)
stepframe.number.text:SetText(titletext)
stepframe.number:SetSize(
stepframe.number.text:GetStringWidth() + 10, 17)
end
stepframe.step = step
stepframe.index = index
stepframe.sticky = step.sticky
local e = 0
local frameHeight = 0
for j, element in ipairs(step.elements or {}) do
e = j
local elementFrame = stepframe.elements[e]
if not stepframe.elements[e] then
stepframe.elements[e] = CreateFrame("Frame", "$parent_" .. e,
stepframe, nil)
elementFrame = stepframe.elements[e]
-- elementFrame:SetHeight(0)
-- elementFrame:SetWidth(300)
local button = CreateFrame("CheckButton", "$parentCheck",
elementFrame,
"ChatConfigCheckButtonTemplate");
elementFrame.button = button
button:SetSize(12, 12)
button:SetScript("PostClick", function(self)
local parent = self:GetParent()
local element = parent.element
if element and not element.optional then
local skip = self:GetChecked()
if element.OnComplete and skip and not element.skip then
element.OnComplete(element)
end
element.skip = skip
end
addon.updateSteps = true
addon.UpdateMap()
end)
--
button:SetPushedTexture("")
button:SetHighlightTexture(
"Interface/MINIMAP/UI-Minimap-ZoomButton-Highlight", "ADD")
elementFrame.text = getglobal(
elementFrame.button:GetName() .. 'Text')
elementFrame.text:SetParent(elementFrame)
elementFrame.text:SetJustifyH("LEFT")
elementFrame.text:SetJustifyV("MIDDLE")
elementFrame.text:SetTextColor(
unpack(addon.activeTheme.textColor))
elementFrame.text:SetFont(addon.font, addon.settings.profile
.guideFontSize + 2, "") -- 11
elementFrame.icon =
elementFrame:CreateFontString(nil, "OVERLAY")
elementFrame.icon:SetFontObject(_G.GameFontNormalSmall)
elementFrame:SetMouseMotionEnabled(true)
local ht = elementFrame:CreateTexture(nil, "HIGHLIGHT")
ht:SetAllPoints(elementFrame.text)
ht:SetTexture("Interface\\Worldmap\\UI-QuestPoi-HighlightBar")
ht:SetBlendMode("ADD")
ht:Hide()
elementFrame.highlight = ht
local function tpOnEnter(self)
if self:IsForbidden() or _G.GameTooltip:IsForbidden() then
return
end
local element = self.element or self:GetParent().element
if element and element.tooltip then
_G.GameTooltip:SetOwner(self, "ANCHOR_BOTTOM", 0, -10)
_G.GameTooltip:ClearLines()
_G.GameTooltip:AddLine(element.tooltip, 1, 1, 1)
_G.GameTooltip:Show()
end
end
local function tpOnLeave(self)
if self:IsForbidden() or _G.GameTooltip:IsForbidden() then
return
end
local element = self.element or self:GetParent().element
if element and element.tooltip then
_G.GameTooltip:Hide()
end
end
elementFrame:SetScript("OnEnter", tpOnEnter)
elementFrame:SetScript("OnLeave", tpOnLeave)
elementFrame.button:HookScript("OnEnter", tpOnEnter)
elementFrame.button:HookScript("OnLeave", tpOnLeave)
end
if elementFrame.button.theme ~= addon.activeTheme then
elementFrame.button.theme = addon.activeTheme
elementFrame.button:SetNormalTexture(addon.GetTexture(
"rxp-btn-blank-32"))
elementFrame.button:SetCheckedTexture(addon.GetTexture(
"rxp-checked-32"))
elementFrame.button:SetDisabledCheckedTexture(addon.GetTexture(
"rxp-checked-32"))
end
elementFrame.step = step
elementFrame.element = element
elementFrame.index = index
element.frame = elementFrame
elementFrame.button:Enable()
if element.tag then
local events = element.event or addon.functions.events[element.tag]
elementFrame.callback = addon.functions[element.tag]
addon.Call(element.tag,elementFrame.callback,elementFrame)
if type(events) == "string" then
if events == "OnUpdate" then
elementFrame:SetScript("OnUpdate", elementFrame.callback)
else
elementFrame:RegisterEvent(events)
elementFrame:SetScript("OnEvent",
CurrentStepFrame.EventHandler)
end
elseif type(events) == "table" then
for _, event in ipairs(events) do
if event == "OnUpdate" then
elementFrame:SetScript("OnUpdate",
elementFrame.callback)
else
elementFrame:RegisterEvent(event)
elementFrame:SetScript("OnEvent",
CurrentStepFrame.EventHandler)
end
end
end
end
if element.unitscan then
for _, t in ipairs(element.unitscan) do
if not activeTargets[t] then
activeTargets[t] = true
tinsert(stepUnitscan, addon.GetCreatureName(t))
end
end
end
if element.mobs then
for _, t in ipairs(element.mobs) do
if not activeTargets[t] then
activeTargets[t] = true
tinsert(stepMobs, addon.GetCreatureName(t))
end
end
end
if element.targets then
for _, t in ipairs(element.targets) do
if not activeTargets[t] then
activeTargets[t] = true
tinsert(stepTargets, addon.GetCreatureName(t))
end
end
end