Mercurial > wow > inventory
diff Summary.lua @ 13:5006cb0e97c6
Removed sound media registrations since we don?t use them.
Added an option to include tadeskill items above a certain item level threshold in the add items config tab.
Renamed the variable for toggling hiding from summary when below price threshold-option. You will have to re-set it.
Summary size and processing speed will now be remembered.
Processing speed slider can now go up to 500% (up from 100%).
Silver will be hidden from money when it includes more than 10 gold (down from 100g) and copper will be hidden if it includes more than 1 gold (down from 10g).
Auction addons, crafting addons and itemcount addons can now register themselves through a few global functions. The most used addons have been included in the addon folder.
You can now select the prefered default pricing, item count and crafting addons.
Temporarily removed the ?dialogControl = ?DropDown?? from the track at select boxes. This functionality is broken within the Ace3 library and until it is fixed I wish to keep these options somewhat functional.
The item list will now be truncated before rebuilding. Previously items disappearing from your inventory would still appear in this list.
Mass add is now functional.
All buttons and sliders that were meant to receive a tooltip (including the sort-headers), now have one.
Added spacers between all buttons and sliders of the summary window.
Added a ?queue all? button to the summary window. This button is not yet functional.
If the value of an item is not retrieved from the auction prices database, it will appear as a dash (-) rather than ?0c?.
If no item count is enabled, item counts will appear as ?Unknown? instead of breaking (or defaulting to 0).
author | Zerotorescue |
---|---|
date | Mon, 18 Oct 2010 15:26:42 +0200 |
parents | 417c3cfb9623 |
children | 0fc8a54516d7 |
line wrap: on
line diff
--- a/Summary.lua Sat Oct 16 20:58:39 2010 +0200 +++ b/Summary.lua Mon Oct 18 15:26:42 2010 +0200 @@ -13,6 +13,25 @@ end, "s", "sum", "summary"); end +local function ShowTooltip(self) + -- If this function is called from a widget, self is the widget and self.frame the actual frame + local this = self.frame or self; + + GameTooltip:SetOwner(this, "ANCHOR_NONE"); + GameTooltip:SetPoint("BOTTOM", this, "TOP"); + GameTooltip:SetText(this.tooltipTitle, 1, .82, 0, 1); + + if type(this.tooltip) == "string" then + GameTooltip:AddLine(this.tooltip, 1, 1, 1, 1); + end + + GameTooltip:Show(); +end + +local function HideTooltip() + GameTooltip:Hide(); +end + function mod:RegisterWidgets() -- Register InlineGroupWithButton-widget -- This widget adds a button next to the header of an inline group @@ -35,20 +54,8 @@ button:SetScript("OnClick", buttonSettings.exec); button.tooltipTitle = buttonSettings.name; button.tooltip = buttonSettings.desc or ""; - button:SetScript("OnEnter", function(self) - GameTooltip:SetOwner(self, "ANCHOR_NONE") - GameTooltip:SetPoint("BOTTOM", self, "TOP") - GameTooltip:SetText(self.tooltipTitle, 1, .82, 0, 1) - - if type(self.tooltip) == "string" then - GameTooltip:AddLine(self.tooltip, 1, 1, 1, 1); - end - - GameTooltip:Show(); - end); - button:SetScript("OnLeave", function(self) - GameTooltip:Hide(); - end); + button:SetScript("OnEnter", ShowTooltip); + button:SetScript("OnLeave", HideTooltip); else error("settings must be a table - usage: MakeButton(table);"); end @@ -61,7 +68,8 @@ end local itemsCache = {}; -local CACHE_ITEMS_TOTAL, CACHE_ITEMS_CURRENT, CACHE_ITEMS_PER_UPDATE = 0, 0, 5; + +local CACHE_ITEMS_TOTAL, CACHE_ITEMS_CURRENT = 0, 0; local cacheStart; function mod:BuildMain() @@ -71,12 +79,20 @@ -- Main Window mod.frame = AceGUI:Create("Frame"); - mod.frame:SetTitle("Inventorium Summary"); + mod.frame:SetTitle("Summary"); mod.frame:SetLayout("Fill"); mod.frame:SetCallback("OnClose", function(widget) mod:CancelTimer(self.tmrUpdater, true); mod:CloseFrame(); end); + mod.frame:SetWidth(addon.db.global.defaults.summary.width); + mod.frame:SetHeight(addon.db.global.defaults.summary.height); + mod.frame.OnWidthSet = function(_, width) + addon.db.global.defaults.summary.width = width; + end; + mod.frame.OnHeightSet = function(_, height) + addon.db.global.defaults.summary.height = height; + end; -- ScrollFrame child mod.scrollFrame = AceGUI:Create("ScrollFrame"); @@ -144,7 +160,6 @@ -- Refresh button local btnRefresh = AceGUI:Create("Button"); btnRefresh:SetText("Refresh"); - -- SetTooltip: Reload all item counts and auction values. btnRefresh:SetRelativeWidth(.2); btnRefresh:SetCallback("OnClick", function() -- Reset items cache @@ -153,22 +168,75 @@ -- Rebuild itemlist and start caching mod:Build(); end); + btnRefresh:SetCallback("OnEnter", ShowTooltip); + btnRefresh:SetCallback("OnLeave", HideTooltip); + btnRefresh.frame.tooltipTitle = "Refresh Cache"; + btnRefresh.frame.tooltip = "Refresh the list and recache the item counts and auction values."; mod.scrollFrame:AddChild(btnRefresh); + local lblSpacer = AceGUI:Create("Label"); + lblSpacer:SetRelativeWidth(.03); + + mod.scrollFrame:AddChild(lblSpacer); + -- Speed slider - local btnRefresh = AceGUI:Create("Slider"); - btnRefresh:SetLabel("Processing speed"); - btnRefresh:SetSliderValues(0.01, 1, 0.01); - btnRefresh:SetIsPercent(true); - -- SetTooltip: Change the speed at which item counts and auction values are being cached. Higher is faster but may drastically reduce your FPS while caching. - btnRefresh:SetRelativeWidth(.3); - btnRefresh:SetCallback("OnMouseUp", function(self, event, value) - CACHE_ITEMS_PER_UPDATE = ceil( value * 100 / 5 ); -- max = 20, min = 1 + local sdrSpeed = AceGUI:Create("Slider"); + sdrSpeed:SetLabel("Processing speed"); + sdrSpeed:SetSliderValues(0.01, 5, 0.01); + sdrSpeed:SetIsPercent(true); + sdrSpeed:SetRelativeWidth(.3); + sdrSpeed:SetCallback("OnMouseUp", function(self, event, value) + addon.db.global.defaults.summary.speed = ceil( value * 100 / 5 ); + + CACHE_ITEMS_PER_UPDATE = addon.db.global.defaults.summary.speed; -- max = 20, min = 1 end); - btnRefresh:SetValue( CACHE_ITEMS_PER_UPDATE * 5 / 100 ); + sdrSpeed:SetValue( addon.db.global.defaults.summary.speed * 5 / 100 ); + sdrSpeed:SetCallback("OnEnter", ShowTooltip); + sdrSpeed:SetCallback("OnLeave", HideTooltip); + sdrSpeed.frame.tooltipTitle = "Caching Processing Speed"; + 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."; - mod.scrollFrame:AddChild(btnRefresh); + mod.scrollFrame:AddChild(sdrSpeed); + + local lblSpacer = AceGUI:Create("Label"); + lblSpacer:SetRelativeWidth(.23); + + mod.scrollFrame:AddChild(lblSpacer); + + -- Config button + --[[local btnConfig = AceGUI:Create("Button"); + btnConfig:SetText("Config"); + btnConfig:SetRelativeWidth(.2); + btnConfig:SetCallback("OnClick", function() + --TODO: Tidy up + SlashCmdList["INVENTORIUM"]("config"); + end); + btnConfig:SetCallback("OnEnter", ShowTooltip); + btnConfig:SetCallback("OnLeave", HideTooltip); + btnConfig.frame.tooltipTitle = "Config"; + btnConfig.frame.tooltip = "Click to open the config window. This will close the current window."; + + mod.scrollFrame:AddChild(btnConfig);]] + + local lblSpacer = AceGUI:Create("Label"); + lblSpacer:SetRelativeWidth(.03); + + mod.scrollFrame:AddChild(lblSpacer); + + -- Queue all button + local btnQueueAll = AceGUI:Create("Button"); + btnQueueAll:SetText("Queue All"); + btnQueueAll:SetRelativeWidth(.2); + btnQueueAll:SetCallback("OnClick", function() + + end); + btnQueueAll:SetCallback("OnEnter", ShowTooltip); + btnQueueAll:SetCallback("OnLeave", HideTooltip); + btnQueueAll.frame.tooltipTitle = "Queue all"; + btnQueueAll.frame.tooltip = "Queue everything that requires restocking within every single visible group."; + + mod.scrollFrame:AddChild(btnQueueAll); times.init = ceil( ( GetTime() - buildStartTime ) * 1000 ); addon:Debug("Time spent legend: (init / sorting / preparing / building / all)."); @@ -216,6 +284,10 @@ lblItem:SetFontObject(GameFontHighlight); lblItem:SetRelativeWidth(.7); lblItem:SetCallback("OnClick", function() ReSort("item"); end); + lblItem:SetCallback("OnEnter", ShowTooltip); + lblItem:SetCallback("OnLeave", HideTooltip); + lblItem.frame.tooltipTitle = "Item"; + lblItem.frame.tooltip = "Sort on the item quality, then name."; iGroup:AddChild(lblItem); @@ -225,15 +297,23 @@ lblQuantity:SetFontObject(GameFontHighlight); lblQuantity:SetRelativeWidth(.099); lblQuantity:SetCallback("OnClick", function() ReSort("current"); end); + lblQuantity:SetCallback("OnEnter", ShowTooltip); + lblQuantity:SetCallback("OnLeave", HideTooltip); + lblQuantity.frame.tooltipTitle = "Current stock"; + lblQuantity.frame.tooltip = "Sort on the amount of items currently in stock."; iGroup:AddChild(lblQuantity); -- Required stock local lblMinimumStock = AceGUI:Create("InteractiveLabel"); - lblMinimumStock:SetText("|cfffed000Req.|r"); + lblMinimumStock:SetText("|cfffed000Min.|r"); lblMinimumStock:SetFontObject(GameFontHighlight); lblMinimumStock:SetRelativeWidth(.099); lblMinimumStock:SetCallback("OnClick", function() ReSort("percentage"); end); + lblMinimumStock:SetCallback("OnEnter", ShowTooltip); + lblMinimumStock:SetCallback("OnLeave", HideTooltip); + lblMinimumStock.frame.tooltipTitle = "Minimum stock"; + lblMinimumStock.frame.tooltip = "Sort on the minimum amount of items you wish to keep in stock."; iGroup:AddChild(lblMinimumStock); @@ -243,6 +323,10 @@ lblValue:SetFontObject(GameFontHighlight); lblValue:SetRelativeWidth(.099); lblValue:SetCallback("OnClick", function() ReSort("value"); end); + lblValue:SetCallback("OnEnter", ShowTooltip); + lblValue:SetCallback("OnLeave", HideTooltip); + lblValue.frame.tooltipTitle = "Value"; + lblValue.frame.tooltip = "Sort on the item auction value."; iGroup:AddChild(lblValue); @@ -257,15 +341,11 @@ for itemId, _ in pairs(values.items) do local itemName, itemLink, itemRarity = GetItemInfo(itemId); - if not itemRarity then - print(itemId .. ": " .. itemName .. " - " .. itemLink); - end - table.insert(itemsCache[groupName], { id = itemId, name = itemName or unknownItemName:format(itemId), link = itemLink or unknownItemName:format(itemId), - value = ((priceThreshold == 0) and 0) or -3,-- if no price threshold is set for this item, then don't look it up either --addon:GetAuctionValue(itemLink), + value = ((priceThreshold == 0) and -4) or -3,-- if no price threshold is set for this item, then don't look it up either --addon:GetAuctionValue(itemLink), rarity = itemRarity or 1, count = -3,--addon:GetItemCount(itemId), set = {}, @@ -379,7 +459,9 @@ groupTimes.building = ceil( ( GetTime() - groupStartTime ) * 1000 ); end - addon:Debug(("Building of %s took %d ms (%d / %d / %d / %d / %d)."):format(groupName, ceil( ( GetTime() - groupStartTime ) * 1000 ), groupTimes.init, groupTimes.sorting, groupTimes.preparing, groupTimes.building, ceil( ( GetTime() - buildStartTime ) * 1000 ))); + if groupStartTime and groupTimes then + addon:Debug(("Building of %s took %d ms (%d / %d / %d / %d / %d)."):format(groupName, ceil( ( GetTime() - groupStartTime ) * 1000 ), groupTimes.init or 0, groupTimes.sorting or 0, groupTimes.preparing or 0, groupTimes.building or 0, ceil( ( GetTime() - buildStartTime ) * 1000 ))); + end end mod.scrollFrame:ResumeLayout(); @@ -428,7 +510,7 @@ mod.frame:SetStatusText(("Caching auction values and item-counts... %d%% has already been processed."):format(floor(CACHE_ITEMS_CURRENT / CACHE_ITEMS_TOTAL * 100))); end - if i >= CACHE_ITEMS_PER_UPDATE then + if i >= addon.db.global.defaults.summary.speed then return; end end @@ -473,6 +555,8 @@ return "|cff0000ffNo AH mod|r"; elseif value == -3 then return "|cffffff00Unknown|r"; + elseif value == -4 then + return "|cff00ff00-|r"; elseif value < priceThreshold then return ("|cffff0000%s|r"):format(addon:ReadableMoney(value or 0, true)); else @@ -481,7 +565,9 @@ end function mod:DisplayItemCount(value, minimumStock) - if value == -3 then + if value == -1 then + return "|cffffff00Unknown|r"; + elseif value == -3 then return "|cffffff00Unknown|r"; else return self:ColorCode(value, minimumStock); @@ -501,30 +587,3 @@ return formatted; end - ---[[ -No longer used, we're now caching complete item data instead of just AH values. -local AuctionValueCache = {}; -function mod:GetAuctionValue(link) - local itemId = addon:GetItemId(link); - - if AuctionValueCache[itemId] then - return AuctionValueCache[itemId]; - else - local value = addon:GetAuctionValue(link); - - AuctionValueCache[itemId] = value; - - -- Reset the cache 1 minute after last updating it - self:CancelTimer(self.tmrResetCache, true); - self.tmrResetCache = self:ScheduleTimer(function() - table.wipe(AuctionValueCache); - - mod.frame:SetStatusText("The auction item value cache has been reset."); - end, 60); - mod.frame:SetStatusText(""); - - return value; - end -end -]] \ No newline at end of file