-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathbrToolbar.lua
More file actions
307 lines (272 loc) · 12.1 KB
/
brToolbar.lua
File metadata and controls
307 lines (272 loc) · 12.1 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
---@type _,br,Daemonic
local _,br,dmc = ...
---@type AbstractFramework
local AF = _G.AbstractFramework
---@type br.Settings
local Settings = br.Settings
---@type br.Logging
local Log = br.Logging
---@class br
br = br or {}
function br:ToggleToolbar()
if br.TOOLBAR and br.TOOLBAR:IsShown() then
br.TOOLBAR:Hide()
else
br.TOOLBAR:Show()
end
end
function br:ShowMover()
AF.ShowMovers("BR")
end
function br:ToggleToolbarColor(button,enabled)
if enabled then
button:SetBorderHighlightColor("green")
button:SetBorderColor("green")
else
button:SetBorderHighlightColor("red")
button:SetBorderColor("red")
end
end
function br:InitializeToolbar()
local savedSettings = br.Settings:GetSetting("TOOLBAR_SETTINGS")
if not savedSettings then
savedSettings = {}
savedSettings.x = 100
savedSettings.y = 100
savedSettings.height = 40
savedSettings.width = 200
savedSettings.point = "TOPLEFT"
savedSettings.shown = true
Settings:SetSetting("TOOLBAR_SETTINGS",savedSettings)
end
---@type AF_BorderedFrame
local toolbarFrame = AF.CreateBorderedFrame(AF.UIParent,"TOOLBAR_FRAME",240,savedSettings.height,"white","black")
AF.SetPoint(toolbarFrame,savedSettings.point,savedSettings.x,savedSettings.y)
AF.CreateMover(toolbarFrame, "BR", "BR Toolbar Mover",function(p,x,y)
savedSettings.x = x
savedSettings.y = y
savedSettings.point = p
br.Settings:SetSetting("TOOLBAR_SETTINGS",savedSettings)
end)
toolbarFrame:SetFrameLevel(900)
local brEnableButton = AF.CreateButton(toolbarFrame,nil,"red",40,40)
brEnableButton:SetPoint("TOPLEFT",0,0)
brEnableButton:SetTexture("classicon-" .. strlower(PlayerUtil.GetClassFile()),{34,34},{"CENTER",0,0},true) --inv_10_gearupgrade_flightstone_black
br:ToggleToolbarColor(brEnableButton,br.pulse)
AF.SetTooltip(brEnableButton,"TOPLEFT",-10,0,"Toggle BR Lite Pulse. Pulse is the main loop that runs the rotation.")
brEnableButton:SetScript("OnClick",function()
br.pulse = not br.pulse
br:ToggleToolbarColor(brEnableButton,br.pulse)
end)
toolbarFrame.brEnableButton = brEnableButton
local brEnableFishing = AF.CreateButton(toolbarFrame,nil,"red",40,40)
brEnableFishing:SetPoint("TOPLEFT",40,0)
local brEnableFishingInnerFrame = AF.CreateFrame(brEnableFishing,nil,36,36)
brEnableFishingInnerFrame:SetPoint("CENTER",0,0)
local tex = brEnableFishingInnerFrame:CreateTexture(nil,"ARTWORK")
tex:SetTexture(132932)
tex:SetSize(30,30)
tex:SetPoint("CENTER",0,0)
tex:SetAllPoints(brEnableFishingInnerFrame)
br:ToggleToolbarColor(brEnableFishing,br.Fishing.Active)
AF.SetTooltip(brEnableFishing,"TOPLEFT",-10,0,"Toggle Auto Fishing.")
brEnableFishing:SetScript("OnClick",function()
br.Fishing.Active = not br.Fishing.Active
br:ToggleToolbarColor(brEnableFishing,br.Fishing.Active)
if br.Fishing.Active then
br.Fishing:Fish()
end
end)
local brMovement = AF.CreateButton(toolbarFrame,nil,"blue",40,40)
brMovement:SetPoint("TOPLEFT",80,0)
AF.SetTooltip(brMovement,"TOPLEFT",-10,0,"Enable BR Movement calls, like closing to a target.")
local brMovementInnerFrame = AF.CreateFrame(brMovement,nil,36,36)
brMovementInnerFrame:SetPoint("CENTER",0,0)
local MoveTex = brMovementInnerFrame:CreateTexture(nil,"ARTWORK")
MoveTex:SetTexture(134060)
MoveTex:SetSize(30,30)
MoveTex:SetPoint("CENTER",0,0)
if br.DoMovement then
brMovement:SetBorderHighlightColor("green")
brMovement:SetBorderColor("green")
else
brMovement:SetBorderHighlightColor("red")
brMovement:SetBorderColor("red")
end
MoveTex:SetAllPoints(brMovementInnerFrame)
brMovement:SetScript("OnClick",function()
br.DoMovement = not br.DoMovement
if br.DoMovement then
brMovement:SetBorderHighlightColor("green")
brMovement:SetBorderColor("green")
Log:Log("BR Movement Enabled")
Settings:SetSetting("BR_MOVEMENT_ENABLED",true)
else
brMovement:SetBorderHighlightColor("red")
brMovement:SetBorderColor("red")
Log:Log("BR Movement Disabled")
Settings:SetSetting("BR_MOVEMENT_ENABLED",false)
end
end)
local brFacing = AF.CreateButton(toolbarFrame,nil,"blue",40,40)
brFacing:SetPoint("TOPLEFT",120,0)
AF.SetTooltip(brFacing,"TOPLEFT",-10,0,"Enable BR Facing calls, like ensuring you are facing your target.")
local brFacingInnerFrame = AF.CreateFrame(brFacing,nil,36,36)
brFacingInnerFrame:SetPoint("CENTER",0,0)
local FaceTex = brFacingInnerFrame:CreateTexture(nil,"ARTWORK")
FaceTex:SetTexture(134269)
FaceTex:SetSize(30,30)
FaceTex:SetPoint("CENTER",0,0)
if br.DoFacing then
brFacing:SetBorderHighlightColor("green")
brFacing:SetBorderColor("green")
else
brFacing:SetBorderHighlightColor("red")
brFacing:SetBorderColor("red")
end
FaceTex:SetAllPoints(brFacingInnerFrame)
brFacing:SetScript("OnClick",function()
br.DoFacing = not br.DoFacing
if br.DoFacing then
brFacing:SetBorderHighlightColor("green")
brFacing:SetBorderColor("green")
Log:Log("BR Facing Enabled")
Settings:SetSetting("BR_FACING_ENABLED",true)
else
brFacing:SetBorderHighlightColor("red")
brFacing:SetBorderColor("red")
Log:Log("BR Facing Disabled")
Settings:SetSetting("BR_FACING_ENABLED",false)
end
end)
local brLooting = AF.CreateButton(toolbarFrame,nil,"green",40,40)
brLooting:SetPoint("TOPLEFT",160,0)
AF.SetTooltip(brLooting,"TOPLEFT",-10,0,"Toggle Auto Looting.")
local brLootingInnerFrame = AF.CreateFrame(brLooting,nil,36,36)
brLootingInnerFrame:SetPoint("CENTER",0,0)
local LootTex = brLootingInnerFrame:CreateTexture(nil,"ARTWORK")
LootTex:SetTexture(133784)
LootTex:SetSize(30,30)
LootTex:SetPoint("CENTER",0,0)
if br.DoLooting then
brLooting:SetBorderHighlightColor("green")
brLooting:SetBorderColor("green")
else
brLooting:SetBorderHighlightColor("red")
brLooting:SetBorderColor("red")
end
LootTex:SetAllPoints(brLootingInnerFrame)
brLooting:SetScript("OnClick",function()
br.DoLooting = not br.DoLooting
if br.DoLooting then
brLooting:SetBorderHighlightColor("green")
brLooting:SetBorderColor("green")
Log:Log("BR Looting Enabled")
Settings:SetSetting("BR_LOOTING_ENABLED",true)
else
brLooting:SetBorderHighlightColor("red")
brLooting:SetBorderColor("red")
Log:Log("BR Looting Disabled")
Settings:SetSetting("BR_LOOTING_ENABLED",false)
end
end)
local PullModeButton = AF.CreateButton(toolbarFrame,nil,"green",40,40)
PullModeButton:SetPoint("TOPLEFT",200,0)
AF.SetTooltip(PullModeButton,"TOPLEFT",-10,0,"Toggle Pull Mode. In Pull Mode, BR will use your pull rotation.")
local PullModeInnerFrame = AF.CreateFrame(PullModeButton,nil,36,36)
PullModeInnerFrame:SetPoint("CENTER",0,0)
local PullTex = PullModeInnerFrame:CreateTexture(nil,"ARTWORK")
PullTex:SetTexture(136082)
PullTex:SetSize(30,30)
PullTex:SetPoint("CENTER",0,0)
if br.PullMode then
PullModeButton:SetBorderHighlightColor("green")
PullModeButton:SetBorderColor("green")
else
PullModeButton:SetBorderHighlightColor("red")
PullModeButton:SetBorderColor("red")
end
PullTex:SetAllPoints(PullModeInnerFrame)
PullModeButton:SetScript("OnClick",function()
br.PullMode = not br.PullMode
if br.PullMode then
PullModeButton:SetBorderHighlightColor("green")
PullModeButton:SetBorderColor("green")
Log:Log("Pull Mode Enabled")
Settings:SetSetting("BR_PULL_MODE_ENABLED",true)
else
PullModeButton:SetBorderHighlightColor("red")
PullModeButton:SetBorderColor("red")
Log:Log("Pull Mode Disabled")
Settings:SetSetting("BR_PULL_MODE_ENABLED",false)
end
end)
local brDebug = AF.CreateButton(toolbarFrame,nil,"yellow",40,40)
brDebug:SetPoint("TOPLEFT",240,0)
local brDebugInnerFrame = AF.CreateFrame(brDebug,nil,36,36)
brDebugInnerFrame:SetPoint("CENTER",0,0)
local DebugTex = brDebugInnerFrame:CreateTexture(nil,"ARTWORK")
DebugTex:SetTexture(136243)
DebugTex:SetSize(30,30)
DebugTex:SetPoint("CENTER",0,0)
DebugTex:SetAllPoints(brDebugInnerFrame)
brDebug:SetScript("OnClick",function()
---@type Unit
local target = br.ActivePlayer:TargetUnit()
if not target then
Log:Log("No target selected.")
else
Log:Log("Target selected: " .. tostring(target.name))
end
--get target guid
local tguid = UnitGUID("target")
for k,v in pairs(br.ObjectManager.Units) do
if v.WoWGUID == tguid then
Log:Log("Found target in Object Manager with guid: " .. tostring(k))
target = v
break
end
end
if not target then
Log:Log("Target not found in Object Manager.")
return
else
Log:Log("Target found in Object Manager: " .. tostring(target.name))
end
for i = 0x1000,0x2300,8 do
local val = br.ObjectField(target.guid,i,5)
if val == br.ActivePlayer.guid then
Log:Log(string.format("Found target guid in Object Fields at offset 0x%X",i))
break
end
end
if target then
-- Log:Log("Debug Info for target: " .. target.name)
-- Log:Log("Unit is Dead or Ghost: " .. tostring(UnitIsDeadOrGhost(target.WoWGUID)))
-- Log:Log("Lootable Count: " .. tostring(br.ObjectManager:LootableCount()))
-- Log:Log("Skinnable Count: " .. tostring(br.ObjectManager:SkinnableCount()))
-- Log:Log("Loot Status: " .. tostring(br.ObjectLootable(target.guid)))
-- Log:Log("Is Skinnable: " .. tostring(br.ObjectSkinnable(target.guid)))
-- print("Evaluating target: " .. tostring(target.name) .. " Distance: " .. tostring(target:Distance()))
-- print("WowGUID: [" .. tostring(target.WoWGUID) .. "] type: " .. type(target.WoWGUID))
-- print("Tool ID: [" .. tostring(target.guid) .. "] type: " .. type(target.guid))
-- print("Guid of Target: [" .. UnitGUID("target") .. "] type: " .. type(UnitGUID("target")))
-- --print("IsAlive: " .. tostring(target:IsAlive()))
-- print("UnitCanAttack: " .. tostring(UnitCanAttack("player",target.WoWGUID)))
-- print("UnitIsEnemy: " .. tostring(UnitIsEnemy("player",target.WoWGUID)))
-- print("'target' Can Attack: " .. tostring(UnitCanAttack("player","target")))
-- print("'target' Is Enemy: " .. tostring(UnitIsEnemy("player","target")) )
-- print("Unit Reaction: " .. tostring(UnitReaction("player",target.WoWGUID)))
-- print('"target" Reaction: ' .. tostring(UnitReaction("player","target")))
-- print("IsAffectingCombat: " .. tostring(UnitAffectingCombat(target.WoWGUID)))
-- print('"target" Is Affecting Combat: ' .. tostring(UnitAffectingCombat("target")))
-- print("Is Targetting Player: " .. tostring(target:IsTargetingPlayer()))
-- print("Object Exists: " .. tostring(br.ObjectExists(target.guid)))
-- print("Health: " .. tostring(br.unwrap(UnitHealth(target.WoWGUID))))
-- print("Health using apis: " .. tostring(br.apis.UnitHealth(target.WoWGUID)))
-- print("Target Health: " .. tostring(br.unwrap(UnitHealth("target"))))
-- print("-------------------------------------------------------------------")
end
end)
br.TOOLBAR = toolbarFrame
end