module refactoring
This commit is contained in:
+23
-23
@@ -20,19 +20,19 @@ do
|
||||
end
|
||||
end
|
||||
|
||||
function read_settings(item_key)
|
||||
function private.read_settings(item_key)
|
||||
item_key = item_key or selected_item.key
|
||||
return data[item_key] and persistence.read(settings_schema, data[item_key]) or default_settings
|
||||
end
|
||||
|
||||
function write_settings(settings, item_key)
|
||||
function private.write_settings(settings, item_key)
|
||||
item_key = item_key or selected_item.key
|
||||
data[item_key] = persistence.write(settings_schema, settings)
|
||||
end
|
||||
|
||||
local scan_id, inventory_records, existing_auctions = 0, t, t
|
||||
|
||||
function refresh_button_click()
|
||||
function private.refresh_button_click()
|
||||
aux.scan.abort(scan_id)
|
||||
refresh_entries()
|
||||
refresh = true
|
||||
@@ -69,25 +69,25 @@ function USE_ITEM(item_info)
|
||||
select_item(item_info.item_key)
|
||||
end
|
||||
|
||||
function get_unit_start_price()
|
||||
function private.get_unit_start_price()
|
||||
local money_text = unit_start_price:GetText()
|
||||
return aux.money.from_string(money_text) or 0
|
||||
end
|
||||
|
||||
function set_unit_start_price(amount)
|
||||
function private.set_unit_start_price(amount)
|
||||
unit_start_price:SetText(aux.money.to_string(amount, true, nil, 3, nil, true))
|
||||
end
|
||||
|
||||
function get_unit_buyout_price()
|
||||
function private.get_unit_buyout_price()
|
||||
local money_text = unit_buyout_price:GetText()
|
||||
return aux.money.from_string(money_text) or 0
|
||||
end
|
||||
|
||||
function set_unit_buyout_price(amount)
|
||||
function private.set_unit_buyout_price(amount)
|
||||
unit_buyout_price:SetText(aux.money.to_string(amount, true, nil, 3, nil, true))
|
||||
end
|
||||
|
||||
function update_inventory_listing()
|
||||
function private.update_inventory_listing()
|
||||
if not ACTIVE then return end
|
||||
item_listing.populate(inventory_listing, values(filter(copy(inventory_records), function(record)
|
||||
local settings = read_settings(record.key)
|
||||
@@ -95,7 +95,7 @@ function update_inventory_listing()
|
||||
end)))
|
||||
end
|
||||
|
||||
function update_auction_listing()
|
||||
function private.update_auction_listing()
|
||||
if not ACTIVE then return end
|
||||
local auction_rows = t
|
||||
if selected_item then
|
||||
@@ -177,7 +177,7 @@ function public.select_item(item_key)
|
||||
end
|
||||
end
|
||||
|
||||
function price_update()
|
||||
function private.price_update()
|
||||
if selected_item then
|
||||
local settings = read_settings()
|
||||
|
||||
@@ -195,7 +195,7 @@ function price_update()
|
||||
end
|
||||
end
|
||||
|
||||
function post_auctions()
|
||||
function private.post_auctions()
|
||||
if selected_item then
|
||||
local unit_start_price = get_unit_start_price()
|
||||
local unit_buyout_price = get_unit_buyout_price()
|
||||
@@ -239,7 +239,7 @@ function post_auctions()
|
||||
end
|
||||
end
|
||||
|
||||
function validate_parameters()
|
||||
function private.validate_parameters()
|
||||
if not selected_item then
|
||||
post_button:Disable()
|
||||
return
|
||||
@@ -259,7 +259,7 @@ function validate_parameters()
|
||||
post_button:Enable()
|
||||
end
|
||||
|
||||
function update_item_configuration()
|
||||
function private.update_item_configuration()
|
||||
if not selected_item then
|
||||
refresh_button:Disable()
|
||||
|
||||
@@ -314,7 +314,7 @@ function update_item_configuration()
|
||||
end
|
||||
end
|
||||
|
||||
function undercut(record, stack_size, stack)
|
||||
function private.undercut(record, stack_size, stack)
|
||||
local start_price = round(record.unit_blizzard_bid * (stack and record.stack_size or stack_size))
|
||||
local buyout_price = round(record.unit_buyout_price * (stack and record.stack_size or stack_size))
|
||||
if not record.own then
|
||||
@@ -324,7 +324,7 @@ function undercut(record, stack_size, stack)
|
||||
return start_price / stack_size, buyout_price / stack_size
|
||||
end
|
||||
|
||||
function quantity_update(max_count)
|
||||
function private.quantity_update(max_count)
|
||||
if selected_item then
|
||||
local max_stack_count = selected_item.max_charges and selected_item.availability[stack_size_slider:GetValue()] or floor(selected_item.availability[0] / stack_size_slider:GetValue())
|
||||
stack_count_slider:SetMinMaxValues(1, max_stack_count)
|
||||
@@ -335,7 +335,7 @@ function quantity_update(max_count)
|
||||
refresh = true
|
||||
end
|
||||
|
||||
function unit_vendor_price(item_key)
|
||||
function private.unit_vendor_price(item_key)
|
||||
for slot in info.inventory do auto[slot] = true
|
||||
local item_info = info.container_item(unpack(slot))
|
||||
if item_info and item_info.item_key == item_key then
|
||||
@@ -355,7 +355,7 @@ function unit_vendor_price(item_key)
|
||||
end
|
||||
end
|
||||
|
||||
function update_historical_value_button()
|
||||
function private.update_historical_value_button()
|
||||
if selected_item then
|
||||
local historical_value = history.value(selected_item.key)
|
||||
historical_value_button.amount = historical_value
|
||||
@@ -363,7 +363,7 @@ function update_historical_value_button()
|
||||
end
|
||||
end
|
||||
|
||||
function set_item(item)
|
||||
function private.set_item(item)
|
||||
local settings = read_settings(item.key)
|
||||
|
||||
item.unit_vendor_price = unit_vendor_price(item.key)
|
||||
@@ -398,7 +398,7 @@ function set_item(item)
|
||||
refresh = true
|
||||
end
|
||||
|
||||
function update_inventory_records()
|
||||
function private.update_inventory_records()
|
||||
local auctionable_map = tt
|
||||
for slot in info.inventory do auto[slot] = true
|
||||
for item_info in present(info.container_item(unpack(slot))) do
|
||||
@@ -436,7 +436,7 @@ function update_inventory_records()
|
||||
refresh = true
|
||||
end
|
||||
|
||||
function refresh_entries()
|
||||
function private.refresh_entries()
|
||||
if selected_item then
|
||||
local item_id, suffix_id = selected_item.item_id, selected_item.suffix_id
|
||||
local item_key = item_id .. ':' .. suffix_id
|
||||
@@ -481,7 +481,7 @@ function refresh_entries()
|
||||
end
|
||||
end
|
||||
|
||||
function record_auction(key, aux_quantity, unit_blizzard_bid, unit_buyout_price, duration, owner)
|
||||
function private.record_auction(key, aux_quantity, unit_blizzard_bid, unit_buyout_price, duration, owner)
|
||||
existing_auctions[key] = existing_auctions[key] or t
|
||||
local entry
|
||||
for _, record in existing_auctions[key] do
|
||||
@@ -497,7 +497,7 @@ function record_auction(key, aux_quantity, unit_blizzard_bid, unit_buyout_price,
|
||||
return entry
|
||||
end
|
||||
|
||||
function on_update()
|
||||
function private.on_update()
|
||||
if refresh then
|
||||
refresh = false
|
||||
price_update()
|
||||
@@ -509,7 +509,7 @@ function on_update()
|
||||
validate_parameters()
|
||||
end
|
||||
|
||||
function initialize_duration_dropdown()
|
||||
function private.initialize_duration_dropdown()
|
||||
local function on_click()
|
||||
UIDropDownMenu_SetSelectedValue(duration_dropdown, this.value)
|
||||
local settings = read_settings()
|
||||
|
||||
+26
-26
@@ -1,7 +1,7 @@
|
||||
aux 'post_tab' local gui, listing, item_listing, money, search_tab = aux.gui, aux.listing, aux.item_listing, aux.money, aux.search_tab
|
||||
|
||||
function create_frames()
|
||||
frame = CreateFrame('Frame', nil, aux_frame)
|
||||
function private.create_frames()
|
||||
private.frame = CreateFrame('Frame', nil, aux_frame)
|
||||
frame:SetAllPoints()
|
||||
frame:SetScript('OnUpdate', on_update)
|
||||
frame:Hide()
|
||||
@@ -35,12 +35,12 @@ function create_frames()
|
||||
local label = gui.label(checkbox, gui.font_size.small)
|
||||
label:SetPoint('LEFT', checkbox, 'RIGHT', 4, 1)
|
||||
label:SetText('Show hidden items')
|
||||
show_hidden_checkbox = checkbox
|
||||
private.show_hidden_checkbox = checkbox
|
||||
end
|
||||
|
||||
gui.horizontal_line(frame.inventory, -48)
|
||||
|
||||
inventory_listing = item_listing.create(
|
||||
private.inventory_listing = item_listing.create(
|
||||
frame.inventory,
|
||||
function()
|
||||
if arg1 == 'LeftButton' then
|
||||
@@ -56,15 +56,15 @@ function create_frames()
|
||||
end
|
||||
)
|
||||
|
||||
auction_listing = listing.CreateScrollingTable(frame.auctions)
|
||||
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'}
|
||||
{ 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)
|
||||
@@ -81,7 +81,7 @@ function create_frames()
|
||||
end)
|
||||
|
||||
do
|
||||
status_bar = gui.status_bar(frame)
|
||||
private.status_bar = gui.status_bar(frame)
|
||||
status_bar:SetWidth(265)
|
||||
status_bar:SetHeight(25)
|
||||
status_bar:SetPoint('TOPLEFT', aux_frame.content, 'BOTTOMLEFT', 0, -6)
|
||||
@@ -93,17 +93,17 @@ function create_frames()
|
||||
btn:SetPoint('TOPLEFT', status_bar, 'TOPRIGHT', 5, 0)
|
||||
btn:SetText('Post')
|
||||
btn:SetScript('OnClick', post_auctions)
|
||||
post_button = btn
|
||||
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)
|
||||
refresh_button = btn
|
||||
private.refresh_button = btn
|
||||
end
|
||||
do
|
||||
item = gui.item(frame.parameters)
|
||||
private.item = gui.item(frame.parameters)
|
||||
item:SetPoint('TOPLEFT', 10, -6)
|
||||
item.button:SetScript('OnEnter', function()
|
||||
if selected_item then
|
||||
@@ -143,7 +143,7 @@ function create_frames()
|
||||
slider.editbox:SetNumeric(true)
|
||||
slider.editbox:SetMaxLetters(3)
|
||||
slider.label:SetText('Stack Size')
|
||||
stack_size_slider = slider
|
||||
private.stack_size_slider = slider
|
||||
end
|
||||
do
|
||||
local slider = gui.slider(frame.parameters)
|
||||
@@ -166,7 +166,7 @@ function create_frames()
|
||||
end)
|
||||
slider.editbox:SetNumeric(true)
|
||||
slider.label:SetText('Stack Count')
|
||||
stack_count_slider = slider
|
||||
private.stack_count_slider = slider
|
||||
end
|
||||
do
|
||||
local dropdown = gui.dropdown(frame.parameters)
|
||||
@@ -179,12 +179,12 @@ function create_frames()
|
||||
dropdown:SetScript('OnShow', function()
|
||||
UIDropDownMenu_Initialize(this, initialize_duration_dropdown)
|
||||
end)
|
||||
duration_dropdown = dropdown
|
||||
private.duration_dropdown = dropdown
|
||||
end
|
||||
do
|
||||
local label = gui.label(frame.parameters, gui.font_size.medium)
|
||||
label:SetPoint('LEFT', duration_dropdown, 'RIGHT', 25, 0)
|
||||
deposit = label
|
||||
private.deposit = label
|
||||
end
|
||||
do
|
||||
local checkbox = gui.checkbox(frame.parameters)
|
||||
@@ -198,7 +198,7 @@ function create_frames()
|
||||
local label = gui.label(checkbox, gui.font_size.small)
|
||||
label:SetPoint('LEFT', checkbox, 'RIGHT', 4, 1)
|
||||
label:SetText('Hide this item')
|
||||
hide_checkbox = checkbox
|
||||
private.hide_checkbox = checkbox
|
||||
end
|
||||
do
|
||||
local editbox = gui.editbox(frame.parameters)
|
||||
@@ -231,9 +231,9 @@ function create_frames()
|
||||
label:SetPoint('LEFT', editbox, 'RIGHT', 8, 0)
|
||||
label:SetWidth(50)
|
||||
label:SetJustifyH('CENTER')
|
||||
start_price_percentage = label
|
||||
private.start_price_percentage = label
|
||||
end
|
||||
unit_start_price = editbox
|
||||
private.unit_start_price = editbox
|
||||
end
|
||||
do
|
||||
local editbox = gui.editbox(frame.parameters)
|
||||
@@ -266,9 +266,9 @@ function create_frames()
|
||||
label:SetPoint('LEFT', editbox, 'RIGHT', 8, 0)
|
||||
label:SetWidth(50)
|
||||
label:SetJustifyH('CENTER')
|
||||
buyout_price_percentage = label
|
||||
private.buyout_price_percentage = label
|
||||
end
|
||||
unit_buyout_price = editbox
|
||||
private.unit_buyout_price = editbox
|
||||
end
|
||||
do
|
||||
local btn = gui.button(frame.parameters, 14)
|
||||
@@ -285,6 +285,6 @@ function create_frames()
|
||||
local label = gui.label(btn, gui.font_size.small)
|
||||
label:SetPoint('BOTTOMLEFT', btn, 'TOPLEFT', -2, 1)
|
||||
label:SetText('Historical Value')
|
||||
historical_value_button = btn
|
||||
private.historical_value_button = btn
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user