From cf04807e2b2dc9ff05f1a6312c8806d33589898e Mon Sep 17 00:00:00 2001 From: Manuel Simon Hirsig Date: Tue, 13 Oct 2015 01:19:37 +0200 Subject: [PATCH] working on redesign and new features for buy --- buy.lua | 43 ++++++++++++--------- buy.xml | 71 ++++++++++++---------------------- core.lua | 25 +----------- list.lua | 116 +++++++++++++++++++++++++++++++++++++------------------ list.xml | 72 ++++++++++++++++++++++++++-------- 5 files changed, 185 insertions(+), 142 deletions(-) diff --git a/buy.lua b/buy.lua index e94aa2b..9388e72 100644 --- a/buy.lua +++ b/buy.lua @@ -154,6 +154,9 @@ end ----------------------------------------- function AuxBuyEntry_OnClick(entry_index) + local scroll_frame = getglobal(this:GetParent():GetName().."ScrollFrame") + local entry_index = this:GetID() + FauxScrollFrame_GetOffset(scroll_frame) + local express_mode = IsAltKeyDown() local buyout_mode = arg1 == "LeftButton" @@ -261,8 +264,10 @@ function AuxBuyEntry_OnClick(entry_index) } end -function AuxBuyEntry_OnEnter(entry_index) - local entry = entries[entry_index] +function Aux.buy.icon_on_enter() + local scroll_frame = getglobal(this:GetParent():GetParent():GetName().."ScrollFrame") + local index = this:GetParent():GetID() + FauxScrollFrame_GetOffset(scroll_frame) + local entry = entries[index] Aux.info.set_game_tooltip(this, entry.tooltip) @@ -279,11 +284,12 @@ function process_auction(auction_item, current_page) 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 buyout_price = auction_item.buyout_price > 0 and auction_item.buyout_price or nil - 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 tinsert(entries, { name = auction_item.name, + texture = auction_item.texture, tooltip = auction_item.tooltip, stack_size = stack_size, buyout_price = buyout_price, @@ -293,7 +299,7 @@ function process_auction(auction_item, current_page) itemstring = auction_item.itemstring, page = current_page, bid = bid, - bid_per_unit = Aux_Round(bid / stack_size), + bid_per_unit = Aux_Round(bid/stack_size), owner = auction_item.owner, duration = auction_item.duration, }) @@ -335,7 +341,7 @@ function AuxBuyCategoryDropDown_Initialize(arg1) if level == 1 then local value = {} UIDropDownMenu_AddButton({ - text= 'All', + text = ALL, value = value, func = AuxBuyCategoryDropDown_OnClick, }, 1) @@ -394,25 +400,24 @@ function AuxBuyCategoryDropDown_OnClick() CloseDropDownMenus(1) end -function AuxBuySlotDropDown_Initialize() +function AuxBuyQualityDropDown_Initialize() UIDropDownMenu_AddButton{ - text= 'All', - value = value, - func = AuxBuySlotDropDown_OnClick('All', value), + text = ALL, + value = -1, + func = AuxBuyQualityDropDown_OnClick, } - - -- for i, type in pairs({ GetAuctionInvTypes() }) do - -- UIDropDownMenu_AddButton{ - -- text = class, - -- value = i, - -- func = AuxBuySlotDropDown_OnClick(), - -- } - -- end + for i=0,getn(ITEM_QUALITY_COLORS)-2 do + UIDropDownMenu_AddButton{ + text = getglobal("ITEM_QUALITY"..i.."_DESC"), + value = i, + func = AuxBuyQualityDropDown_OnClick, + } + end end -function AuxBuySlotDropDown_OnClick() - UIDropDownMenu_SetSelectedValue(AuxBuySlotDropDown, this.value) +function AuxBuyQualityDropDown_OnClick() + UIDropDownMenu_SetSelectedValue(AuxBuyQualityDropDown, this.value) end function AuxBuyTooltipButton_OnClick() diff --git a/buy.xml b/buy.xml index f013165..602aa81 100644 --- a/buy.xml +++ b/buy.xml @@ -17,11 +17,6 @@ this:RegisterForClicks("LeftButtonUp", "RightButtonUp") - - scrollFrame = getglobal(this:GetParent():GetName().."ScrollFrame") - index = this:GetID() + FauxScrollFrame_GetOffset(scrollFrame) - AuxBuyEntry_OnEnter(index) - GameTooltip:Hide() ResetCursor() @@ -65,8 +60,8 @@ - - + + Aux.list.on_load(this) @@ -212,10 +207,10 @@ - + - + @@ -250,7 +245,7 @@ - + @@ -267,7 +262,7 @@ - + @@ -284,7 +279,7 @@ UIDropDownMenu_Initialize(this, AuxBuyCategoryDropDown_Initialize) - UIDropDownMenu_SetWidth(200) + UIDropDownMenu_SetWidth(140) UIDropDownMenu_Initialize(this, AuxBuyCategoryDropDown_Initialize) @@ -294,7 +289,7 @@ - + @@ -311,8 +306,8 @@ - - + + @@ -334,7 +329,6 @@ - UIDropDownMenu_Initialize(this, AuxBuyTooltipDropDown_Initialize) @@ -351,59 +345,42 @@ - - - - - - + + - - - - - - + + - - - - - - + + - - - - - - + + - - + diff --git a/core.lua b/core.lua index 51ed742..4fbf6a9 100644 --- a/core.lua +++ b/core.lua @@ -73,30 +73,9 @@ function Aux_OnAddonLoaded() AuctionsBidSort, AuctionsCancelAuctionButton } - + Aux.tabs.buy.hiddenElements = { AuctionFrameBrowse, - BidTitle, - BidScrollFrame, - BidButton1, - BidButton2, - BidButton3, - BidButton4, - BidButton5, - BidButton6, - BidButton7, - BidButton8, - BidButton9, - BidQualitySort, - BidLevelSort, - BidDurationSort, - BidBuyoutSort, - BidStatusSort, - BidBidSort, - BidBidButton, - BidBuyoutButton, - BidBidPrice, - BidBidText } Aux.tabs.sell.recommendationElements = { @@ -246,7 +225,7 @@ function Aux_AuctionFrameTab_OnClick(index) AuctionFrame:EnableMouse(false) elseif index == Aux.tabs.buy.index then - AuctionFrameTab_OnClick(2) + Aux.orig.AuctionFrameTab_OnClick(1) PanelTemplates_SetTab(AuctionFrame, Aux.tabs.buy.index) diff --git a/list.lua b/list.lua index 0bd7f67..17b52a1 100644 --- a/list.lua +++ b/list.lua @@ -2,7 +2,7 @@ Aux.list = {} local MAX_COLUMNS = 6 -local NAME, OWNER, BID, BID_UNIT, BUYOUT, BUYOUT_UNIT, QUANTITY = 1, 2, 3, 4, 5, 6, 7, 8 +local NAME, OWNER, BID, BID_UNIT, BUYOUT, BUYOUT_UNIT, QUANTITY, TIME_LEFT = 1, 2, 3, 4, 5, 6, 7, 8 MoneyTypeInfo["AUX_LIST"] = { UpdateFunc = function() @@ -15,10 +15,11 @@ MoneyTypeInfo["AUX_LIST"] = { local logical_columns = { { - type = 'STRING', - title = 'Name', - comparator = function(row1, row2) return Aux.util.compare(row1.name, row2.name, Aux.util.GT) end, - getter = function(row) return row.name end, + type = 'ITEM', + title = 'Auction Item', + texture = function(row) return row.texture end, + comparator = function(row1, row2) return Aux.util.compare(row1.tooltip[1][1].text, row2.tooltip[1][1].text, Aux.util.GT) end, + getter = function(row) return ' ['..row.tooltip[1][1].text..']' end, color = function(row) return ITEM_QUALITY_COLORS[row.quality] end, }, { @@ -53,38 +54,61 @@ local logical_columns = { }, { type = 'NUMBER', - title = 'Quantity', + title = '#', comparator = function(row1, row2) return Aux.util.compare(row1.stack_size, row2.stack_size, Aux.util.LT) end, getter = function(row) return row.stack_size end, }, { type = 'STRING', - title = 'Time Left', + title = 'Left', comparator = function(row1, row2) return Aux.util.compare(row1.duration, row2.duration, Aux.util.GT) end, getter = function(row) if row.duration == 1 then - return 'Short' + return '30m' elseif row.duration == 2 then - return 'Medium' + return '2h' elseif row.duration == 3 then - return 'Long' + return '8h' elseif row.duration == 4 then - return 'Very Long' + return '12h' end end, }, } local physical_columns = { - { logical_column = logical_columns[NAME], width = 156 }, - { logical_column = logical_columns[OWNER], width = 156 }, - { logical_column = logical_columns[BUYOUT_UNIT], width = 156 }, - { logical_column = logical_columns[QUANTITY], width = 156 }, - { logical_column = logical_columns[BUYOUT], width = 156 }, + { + logical_columns = { logical_columns[QUANTITY] }, + logical_column = logical_columns[QUANTITY], + width = 30 + }, + { + logical_columns = { logical_columns[NAME] }, + logical_column = logical_columns[NAME], + width = 180 + }, + { + logical_columns = { logical_columns[TIME_LEFT] }, + logical_column = logical_columns[TIME_LEFT], + width = 40 + }, + { + logical_columns = { logical_columns[OWNER] }, + logical_column = logical_columns[OWNER], + width = 90 + }, + { + logical_columns = { logical_columns[BID_UNIT], logical_columns[BUYOUT_UNIT] }, + logical_column = logical_columns[BUYOUT_UNIT], + width = 140 + }, + { + logical_columns = { logical_columns[BID], logical_columns[BUYOUT] }, + logical_column = logical_columns[BUYOUT], + width = 140 + }, } - - function Aux.list.on_load() Aux.list.initialize(this, physical_columns, logical_columns) end @@ -120,11 +144,12 @@ function Aux.list.initialize(frame, physical_columns, logical_columns) frame.sort_order = {} for i, logical_column in logical_columns do - if i ~= BUYOUT_UNIT then + if i ~= BUYOUT_UNIT and i ~= NAME then tinsert(frame.sort_order, { logical_column = logical_column, sort_ascending = true }) end end tinsert(frame.sort_order, 1, { logical_column = logical_columns[BUYOUT_UNIT], sort_ascending = true }) + tinsert(frame.sort_order, 1, { logical_column = logical_columns[NAME], sort_ascending = true }) for i = 1, MAX_COLUMNS do local button = getglobal(frame:GetName().."Column"..i.."Sort") @@ -136,7 +161,11 @@ function Aux.list.initialize(frame, physical_columns, logical_columns) getglobal(button:GetName().."Arrow"):Hide() getglobal(button:GetName().."Text"):SetText(logical_column.title) button:Show() - dropdown:Show() + if (getn(physical_column.logical_columns) > 1) then + dropdown:Show(); + else + dropdown:Hide(); + end Aux.list.set_column_width(frame, i, physical_column.width); else @@ -160,7 +189,7 @@ function Aux.list.set_column_width(frame, column_index, width) for line = 1, frame.lines do local text = getglobal(frame:GetName().."Item"..line.."Column"..column_index) if text then - text:SetWidth(width - 20) + text:SetWidth(width - 3) end end end @@ -264,20 +293,29 @@ function Aux.list.scroll_frame_update(frame) if row_index <= getn(content) then for column_index = 1, MAX_COLUMNS do + local item = getglobal(parent:GetName().."Item"..line.."Column"..column_index.."Item") + if item then + item:Hide() + end + local text = getglobal(parent:GetName().."Item"..line.."Column"..column_index) -- text:Hide() TODO text:SetText() local moneyFrame = getglobal(parent:GetName().."Item"..line.."Column"..column_index.."MoneyFrame") moneyFrame:Hide() - + if column_index <= table.getn(parent.physical_columns) then local physical_column = parent.physical_columns[column_index] local logical_column = physical_column.logical_column local value = logical_column.getter(content[row_index]) if value then - if text and (logical_column.type == "DATE" or logical_column.type == "NUMBER" or logical_column.type == "STRING") then + if item and logical_column.type == "ITEM" then + item:Show() + getglobal(item:GetName() .. 'IconTexture'):SetTexture(logical_column.texture(content[row_index])) + end + if text and (logical_column.type == "DATE" or logical_column.type == "NUMBER" or logical_column.type == "STRING" or logical_column.type == "ITEM") then text:SetText(value) if logical_column.color then local color = logical_column.color(content[row_index]) @@ -290,11 +328,11 @@ function Aux.list.scroll_frame_update(frame) else text:SetAlpha(1.0) end - if (logical_column.type == "NUMBER") then - text:SetJustifyH("RIGHT") - else - text:SetJustifyH("LEFT") - end + -- if (logical_column.type == "NUMBER") then + -- text:SetJustifyH("RIGHT") + -- else + -- text:SetJustifyH("LEFT") + -- end text:Show() elseif moneyFrame and logical_column.type == "MONEY" then if value >= 0 then @@ -341,13 +379,17 @@ end function Aux.list.dropdown_initialize() local dropdown = this:GetParent() local frame = dropdown:GetParent() - - for _, logical_column in pairs(frame.logical_columns) do - UIDropDownMenu_AddButton({ - text = logical_column.title, - owner = dropdown, - func = Aux.list.dropdown_item_onclick - }) + + if frame.physical_columns then + local physical_column_index = dropdown:GetID() + local physical_column = frame.physical_columns[physical_column_index] + for _, logical_column in pairs(physical_column.logical_columns) do + UIDropDownMenu_AddButton({ + text = logical_column.title, + owner = dropdown, + func = Aux.list.dropdown_item_onclick, + }) + end end end @@ -358,9 +400,9 @@ function Aux.list.dropdown_item_onclick() local physical_column_index = this.owner:GetID() local dropdown = this.owner local frame = dropdown:GetParent() - if (frame.physical_columns[physical_column_index].logical_column ~= frame.logical_columns[logical_column_index]) then + if frame.physical_columns[physical_column_index].logical_column ~= frame.logical_columns[logical_column_index] then - frame.physical_columns[physical_column_index].logical_column = frame.logical_columns[logical_column_index] + frame.physical_columns[physical_column_index].logical_column = frame.physical_columns[physical_column_index].logical_columns[logical_column_index] getglobal(frame:GetName().."Column"..physical_column_index.."SortText"):SetText(frame.physical_columns[physical_column_index].logical_column.title) Aux.util.merge_sort(frame.content, Aux.list.row_comparator(frame)) diff --git a/list.xml b/list.xml index cb03cf2..9a1d3e1 100644 --- a/list.xml +++ b/list.xml @@ -3,38 +3,78 @@