From b5750fc2941db25f9916653a5719a9e7cbcd41fd Mon Sep 17 00:00:00 2001 From: Manuel Simon Hirsig Date: Tue, 6 Sep 2016 10:09:35 +0200 Subject: [PATCH] refactoring --- frame.lua | 16 ++++++++-------- gui/core.lua | 34 ++++++++++++++++------------------ tabs/auctions/frame.lua | 8 ++------ tabs/bids/frame.lua | 12 +++--------- tabs/post/frame.lua | 12 ++++-------- tabs/search/frame.lua | 37 +++++++++++++------------------------ 6 files changed, 46 insertions(+), 73 deletions(-) diff --git a/frame.lua b/frame.lua index 1a87b9b..697355a 100644 --- a/frame.lua +++ b/frame.lua @@ -17,8 +17,8 @@ do frame:RegisterForDrag('LeftButton') frame:SetScript('OnDragStart', function() this:StartMoving() end) frame:SetScript('OnDragStop', function() this:StopMovingOrSizing() end) - frame:SetScript('OnShow', function() PlaySound 'AuctionWindowOpen' end) - frame:SetScript('OnHide', function() PlaySound 'AuctionWindowClose' CloseAuctionHouse() end) + frame:SetScript('OnShow', function() PlaySound('AuctionWindowOpen') end) + frame:SetScript('OnHide', function() PlaySound('AuctionWindowClose') CloseAuctionHouse() end) frame.content = CreateFrame('Frame', nil, frame) frame.content:SetPoint('TOPLEFT', 4, -80) frame.content:SetPoint('BOTTOMRIGHT', -4, 35) @@ -31,18 +31,18 @@ do function public.tab.set(id) tabs:select(id) end end do - local btn = gui.button(aux_frame, 16) - btn:SetPoint('BOTTOMRIGHT', -6, 6) - gui.set_size(btn, 65, 24) + local btn = gui.button(aux_frame) + btn:SetPoint('BOTTOMRIGHT', -5, 5) + gui.set_size(btn, 60, 24) btn:SetText('Close') btn:SetScript('OnClick', L(aux_frame.Hide, aux_frame)) public.close_button = btn end 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) - gui.set_size(btn, 65, 24) - btn:SetText('Default UI') + gui.set_size(btn, 60, 24) + btn:SetText(color.blizzard'Blizzard UI') btn:SetScript('OnClick',function() if AuctionFrame:IsVisible() then HideUIPanel(AuctionFrame) else ShowUIPanel(AuctionFrame) end end) diff --git a/gui/core.lua b/gui/core.lua index f9ed6bb..4a798df 100644 --- a/gui/core.lua +++ b/gui/core.lua @@ -1,5 +1,14 @@ aux 'gui' +public.font = [[Fonts\ARIALN.TTF]] + +public.font_size = { + small = 13, + medium = 15, + large = 18, + huge = 23, +} + function LOAD() do 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('TOPRIGHT', 0, -((button:GetID() - 1) * UIDROPDOWNMENU_BUTTON_HEIGHT) - 7) local text = button:GetFontString() - text:SetFont(font, font_size.small2) + text:SetFont(font, 14) text:SetPoint('TOPLEFT', 18, 0) text:SetPoint('BOTTOMRIGHT', -8, 0) local highlight = _G['DropDownList1Button' .. i..'Highlight'] @@ -74,18 +83,6 @@ function LOAD() 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 local id = 1 function public.name.get() @@ -165,8 +162,9 @@ function public.checkbutton(parent, text_height) end 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) + set_size(button, 80, 24) set_content_style(button) local highlight = button:CreateTexture(nil, 'HIGHLIGHT') highlight:SetAllPoints() @@ -234,7 +232,7 @@ do tab.text:SetPoint('RIGHT', -3, -1) tab.text:SetJustifyH('CENTER') tab.text:SetJustifyV('CENTER') - tab.text:SetFont(font, font_size.large2) + tab.text:SetFont(font, font_size.large) tab:SetFontString(tab.text) tab:SetText(text) @@ -377,7 +375,7 @@ function public.editbox(parent) display:SetPoint('RIGHT', -1.5, 0) display:SetTextColor(color.text.enabled()) editbox.display = display - local cursor = label(editbox, font_size.large) + local cursor = label(editbox, 17) cursor:SetText('|') cursor:SetTextColor(color.text.enabled()) cursor:SetAlpha(0) @@ -432,7 +430,7 @@ function public.status_bar(parent) local text_frame = CreateFrame('Frame', nil, self) text_frame:SetFrameLevel(level + 4) text_frame:SetAllPoints(self) - local text = label(text_frame, 15) + local text = label(text_frame, font_size.medium) text:SetTextColor(color.text.enabled()) text:SetPoint('CENTER', 0, 0) self.text = text @@ -461,7 +459,7 @@ function public.item(parent) btn:RegisterForClicks() item.texture = _G[btn:GetName() .. 'Icon'] 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:SetPoint('LEFT', btn, 'RIGHT', 10, 0) item.name:SetPoint('RIGHT', item, 'RIGHT', -10, .5) diff --git a/tabs/auctions/frame.lua b/tabs/auctions/frame.lua index ca6a6d1..09953e1 100644 --- a/tabs/auctions/frame.lua +++ b/tabs/auctions/frame.lua @@ -33,19 +33,15 @@ function create_frames() status_bar:set_text('') end do - local btn = gui.button(frame, 16) + local btn = gui.button(frame) btn:SetPoint('TOPLEFT', status_bar, 'TOPRIGHT', 5, 0) - btn:SetWidth(80) - btn:SetHeight(24) btn:SetText('Cancel') btn:Disable() cancel_button = btn end do - local btn = gui.button(frame, 16) + local btn = gui.button(frame) btn:SetPoint('TOPLEFT', cancel_button, 'TOPRIGHT', 5, 0) - btn:SetWidth(80) - btn:SetHeight(24) btn:SetText('Refresh') btn:SetScript('OnClick', function() scan_auctions() diff --git a/tabs/bids/frame.lua b/tabs/bids/frame.lua index 79c26a0..e60fd27 100644 --- a/tabs/bids/frame.lua +++ b/tabs/bids/frame.lua @@ -37,28 +37,22 @@ function create_frames() status_bar:set_text('') end do - local btn = gui.button(frame, 16) + local btn = gui.button(frame) btn:SetPoint('TOPLEFT', status_bar, 'TOPRIGHT', 5, 0) - btn:SetWidth(80) - btn:SetHeight(24) btn:SetText('Bid') btn:Disable() bid_button = btn end do - local btn = gui.button(frame, 16) + local btn = gui.button(frame) btn:SetPoint('TOPLEFT', bid_button, 'TOPRIGHT', 5, 0) - btn:SetWidth(80) - btn:SetHeight(24) btn:SetText('Buyout') btn:Disable() buyout_button = btn end do - local btn = gui.button(frame, 16) + local btn = gui.button(frame) btn:SetPoint('TOPLEFT', buyout_button, 'TOPRIGHT', 5, 0) - btn:SetWidth(80) - btn:SetHeight(24) btn:SetText('Refresh') btn:SetScript('OnClick', function() scan_bids() diff --git a/tabs/post/frame.lua b/tabs/post/frame.lua index 0447798..79234dc 100644 --- a/tabs/post/frame.lua +++ b/tabs/post/frame.lua @@ -89,19 +89,15 @@ function create_frames() status_bar:set_text('') end do - local btn = gui.button(frame.parameters, 16) + local btn = gui.button(frame.parameters) btn:SetPoint('TOPLEFT', status_bar, 'TOPRIGHT', 5, 0) - btn:SetWidth(80) - btn:SetHeight(24) btn:SetText('Post') btn:SetScript('OnClick', post_auctions) post_button = btn end do - local btn = gui.button(frame.parameters, 16) + local btn = gui.button(frame.parameters) btn:SetPoint('TOPLEFT', post_button, 'TOPRIGHT', 5, 0) - btn:SetWidth(80) - btn:SetHeight(24) btn:SetText('Refresh') btn:SetScript('OnClick', refresh_button_click) refresh_button = btn @@ -121,7 +117,7 @@ function create_frames() do local slider = gui.slider(frame.parameters) slider:SetValueStep(1) - slider:SetPoint('TOPLEFT', 13, -74) + slider:SetPoint('TOPLEFT', 13, -73) slider:SetWidth(190) slider:SetScript('OnValueChanged', function() quantity_update(true) @@ -174,7 +170,7 @@ function create_frames() end do 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) local label = gui.label(dropdown, gui.font_size.small) label:SetPoint('BOTTOMLEFT', dropdown, 'TOPLEFT', -2, -3) diff --git a/tabs/search/frame.lua b/tabs/search/frame.lua index 69d3595..a62e27e 100644 --- a/tabs/search/frame.lua +++ b/tabs/search/frame.lua @@ -111,7 +111,7 @@ function create_frames() end end do - local btn = gui.checkbutton(settings) + local btn = gui.checkbutton(settings, gui.font_size.large) btn:SetPoint('LEFT', 230, 0) btn:SetWidth(140) btn:SetHeight(25) @@ -126,7 +126,7 @@ function create_frames() public.real_time_button = btn end 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:SetWidth(140) btn:SetHeight(25) @@ -141,7 +141,7 @@ function create_frames() auto_buy_button = btn end 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:SetWidth(140) btn:SetHeight(25) @@ -242,7 +242,7 @@ function create_frames() gui.horizontal_line(frame, -40) end 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:SetWidth(243) btn:SetHeight(22) @@ -251,7 +251,7 @@ function create_frames() search_results_button = btn end 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:SetWidth(243) btn:SetHeight(22) @@ -260,7 +260,7 @@ function create_frames() saved_searches_button = btn end 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:SetWidth(243) btn:SetHeight(22) @@ -276,28 +276,22 @@ function create_frames() status_bar_frame = frame end do - local btn = gui.button(frame.results, 16) + local btn = gui.button(frame.results) btn:SetPoint('TOPLEFT', status_bar_frame, 'TOPRIGHT', 5, 0) - btn:SetWidth(80) - btn:SetHeight(24) btn:SetText('Bid') btn:Disable() bid_button = btn end do - local btn = gui.button(frame.results, 16) + local btn = gui.button(frame.results) btn:SetPoint('TOPLEFT', bid_button, 'TOPRIGHT', 5, 0) - btn:SetWidth(80) - btn:SetHeight(24) btn:SetText('Buyout') btn:Disable() buyout_button = btn end do - local btn = gui.button(frame.results, 16) + local btn = gui.button(frame.results) btn:SetPoint('TOPLEFT', buyout_button, 'TOPRIGHT', 5, 0) - btn:SetWidth(80) - btn:SetHeight(24) btn:SetText('Clear') btn:SetScript('OnClick', function() while tremove(current_search.records) do end @@ -305,10 +299,8 @@ function create_frames() end) end do - local btn = gui.button(frame.saved, 16) + local btn = gui.button(frame.saved) btn:SetPoint('TOPLEFT', status_bar_frame, 'TOPRIGHT', 5, 0) - btn:SetWidth(80) - btn:SetHeight(24) btn:SetText('Favorite') btn:SetScript('OnClick', function() local filters = filter_util.queries(search_box:GetText()) @@ -322,24 +314,21 @@ function create_frames() end) end do - local btn1 = gui.button(frame.filter, 16) + local btn1 = gui.button(frame.filter) btn1:SetPoint('TOPLEFT', status_bar_frame, 'TOPRIGHT', 5, 0) - gui.set_size(btn1, 80, 24) btn1:SetText('Search') btn1:SetScript('OnClick', function() export_filter_string() execute() end) - local btn2 = gui.button(frame.filter, 16) + local btn2 = gui.button(frame.filter) btn2:SetPoint('LEFT', btn1, 'RIGHT', 5, 0) - gui.set_size(btn2, 80, 24) btn2:SetText('Export') 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) - gui.set_size(btn3, 80, 24) btn3:SetText('Import') btn3:SetScript('OnClick', import_filter_string) end