module refactoring
This commit is contained in:
+1
-3
@@ -2,8 +2,6 @@ library 'green_t'
|
||||
|
||||
local next, getn, setn, tremove, type, setmetatable = next, getn, table.setn, tremove, type, setmetatable
|
||||
|
||||
-- TODO recursive releasing with specified depth, maybe allow setting "release structure" on creation for easier releasing, mandatory operation table mandate + comply/fulfill functions to ensure something is being released?
|
||||
|
||||
local wipe, acquire, release, set_auto_release
|
||||
do
|
||||
local pool, pool_size, overflow_pool, auto_release = {}, 0, setmetatable({}, { __mode='k' }), {}
|
||||
@@ -33,7 +31,6 @@ do
|
||||
end
|
||||
return {}
|
||||
end
|
||||
public.acquire = acquire
|
||||
|
||||
function release(t)
|
||||
wipe(t)
|
||||
@@ -55,6 +52,7 @@ do
|
||||
end
|
||||
|
||||
public.get_t = acquire
|
||||
|
||||
function public.get_tt()
|
||||
local t = acquire()
|
||||
set_auto_release(t, true)
|
||||
|
||||
+13
-17
@@ -81,21 +81,21 @@ function USE_ITEM(item_info)
|
||||
end
|
||||
|
||||
function get_unit_start_price()
|
||||
local money_text = unit_start_price:GetText()
|
||||
local money_text = unit_start_price_input:GetText()
|
||||
return money.from_string(money_text) or 0
|
||||
end
|
||||
|
||||
function set_unit_start_price(amount)
|
||||
unit_start_price:SetText(money.to_string(amount, true, nil, 3, nil, true))
|
||||
unit_start_price_input:SetText(money.to_string(amount, true, nil, 3, nil, true))
|
||||
end
|
||||
|
||||
function get_unit_buyout_price()
|
||||
local money_text = unit_buyout_price:GetText()
|
||||
local money_text = unit_buyout_price_input:GetText()
|
||||
return money.from_string(money_text) or 0
|
||||
end
|
||||
|
||||
function set_unit_buyout_price(amount)
|
||||
unit_buyout_price:SetText(money.to_string(amount, true, nil, 3, nil, true))
|
||||
unit_buyout_price_input:SetText(money.to_string(amount, true, nil, 3, nil, true))
|
||||
end
|
||||
|
||||
function update_inventory_listing()
|
||||
@@ -182,7 +182,7 @@ end
|
||||
function public.select_item(item_key)
|
||||
for _, inventory_record in filter(copy(inventory_records), function(record) return record.aux_quantity > 0 end) do
|
||||
if inventory_record.key == item_key then
|
||||
set_item(inventory_record)
|
||||
update_item(inventory_record)
|
||||
return
|
||||
end
|
||||
end
|
||||
@@ -240,7 +240,7 @@ function post_auctions()
|
||||
selected_item = nil
|
||||
for _, record in inventory_records do
|
||||
if record.key == key then
|
||||
set_item(record)
|
||||
update_item(record)
|
||||
break
|
||||
end
|
||||
end
|
||||
@@ -279,21 +279,17 @@ function update_item_configuration()
|
||||
item.name:SetTextColor(color.label.enabled())
|
||||
item.name:SetText'No item selected'
|
||||
|
||||
unit_start_price:Hide()
|
||||
unit_buyout_price:Hide()
|
||||
unit_start_price_input:Hide()
|
||||
unit_buyout_price_input:Hide()
|
||||
stack_size_slider:Hide()
|
||||
stack_count_slider:Hide()
|
||||
deposit:Hide()
|
||||
duration_dropdown:Hide()
|
||||
historical_value_button:Hide()
|
||||
hide_checkbox:Hide()
|
||||
|
||||
-- deposit:SetText('Deposit: ' .. money.to_string(0, nil, nil, nil, gui.inline_color.text.enabled))
|
||||
-- set_unit_start_price(0)
|
||||
-- set_unit_buyout_price(0)
|
||||
else
|
||||
unit_start_price:Show()
|
||||
unit_buyout_price:Show()
|
||||
unit_start_price_input:Show()
|
||||
unit_buyout_price_input:Show()
|
||||
stack_size_slider:Show()
|
||||
stack_count_slider:Show()
|
||||
deposit:Show()
|
||||
@@ -374,7 +370,7 @@ function update_historical_value_button()
|
||||
end
|
||||
end
|
||||
|
||||
function set_item(item)
|
||||
function update_item(item)
|
||||
local settings = read_settings(item.key)
|
||||
|
||||
item.unit_vendor_price = unit_vendor_price(item.key)
|
||||
@@ -398,8 +394,8 @@ function set_item(item)
|
||||
stack_size_slider:SetValue(settings.stack_size)
|
||||
quantity_update(true)
|
||||
|
||||
unit_start_price:SetText(money.to_string(settings.start_price, true, nil, 3, nil, true))
|
||||
unit_buyout_price:SetText(money.to_string(settings.buyout_price, true, nil, 3, nil, true))
|
||||
unit_start_price_input:SetText(money.to_string(settings.start_price, true, nil, 3, nil, true))
|
||||
unit_buyout_price_input:SetText(money.to_string(settings.buyout_price, true, nil, 3, nil, true))
|
||||
|
||||
if not existing_auctions[selected_item.key] then
|
||||
refresh_entries()
|
||||
|
||||
+12
-12
@@ -50,7 +50,7 @@ inventory_listing = item_listing.create(
|
||||
frame.inventory,
|
||||
function()
|
||||
if arg1 == 'LeftButton' then
|
||||
set_item(this.item_record)
|
||||
update_item(this.item_record)
|
||||
elseif arg1 == 'RightButton' then
|
||||
tab = 1
|
||||
search_tab.set_filter(strlower(info.item(this.item_record.item_id).name) .. '/exact')
|
||||
@@ -139,11 +139,11 @@ do
|
||||
end
|
||||
slider.editbox:SetScript('OnTabPressed', function()
|
||||
if IsShiftKeyDown() then
|
||||
unit_buyout_price:SetFocus()
|
||||
unit_buyout_price_input:SetFocus()
|
||||
elseif stack_count_slider.editbox:IsVisible() then
|
||||
stack_count_slider.editbox:SetFocus()
|
||||
else
|
||||
unit_start_price:SetFocus()
|
||||
unit_start_price_input:SetFocus()
|
||||
end
|
||||
end)
|
||||
slider.editbox:SetNumeric(true)
|
||||
@@ -167,7 +167,7 @@ do
|
||||
if IsShiftKeyDown() then
|
||||
stack_size_slider.editbox:SetFocus()
|
||||
else
|
||||
unit_start_price:SetFocus()
|
||||
unit_start_price_input:SetFocus()
|
||||
end
|
||||
end)
|
||||
slider.editbox:SetNumeric(true)
|
||||
@@ -218,7 +218,7 @@ do
|
||||
if IsShiftKeyDown() then
|
||||
stack_count_slider.editbox:SetFocus()
|
||||
else
|
||||
unit_buyout_price:SetFocus()
|
||||
unit_buyout_price_input:SetFocus()
|
||||
end
|
||||
end)
|
||||
editbox.formatter = function() return money.to_string(get_unit_start_price(), true, nil, 3) end
|
||||
@@ -239,19 +239,19 @@ do
|
||||
label:SetJustifyH('CENTER')
|
||||
start_price_percentage = label
|
||||
end
|
||||
unit_start_price = editbox
|
||||
unit_start_price_input = editbox
|
||||
end
|
||||
do
|
||||
local editbox = gui.editbox(frame.parameters)
|
||||
editbox.name = 'buy'
|
||||
editbox:SetPoint('TOPRIGHT', unit_start_price, 'BOTTOMRIGHT', 0, -19)
|
||||
editbox:SetPoint('TOPRIGHT', unit_start_price_input, '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()
|
||||
unit_start_price_input:SetFocus()
|
||||
else
|
||||
stack_size_slider.editbox:SetFocus()
|
||||
end
|
||||
@@ -265,16 +265,16 @@ do
|
||||
do
|
||||
local label = gui.label(editbox, gui.font_size.small)
|
||||
label:SetPoint('BOTTOMLEFT', editbox, 'TOPLEFT', -2, 1)
|
||||
label:SetText('Unit Buyout Price')
|
||||
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')
|
||||
label:SetJustifyH'CENTER'
|
||||
buyout_price_percentage = label
|
||||
end
|
||||
unit_buyout_price = editbox
|
||||
unit_buyout_price_input = editbox
|
||||
end
|
||||
do
|
||||
local btn = gui.button(frame.parameters, 14)
|
||||
@@ -290,6 +290,6 @@ do
|
||||
end)
|
||||
local label = gui.label(btn, gui.font_size.small)
|
||||
label:SetPoint('BOTTOMLEFT', btn, 'TOPLEFT', -2, 1)
|
||||
label:SetText('Historical Value')
|
||||
label:SetText'Historical Value'
|
||||
historical_value_button = btn
|
||||
end
|
||||
Reference in New Issue
Block a user