Mercurial > wow > inventory
changeset 189:90e5911a2ff1
Added full backup functionality.
Added a description to the export groups inline-group.
author | Zerotorescue |
---|---|
date | Mon, 31 Jan 2011 23:18:24 +0100 |
parents | 5cee31b1418a |
children | 830408b2d598 |
files | Modules/Config.lua |
diffstat | 1 files changed, 249 insertions(+), 73 deletions(-) [+] |
line wrap: on
line diff
--- a/Modules/Config.lua Mon Jan 31 15:06:37 2011 +0100 +++ b/Modules/Config.lua Mon Jan 31 23:18:24 2011 +0100 @@ -1860,7 +1860,7 @@ end function mod:FillExtraOptions() - local selectedExportGroups = {}; + local selectedExportGroups, enableBackupGeneration; options.args.extra = { order = 300, type = "group", @@ -1953,78 +1953,6 @@ }, }, }, - export = { - order = 20, - type = "group", - inline = true, - name = "Export groups", - args = { - localItemData = { - order = 0, - type = "multiselect", - name = "Select groups", - desc = "Select which groups should be included in the export.", - values = function() - local temp = {}; - - if addon.db.profile.groups then - temp["*InverseAll"] = "Inverse"; - - for groupName, _ in pairs(addon.db.profile.groups) do - temp[groupName] = groupName; - end - end - - return temp; - end, - get = function(info, value) - --local groupName = groupIdToName[info[2]]; - --local optionName = info[#info]; - - return selectedExportGroups[value]; - end, - set = function(info, name, value) - --local groupName = groupIdToName[info[2]]; - --local optionName = info[#info]; - - if name == "*InverseAll" then - for groupName, _ in pairs(addon.db.profile.groups) do - if selectedExportGroups[groupName] then - selectedExportGroups[groupName] = nil; - else - selectedExportGroups[groupName] = true; - end - end - else - if selectedExportGroups[name] then - selectedExportGroups[name] = nil; - else - selectedExportGroups[name] = true; - end - end - end, - }, - input = { - order = 10, - type = "input", - multiline = true, - width = "full", - name = "Exported data", - desc = "Export the group data for the currently selected group. Press CTRL-A to select all and CTRL-C to copy the text.", - set = false, - get = function(info) - local result = ""; - for groupName, v in pairs(selectedExportGroups) do - if v then - result = result .. mod:ExportGroup(groupName) .. "\n"; - end - end - - return result; - end, - }, - }, - }, colorCodes = { order = 30, type = "group", @@ -2093,6 +2021,254 @@ }, }, }, + export = { + order = 80, + type = "group", + inline = true, + name = "Export groups", + args = { + description = { + order = 0, + type = "description", + name = "Select the groups you wish to export below. Each group will have any account specific data removed and can safely and freely be shared with other users. All exported groups can be imported at once at the bottom of the \"Groups\" category of the config.", + hidden = function() return addon.db.profile.defaults.hideHelp; end, + }, + header = { + order = 5, + type = "header", + name = "", + hidden = function() return addon.db.profile.defaults.hideHelp; end, + }, + localItemData = { + order = 9, + type = "multiselect", + name = "Select groups", + desc = "Select which groups should be included in the export.", + values = function() + local temp = {}; + + if addon.db.profile.groups then + temp["*InverseAll"] = "Inverse"; + + for groupName, _ in pairs(addon.db.profile.groups) do + temp[groupName] = groupName; + end + end + + return temp; + end, + get = function(info, value) + --local groupName = groupIdToName[info[2]]; + --local optionName = info[#info]; + + return selectedExportGroups and selectedExportGroups[value]; + end, + set = function(info, name, value) + --local groupName = groupIdToName[info[2]]; + --local optionName = info[#info]; + + if not selectedExportGroups then + selectedExportGroups = {}; + end + + if name == "*InverseAll" then + for groupName, _ in pairs(addon.db.profile.groups) do + if selectedExportGroups and selectedExportGroups[groupName] then + selectedExportGroups[groupName] = nil; + else + selectedExportGroups[groupName] = true; + end + end + else + if selectedExportGroups and selectedExportGroups[name] then + selectedExportGroups[name] = nil; + else + selectedExportGroups[name] = true; + end + end + end, + }, + input = { + order = 10, + type = "input", + multiline = true, + width = "full", + name = "Exported data", + desc = "Exported group data for the currently selected group(s). Press CTRL-A to select all and CTRL-C to copy the text.", + set = false, + get = function() + local result = ""; + if selectedExportGroups then + for groupName, v in pairs(selectedExportGroups) do + if v then + result = result .. mod:ExportGroup(groupName) .. "\n"; + end + end + end + + return result; + end, + }, + }, + }, + backup = { + order = 100, + type = "group", + inline = true, + name = "Generate a full backup", + args = { + description = { + order = 0, + type = "description", + name = "With this you can generate a full backup of all your Inventorium settings. You can store this in a text file on your computer so you can import it at a later time if anything breaks to prevent losing a time consuming setup. You can also use it to share with other users but keep in mind this will include account specific data which you might not want in the wrong hands.", + hidden = function() return addon.db.profile.defaults.hideHelp; end, + }, + header = { + order = 5, + type = "header", + name = "", + hidden = function() return addon.db.profile.defaults.hideHelp; end, + }, + generate = { + order = 9, + type = "toggle", + width = "full", + name = "Generate a full backup (might take a second)", + desc = "Generate a full backup. This process might take 1 to 2 seconds.", + set = function(_, v) + enableBackupGeneration = v; + end, + get = function() + return enableBackupGeneration; + end, + }, + input = { + order = 10, + type = "input", + multiline = true, + width = "full", + name = "Exported data", + desc = "Exported backup data. Press CTRL-A to select all and CTRL-C to copy the text.\n\nPlease note this includes character data.", + set = false, + get = function() + if not enableBackupGeneration then + return; + end + + -- We want to include the group name, so we copy the table then set another value + local temp = { + ["type"] = "backup", + ["global"] = addon.db.global or {}, + ["profiles"] = addon.db.profiles or {}, + ["factionrealm"] = addon.db.factionrealm or {}, + }; + + if not AceSerializer then + AceSerializer = LibStub("AceSerializer-3.0"); + end + + return AceSerializer:Serialize(temp); + end, + }, + }, + }, + importBackup = { + order = 101, + type = "group", + inline = true, + name = "Import a full backup", + args = { + description = { + order = 0, + type = "description", + name = "With this you can import a full backup of all your Inventorium settings. |cffff0000Warning! Importing a backup will TRASH all your current settings and profiles. You are advised to store your own backup prior to importing one.|r", + hidden = function() return addon.db.profile.defaults.hideHelp; end, + }, + header = { + order = 5, + type = "header", + name = "", + hidden = function() return addon.db.profile.defaults.hideHelp; end, + }, + input = { + order = 10, + type = "input", + multiline = true, + width = "full", + name = "Paste the backup data here", + desc = "Exported backup data. To copy the backup data, press CTRL-A to select all and CTRL-C to copy it. Then click this textblock and hit CTRL-V to paste it.", + set = function(_, v) + if v and string.trim(v) ~= "" then + if not AceSerializer then + AceSerializer = LibStub("AceSerializer-3.0"); + end + + local result, temp = AceSerializer:Deserialize(v); + + if result and temp and type(temp) == "table" and temp.type and temp.type == "backup" then + addon.db:ResetDB("TEMPPROFILENAME" .. GetTime()); + + local tempProfileName = addon.db:GetCurrentProfile(); + + if temp.global then + print("Importing |cfffed000global|r data..."); + + -- Update by reference, rather than changing the reference + for k, v in pairs(temp.global) do + addon.db.global[k] = v; + end + end + + if temp.profiles then + print("Importing |cfffed000profiles|r data..."); + + -- Update by reference, rather than changing the reference + for profileName, profile in pairs(temp.profiles) do + print("Importing profile |cfffed000" .. profileName .. "|r..."); + + addon.db.profiles[profileName] = profile; + + -- If the current profile is the temp profile, select the first profile in the backup + if addon.db:GetCurrentProfile() == tempProfileName or profileName == "Default" then + addon.db:SetProfile(profileName); + end + + -- If our backup contains a profile with the same name as the temp profile, then don't delete the temp profile + if profileName == tempProfileName then + tempProfileName = nil; + end + end + end + + -- Delete the temp profile + if tempProfileName then + addon.db:DeleteProfile(tempProfileName); + end + + if temp.factionrealm then + print("Importing |cfffed000character|r data..."); + + -- Update by reference, rather than changing the reference + for k, v in pairs(temp.factionrealm) do + addon.db.factionrealm[k] = v; + end + end + + mod:FillGroupOptions(); + + addon:Print("Import finished.", addon.Colors.Green); + else + addon:Print("The data provided is not supported.", addon.Colors.Red); + end + else + addon:Print("The data provided is not supported.", addon.Colors.Red); + end + end, + get = false, + confirm = function() return "Are you sure you wish to override all your current settings with this data?"; end, + }, + }, + }, }, }; end