refactoring

This commit is contained in:
Manuel Simon Hirsig
2016-09-06 10:09:35 +02:00
parent 3e2814a752
commit b5750fc294
6 changed files with 46 additions and 73 deletions
+8 -8
View File
@@ -17,8 +17,8 @@ do
frame:RegisterForDrag('LeftButton') frame:RegisterForDrag('LeftButton')
frame:SetScript('OnDragStart', function() this:StartMoving() end) frame:SetScript('OnDragStart', function() this:StartMoving() end)
frame:SetScript('OnDragStop', function() this:StopMovingOrSizing() end) frame:SetScript('OnDragStop', function() this:StopMovingOrSizing() end)
frame:SetScript('OnShow', function() PlaySound 'AuctionWindowOpen' end) frame:SetScript('OnShow', function() PlaySound('AuctionWindowOpen') end)
frame:SetScript('OnHide', function() PlaySound 'AuctionWindowClose' CloseAuctionHouse() end) frame:SetScript('OnHide', function() PlaySound('AuctionWindowClose') CloseAuctionHouse() end)
frame.content = CreateFrame('Frame', nil, frame) frame.content = CreateFrame('Frame', nil, frame)
frame.content:SetPoint('TOPLEFT', 4, -80) frame.content:SetPoint('TOPLEFT', 4, -80)
frame.content:SetPoint('BOTTOMRIGHT', -4, 35) frame.content:SetPoint('BOTTOMRIGHT', -4, 35)
@@ -31,18 +31,18 @@ do
function public.tab.set(id) tabs:select(id) end function public.tab.set(id) tabs:select(id) end
end end
do do
local btn = gui.button(aux_frame, 16) local btn = gui.button(aux_frame)
btn:SetPoint('BOTTOMRIGHT', -6, 6) btn:SetPoint('BOTTOMRIGHT', -5, 5)
gui.set_size(btn, 65, 24) gui.set_size(btn, 60, 24)
btn:SetText('Close') btn:SetText('Close')
btn:SetScript('OnClick', L(aux_frame.Hide, aux_frame)) btn:SetScript('OnClick', L(aux_frame.Hide, aux_frame))
public.close_button = btn public.close_button = btn
end end
do do
local btn = gui.button(aux_frame, 16) local btn = gui.button(aux_frame, gui.font_size.small)
btn:SetPoint('RIGHT', close_button, 'LEFT' , -5, 0) btn:SetPoint('RIGHT', close_button, 'LEFT' , -5, 0)
gui.set_size(btn, 65, 24) gui.set_size(btn, 60, 24)
btn:SetText('Default UI') btn:SetText(color.blizzard'Blizzard UI')
btn:SetScript('OnClick',function() btn:SetScript('OnClick',function()
if AuctionFrame:IsVisible() then HideUIPanel(AuctionFrame) else ShowUIPanel(AuctionFrame) end if AuctionFrame:IsVisible() then HideUIPanel(AuctionFrame) else ShowUIPanel(AuctionFrame) end
end) end)
+16 -18
View File
@@ -1,5 +1,14 @@
aux 'gui' aux 'gui'
public.font = [[Fonts\ARIALN.TTF]]
public.font_size = {
small = 13,
medium = 15,
large = 18,
huge = 23,
}
function LOAD() function LOAD()
do do
local blizzard_backdrop, aux_background, aux_border local blizzard_backdrop, aux_background, aux_border
@@ -37,7 +46,7 @@ function LOAD()
button:SetPoint('TOPLEFT', 0, -((button:GetID() - 1) * UIDROPDOWNMENU_BUTTON_HEIGHT) - 7) button:SetPoint('TOPLEFT', 0, -((button:GetID() - 1) * UIDROPDOWNMENU_BUTTON_HEIGHT) - 7)
button:SetPoint('TOPRIGHT', 0, -((button:GetID() - 1) * UIDROPDOWNMENU_BUTTON_HEIGHT) - 7) button:SetPoint('TOPRIGHT', 0, -((button:GetID() - 1) * UIDROPDOWNMENU_BUTTON_HEIGHT) - 7)
local text = button:GetFontString() local text = button:GetFontString()
text:SetFont(font, font_size.small2) text:SetFont(font, 14)
text:SetPoint('TOPLEFT', 18, 0) text:SetPoint('TOPLEFT', 18, 0)
text:SetPoint('BOTTOMRIGHT', -8, 0) text:SetPoint('BOTTOMRIGHT', -8, 0)
local highlight = _G['DropDownList1Button' .. i..'Highlight'] local highlight = _G['DropDownList1Button' .. i..'Highlight']
@@ -74,18 +83,6 @@ function LOAD()
end end
end end
public.font = [[Fonts\ARIALN.TTF]]
public.font_size = {
small = 13,
small2 = 14,
medium = 15,
medium2 = 16,
large = 17,
large2 = 18,
huge = 23,
}
do do
local id = 1 local id = 1
function public.name.get() function public.name.get()
@@ -165,8 +162,9 @@ function public.checkbutton(parent, text_height)
end end
function public.button(parent, text_height) function public.button(parent, text_height)
text_height = text_height or 16 text_height = text_height or font_size.large
local button = CreateFrame('Button', nil, parent) local button = CreateFrame('Button', nil, parent)
set_size(button, 80, 24)
set_content_style(button) set_content_style(button)
local highlight = button:CreateTexture(nil, 'HIGHLIGHT') local highlight = button:CreateTexture(nil, 'HIGHLIGHT')
highlight:SetAllPoints() highlight:SetAllPoints()
@@ -234,7 +232,7 @@ do
tab.text:SetPoint('RIGHT', -3, -1) tab.text:SetPoint('RIGHT', -3, -1)
tab.text:SetJustifyH('CENTER') tab.text:SetJustifyH('CENTER')
tab.text:SetJustifyV('CENTER') tab.text:SetJustifyV('CENTER')
tab.text:SetFont(font, font_size.large2) tab.text:SetFont(font, font_size.large)
tab:SetFontString(tab.text) tab:SetFontString(tab.text)
tab:SetText(text) tab:SetText(text)
@@ -377,7 +375,7 @@ function public.editbox(parent)
display:SetPoint('RIGHT', -1.5, 0) display:SetPoint('RIGHT', -1.5, 0)
display:SetTextColor(color.text.enabled()) display:SetTextColor(color.text.enabled())
editbox.display = display editbox.display = display
local cursor = label(editbox, font_size.large) local cursor = label(editbox, 17)
cursor:SetText('|') cursor:SetText('|')
cursor:SetTextColor(color.text.enabled()) cursor:SetTextColor(color.text.enabled())
cursor:SetAlpha(0) cursor:SetAlpha(0)
@@ -432,7 +430,7 @@ function public.status_bar(parent)
local text_frame = CreateFrame('Frame', nil, self) local text_frame = CreateFrame('Frame', nil, self)
text_frame:SetFrameLevel(level + 4) text_frame:SetFrameLevel(level + 4)
text_frame:SetAllPoints(self) text_frame:SetAllPoints(self)
local text = label(text_frame, 15) local text = label(text_frame, font_size.medium)
text:SetTextColor(color.text.enabled()) text:SetTextColor(color.text.enabled())
text:SetPoint('CENTER', 0, 0) text:SetPoint('CENTER', 0, 0)
self.text = text self.text = text
@@ -461,7 +459,7 @@ function public.item(parent)
btn:RegisterForClicks() btn:RegisterForClicks()
item.texture = _G[btn:GetName() .. 'Icon'] item.texture = _G[btn:GetName() .. 'Icon']
item.texture:SetTexCoord(.06, .94, .06, .94) item.texture:SetTexCoord(.06, .94, .06, .94)
item.name = label(btn, 15) item.name = label(btn, font_size.medium)
item.name:SetJustifyH('LEFT') item.name:SetJustifyH('LEFT')
item.name:SetPoint('LEFT', btn, 'RIGHT', 10, 0) item.name:SetPoint('LEFT', btn, 'RIGHT', 10, 0)
item.name:SetPoint('RIGHT', item, 'RIGHT', -10, .5) item.name:SetPoint('RIGHT', item, 'RIGHT', -10, .5)
+2 -6
View File
@@ -33,19 +33,15 @@ function create_frames()
status_bar:set_text('') status_bar:set_text('')
end end
do do
local btn = gui.button(frame, 16) local btn = gui.button(frame)
btn:SetPoint('TOPLEFT', status_bar, 'TOPRIGHT', 5, 0) btn:SetPoint('TOPLEFT', status_bar, 'TOPRIGHT', 5, 0)
btn:SetWidth(80)
btn:SetHeight(24)
btn:SetText('Cancel') btn:SetText('Cancel')
btn:Disable() btn:Disable()
cancel_button = btn cancel_button = btn
end end
do do
local btn = gui.button(frame, 16) local btn = gui.button(frame)
btn:SetPoint('TOPLEFT', cancel_button, 'TOPRIGHT', 5, 0) btn:SetPoint('TOPLEFT', cancel_button, 'TOPRIGHT', 5, 0)
btn:SetWidth(80)
btn:SetHeight(24)
btn:SetText('Refresh') btn:SetText('Refresh')
btn:SetScript('OnClick', function() btn:SetScript('OnClick', function()
scan_auctions() scan_auctions()
+3 -9
View File
@@ -37,28 +37,22 @@ function create_frames()
status_bar:set_text('') status_bar:set_text('')
end end
do do
local btn = gui.button(frame, 16) local btn = gui.button(frame)
btn:SetPoint('TOPLEFT', status_bar, 'TOPRIGHT', 5, 0) btn:SetPoint('TOPLEFT', status_bar, 'TOPRIGHT', 5, 0)
btn:SetWidth(80)
btn:SetHeight(24)
btn:SetText('Bid') btn:SetText('Bid')
btn:Disable() btn:Disable()
bid_button = btn bid_button = btn
end end
do do
local btn = gui.button(frame, 16) local btn = gui.button(frame)
btn:SetPoint('TOPLEFT', bid_button, 'TOPRIGHT', 5, 0) btn:SetPoint('TOPLEFT', bid_button, 'TOPRIGHT', 5, 0)
btn:SetWidth(80)
btn:SetHeight(24)
btn:SetText('Buyout') btn:SetText('Buyout')
btn:Disable() btn:Disable()
buyout_button = btn buyout_button = btn
end end
do do
local btn = gui.button(frame, 16) local btn = gui.button(frame)
btn:SetPoint('TOPLEFT', buyout_button, 'TOPRIGHT', 5, 0) btn:SetPoint('TOPLEFT', buyout_button, 'TOPRIGHT', 5, 0)
btn:SetWidth(80)
btn:SetHeight(24)
btn:SetText('Refresh') btn:SetText('Refresh')
btn:SetScript('OnClick', function() btn:SetScript('OnClick', function()
scan_bids() scan_bids()
+4 -8
View File
@@ -89,19 +89,15 @@ function create_frames()
status_bar:set_text('') status_bar:set_text('')
end end
do do
local btn = gui.button(frame.parameters, 16) local btn = gui.button(frame.parameters)
btn:SetPoint('TOPLEFT', status_bar, 'TOPRIGHT', 5, 0) btn:SetPoint('TOPLEFT', status_bar, 'TOPRIGHT', 5, 0)
btn:SetWidth(80)
btn:SetHeight(24)
btn:SetText('Post') btn:SetText('Post')
btn:SetScript('OnClick', post_auctions) btn:SetScript('OnClick', post_auctions)
post_button = btn post_button = btn
end end
do do
local btn = gui.button(frame.parameters, 16) local btn = gui.button(frame.parameters)
btn:SetPoint('TOPLEFT', post_button, 'TOPRIGHT', 5, 0) btn:SetPoint('TOPLEFT', post_button, 'TOPRIGHT', 5, 0)
btn:SetWidth(80)
btn:SetHeight(24)
btn:SetText('Refresh') btn:SetText('Refresh')
btn:SetScript('OnClick', refresh_button_click) btn:SetScript('OnClick', refresh_button_click)
refresh_button = btn refresh_button = btn
@@ -121,7 +117,7 @@ function create_frames()
do do
local slider = gui.slider(frame.parameters) local slider = gui.slider(frame.parameters)
slider:SetValueStep(1) slider:SetValueStep(1)
slider:SetPoint('TOPLEFT', 13, -74) slider:SetPoint('TOPLEFT', 13, -73)
slider:SetWidth(190) slider:SetWidth(190)
slider:SetScript('OnValueChanged', function() slider:SetScript('OnValueChanged', function()
quantity_update(true) quantity_update(true)
@@ -174,7 +170,7 @@ function create_frames()
end end
do do
local dropdown = gui.dropdown(frame.parameters) local dropdown = gui.dropdown(frame.parameters)
dropdown:SetPoint('TOPLEFT', stack_count_slider, 'BOTTOMLEFT', 0, -19) dropdown:SetPoint('TOPLEFT', stack_count_slider, 'BOTTOMLEFT', 0, -21)
dropdown:SetWidth(90) dropdown:SetWidth(90)
local label = gui.label(dropdown, gui.font_size.small) local label = gui.label(dropdown, gui.font_size.small)
label:SetPoint('BOTTOMLEFT', dropdown, 'TOPLEFT', -2, -3) label:SetPoint('BOTTOMLEFT', dropdown, 'TOPLEFT', -2, -3)
+13 -24
View File
@@ -111,7 +111,7 @@ function create_frames()
end end
end end
do do
local btn = gui.checkbutton(settings) local btn = gui.checkbutton(settings, gui.font_size.large)
btn:SetPoint('LEFT', 230, 0) btn:SetPoint('LEFT', 230, 0)
btn:SetWidth(140) btn:SetWidth(140)
btn:SetHeight(25) btn:SetHeight(25)
@@ -126,7 +126,7 @@ function create_frames()
public.real_time_button = btn public.real_time_button = btn
end end
do do
local btn = gui.checkbutton(settings) local btn = gui.checkbutton(settings, gui.font_size.large)
btn:SetPoint('LEFT', real_time_button, 'RIGHT', 15, 0) btn:SetPoint('LEFT', real_time_button, 'RIGHT', 15, 0)
btn:SetWidth(140) btn:SetWidth(140)
btn:SetHeight(25) btn:SetHeight(25)
@@ -141,7 +141,7 @@ function create_frames()
auto_buy_button = btn auto_buy_button = btn
end end
do do
local btn = gui.checkbutton(settings) local btn = gui.checkbutton(settings, gui.font_size.large)
btn:SetPoint('LEFT', auto_buy_button, 'RIGHT', 15, 0) btn:SetPoint('LEFT', auto_buy_button, 'RIGHT', 15, 0)
btn:SetWidth(140) btn:SetWidth(140)
btn:SetHeight(25) btn:SetHeight(25)
@@ -242,7 +242,7 @@ function create_frames()
gui.horizontal_line(frame, -40) gui.horizontal_line(frame, -40)
end end
do do
local btn = gui.button(frame, gui.font_size.large2) local btn = gui.button(frame, gui.font_size.large)
btn:SetPoint('BOTTOMLEFT', aux_frame.content, 'TOPLEFT', 10, 8) btn:SetPoint('BOTTOMLEFT', aux_frame.content, 'TOPLEFT', 10, 8)
btn:SetWidth(243) btn:SetWidth(243)
btn:SetHeight(22) btn:SetHeight(22)
@@ -251,7 +251,7 @@ function create_frames()
search_results_button = btn search_results_button = btn
end end
do do
local btn = gui.button(frame, gui.font_size.large2) local btn = gui.button(frame, gui.font_size.large)
btn:SetPoint('TOPLEFT', search_results_button, 'TOPRIGHT', 5, 0) btn:SetPoint('TOPLEFT', search_results_button, 'TOPRIGHT', 5, 0)
btn:SetWidth(243) btn:SetWidth(243)
btn:SetHeight(22) btn:SetHeight(22)
@@ -260,7 +260,7 @@ function create_frames()
saved_searches_button = btn saved_searches_button = btn
end end
do do
local btn = gui.button(frame, gui.font_size.large2) local btn = gui.button(frame, gui.font_size.large)
btn:SetPoint('TOPLEFT', saved_searches_button, 'TOPRIGHT', 5, 0) btn:SetPoint('TOPLEFT', saved_searches_button, 'TOPRIGHT', 5, 0)
btn:SetWidth(243) btn:SetWidth(243)
btn:SetHeight(22) btn:SetHeight(22)
@@ -276,28 +276,22 @@ function create_frames()
status_bar_frame = frame status_bar_frame = frame
end end
do do
local btn = gui.button(frame.results, 16) local btn = gui.button(frame.results)
btn:SetPoint('TOPLEFT', status_bar_frame, 'TOPRIGHT', 5, 0) btn:SetPoint('TOPLEFT', status_bar_frame, 'TOPRIGHT', 5, 0)
btn:SetWidth(80)
btn:SetHeight(24)
btn:SetText('Bid') btn:SetText('Bid')
btn:Disable() btn:Disable()
bid_button = btn bid_button = btn
end end
do do
local btn = gui.button(frame.results, 16) local btn = gui.button(frame.results)
btn:SetPoint('TOPLEFT', bid_button, 'TOPRIGHT', 5, 0) btn:SetPoint('TOPLEFT', bid_button, 'TOPRIGHT', 5, 0)
btn:SetWidth(80)
btn:SetHeight(24)
btn:SetText('Buyout') btn:SetText('Buyout')
btn:Disable() btn:Disable()
buyout_button = btn buyout_button = btn
end end
do do
local btn = gui.button(frame.results, 16) local btn = gui.button(frame.results)
btn:SetPoint('TOPLEFT', buyout_button, 'TOPRIGHT', 5, 0) btn:SetPoint('TOPLEFT', buyout_button, 'TOPRIGHT', 5, 0)
btn:SetWidth(80)
btn:SetHeight(24)
btn:SetText('Clear') btn:SetText('Clear')
btn:SetScript('OnClick', function() btn:SetScript('OnClick', function()
while tremove(current_search.records) do end while tremove(current_search.records) do end
@@ -305,10 +299,8 @@ function create_frames()
end) end)
end end
do do
local btn = gui.button(frame.saved, 16) local btn = gui.button(frame.saved)
btn:SetPoint('TOPLEFT', status_bar_frame, 'TOPRIGHT', 5, 0) btn:SetPoint('TOPLEFT', status_bar_frame, 'TOPRIGHT', 5, 0)
btn:SetWidth(80)
btn:SetHeight(24)
btn:SetText('Favorite') btn:SetText('Favorite')
btn:SetScript('OnClick', function() btn:SetScript('OnClick', function()
local filters = filter_util.queries(search_box:GetText()) local filters = filter_util.queries(search_box:GetText())
@@ -322,24 +314,21 @@ function create_frames()
end) end)
end end
do do
local btn1 = gui.button(frame.filter, 16) local btn1 = gui.button(frame.filter)
btn1:SetPoint('TOPLEFT', status_bar_frame, 'TOPRIGHT', 5, 0) btn1:SetPoint('TOPLEFT', status_bar_frame, 'TOPRIGHT', 5, 0)
gui.set_size(btn1, 80, 24)
btn1:SetText('Search') btn1:SetText('Search')
btn1:SetScript('OnClick', function() btn1:SetScript('OnClick', function()
export_filter_string() export_filter_string()
execute() execute()
end) end)
local btn2 = gui.button(frame.filter, 16) local btn2 = gui.button(frame.filter)
btn2:SetPoint('LEFT', btn1, 'RIGHT', 5, 0) btn2:SetPoint('LEFT', btn1, 'RIGHT', 5, 0)
gui.set_size(btn2, 80, 24)
btn2:SetText('Export') btn2:SetText('Export')
btn2:SetScript('OnClick', export_filter_string) btn2:SetScript('OnClick', export_filter_string)
local btn3 = gui.button(frame.filter, 16) local btn3 = gui.button(frame.filter)
btn3:SetPoint('LEFT', btn2, 'RIGHT', 5, 0) btn3:SetPoint('LEFT', btn2, 'RIGHT', 5, 0)
gui.set_size(btn3, 80, 24)
btn3:SetText('Import') btn3:SetText('Import')
btn3:SetScript('OnClick', import_filter_string) btn3:SetScript('OnClick', import_filter_string)
end end