added an instant buyout with right-click feature and and an option in the settings, removed the weird pointless boolean-number conversions for the settings

This commit is contained in:
Manuel Simon Hirsig
2015-09-07 16:52:34 +02:00
parent 45b26d2e23
commit 21ba5feb86
4 changed files with 183 additions and 114 deletions
+46 -112
View File
@@ -1,13 +1,12 @@
local AuctionatorVersion = "1.1.0-Vanilla"
local AuctionatorAuthor = "Zirco; Backport by Nimeral; Reworked by Simon Hirsig"
local AuctionatorLoaded = false
local recommendationElements = {}
local auctionsTabElements = {}
AUCTIONATOR_ENABLE_ALT = 1
AUCTIONATOR_OPEN_FIRST = 0
AUCTIONATOR_ENABLE_ALT = true
AUCTIONATOR_OPEN_FIRST = false
AUCTIONATOR_INSTANT_BUYOUT = false
auctionatorEntries = {}
local AUCTIONATOR_TAB_INDEX = 4
@@ -45,7 +44,7 @@ local lastItemPosted = nil
-----------------------------------------
local log, BoolToString, BoolToNum, NumToBool, pluralizeIf, round, undercut, roundPriceDown
local log, pluralizeIf, round, undercut, roundPriceDown
local val2gsc, priceToString, ItemType2AuctionClass, SubType2AuctionSubclass
-----------------------------------------
@@ -213,6 +212,27 @@ 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)
PlaceAuctionBid("list", index, buyoutPrice)
AuctionFrameBrowse_Update()
end
end
-----------------------------------------
function Auctionator_SetupHookFunctions()
-- Auctionator_Orig_AuctionFrameBrowse_Update = AuctionFrameBrowse_Update
@@ -221,6 +241,26 @@ function Auctionator_SetupHookFunctions()
-- Auctionator_Orig_AuctionFrameBrowse_Scan = AuctionFrameBrowse_Scan
-- AuctionFrameBrowse_Scan = Auctionator_AuctionFrameBrowse_Scan
Auctionator_Orig_BrowseButton_OnClick = BrowseButton_OnClick
BrowseButton_OnClick = Auctionator_BrowseButton_OnClick
BrowseButton1:RegisterForClicks("LeftButtonUp", "RightButtonDown")
BrowseButton1:SetScript("OnMouseDown", Auctionator_BrowseButton_OnMouseDown)
BrowseButton2:RegisterForClicks("LeftButtonUp", "RightButtonDown")
BrowseButton2:SetScript("OnMouseDown", Auctionator_BrowseButton_OnMouseDown)
BrowseButton3:RegisterForClicks("LeftButtonUp", "RightButtonDown")
BrowseButton3:SetScript("OnMouseDown", Auctionator_BrowseButton_OnMouseDown)
BrowseButton4:RegisterForClicks("LeftButtonUp", "RightButtonDown")
BrowseButton4:SetScript("OnMouseDown", Auctionator_BrowseButton_OnMouseDown)
BrowseButton5:RegisterForClicks("LeftButtonUp", "RightButtonDown")
BrowseButton5:SetScript("OnMouseDown", Auctionator_BrowseButton_OnMouseDown)
BrowseButton6:RegisterForClicks("LeftButtonUp", "RightButtonDown")
BrowseButton6:SetScript("OnMouseDown", Auctionator_BrowseButton_OnMouseDown)
BrowseButton7:RegisterForClicks("LeftButtonUp", "RightButtonDown")
BrowseButton7:SetScript("OnMouseDown", Auctionator_BrowseButton_OnMouseDown)
BrowseButton8:RegisterForClicks("LeftButtonUp", "RightButtonDown")
BrowseButton8:SetScript("OnMouseDown", Auctionator_BrowseButton_OnMouseDown)
Auctionator_Orig_AuctionFrameTab_OnClick = AuctionFrameTab_OnClick
AuctionFrameTab_OnClick = Auctionator_AuctionFrameTab_OnClick
@@ -749,82 +789,6 @@ function AuctionatorMoneyFrame_OnLoad()
MoneyFrame_SetType("AUCTION")
end
-----------------------------------------
function Auctionator_ShowDescriptionFrame()
AuctionatorDescriptionFrame:Show()
AuctionatorAuthorText:SetText("Author: "..AuctionatorAuthor)
end
-----------------------------------------
function Auctionator_ShowOptionsFrame()
AuctionatorOptionsFrame:Show()
AuctionatorOptionsFrame:SetBackdropColor(0,0,0,100)
AuctionatorConfigFrameTitle:SetText("Auctionator Options for "..UnitName("player"))
local expText = "<html><body>"
.."<h1>What is Auctionator?</h1><br/>"
.."<p>"
.."Figuring out a good buyout price when posting auctions can be tedious and time-consuming. If you're like most people, you first browse the current "
.."auctions to get a sense of how much your item is currently selling for. Then you undercut the lowest price by a bit. If you're creating multiple auctions "
.."you're bouncing back and forth between the Browse tab and the Auctions tab, doing lots of division in "
.."your head, and doing lots of clicking and typing."
.."</p><br/><h1>How it works</h1><br/><p>"
.."Auctionator makes this whole process easy and streamlined. When you select an item to auction, Auctionator displays a summary of all the current auctions for "
.."that item sorted by per-item price. Auctionator also calculates a recommended buyout price based on the cheapest per-item price for your item. If you're "
.."selling a stack rather than a single item, Auctionator bases its recommended buyout price on the cheapest stack of the same size."
.."</p><br/><p>"
.."If you don't like Auctionator's recommendation, you can click on any line in the summary and Auctionator will recalculate the recommended buyout price based "
.."on that auction. Of course, you can always override Auctionator's recommendation by just typing in your own buyout price."
.."</p><br/><p>"
.."With Auctionator, creating an auction is usually just a matter of picking an item to auction and clicking the Create Auction button."
.."</p>"
.."</body></html>"
AuctionatorExplanation:SetText("Auctionator is an addon designed to make it easier and faster to setup your auctions at the auction house.")
AuctionatorDescriptionHTML:SetText(expText)
AuctionatorDescriptionHTML:SetSpacing(3)
AuctionatorVersionText:SetText("Version: "..AuctionatorVersion)
AuctionatorOption_Enable_Alt:SetChecked(NumToBool(AUCTIONATOR_ENABLE_ALT))
AuctionatorOption_Open_First:SetChecked(NumToBool(AUCTIONATOR_OPEN_FIRST))
end
-----------------------------------------
function AuctionatorOptionsSave()
AUCTIONATOR_ENABLE_ALT = BoolToNum(AuctionatorOption_Enable_Alt:GetChecked ())
AUCTIONATOR_OPEN_FIRST = BoolToNum(AuctionatorOption_Open_First:GetChecked ())
end
-----------------------------------------
function Auctionator_ShowTooltip_EnableAlt()
GameTooltip:SetOwner(this, "ANCHOR_BOTTOM")
GameTooltip:SetText("Enable alt-key shortcut", 0.9, 1.0, 1.0)
GameTooltip:AddLine("If this option is checked, holding the Alt key down while clicking an item in your bags will switch to the Auctionator panel, place the item in the Auction Item area, and start the scan.", 0.5, 0.5, 1.0, 1)
GameTooltip:Show()
end
-----------------------------------------
function Auctionator_ShowTooltip_OpenFirst()
GameTooltip:SetOwner(this, "ANCHOR_BOTTOM")
GameTooltip:SetText("Automatically open Auctionator panel", 0.9, 1.0, 1.0)
GameTooltip:AddLine("If this option is checked, the Auctionator panel will display first whenever you open the Auction House window.", 0.5, 0.5, 1.0, 1)
GameTooltip:Show()
end
--[[***************************************************************
All function below here are local utility functions.
@@ -832,36 +796,6 @@ end
--*****************************************************************]]
function BoolToString(b)
if b then
return "true"
end
return "false"
end
-----------------------------------------
function BoolToNum(b)
if b then
return 1
end
return 0
end
-----------------------------------------
function NumToBool(n)
if n == 0 then
return false
end
return true
end
-----------------------------------------
function pluralizeIf(word, count)
if count and count == 1 then
+1 -1
View File
@@ -1,7 +1,7 @@
## Interface: 11200
## Title: Auctionator
## Notes: A lightweight addon designed to help manage auctions
## SavedVariablesPerCharacter: AUCTIONATOR_ENABLE_ALT, AUCTIONATOR_OPEN_FIRST
## SavedVariablesPerCharacter: AUCTIONATOR_ENABLE_ALT, AUCTIONATOR_OPEN_FIRST, AUCTIONATOR_INSTANT_BUYOUT
## SavedVariables: auctionatorEntries
Auctionator.xml
Options.xml
+91
View File
@@ -0,0 +1,91 @@
local AuctionatorVersion = "1.1.0-Vanilla"
local AuctionatorAuthor = "Zirco; Backport by Nimeral; Reworked by Simon Hirsig"
local BoolToString, BoolToNum, NumToBool
function Auctionator_ShowDescriptionFrame()
AuctionatorDescriptionFrame:Show()
AuctionatorAuthorText:SetText("Author: "..AuctionatorAuthor)
end
-----------------------------------------
function Auctionator_ShowOptionsFrame()
AuctionatorOptionsFrame:Show()
AuctionatorOptionsFrame:SetBackdropColor(0,0,0,100)
AuctionatorConfigFrameTitle:SetText("Auctionator Options for "..UnitName("player"))
local expText = "<html><body>"
.."<h1>What is Auctionator?</h1><br/>"
.."<p>"
.."Figuring out a good buyout price when posting auctions can be tedious and time-consuming. If you're like most people, you first browse the current "
.."auctions to get a sense of how much your item is currently selling for. Then you undercut the lowest price by a bit. If you're creating multiple auctions "
.."you're bouncing back and forth between the Browse tab and the Auctions tab, doing lots of division in "
.."your head, and doing lots of clicking and typing."
.."</p><br/><h1>How it works</h1><br/><p>"
.."Auctionator makes this whole process easy and streamlined. When you select an item to auction, Auctionator displays a summary of all the current auctions for "
.."that item sorted by per-item price. Auctionator also calculates a recommended buyout price based on the cheapest per-item price for your item. If you're "
.."selling a stack rather than a single item, Auctionator bases its recommended buyout price on the cheapest stack of the same size."
.."</p><br/><p>"
.."If you don't like Auctionator's recommendation, you can click on any line in the summary and Auctionator will recalculate the recommended buyout price based "
.."on that auction. Of course, you can always override Auctionator's recommendation by just typing in your own buyout price."
.."</p><br/><p>"
.."With Auctionator, creating an auction is usually just a matter of picking an item to auction and clicking the Create Auction button."
.."</p>"
.."</body></html>"
AuctionatorExplanation:SetText("Auctionator is an addon designed to make it easier and faster to setup your auctions at the auction house.")
AuctionatorDescriptionHTML:SetText(expText)
AuctionatorDescriptionHTML:SetSpacing(3)
AuctionatorVersionText:SetText("Version: "..AuctionatorVersion)
AuctionatorOption_Enable_Alt:SetChecked(AUCTIONATOR_ENABLE_ALT)
AuctionatorOption_Open_First:SetChecked(AUCTIONATOR_OPEN_FIRST)
AuctionatorOption_Instant_Buyout:SetChecked(AUCTIONATOR_INSTANT_BUYOUT)
end
-----------------------------------------
function AuctionatorOptionsSave()
AUCTIONATOR_ENABLE_ALT = AuctionatorOption_Enable_Alt:GetChecked()
AUCTIONATOR_OPEN_FIRST = AuctionatorOption_Open_First:GetChecked()
AUCTIONATOR_INSTANT_BUYOUT = AuctionatorOption_Instant_Buyout:GetChecked()
end
-----------------------------------------
function Auctionator_ShowTooltip_EnableAlt()
GameTooltip:SetOwner(this, "ANCHOR_BOTTOM")
GameTooltip:SetText("Enable alt-key shortcut", 0.9, 1.0, 1.0)
GameTooltip:AddLine("If this option is checked, holding the Alt key down while clicking an item in your bags will switch to the Auctionator panel, place the item in the Auction Item area, and start the scan.", 0.5, 0.5, 1.0, 1)
GameTooltip:Show()
end
-----------------------------------------
function Auctionator_ShowTooltip_OpenFirst()
GameTooltip:SetOwner(this, "ANCHOR_BOTTOM")
GameTooltip:SetText("Automatically open Auctionator panel", 0.9, 1.0, 1.0)
GameTooltip:AddLine("If this option is checked, the Auctionator panel will display first whenever you open the Auction House window.", 0.5, 0.5, 1.0, 1)
GameTooltip:Show()
end
-----------------------------------------
function Auctionator_ShowTooltip_InstantBuyout()
GameTooltip:SetOwner(this, "ANCHOR_BOTTOM")
GameTooltip:SetText("Enable right-click instant buyout", 0.9, 1.0, 1.0)
GameTooltip:AddLine("If this option is checked, right-clicking on an auction in the Browse tab will instantly buy it out", 0.5, 0.5, 1.0, 1)
GameTooltip:Show()
end
+45 -1
View File
@@ -1,6 +1,6 @@
<Ui xsi:schemaLocation="http://www.blizzard.com/wow/ui/">
<Script file="Auctionator.lua"/>
<Script file="Options.lua"/>
<Frame name="AuctionatorOptionsButtonFrame" frameStrata="HIGH" hidden="true">
<Size>
@@ -204,6 +204,50 @@
</Frames>
</Frame>
<Frame name="AuctionatorOption_Instant_Buyout_Box">
<Size><AbsDimension y="40" /></Size>
<Anchors>
<Anchor point="TOP" relativeTo="AuctionatorOption_Title" relativePoint="BOTTOM" ><Offset><AbsDimension y="-65"/></Offset></Anchor>
<Anchor point="LEFT" ><Offset><AbsDimension x="40"/></Offset></Anchor>
<Anchor point="RIGHT"><Offset><AbsDimension x="-20"/></Offset></Anchor>
</Anchors>
<Scripts>
<OnEnter>
Auctionator_ShowTooltip_InstantBuyout()
</OnEnter>
<OnLeave>
GameTooltip:Hide()
</OnLeave>
</Scripts>
<Frames>
<CheckButton name="AuctionatorOption_Instant_Buyout" inherits="UICheckButtonTemplate">
<Anchors><Anchor point="TOPLEFT"><Offset><AbsDimension x="0" y="0"/></Offset></Anchor></Anchors>
<Layers>
<Layer level="BACKGROUND">
<FontString inherits="GameFontHighlight" text="Enable right-click instant buyout">
<Anchors>
<Anchor point="LEFT" relativePoint="RIGHT" relativeTo="AuctionatorOption_Instant_Buyout">
<Offset><AbsDimension x="8" y="1"/></Offset>
</Anchor>
</Anchors>
</FontString>
</Layer>
</Layers>
<Scripts>
<OnEnter>
Auctionator_ShowTooltip_InstantBuyout()
</OnEnter>
<OnLeave>
GameTooltip:Hide()
</OnLeave>
</Scripts>
</CheckButton>
</Frames>
</Frame>
<Frame>
<Size><AbsDimension x="150" y="40" /></Size>