diff --git a/Buy.lua b/Buy.lua index 5a4e965..fb39b16 100644 --- a/Buy.lua +++ b/Buy.lua @@ -180,7 +180,9 @@ function Auctionator_Buy_ScrollbarUpdate() local lineEntry_stackSize = getglobal("AuctionatorBuyEntry"..line.."_StackSize") local color = "ffffffff" - if(type(Auctionator.item_colors[entry.quality+1]) == "string") then color = Auctionator.item_colors[entry.quality+1]; end + if Auctionator.qualityColor(entry.quality) then + color = Auctionator.qualityColor(entry.quality) + end lineEntry_name:SetText("\124c" .. color .. entry.name .. "\124r") diff --git a/Core.lua b/Core.lua index 4b561f4..331614f 100644 --- a/Core.lua +++ b/Core.lua @@ -18,14 +18,21 @@ Auctionator = { index = 5 } }, - item_colors = { - "ff9d9d9d", -- poor, gray - "ffffffff", -- common, white - "ff1eff00", -- uncommon, green - "ff0070dd", -- rare, blue - "ffa335ee", -- epic, purple - "ffff8000", -- legendary, orange - } + qualityColor = function(code) + if code == 0 then + return "ff9d9d9d" -- poor, gray + elseif code == 1 then + return "ffffffff" -- common, white + elseif code == 2 then + return "ff1eff00" -- uncommon, green + elseif code == 3 then -- rare, blue + return "ff0070dd" + elseif code == 4 then + return "ffa335ee" -- epic, purple + elseif code == 5 then + return "ffff8000" -- legendary, orange + end + end } local relevel @@ -313,4 +320,62 @@ function relevel(frame) child:SetFrameLevel(myLevel) relevel(child) end +end + +----------------------------------------- + +function Auctionator_BrowseButton_OnClick(button) + if arg1 == "LeftButton" then -- because we additionally registered right clicks we only let left ones pass here + Auctionator.orig.BrowseButton_OnClick(button) + end +end + +----------------------------------------- + +function Auctionator_BrowseButton_OnMouseDown() + if arg1 == "RightButton" and AUCTIONATOR_INSTANT_BUYOUT then + local index = this:GetID() + FauxScrollFrame_GetOffset(BrowseScrollFrame) + + SetSelectedAuctionItem("list", index) + + local _, _, _, _, _, _, _, _, buyoutPrice = GetAuctionItemInfo("list", index) + if buyoutPrice > 0 then + PlaceAuctionBid("list", index, buyoutPrice) + end + + AuctionFrameBrowse_Update() + end +end + +----------------------------------------- + +function Auctionator_ContainerFrameItemButton_OnClick(button) + + if button == "LeftButton" + and IsShiftKeyDown() + and not ChatFrameEditBox:IsVisible() + and (PanelTemplates_GetSelectedTab(AuctionFrame) == 1 or PanelTemplates_GetSelectedTab(AuctionFrame) == Auctionator.tabs.buy.index) + then + local itemLink = GetContainerItemLink(this:GetParent():GetID(), this:GetID()) + if itemLink then + local itemName = string.gsub(itemLink, "^.-%[(.*)%].*", "%1") + if PanelTemplates_GetSelectedTab(AuctionFrame) == 1 then + BrowseName:SetText(itemName) + elseif PanelTemplates_GetSelectedTab(AuctionFrame) == Auctionator.tabs.buy.index then + AuctionatorBuySearchBox:SetText(itemName) + end + end + else + Auctionator.orig.ContainerFrameItemButton_OnClick(button) + + if AUCTIONATOR_ENABLE_ALT and AuctionFrame:IsShown() and IsAltKeyDown() and button == "LeftButton" then + + ClickAuctionSellItemButton() + ClearCursor() + + if PanelTemplates_GetSelectedTab(AuctionFrame) ~= Auctionator.tabs.sell.index then + AuctionFrameTab_OnClick(Auctionator.tabs.sell.index) + end + end + end end \ No newline at end of file diff --git a/Sell.lua b/Sell.lua index f417779..46b3739 100644 --- a/Sell.lua +++ b/Sell.lua @@ -26,43 +26,8 @@ end ----------------------------------------- -function Auctionator_ContainerFrameItemButton_OnClick(button) - - if button == "LeftButton" - and IsShiftKeyDown() - and not ChatFrameEditBox:IsVisible() - and (PanelTemplates_GetSelectedTab(AuctionFrame) == 1 or PanelTemplates_GetSelectedTab(AuctionFrame) == Auctionator.tabs.buy.index) - then - local itemLink = GetContainerItemLink(this:GetParent():GetID(), this:GetID()) - if itemLink then - local itemName = string.gsub(itemLink, "^.-%[(.*)%].*", "%1") - if PanelTemplates_GetSelectedTab(AuctionFrame) == 1 then - BrowseName:SetText(itemName) - elseif PanelTemplates_GetSelectedTab(AuctionFrame) == Auctionator.tabs.buy.index then - AuctionatorBuySearchBox:SetText(itemName) - end - end - else - Auctionator.orig.ContainerFrameItemButton_OnClick(button) - - if AUCTIONATOR_ENABLE_ALT and AuctionFrame:IsShown() and IsAltKeyDown() and button == "LeftButton" then - - ClickAuctionSellItemButton() - ClearCursor() - - if PanelTemplates_GetSelectedTab(AuctionFrame) ~= Auctionator.tabs.sell.index then - AuctionFrameTab_OnClick(Auctionator.tabs.sell.index) - end - end - end -end - ------------------------------------------ - function Auctionator_AuctionFrameAuctions_Update() - Auctionator.orig.AuctionFrameAuctions_Update() - if PanelTemplates_GetSelectedTab(AuctionFrame) == Auctionator.tabs.sell.index and AuctionFrame:IsShown() then Auctionator_HideElems(Auctionator.tabs.sell.hiddenElements) end @@ -73,25 +38,18 @@ end -- that we can note the auction values ----------------------------------------- -function Auctionator_AuctionsCreateAuctionButton_OnClick() - - if PanelTemplates_GetSelectedTab(AuctionFrame) == Auctionator.tabs.sell.index and AuctionFrame:IsShown() then - +function Auctionator_AuctionsCreateAuctionButton_OnClick() + if PanelTemplates_GetSelectedTab(AuctionFrame) == Auctionator.tabs.sell.index and AuctionFrame:IsShown() then lastBuyoutPrice = MoneyInputFrame_GetCopper(BuyoutPrice) lastItemPosted = currentAuctionItemName - end - Auctionator.orig.AuctionsCreateAuctionButton_OnClick() - end ----------------------------------------- function Auctionator_OnAuctionOwnedUpdate() - - if lastItemPosted then - + if lastItemPosted then Auctionator_Recommend_Text:SetText("Auction Created for "..lastItemPosted) MoneyFrame_Update("Auctionator_RecommendPerStack_Price", lastBuyoutPrice) @@ -113,31 +71,6 @@ end ----------------------------------------- -function Auctionator_BrowseButton_OnClick(button) - if arg1 == "LeftButton" then - Auctionator.orig.BrowseButton_OnClick(button) - end -end - ------------------------------------------ - -function Auctionator_BrowseButton_OnMouseDown() - if arg1 == "RightButton" and AUCTIONATOR_INSTANT_BUYOUT then - local index = this:GetID() + FauxScrollFrame_GetOffset(BrowseScrollFrame) - - SetSelectedAuctionItem("list", index) - - local _, _, _, _, _, _, _, _, buyoutPrice = GetAuctionItemInfo("list", index) - if buyoutPrice > 0 then - PlaceAuctionBid("list", index, buyoutPrice) - end - - AuctionFrameBrowse_Update() - end -end - ------------------------------------------ - function Auctionator_SetupHookFunctions() Auctionator.orig.BrowseButton_OnClick = BrowseButton_OnClick @@ -223,10 +156,10 @@ end function Auctionator_UpdateRecommendation() if not currentAuctionItemName then - AuctionatorRefreshButton:Disable() + AuctionatorSellRefreshButton:Disable() Auctionator_SetMessage("Drag an item to the Auction Item area\n\nto see recommended pricing information") else - AuctionatorRefreshButton:Enable() + AuctionatorSellRefreshButton:Enable() if selectedAuctionatorEntry then local newBuyoutPrice = selectedAuctionatorEntry.itemPrice * currentAuctionItemStackSize @@ -341,7 +274,7 @@ function Auctionator_ScrollbarUpdate() for line = 1,12 do local dataOffset = line + FauxScrollFrame_GetOffset(AuctionatorScrollFrame) - local lineEntry = getglobal("AuctionatorEntry"..line) + local lineEntry = getglobal("AuctionatorSellEntry"..line) if numrows <= 12 then lineEntry:SetWidth(603) @@ -353,38 +286,38 @@ function Auctionator_ScrollbarUpdate() if currentAuctionItemName and dataOffset <= numrows and auctionatorEntries[currentAuctionItemName] then - local auctionatorEntry = auctionatorEntries[currentAuctionItemName][dataOffset] + local entry = auctionatorEntries[currentAuctionItemName][dataOffset] - local lineEntry_avail = getglobal("AuctionatorEntry"..line.."_Availability") - local lineEntry_comm = getglobal("AuctionatorEntry"..line.."_Comment") - local lineEntry_stack = getglobal("AuctionatorEntry"..line.."_StackPrice") + local lineEntry_avail = getglobal("AuctionatorSellEntry"..line.."_Availability") + local lineEntry_comm = getglobal("AuctionatorSellEntry"..line.."_Comment") + local lineEntry_stack = getglobal("AuctionatorSellEntry"..line.."_StackPrice") - if selectedAuctionatorEntry and auctionatorEntry.itemPrice == selectedAuctionatorEntry.itemPrice and auctionatorEntry.stackSize == selectedAuctionatorEntry.stackSize then + if selectedAuctionatorEntry and entry.itemPrice == selectedAuctionatorEntry.itemPrice and entry.stackSize == selectedAuctionatorEntry.stackSize then lineEntry:LockHighlight() else lineEntry:UnlockHighlight() end - if auctionatorEntry.stackSize == currentAuctionItemStackSize then + if entry.stackSize == currentAuctionItemStackSize then lineEntry_avail:SetTextColor(0.2, 0.9, 0.2) else lineEntry_avail:SetTextColor(1.0, 1.0, 1.0) end - if auctionatorEntry.numYours == 0 then + if entry.numYours == 0 then lineEntry_comm:SetText("") elseif - auctionatorEntry.numYours == auctionatorEntry.count then + entry.numYours == entry.count then lineEntry_comm:SetText("yours") else - lineEntry_comm:SetText("yours: "..auctionatorEntry.numYours) + lineEntry_comm:SetText("yours: "..entry.numYours) end - local tx = string.format("%i %s of %i", auctionatorEntry.count, Auctionator_PluralizeIf("stack", auctionatorEntry.count), auctionatorEntry.stackSize) + local tx = string.format("%i %s of %i", entry.count, Auctionator_PluralizeIf("stack", entry.count), entry.stackSize) lineEntry_avail:SetText(tx) - MoneyFrame_Update("AuctionatorEntry"..line.."_UnitPrice", Auctionator_Round(auctionatorEntry.buyoutPrice/auctionatorEntry.stackSize)) - MoneyFrame_Update("AuctionatorEntry"..line.."_TotalPrice", Auctionator_Round(auctionatorEntry.buyoutPrice)) + MoneyFrame_Update("AuctionatorSellEntry"..line.."_UnitPrice", Auctionator_Round(entry.buyoutPrice/entry.stackSize)) + MoneyFrame_Update("AuctionatorSellEntry"..line.."_TotalPrice", Auctionator_Round(entry.buyoutPrice)) lineEntry:Show() else @@ -395,7 +328,7 @@ end ----------------------------------------- -function Auctionator_EntryOnClick() +function AuctionatorSellEntry_OnClick() local entryIndex = this:GetID() selectedAuctionatorEntry = auctionatorEntries[currentAuctionItemName][entryIndex] @@ -405,7 +338,9 @@ function Auctionator_EntryOnClick() PlaySound("igMainMenuOptionCheckBoxOn") end -function Auctionator_RefreshButtonOnClick() +----------------------------------------- + +function AuctionatorSellRefreshButton_OnClick() if not Auctionator_Scan_IsIdle() then Auctionator_Scan_Abort() end @@ -485,13 +420,15 @@ function ItemType2AuctionClass(itemType) end end end - else Auctionator_Log("Can't GetAuctionItemClasses") end + else + Auctionator_Log("Can't GetAuctionItemClasses") + end end ----------------------------------------- function SubType2AuctionSubclass(auctionClass, itemSubtype) - local itemClasses = { GetAuctionItemSubClasses(auctionClass.number) }; + local itemClasses = { GetAuctionItemSubClasses(auctionClass.number) } if itemClasses.n > 0 then local itemClass for x, itemClass in pairs(itemClasses) do diff --git a/Sell.xml b/Sell.xml index 92a5d52..ede120f 100644 --- a/Sell.xml +++ b/Sell.xml @@ -14,7 +14,7 @@ - @@ -256,7 +256,7 @@ - @@ -286,20 +286,20 @@ - - - - - - - - - - - - + + + + + + + + + + +