forked from Bastion/Bastion
parent
8b5f04bdea
commit
0d0c039e18
@ -0,0 +1,81 @@ |
||||
local Tinkr, Bastion = ... |
||||
|
||||
---@class Environment |
||||
local Environment = {} |
||||
Environment.__index = Environment |
||||
|
||||
local buildNum = select(4, GetBuildInfo()) |
||||
local buildName = "CLASSIC" |
||||
if buildNum > 100000 then |
||||
buildName = "RETAIL" |
||||
elseif buildNum > 40000 then |
||||
buildName = "CATA" |
||||
elseif buildNum > 30000 then |
||||
buildName = "WOTLK" |
||||
elseif buildNum > 20000 then |
||||
buildName = "TBC" |
||||
end |
||||
|
||||
function Environment:GetWoWBuildNumber() |
||||
return buildNum |
||||
end |
||||
|
||||
function Environment:GetWoWBuild() |
||||
return buildName |
||||
end |
||||
|
||||
if C_Timer == nil then |
||||
Bastion:Debug("Adding C_Timer") |
||||
C_Timer = {} |
||||
local f = CreateFrame("Frame", "C_Timer") |
||||
f.tab = {} |
||||
f:HookScript("OnUpdate", function() |
||||
for i, v in pairs(f.tab) do |
||||
if v[1] <= GetTime() then |
||||
local func = v[2] |
||||
func() |
||||
table.remove(f.tab, i) |
||||
end |
||||
end |
||||
end |
||||
) |
||||
function C_Timer.After(time, func) |
||||
table.insert(f.tab, {GetTime() + time, func}) |
||||
end |
||||
end |
||||
|
||||
function Environment:GetCVar(name) |
||||
if C_Var and C_Cvar.GetCvar then return C_Cvar.GetCvar(name) end |
||||
if Cvar then return GetCvar(name) end |
||||
Bastion:Debug("[GetCvar] failed") |
||||
return nil |
||||
end |
||||
|
||||
function Environment:SetCVar(name, value) |
||||
if C_Var and C_Cvar.SetCvar then return C_Cvar.SetCvar(name, value) end |
||||
if Cvar then return SetCvar(name, value) end |
||||
Bastion:Debug("[SetCvar] failed") |
||||
return nil |
||||
end |
||||
|
||||
function Environment:GetItemInfo(itemId) |
||||
if itemId == nil then return nil end |
||||
if C_Item and C_Item.GetItemInfo then return C_Item.GetItemInfo(itemId) end |
||||
if GetItemInfo then return GetItemInfo(itemId) end |
||||
Bastion:Debug("[GetItemInfo] failed") |
||||
return nil |
||||
end |
||||
|
||||
function Environment:GetSpellInfo(spellId) |
||||
if spellId == nil then return nil end |
||||
if C_Spell and C_Spell.GetSpellInfo then |
||||
local tab = C_Spell.GetSpellInfo(spellId) |
||||
if tab then return tab.name, tab.rank, tab.icon, tab.castTime, tab.minRange, tab.maxRange, tab.spellId |
||||
end |
||||
end |
||||
if GetSpellInfo then return GetSpellInfo(spellId) end |
||||
Bastion:Debug("[GetSpellInfo] failed") |
||||
return nil |
||||
end |
||||
|
||||
return Environment |
||||
Loading…
Reference in new issue