refactoring

This commit is contained in:
Manuel Simon Hirsig
2016-07-16 13:10:19 +02:00
parent 182047d33b
commit b97ad322ce
3 changed files with 68 additions and 64 deletions
+26 -25
View File
@@ -14,10 +14,27 @@ end
private.tabs = {}
function public.tab(index, name)
local ret = { m.module(name) }
ret[3].ACTIVE = function()
return index == m.active_tab
end
m.tabs[index] = m[name]
return unpack(ret)
end
private.active_tab = nil
do
local active_tab_index
function private.active_tab()
if active_tab_index then
return m.tabs[active_tab_index]
end
end
function private.on_tab_click(index)
if m.active_tab() then
m.active_tab().CLOSE()
end
active_tab_index = index
m.active_tab().OPEN()
end
end
function public.on_load()
public.version = '3.0.1'
@@ -273,41 +290,25 @@ function private.AuctionFrameAuctions_OnEvent(...)
end
end
function public.neutral_faction()
return not UnitFactionGroup('npc')
end
function private.on_auction_house_show()
AuxFrame:Show()
m.tab_group:set_tab(1)
end
function public.neutral_faction()
return not UnitFactionGroup('npc')
end
function private.on_auction_house_closed()
m.post.stop()
m.stack.stop()
m.scan.abort()
m.tabs[m.active_tab].CLOSE()
m.active_tab().CLOSE()
AuxFrame:Hide()
end
function private.on_tab_click(index)
local y = m.active_tab
if m.active_tab then
m.tabs[m.active_tab].CLOSE()
end
AuxSearchFrame:Hide()
AuxPostFrame:Hide()
AuxAuctionsFrame:Hide()
AuxBidsFrame:Hide()
m.tabs[index].OPEN()
m.active_tab = index
end
function public.round(v)
return floor(v + 0.5)
end
@@ -350,7 +351,7 @@ end
function private.SetItemRef(...)
local itemstring, text, button = unpack(arg)
if AuxSearchFrame:IsVisible() and button == 'RightButton' then
if m.search_tab.ACTIVE() and button == 'RightButton' then
local item_info = m.info.item(tonumber(({strfind(itemstring, '^item:(%d+)')})[3]))
if item_info then
m.search_tab.set_filter(strlower(item_info.name)..'/exact')
@@ -368,7 +369,7 @@ function private.UseContainerItem(...)
return m.orig.UseContainerItem(unpack(arg))
end
if AuxSearchFrame:IsVisible() then
if m.search_tab.ACTIVE() then
local item_info = m.info.container_item(bag, slot)
item_info = item_info and m.info.item(item_info.item_id)
if item_info then
@@ -379,7 +380,7 @@ function private.UseContainerItem(...)
return
end
if AuxPostFrame:IsVisible() then
if m.post_tab.ACTIVE() then
local item_info = m.info.container_item(bag, slot)
if item_info then
m.post_tab.select_item(item_info.item_key)
+2 -2
View File
@@ -81,13 +81,13 @@ function public.LOAD()
end
function public.OPEN()
AuxSearchFrame:Show()
m.frame:Show()
m.update_search_listings()
end
function public.CLOSE()
m.results_listing:SetSelectedRecord()
AuxSearchFrame:Hide()
m.frame:Hide()
end
function private.update_search_listings()
+40 -37
View File
@@ -22,7 +22,7 @@ Aux.search_tab.FRAMES(function(m, public, private)
m.frame.saved.recent:SetPoint('TOPRIGHT', -4, -4)
m.frame.saved.recent:SetPoint('BOTTOMRIGHT', -4, 4)
do
local btn = Aux.gui.button(AuxSearchFrame, 22)
local btn = Aux.gui.button(m.frame, 22)
btn:SetPoint('TOPLEFT', 5, -8)
btn:SetWidth(70)
btn:SetHeight(25)
@@ -48,9 +48,9 @@ Aux.search_tab.FRAMES(function(m, public, private)
btn.auto = false
private.snipe_button = btn
end
Aux.gui.vertical_line(AuxSearchFrame, 80, nil, 408)
Aux.gui.vertical_line(m.frame, 80, nil, 408)
do
local btn = Aux.gui.button(AuxSearchFrame, 26)
local btn = Aux.gui.button(m.frame, 26)
btn:SetPoint('LEFT', m.snipe_button, 'RIGHT', 12, 0)
btn:SetWidth(30)
btn:SetHeight(25)
@@ -59,7 +59,7 @@ Aux.search_tab.FRAMES(function(m, public, private)
private.previous_button = btn
end
do
local btn = Aux.gui.button(AuxSearchFrame, 26)
local btn = Aux.gui.button(m.frame, 26)
btn:SetPoint('LEFT', m.previous_button, 'RIGHT', 4, 0)
btn:SetWidth(30)
btn:SetHeight(25)
@@ -68,7 +68,7 @@ Aux.search_tab.FRAMES(function(m, public, private)
private.next_button = btn
end
do
local btn = Aux.gui.button(AuxSearchFrame, 22)
local btn = Aux.gui.button(m.frame, 22)
btn:SetPoint('TOPRIGHT', -5, -8)
btn:SetWidth(70)
btn:SetHeight(25)
@@ -83,7 +83,7 @@ Aux.search_tab.FRAMES(function(m, public, private)
private.start_button = btn
end
do
local btn = Aux.gui.button(AuxSearchFrame, 22)
local btn = Aux.gui.button(m.frame, 22)
btn:SetPoint('TOPRIGHT', -5, -8)
btn:SetWidth(70)
btn:SetHeight(25)
@@ -95,7 +95,7 @@ Aux.search_tab.FRAMES(function(m, public, private)
private.stop_button = btn
end
do
local btn = Aux.gui.button(AuxSearchFrame, 22)
local btn = Aux.gui.button(m.frame, 22)
btn:SetPoint('RIGHT', m.start_button, 'LEFT', -4, 0)
btn:SetWidth(70)
btn:SetHeight(25)
@@ -106,7 +106,7 @@ Aux.search_tab.FRAMES(function(m, public, private)
private.resume_button = btn
end
do
local editbox = Aux.gui.editbox(AuxSearchFrame)
local editbox = Aux.gui.editbox(m.frame)
editbox:SetMaxLetters(nil)
editbox:EnableMouse(1)
editbox.complete = Aux.completion.complete
@@ -135,10 +135,10 @@ Aux.search_tab.FRAMES(function(m, public, private)
private.search_box = editbox
end
do
Aux.gui.horizontal_line(AuxSearchFrame, -40)
Aux.gui.horizontal_line(m.frame, -40)
end
do
local btn = Aux.gui.button(AuxSearchFrame, 18)
local btn = Aux.gui.button(m.frame, 18)
btn:SetPoint('BOTTOMLEFT', AuxFrameContent, 'TOPLEFT', 10, 8)
btn:SetWidth(243)
btn:SetHeight(22)
@@ -147,7 +147,7 @@ Aux.search_tab.FRAMES(function(m, public, private)
private.search_results_button = btn
end
do
local btn = Aux.gui.button(AuxSearchFrame, 18)
local btn = Aux.gui.button(m.frame, 18)
btn:SetPoint('TOPLEFT', m.search_results_button, 'TOPRIGHT', 5, 0)
btn:SetWidth(243)
btn:SetHeight(22)
@@ -156,7 +156,7 @@ Aux.search_tab.FRAMES(function(m, public, private)
private.saved_searches_button = btn
end
do
local btn = Aux.gui.button(AuxSearchFrame, 18)
local btn = Aux.gui.button(m.frame, 18)
btn:SetPoint('TOPLEFT', m.saved_searches_button, 'TOPRIGHT', 5, 0)
btn:SetWidth(243)
btn:SetHeight(22)
@@ -165,7 +165,7 @@ Aux.search_tab.FRAMES(function(m, public, private)
private.new_filter_button = btn
end
do
local status_bar = Aux.gui.status_bar(AuxSearchFrame)
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)
@@ -253,12 +253,12 @@ Aux.search_tab.FRAMES(function(m, public, private)
end)
end
do
local editbox = Aux.gui.editbox(m.frame.filter, '$parentNameInputBox')
local editbox = Aux.gui.editbox(m.frame.filter)
editbox.complete_item = Aux.completion.completor(function() return aux_auctionable_items end)
editbox:SetPoint('TOPLEFT', 14, -20)
editbox:SetWidth(260)
editbox:SetScript('OnChar', function()
if m.frame.filterExactCheckButton:GetChecked() then
if m.exact_checkbox:GetChecked() then
this:complete_item()
end
end)
@@ -266,7 +266,7 @@ Aux.search_tab.FRAMES(function(m, public, private)
if IsShiftKeyDown() then
m.last_page_editbox:SetFocus()
else
getglobal(this:GetParent():GetName()..'MinLevel'):SetFocus()
m.min_level_input:SetFocus()
end
end)
editbox:SetScript('OnEnterPressed', function()
@@ -276,28 +276,29 @@ Aux.search_tab.FRAMES(function(m, public, private)
local label = Aux.gui.label(editbox, 13)
label:SetPoint('BOTTOMLEFT', editbox, 'TOPLEFT', -2, 1)
label:SetText('Name')
private.name_input = editbox
end
do
local checkbox = CreateFrame('CheckButton', '$parentExactCheckButton', m.frame.filter, 'UICheckButtonTemplate')
local checkbox = CreateFrame('CheckButton', nil, m.frame.filter, 'UICheckButtonTemplate')
checkbox:SetWidth(22)
checkbox:SetHeight(22)
checkbox:SetPoint('TOPLEFT', m.frame.filterNameInputBox, 'TOPRIGHT', 10, 0)
local label = Aux.gui.label(m.frame.filterExactCheckButton, 13)
label:SetPoint('BOTTOMLEFT', m.frame.filterExactCheckButton, 'TOPLEFT', 1, -3)
checkbox:SetPoint('TOPLEFT', m.name_input, 'TOPRIGHT', 10, 0)
local label = Aux.gui.label(checkbox, 13)
label:SetPoint('BOTTOMLEFT', checkbox, 'TOPLEFT', 1, -3)
label:SetText('Exact')
private.show_hidden_checkbox = checkbox
private.exact_checkbox = checkbox
end
do
local editbox = Aux.gui.editbox(m.frame.filter, '$parentMinLevel')
editbox:SetPoint('TOPLEFT', m.frame.filterNameInputBox, 'BOTTOMLEFT', 0, -22)
local editbox = Aux.gui.editbox(m.frame.filter)
editbox:SetPoint('TOPLEFT', m.name_input, 'BOTTOMLEFT', 0, -22)
editbox:SetWidth(125)
editbox:SetNumeric(true)
editbox:SetMaxLetters(2)
editbox:SetScript('OnTabPressed', function()
if IsShiftKeyDown() then
getglobal(this:GetParent():GetName()..'NameInputBox'):SetFocus()
m.name_input:SetFocus()
else
getglobal(this:GetParent():GetName()..'MaxLevel'):SetFocus()
m.max_level_input:SetFocus()
end
end)
editbox:SetScript('OnEnterPressed', function()
@@ -307,16 +308,17 @@ Aux.search_tab.FRAMES(function(m, public, private)
local label = Aux.gui.label(editbox, 13)
label:SetPoint('BOTTOMLEFT', editbox, 'TOPLEFT', -2, 1)
label:SetText('Level Range')
private.min_level_input = editbox
end
do
local editbox = Aux.gui.editbox(m.frame.filter, '$parentMaxLevel')
editbox:SetPoint('TOPLEFT', m.frame.filterMinLevel, 'TOPRIGHT', 10, 0)
local editbox = Aux.gui.editbox(m.frame.filter)
editbox:SetPoint('TOPLEFT', m.min_level_input, 'TOPRIGHT', 10, 0)
editbox:SetWidth(125)
editbox:SetNumeric(true)
editbox:SetMaxLetters(2)
editbox:SetScript('OnTabPressed', function()
if IsShiftKeyDown() then
getglobal(this:GetParent():GetName()..'MinLevel'):SetFocus()
m.min_level_input:SetFocus()
else
m.first_page_editbox:SetFocus()
end
@@ -328,20 +330,21 @@ Aux.search_tab.FRAMES(function(m, public, private)
local label = Aux.gui.label(editbox, 13)
label:SetPoint('RIGHT', editbox, 'LEFT', -4, 0)
label:SetText('-')
private.max_level_input = editbox
end
do
local checkbox = CreateFrame('CheckButton', '$parentUsableCheckButton', m.frame.filter, 'UICheckButtonTemplate')
local checkbox = CreateFrame('CheckButton', nil, m.frame.filter, 'UICheckButtonTemplate')
checkbox:SetWidth(22)
checkbox:SetHeight(22)
checkbox:SetPoint('TOPLEFT', m.frame.filterMaxLevel, 'TOPRIGHT', 10, 0)
local label = Aux.gui.label(m.frame.filterUsableCheckButton, 13)
label:SetPoint('BOTTOMLEFT', m.frame.filterUsableCheckButton, 'TOPLEFT', 1, -3)
checkbox:SetPoint('TOPLEFT', m.max_level_input, 'TOPRIGHT', 10, 0)
local label = Aux.gui.label(checkbox, 13)
label:SetPoint('BOTTOMLEFT', checkbox, 'TOPLEFT', 1, -3)
label:SetText('Usable')
private.usable_checkbox = checkbox
end
do
local dropdown = Aux.gui.dropdown(m.frame.filter)
dropdown:SetPoint('TOPLEFT', m.frame.filterMinLevel, 'BOTTOMLEFT', 0, -18)
dropdown:SetPoint('TOPLEFT', m.min_level_input, 'BOTTOMLEFT', 0, -18)
dropdown:SetWidth(300)
dropdown:SetHeight(10)
local label = Aux.gui.label(dropdown, 13)
@@ -403,7 +406,7 @@ Aux.search_tab.FRAMES(function(m, public, private)
editbox:SetMaxLetters(2)
editbox:SetScript('OnTabPressed', function()
if IsShiftKeyDown() then
getglobal(this:GetParent():GetName()..'MaxLevel'):SetFocus()
m.max_level_input:SetFocus()
else
m.last_page_editbox:SetFocus()
end
@@ -427,7 +430,7 @@ Aux.search_tab.FRAMES(function(m, public, private)
if IsShiftKeyDown() then
m.first_page_editbox:SetFocus()
else
getglobal(this:GetParent():GetName()..'NameInputBox'):SetFocus()
m.name_input:SetFocus()
end
end)
editbox:SetScript('OnEnterPressed', function()
@@ -441,8 +444,8 @@ Aux.search_tab.FRAMES(function(m, public, private)
end
Aux.gui.vertical_line(m.frame.filter, 332)
do
local label = Aux.gui.label(m.frame.filterUsableCheckButton, 13)
label:SetPoint('BOTTOMLEFT', m.frame.filterUsableCheckButton, 'TOPLEFT', 1, -3)
local label = Aux.gui.label(m.usable_checkbox, 13)
label:SetPoint('BOTTOMLEFT', m.usable_checkbox, 'TOPLEFT', 1, -3)
label:SetText('Usable')
end
local function add_modifier(...)