comparison Summary.lua @ 61:d903b0a151d3

Command handler function is now private, no need to keep it global when you can use the global SlashCmdList["INVENTORIUM"](msg) instead. Added database updating mechanism. All database vars are now stored in profiles rather than global. Now refreshing options when a different profile is selected. Fixed an issue with minimum local and global stock values not being inherited from the defaults.
author Zerotorescue
date Wed, 22 Dec 2010 15:04:09 +0100
parents 03c0610e9c1e
children fee06221176f
comparison
equal deleted inserted replaced
60:12c2b20ca843 61:d903b0a151d3
101 mod.frame:SetLayout("Fill"); 101 mod.frame:SetLayout("Fill");
102 mod.frame:SetCallback("OnClose", function(widget) 102 mod.frame:SetCallback("OnClose", function(widget)
103 mod:CancelTimer(self.tmrUpdater, true); 103 mod:CancelTimer(self.tmrUpdater, true);
104 mod:CloseFrame(); 104 mod:CloseFrame();
105 end); 105 end);
106 mod.frame:SetWidth(addon.db.global.defaults.summary.width); 106 mod.frame:SetWidth(addon.db.profile.defaults.summary.width);
107 mod.frame:SetHeight(addon.db.global.defaults.summary.height); 107 mod.frame:SetHeight(addon.db.profile.defaults.summary.height);
108 mod.frame.OnWidthSet = function(_, width) 108 mod.frame.OnWidthSet = function(_, width)
109 addon.db.global.defaults.summary.width = width; 109 addon.db.profile.defaults.summary.width = width;
110 end; 110 end;
111 mod.frame.OnHeightSet = function(_, height) 111 mod.frame.OnHeightSet = function(_, height)
112 addon.db.global.defaults.summary.height = height; 112 addon.db.profile.defaults.summary.height = height;
113 end; 113 end;
114 114
115 -- Close on escape 115 -- Close on escape
116 tinsert(UISpecialFrames, "InventoriumSummary"); 116 tinsert(UISpecialFrames, "InventoriumSummary");
117 117
206 sdrSpeed:SetLabel("Processing speed"); 206 sdrSpeed:SetLabel("Processing speed");
207 sdrSpeed:SetSliderValues(0.01, 5, 0.05); 207 sdrSpeed:SetSliderValues(0.01, 5, 0.05);
208 sdrSpeed:SetIsPercent(true); 208 sdrSpeed:SetIsPercent(true);
209 sdrSpeed:SetRelativeWidth(.3); 209 sdrSpeed:SetRelativeWidth(.3);
210 sdrSpeed:SetCallback("OnMouseUp", function(self, event, value) 210 sdrSpeed:SetCallback("OnMouseUp", function(self, event, value)
211 addon.db.global.defaults.summary.speed = ceil( value * 100 / 5 ); 211 addon.db.profile.defaults.summary.speed = ceil( value * 100 / 5 );
212 212
213 CACHE_ITEMS_PER_UPDATE = addon.db.global.defaults.summary.speed; -- max = 20, min = 1 213 CACHE_ITEMS_PER_UPDATE = addon.db.profile.defaults.summary.speed; -- max = 20, min = 1
214 end); 214 end);
215 sdrSpeed:SetValue( addon.db.global.defaults.summary.speed * 5 / 100 ); 215 sdrSpeed:SetValue( addon.db.profile.defaults.summary.speed * 5 / 100 );
216 sdrSpeed:SetCallback("OnEnter", ShowTooltip); 216 sdrSpeed:SetCallback("OnEnter", ShowTooltip);
217 sdrSpeed:SetCallback("OnLeave", HideTooltip); 217 sdrSpeed:SetCallback("OnLeave", HideTooltip);
218 sdrSpeed.frame.tooltipTitle = "Caching Processing Speed"; 218 sdrSpeed.frame.tooltipTitle = "Caching Processing Speed";
219 sdrSpeed.frame.tooltip = "Change the speed at which item counts and auction values are being cached. Higher is faster but may drastically reduce your FPS while caching.\n\nAnything above 100% will probably become uncomfortable."; 219 sdrSpeed.frame.tooltip = "Change the speed at which item counts and auction values are being cached. Higher is faster but may drastically reduce your FPS while caching.\n\nAnything above 100% will probably become uncomfortable.";
220 220
263 addon:Debug("Time spent legend: (init / sorting / preparing / building / all)."); 263 addon:Debug("Time spent legend: (init / sorting / preparing / building / all).");
264 264
265 local playerName = UnitName("player"); 265 local playerName = UnitName("player");
266 266
267 -- Go through all our stored groups 267 -- Go through all our stored groups
268 for groupName, values in pairsByKeys(addon.db.global.groups, function(a, b) return a:lower() < b:lower(); end) do 268 for groupName, values in pairsByKeys(addon.db.profile.groups, function(a, b) return a:lower() < b:lower(); end) do
269 local groupStartTime, groupTimes = GetTime(), {}; 269 local groupStartTime, groupTimes = GetTime(), {};
270 270
271 local trackAt = addon:GetOptionByKey(groupName, "trackAtCharacters"); 271 local trackAt = addon:GetOptionByKey(groupName, "trackAtCharacters");
272 272
273 273
529 529
530 function mod:UpdateNextItem() 530 function mod:UpdateNextItem()
531 local i = 0; 531 local i = 0;
532 532
533 for groupName, items in pairs(itemsCache) do 533 for groupName, items in pairs(itemsCache) do
534 local minGlobalStock = addon:GetOptionByKey(groupName, "minimumStock"); 534 local minGlobalStock = addon:GetOptionByKey(groupName, "minGlobalStock");
535 local minLocalStock = addon:GetOptionByKey(groupName, "minimumLocalStock"); 535 local minLocalStock = addon:GetOptionByKey(groupName, "minLocalStock");
536 local priceThreshold = addon:GetOptionByKey(groupName, "priceThreshold"); 536 local priceThreshold = addon:GetOptionByKey(groupName, "priceThreshold");
537 537
538 for _, item in pairs(items) do 538 for _, item in pairs(items) do
539 if item.set then 539 if item.set then
540 if item.count == -3 then 540 if item.count == -3 then
574 574
575 if mod.frame then 575 if mod.frame then
576 mod.frame:SetStatusText(("Caching auction values and item-counts... %d%% has already been processed."):format(floor(CACHE_ITEMS_CURRENT / CACHE_ITEMS_TOTAL * 100))); 576 mod.frame:SetStatusText(("Caching auction values and item-counts... %d%% has already been processed."):format(floor(CACHE_ITEMS_CURRENT / CACHE_ITEMS_TOTAL * 100)));
577 end 577 end
578 578
579 if i >= addon.db.global.defaults.summary.speed then 579 if i >= addon.db.profile.defaults.summary.speed then
580 return; 580 return;
581 end 581 end
582 end 582 end
583 end 583 end
584 end 584 end
601 end 601 end
602 602
603 function mod:ColorCode(num, required) 603 function mod:ColorCode(num, required)
604 local percentage = ( num / required ); 604 local percentage = ( num / required );
605 605
606 if percentage >= addon.db.global.defaults.colors.green then 606 if percentage >= addon.db.profile.defaults.colors.green then
607 return ("|cff00ff00%d|r"):format(num); 607 return ("|cff00ff00%d|r"):format(num);
608 elseif percentage >= addon.db.global.defaults.colors.yellow then 608 elseif percentage >= addon.db.profile.defaults.colors.yellow then
609 return ("|cffffff00%d|r"):format(num); 609 return ("|cffffff00%d|r"):format(num);
610 elseif percentage >= addon.db.global.defaults.colors.orange then 610 elseif percentage >= addon.db.profile.defaults.colors.orange then
611 return ("|cffff9933%d|r"):format(num); 611 return ("|cffff9933%d|r"):format(num);
612 elseif percentage >= addon.db.global.defaults.colors.red then 612 elseif percentage >= addon.db.profile.defaults.colors.red then
613 return ("|cffff0000%d|r"):format(num); 613 return ("|cffff0000%d|r"):format(num);
614 end 614 end
615 end 615 end
616 616
617 function mod:DisplayMoney(value, priceThreshold) 617 function mod:DisplayMoney(value, priceThreshold)