-
Notifications
You must be signed in to change notification settings - Fork 16
/
bestride.lua
206 lines (180 loc) · 6.87 KB
/
bestride.lua
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
function BeStride:OnInitialize()
self.configDialogs = {}
self.db = LibStub("AceDB-3.0"):New("BeStrideDB", defaults, "Default")
self:RegisterChatCommand("bestride","ChatCommand")
self:RegisterChatCommand("br","ChatCommand")
BeStride:OptionsTable()
self.buttons = {
["mount"] = nil,
["ground"] = nil,
["repair"] = nil,
["passenger"] = nil,
}
self.buttons["regular"] = BeStride:CreateActionButton('Regular')
self.buttons["ground"] = BeStride:CreateActionButton('Ground')
self.buttons["repair"] = BeStride:CreateActionButton('Repair')
self.buttons["passenger"] = BeStride:CreateActionButton('Passenger')
local className,classFilename,classID = UnitClass("player")
local raceName,raceFile,raceID = UnitRace("player")
local factionName,factionLocalized = UnitFactionGroup("player")
local factionId = nil
if factionName == "Alliance" then
factionId = 1
else
factionId = 0
end
playerTable["class"] = {}
playerTable["class"]["id"] = classID
playerTable["class"]["name"] = className
playerTable["race"] = {}
playerTable["race"]["name"] = raceName
playerTable["race"]["id"] = raceID
playerTable["faction"] = {}
playerTable["faction"]["name"] = factionName
playerTable["faction"]["id"] = factionId
playerTable["faction"]["localization"] = factionLocalized
if BeStride.OverrideConstants ~= nil then
BeStride:OverrideConstants()
end
end
function BeStride:OnEnable()
BeStride:Version_OnEnable()
BeStride:buildMountTables()
if BeStride_Game == "Mainline" then
BeStride:RegisterEvent("NEW_MOUNT_ADDED", "EventNewMount")
else
BeStride:RegisterEvent("COMPANION_LEARNED", "EventNewMount")
end
BeStride:RegisterEvent("PLAYER_REGEN_DISABLED", "EventCombatEnter")
BeStride:RegisterEvent("PLAYER_REGEN_ENABLED", "EventCombatExit")
BeStride:Upgrade()
end
function BeStride:GetProfiles()
local profiles = BeStride.db:GetProfiles()
table.sort(profiles)
return profiles
end
function BeStride:UpdateBindings()
BeStride:SetKeyBindings(self.buttons["regular"])
BeStride:SetKeyBindings(self.buttons["ground"])
BeStride:SetKeyBindings(self.buttons["passenger"])
BeStride:SetKeyBindings(self.buttons["repair"])
SaveBindings(GetCurrentBindingSet())
end
function BeStride:UpdateOverrideBindings()
BeStride:SetKeyBindingsOverrides(self.buttons["regular"])
BeStride:SetKeyBindingsOverrides(self.buttons["ground"])
BeStride:SetKeyBindingsOverrides(self.buttons["passenger"])
BeStride:SetKeyBindingsOverrides(self.buttons["repair"])
SaveBindings(GetCurrentBindingSet())
end
function BeStride:SetKeyBindings(button)
local primaryKey,secondaryKey = GetBindingKey("CLICK " .. button:GetName() .. ":LeftButton")
if primaryKey then
SetBindingClick(primaryKey,button:GetName())
end
if secondaryKey then
SetBindingClick(secondaryKey,button:GetName())
end
end
function BeStride:SetKeyBindingsOverrides(button)
ClearOverrideBindings(button)
local primaryKey,secondaryKey = GetBindingKey(button:GetName())
if primaryKey then
SetOverrideBindingClick(button, true, primaryKey, button:GetName())
end
if secondaryKey then
SetOverrideBindingClick(button, true, secondaryKey, button:GetName())
end
end
function BeStride:ChatCommand(input)
local command,args = strsplit(" ", input, 2)
if command == "help" then
print("Bestride Command options")
print("/br - Open Main Configuration Dialog")
print("/br about - Open about Dialog")
print("/br help - This help")
print("/br reload - Rebuild the mount table")
print("/br map - Print the current map layers")
elseif command == "locale" then
local L = LibStub("AceLocale-3.0"):GetLocale("BeStride")
print(L["Open.GUI"])
elseif command == "speed" then
print(BeStride:SpeedCheck())
elseif command == "mountdb" then
self:ListMountDB()
elseif command == "gamemounts" then
self:PrintGameMounts()
elseif command == "mountsTable" then
self:ListGameMounts()
elseif command == "reload" then
mountTable.master = {}
BeStride:buildMountTables()
elseif command == "map" then
local locID = C_Map.GetBestMapForUnit("player")
print("mapID:name:mapType:parentMapID")
local map = self:GetMapUntil(locID,0,true)
print("Final: ")
print(map.mapID .. ":" .. map.name .. ":" .. map.mapType .. ":" .. map.parentMapID)
elseif command == "maplast" then
local locID = C_Map.GetBestMapForUnit("player")
print("mapID:name:mapType:parentMapID")
local map = self:GetMapUntilLast(locID,0,true)
print("Final: ")
print(map.mapID .. ":" .. map.name .. ":" .. map.mapType .. ":" .. map.parentMapID)
elseif command == "underwater" then
BeStride:IsUnderwater()
elseif command == "mountID" then
mount = BeStride:GetMountInfoByMountID(args)
print(mount.creatureName)
elseif command == "spellID" then
mount = BeStride:GetMountInfoBySpellID(args)
print(mount.creatureName)
elseif command == "mounts" then
LibStub("AceConfigDialog-3.0"):Open("BeStride-Mounts")
elseif command == "options" then
if self.IsMainline() then
InterfaceOptionsFrame_OpenToCategory(self.configDialogs.configuration.frame)
else
InterfaceOptionsFrame_OpenToCategory(self.configDialogs.options.frame)
InterfaceOptionsFrame_OpenToCategory(self.configDialogs.options.frame)
end
elseif command == "profiles" then
if self.IsMainline() then
InterfaceOptionsFrame_OpenToCategory(self.configDialogs.configuration.frame)
else
InterfaceOptionsFrame_OpenToCategory(self.configDialogs.profiles.frame)
InterfaceOptionsFrame_OpenToCategory(self.configDialogs.profiles.frame)
end
elseif command == "debug" or input == "bug" then
LibStub("AceConfigDialog-3.0"):Open("BeStride-Debug")
elseif command == "about" then
LibStub("AceConfigDialog-3.0"):Open("BeStride")
else
print("/br - Open Main Configuration Dialog and print help")
print("/br options - Open options Dialog")
print("/br about - Open about Dialog")
print("/br help - This help")
print("/br reload - Rebuild the mount table")
print("/br map - Print the current map layers")
InterfaceOptionsFrame_OpenToCategory(self.configDialogs.profiles.frame)
InterfaceOptionsFrame_OpenToCategory(self.configDialogs.profiles.frame)
InterfaceOptionsFrame_OpenToCategory("BeStride")
end
end
function BeStride:ListGameMounts()
print("Mount (index):name:spellID:mountID:isActive")
for i=1, GetNumCompanions("MOUNT") do
local mountID,name,spellID,icon,isSummoned = GetCompanionInfo("MOUNT", i)
print("Mount (" .. i .. "):" .. (name or "")..":"..(spellID or "")..":"..(mountID or "")..":"..tostring(isSummoned or ""))
end
end
function BeStride:ListMountDB()
print("Mount (mountID):name:spellID:mountID:isActive:faction:source:type")
for key,value in pairs(mountTable["master"]) do
print("Mount (" .. key .. "):" .. (value.name or "")..":"..(value.spellID or "")..":"..(value.mountID or "")..":"..tostring(value.isActive or "")..":"..tostring(value.faction or "")..":"..(value.source or "")..":"..(value.type or ""))
end
end
function BeStride:PrintGameMounts()
self:PrintAllMounts()
end