-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathbrFramework.lua
More file actions
141 lines (118 loc) · 4.68 KB
/
brFramework.lua
File metadata and controls
141 lines (118 loc) · 4.68 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
---@type _,br,NilName
local _,br,nn = ...
---@type br.Logging, br.Settings
local Log,Settings = br.Logging,br.Settings
---@class br.Framework
---@field Startup function #Scaffold the framework int br class
local Framework = br.Framework
function br.Framework:RotationPulse()
br.Looting:Loot()
if br.pulse and br.ActiveRotation then
br.ActiveRotation:Pulse()
end
local callbackTime = math.random(150,450)/1000
C_Timer.After(callbackTime, function() br.Framework:RotationPulse() end)
end
function br.Framework:Startup()
---@type AbstractFramework
local AF = _G.AbstractFramework
if not AF then
Log:LogError("ERROR: AbstractFramework not found. BRLite cannot start.")
return
end
print("Settings Root Path: " .. tostring(br.Settings.RootPath))
Settings:Initialize(br.Settings.RootPath,"brlite_settings.json")
br.pulse = Settings:GetSettingToggle("BR_ENABLED",true)
br.DoMovement = Settings:GetSettingToggle("BR_MOVEMENT_ENABLED",true)
br.DoFacing = Settings:GetSettingToggle("BR_FACING_ENABLED",true)
br.DoLooting = Settings:GetSettingToggle("BR_LOOTING_ENABLED",true)
br.PullMode = Settings:GetSettingToggle("BR_PULL_MODE_ENABLED",false)
br.UI.Elements.MinimapIcon:Initialize()
br:InitializeToolbar()
--Set ObjectManager to active and start its timer
br.ObjectManager:Update()
br.ObjectManager.Active = true
br.ObjectManager:Timer()
--Combat Manager Initialization
br.CombatManager:Initialize()
--Load available Rotations
br.Rotations = {}
local specName = "AAAA"
if br.ActivePlayer.Specialization ~= 5 then
specName = br.ActivePlayer.SpecializationName
specName = string.gsub(specName," ","")
else
specName = "Initial"
end
local rotationPath = br.RotationBasePath .. "/" .. br.ActivePlayer.ClassName .. "/" .. specName .. "/"
local rotFiles = br.ListFiles(rotationPath .. "*.lua")
if not rotFiles or #rotFiles == 0 then
Log:LogError("No rotation files found in path: " .. rotationPath)
Log:LogError("Please add a rotation for your client version, class, and specialty")
Log:LogError("Then Reload the UI.")
br.ActiveRotation = nil
br.pulse = false
return
end
for i=1,#rotFiles do
br.RequireFile(rotationPath .. rotFiles[i],br)
end
-- Count non sequenced # of pairs in table and store
local rotCount = 0
for k,v in pairs(br.Rotations) do
rotCount = rotCount + 1
end
br.RotationCount = rotCount
--Set MinimapIcon handler
br.UI.Elements.MinimapIcon:SetLeftClickHandler(
function()
br:ShowSettingsWindow()
end)
br.UI.Elements.MinimapIcon:SetRightClickHandler(
function()
br:ToggleToolbar()
end)
br.UI.Elements.MinimapIcon:SetShiftLeftClickHandler(
function()
br:ShowMover()
end)
local savedSettings = br.Settings:GetSetting("WINDOW_SETTINGS")
if savedSettings and savedSettings.shown then
br:ShowSettingsWindow()
end
local rotationSettings = Settings:GetSetting("ACTIVE_ROTATION")
if not rotationSettings then
if not br.Rotations or br.RotationCount == 0 then
Log:LogError("ERROR: Available Rotation Count: " .. br.RotationCount )
Log:LogError("No rotations available to set as active.")
Log:LogError("Please add a rotation for your client version, class, and specialty")
Log:LogError("Then Reload the UI.")
br.ActiveRotation = nil
br.pulse = false
return
else
Log:Log("No saved active rotation; defaulting to first available rotation.")
_,br.ActiveRotation = next(br.Rotations)
Log:Log("1. Setting Active Rotation to: " .. tostring(br.ActiveRotation.ShortName))
end
else
local rot = br.Rotations[rotationSettings.shortName]
if rot then
br.ActiveRotation = rot
Log:Log("2. Setting Active Rotation to: " .. tostring(br.ActiveRotation.ShortName))
else
Log:Log("Saved active rotation " .. rotationSettings.shortName .. " not found; defaulting to first available rotation.")
_,br.ActiveRotation = next(br.Rotations)
Log:Log("2. Setting Active Rotation to: " .. tostring(br.ActiveRotation.ShortName))
end
end
--Attempt to Initialize Active Rotation
if br.ActiveRotation then
br.ActiveRotation:Initialize()
br.Framework:RotationPulse()
else
Log:LogError("No Active Rotation to initialize.")
return
end
Log:Log("BR Framework Startup Complete")
end