Mercurial > wow > inventory
comparison Config.lua @ 68:710f03653aaf
When the track at option of a group is overridden, the default is no longer passed by reference but copied whenever it is a table.
author | Zerotorescue |
---|---|
date | Thu, 23 Dec 2010 13:57:48 +0100 |
parents | ac1189599769 |
children | 6329ee822172 |
comparison
equal
deleted
inserted
replaced
67:67181b118bed | 68:710f03653aaf |
---|---|
20 -- If this is an override toggler then also set the related field to nil | 20 -- If this is an override toggler then also set the related field to nil |
21 addon.db.profile.groups[groupName][info.arg] = nil; | 21 addon.db.profile.groups[groupName][info.arg] = nil; |
22 elseif value and info.arg then | 22 elseif value and info.arg then |
23 -- If this override is now enabled, we need to copy the default into this field (unless it is not nil (which is supposed to be impossible), in which case we'll use the already selected value) | 23 -- If this override is now enabled, we need to copy the default into this field (unless it is not nil (which is supposed to be impossible), in which case we'll use the already selected value) |
24 | 24 |
25 addon.db.profile.groups[groupName][info.arg] = addon:GetOptionByKey(groupName, info.arg); | 25 local inheritedValue = addon:GetOptionByKey(groupName, info.arg); |
26 | |
27 addon.db.profile.groups[groupName][info.arg] = (type(inheritedValue) ~= "table" and inheritedValue) or CopyTable(inheritedValue); -- copying defaults by reference would let one (unintendedly) change the defaults | |
26 end | 28 end |
27 end | 29 end |
28 | 30 |
29 if multiSelectEnabled ~= nil then | 31 if multiSelectEnabled ~= nil then |
30 -- The saved vars for a multiselect will always be an array, it may not yet exist in which case it must be created. | 32 -- The saved vars for a multiselect will always be an array, it may not yet exist in which case it must be created. |
53 | 55 |
54 local function GetMultiOption(info, value) | 56 local function GetMultiOption(info, value) |
55 local groupName = groupIdToName[info[2]]; | 57 local groupName = groupIdToName[info[2]]; |
56 local optionName = info[#info]; | 58 local optionName = info[#info]; |
57 | 59 |
58 if addon.db.profile.groups[groupName][optionName] ~= nil then | 60 local multiSelectValue = addon:GetOptionByKey(groupName, optionName); |
59 return addon.db.profile.groups[groupName][optionName][value]; | 61 |
60 elseif addon.db.profile.defaults[optionName] then | 62 return multiSelectValue and multiSelectValue[value]; |
61 return addon.db.profile.defaults[optionName][value]; | |
62 else | |
63 return nil; | |
64 end | |
65 end | 63 end |
66 | 64 |
67 local function GetDisabled(info) | 65 local function GetDisabled(info) |
68 local groupName = groupIdToName[info[2]]; | 66 local groupName = groupIdToName[info[2]]; |
69 local optionName = info[#info]; | 67 local optionName = info[#info]; |
1460 temp[charName] = charName; | 1458 temp[charName] = charName; |
1461 end | 1459 end |
1462 | 1460 |
1463 return temp; | 1461 return temp; |
1464 end, | 1462 end, |
1465 get = function(i, v) return addon.db.profile.defaults.trackAtCharacters[v]; end, | 1463 get = function(i, v) |
1466 set = function(i, v, e) addon.db.profile.defaults.trackAtCharacters[v] = e or nil; end, | 1464 return addon.db.profile.defaults.trackAtCharacters[v]; |
1465 end, | |
1466 set = function(i, v, e) | |
1467 addon.db.profile.defaults.trackAtCharacters[v] = e or nil; | |
1468 end, | |
1467 dialogControl = "Dropdown", -- this is not standard, normal multiselect control gives us a list of all chars with toggle-boxes. UGLY! We want a multiselect-box instead. | 1469 dialogControl = "Dropdown", -- this is not standard, normal multiselect control gives us a list of all chars with toggle-boxes. UGLY! We want a multiselect-box instead. |
1468 }, | 1470 }, |
1469 }, | 1471 }, |
1470 }, | 1472 }, |
1471 refill = { | 1473 refill = { |