This repository was archived by the owner on Feb 1, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.lua
More file actions
150 lines (134 loc) · 4.17 KB
/
Main.lua
File metadata and controls
150 lines (134 loc) · 4.17 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
local _G = getfenv()
local Gamepad = _G.Gamepad
local L = Gamepad.Locales[_G.GetLocale()].Strings
_G.BINDING_HEADER_GAMEPAD_HEADER = L['Gamepad']
_G.BINDING_NAME_GAMEPAD_BUTTON1 = L['Use Action']
_G.BINDING_NAME_GAMEPAD_BUTTON2 = L['Previous Action']
_G.BINDING_NAME_GAMEPAD_BUTTON3 = L['Next Action']
Gamepad.actions = {
{
['shapeshiftID'] = {[1] = 76}, -- cheap shot
['defaultActionID'] = 4, -- kidney shot
}, 28, 29, 30,
31, 33, 25,
43, 47
}
--[[
/script ChatFrame1:AddMessage(GetBonusBarOffset())
/run local l = 0;for l = 1, 120 do local t = GetActionText(l);local x = GetActionTexture(l);if x then local m = "Slot " .. l .. ": [" .. x .. "]";if t then m = m .. " \"" .. t .. "\"";end DEFAULT_CHAT_FRAME:AddMessage(m);end end
]]
Gamepad.currentAction = nil
Gamepad.currentActionID = nil
Gamepad.actionsLength = getn(Gamepad.actions)
function Gamepad.UpdateActionID()
if type(Gamepad.actions[Gamepad.currentAction]) == 'table' then
for shapeshiftID, actionID in ipairs(Gamepad.actions[Gamepad.currentAction].shapeshiftID) do
if Gamepad.shapeshift[shapeshiftID] then
Gamepad.currentActionID = actionID
return
end
end
Gamepad.currentActionID = Gamepad.actions[Gamepad.currentAction].defaultActionID
else
Gamepad.currentActionID = Gamepad.actions[Gamepad.currentAction]
end
end
Gamepad.shapeshiftNum = GetNumShapeshiftForms()
Gamepad.shapeshift = {}
function Gamepad.UpdateShapeshift()
Gamepad.shapeshift = {}
local icon, name, active
for i = 1, Gamepad.shapeshiftNum, 1 do
icon, name, active = GetShapeshiftFormInfo(i)
Gamepad.shapeshift[i] = active
end
end
local frame = CreateFrame('Frame')
Gamepad.frame = frame
frame:SetScript('OnEvent', function()
this[event](this)
end)
frame:RegisterEvent('ADDON_LOADED')
frame:RegisterEvent('ACTIONBAR_SLOT_CHANGED')
frame:RegisterEvent('ACTIONBAR_PAGE_CHANGED')
frame:RegisterEvent('UPDATE_BONUS_ACTIONBAR')
frame:RegisterEvent('PLAYER_TARGET_CHANGED')
frame:RegisterEvent('PLAYER_AURAS_CHANGED')
frame:RegisterEvent('PLAYER_ENTER_COMBAT')
frame:RegisterEvent('PLAYER_LEAVE_COMBAT')
frame:RegisterEvent('START_AUTOREPEAT_SPELL')
frame:RegisterEvent('STOP_AUTOREPEAT_SPELL')
frame:RegisterEvent('ACTIONBAR_UPDATE_USABLE')
frame:RegisterEvent('UPDATE_INVENTORY_ALERTS')
frame:RegisterEvent('ACTIONBAR_UPDATE_COOLDOWN')
frame:RegisterEvent('ACTIONBAR_UPDATE_STATE')
frame:RegisterEvent('CRAFT_SHOW')
frame:RegisterEvent('CRAFT_CLOSE')
frame:RegisterEvent('TRADE_SKILL_SHOW')
frame:RegisterEvent('TRADE_SKILL_CLOSE')
function frame:ADDON_LOADED()
if arg1 ~= 'Gamepad' then
return
end
Gamepad.UpdateShapeshift()
Gamepad.UI.Load()
end
function frame:ACTIONBAR_SLOT_CHANGED()
Gamepad.UI.UpdateActionButton()
Gamepad.UI.UpdateActionButtonState()
end
function frame:ACTIONBAR_PAGE_CHANGED()
Gamepad.UI.UpdateActionButton()
Gamepad.UI.UpdateActionButtonState()
end
function frame:UPDATE_BONUS_ACTIONBAR()
Gamepad.UI.UpdateActionButton()
Gamepad.UI.UpdateActionButtonState()
end
function frame:PLAYER_TARGET_CHANGED()
Gamepad.UI.UpdateActionButtoUsable()
end
function frame:PLAYER_AURAS_CHANGED()
Gamepad.UpdateShapeshift()
Gamepad.UpdateActionID()
Gamepad.UI.UpdateActionButtoUsable()
end
function frame:ACTIONBAR_UPDATE_USABLE()
Gamepad.UI.UpdateActionButtoUsable()
Gamepad.UI.UpdateActionButtonCooldown()
end
function frame:UPDATE_INVENTORY_ALERTS()
Gamepad.UI.UpdateActionButtoUsable()
Gamepad.UI.UpdateActionButtonCooldown()
end
function frame:ACTIONBAR_UPDATE_COOLDOWN()
Gamepad.UI.UpdateActionButtoUsable()
Gamepad.UI.UpdateActionButtonCooldown()
end
function frame:ACTIONBAR_UPDATE_STATE()
Gamepad.UI.UpdateActionButtonState()
end
function frame:CRAFT_SHOW()
Gamepad.UI.UpdateActionButtonState()
end
function frame:CRAFT_CLOSE()
Gamepad.UI.UpdateActionButtonState()
end
function frame:TRADE_SKILL_SHOW()
Gamepad.UI.UpdateActionButtonState()
end
function frame:TRADE_SKILL_CLOSE()
Gamepad.UI.UpdateActionButtonState()
end
function frame:PLAYER_ENTER_COMBAT()
Gamepad.UI.UpdateActionButtonState()
end
function frame:PLAYER_LEAVE_COMBAT()
Gamepad.UI.UpdateActionButtonState()
end
function frame:START_AUTOREPEAT_SPELL()
Gamepad.UI.UpdateActionButtonState()
end
function frame:STOP_AUTOREPEAT_SPELL()
Gamepad.UI.UpdateActionButtonState()
end