Upload files to "/"
This commit is contained in:
@@ -2,7 +2,7 @@
|
|||||||
## Title: RelationshipsThreatPlates - OctoWoW
|
## Title: RelationshipsThreatPlates - OctoWoW
|
||||||
## Notes: OctoWoW-compatible RelationshipsThreatPlates
|
## Notes: OctoWoW-compatible RelationshipsThreatPlates
|
||||||
## Author: Relationship
|
## Author: Relationship
|
||||||
## Version: 1.4
|
## Version: 1.5
|
||||||
## SavedVariables: RelationshipsThreatPlatesDB
|
## SavedVariables: RelationshipsThreatPlatesDB
|
||||||
## X-Website: https://github.com/Relationship-OctoWoW/RelationshipsThreatPlates
|
## X-Website: https://github.com/Relationship-OctoWoW/RelationshipsThreatPlates
|
||||||
## X-GitHub: https://github.com/Relationship-OctoWoW/RelationshipsThreatPlates
|
## X-GitHub: https://github.com/Relationship-OctoWoW/RelationshipsThreatPlates
|
||||||
|
|||||||
@@ -111,45 +111,76 @@ local function DeepCopy(src)
|
|||||||
return dst
|
return dst
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- ==================================================================
|
||||||
|
-- Ensure SavedVariable table exists and has all default keys.
|
||||||
|
-- Safe to call multiple times.
|
||||||
|
-- ==================================================================
|
||||||
|
local function EnsureDB()
|
||||||
|
if not RelationshipsThreatPlatesDB then
|
||||||
|
RelationshipsThreatPlatesDB = DeepCopy(DEFAULT_CONFIG)
|
||||||
|
else
|
||||||
|
for k, v in pairs(DEFAULT_CONFIG) do
|
||||||
|
if RelationshipsThreatPlatesDB[k] == nil then
|
||||||
|
RelationshipsThreatPlatesDB[k] = DeepCopy(v)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
addon.EnsureDB = EnsureDB
|
||||||
|
|
||||||
|
-- In WoW 1.12, SavedVariables are loaded BEFORE the addon's Lua files
|
||||||
|
-- execute, so it is safe to initialize the DB at file load. Doing this
|
||||||
|
-- here (in addition to ADDON_LOADED) protects against cases where the
|
||||||
|
-- installed folder name doesn't match TP_ADDON_NAME exactly
|
||||||
|
-- (e.g. "RelationshipsThreatPlates-main" from a GitHub zip), which
|
||||||
|
-- would otherwise cause the ADDON_LOADED arg1 check to fail and leave
|
||||||
|
-- RelationshipsThreatPlatesDB nil - the root cause of
|
||||||
|
-- "attempt to index global 'RelationshipsThreatPlatesDB' a nil value"
|
||||||
|
-- reported at RelationshipsThreatPlates_GUI.lua:320.
|
||||||
|
EnsureDB()
|
||||||
|
|
||||||
-- ==================================================================
|
-- ==================================================================
|
||||||
-- Event handling
|
-- Event handling
|
||||||
-- ==================================================================
|
-- ==================================================================
|
||||||
addon:RegisterEvent("ADDON_LOADED")
|
addon:RegisterEvent("ADDON_LOADED")
|
||||||
addon:RegisterEvent("PLAYER_ENTERING_WORLD")
|
addon:RegisterEvent("PLAYER_ENTERING_WORLD")
|
||||||
|
|
||||||
|
local modulesInitialized = false
|
||||||
|
local function InitializeModules()
|
||||||
|
if modulesInitialized then return end
|
||||||
|
modulesInitialized = true
|
||||||
|
|
||||||
|
EnsureDB()
|
||||||
|
|
||||||
|
-- Ensure media textures
|
||||||
|
addon.Media.EnsureTextures()
|
||||||
|
|
||||||
|
-- Initialize modules
|
||||||
|
addon.ThreatEngine:Initialize()
|
||||||
|
addon.Threat:Initialize()
|
||||||
|
addon.Nameplates:Initialize()
|
||||||
|
addon.GUI:Initialize()
|
||||||
|
|
||||||
|
addon:ui_print("v" .. TP_VERSION .. " loaded! Type /tp for options.")
|
||||||
|
end
|
||||||
|
|
||||||
addon:SetScript("OnEvent", function()
|
addon:SetScript("OnEvent", function()
|
||||||
if event == "ADDON_LOADED" and arg1 == TP_ADDON_NAME then
|
if event == "ADDON_LOADED" then
|
||||||
-- Initialize saved variables with defaults
|
-- Accept any ADDON_LOADED: this script only runs when our addon
|
||||||
if not RelationshipsThreatPlatesDB then
|
-- is loaded, so the first ADDON_LOADED we see is safe to act on.
|
||||||
RelationshipsThreatPlatesDB = DeepCopy(DEFAULT_CONFIG)
|
-- This avoids folder-rename issues where arg1 ~= TP_ADDON_NAME.
|
||||||
else
|
InitializeModules()
|
||||||
-- Merge in any missing keys from defaults
|
|
||||||
for k, v in pairs(DEFAULT_CONFIG) do
|
|
||||||
if RelationshipsThreatPlatesDB[k] == nil then
|
|
||||||
RelationshipsThreatPlatesDB[k] = DeepCopy(v)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Ensure media textures
|
|
||||||
addon.Media.EnsureTextures()
|
|
||||||
|
|
||||||
-- Initialize modules
|
|
||||||
addon.ThreatEngine:Initialize()
|
|
||||||
addon.Threat:Initialize()
|
|
||||||
addon.Nameplates:Initialize()
|
|
||||||
addon.GUI:Initialize()
|
|
||||||
|
|
||||||
addon:ui_print("v" .. TP_VERSION .. " loaded! Type /tp for options.")
|
|
||||||
|
|
||||||
elseif event == "PLAYER_ENTERING_WORLD" then
|
elseif event == "PLAYER_ENTERING_WORLD" then
|
||||||
-- Force a nameplate scan on entering world
|
-- Safety net: if ADDON_LOADED was somehow missed, initialize now.
|
||||||
|
InitializeModules()
|
||||||
if RelationshipsThreatPlatesDB and RelationshipsThreatPlatesDB.enabled then
|
if RelationshipsThreatPlatesDB and RelationshipsThreatPlatesDB.enabled then
|
||||||
addon.Nameplates:UpdateAll()
|
addon.Nameplates:UpdateAll()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
|
||||||
-- ==================================================================
|
-- ==================================================================
|
||||||
-- Slash commands
|
-- Slash commands
|
||||||
-- ==================================================================
|
-- ==================================================================
|
||||||
|
|||||||
Reference in New Issue
Block a user