diff Config.lua @ 65:ac1189599769

Added warning to AuctionLite pricing addon selection stating the addon wasn?t tested properly yet. Premade groups check now occurs when the config is opened rather than upon login. All multiselects are now dropdowns as they are meant to be. Please ensure the pullouts are closed before switching groups or closing the window or you may get some LUA errors (thanks Wowace for not fixing what seems to be a year old issue). Hopefully added support for the crafting addon ?Cauldron?, but this still has to be tested.
author Zerotorescue
date Thu, 23 Dec 2010 03:19:27 +0100
parents fee06221176f
children 710f03653aaf
line wrap: on
line diff
--- a/Config.lua	Wed Dec 22 20:01:13 2010 +0100
+++ b/Config.lua	Thu Dec 23 03:19:27 2010 +0100
@@ -421,7 +421,7 @@
 								["Mailbox"] = "Mailbox",
 							},
 							get = GetMultiOption,
-							--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.
+							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.
 							arg = "overrideLocalItemData",
 						},
 						virtualGroup = {
@@ -579,7 +579,7 @@
 								return temp;
 							end,
 							get = GetMultiOption,
-							--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.
+							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.
 							arg = "overrideTrackAtCharacters",
 						},
 					},
@@ -1190,11 +1190,15 @@
 end
 
 function mod:RefreshConfig()
+	self:PremadeGroupsCheck();
+	
 	self:FillGroupOptions();
 end
 
 function mod:Load()
 	if not AceConfigDialog and not AceConfigRegistry then
+		self:PremadeGroupsCheck();
+		
 		self:FillOptions();
 	
 		-- Build options dialog
@@ -1372,7 +1376,7 @@
 						},
 						get = function(i, v) return addon.db.profile.defaults.localItemData and addon.db.profile.defaults.localItemData[v]; end,
 						set = function(i, v, e) addon.db.profile.defaults.localItemData[v] = e or nil; end,
-						--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.
+						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.
 					},
 				},
 			},
@@ -1460,7 +1464,7 @@
 						end,
 						get = function(i, v) return addon.db.profile.defaults.trackAtCharacters[v]; end,
 						set = function(i, v, e) addon.db.profile.defaults.trackAtCharacters[v] = e or nil; end,
-						--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.
+						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.
 					},
 				},
 			},
@@ -1903,3 +1907,95 @@
 		end
 	end
 end
+
+
+
+
+
+
+-- Verify premade groups
+
+function mod:PremadeGroupsCheck(updateGroupName, updateKey, accept)
+	-- Compare the current premade groups with those used, notify about changes
+	if addon.defaultGroups then
+		for premadeGroupName, groupInfo in pairs(addon.defaultGroups) do
+			-- Go through all default groups
+			
+			for groupName, values in pairs(addon.db.profile.groups) do
+				-- Go through all groups to find those with this premade group
+				
+				if values.premadeGroups and values.premadeGroups[premadeGroupName] and values.premadeGroups[premadeGroupName] < groupInfo.version then
+					-- Outdated group
+					
+					if updateGroupName and updateKey then
+						-- This function was called after pressing yes or no in a confirm box
+						
+						if accept then
+							-- Yes was clicked
+							
+							for itemId, version in pairs(groupInfo.items) do
+								-- Go through all items in this premade group
+								
+								if version > values.premadeGroups[premadeGroupName] then
+									-- This item was added in a more recent version than this group: Add item
+									
+									if addon:InGroup(itemId) then
+										print(("Skipping %s (#%d) as it is already in the group |cfffed000%s|r."):format(select(2, GetItemInfo(itemId)) or "Unknown", itemId, addon:InGroup(itemId)));
+									elseif addon:AddItemToGroup(groupName, itemId) then
+										print(("|cff00ff00Added|r %s (#%d) found in the premade group |cfffed000%s|r to the group |cfffed000%s|r."):format(select(2, GetItemInfo(itemId)) or "Unknown", itemId, premadeGroupName, addon:InGroup(itemId)));
+									end
+								elseif ( version * -1 ) > values.premadeGroups[premadeGroupName] then
+									if addon:InGroup(itemId) == groupName then
+										print(("|cffff0000Removed|r %s (#%d) from the group |cfffed000%s|r as it was removed from the premade group |cfffed000%s|r."):format(select(2, GetItemInfo(itemId)) or "Unknown", itemId, addon:InGroup(itemId), premadeGroupName));
+										addon:RemoveItemFromGroup(groupName, itemId);
+									else
+										print(("Skipping the removal of %s (#%d) as it isn't in this group."):format(select(2, GetItemInfo(itemId)) or "Unknown", itemId, addon:InGroup(itemId)));
+									end
+								end
+							end
+							
+							-- Remember the new version
+							values.premadeGroups[premadeGroupName] = groupInfo.version;
+						else
+							-- No was clicked
+							
+							-- Let user know what was not added
+							for itemId, version in pairs(groupInfo.items) do
+								-- Go through all items in this premade group
+								
+								if version > values.premadeGroups[premadeGroupName] then
+									-- This item was added in a more recent version than this group: don't add (since we clicked no), but announce it
+									
+									print(("Skipping %s (#%d) found in the premade group |cfffed000%s|r."):format(select(2, GetItemInfo(itemId)) or "Unknown", itemId, addon:InGroup(itemId)));
+								end
+							end
+							
+							-- Remember the new version
+							values.premadeGroups[premadeGroupName] = groupInfo.version;
+						end
+					else
+						StaticPopupDialogs["InventoriumConfirmUpdatePremadeGroup"] = {
+							text = "The premade group |cfffed000%s|r used in the group |cfffed000%s|r has been changed. Do you wish to copy these changes?",
+							button1 = YES,
+							button2 = NO,
+							OnAccept = function()
+								addon:PremadeGroupsCheck(groupName, premadeGroupName, true);
+							end,
+							OnCancel = function(_, _, reason)
+								if reason == "clicked" then
+									addon:PremadeGroupsCheck(groupName, premadeGroupName, false);
+								end
+							end,
+							timeout = 0,
+							whileDead = 1,
+							hideOnEscape = 1,
+						};
+						StaticPopup_Show("InventoriumConfirmUpdatePremadeGroup", premadeGroupName, groupName);
+						
+						return;
+					end
+				end
+			end
+		end
+	end
+end