Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ NotGrid is a party and raid frame addon for Vanilla World of Warcraft (1.12.1).
Use */notgrid* or */ng* to show the config menu.
Use */notgrid grid* to generate a style similar to the original grid.
Use */notgrid reset* to restore the default settings.
Use */notgrid profile save <profilename>* to save current settings as a profile (account-wide).
Use */notgrid profile load <profilename>* to load a saved profile (account-wide).
Use */notgrid profile delete <profilename>* to delete a saved profile (account-wide).
Use */notgrid profile list* to show all available profiles (account-wide).
Use / for separating multiple Buffs/Debuffs to track on one icon.
Use */ngcast spellname(Rank X)* in macros for mouseover casting.

Expand Down
6 changes: 6 additions & 0 deletions core.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
local L = AceLibrary("AceLocale-2.2"):new("NotGrid")
NotGrid = AceLibrary("AceAddon-2.0"):new("AceEvent-2.0")
NotGridOptions = {} -- After the addon is fully initialized WoW will fill this up with its saved variables if any
-- NotGridProfiles will be initialized safely in OnEnable after saved variables are loaded

function NotGrid:OnInitialize()
self.HealComm = AceLibrary("HealComm-1.0")
Expand All @@ -20,6 +21,11 @@ function NotGrid:OnInitialize()
end

function NotGrid:OnEnable()
-- Initialize profiles after saved variables are loaded
if not NotGridProfiles then
NotGridProfiles = {}
end

self.o = NotGridOptions -- Need to wait for addon to be fully initialized and saved variables loaded before I set this
self:SetDefaultOptions() -- if NotGridOptions is empty(no saved variables) this will fill it up with defaults
self:DoDropDown()
Expand Down
1 change: 1 addition & 0 deletions notgrid.toc
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## Notes: It's Not Grid
## Notes-ruRU: Это не Grid
## SavedVariablesPerCharacter: NotGridOptions
## SavedVariables: NotGridProfiles

Libs\AceLibrary\AceLibrary.lua
Libs\AceLocale-2.2\AceLocale-2.2.lua
Expand Down
100 changes: 100 additions & 0 deletions options.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
local L = AceLibrary("AceLocale-2.2"):new("NotGrid")

local function deepcopy(orig)
local orig_type = type(orig)
local copy
if orig_type == 'table' then
copy = {}
for orig_key, orig_value in next, orig, nil do
copy[deepcopy(orig_key)] = deepcopy(orig_value)
end
setmetatable(copy, deepcopy(getmetatable(orig)))
else -- number, string, boolean, function
copy = orig
end
return copy
end

local DefaultOptions = {
["version"] = 1.132, -- will be the commit number from now on.
["versionchecking"] = true,
Expand Down Expand Up @@ -159,6 +174,91 @@ function SlashCmdList.NOTGRID(msg, editbox)
NotGrid.o.colorunithealthbarbyclass = false
NotGrid.o.colorunithealthbarbgbyclass = true
ReloadUI()
elseif type(msg) == "string" and string.find(msg, "^profile") then
local _, args = string.match(msg, "^(profile)%s*(.*)")
local action = "list"
local profileName = nil

if args and args ~= "" then
local words = {}
for word in string.gmatch(args, "%S+") do
table.insert(words, word)
end

if words[1] then
action = words[1]
profileName = words[2]
end
end

if action == "save" then
if profileName then
-- Validate that profiles table exists before saving
if not NotGridProfiles then
DEFAULT_CHAT_FRAME:AddMessage("NotGrid: Error - Profile system not initialized!")
return
end
NotGridProfiles[profileName] = deepcopy(NotGrid.o)
DEFAULT_CHAT_FRAME:AddMessage("NotGrid profile '" .. profileName .. "' saved.")
else
DEFAULT_CHAT_FRAME:AddMessage("Usage: /ng profile save <profilename>")
end
elseif action == "load" then
if profileName then
-- Validate that profiles table exists before loading
if not NotGridProfiles then
DEFAULT_CHAT_FRAME:AddMessage("NotGrid: Error - Profile system not initialized!")
return
end
if NotGridProfiles[profileName] then
for k in pairs(NotGrid.o) do NotGrid.o[k] = nil end
for k, v in pairs(NotGridProfiles[profileName]) do NotGrid.o[k] = deepcopy(v) end
NotGrid:SetDefaultOptions()
ReloadUI()
DEFAULT_CHAT_FRAME:AddMessage("NotGrid profile '" .. profileName .. "' loaded.")
else
DEFAULT_CHAT_FRAME:AddMessage("NotGrid profile '" .. profileName .. "' not found.")
end
else
DEFAULT_CHAT_FRAME:AddMessage("Usage: /ng profile load <profilename>")
end
elseif action == "delete" then
if profileName then
-- Validate that profiles table exists before deleting
if not NotGridProfiles then
DEFAULT_CHAT_FRAME:AddMessage("NotGrid: Error - Profile system not initialized!")
return
end
if NotGridProfiles[profileName] then
NotGridProfiles[profileName] = nil
DEFAULT_CHAT_FRAME:AddMessage("NotGrid profile '" .. profileName .. "' deleted.")
else
DEFAULT_CHAT_FRAME:AddMessage("NotGrid profile '" .. profileName .. "' not found.")
end
else
DEFAULT_CHAT_FRAME:AddMessage("Usage: /ng profile delete <profilename>")
end
elseif action == "list" then
-- Validate that profiles table exists before listing
if not NotGridProfiles then
DEFAULT_CHAT_FRAME:AddMessage("NotGrid: Error - Profile system not initialized!")
return
end
local profileCount = 0
local profileList = ""
for name in pairs(NotGridProfiles) do
if profileList ~= "" then profileList = profileList .. ", " end
profileList = profileList .. name
profileCount = profileCount + 1
end
if profileCount > 0 then
DEFAULT_CHAT_FRAME:AddMessage("Available NotGrid profiles: " .. profileList)
else
DEFAULT_CHAT_FRAME:AddMessage("No NotGrid profiles saved.")
end
else
DEFAULT_CHAT_FRAME:AddMessage("Invalid profile action. Usage: /ng profile [save|load|delete <profilename>] or /ng profile list")
end
else
NotGridOptionsMenu:Show()
end
Expand Down