From 962e63f821e5aeac348aa279942c821f473374d8 Mon Sep 17 00:00:00 2001 From: CiscOH Bellic Date: Sat, 27 Jul 2024 09:42:02 -0400 Subject: [PATCH] "Added new functions to Environment.lua and updated _bastion.lua to include Locale and Load '@Locales/'" --- src/Environment/Environment.lua | 29 ++++++++++++++++++++++++++++- src/Locale/Locale.lua | 6 ++++++ src/_bastion.lua | 3 +++ 3 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 src/Locale/Locale.lua diff --git a/src/Environment/Environment.lua b/src/Environment/Environment.lua index cab07d8..532e0b8 100644 --- a/src/Environment/Environment.lua +++ b/src/Environment/Environment.lua @@ -7,13 +7,19 @@ local C_Spell = C_Spell or nil local C_Item = C_Item or nil local C_Var = C_Var or nil local C_Timer = C_Timer or nil -local C_Var = C_Var or nil +local C_AddOns = C_AddOns local Cvar = Cvar or nil local GetItemInfo = GetItemInfo or nil local GetSpellInfo = GetSpellInfo or nil local IsSpellInRange = IsSpellInRange or nil local GetCvar = GetCvar or nil local SetCvar = SetCvar or nil +local GetMouseFocus = GetMouseFocus or nil +local GetMouseFoci = GetMouseFoci or nil +local GetBuildInfo = GetBuildInfo or nil +local LoadAddOn = LoadAddOn or nil +local IsAddOnLoaded = IsAddOnLoaded or nil + local buildNum = select(4, GetBuildInfo()) local buildName = "CLASSIC" @@ -97,4 +103,25 @@ function Environment:IsSpellInRange(spellId, spellType, unit) return nil end +function Environment:GetMouseFocus() + if GetMouseFoci then return GetMouseFoci() end + if GetMouseFocus then return GetMouseFocus() end + Bastion:Debug("[GetMouseFocus] failed") + return nil +end + +function Environment:LoadAddOn(name) + if C_AddOns and C_AddOns.LoadAddOn then return C_AddOns.LoadAddOn(name) end + if LoadAddOn then return LoadAddOn(name) end + Bastion:Debug("[LoadAddOn] failed") + return nil +end + +function Environment:IsAddonLoaded(name) + if C_AddOns and C_AddOns.IsAddonLoaded then return C_AddOns.IsAddonLoaded(name) end + if IsAddOnLoaded then return IsAddOnLoaded(name) end + Bastion:Debug("[IsAddonLoaded] failed") + return nil +end + return Environment diff --git a/src/Locale/Locale.lua b/src/Locale/Locale.lua new file mode 100644 index 0000000..af216a4 --- /dev/null +++ b/src/Locale/Locale.lua @@ -0,0 +1,6 @@ +local Tinkr, Bastion = ... + +local Locale = {} +Locale.__index = Locale + +return Locale diff --git a/src/_bastion.lua b/src/_bastion.lua index 5607b83..a1cb5c0 100644 --- a/src/_bastion.lua +++ b/src/_bastion.lua @@ -58,6 +58,9 @@ end Bastion.Globals = {} +---@type Locale +Bastion.Locale = Bastion.require("Locale") +Load("@Locales/") ---@type Environment Bastion.Environment = Bastion.require("Environment") ---@type ClassMagic