working on separating bids and auctions

This commit is contained in:
Manuel Simon Hirsig
2015-11-23 03:02:36 +01:00
parent 5e256bd76c
commit c1ef4130e2
7 changed files with 525 additions and 278 deletions
+2 -1
View File
@@ -19,7 +19,8 @@ completion.xml
item_search_frame.xml
filter_search_frame.xml
post_frame.xml
manage_frame.xml
auctions_frame.xml
bids_frame.xml
scan_frame.xml
options.xml
+372
View File
@@ -0,0 +1,372 @@
local private, public = {}, {}
Aux.auctions_frame = public
local auction_records
public.auction_listing_config = {
on_row_click = function (sheet, row_index)
local data_index = row_index + FauxScrollFrame_GetOffset(sheet.scroll_frame)
public.on_auction_click(sheet.data[data_index])
end,
on_row_enter = function (sheet, row_index)
sheet.rows[row_index].highlight:SetAlpha(.5)
end,
on_row_leave = function (sheet, row_index)
sheet.rows[row_index].highlight:SetAlpha(0)
end,
columns = {
{
title = 'Auction Item',
width = 280,
comparator = function(row1, row2) return Aux.util.compare(row1.tooltip[1][1].text, row2.tooltip[1][1].text, Aux.util.GT) end,
cell_initializer = function(cell)
local icon = CreateFrame('Button', nil, cell)
icon:EnableMouse(false)
local icon_texture = icon:CreateTexture(nil, 'BORDER')
icon_texture:SetAllPoints(icon)
icon.icon_texture = icon_texture
local normal_texture = icon:CreateTexture(nil)
normal_texture:SetPoint('CENTER', 0, 0)
normal_texture:SetWidth(22)
normal_texture:SetHeight(22)
normal_texture:SetTexture('Interface\\Buttons\\UI-Quickslot2')
icon:SetNormalTexture(normal_texture)
icon:SetPoint('LEFT', cell)
icon:SetWidth(12)
icon:SetHeight(12)
local text = cell:CreateFontString(nil, 'OVERLAY', 'GameFontHighlightSmall')
text:SetPoint("LEFT", icon, "RIGHT", 1, 0)
text:SetPoint('TOPRIGHT', cell)
text:SetPoint('BOTTOMRIGHT', cell)
text:SetJustifyV('TOP')
text:SetJustifyH('LEFT')
text:SetTextColor(0.8, 0.8, 0.8)
cell.text = text
cell.icon = icon
end,
cell_setter = function(cell, datum)
cell.icon.icon_texture:SetTexture(Aux.info.item(datum.item_id).texture)
if not datum.usable then
cell.icon.icon_texture:SetVertexColor(1.0, 0.1, 0.1)
else
cell.icon.icon_texture:SetVertexColor(1.0, 1.0, 1.0)
end
cell.text:SetText('['..datum.tooltip[1][1].text..']')
local color = ITEM_QUALITY_COLORS[datum.quality]
cell.text:SetTextColor(color.r, color.g, color.b)
private.auction_alpha_setter(cell, datum)
end,
},
{
title = 'Qty',
width = 25,
comparator = function(row1, row2) return Aux.util.compare(row1.stack_size, row2.stack_size, Aux.util.LT) end,
cell_initializer = Aux.sheet.default_cell_initializer('RIGHT'),
cell_setter = function(cell, datum)
cell.text:SetText(datum.aux_quantity)
private.auction_alpha_setter(cell, datum)
end,
},
{
title = 'Left',
width = 30,
comparator = function(row1, row2) return Aux.util.compare(row1.duration, row2.duration, Aux.util.GT) end,
cell_initializer = Aux.sheet.default_cell_initializer('CENTER'),
cell_setter = function(cell, datum)
local text
if datum.duration == 1 then
text = '30m'
elseif datum.duration == 2 then
text = '2h'
elseif datum.duration == 3 then
text = '8h'
elseif datum.duration == 4 then
text = '24h'
end
cell.text:SetText(text)
private.auction_alpha_setter(cell, datum)
end,
},
{
title = 'Current Bid',
width = 90,
comparator = function(auction1, auction2) return Aux.util.compare(auction1.current_bid, auction2.current_bid, Aux.util.GT) end,
cell_initializer = Aux.sheet.default_cell_initializer('CENTER'),
cell_setter = function(cell, auction)
cell.text:SetText(auction.current_bid and Aux.util.money_string(auction.current_bid) or RED_FONT_COLOR_CODE..'No Bids'..FONT_COLOR_CODE_CLOSE)
private.auction_alpha_setter(cell, auction)
end,
},
{
title = 'Min Bid',
width = 90,
comparator = function(auction1, auction2) return Aux.util.compare(auction1.min_bid, auction2.min_bid, Aux.util.GT) end,
cell_initializer = Aux.sheet.default_cell_initializer('CENTER'),
cell_setter = function(cell, auction)
cell.text:SetText(Aux.util.money_string(auction.min_bid))
private.auction_alpha_setter(cell, auction)
end,
},
{
title = 'Buy',
width = 90,
comparator = function(row1, row2) return Aux.util.compare(row1.buyout_price, row2.buyout_price, Aux.util.GT) end,
cell_initializer = Aux.sheet.default_cell_initializer('RIGHT'),
cell_setter = function(cell, datum)
cell.text:SetText(Aux.util.money_string(datum.buyout_price))
private.auction_alpha_setter(cell, datum)
end,
},
},
sort_order = {{ column = 1, order = 'ascending' }},
}
function public.on_open()
public.update_auction_records()
public.update_listing()
end
function public.on_close()
end
function private.auction_alpha_setter(cell, auction)
cell:SetAlpha(auction.gone and 0.3 or 1)
end
function public.update_auction_records()
Aux.log('Scanning auctions ...')
auction_records = {}
Aux.scan.start{
type = 'owner',
page = 0,
on_page_loaded = function(page, total_pages)
Aux.log('Scanning auction page '..(page+1)..' out of '..total_pages..' ...')
end,
on_read_auction = function(auction_info)
private.create_auction_record(auction_info)
end,
on_complete = function()
Aux.log('Scan complete: '..getn(auction_records)..' auctions found')
public.update_listing()
end,
on_abort = function()
end,
next_page = function(page, total_pages)
local last_page = max(total_pages - 1, 0)
if page < last_page then
return page + 1
end
end,
}
end
function public.update_listing()
AuxManageFrameListingAuctionListing:Show()
Aux.sheet.populate(AuxManageFrameListingAuctionListing.sheet, auction_records)
AuxManageFrameListing:SetWidth(AuxManageFrameListingAuctionListing:GetWidth() + 40)
AuxFrame:SetWidth(AuxManageFrameListing:GetWidth() + 15)
end
function private.create_record(auction_info)
local aux_quantity = auction_info.charges or auction_info.count
local bid = (auction_info.current_bid > 0 and auction_info.current_bid or auction_info.min_bid) + auction_info.min_increment
local buyout_price = auction_info.buyout_price > 0 and auction_info.buyout_price or nil
local buyout_price_per_unit = buyout_price and Aux_Round(auction_info.buyout_price / aux_quantity)
local status
if auction_info.high_bidder then
status = GREEN_FONT_COLOR_CODE..'High Bidder'..FONT_COLOR_CODE_CLOSE
else
status = RED_FONT_COLOR_CODE..'Outbid'..FONT_COLOR_CODE_CLOSE
end
return {
item_id = auction_info.item_id,
key = auction_info.item_signature,
signature = Aux.auction_signature(auction_info.hyperlink, aux_quantity, bid, auction_info.buyout_price),
name = auction_info.name,
level = auction_info.level,
tooltip = auction_info.tooltip,
aux_quantity = aux_quantity,
buyout_price = buyout_price,
buyout_price_per_unit = buyout_price_per_unit,
quality = auction_info.quality,
hyperlink = auction_info.hyperlink,
itemstring = auction_info.itemstring,
bid = bid,
bid_per_unit = Aux_Round(bid / aux_quantity),
owner = auction_info.owner,
duration = auction_info.duration,
usable = auction_info.usable,
high_bidder = auction_info.high_bidder,
current_bid = auction_info.current_bid > 0 and auction_info.current_bid or nil,
min_bid = auction_info.min_bid,
status = status,
EnhTooltip_info = auction_info.EnhTooltip_info,
}
end
function private.create_auction_record(auction_info)
tinsert(auction_records, private.create_record(auction_info))
end
function public.dialog_cancel()
Aux.log('Aborted.')
Aux.scan.abort()
AuxManageFrameListingDialog:Hide()
public.update_listing()
end
function private.find_auction(entry, action, express_mode)
if entry.gone then
Aux.log('Auction not available')
return
end
if action == 'buyout' and not entry.buyout_price then
Aux.log('Auction has no buyout price')
return
end
local amount
if action == 'buyout' then
amount = entry.buyout_price
elseif action == 'bid' then
amount = entry.bid
end
Aux.log('Processing '..action..' request for '..entry.hyperlink..' x '..entry.aux_quantity..' at '..Aux.util.money_string(amount)..' ...')
if not express_mode then
private.show_dialog(action, entry, amount)
end
PlaySound('igMainMenuOptionCheckBoxOn')
local found
Aux.scan.start{
type = action == 'cancel' and 'owner' or 'bidder',
page = entry.page,
on_read_auction = function(auction_info, ctrl)
local auction_record = private.create_record(auction_info)
if entry.signature == auction_record.signature then
ctrl.suspend()
found = true
Aux.log('Matching auction found.'..(express_mode and '' or ' Awaiting confirmation ...'))
if express_mode then
if action == 'cancel' then
CancelAuction(auction_info.index)
entry.gone = true
Aux.log('Canceled'..auction_record.hyperlink..' x '..auction_record.aux_quantity)
elseif GetMoney() >= amount then
PlaceAuctionBid('bidder', auction_info.index, amount)
Aux.log((action == 'buyout' and 'Purchased ' or 'Bid on ')..auction_record.hyperlink..' x '..auction_record.aux_quantity..' at '..Aux.util.money_string(amount)..'.')
entry.gone = true
else
Aux.log((action == 'buyout' and 'Purchase' or 'Bid')..' failed: Not enough money.')
end
Aux.scan.abort()
else
public.dialog_action = function()
if private.create_record(Aux.info.auction(auction_info.index, action == 'cancel' and 'owner' or 'bidder')).signature == entry.signature then
if action == 'cancel' then
CancelAuction(auction_info.index)
entry.gone = true
Aux.log('Canceled'..auction_record.hyperlink..' x '..auction_record.aux_quantity)
elseif GetMoney() >= amount then
PlaceAuctionBid('bidder', auction_info.index, action == 'bid' and MoneyInputFrame_GetCopper(AuxManageFrameListingDialogContentBid) or amount)
Aux.log((action == 'buyout' and 'Purchased ' or 'Bid on ')..auction_record.hyperlink..' x '..auction_record.aux_quantity..' at '..Aux.util.money_string(action == 'bid' and MoneyInputFrame_GetCopper(AuxManageFrameListingDialogContentBid) or amount)..'.')
entry.gone = true
else
Aux.log('Not enough money.')
end
Aux.scan.abort()
AuxManageFrameListingDialog:Hide()
public.update_listing()
end
end
AuxManageFrameListingDialogContentActionButton:Enable()
end
end
end,
on_complete = function()
if not found then
Aux.log('No matching auction found. Removing entry from the cache.')
entry.gone = true
public.dialog_cancel()
end
end,
on_abort = function()
public.update_listing()
end,
next_page = function(page, total_pages)
if not page or page == entry.page then
return entry.page - 1
end
end,
}
end
function public.on_auction_click(auction_record)
local express_mode = IsAltKeyDown()
if IsControlKeyDown() then
DressUpItemLink(auction_record.hyperlink)
else
private.find_auction(auction_record, 'cancel', express_mode)
end
end
function private.show_dialog(action, entry, amount)
AuxManageFrameListingDialogContentItem.itemstring = Aux.info.itemstring(entry.item_id, entry.suffix_id, entry.unique_id, entry.enchant_id)
AuxManageFrameListingDialogContentItem.EnhTooltip_info = entry.EnhTooltip_info
AuxManageFrameListingDialogContentActionButton:Disable()
AuxManageFrameListingDialogContentItemIconTexture:SetTexture(Aux.info.item(entry.item_id).texture)
AuxManageFrameListingDialogContentItemName:SetText(entry.name)
local color = ITEM_QUALITY_COLORS[entry.quality]
AuxManageFrameListingDialogContentItemName:SetTextColor(color.r, color.g, color.b)
if entry.aux_quantity > 1 then
AuxManageFrameListingDialogContentItemCount:SetText(entry.aux_quantity);
AuxManageFrameListingDialogContentItemCount:Show()
else
AuxManageFrameListingDialogContentItemCount:Hide()
end
if action == 'buyout' then
AuxManageFrameListingDialogContentActionButton:SetText('Buy')
AuxManageFrameListingDialogContentCancelButton:SetText('Cancel')
MoneyFrame_Update('AuxManageFrameListingDialogContentBuyoutPrice', amount)
AuxManageFrameListingDialogContentBid:Hide()
AuxManageFrameListingDialogContentCancelLabel:Hide()
AuxManageFrameListingDialogContentBuyoutPrice:Show()
elseif action == 'bid' then
AuxManageFrameListingDialogContentActionButton:SetText('Bid')
AuxManageFrameListingDialogContentCancelButton:SetText('Cancel')
MoneyInputFrame_SetCopper(AuxManageFrameListingDialogContentBid, amount)
AuxManageFrameListingDialogContentBuyoutPrice:Hide()
AuxManageFrameListingDialogContentCancelLabel:Hide()
AuxManageFrameListingDialogContentBid:Show()
elseif action == 'cancel' then
AuxManageFrameListingDialogContentBid:Hide()
AuxManageFrameListingDialogContentBuyoutPrice:Hide()
AuxManageFrameListingDialogContentCancelLabel:Show()
AuxManageFrameListingDialogContentActionButton:SetText('Yes')
AuxManageFrameListingDialogContentCancelButton:SetText('No')
end
AuxManageFrameListingDialog:Show()
end
+115
View File
@@ -0,0 +1,115 @@
<Ui xsi:schemaLocation="http://www.blizzard.com/wow/ui/">
<Script file="auctions_frame.lua"/>
<Frame name="AuxManageFrame" hidden="true" parent="AuxFrame" setAllPoints="true">
<Frames>
<Frame name="$parentListing" inherits="AuxFrameBoxTemplate">
<Size>
<AbsDimension x="400" y="326"/>
</Size>
<Anchors><Anchor point="TOPLEFT"><Offset><AbsDimension x="5" y="-35"/></Offset></Anchor></Anchors>
<Scripts>
<OnLoad>
this:SetBackdropBorderColor(0.4, 0.4, 0.4)
this:SetBackdropColor(0.15, 0.15, 0.15)
</OnLoad>
</Scripts>
<Frames>
<Frame name="$parentAuctionListing">
<Anchors>
<Anchor point="TOPLEFT"><Offset><AbsDimension x="0" y="0"/></Offset></Anchor>
<Anchor point="BOTTOM"><Offset><AbsDimension x="0" y="0"/></Offset></Anchor>
</Anchors>
<Scripts>
<OnLoad>
local config = Aux.auctions_frame.auction_listing_config
this.sheet = Aux.sheet.create{
frame = this,
columns = config.columns,
sort_order = config.sort_order,
row_setter = config.row_setter,
on_row_click = config.on_row_click,
on_row_enter = config.on_row_enter,
on_row_leave = config.on_row_leave,
on_row_update = config.on_row_update,
}
</OnLoad>
</Scripts>
</Frame>
<Frame name="$parentDialog" frameStrata="FULLSCREEN_DIALOG" inherits="OptionFrameBoxTemplate" enableMouse="true" enableMouseWheel="true" hidden="true">
<Anchors>
<Anchor point="TOPLEFT"><Offset><AbsDimension x="0" y="0"/></Offset></Anchor>
<Anchor point="BOTTOMRIGHT"><Offset><AbsDimension x="0" y="0"/></Offset></Anchor>
</Anchors>
<Scripts>
<OnMouseWheel></OnMouseWheel>
</Scripts>
<Frames>
<Frame name="$parentContent">
<Anchors><Anchor point="CENTER"><Offset><AbsDimension x="0" y="5"/></Offset></Anchor></Anchors>
<Size><AbsDimension x="193" y="120"/></Size>
<Layers>
<Layer level="OVERLAY">
<FontString name="$parentCancelLabel" inherits="GameFontNormal" text="Cancel this auction?" justifyH="RIGHT">
<Anchors><Anchor point="BOTTOM"><Offset><AbsDimension x="0" y="45"/></Offset></Anchor></Anchors>
</FontString>
</Layer>
</Layers>
<Frames>
<Frame name="$parentItem" inherits="AuxItemTemplate">
<Anchors><Anchor point="TOP"><Offset><AbsDimension x="0" y="0"/></Offset></Anchor></Anchors>
</Frame>
<Frame name="$parentBid" inherits="MoneyInputFrameTemplate">
<Anchors><Anchor point="BOTTOM"><Offset><AbsDimension x="30" y="43"/></Offset></Anchor></Anchors>
<Layers>
<Layer level="OVERLAY">
<FontString inherits="GameFontNormal" text="Price:" justifyH="RIGHT">
<Anchors><Anchor point="RIGHT" relativePoint="LEFT"><Offset><AbsDimension x="-10" y="0"/></Offset></Anchor></Anchors>
</FontString>
</Layer>
</Layers>
</Frame>
<Frame name="$parentBuyoutPrice" inherits="SmallMoneyFrameTemplate">
<Anchors><Anchor point="BOTTOM"><Offset><AbsDimension x="30" y="45"/></Offset></Anchor></Anchors>
<Scripts>
<OnLoad>
SmallMoneyFrame_OnLoad()
MoneyFrame_SetType("STATIC")
</OnLoad>
</Scripts>
<Layers>
<Layer level="OVERLAY">
<FontString inherits="GameFontNormal" text="Price:" justifyH="RIGHT">
<Anchors><Anchor point="RIGHT" relativePoint="LEFT"><Offset><AbsDimension x="-5" y="0"/></Offset></Anchor></Anchors>
</FontString>
</Layer>
</Layers>
</Frame>
<Button name="$parentActionButton" inherits="UIPanelButtonTemplate" text="Buy" disabled="true">
<Size><AbsDimension x="90" y="26"/> </Size>
<Anchors><Anchor point="BOTTOMLEFT"><Offset><AbsDimension x="0" y="0"/></Offset></Anchor></Anchors>
<Scripts>
<OnClick>
Aux.auctions_frame.dialog_action()
</OnClick>
</Scripts>
</Button>
<Button name="$parentCancelButton" inherits="UIPanelButtonTemplate" text="Cancel">
<Size><AbsDimension x="90" y="26"/></Size>
<Anchors><Anchor point="BOTTOMRIGHT"><Offset><AbsDimension x="0" y="0"/></Offset></Anchor></Anchors>
<Scripts>
<OnClick>
Aux.auctions_frame.dialog_cancel()
</OnClick>
</Scripts>
</Button>
</Frames>
</Frame>
</Frames>
</Frame>
</Frames>
</Frame>
</Frames>
</Frame>
</Ui>
+7 -3
View File
@@ -175,10 +175,11 @@ function Aux.on_tab_click(index)
Aux.item_search_frame.on_close()
Aux.filter_search_frame.on_close()
Aux.sell.on_close()
Aux.manage_frame.on_close()
Aux.auctions_frame.on_close()
Aux.bids_frame.on_close()
Aux.history.on_close()
for i=1,4 do
for i=1,5 do
getglobal('AuxTab'..i):SetAlpha(i == index and 1 or 0.5)
end
@@ -199,7 +200,10 @@ function Aux.on_tab_click(index)
Aux.sell.on_open()
elseif index == 4 then
AuxManageFrame:Show()
Aux.manage_frame.on_open()
Aux.auctions_frame.on_open()
elseif index == 5 then
AuxManageFrame:Show()
Aux.bids_frame.on_open()
end
end)
end
+18 -1
View File
@@ -462,7 +462,24 @@
</Anchors>
<Scripts>
<OnLoad>
getglobal(this:GetName().."Text"):SetText('Manage')
getglobal(this:GetName().."Text"):SetText('Auctions')
</OnLoad>
<OnClick>
Aux.on_tab_click(this:GetID())
</OnClick>
</Scripts>
</Button>
<Button name="AuxTab5" inherits="AuxBottomTabTemplate" id="5">
<Anchors>
<Anchor point="LEFT" relativeTo="AuxTab4" relativePoint="RIGHT">
<Offset>
<AbsDimension x="0" y="0"/>
</Offset>
</Anchor>
</Anchors>
<Scripts>
<OnLoad>
getglobal(this:GetName().."Text"):SetText('Bids')
</OnLoad>
<OnClick>
Aux.on_tab_click(this:GetID())
+7 -194
View File
@@ -1,11 +1,7 @@
local private, public = {}, {}
Aux.manage_frame = public
Aux.bids_frame = public
local update_bid_records, update_auction_records, wait_for_bids, wait_for_auctions
local bid_records, auction_records
local BIDS, AUCTIONS = 1, 2
local bid_records
public.bid_listing_config = {
on_row_click = function(sheet, row_index, column_index)
@@ -148,135 +144,8 @@ public.bid_listing_config = {
sort_order = {{ column = 1, order = 'ascending' }},
}
public.auction_listing_config = {
on_row_click = function (sheet, row_index)
local data_index = row_index + FauxScrollFrame_GetOffset(sheet.scroll_frame)
public.on_auction_click(sheet.data[data_index])
end,
on_row_enter = function (sheet, row_index)
sheet.rows[row_index].highlight:SetAlpha(.5)
end,
on_row_leave = function (sheet, row_index)
sheet.rows[row_index].highlight:SetAlpha(0)
end,
columns = {
{
title = 'Auction Item',
width = 280,
comparator = function(row1, row2) return Aux.util.compare(row1.tooltip[1][1].text, row2.tooltip[1][1].text, Aux.util.GT) end,
cell_initializer = function(cell)
local icon = CreateFrame('Button', nil, cell)
icon:EnableMouse(false)
local icon_texture = icon:CreateTexture(nil, 'BORDER')
icon_texture:SetAllPoints(icon)
icon.icon_texture = icon_texture
local normal_texture = icon:CreateTexture(nil)
normal_texture:SetPoint('CENTER', 0, 0)
normal_texture:SetWidth(22)
normal_texture:SetHeight(22)
normal_texture:SetTexture('Interface\\Buttons\\UI-Quickslot2')
icon:SetNormalTexture(normal_texture)
icon:SetPoint('LEFT', cell)
icon:SetWidth(12)
icon:SetHeight(12)
local text = cell:CreateFontString(nil, 'OVERLAY', 'GameFontHighlightSmall')
text:SetPoint("LEFT", icon, "RIGHT", 1, 0)
text:SetPoint('TOPRIGHT', cell)
text:SetPoint('BOTTOMRIGHT', cell)
text:SetJustifyV('TOP')
text:SetJustifyH('LEFT')
text:SetTextColor(0.8, 0.8, 0.8)
cell.text = text
cell.icon = icon
end,
cell_setter = function(cell, datum)
cell.icon.icon_texture:SetTexture(Aux.info.item(datum.item_id).texture)
if not datum.usable then
cell.icon.icon_texture:SetVertexColor(1.0, 0.1, 0.1)
else
cell.icon.icon_texture:SetVertexColor(1.0, 1.0, 1.0)
end
cell.text:SetText('['..datum.tooltip[1][1].text..']')
local color = ITEM_QUALITY_COLORS[datum.quality]
cell.text:SetTextColor(color.r, color.g, color.b)
private.auction_alpha_setter(cell, datum)
end,
},
{
title = 'Qty',
width = 25,
comparator = function(row1, row2) return Aux.util.compare(row1.stack_size, row2.stack_size, Aux.util.LT) end,
cell_initializer = Aux.sheet.default_cell_initializer('RIGHT'),
cell_setter = function(cell, datum)
cell.text:SetText(datum.aux_quantity)
private.auction_alpha_setter(cell, datum)
end,
},
{
title = 'Left',
width = 30,
comparator = function(row1, row2) return Aux.util.compare(row1.duration, row2.duration, Aux.util.GT) end,
cell_initializer = Aux.sheet.default_cell_initializer('CENTER'),
cell_setter = function(cell, datum)
local text
if datum.duration == 1 then
text = '30m'
elseif datum.duration == 2 then
text = '2h'
elseif datum.duration == 3 then
text = '8h'
elseif datum.duration == 4 then
text = '24h'
end
cell.text:SetText(text)
private.auction_alpha_setter(cell, datum)
end,
},
{
title = 'Current Bid',
width = 90,
comparator = function(auction1, auction2) return Aux.util.compare(auction1.current_bid, auction2.current_bid, Aux.util.GT) end,
cell_initializer = Aux.sheet.default_cell_initializer('CENTER'),
cell_setter = function(cell, auction)
cell.text:SetText(auction.current_bid and Aux.util.money_string(auction.current_bid) or RED_FONT_COLOR_CODE..'No Bids'..FONT_COLOR_CODE_CLOSE)
private.auction_alpha_setter(cell, auction)
end,
},
{
title = 'Min Bid',
width = 90,
comparator = function(auction1, auction2) return Aux.util.compare(auction1.min_bid, auction2.min_bid, Aux.util.GT) end,
cell_initializer = Aux.sheet.default_cell_initializer('CENTER'),
cell_setter = function(cell, auction)
cell.text:SetText(Aux.util.money_string(auction.min_bid))
private.auction_alpha_setter(cell, auction)
end,
},
{
title = 'Buy',
width = 90,
comparator = function(row1, row2) return Aux.util.compare(row1.buyout_price, row2.buyout_price, Aux.util.GT) end,
cell_initializer = Aux.sheet.default_cell_initializer('RIGHT'),
cell_setter = function(cell, datum)
cell.text:SetText(Aux.util.money_string(datum.buyout_price))
private.auction_alpha_setter(cell, datum)
end,
},
},
sort_order = {{ column = 1, order = 'ascending' }},
}
function public.on_open()
public.listing = public.listing or BIDS
if public.listing == BIDS then
public.update_bid_records()
elseif public.listing == AUCTIONS then
public.update_auction_records()
end
public.update_bid_records()
public.update_listing()
end
@@ -314,52 +183,11 @@ function public.update_bid_records()
}
end
function public.update_auction_records()
Aux.log('Scanning auctions ...')
auction_records = {}
Aux.scan.start{
type = 'owner',
page = 0,
on_page_loaded = function(page, total_pages)
Aux.log('Scanning auction page '..(page+1)..' out of '..total_pages..' ...')
end,
on_read_auction = function(auction_info)
private.create_auction_record(auction_info)
end,
on_complete = function()
Aux.log('Scan complete: '..getn(auction_records)..' auctions found')
public.update_listing()
end,
on_abort = function()
end,
next_page = function(page, total_pages)
local last_page = max(total_pages - 1, 0)
if page < last_page then
return page + 1
end
end,
}
end
function public.update_listing()
AuxManageFrameListingBidListing:Hide()
AuxManageFrameListingAuctionListing:Hide()
for i=1,2 do
getglobal('AuxManageFrameListingTab'..i):SetAlpha(i == public.listing and 1 or 0.5)
end
if public.listing == BIDS then
AuxManageFrameListingBidListing:Show()
Aux.sheet.populate(AuxManageFrameListingBidListing.sheet, bid_records)
AuxManageFrameListing:SetWidth(AuxManageFrameListingBidListing:GetWidth() + 40)
AuxFrame:SetWidth(AuxManageFrameListing:GetWidth() + 15)
elseif public.listing == AUCTIONS then
AuxManageFrameListingAuctionListing:Show()
Aux.sheet.populate(AuxManageFrameListingAuctionListing.sheet, auction_records)
AuxManageFrameListing:SetWidth(AuxManageFrameListingAuctionListing:GetWidth() + 40)
AuxFrame:SetWidth(AuxManageFrameListing:GetWidth() + 15)
end
AuxManageFrameListingBidListing:Show()
Aux.sheet.populate(AuxManageFrameListingBidListing.sheet, bid_records)
AuxManageFrameListing:SetWidth(AuxManageFrameListingBidListing:GetWidth() + 40)
AuxFrame:SetWidth(AuxManageFrameListing:GetWidth() + 15)
end
function private.create_record(auction_info)
@@ -404,10 +232,6 @@ function private.create_record(auction_info)
}
end
function private.create_auction_record(auction_info)
tinsert(auction_records, private.create_record(auction_info))
end
function private.create_bid_record(auction_info)
tinsert(bid_records, private.create_record(auction_info))
end
@@ -514,17 +338,6 @@ function private.find_auction(entry, action, express_mode)
}
end
function public.on_auction_click(auction_record)
local express_mode = IsAltKeyDown()
if IsControlKeyDown() then
DressUpItemLink(auction_record.hyperlink)
else
private.find_auction(auction_record, 'cancel', express_mode)
end
end
function public.on_bid_click(bid_record)
local express_mode = IsAltKeyDown()
+4 -79
View File
@@ -1,6 +1,6 @@
<Ui xsi:schemaLocation="http://www.blizzard.com/wow/ui/">
<Script file="manage_frame.lua"/>
<Script file="bids_frame.lua"/>
<Frame name="AuxManageFrame" hidden="true" parent="AuxFrame" setAllPoints="true">
<Frames>
@@ -16,44 +16,6 @@
</OnLoad>
</Scripts>
<Frames>
<Button name="$parentTab1" inherits="AuxTopTabTemplate" id="1">
<Anchors>
<Anchor point="BOTTOMLEFT" relativePoint="TOPLEFT">
<Offset>
<AbsDimension x="7" y="-2"/>
</Offset>
</Anchor>
</Anchors>
<Scripts>
<OnLoad>
getglobal(this:GetName().."Text"):SetText('Bids')
</OnLoad>
<OnClick>
Aux.manage_frame.listing = this:GetID()
Aux.manage_frame.update_bid_records()
Aux.manage_frame.update_listing()
</OnClick>
</Scripts>
</Button>
<Button name="$parentTab2" inherits="AuxTopTabTemplate" id="2">
<Anchors>
<Anchor point="LEFT" relativeTo="$parentTab1" relativePoint="RIGHT">
<Offset>
<AbsDimension x="0" y="0"/>
</Offset>
</Anchor>
</Anchors>
<Scripts>
<OnLoad>
getglobal(this:GetName().."Text"):SetText('Auctions')
</OnLoad>
<OnClick>
Aux.manage_frame.listing = this:GetID()
Aux.manage_frame.update_auction_records()
Aux.manage_frame.update_listing()
</OnClick>
</Scripts>
</Button>
<Frame name="$parentBidListing">
<Anchors>
<Anchor point="TOPLEFT"><Offset><AbsDimension x="0" y="0"/></Offset></Anchor>
@@ -61,7 +23,7 @@
</Anchors>
<Scripts>
<OnLoad>
local config = Aux.manage_frame.bid_listing_config
local config = Aux.bids_frame.bid_listing_config
this.sheet = Aux.sheet.create{
frame = this,
columns = config.columns,
@@ -75,27 +37,6 @@
</OnLoad>
</Scripts>
</Frame>
<Frame name="$parentAuctionListing">
<Anchors>
<Anchor point="TOPLEFT"><Offset><AbsDimension x="0" y="0"/></Offset></Anchor>
<Anchor point="BOTTOM"><Offset><AbsDimension x="0" y="0"/></Offset></Anchor>
</Anchors>
<Scripts>
<OnLoad>
local config = Aux.manage_frame.auction_listing_config
this.sheet = Aux.sheet.create{
frame = this,
columns = config.columns,
sort_order = config.sort_order,
row_setter = config.row_setter,
on_row_click = config.on_row_click,
on_row_enter = config.on_row_enter,
on_row_leave = config.on_row_leave,
on_row_update = config.on_row_update,
}
</OnLoad>
</Scripts>
</Frame>
<Frame name="$parentDialog" frameStrata="FULLSCREEN_DIALOG" inherits="OptionFrameBoxTemplate" enableMouse="true" enableMouseWheel="true" hidden="true">
<Anchors>
<Anchor point="TOPLEFT"><Offset><AbsDimension x="0" y="0"/></Offset></Anchor>
@@ -150,7 +91,7 @@
<Anchors><Anchor point="BOTTOMLEFT"><Offset><AbsDimension x="0" y="0"/></Offset></Anchor></Anchors>
<Scripts>
<OnClick>
Aux.manage_frame.dialog_action()
Aux.bids_frame.dialog_action()
</OnClick>
</Scripts>
</Button>
@@ -159,7 +100,7 @@
<Anchors><Anchor point="BOTTOMRIGHT"><Offset><AbsDimension x="0" y="0"/></Offset></Anchor></Anchors>
<Scripts>
<OnClick>
Aux.manage_frame.dialog_cancel()
Aux.bids_frame.dialog_cancel()
</OnClick>
</Scripts>
</Button>
@@ -169,22 +110,6 @@
</Frame>
</Frames>
</Frame>
<Frame name="AuxManageAuctions" inherits="AuxFrameBoxTemplate">
<Size>
<AbsDimension x="400" y="326"/>
</Size>
<Anchors><Anchor point="TOPLEFT" relativePoint="TOPRIGHT" relativeTo="AuxManageBids"><Offset><AbsDimension x="0" y="0"/></Offset></Anchor></Anchors>
<Scripts>
<OnLoad>
this:SetBackdropBorderColor(0.4, 0.4, 0.4)
this:SetBackdropColor(0.15, 0.15, 0.15)
getglobal(this:GetName().."Title"):SetText('Auctions')
</OnLoad>
</Scripts>
<Frames>
</Frames>
</Frame>
</Frames>
</Frame>
</Ui>