From c29f59c6978c1917b72712fcec4de99a13bef125 Mon Sep 17 00:00:00 2001 From: Manuel Simon Hirsig Date: Sat, 16 Jul 2016 14:04:06 +0200 Subject: [PATCH] refactoring --- Aux-AddOn.toc | 4 +-- control.lua | 4 +-- core.lua | 6 ++-- tables/item_listing.lua | 2 +- tabs/auctions/core.lua | 8 ++--- tabs/auctions/core.xml | 18 ---------- tabs/auctions/frames.lua | 18 +++++++--- tabs/bids/core.lua | 8 ++--- tabs/bids/core.xml | 18 ---------- tabs/bids/frames.lua | 20 ++++++++--- tabs/post/core.lua | 28 ++++++++-------- tabs/post/core.xml | 50 ---------------------------- tabs/post/frames.lua | 71 +++++++++++++++++++++++++++------------- tabs/search/core.lua | 2 +- tabs/search/frames.lua | 1 + 15 files changed, 109 insertions(+), 149 deletions(-) delete mode 100644 tabs/auctions/core.xml delete mode 100644 tabs/bids/core.xml delete mode 100644 tabs/post/core.xml diff --git a/Aux-AddOn.toc b/Aux-AddOn.toc index 6a95265..ce31629 100644 --- a/Aux-AddOn.toc +++ b/Aux-AddOn.toc @@ -32,18 +32,16 @@ tables\listing.lua tables\auction_listing.lua tables\item_listing.lua + tabs\search\core.lua tabs\search\frames.lua -tabs\post\core.xml tabs\post\core.lua tabs\post\frames.lua -tabs\auctions\core.xml tabs\auctions\core.lua tabs\auctions\frames.lua -tabs\bids\core.xml tabs\bids\core.lua tabs\bids\frames.lua diff --git a/control.lua b/control.lua index eda380c..cbf5523 100644 --- a/control.lua +++ b/control.lua @@ -10,7 +10,7 @@ function public.LOAD() m.event_frame:SetScript('OnEvent', m.on_event) end -function public.on_event() +function private.on_event() for listener, _ in m.event_listeners do if event == listener.event and not listener.deleted then listener.action() @@ -18,7 +18,7 @@ function public.on_event() end end -function public.on_update() +function private.on_update() m.event_listeners = Aux.util.set_filter(m.event_listeners, function(l) return not l.deleted end) local threads = {} for thread_id, thread in m.threads do diff --git a/core.lua b/core.lua index 33c39df..140fd3c 100644 --- a/core.lua +++ b/core.lua @@ -14,8 +14,8 @@ end private.tabs = {} function public.tab(index, name) local ret = { m.module(name) } - ret[3].ACTIVE = function() - return index == m.active_tab + ret[2].ACTIVE = function() + return m[name] == m.active_tab() end m.tabs[index] = m[name] return unpack(ret) @@ -37,7 +37,7 @@ do end function public.on_load() - public.version = '3.0.1' + public.version = '3.0.2' public.blizzard_ui_shown = false public.bids_loaded = false public.current_owner_page = nil diff --git a/tables/item_listing.lua b/tables/item_listing.lua index 0bec9c7..952448e 100644 --- a/tables/item_listing.lua +++ b/tables/item_listing.lua @@ -37,7 +37,7 @@ function public.render(item_listing) end function public.create(parent, on_click, on_enter, on_leave, selected) - local name = (parent:GetName() or '')..'aux_item_list' + local name = 'aux_item_list' local id = 1 while getglobal(name..id) do diff --git a/tabs/auctions/core.lua b/tabs/auctions/core.lua index 7b1adc1..681eb42 100644 --- a/tabs/auctions/core.lua +++ b/tabs/auctions/core.lua @@ -11,16 +11,16 @@ function public.LOAD() end function public.OPEN() - AuxAuctionsFrame:Show() + m.frame:Show() m.scan_auctions() end function public.CLOSE() - AuxAuctionsFrame:Hide() + m.frame:Hide() end function private.update_listing() - if not AuxAuctionsFrame:IsVisible() then + if not m:ACTIVE() then return end @@ -106,7 +106,7 @@ do ) end - function public.on_update() + function private.on_update() if state == IDLE or state == SEARCHING then m.cancel_button:Disable() end diff --git a/tabs/auctions/core.xml b/tabs/auctions/core.xml deleted file mode 100644 index 49d8338..0000000 --- a/tabs/auctions/core.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - Aux.auctions_tab.on_update() - - - - - - - - - - - - - diff --git a/tabs/auctions/frames.lua b/tabs/auctions/frames.lua index ec1b467..ebd179a 100644 --- a/tabs/auctions/frames.lua +++ b/tabs/auctions/frames.lua @@ -1,5 +1,15 @@ Aux.auctions_tab.FRAMES(function(m, public, private) - private.listing = Aux.auction_listing.CreateAuctionResultsTable(AuxAuctionsFrameListing, Aux.auction_listing.auctions_config) + private.frame = CreateFrame('Frame', nil, AuxFrame) + m.frame:SetAllPoints() + m.frame:SetScript('OnUpdate', m.on_update) + m.frame:Hide() + + m.frame.listing = CreateFrame('Frame', nil, m.frame, 'AuxFrameBoxTemplate') + m.frame.listing:SetPoint('TOP', AuxFrame, 'TOP', 0, -8) + m.frame.listing:SetPoint('BOTTOMLEFT', AuxFrameContent, 'BOTTOMLEFT', 0, 0) + m.frame.listing:SetPoint('BOTTOMRIGHT', AuxFrameContent, 'BOTTOMRIGHT', 0, 0) + + private.listing = Aux.auction_listing.CreateAuctionResultsTable(m.frame.listing, Aux.auction_listing.auctions_config) m.listing:SetSort(1,2,3,4,5,6,7,8) m.listing:Reset() m.listing:SetHandler('OnCellClick', function(cell, button) @@ -13,7 +23,7 @@ Aux.auctions_tab.FRAMES(function(m, public, private) end) do - local status_bar = Aux.gui.status_bar(AuxAuctionsFrame) + local status_bar = Aux.gui.status_bar(m.frame) status_bar:SetWidth(265) status_bar:SetHeight(25) status_bar:SetPoint('TOPLEFT', AuxFrameContent, 'BOTTOMLEFT', 0, -6) @@ -22,7 +32,7 @@ Aux.auctions_tab.FRAMES(function(m, public, private) private.status_bar = status_bar end do - local btn = Aux.gui.button(AuxAuctionsFrame, 16) + local btn = Aux.gui.button(m.frame, 16) btn:SetPoint('TOPLEFT', m.status_bar, 'TOPRIGHT', 5, 0) btn:SetWidth(80) btn:SetHeight(24) @@ -31,7 +41,7 @@ Aux.auctions_tab.FRAMES(function(m, public, private) private.cancel_button = btn end do - local btn = Aux.gui.button(AuxAuctionsFrame, 16) + local btn = Aux.gui.button(m.frame, 16) btn:SetPoint('TOPLEFT', m.cancel_button, 'TOPRIGHT', 5, 0) btn:SetWidth(80) btn:SetHeight(24) diff --git a/tabs/bids/core.lua b/tabs/bids/core.lua index ac0d9a7..a0014db 100644 --- a/tabs/bids/core.lua +++ b/tabs/bids/core.lua @@ -11,16 +11,16 @@ function public.LOAD() end function public.OPEN() - AuxBidsFrame:Show() + m.frame:Show() m.scan_bids() end function public.CLOSE() - AuxBidsFrame:Hide() + m.frame:Hide() end function private.update_listing() - if not AuxBidsFrame:IsVisible() then + if not m:ACTIVE() then return end @@ -120,7 +120,7 @@ do ) end - function public.on_update() + function private.on_update() if state == IDLE or state == SEARCHING then m.buyout_button:Disable() m.bid_button:Disable() diff --git a/tabs/bids/core.xml b/tabs/bids/core.xml deleted file mode 100644 index 92be63e..0000000 --- a/tabs/bids/core.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - Aux.bids_tab.on_update() - - - - - - - - - - - - - diff --git a/tabs/bids/frames.lua b/tabs/bids/frames.lua index 27eaeb4..cf52bf7 100644 --- a/tabs/bids/frames.lua +++ b/tabs/bids/frames.lua @@ -1,5 +1,15 @@ Aux.bids_tab.FRAMES(function(m, public, private) - private.listing = Aux.auction_listing.CreateAuctionResultsTable(AuxBidsFrameListing, Aux.auction_listing.bids_config) + private.frame = CreateFrame('Frame', nil, AuxFrame) + m.frame:SetAllPoints() + m.frame:SetScript('OnUpdate', m.on_update) + m.frame:Hide() + + m.frame.listing = CreateFrame('Frame', nil, m.frame, 'AuxFrameBoxTemplate') + m.frame.listing:SetPoint('TOP', AuxFrame, 'TOP', 0, -8) + m.frame.listing:SetPoint('BOTTOMLEFT', AuxFrameContent, 'BOTTOMLEFT', 0, 0) + m.frame.listing:SetPoint('BOTTOMRIGHT', AuxFrameContent, 'BOTTOMRIGHT', 0, 0) + + private.listing = Aux.auction_listing.CreateAuctionResultsTable(m.frame.listing, Aux.auction_listing.bids_config) m.listing:SetSort(1,2,3,4,5,6,7,8) m.listing:Reset() m.listing:SetHandler('OnCellClick', function(cell, button) @@ -17,7 +27,7 @@ Aux.bids_tab.FRAMES(function(m, public, private) end) do - local status_bar = Aux.gui.status_bar(AuxBidsFrame) + local status_bar = Aux.gui.status_bar(m.frame) status_bar:SetWidth(265) status_bar:SetHeight(25) status_bar:SetPoint('TOPLEFT', AuxFrameContent, 'BOTTOMLEFT', 0, -6) @@ -26,7 +36,7 @@ Aux.bids_tab.FRAMES(function(m, public, private) private.status_bar = status_bar end do - local btn = Aux.gui.button(AuxBidsFrame, 16) + local btn = Aux.gui.button(m.frame, 16) btn:SetPoint('TOPLEFT', m.status_bar, 'TOPRIGHT', 5, 0) btn:SetWidth(80) btn:SetHeight(24) @@ -35,7 +45,7 @@ Aux.bids_tab.FRAMES(function(m, public, private) private.bid_button = btn end do - local btn = Aux.gui.button(AuxBidsFrame, 16) + local btn = Aux.gui.button(m.frame, 16) btn:SetPoint('TOPLEFT', m.bid_button, 'TOPRIGHT', 5, 0) btn:SetWidth(80) btn:SetHeight(24) @@ -44,7 +54,7 @@ Aux.bids_tab.FRAMES(function(m, public, private) private.buyout_button = btn end do - local btn = Aux.gui.button(AuxBidsFrame, 16) + local btn = Aux.gui.button(m.frame, 16) btn:SetPoint('TOPLEFT', m.buyout_button, 'TOPRIGHT', 5, 0) btn:SetWidth(80) btn:SetHeight(24) diff --git a/tabs/post/core.lua b/tabs/post/core.lua index c2a9e97..aa2b786 100644 --- a/tabs/post/core.lua +++ b/tabs/post/core.lua @@ -18,7 +18,7 @@ function public.LOAD() end function public.OPEN() - AuxPostFrame:Show() + m.frame:Show() m.deposit:SetText('Deposit: '..Aux.money.to_string(0, nil, nil, nil, Aux.gui.inline_color({255, 254, 250, 1}))) @@ -32,7 +32,7 @@ end function public.CLOSE() m.selected_item = nil - AuxPostFrame:Hide() + m.frame:Hide() end function private.default_settings() @@ -87,7 +87,7 @@ function private.set_unit_buyout_price(amount) end function private.update_inventory_listing() - if not AuxPostFrame:IsVisible() then + if not m.ACTIVE() then return end @@ -98,7 +98,7 @@ function private.update_inventory_listing() end function private.update_auction_listing() - if not AuxPostFrame:IsVisible() then + if not m.ACTIVE() then return end @@ -276,10 +276,10 @@ function private.update_item_configuration() if not m.selected_item then m.refresh_button:Disable() - AuxPostParametersItemIconTexture:SetTexture(nil) - AuxPostParametersItemCount:SetText() - AuxPostParametersItemName:SetTextColor(unpack(Aux.gui.config.label_color.enabled)) - AuxPostParametersItemName:SetText('No item selected') + AuxPostItemIconTexture:SetTexture(nil) + AuxPostItemCount:SetText() + AuxPostItemName:SetTextColor(unpack(Aux.gui.config.label_color.enabled)) + AuxPostItemName:SetText('No item selected') m.unit_start_price:Hide() m.unit_buyout_price:Hide() @@ -299,14 +299,14 @@ function private.update_item_configuration() m.historical_value_button:Show() m.hide_checkbox:Show() - AuxPostParametersItemIconTexture:SetTexture(m.selected_item.texture) - AuxPostParametersItemName:SetText('['..m.selected_item.name..']') + AuxPostItemIconTexture:SetTexture(m.selected_item.texture) + AuxPostItemName:SetText('['..m.selected_item.name..']') local color = ITEM_QUALITY_COLORS[m.selected_item.quality] - AuxPostParametersItemName:SetTextColor(color.r, color.g, color.b) + AuxPostItemName:SetTextColor(color.r, color.g, color.b) if m.selected_item.aux_quantity > 1 then - AuxPostParametersItemCount:SetText(m.selected_item.aux_quantity) + AuxPostItemCount:SetText(m.selected_item.aux_quantity) else - AuxPostParametersItemCount:SetText() + AuxPostItemCount:SetText() end m.stack_size_slider.editbox:SetNumber(m.stack_size_slider:GetValue()) @@ -543,7 +543,7 @@ function private.record_auction(key, aux_quantity, unit_blizzard_bid, unit_buyou return entry end -function public.on_update() +function private.on_update() if m.refresh then m.refresh = false m.price_update() diff --git a/tabs/post/core.xml b/tabs/post/core.xml deleted file mode 100644 index ad16dde..0000000 --- a/tabs/post/core.xml +++ /dev/null @@ -1,50 +0,0 @@ - - - - - - - - - Aux.post_tab.on_update() - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/tabs/post/frames.lua b/tabs/post/frames.lua index 868395c..e08147b 100644 --- a/tabs/post/frames.lua +++ b/tabs/post/frames.lua @@ -1,38 +1,65 @@ Aux.post_tab.FRAMES(function(m, public, private) - Aux.gui.vertical_line(AuxPostFrameContent, 219) + private.frame = CreateFrame('Frame', nil, AuxFrame) + m.frame:SetAllPoints() + m.frame:SetScript('OnUpdate', m.on_update) + m.frame:Hide() - AuxPostParametersItem:EnableMouse() - AuxPostParametersItem:SetScript('OnReceiveDrag', function() + m.frame.content = CreateFrame('Frame', nil, m.frame, 'AuxFrameBoxTemplate') + m.frame.content:SetPoint('TOP', AuxFrame, 'TOP', 0, -8) + m.frame.content:SetPoint('BOTTOMLEFT', AuxFrameContent, 'BOTTOMLEFT', 0, 0) + m.frame.content:SetPoint('BOTTOMRIGHT', AuxFrameContent, 'BOTTOMRIGHT', 0, 0) + + m.frame.inventory = CreateFrame('Frame', nil, m.frame.content, 'AuxFrameBoxTemplate') + m.frame.inventory:SetWidth(212) + m.frame.inventory:SetPoint('TOPLEFT', 4, -4) + m.frame.inventory:SetPoint('BOTTOMLEFT', 4, 4) + + m.frame.parameters = CreateFrame('Frame', nil, m.frame.content, 'AuxFrameBoxTemplate') + m.frame.parameters:SetHeight(177) + m.frame.parameters:SetPoint('TOPLEFT', m.frame.inventory, 'TOPRIGHT', 8, 0) + m.frame.parameters:SetPoint('TOPRIGHT', -4, 0) + + m.frame.parameters.item = CreateFrame('Button', 'AuxPostItem', m.frame.parameters, 'AuxItemTemplate') + m.frame.parameters.item:SetPoint('TOPLEFT', 10, -10) + + m.frame.auctions = CreateFrame('Frame', nil, m.frame.content, 'AuxFrameBoxTemplate') + m.frame.auctions:SetHeight(217) + m.frame.auctions:SetPoint('BOTTOMLEFT', m.frame.inventory, 'BOTTOMRIGHT', 8, 0) + m.frame.auctions:SetPoint('BOTTOMRIGHT', -4, 0) + + Aux.gui.vertical_line(m.frame.content, 219) + m.frame.parameters.item:EnableMouse() + m.frame.parameters.item:SetScript('OnReceiveDrag', function() local item_info = Aux.cursor_item() if item_info then m.select_item(item_info.item_key) end ClearCursor() end) - AuxPostParametersItem:SetScript('OnClick', function() + m.frame.parameters.item:SetScript('OnClick', function() local item_info = Aux.cursor_item() if item_info then m.select_item(item_info.item_key) end ClearCursor() end) - local highlight = AuxPostParametersItem:CreateTexture() - highlight:SetAllPoints(AuxPostParametersItem) + local highlight = m.frame.parameters.item:CreateTexture() + highlight:SetAllPoints(m.frame.parameters.item) highlight:Hide() highlight:SetTexture(1, .9, .9, .1) - AuxPostParametersItem:SetScript('OnEnter', function() + m.frame.parameters.item:SetScript('OnEnter', function() highlight:Show() if m.selected_item then Aux.info.set_tooltip(m.selected_item.itemstring, this, 'ANCHOR_RIGHT') end end) - AuxPostParametersItem:SetScript('OnLeave', function() + m.frame.parameters.item:SetScript('OnLeave', function() highlight:Hide() GameTooltip:Hide() end) do - local checkbox = CreateFrame('CheckButton', nil, AuxPostInventory, 'UICheckButtonTemplate') + local checkbox = CreateFrame('CheckButton', nil, m.frame.inventory, 'UICheckButtonTemplate') checkbox:SetWidth(22) checkbox:SetHeight(22) checkbox:SetPoint('TOPLEFT', 45, -15) @@ -45,10 +72,10 @@ Aux.post_tab.FRAMES(function(m, public, private) private.show_hidden_checkbox = checkbox end - Aux.gui.horizontal_line(AuxPostInventory, -48) + Aux.gui.horizontal_line(m.frame.inventory, -48) private.item_listing = Aux.item_listing.create( - AuxPostInventory, + m.frame.inventory, function() if arg1 == 'LeftButton' then m.set_item(this.item_record) @@ -70,7 +97,7 @@ Aux.post_tab.FRAMES(function(m, public, private) end ) - private.auction_listing = Aux.listing.CreateScrollingTable(AuxPostAuctions) + private.auction_listing = Aux.listing.CreateScrollingTable(m.frame.auctions) m.auction_listing:SetColInfo({ { name='Auctions', width=.12, align='CENTER' }, { name='Left', width=.1, align='CENTER' }, @@ -95,7 +122,7 @@ Aux.post_tab.FRAMES(function(m, public, private) end) do - local status_bar = Aux.gui.status_bar(AuxPostFrame) + local status_bar = Aux.gui.status_bar(m.frame) status_bar:SetWidth(265) status_bar:SetHeight(25) status_bar:SetPoint('TOPLEFT', AuxFrameContent, 'BOTTOMLEFT', 0, -6) @@ -104,7 +131,7 @@ Aux.post_tab.FRAMES(function(m, public, private) private.status_bar = status_bar end do - local btn = Aux.gui.button(AuxPostParameters, 16) + local btn = Aux.gui.button(m.frame.parameters, 16) btn:SetPoint('TOPLEFT', m.status_bar, 'TOPRIGHT', 5, 0) btn:SetWidth(80) btn:SetHeight(24) @@ -113,7 +140,7 @@ Aux.post_tab.FRAMES(function(m, public, private) private.post_button = btn end do - local btn = Aux.gui.button(AuxPostParameters, 16) + local btn = Aux.gui.button(m.frame.parameters, 16) btn:SetPoint('TOPLEFT', m.post_button, 'TOPRIGHT', 5, 0) btn:SetWidth(80) btn:SetHeight(24) @@ -126,7 +153,7 @@ Aux.post_tab.FRAMES(function(m, public, private) private.refresh_button = btn end do - local slider = Aux.gui.slider(AuxPostParameters) + local slider = Aux.gui.slider(m.frame.parameters) slider:SetValueStep(1) slider:SetPoint('TOPLEFT', 16, -75) slider:SetWidth(190) @@ -159,7 +186,7 @@ Aux.post_tab.FRAMES(function(m, public, private) private.stack_size_slider = slider end do - local slider = Aux.gui.slider(AuxPostParameters) + local slider = Aux.gui.slider(m.frame.parameters) slider:SetValueStep(1) slider:SetPoint('TOPLEFT', m.stack_size_slider, 'BOTTOMLEFT', 0, -30) slider:SetWidth(190) @@ -184,7 +211,7 @@ Aux.post_tab.FRAMES(function(m, public, private) private.stack_count_slider = slider end do - local dropdown = Aux.gui.dropdown(AuxPostParameters) + local dropdown = Aux.gui.dropdown(m.frame.parameters) dropdown:SetPoint('TOPLEFT', m.stack_count_slider, 'BOTTOMLEFT', 0, -19) dropdown:SetWidth(90) dropdown:SetHeight(10) @@ -201,7 +228,7 @@ Aux.post_tab.FRAMES(function(m, public, private) private.duration_dropdown = dropdown end do - local checkbox = CreateFrame('CheckButton', nil, AuxPostParameters, 'UICheckButtonTemplate') + local checkbox = CreateFrame('CheckButton', nil, m.frame.parameters, 'UICheckButtonTemplate') checkbox:SetWidth(22) checkbox:SetHeight(22) checkbox:SetPoint('TOPRIGHT', -85, -6) @@ -217,7 +244,7 @@ Aux.post_tab.FRAMES(function(m, public, private) private.hide_checkbox = checkbox end do - local editbox = Aux.gui.editbox(AuxPostParameters) + local editbox = Aux.gui.editbox(m.frame.parameters) editbox:SetPoint('TOPRIGHT', -65, -66) editbox:SetJustifyH('RIGHT') editbox:SetWidth(150) @@ -263,7 +290,7 @@ Aux.post_tab.FRAMES(function(m, public, private) private.unit_start_price = editbox end do - local editbox = Aux.gui.editbox(AuxPostParameters) + local editbox = Aux.gui.editbox(m.frame.parameters) editbox:SetPoint('TOPRIGHT', m.unit_start_price, 'BOTTOMRIGHT', 0, -18) editbox:SetJustifyH('RIGHT') editbox:SetWidth(150) @@ -307,7 +334,7 @@ Aux.post_tab.FRAMES(function(m, public, private) private.unit_buyout_price = editbox end do - local btn = Aux.gui.button(AuxPostParameters, 16) + local btn = Aux.gui.button(m.frame.parameters, 16) btn:SetPoint('TOPRIGHT', -15, -143) btn:SetWidth(150) btn:SetHeight(20) diff --git a/tabs/search/core.lua b/tabs/search/core.lua index 8549e6c..42a3ac3 100644 --- a/tabs/search/core.lua +++ b/tabs/search/core.lua @@ -524,7 +524,7 @@ do ) end - function public.on_update() + function private.on_update() if state == IDLE or state == SEARCHING then m.buyout_button:Disable() m.bid_button:Disable() diff --git a/tabs/search/frames.lua b/tabs/search/frames.lua index 65761ff..52cb835 100644 --- a/tabs/search/frames.lua +++ b/tabs/search/frames.lua @@ -2,6 +2,7 @@ Aux.search_tab.FRAMES(function(m, public, private) private.frame = CreateFrame('Frame', nil, AuxFrame) m.frame:SetAllPoints() m.frame:SetScript('OnUpdate', m.on_update) + m.frame:Hide() m.frame.filter = CreateFrame('Frame', nil, m.frame, 'AuxFrameBoxTemplate') m.frame.filter:SetAllPoints(AuxFrameContent)