refactoring

This commit is contained in:
Manuel Simon Hirsig
2016-07-15 20:40:27 +02:00
parent a9290f2885
commit 54eb2a67ef
15 changed files with 724 additions and 725 deletions
+56 -56
View File
@@ -1,18 +1,18 @@
function Aux.post_frame.create_frames(private, public)
Aux.post_frame.FRAMES(function(m, private, public)
Aux.gui.vertical_line(AuxPostFrameContent, 219)
AuxPostParametersItem:EnableMouse()
AuxPostParametersItem:SetScript('OnReceiveDrag', function()
local item_info = Aux.cursor_item()
if item_info then
public.select_item(item_info.item_key)
m.select_item(item_info.item_key)
end
ClearCursor()
end)
AuxPostParametersItem:SetScript('OnClick', function()
local item_info = Aux.cursor_item()
if item_info then
public.select_item(item_info.item_key)
m.select_item(item_info.item_key)
end
ClearCursor()
end)
@@ -22,8 +22,8 @@ function Aux.post_frame.create_frames(private, public)
highlight:SetTexture(1, .9, .9, .1)
AuxPostParametersItem:SetScript('OnEnter', function()
highlight:Show()
if private.selected_item then
Aux.info.set_tooltip(private.selected_item.itemstring, this, 'ANCHOR_RIGHT')
if m.selected_item then
Aux.info.set_tooltip(m.selected_item.itemstring, this, 'ANCHOR_RIGHT')
end
end)
AuxPostParametersItem:SetScript('OnLeave', function()
@@ -37,7 +37,7 @@ function Aux.post_frame.create_frames(private, public)
checkbox:SetHeight(22)
checkbox:SetPoint('TOPLEFT', 45, -15)
checkbox:SetScript('OnClick', function()
private.refresh = true
m.refresh = true
end)
local label = Aux.gui.label(checkbox, 13)
label:SetPoint('LEFT', checkbox, 'RIGHT', 2, 1)
@@ -51,7 +51,7 @@ function Aux.post_frame.create_frames(private, public)
AuxPostInventory,
function()
if arg1 == 'LeftButton' then
private.set_item(this.item_record)
m.set_item(this.item_record)
elseif arg1 == 'RightButton' then
Aux.tab_group:set_tab(1)
Aux.search_frame.set_filter(strlower(Aux.info.item(this.item_record.item_id).name)..'/exact')
@@ -66,12 +66,12 @@ function Aux.post_frame.create_frames(private, public)
GameTooltip:Hide()
end,
function(item_record)
return item_record == private.selected_item
return item_record == m.selected_item
end
)
private.auction_listing = Aux.listing.CreateScrollingTable(AuxPostAuctions)
private.auction_listing:SetColInfo({
m.auction_listing:SetColInfo({
{ name='Auctions', width=.12, align='CENTER' },
{ name='Left', width=.1, align='CENTER' },
{ name='Qty', width=.08, align='CENTER' },
@@ -80,17 +80,17 @@ function Aux.post_frame.create_frames(private, public)
{ name='Buy/ea', width=.23, align='RIGHT' },
{ name='Buy Pct', width=.12, align='CENTER' }
})
private.auction_listing:EnableSorting(false)
private.auction_listing:DisableSelection(true)
private.auction_listing:SetHandler('OnClick', function(table, row_data, column, button)
m.auction_listing:EnableSorting(false)
m.auction_listing:DisableSelection(true)
m.auction_listing:SetHandler('OnClick', function(table, row_data, column, button)
local column_index = Aux.util.index_of(column, column.row.cols)
local unit_start_price, unit_buyout_price = private.undercut(row_data.record, private.stack_size_slider:GetValue(), button == 'RightButton')
local unit_start_price, unit_buyout_price = m.undercut(row_data.record, m.stack_size_slider:GetValue(), button == 'RightButton')
if column_index == 3 then
private.stack_size_slider:SetValue(row_data.record.stack_size)
m.stack_size_slider:SetValue(row_data.record.stack_size)
elseif column_index == 4 then
private.set_unit_start_price(unit_start_price)
m.set_unit_start_price(unit_start_price)
elseif column_index == 6 then
private.set_unit_buyout_price(unit_buyout_price)
m.set_unit_buyout_price(unit_buyout_price)
end
end)
@@ -105,20 +105,20 @@ function Aux.post_frame.create_frames(private, public)
end
do
local btn = Aux.gui.button(AuxPostParameters, 16)
btn:SetPoint('TOPLEFT', private.status_bar, 'TOPRIGHT', 5, 0)
btn:SetPoint('TOPLEFT', m.status_bar, 'TOPRIGHT', 5, 0)
btn:SetWidth(80)
btn:SetHeight(24)
btn:SetText('Post')
btn:SetScript('OnClick', private.post_auctions)
btn:SetScript('OnClick', m.post_auctions)
private.post_button = btn
end
do
local btn = Aux.gui.button(AuxPostParameters, 16)
btn:SetPoint('TOPLEFT', private.post_button, 'TOPRIGHT', 5, 0)
btn:SetPoint('TOPLEFT', m.post_button, 'TOPRIGHT', 5, 0)
btn:SetWidth(80)
btn:SetHeight(24)
btn:SetText('Refresh')
btn:SetScript('OnClick', private.refresh)
-- btn:SetScript('OnClick', m.refresh) TODO
private.refresh_button = btn
end
do
@@ -127,24 +127,24 @@ function Aux.post_frame.create_frames(private, public)
slider:SetPoint('TOPLEFT', 16, -75)
slider:SetWidth(190)
slider:SetScript('OnValueChanged', function()
private.quantity_update(true)
m.quantity_update(true)
end)
slider.editbox:SetScript('OnTextChanged', function()
slider:SetValue(this:GetNumber())
private.quantity_update(true)
if private.selected_item then
local settings = private.read_settings()
m.quantity_update(true)
if m.selected_item then
local settings = m.read_settings()
settings.stack_size = this:GetNumber()
private.write_settings(settings)
m.write_settings(settings)
end
end)
slider.editbox:SetScript('OnTabPressed', function()
if IsShiftKeyDown() then
private.unit_buyout_price:SetFocus()
elseif private.stack_count_slider.editbox:IsVisible() then
private.stack_count_slider.editbox:SetFocus()
m.unit_buyout_price:SetFocus()
elseif m.stack_count_slider.editbox:IsVisible() then
m.stack_count_slider.editbox:SetFocus()
else
private.unit_start_price:SetFocus()
m.unit_start_price:SetFocus()
end
end)
slider.editbox:SetWidth(50)
@@ -157,20 +157,20 @@ function Aux.post_frame.create_frames(private, public)
do
local slider = Aux.gui.slider(AuxPostParameters)
slider:SetValueStep(1)
slider:SetPoint('TOPLEFT', private.stack_size_slider, 'BOTTOMLEFT', 0, -30)
slider:SetPoint('TOPLEFT', m.stack_size_slider, 'BOTTOMLEFT', 0, -30)
slider:SetWidth(190)
slider:SetScript('OnValueChanged', function()
private.quantity_update()
m.quantity_update()
end)
slider.editbox:SetScript('OnTextChanged', function()
slider:SetValue(this:GetNumber())
private.quantity_update()
m.quantity_update()
end)
slider.editbox:SetScript('OnTabPressed', function()
if IsShiftKeyDown() then
private.stack_size_slider.editbox:SetFocus()
m.stack_size_slider.editbox:SetFocus()
else
private.unit_start_price:SetFocus()
m.unit_start_price:SetFocus()
end
end)
slider.editbox:SetWidth(50)
@@ -181,15 +181,15 @@ function Aux.post_frame.create_frames(private, public)
end
do
local dropdown = Aux.gui.dropdown(AuxPostParameters)
dropdown:SetPoint('TOPLEFT', private.stack_count_slider, 'BOTTOMLEFT', 0, -19)
dropdown:SetPoint('TOPLEFT', m.stack_count_slider, 'BOTTOMLEFT', 0, -19)
dropdown:SetWidth(90)
dropdown:SetHeight(10)
local label = Aux.gui.label(dropdown, 13)
label:SetPoint('BOTTOMLEFT', dropdown, 'TOPLEFT', -2, -4)
label:SetText('Duration')
UIDropDownMenu_Initialize(dropdown, private.initialize_duration_dropdown)
UIDropDownMenu_Initialize(dropdown, m.initialize_duration_dropdown)
dropdown:SetScript('OnShow', function()
UIDropDownMenu_Initialize(this, private.initialize_duration_dropdown)
UIDropDownMenu_Initialize(this, m.initialize_duration_dropdown)
end)
local label = Aux.gui.label(dropdown, 15)
label:SetPoint('LEFT', dropdown, 'RIGHT', 25, 0)
@@ -202,10 +202,10 @@ function Aux.post_frame.create_frames(private, public)
checkbox:SetHeight(22)
checkbox:SetPoint('TOPRIGHT', -85, -6)
checkbox:SetScript('OnClick', function()
local settings = private.read_settings()
local settings = m.read_settings()
settings.hidden = this:GetChecked()
private.write_settings(settings)
private.refresh = true
m.write_settings(settings)
m.refresh = true
end)
local label = Aux.gui.label(checkbox, 13)
label:SetPoint('LEFT', checkbox, 'RIGHT', 2, 1)
@@ -218,16 +218,16 @@ function Aux.post_frame.create_frames(private, public)
editbox:SetJustifyH('RIGHT')
editbox:SetWidth(150)
editbox:SetScript('OnTextChanged', function()
this.pretty:SetText(Aux.money.to_string(private.get_unit_start_price(), true, nil, 3))
private.refresh = true
this.pretty:SetText(Aux.money.to_string(m.get_unit_start_price(), true, nil, 3))
m.refresh = true
end)
editbox:SetScript('OnTabPressed', function()
if IsShiftKeyDown() and private.stack_count_slider.editbox:IsVisible() then
private.stack_count_slider.editbox:SetFocus()
if IsShiftKeyDown() and m.stack_count_slider.editbox:IsVisible() then
m.stack_count_slider.editbox:SetFocus()
elseif IsShiftKeyDown() then
private.stack_size_slider.editbox:SetFocus()
m.stack_size_slider.editbox:SetFocus()
else
private.unit_buyout_price:SetFocus()
m.unit_buyout_price:SetFocus()
end
end)
editbox:SetScript('OnEnterPressed', function()
@@ -238,7 +238,7 @@ function Aux.post_frame.create_frames(private, public)
this.pretty:Hide()
end)
editbox:SetScript('OnEditFocusLost', function()
this:SetText(Aux.money.to_string(private.get_unit_start_price(), true, nil, 3, nil, true))
this:SetText(Aux.money.to_string(m.get_unit_start_price(), true, nil, 3, nil, true))
this.pretty:Show()
end)
editbox.pretty = Aux.gui.label(editbox, Aux.gui.config.normal_font_size)
@@ -260,18 +260,18 @@ function Aux.post_frame.create_frames(private, public)
end
do
local editbox = Aux.gui.editbox(AuxPostParameters)
editbox:SetPoint('TOPRIGHT', private.unit_start_price, 'BOTTOMRIGHT', 0, -18)
editbox:SetPoint('TOPRIGHT', m.unit_start_price, 'BOTTOMRIGHT', 0, -18)
editbox:SetJustifyH('RIGHT')
editbox:SetWidth(150)
editbox:SetScript('OnTextChanged', function()
this.pretty:SetText(Aux.money.to_string(private.get_unit_buyout_price(), true, nil, 3))
private.refresh = true
this.pretty:SetText(Aux.money.to_string(m.get_unit_buyout_price(), true, nil, 3))
m.refresh = true
end)
editbox:SetScript('OnTabPressed', function()
if IsShiftKeyDown() then
private.unit_start_price:SetFocus()
m.unit_start_price:SetFocus()
else
private.stack_size_slider.editbox:SetFocus()
m.stack_size_slider.editbox:SetFocus()
end
end)
editbox:SetScript('OnEnterPressed', function()
@@ -282,7 +282,7 @@ function Aux.post_frame.create_frames(private, public)
this.pretty:Hide()
end)
editbox:SetScript('OnEditFocusLost', function()
this:SetText(Aux.money.to_string(private.get_unit_buyout_price(), true, nil, 3, nil, true))
this:SetText(Aux.money.to_string(m.get_unit_buyout_price(), true, nil, 3, nil, true))
this.pretty:Show()
end)
editbox.pretty = Aux.gui.label(editbox, Aux.gui.config.normal_font_size)
@@ -312,8 +312,8 @@ function Aux.post_frame.create_frames(private, public)
btn:GetFontString():SetPoint('RIGHT', 0, 0)
btn:SetScript('OnClick', function()
if this.amount then
private.set_unit_start_price(this.amount)
private.set_unit_buyout_price(this.amount)
m.set_unit_start_price(this.amount)
m.set_unit_buyout_price(this.amount)
end
end)
local label = Aux.gui.label(btn, 13)
@@ -321,4 +321,4 @@ function Aux.post_frame.create_frames(private, public)
label:SetText('Historical Value')
private.historical_value_button = btn
end
end
end)