working on buy modes

This commit is contained in:
Simon Hirsig
2015-10-19 13:08:29 +02:00
parent 983f515e41
commit 2cebeb5640
+48 -69
View File
@@ -1,8 +1,8 @@
Aux.buy = {} Aux.buy = {}
local process_auction, set_message, report, show_dialog, find_auction, hide_sheet, show_sheet, alpha_setter local process_auction, set_message, report, show_dialog, find_auction, hide_sheet, show_sheet, alpha_setter
local entries local auctions
local selectedEntries = {} local selectedAuctions = {}
local search_query local search_query
local tooltip_patterns = {} local tooltip_patterns = {}
local current_page local current_page
@@ -12,8 +12,10 @@ local function alpha_setter(cell, datum)
cell:SetAlpha(datum.gone and 0.4 or 1) cell:SetAlpha(datum.gone and 0.4 or 1)
end end
local BUY, BID, FULL = 1, 2, 3
Aux.buy.modes = { Aux.buy.modes = {
{ [BUY] = {
name = 'Buy', name = 'Buy',
on_cell_click = function (sheet, row_index, column_index) on_cell_click = function (sheet, row_index, column_index)
local entry_index = row_index + FauxScrollFrame_GetOffset(sheet.scroll_frame) local entry_index = row_index + FauxScrollFrame_GetOffset(sheet.scroll_frame)
@@ -133,19 +135,9 @@ Aux.buy.modes = {
alpha_setter(cell, datum) alpha_setter(cell, datum)
end, end,
}, },
{
title = 'Bid/ea',
width = 70,
comparator = function(row1, row2) return Aux.util.compare(row1.bid_per_unit, row2.bid_per_unit, 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.bid_per_unit))
alpha_setter(cell, datum)
end,
},
{ {
title = 'Buy/ea', title = 'Buy/ea',
width = 70, width = 140,
comparator = function(row1, row2) return Aux.util.compare(row1.buyout_price_per_unit, row2.buyout_price_per_unit, Aux.util.GT) end, comparator = function(row1, row2) return Aux.util.compare(row1.buyout_price_per_unit, row2.buyout_price_per_unit, Aux.util.GT) end,
cell_initializer = Aux.sheet.default_cell_initializer('RIGHT'), cell_initializer = Aux.sheet.default_cell_initializer('RIGHT'),
cell_setter = function(cell, datum) cell_setter = function(cell, datum)
@@ -153,19 +145,9 @@ Aux.buy.modes = {
alpha_setter(cell, datum) alpha_setter(cell, datum)
end, end,
}, },
{
title = 'Bid',
width = 70,
comparator = function(row1, row2) return Aux.util.compare(row1.bid, row2.bid, 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.bid))
alpha_setter(cell, datum)
end,
},
{ {
title = 'Buy', title = 'Buy',
width = 70, width = 140,
comparator = function(row1, row2) return Aux.util.compare(row1.buyout_price, row2.buyout_price, Aux.util.GT) end, 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_initializer = Aux.sheet.default_cell_initializer('RIGHT'),
cell_setter = function(cell, datum) cell_setter = function(cell, datum)
@@ -175,7 +157,7 @@ Aux.buy.modes = {
}, },
}, },
}, },
{ [BID] = {
name = 'Bid', name = 'Bid',
on_cell_click = function (sheet, row_index, column_index) on_cell_click = function (sheet, row_index, column_index)
local entry_index = row_index + FauxScrollFrame_GetOffset(sheet.scroll_frame) local entry_index = row_index + FauxScrollFrame_GetOffset(sheet.scroll_frame)
@@ -297,7 +279,7 @@ Aux.buy.modes = {
}, },
{ {
title = 'Bid/ea', title = 'Bid/ea',
width = 70, width = 140,
comparator = function(row1, row2) return Aux.util.compare(row1.bid_per_unit, row2.bid_per_unit, Aux.util.GT) end, comparator = function(row1, row2) return Aux.util.compare(row1.bid_per_unit, row2.bid_per_unit, Aux.util.GT) end,
cell_initializer = Aux.sheet.default_cell_initializer('RIGHT'), cell_initializer = Aux.sheet.default_cell_initializer('RIGHT'),
cell_setter = function(cell, datum) cell_setter = function(cell, datum)
@@ -305,19 +287,9 @@ Aux.buy.modes = {
alpha_setter(cell, datum) alpha_setter(cell, datum)
end, end,
}, },
{
title = 'Buy/ea',
width = 70,
comparator = function(row1, row2) return Aux.util.compare(row1.buyout_price_per_unit, row2.buyout_price_per_unit, 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_per_unit))
alpha_setter(cell, datum)
end,
},
{ {
title = 'Bid', title = 'Bid',
width = 70, width = 140,
comparator = function(row1, row2) return Aux.util.compare(row1.bid, row2.bid, Aux.util.GT) end, comparator = function(row1, row2) return Aux.util.compare(row1.bid, row2.bid, Aux.util.GT) end,
cell_initializer = Aux.sheet.default_cell_initializer('RIGHT'), cell_initializer = Aux.sheet.default_cell_initializer('RIGHT'),
cell_setter = function(cell, datum) cell_setter = function(cell, datum)
@@ -325,19 +297,9 @@ Aux.buy.modes = {
alpha_setter(cell, datum) alpha_setter(cell, datum)
end, end,
}, },
{
title = 'Buy',
width = 70,
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))
alpha_setter(cell, datum)
end,
},
}, },
}, },
{ [FULL] = {
name = 'Full', name = 'Full',
on_cell_click = function (sheet, row_index, column_index) on_cell_click = function (sheet, row_index, column_index)
local entry_index = row_index + FauxScrollFrame_GetOffset(sheet.scroll_frame) local entry_index = row_index + FauxScrollFrame_GetOffset(sheet.scroll_frame)
@@ -531,13 +493,24 @@ function Aux.buy.StopButton_onclick()
end end
function show_sheet() function show_sheet()
-- TODO AuxBuyBuyList:Hide()
AuxBuyFullList:Show() AuxBuyBidList:Hide()
AuxBuyFullList:Hide()
local mode = AuxBuyModeDropDown:GetValue()
if mode == BUY then
AuxBuyBuyList:Show()
elseif mode == BID then
AuxBuyBidList:Show()
elseif mode == FULL then
AuxBuyFullList:Show()
end
end end
function hide_sheet() function hide_sheet()
-- TODO AuxBuyBuyList:Hide()
AuxBuyFullList:Hide() AuxBuyBidList:Hide()
AuxBuyFullList:Hide()
end end
function Aux.buy.SearchButton_onclick() function Aux.buy.SearchButton_onclick()
@@ -549,8 +522,8 @@ function Aux.buy.SearchButton_onclick()
AuxBuySearchButton:Hide() AuxBuySearchButton:Hide()
AuxBuyStopButton:Show() AuxBuyStopButton:Show()
entries = nil auctions = nil
selectedEntries = {} selectedAuctions = {}
refresh = true refresh = true
@@ -590,8 +563,8 @@ function Aux.buy.SearchButton_onclick()
end end
end, end,
on_complete = function() on_complete = function()
entries = entries or {} auctions = auctions or {}
if getn(entries) == 0 then if getn(auctions) == 0 then
set_message("No auctions were found") set_message("No auctions were found")
else else
AuxBuyMessage:Hide() AuxBuyMessage:Hide()
@@ -601,8 +574,8 @@ function Aux.buy.SearchButton_onclick()
refresh = true refresh = true
end, end,
on_abort = function() on_abort = function()
entries = entries or {} auctions = auctions or {}
if getn(entries) == 0 then if getn(auctions) == 0 then
set_message("No auctions were found") set_message("No auctions were found")
else else
AuxBuyMessage:Hide() AuxBuyMessage:Hide()
@@ -778,7 +751,7 @@ function AuxBuyEntry_OnClick(entry_index)
local express_mode = IsAltKeyDown() local express_mode = IsAltKeyDown()
local buyout_mode = arg1 == 'LeftButton' local buyout_mode = arg1 == 'LeftButton'
local entry = entries[entry_index] local entry = auctions[entry_index]
if IsControlKeyDown() then if IsControlKeyDown() then
DressUpItemLink(entry.hyperlink) DressUpItemLink(entry.hyperlink)
@@ -790,7 +763,7 @@ end
----------------------------------------- -----------------------------------------
function process_auction(auction_item, current_page) function process_auction(auction_item, current_page)
entries = entries or {} auctions = auctions or {}
local stack_size = auction_item.charges or auction_item.count local stack_size = auction_item.charges or auction_item.count
local bid = (auction_item.current_bid > 0 and auction_item.current_bid or auction_item.min_bid) + auction_item.min_increment local bid = (auction_item.current_bid > 0 and auction_item.current_bid or auction_item.min_bid) + auction_item.min_increment
@@ -798,7 +771,7 @@ function process_auction(auction_item, current_page)
local buyout_price_per_unit = buyout_price and Aux_Round(auction_item.buyout_price/stack_size) local buyout_price_per_unit = buyout_price and Aux_Round(auction_item.buyout_price/stack_size)
if auction_item.owner ~= UnitName('player') then if auction_item.owner ~= UnitName('player') then
tinsert(entries, { tinsert(auctions, {
name = auction_item.name, name = auction_item.name,
level = auction_item.level, level = auction_item.level,
texture = auction_item.texture, texture = auction_item.texture,
@@ -834,7 +807,13 @@ end
----------------------------------------- -----------------------------------------
function Aux_Buy_ScrollbarUpdate() function Aux_Buy_ScrollbarUpdate()
Aux.list.populate(AuxBuyFullList.sheet, entries or {}) if mode == BUY then
Aux.list.populate(AuxBuyBuyList.sheet, auctions or {})
elseif mode == BID then
Aux.list.populate(AuxBuyBidList.sheet, auctions or {})
elseif mode == FULL then
Aux.list.populate(AuxBuyFullList.sheet, auctions or {})
end
end end
----------------------------------------- -----------------------------------------
@@ -915,15 +894,13 @@ function AuxBuyQualityDropDown_Initialize()
UIDropDownMenu_AddButton{ UIDropDownMenu_AddButton{
text = getglobal("ITEM_QUALITY"..i.."_DESC"), text = getglobal("ITEM_QUALITY"..i.."_DESC"),
value = i, value = i,
func = AuxBuyQualityDropDown_OnClick, func = function AuxBuyQualityDropDown_OnClick()
UIDropDownMenu_SetSelectedValue(AuxBuyQualityDropDown, this.value)
end,
} }
end end
end end
function AuxBuyQualityDropDown_OnClick()
UIDropDownMenu_SetSelectedValue(AuxBuyQualityDropDown, this.value)
end
function AuxBuyTooltipButton_OnClick() function AuxBuyTooltipButton_OnClick()
local pattern = AuxBuyTooltipInputBox:GetText() local pattern = AuxBuyTooltipInputBox:GetText()
if pattern ~= '' then if pattern ~= '' then
@@ -961,7 +938,9 @@ function AuxBuyModeDropDown_Initialize()
UIDropDownMenu_AddButton{ UIDropDownMenu_AddButton{
text = mode.name, text = mode.name,
value = i, value = i,
func = AuxBuyQualityDropDown_OnClick, func = function AuxBuyQualityDropDown_OnClick()
UIDropDownMenu_SetSelectedValue(AuxBuyModeDropDown, this.value)
end,
} }
end end
end end