diff --git a/frame.lua b/frame.lua index a4c1676..fbaf3fa 100644 --- a/frame.lua +++ b/frame.lua @@ -2,6 +2,12 @@ module 'aux' local gui = require 'aux.gui' +function LOAD() + for _, info in tab_info do + tabs:create_tab(info.name) + end +end + do local frame = CreateFrame('Frame', 'AuxFrame', UIParent) tinsert(UISpecialFrames, 'AuxFrame') @@ -44,7 +50,4 @@ do btn:SetScript('OnClick',function() if AuctionFrame:IsVisible() then HideUIPanel(AuctionFrame) else ShowUIPanel(AuctionFrame) end end) -end -for _, info in tab_info do - tabs:create_tab(info.name) end \ No newline at end of file diff --git a/gui/auction_listing.lua b/gui/auction_listing.lua index 8025a3e..1730b71 100644 --- a/gui/auction_listing.lua +++ b/gui/auction_listing.lua @@ -643,7 +643,7 @@ local methods = { elseif IsShiftKeyDown() and ChatFrameEditBox:IsVisible() then ChatFrameEditBox:Insert(this.row.data.record.link) elseif not modified and button == 'RightButton' then -- TODO not when alt (how?) - aux.tab = 1 + tab = 1 search_tab.set_filter(strlower(info.item(this.row.data.record.item_id).name) .. '/exact') search_tab.execute(nil, false) else diff --git a/libs/module.lua b/libs/module.lua index 9ee9335..31cc59b 100644 --- a/libs/module.lua +++ b/libs/module.lua @@ -49,6 +49,7 @@ function include(self, name) end function create_module(name) + if type(name) ~= 'string' then error('Invalid module name "%s".', name) end local P, environment, interface, definition_helper, modifiers, accessors, mutators, fields, public_accessors, public_mutators, public_fields environment, interface, definition_helper = {}, {}, setmetatable({}, definition_helper_mt) accessors = { private=function() _access[definition_helper] = PRIVATE; return definition_helper end, public=function() _access[definition_helper] = PUBLIC; return definition_helper end } diff --git a/tabs/auctions/core.lua b/tabs/auctions/core.lua index b386d68..84ae5f3 100644 --- a/tabs/auctions/core.lua +++ b/tabs/auctions/core.lua @@ -6,16 +6,11 @@ include 'aux' local info = require 'aux.util.info' local scan_util = require 'aux.util.scan' local scan = require 'aux.core.scan' -local tab_frame = require 'aux.tabs.auctions.frame' TAB 'Auctions' private.auction_records = t -function LOAD() - tab_frame.create() -end - function OPEN() frame:Show() scan_auctions() diff --git a/tabs/auctions/frame.lua b/tabs/auctions/frame.lua index 869b541..79351c9 100644 --- a/tabs/auctions/frame.lua +++ b/tabs/auctions/frame.lua @@ -1,54 +1,51 @@ -module 'aux.tabs.auctions.frame' +module 'aux.tabs.auctions' local gui = require 'aux.gui' local auction_listing = require 'aux.gui.auction_listing' -function public.create() - setfenv(1, getfenv(2)) - private.frame = CreateFrame('Frame', nil, AuxFrame) - frame:SetAllPoints() - frame:SetScript('OnUpdate', on_update) - frame:Hide() +private.frame = CreateFrame('Frame', nil, AuxFrame) +frame:SetAllPoints() +frame:SetScript('OnUpdate', on_update) +frame:Hide() - frame.listing = gui.panel(frame) - frame.listing:SetPoint('TOP', frame, 'TOP', 0, -8) - frame.listing:SetPoint('BOTTOMLEFT', AuxFrame.content, 'BOTTOMLEFT', 0, 0) - frame.listing:SetPoint('BOTTOMRIGHT', AuxFrame.content, 'BOTTOMRIGHT', 0, 0) +frame.listing = gui.panel(frame) +frame.listing:SetPoint('TOP', frame, 'TOP', 0, -8) +frame.listing:SetPoint('BOTTOMLEFT', AuxFrame.content, 'BOTTOMLEFT', 0, 0) +frame.listing:SetPoint('BOTTOMRIGHT', AuxFrame.content, 'BOTTOMRIGHT', 0, 0) - private.listing = auction_listing.CreateAuctionResultsTable(frame.listing, auction_listing.auctions_config) - listing:SetSort(1, 2, 3, 4, 5, 6, 7, 8) - listing:Reset() - listing:SetHandler('OnCellClick', function(cell, button) - if IsAltKeyDown() and listing:GetSelection().record == cell.row.data.record and cancel_button:IsEnabled() then - cancel_button:Click() - end - end) - listing:SetHandler('OnSelectionChanged', function(rt, datum) - if not datum then return end - find_auction(datum.record) - end) +private.listing = auction_listing.CreateAuctionResultsTable(frame.listing, auction_listing.auctions_config) +listing:SetSort(1, 2, 3, 4, 5, 6, 7, 8) +listing:Reset() +listing:SetHandler('OnCellClick', function(cell, button) + if IsAltKeyDown() and listing:GetSelection().record == cell.row.data.record and cancel_button:IsEnabled() then + cancel_button:Click() + end +end) +listing:SetHandler('OnSelectionChanged', function(rt, datum) + if not datum then return end + find_auction(datum.record) +end) - do - private.status_bar = gui.status_bar(frame) - status_bar:SetWidth(265) - status_bar:SetHeight(25) - status_bar:SetPoint('TOPLEFT', AuxFrame.content, 'BOTTOMLEFT', 0, -6) - status_bar:update_status(100, 100) - status_bar:set_text'' - end - do - local btn = gui.button(frame) - btn:SetPoint('TOPLEFT', status_bar, 'TOPRIGHT', 5, 0) - btn:SetText'Cancel' - btn:Disable() - private.cancel_button = btn - end - do - local btn = gui.button(frame) - btn:SetPoint('TOPLEFT', cancel_button, 'TOPRIGHT', 5, 0) - btn:SetText'Refresh' - btn:SetScript('OnClick', function() - scan_auctions() - end) - end +do + private.status_bar = gui.status_bar(frame) + status_bar:SetWidth(265) + status_bar:SetHeight(25) + status_bar:SetPoint('TOPLEFT', AuxFrame.content, 'BOTTOMLEFT', 0, -6) + status_bar:update_status(100, 100) + status_bar:set_text'' +end +do + local btn = gui.button(frame) + btn:SetPoint('TOPLEFT', status_bar, 'TOPRIGHT', 5, 0) + btn:SetText'Cancel' + btn:Disable() + private.cancel_button = btn +end +do + local btn = gui.button(frame) + btn:SetPoint('TOPLEFT', cancel_button, 'TOPRIGHT', 5, 0) + btn:SetText'Refresh' + btn:SetScript('OnClick', function() + scan_auctions() + end) end \ No newline at end of file diff --git a/tabs/bids/core.lua b/tabs/bids/core.lua index b1e44cf..45d1c86 100644 --- a/tabs/bids/core.lua +++ b/tabs/bids/core.lua @@ -6,16 +6,11 @@ include 'aux' local info = require 'aux.util.info' local scan_util = require 'aux.util.scan' local scan = require 'aux.core.scan' -local tab_frame = require 'aux.tabs.bids.frame' TAB 'Bids' private.auction_records = t -function LOAD() - tab_frame.create() -end - function OPEN() frame:Show() scan_bids() @@ -33,7 +28,7 @@ end function public.scan_bids() status_bar:update_status(0,0) - status_bar:set_text('Scanning auctions...') + status_bar:set_text'Scanning auctions...' wipe(auction_records) update_listing() @@ -49,12 +44,12 @@ function public.scan_bids() end, on_complete = function() status_bar:update_status(100, 100) - status_bar:set_text('Scan complete') + status_bar:set_text'Scan complete' update_listing() end, on_abort = function() status_bar:update_status(100, 100) - status_bar:set_text('Scan aborted') + status_bar:set_text'Scan aborted' end, } end diff --git a/tabs/bids/frame.lua b/tabs/bids/frame.lua index f7e65ae..25a2568 100644 --- a/tabs/bids/frame.lua +++ b/tabs/bids/frame.lua @@ -1,65 +1,62 @@ -module 'aux.tabs.bids.frame' +module 'aux.tabs.bids' local gui = require 'aux.gui' local auction_listing = require 'aux.gui.auction_listing' -function public.create() - setfenv(1, getfenv(2)) - private.frame = CreateFrame('Frame', nil, AuxFrame) - frame:SetAllPoints() - frame:SetScript('OnUpdate', on_update) - frame:Hide() +private.frame = CreateFrame('Frame', nil, AuxFrame) +frame:SetAllPoints() +frame:SetScript('OnUpdate', on_update) +frame:Hide() - frame.listing = gui.panel(frame) - frame.listing:SetPoint('TOP', frame, 'TOP', 0, -8) - frame.listing:SetPoint('BOTTOMLEFT', AuxFrame.content, 'BOTTOMLEFT', 0, 0) - frame.listing:SetPoint('BOTTOMRIGHT', AuxFrame.content, 'BOTTOMRIGHT', 0, 0) +frame.listing = gui.panel(frame) +frame.listing:SetPoint('TOP', frame, 'TOP', 0, -8) +frame.listing:SetPoint('BOTTOMLEFT', AuxFrame.content, 'BOTTOMLEFT', 0, 0) +frame.listing:SetPoint('BOTTOMRIGHT', AuxFrame.content, 'BOTTOMRIGHT', 0, 0) - private.listing = auction_listing.CreateAuctionResultsTable(frame.listing, auction_listing.bids_config) - listing:SetSort(1, 2, 3, 4, 5, 6, 7, 8) - listing:Reset() - listing:SetHandler('OnCellClick', function(cell, button) - if IsAltKeyDown() and listing:GetSelection().record == cell.row.data.record then - if button == 'LeftButton' and buyout_button:IsEnabled() then - buyout_button:Click() - elseif button == 'RightButton' and bid_button:IsEnabled() then - bid_button:Click() - end - end - end) - listing:SetHandler('OnSelectionChanged', function(rt, datum) - if not datum then return end - find_auction(datum.record) - end) +private.listing = auction_listing.CreateAuctionResultsTable(frame.listing, auction_listing.bids_config) +listing:SetSort(1, 2, 3, 4, 5, 6, 7, 8) +listing:Reset() +listing:SetHandler('OnCellClick', function(cell, button) + if IsAltKeyDown() and listing:GetSelection().record == cell.row.data.record then + if button == 'LeftButton' and buyout_button:IsEnabled() then + buyout_button:Click() + elseif button == 'RightButton' and bid_button:IsEnabled() then + bid_button:Click() + end + end +end) +listing:SetHandler('OnSelectionChanged', function(rt, datum) + if not datum then return end + find_auction(datum.record) +end) - do - private.status_bar = gui.status_bar(frame) - status_bar:SetWidth(265) - status_bar:SetHeight(25) - status_bar:SetPoint('TOPLEFT', AuxFrame.content, 'BOTTOMLEFT', 0, -6) - status_bar:update_status(100, 0) - status_bar:set_text('') - end - do - local btn = gui.button(frame) - btn:SetPoint('TOPLEFT', status_bar, 'TOPRIGHT', 5, 0) - btn:SetText'Bid' - btn:Disable() - private.bid_button = btn - end - do - local btn = gui.button(frame) - btn:SetPoint('TOPLEFT', bid_button, 'TOPRIGHT', 5, 0) - btn:SetText'Buyout' - btn:Disable() - private.buyout_button = btn - end - do - local btn = gui.button(frame) - btn:SetPoint('TOPLEFT', buyout_button, 'TOPRIGHT', 5, 0) - btn:SetText'Refresh' - btn:SetScript('OnClick', function() - scan_bids() - end) - end +do + private.status_bar = gui.status_bar(frame) + status_bar:SetWidth(265) + status_bar:SetHeight(25) + status_bar:SetPoint('TOPLEFT', AuxFrame.content, 'BOTTOMLEFT', 0, -6) + status_bar:update_status(100, 0) + status_bar:set_text('') +end +do + local btn = gui.button(frame) + btn:SetPoint('TOPLEFT', status_bar, 'TOPRIGHT', 5, 0) + btn:SetText'Bid' + btn:Disable() + private.bid_button = btn +end +do + local btn = gui.button(frame) + btn:SetPoint('TOPLEFT', bid_button, 'TOPRIGHT', 5, 0) + btn:SetText'Buyout' + btn:Disable() + private.buyout_button = btn +end +do + local btn = gui.button(frame) + btn:SetPoint('TOPLEFT', buyout_button, 'TOPRIGHT', 5, 0) + btn:SetText'Refresh' + btn:SetScript('OnClick', function() + scan_bids() + end) end \ No newline at end of file diff --git a/tabs/post/core.lua b/tabs/post/core.lua index 07893f8..3acd094 100644 --- a/tabs/post/core.lua +++ b/tabs/post/core.lua @@ -13,7 +13,6 @@ local scan = require 'aux.core.scan' local history = require 'aux.core.history' local item_listing = require 'aux.gui.item_listing' local al = require 'aux.gui.auction_listing' -local tab_frame = require 'aux.tabs.post.frame' TAB 'Post' @@ -66,10 +65,6 @@ do function private.refresh.set(v) c = v end end -function LOAD() - tab_frame.create() -end - function OPEN() frame:Show() update_inventory_records() diff --git a/tabs/post/frame.lua b/tabs/post/frame.lua index dac6298..37320ce 100644 --- a/tabs/post/frame.lua +++ b/tabs/post/frame.lua @@ -1,4 +1,4 @@ -module'aux.tabs.post.frame' +module'aux.tabs.post' local info = require 'aux.util.info' local money = require 'aux.util.money' @@ -7,292 +7,289 @@ local listing = require 'aux.gui.listing' local item_listing = require 'aux.gui.item_listing' local search_tab = require 'aux.tabs.search' -function public.create() - setfenv(1, getfenv(2)) - private.frame = CreateFrame('Frame', nil, AuxFrame) - frame:SetAllPoints() - frame:SetScript('OnUpdate', on_update) - frame:Hide() +private.frame = CreateFrame('Frame', nil, AuxFrame) +frame:SetAllPoints() +frame:SetScript('OnUpdate', on_update) +frame:Hide() - frame.content = CreateFrame('Frame', nil, frame) - frame.content:SetPoint('TOP', frame, 'TOP', 0, -8) - frame.content:SetPoint('BOTTOMLEFT', AuxFrame.content, 'BOTTOMLEFT', 0, 0) - frame.content:SetPoint('BOTTOMRIGHT', AuxFrame.content, 'BOTTOMRIGHT', 0, 0) +frame.content = CreateFrame('Frame', nil, frame) +frame.content:SetPoint('TOP', frame, 'TOP', 0, -8) +frame.content:SetPoint('BOTTOMLEFT', AuxFrame.content, 'BOTTOMLEFT', 0, 0) +frame.content:SetPoint('BOTTOMRIGHT', AuxFrame.content, 'BOTTOMRIGHT', 0, 0) - frame.inventory = gui.panel(frame.content) - frame.inventory:SetWidth(212) - frame.inventory:SetPoint('TOPLEFT', 0, 0) - frame.inventory:SetPoint('BOTTOMLEFT', 0, 0) +frame.inventory = gui.panel(frame.content) +frame.inventory:SetWidth(212) +frame.inventory:SetPoint('TOPLEFT', 0, 0) +frame.inventory:SetPoint('BOTTOMLEFT', 0, 0) - frame.parameters = gui.panel(frame.content) - frame.parameters:SetHeight(173) - frame.parameters:SetPoint('TOPLEFT', frame.inventory, 'TOPRIGHT', 2.5, 0) - frame.parameters:SetPoint('TOPRIGHT', 0, 0) +frame.parameters = gui.panel(frame.content) +frame.parameters:SetHeight(173) +frame.parameters:SetPoint('TOPLEFT', frame.inventory, 'TOPRIGHT', 2.5, 0) +frame.parameters:SetPoint('TOPRIGHT', 0, 0) - frame.auctions = gui.panel(frame.content) - frame.auctions:SetHeight(228) - frame.auctions:SetPoint('BOTTOMLEFT', frame.inventory, 'BOTTOMRIGHT', 2.5, 0) - frame.auctions:SetPoint('BOTTOMRIGHT', 0, 0) +frame.auctions = gui.panel(frame.content) +frame.auctions:SetHeight(228) +frame.auctions:SetPoint('BOTTOMLEFT', frame.inventory, 'BOTTOMRIGHT', 2.5, 0) +frame.auctions:SetPoint('BOTTOMRIGHT', 0, 0) - do - local checkbox = gui.checkbox(frame.inventory) - checkbox:SetPoint('TOPLEFT', 49, -16) - checkbox:SetScript('OnClick', function() - refresh = true - end) - local label = gui.label(checkbox, gui.font_size.small) - label:SetPoint('LEFT', checkbox, 'RIGHT', 4, 1) - label:SetText('Show hidden items') - private.show_hidden_checkbox = checkbox - end +do + local checkbox = gui.checkbox(frame.inventory) + checkbox:SetPoint('TOPLEFT', 49, -16) + checkbox:SetScript('OnClick', function() + refresh = true + end) + local label = gui.label(checkbox, gui.font_size.small) + label:SetPoint('LEFT', checkbox, 'RIGHT', 4, 1) + label:SetText('Show hidden items') + private.show_hidden_checkbox = checkbox +end - gui.horizontal_line(frame.inventory, -48) +gui.horizontal_line(frame.inventory, -48) - private.inventory_listing = item_listing.create( - frame.inventory, - function() - if arg1 == 'LeftButton' then - set_item(this.item_record) - elseif arg1 == 'RightButton' then - aux.tab = 1 - search_tab.set_filter(strlower(info.item(this.item_record.item_id).name) .. '/exact') - search_tab.execute(nil, false) - end - end, - function(item_record) - return item_record == selected_item - end - ) +private.inventory_listing = item_listing.create( + frame.inventory, + function() + if arg1 == 'LeftButton' then + set_item(this.item_record) + elseif arg1 == 'RightButton' then + tab = 1 + search_tab.set_filter(strlower(info.item(this.item_record.item_id).name) .. '/exact') + search_tab.execute(nil, false) + end + end, + function(item_record) + return item_record == selected_item + end +) - private.auction_listing = listing.CreateScrollingTable(frame.auctions) - auction_listing:SetColInfo{ - { name='Auctions', width=.12, align='CENTER' }, - { name='Left', width=.1, align='CENTER' }, - { name='Qty', width=.08, align='CENTER' }, - { name='Bid/ea', width=.22, align='RIGHT' }, - { name='Bid Pct', width=.13, align='CENTER' }, - { name='Buy/ea', width=.22, align='RIGHT' }, - { name='Buy Pct', width=.13, align='CENTER' }, - } - auction_listing:EnableSorting(false) - auction_listing:DisableSelection(true) - auction_listing:SetHandler('OnClick', function(table, row_data, column, button) - local column_index = key(column, column.row.cols) - local unit_start_price, unit_buyout_price = undercut(row_data.record, stack_size_slider:GetValue(), button == 'RightButton') - if column_index == 3 then - stack_size_slider:SetValue(row_data.record.stack_size) - elseif column_index == 4 then - set_unit_start_price(unit_start_price) - elseif column_index == 6 then - set_unit_buyout_price(unit_buyout_price) - end - end) +private.auction_listing = listing.CreateScrollingTable(frame.auctions) +auction_listing:SetColInfo{ + { name='Auctions', width=.12, align='CENTER' }, + { name='Left', width=.1, align='CENTER' }, + { name='Qty', width=.08, align='CENTER' }, + { name='Bid/ea', width=.22, align='RIGHT' }, + { name='Bid Pct', width=.13, align='CENTER' }, + { name='Buy/ea', width=.22, align='RIGHT' }, + { name='Buy Pct', width=.13, align='CENTER' }, +} +auction_listing:EnableSorting(false) +auction_listing:DisableSelection(true) +auction_listing:SetHandler('OnClick', function(table, row_data, column, button) + local column_index = key(column, column.row.cols) + local unit_start_price, unit_buyout_price = undercut(row_data.record, stack_size_slider:GetValue(), button == 'RightButton') + if column_index == 3 then + stack_size_slider:SetValue(row_data.record.stack_size) + elseif column_index == 4 then + set_unit_start_price(unit_start_price) + elseif column_index == 6 then + set_unit_buyout_price(unit_buyout_price) + end +end) - do - private.status_bar = gui.status_bar(frame) - status_bar:SetWidth(265) - status_bar:SetHeight(25) - status_bar:SetPoint('TOPLEFT', AuxFrame.content, 'BOTTOMLEFT', 0, -6) - status_bar:update_status(100, 100) - status_bar:set_text('') - end - do - local btn = gui.button(frame.parameters) - btn:SetPoint('TOPLEFT', status_bar, 'TOPRIGHT', 5, 0) - btn:SetText('Post') - btn:SetScript('OnClick', post_auctions) - private.post_button = btn - end - do - local btn = gui.button(frame.parameters) - btn:SetPoint('TOPLEFT', post_button, 'TOPRIGHT', 5, 0) - btn:SetText('Refresh') - btn:SetScript('OnClick', refresh_button_click) - private.refresh_button = btn - end - do - private.item = gui.item(frame.parameters) - item:SetPoint('TOPLEFT', 10, -6) - item.button:SetScript('OnEnter', function() - if selected_item then - info.set_tooltip(selected_item.itemstring, this, 'ANCHOR_RIGHT') - end - end) - item.button:SetScript('OnLeave', function() - GameTooltip:Hide() - end) - end - do - local slider = gui.slider(frame.parameters) - slider:SetValueStep(1) - slider:SetPoint('TOPLEFT', 13, -73) - slider:SetWidth(190) - slider:SetScript('OnValueChanged', function() - quantity_update(true) - end) - slider.editbox.change = function() - slider:SetValue(this:GetNumber()) - quantity_update(true) - if selected_item then - local settings = read_settings() - settings.stack_size = this:GetNumber() - write_settings(settings) - end +do + private.status_bar = gui.status_bar(frame) + status_bar:SetWidth(265) + status_bar:SetHeight(25) + status_bar:SetPoint('TOPLEFT', AuxFrame.content, 'BOTTOMLEFT', 0, -6) + status_bar:update_status(100, 100) + status_bar:set_text('') +end +do + local btn = gui.button(frame.parameters) + btn:SetPoint('TOPLEFT', status_bar, 'TOPRIGHT', 5, 0) + btn:SetText('Post') + btn:SetScript('OnClick', post_auctions) + private.post_button = btn +end +do + local btn = gui.button(frame.parameters) + btn:SetPoint('TOPLEFT', post_button, 'TOPRIGHT', 5, 0) + btn:SetText('Refresh') + btn:SetScript('OnClick', refresh_button_click) + private.refresh_button = btn +end +do + private.item = gui.item(frame.parameters) + item:SetPoint('TOPLEFT', 10, -6) + item.button:SetScript('OnEnter', function() + if selected_item then + info.set_tooltip(selected_item.itemstring, this, 'ANCHOR_RIGHT') + end + end) + item.button:SetScript('OnLeave', function() + GameTooltip:Hide() + end) +end +do + local slider = gui.slider(frame.parameters) + slider:SetValueStep(1) + slider:SetPoint('TOPLEFT', 13, -73) + slider:SetWidth(190) + slider:SetScript('OnValueChanged', function() + quantity_update(true) + end) + slider.editbox.change = function() + slider:SetValue(this:GetNumber()) + quantity_update(true) + if selected_item then + local settings = read_settings() + settings.stack_size = this:GetNumber() + write_settings(settings) + end + end + slider.editbox:SetScript('OnTabPressed', function() + if IsShiftKeyDown() then + unit_buyout_price:SetFocus() + elseif stack_count_slider.editbox:IsVisible() then + stack_count_slider.editbox:SetFocus() + else + unit_start_price:SetFocus() + end + end) + slider.editbox:SetNumeric(true) + slider.editbox:SetMaxLetters(3) + slider.label:SetText('Stack Size') + private.stack_size_slider = slider +end +do + local slider = gui.slider(frame.parameters) + slider:SetValueStep(1) + slider:SetPoint('TOPLEFT', stack_size_slider, 'BOTTOMLEFT', 0, -32) + slider:SetWidth(190) + slider:SetScript('OnValueChanged', function() + quantity_update() + end) + slider.editbox.change = function() + slider:SetValue(this:GetNumber()) + quantity_update() + end + slider.editbox:SetScript('OnTabPressed', function() + if IsShiftKeyDown() then + stack_size_slider.editbox:SetFocus() + else + unit_start_price:SetFocus() + end + end) + slider.editbox:SetNumeric(true) + slider.label:SetText('Stack Count') + private.stack_count_slider = slider +end +do + local dropdown = gui.dropdown(frame.parameters) + dropdown:SetPoint('TOPLEFT', stack_count_slider, 'BOTTOMLEFT', 0, -21) + dropdown:SetWidth(90) + local label = gui.label(dropdown, gui.font_size.small) + label:SetPoint('BOTTOMLEFT', dropdown, 'TOPLEFT', -2, -3) + label:SetText('Duration') + UIDropDownMenu_Initialize(dropdown, initialize_duration_dropdown) + dropdown:SetScript('OnShow', function() + UIDropDownMenu_Initialize(this, initialize_duration_dropdown) + end) + private.duration_dropdown = dropdown +end +do + local label = gui.label(frame.parameters, gui.font_size.medium) + label:SetPoint('LEFT', duration_dropdown, 'RIGHT', 25, 0) + private.deposit = label +end +do + local checkbox = gui.checkbox(frame.parameters) + checkbox:SetPoint('TOPRIGHT', -83, -6) + checkbox:SetScript('OnClick', function() + local settings = read_settings() + settings.hidden = this:GetChecked() + write_settings(settings) + refresh = true + end) + local label = gui.label(checkbox, gui.font_size.small) + label:SetPoint('LEFT', checkbox, 'RIGHT', 4, 1) + label:SetText('Hide this item') + private.hide_checkbox = checkbox +end +do + local editbox = gui.editbox(frame.parameters) + editbox.name = 'start' + editbox:SetPoint('TOPRIGHT', -71, -60) + editbox:SetWidth(180) + editbox:SetHeight(22) + editbox:SetAlignment('RIGHT') + editbox:SetFontSize(17) + editbox:SetScript('OnTabPressed', function() + if IsShiftKeyDown() then + stack_count_slider.editbox:SetFocus() + else + unit_buyout_price:SetFocus() end - slider.editbox:SetScript('OnTabPressed', function() - if IsShiftKeyDown() then - unit_buyout_price:SetFocus() - elseif stack_count_slider.editbox:IsVisible() then - stack_count_slider.editbox:SetFocus() - else - unit_start_price:SetFocus() - end - end) - slider.editbox:SetNumeric(true) - slider.editbox:SetMaxLetters(3) - slider.label:SetText('Stack Size') - private.stack_size_slider = slider - end - do - local slider = gui.slider(frame.parameters) - slider:SetValueStep(1) - slider:SetPoint('TOPLEFT', stack_size_slider, 'BOTTOMLEFT', 0, -32) - slider:SetWidth(190) - slider:SetScript('OnValueChanged', function() - quantity_update() - end) - slider.editbox.change = function() - slider:SetValue(this:GetNumber()) - quantity_update() - end - slider.editbox:SetScript('OnTabPressed', function() - if IsShiftKeyDown() then - stack_size_slider.editbox:SetFocus() - else - unit_start_price:SetFocus() - end - end) - slider.editbox:SetNumeric(true) - slider.label:SetText('Stack Count') - private.stack_count_slider = slider - end - do - local dropdown = gui.dropdown(frame.parameters) - dropdown:SetPoint('TOPLEFT', stack_count_slider, 'BOTTOMLEFT', 0, -21) - dropdown:SetWidth(90) - local label = gui.label(dropdown, gui.font_size.small) - label:SetPoint('BOTTOMLEFT', dropdown, 'TOPLEFT', -2, -3) - label:SetText('Duration') - UIDropDownMenu_Initialize(dropdown, initialize_duration_dropdown) - dropdown:SetScript('OnShow', function() - UIDropDownMenu_Initialize(this, initialize_duration_dropdown) - end) - private.duration_dropdown = dropdown - end - do - local label = gui.label(frame.parameters, gui.font_size.medium) - label:SetPoint('LEFT', duration_dropdown, 'RIGHT', 25, 0) - private.deposit = label - end - do - local checkbox = gui.checkbox(frame.parameters) - checkbox:SetPoint('TOPRIGHT', -83, -6) - checkbox:SetScript('OnClick', function() - local settings = read_settings() - settings.hidden = this:GetChecked() - write_settings(settings) - refresh = true - end) - local label = gui.label(checkbox, gui.font_size.small) - label:SetPoint('LEFT', checkbox, 'RIGHT', 4, 1) - label:SetText('Hide this item') - private.hide_checkbox = checkbox - end - do - local editbox = gui.editbox(frame.parameters) - editbox.name = 'start' - editbox:SetPoint('TOPRIGHT', -71, -60) - editbox:SetWidth(180) - editbox:SetHeight(22) - editbox:SetAlignment('RIGHT') - editbox:SetFontSize(17) - editbox:SetScript('OnTabPressed', function() - if IsShiftKeyDown() then - stack_count_slider.editbox:SetFocus() - else - unit_buyout_price:SetFocus() - end - end) - editbox.formatter = function() return money.to_string(get_unit_start_price(), true, nil, 3) end - editbox.change = function() refresh = true end - editbox.enter = function() this:ClearFocus() end - editbox.focus_loss = function() - this:SetText(money.to_string(get_unit_start_price(), true, nil, 3, nil, true)) - end - do - local label = gui.label(editbox, gui.font_size.small) - label:SetPoint('BOTTOMLEFT', editbox, 'TOPLEFT', -2, 1) - label:SetText('Unit Starting Price') - end - do - local label = gui.label(editbox, 14) - label:SetPoint('LEFT', editbox, 'RIGHT', 8, 0) - label:SetWidth(50) - label:SetJustifyH('CENTER') - private.start_price_percentage = label - end - private.unit_start_price = editbox - end - do - local editbox = gui.editbox(frame.parameters) - editbox.name = 'buy' - editbox:SetPoint('TOPRIGHT', unit_start_price, 'BOTTOMRIGHT', 0, -19) - editbox:SetWidth(180) - editbox:SetHeight(22) - editbox:SetAlignment('RIGHT') - editbox:SetFontSize(17) - editbox:SetScript('OnTabPressed', function() - if IsShiftKeyDown() then - unit_start_price:SetFocus() - else - stack_size_slider.editbox:SetFocus() - end - end) - editbox.formatter = function() return money.to_string(get_unit_buyout_price(), true, nil, 3) end - editbox.change = function() refresh = true end - editbox.enter = function() this:ClearFocus() end - editbox.focus_loss = function() - this:SetText(money.to_string(get_unit_buyout_price(), true, nil, 3, nil, true)) - end - do - local label = gui.label(editbox, gui.font_size.small) - label:SetPoint('BOTTOMLEFT', editbox, 'TOPLEFT', -2, 1) - label:SetText('Unit Buyout Price') - end - do - local label = gui.label(editbox, 14) - label:SetPoint('LEFT', editbox, 'RIGHT', 8, 0) - label:SetWidth(50) - label:SetJustifyH('CENTER') - private.buyout_price_percentage = label - end - private.unit_buyout_price = editbox - end - do - local btn = gui.button(frame.parameters, 14) - btn:SetPoint('TOPRIGHT', -10, -146) - gui.set_size(btn, 150, 20) - btn:GetFontString():SetJustifyH('RIGHT') - btn:GetFontString():SetPoint('RIGHT', -2, 0) - btn:SetScript('OnClick', function() - if this.amount then - set_unit_start_price(this.amount) - set_unit_buyout_price(this.amount) - end - end) - local label = gui.label(btn, gui.font_size.small) - label:SetPoint('BOTTOMLEFT', btn, 'TOPLEFT', -2, 1) - label:SetText('Historical Value') - private.historical_value_button = btn - end + end) + editbox.formatter = function() return money.to_string(get_unit_start_price(), true, nil, 3) end + editbox.change = function() refresh = true end + editbox.enter = function() this:ClearFocus() end + editbox.focus_loss = function() + this:SetText(money.to_string(get_unit_start_price(), true, nil, 3, nil, true)) + end + do + local label = gui.label(editbox, gui.font_size.small) + label:SetPoint('BOTTOMLEFT', editbox, 'TOPLEFT', -2, 1) + label:SetText('Unit Starting Price') + end + do + local label = gui.label(editbox, 14) + label:SetPoint('LEFT', editbox, 'RIGHT', 8, 0) + label:SetWidth(50) + label:SetJustifyH('CENTER') + private.start_price_percentage = label + end + private.unit_start_price = editbox +end +do + local editbox = gui.editbox(frame.parameters) + editbox.name = 'buy' + editbox:SetPoint('TOPRIGHT', unit_start_price, 'BOTTOMRIGHT', 0, -19) + editbox:SetWidth(180) + editbox:SetHeight(22) + editbox:SetAlignment('RIGHT') + editbox:SetFontSize(17) + editbox:SetScript('OnTabPressed', function() + if IsShiftKeyDown() then + unit_start_price:SetFocus() + else + stack_size_slider.editbox:SetFocus() + end + end) + editbox.formatter = function() return money.to_string(get_unit_buyout_price(), true, nil, 3) end + editbox.change = function() refresh = true end + editbox.enter = function() this:ClearFocus() end + editbox.focus_loss = function() + this:SetText(money.to_string(get_unit_buyout_price(), true, nil, 3, nil, true)) + end + do + local label = gui.label(editbox, gui.font_size.small) + label:SetPoint('BOTTOMLEFT', editbox, 'TOPLEFT', -2, 1) + label:SetText('Unit Buyout Price') + end + do + local label = gui.label(editbox, 14) + label:SetPoint('LEFT', editbox, 'RIGHT', 8, 0) + label:SetWidth(50) + label:SetJustifyH('CENTER') + private.buyout_price_percentage = label + end + private.unit_buyout_price = editbox +end +do + local btn = gui.button(frame.parameters, 14) + btn:SetPoint('TOPRIGHT', -10, -146) + gui.set_size(btn, 150, 20) + btn:GetFontString():SetJustifyH('RIGHT') + btn:GetFontString():SetPoint('RIGHT', -2, 0) + btn:SetScript('OnClick', function() + if this.amount then + set_unit_start_price(this.amount) + set_unit_buyout_price(this.amount) + end + end) + local label = gui.label(btn, gui.font_size.small) + label:SetPoint('BOTTOMLEFT', btn, 'TOPLEFT', -2, 1) + label:SetText('Historical Value') + private.historical_value_button = btn end \ No newline at end of file diff --git a/tabs/search/core.lua b/tabs/search/core.lua index 776bb49..2606a71 100644 --- a/tabs/search/core.lua +++ b/tabs/search/core.lua @@ -73,7 +73,7 @@ function private.subtab.set(tab) end end -function private.set_filter(filter_string) +function public.set_filter(filter_string) search_box:SetText(filter_string) end