Okay so i have a frame mover system. Sometimes i find i need to add certain frames to the default and i need the ui to check when someone downloads an update if new frames were added to the default table and if so add them to the variables. Without wiping anything the user may have added in between versions. Can I somehow have it version check then if it finds that its a new version compare the default table to the current saved variables and then copy only the missing entry's?
This is the relevant part of the code. Note that the addon already stores the last version its accessed via addon.settings.version a tonumber will be required. Edit- i added the beginning of the function for it just dont know how to make the tables compare and then add to accordingly.
Code:
local addonName, addon = ...
addon:RegisterDefaultSetting("lockFrames", false)
--[[-----------------------------------------------------------------------------
Frames to allow moving and saving
-------------------------------------------------------------------------------]]
--["FrameName"] = false - move the frame
--true - move the frame's parent instead
--string - move the named frame instead
function addon:DefaultMoveableFrames()
if not GMoveableFrames then
GMoveableFrames = GMoveableFrames or {
['MiniMapLFGFrame'] = false,
['ShardBarFrame'] = false,
['BNToastFrame'] = false,
['SpellBookFrame'] = false,
['QuestLogFrame'] = false,
['FriendsFrame'] = false,
['LFDParentFrame'] = false,
['KnowledgeBaseFrame'] = true,
['MerchantFrame'] = false,
['MailFrame'] = false,
['DressUpFrame'] = false,
['TaxiFrame'] = false,
['QuestLogFrame'] = false,
['PaperDollFrame'] = true,
['PVPFrame'] = false,
['WatchFrameHeader'] = true,
['VehicleMenuBar'] = false,
['InspectFrame'] = false,
['PlayerTalentFrame'] = false,
['AchievementFrame'] = false,
['AchievementFrameHeader'] = true,
['AchievementFrameCategoriesContainer'] = 'AchievementFrame',
['GlyphFrame'] = 'PlayerTalentFrame',
['CalendarFrame'] = false,
['ContainerFrame1'] = false,
['ContainerFrame2'] = false,
['ContainerFrame3'] = false,
['ContainerFrame4'] = false,
['ContainerFrame5'] = false,
['Minimap'] = false,
--GrimUI Frames
['GrimUIPlayerFrame'] = false,
['GrimUIPartyFrame1'] = false,
['GrimUIPartyFrame2'] = false,
['GrimUIPartyFrame3'] = false,
['GrimUIPartyFrame4'] = false,
['GrimExpBar'] = false,
['GrimRepBar'] = false,
['GDevBar'] = false,
['GUITTAnchor'] = false,
}
end
end
--[[-----------------------------------------------------------------------------
Initialize
-------------------------------------------------------------------------------]]
local CurVerNum = tonumber(GetAddOnMetadata(addonName, 'Version'))
local LastVerNum
local function VerCheckUpdate()
LastVerNum = tonumber(addon.settings.version)
if CurVerNum > LastVerNum then
dosomthing
end
end
local moveableframes = {}
addon.RegisterEvent("MoveFrames-Initialize", 'PLAYER_LOGIN', function(self, event)
addon.UnregisterEvent(self, event)
movedFrames = addon.settings.movedFrames
if type(movedFrames) ~= 'table' then
movedFrames = { }
addon.settings.movedFrames = movedFrames
end
addon:RegisterDefaultSetting("movedFrames", true) -- Prevent it from being removed on PLAYER_LOGOUT
local function HookFrames(self, event)
addon:DefaultMoveableFrames()
moveableframes = CopyTable(GMoveableFrames)
for name, parent in pairs(moveableframes) do
if HookFrame(name, parent) then
moveableframes[name] = nil
end
end
if next(moveableframes) then return end
addon.UnregisterEvent(self, event)
end
addon.RegisterEvent("MoveFrames-Hook", 'ADDON_LOADED', HookFrames)
HookFrames("MoveFrames-Hook", 'ADDON_LOADED')
end)