Basic initial search in buy tab now working

This commit is contained in:
Manuel Simon Hirsig
2015-09-08 23:55:13 +02:00
parent 0217ac7088
commit bbc7e8c260
5 changed files with 189 additions and 122 deletions
+10 -70
View File
@@ -40,8 +40,8 @@ local lastItemPosted = nil
-----------------------------------------
local processScanResults, relevel, Auctionator_Log, pluralizeIf, round, undercut, roundPriceDown
local val2gsc, priceToString, ItemType2AuctionClass, SubType2AuctionSubclass
local processScanResults, relevel, undercut
local ItemType2AuctionClass, SubType2AuctionSubclass
-----------------------------------------
@@ -255,7 +255,9 @@ function Auctionator_BrowseButton_OnMouseDown()
SetSelectedAuctionItem("list", index)
local _, _, _, _, _, _, _, _, buyoutPrice = GetAuctionItemInfo("list", index)
PlaceAuctionBid("list", index, buyoutPrice)
if buyoutPrice > 0 then
PlaceAuctionBid("list", index, buyoutPrice)
end
AuctionFrameBrowse_Update()
end
@@ -433,8 +435,8 @@ function Auctionator_UpdateRecommendation()
Auctionator_RecommendItem_Tex:Hide()
end
MoneyFrame_Update("Auctionator_RecommendPerItem_Price", round(newBuyoutPrice / currentAuctionItemStackSize))
MoneyFrame_Update("Auctionator_RecommendPerStack_Price", round(newBuyoutPrice))
MoneyFrame_Update("Auctionator_RecommendPerItem_Price", Auctionator_Round(newBuyoutPrice / currentAuctionItemStackSize))
MoneyFrame_Update("Auctionator_RecommendPerStack_Price", Auctionator_Round(newBuyoutPrice))
MoneyInputFrame_SetCopper(BuyoutPrice, newBuyoutPrice)
MoneyInputFrame_SetCopper(StartPrice, newStartPrice)
@@ -583,12 +585,12 @@ function Auctionator_ScrollbarUpdate()
lineEntry_comm:SetText("yours: "..auctionatorEntry.numYours)
end
local tx = string.format("%i %s of %i", auctionatorEntry.count, pluralizeIf("stack", auctionatorEntry.count), auctionatorEntry.stackSize)
local tx = string.format("%i %s of %i", auctionatorEntry.count, Auctionator_PluralizeIf("stack", auctionatorEntry.count), auctionatorEntry.stackSize)
MoneyFrame_Update("AuctionatorEntry"..line.."_PerItem_Price", round(auctionatorEntry.buyoutPrice/auctionatorEntry.stackSize))
MoneyFrame_Update("AuctionatorEntry"..line.."_PerItem_Price", Auctionator_Round(auctionatorEntry.buyoutPrice/auctionatorEntry.stackSize))
lineEntry_avail:SetText(tx)
lineEntry_stack:SetText(priceToString(auctionatorEntry.buyoutPrice))
lineEntry_stack:SetText(Auctionator_PriceToString(auctionatorEntry.buyoutPrice))
lineEntry:Show()
else
@@ -680,74 +682,12 @@ end
-----------------------------------------
function pluralizeIf(word, count)
if count and count == 1 then
return word
else
return word.."s"
end
end
-----------------------------------------
function round(v)
return math.floor(v + 0.5)
end
-----------------------------------------
function undercut(price)
return math.max(0, price - 1)
end
-----------------------------------------
function val2gsc(v)
local rv = round(v)
local g = math.floor(rv/10000)
rv = rv - g * 10000
local s = math.floor(rv/100)
rv = rv - s * 100
local c = rv
return g, s, c
end
-----------------------------------------
function priceToString(val)
local gold, silver, copper = val2gsc(val)
local st = ""
if gold ~= 0 then
st = gold.."g "
end
if st ~= "" then
st = st..format("%02is ", silver)
elseif silver ~= 0 then
st = st..silver.."s "
end
if st ~= "" then
st = st..format("%02ic", copper)
elseif copper ~= 0 then
st = st..copper.."c"
end
return st
end
-----------------------------------------
function ItemType2AuctionClass(itemType)
local itemClasses = { GetAuctionItemClasses() }
if itemClasses then
+4 -4
View File
@@ -30,8 +30,8 @@
<Anchors><Anchor point="RIGHT"><Offset><AbsDimension x="0" y="0"/></Offset></Anchor></Anchors>
<Scripts>
<OnLoad>
SmallMoneyFrame_OnLoad();
MoneyFrame_SetType("STATIC");
SmallMoneyFrame_OnLoad()
MoneyFrame_SetType("STATIC")
</OnLoad>
</Scripts>
</Frame>
@@ -80,7 +80,7 @@
</HighlightTexture>
<Scripts>
<OnClick>
Auctionator_EntryOnClick();
Auctionator_EntryOnClick()
</OnClick>
</Scripts>
</Button>
@@ -260,7 +260,7 @@
</Frame>
<Button name="AuctionatorRefreshButton" inherits="UIPanelButtonTemplate" text="Refresh">
<Size><AbsDimension x="126" y="22"/> </Size>
<Size><AbsDimension x="126" y="22"/></Size>
<Anchors><Anchor point="RIGHT"><Offset><AbsDimension x="-14" y="-199"/></Offset></Anchor></Anchors>
<Scripts>
<OnClick>
+25 -27
View File
@@ -1,5 +1,5 @@
local processScanResults, scrollbarUpdate
local processedData;
local processScanResults
local processedData
function AuctionatorBuySearchButton_OnClick()
@@ -8,13 +8,20 @@ function AuctionatorBuySearchButton_OnClick()
exactMatch = true,
onComplete = function(data)
processScanResults(data)
scrollbarUpdate()
Auctionator_Log("done"..getn(data))
Auctionator_Buy_ScrollbarUpdate()
end
})
end
-----------------------------------------
function AuctionatorBuyEntry_OnClick()
end
-----------------------------------------
function processScanResults(rawData)
processedData = {}
@@ -51,27 +58,28 @@ function processScanResults(rawData)
table.sort(processedData, function(a,b) return a.itemPrice < b.itemPrice end)
end
function scrollbarUpdate()
-----------------------------------------
function Auctionator_Buy_ScrollbarUpdate()
local line -- 1 through 15 of our window to scroll
local dataOffset -- an index into our data calculated from the scroll offset
local numrows
if not currentAuctionItemName or not auctionatorEntries[currentAuctionItemName] then
if not processedData then
numrows = 0
else
numrows = getn(auctionatorEntries[currentAuctionItemName])
numrows = getn(processedData)
end
FauxScrollFrame_Update(AuctionatorScrollFrame, numrows, 12, 16);
FauxScrollFrame_Update(AuctionatorBuyScrollFrame, numrows, 12, 16);
for line = 1,15 do
for line = 1,12 do
dataOffset = line + FauxScrollFrame_GetOffset(AuctionatorScrollFrame)
log(line)
dataOffset = line + FauxScrollFrame_GetOffset(AuctionatorBuyScrollFrame)
local lineEntry = getglobal("AuctionatorBuyEntry"..line)
if numrows <= 15 then
if numrows <= 12 then
lineEntry:SetWidth(603)
else
lineEntry:SetWidth(585)
@@ -79,9 +87,9 @@ function scrollbarUpdate()
lineEntry:SetID(dataOffset)
if currentAuctionItemName and dataOffset <= numrows and auctionatorEntries[currentAuctionItemName][dataOffset] then
if dataOffset <= numrows and processedData[dataOffset] then
local auctionatorEntry = auctionatorEntries[currentAuctionItemName][dataOffset]
local auctionatorEntry = processedData[dataOffset]
local lineEntry_avail = getglobal("AuctionatorBuyEntry"..line.."_Availability")
local lineEntry_comm = getglobal("AuctionatorBuyEntry"..line.."_Comment")
@@ -93,12 +101,6 @@ function scrollbarUpdate()
lineEntry:UnlockHighlight()
end
if auctionatorEntry.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
lineEntry_comm:SetText("")
elseif
@@ -108,12 +110,12 @@ function scrollbarUpdate()
lineEntry_comm:SetText("yours: "..auctionatorEntry.numYours)
end
local tx = string.format("%i %s of %i", auctionatorEntry.count, pluralizeIf("stack", auctionatorEntry.count), auctionatorEntry.stackSize)
local tx = string.format("%i %s of %i", auctionatorEntry.count, Auctionator_PluralizeIf("stack", auctionatorEntry.count), auctionatorEntry.stackSize)
MoneyFrame_Update("AuctionatorBuyEntry"..line.."_PerItem_Price", round(auctionatorEntry.buyoutPrice/auctionatorEntry.stackSize))
MoneyFrame_Update("AuctionatorBuyEntry"..line.."_PerItem_Price", Auctionator_Round(auctionatorEntry.buyoutPrice/auctionatorEntry.stackSize))
lineEntry_avail:SetText(tx)
lineEntry_stack:SetText(priceToString(auctionatorEntry.buyoutPrice))
lineEntry_stack:SetText(Auctionator_PriceToString(auctionatorEntry.buyoutPrice))
lineEntry:Show()
else
@@ -269,10 +271,6 @@ end
-- FauxScrollFrame_Update(BrowseScrollFrame, numBatchAuctions, NUM_BROWSE_TO_DISPLAY, AUCTIONS_BUTTON_HEIGHT)
-- end
local eventFrame = CreateFrame("Frame")
eventFrame:SetScript("OnUpdate", function()
end)
-- eventFrame:RegisterEvent("AUCTION_ITEM_LIST_UPDATE")
-- eventFrame:SetScript("OnEvent", function(event)
-- if state == STATE_POSTQUERY then
+86 -21
View File
@@ -2,6 +2,73 @@
<Script file="Buy.lua"/>
<Button name="AuctionatorBuyEntryTemplate" virtual="true" hidden="true">
<Size><AbsDimension x="603" y="16" /></Size>
<Frames>
<Frame>
<Size><AbsDimension x="120" y="16" /></Size>
<Anchors><Anchor point="LEFT"><Offset><AbsDimension x="22" y="0"/></Offset></Anchor></Anchors>
<Frames>
<Frame name="$parent_PerItem_Price" inherits="SmallMoneyFrameTemplate">
<Anchors><Anchor point="RIGHT"><Offset><AbsDimension x="0" y="0"/></Offset></Anchor></Anchors>
<Scripts>
<OnLoad>
SmallMoneyFrame_OnLoad()
MoneyFrame_SetType("STATIC")
</OnLoad>
</Scripts>
</Frame>
</Frames>
</Frame>
<Frame>
<Size><AbsDimension x="100" y="16" /></Size>
<Anchors><Anchor point="LEFT"><Offset><AbsDimension x="170" y="-3"/></Offset></Anchor></Anchors>
<Layers>
<Layer level="BACKGROUND">
<FontString name="$parent_Availability" inherits="GameFontHighlightSmall">
<Anchors><Anchor point="TOPRIGHT"><Offset><AbsDimension x="0" y="0"/></Offset></Anchor></Anchors>
</FontString>
</Layer>
</Layers>
</Frame>
<Frame>
<Size><AbsDimension x="100" y="16" /></Size>
<Anchors><Anchor point="LEFT"><Offset><AbsDimension x="320" y="-3"/></Offset></Anchor></Anchors>
<Layers>
<Layer level="BACKGROUND">
<FontString name="$parent_Comment" inherits="GameFontHighlightSmall">
<Anchors><Anchor point="TOPLEFT"><Offset><AbsDimension x="0" y="0"/></Offset></Anchor></Anchors>
</FontString>
</Layer>
</Layers>
</Frame>
<Frame>
<Size><AbsDimension x="120" y="16" /></Size>
<Anchors><Anchor point="LEFT"><Offset><AbsDimension x="440" y="-3"/></Offset></Anchor></Anchors>
<Layers>
<Layer level="BACKGROUND">
<FontString name="$parent_StackPrice" inherits="GameFontHighlightSmall">
<Anchors><Anchor point="TOPRIGHT"><Offset><AbsDimension x="0" y="0"/></Offset></Anchor></Anchors>
</FontString>
</Layer>
</Layers>
</Frame>
</Frames>
<HighlightTexture file="Interface\HelpFrame\HelpFrameButton-Highlight" alphaMode="ADD">
<TexCoords left="0" right="1.0" top="0.0" bottom="0.6"/>
</HighlightTexture>
<Scripts>
<OnClick>
AuctionatorBuyEntry_OnClick()
</OnClick>
</Scripts>
</Button>
<Frame name="Auctionator_Buy_Template" virtual="true" hidden="true">
<Size>
<AbsDimension x="550" y="447"/>
@@ -43,17 +110,15 @@
</Scripts>
</Button>
<Button name="AuctionatorBuyRefreshButton" inherits="UIPanelButtonTemplate" text="Refresh">
<!-- <Button name="AuctionatorBuyRefreshButton" inherits="UIPanelButtonTemplate" text="Refresh">
<Size><AbsDimension x="126" y="22"/> </Size>
<Anchors><Anchor point="RIGHT"><Offset><AbsDimension x="-14" y="-199"/></Offset></Anchor></Anchors>
<Scripts>
<OnClick>
<!-- Auctionator_RefreshButtonOnClick() -->
AuctionatorBuyRefreshButton_OnClick()
</OnClick>
</Scripts>
</Button>
</Button> -->
<ScrollFrame name="AuctionatorBuyScrollFrame" inherits="FauxScrollFrameTemplate">
<Size><AbsDimension x="588" y="194"/></Size>
@@ -61,7 +126,7 @@
<Scripts>
<OnVerticalScroll>
<!--FauxScrollFrame_OnVerticalScroll(16, Auctionator_ScrollbarUpdate)-->
FauxScrollFrame_OnVerticalScroll(16, Auctionator_Buy_ScrollbarUpdate)
</OnVerticalScroll>
<OnShow>
<!--Auctionator_ScrollbarUpdate();-->
@@ -69,23 +134,23 @@
</Scripts>
</ScrollFrame>
<Button name="AuctionatorBuyEntry1" inherits="AuctionatorEntryTemplate">
<Button name="AuctionatorBuyEntry1" inherits="AuctionatorBuyEntryTemplate">
<Anchors><Anchor point="TOPLEFT" relativeTo="AuctionatorBuyScrollFrame" relativePoint="TOPLEFT"><Offset><AbsDimension x="8" y="0"/></Offset></Anchor></Anchors>
</Button>
<Button name="AuctionatorBuyEntry2" inherits="AuctionatorEntryTemplate"><Anchors><Anchor point="TOPLEFT" relativeTo="Auctionator_Buy_Entry1" relativePoint="BOTTOMLEFT"/></Anchors></Button>
<Button name="AuctionatorBuyEntry3" inherits="AuctionatorEntryTemplate"><Anchors><Anchor point="TOPLEFT" relativeTo="Auctionator_Buy_Entry2" relativePoint="BOTTOMLEFT"/></Anchors></Button>
<Button name="AuctionatorBuyEntry4" inherits="AuctionatorEntryTemplate"><Anchors><Anchor point="TOPLEFT" relativeTo="Auctionator_Buy_Entry3" relativePoint="BOTTOMLEFT"/></Anchors></Button>
<Button name="AuctionatorBuyEntry5" inherits="AuctionatorEntryTemplate"><Anchors><Anchor point="TOPLEFT" relativeTo="Auctionator_Buy_Entry4" relativePoint="BOTTOMLEFT"/></Anchors></Button>
<Button name="AuctionatorBuyEntry6" inherits="AuctionatorEntryTemplate"><Anchors><Anchor point="TOPLEFT" relativeTo="Auctionator_Buy_Entry5" relativePoint="BOTTOMLEFT"/></Anchors></Button>
<Button name="AuctionatorBuyEntry7" inherits="AuctionatorEntryTemplate"><Anchors><Anchor point="TOPLEFT" relativeTo="Auctionator_Buy_Entry6" relativePoint="BOTTOMLEFT"/></Anchors></Button>
<Button name="AuctionatorBuyEntry8" inherits="AuctionatorEntryTemplate"><Anchors><Anchor point="TOPLEFT" relativeTo="Auctionator_Buy_Entry7" relativePoint="BOTTOMLEFT"/></Anchors></Button>
<Button name="AuctionatorBuyEntry9" inherits="AuctionatorEntryTemplate"><Anchors><Anchor point="TOPLEFT" relativeTo="Auctionator_Buy_Entry8" relativePoint="BOTTOMLEFT"/></Anchors></Button>
<Button name="AuctionatorBuyEntry10" inherits="AuctionatorEntryTemplate"><Anchors><Anchor point="TOPLEFT" relativeTo="Auctionator_Buy_Entry9" relativePoint="BOTTOMLEFT"/></Anchors></Button>
<Button name="AuctionatorBuyEntry11" inherits="AuctionatorEntryTemplate"><Anchors><Anchor point="TOPLEFT" relativeTo="Auctionator_Buy_Entry10" relativePoint="BOTTOMLEFT"/></Anchors></Button>
<Button name="AuctionatorBuyEntry12" inherits="AuctionatorEntryTemplate"><Anchors><Anchor point="TOPLEFT" relativeTo="Auctionator_Buy_Entry11" relativePoint="BOTTOMLEFT"/></Anchors></Button>
<Button name="AuctionatorBuyEntry13" inherits="AuctionatorEntryTemplate"><Anchors><Anchor point="TOPLEFT" relativeTo="Auctionator_Buy_Entry12" relativePoint="BOTTOMLEFT"/></Anchors></Button>
<Button name="AuctionatorBuyEntry14" inherits="AuctionatorEntryTemplate"><Anchors><Anchor point="TOPLEFT" relativeTo="Auctionator_Buy_Entry13" relativePoint="BOTTOMLEFT"/></Anchors></Button>
<Button name="AuctionatorBuyEntry15" inherits="AuctionatorEntryTemplate"><Anchors><Anchor point="TOPLEFT" relativeTo="Auctionator_Buy_Entry14" relativePoint="BOTTOMLEFT"/></Anchors></Button>
<Button name="AuctionatorBuyEntry2" inherits="AuctionatorBuyEntryTemplate"><Anchors><Anchor point="TOPLEFT" relativeTo="AuctionatorBuyEntry1" relativePoint="BOTTOMLEFT"/></Anchors></Button>
<Button name="AuctionatorBuyEntry3" inherits="AuctionatorBuyEntryTemplate"><Anchors><Anchor point="TOPLEFT" relativeTo="AuctionatorBuyEntry2" relativePoint="BOTTOMLEFT"/></Anchors></Button>
<Button name="AuctionatorBuyEntry4" inherits="AuctionatorBuyEntryTemplate"><Anchors><Anchor point="TOPLEFT" relativeTo="AuctionatorBuyEntry3" relativePoint="BOTTOMLEFT"/></Anchors></Button>
<Button name="AuctionatorBuyEntry5" inherits="AuctionatorBuyEntryTemplate"><Anchors><Anchor point="TOPLEFT" relativeTo="AuctionatorBuyEntry4" relativePoint="BOTTOMLEFT"/></Anchors></Button>
<Button name="AuctionatorBuyEntry6" inherits="AuctionatorBuyEntryTemplate"><Anchors><Anchor point="TOPLEFT" relativeTo="AuctionatorBuyEntry5" relativePoint="BOTTOMLEFT"/></Anchors></Button>
<Button name="AuctionatorBuyEntry7" inherits="AuctionatorBuyEntryTemplate"><Anchors><Anchor point="TOPLEFT" relativeTo="AuctionatorBuyEntry6" relativePoint="BOTTOMLEFT"/></Anchors></Button>
<Button name="AuctionatorBuyEntry8" inherits="AuctionatorBuyEntryTemplate"><Anchors><Anchor point="TOPLEFT" relativeTo="AuctionatorBuyEntry7" relativePoint="BOTTOMLEFT"/></Anchors></Button>
<Button name="AuctionatorBuyEntry9" inherits="AuctionatorBuyEntryTemplate"><Anchors><Anchor point="TOPLEFT" relativeTo="AuctionatorBuyEntry8" relativePoint="BOTTOMLEFT"/></Anchors></Button>
<Button name="AuctionatorBuyEntry10" inherits="AuctionatorBuyEntryTemplate"><Anchors><Anchor point="TOPLEFT" relativeTo="AuctionatorBuyEntry9" relativePoint="BOTTOMLEFT"/></Anchors></Button>
<Button name="AuctionatorBuyEntry11" inherits="AuctionatorBuyEntryTemplate"><Anchors><Anchor point="TOPLEFT" relativeTo="AuctionatorBuyEntry10" relativePoint="BOTTOMLEFT"/></Anchors></Button>
<Button name="AuctionatorBuyEntry12" inherits="AuctionatorBuyEntryTemplate"><Anchors><Anchor point="TOPLEFT" relativeTo="AuctionatorBuyEntry11" relativePoint="BOTTOMLEFT"/></Anchors></Button>
<Button name="AuctionatorBuyEntry13" inherits="AuctionatorBuyEntryTemplate"><Anchors><Anchor point="TOPLEFT" relativeTo="AuctionatorBuyEntry12" relativePoint="BOTTOMLEFT"/></Anchors></Button>
<Button name="AuctionatorBuyEntry14" inherits="AuctionatorBuyEntryTemplate"><Anchors><Anchor point="TOPLEFT" relativeTo="AuctionatorBuyEntry13" relativePoint="BOTTOMLEFT"/></Anchors></Button>
<Button name="AuctionatorBuyEntry15" inherits="AuctionatorBuyEntryTemplate"><Anchors><Anchor point="TOPLEFT" relativeTo="AuctionatorBuyEntry14" relativePoint="BOTTOMLEFT"/></Anchors></Button>
</Frames>
</Frame>
</Ui>
+64
View File
@@ -1,5 +1,7 @@
AuctionatorLoaded = false
local val2gsc
-----------------------------------------
function Auctionator_Log(msg)
@@ -10,6 +12,68 @@ end
-----------------------------------------
function Auctionator_PluralizeIf(word, count)
if count and count == 1 then
return word
else
return word.."s"
end
end
-----------------------------------------
function Auctionator_Round(v)
return math.floor(v + 0.5)
end
-----------------------------------------
function Auctionator_PriceToString(val)
local gold, silver, copper = val2gsc(val)
local st = ""
if gold ~= 0 then
st = gold.."g "
end
if st ~= "" then
st = st..format("%02is ", silver)
elseif silver ~= 0 then
st = st..silver.."s "
end
if st ~= "" then
st = st..format("%02ic", copper)
elseif copper ~= 0 then
st = st..copper.."c"
end
return st
end
-----------------------------------------
function val2gsc(v)
local rv = Auctionator_Round(v)
local g = math.floor(rv/10000)
rv = rv - g * 10000
local s = math.floor(rv/100)
rv = rv - s * 100
local c = rv
return g, s, c
end
-----------------------------------------
function Auctionator_OnLoad()
Auctionator_Log("Auctionator Loaded")
AuctionatorLoaded = true