more refactoring

This commit is contained in:
Manuel Simon Hirsig
2016-08-19 13:42:05 +02:00
parent b37e91b739
commit 829483900e
7 changed files with 222 additions and 218 deletions
+66 -66
View File
@@ -7,9 +7,9 @@ do
function public.start(params)
for _, old_state in {scan_states[params.type]} do
m.abort(old_state.id)
abort(old_state.id)
end
local thread_id = aux.control.thread(aux.C(m.wait_for_callback, params.on_scan_start, m.scan))
local thread_id = aux.control.thread(aux.C(wait_for_callback, params.on_scan_start, scan))
scan_states[params.type] = {
id = thread_id,
params = params,
@@ -32,20 +32,20 @@ do
end
function complete()
local on_complete = m.state.params.on_complete
scan_states[m.state.params.type] = nil
local on_complete = state.params.on_complete
scan_states[state.params.type] = nil
aux.call(on_complete)
end
state = aux.dynamic_table(scan_states, function(self)
local _, state = next(aux.util.filter(self.private, function(state) return state.id == aux.control.thread_id end))
function accessor.state()
local _, state = next(aux.util.filter(scan_states, function(state) return state.id == aux.control.thread_id end))
return state
end)
end
end
query = aux.dynamic_table(nil, function()
return m.state.params.queries[m.state.query_index]
end)
function accessor.query()
return state.params.queries[state.query_index]
end
function wait_for_callback(...)
local send_signal, signal_received = aux.util.signal()
@@ -70,47 +70,47 @@ function wait_for_callback(...)
end
function total_pages(total_auctions)
return ceil(total_auctions / m.PAGE_SIZE)
return ceil(total_auctions / PAGE_SIZE)
end
function last_page(total_auctions)
local last_page = max(m.total_pages(total_auctions) - 1, 0)
local last_page_limit = m.query.blizzard_query and m.query.blizzard_query.last_page or last_page
local last_page = max(total_pages(total_auctions) - 1, 0)
local last_page_limit = query.blizzard_query and query.blizzard_query.last_page or last_page
return min(last_page_limit, last_page)
end
function scan()
m.state.query_index = m.state.query_index and m.state.query_index + 1 or 1
if m.query() and (aux.index(m.query.blizzard_query, 'first_page') or 0) <= (aux.index(m.query.blizzard_query, 'last_page') or aux.huge) then
if m.query.blizzard_query then
m.state.page = m.query.blizzard_query.first_page or 0
state.query_index = state.query_index and state.query_index + 1 or 1
if query and (aux.index(query.blizzard_query, 'first_page') or 0) <= (aux.index(query.blizzard_query, 'last_page') or aux.huge) then
if query.blizzard_query then
state.page = query.blizzard_query.first_page or 0
else
m.state.page = nil
state.page = nil
end
return m.wait_for_callback(m.state.params.on_start_query, m.state.query_index, m.process_query)
return wait_for_callback(state.params.on_start_query, state.query_index, process_query)
else
m.complete()
complete()
end
end
function process_query()
if m.query.blizzard_query then
return m.submit_query()
if query.blizzard_query then
return submit_query()
else
return m.scan_page()
return scan_page()
end
end
function submit_query()
aux.control.when(function() return m.state.params.type ~= 'list' or CanSendAuctionQuery() end, function()
aux.call(m.state.params.on_submit_query)
m.state.last_query_time = GetTime()
if m.state.params.type == 'bidder' then
GetBidderAuctionItems(m.state.page)
elseif m.state.params.type == 'owner' then
GetOwnerAuctionItems(m.state.page)
aux.control.when(function() return state.params.type ~= 'list' or CanSendAuctionQuery() end, function()
aux.call(state.params.on_submit_query)
state.last_query_time = GetTime()
if state.params.type == 'bidder' then
GetBidderAuctionItems(state.page)
elseif state.params.type == 'owner' then
GetOwnerAuctionItems(state.page)
else
local blizzard_query = m.query.blizzard_query or {}
local blizzard_query = query.blizzard_query or {}
QueryAuctionItems(
blizzard_query.name,
blizzard_query.min_level,
@@ -118,48 +118,48 @@ function submit_query()
blizzard_query.slot,
blizzard_query.class,
blizzard_query.subclass,
m.state.page,
state.page,
blizzard_query.usable,
blizzard_query.quality
)
end
return m.wait_for_results()
return wait_for_results()
end)
end
function scan_page(i)
i = i or 1
local recurse = function(retry)
if i >= m.PAGE_SIZE then
m.wait_for_callback(m.state.params.on_page_scanned, function()
if m.query.blizzard_query and m.state.page < m.last_page(m.state.total_auctions) then
m.state.page = m.state.page + 1
return m.process_query()
if i >= PAGE_SIZE then
wait_for_callback(state.params.on_page_scanned, function()
if query.blizzard_query and state.page < last_page(state.total_auctions) then
state.page = state.page + 1
return process_query()
else
return m.scan()
return scan()
end
end)
else
return m.scan_page(retry and i or i + 1)
return scan_page(retry and i or i + 1)
end
end
local auction_info = aux.info.auction(i, m.state.params.type)
if auction_info and (auction_info.owner or m.state.params.ignore_owner or _G.aux_ignore_owner) then
local auction_info = aux.info.auction(i, state.params.type)
if auction_info and (auction_info.owner or state.params.ignore_owner or _G.aux_ignore_owner) then
auction_info.index = i
auction_info.page = m.state.page
auction_info.blizzard_query = m.query.blizzard_query
auction_info.query_type = m.state.params.type
auction_info.page = state.page
auction_info.blizzard_query = query.blizzard_query
auction_info.query_type = state.params.type
aux.history.process_auction(auction_info)
if aux.call(m.state.params.auto_buy_validator, auction_info) then
if aux.call(state.params.auto_buy_validator, auction_info) then
local send_signal, signal_received = aux.util.signal()
aux.control.when(signal_received, recurse)
aux.place_bid(auction_info.query_type, auction_info.index, auction_info.buyout_price, aux.C(send_signal, true))
return aux.control.thread(aux.control.when, aux.util.later(GetTime(), 10), aux.C(send_signal, false))
elseif not m.query.validator or m.query.validator(auction_info) then
return m.wait_for_callback(m.state.params.on_auction, auction_info, function(removed)
elseif not query.validator or query.validator(auction_info) then
return wait_for_callback(state.params.on_auction, auction_info, function(removed)
if removed then
return recurse(true)
else
@@ -173,36 +173,36 @@ function scan_page(i)
end
function wait_for_results()
local timeout = aux.util.later(m.state.last_query_time, 10)
local timeout = aux.util.later(state.last_query_time, 10)
local send_signal, signal_received = aux.util.signal()
aux.control.when(signal_received, function()
if timeout() then
return m.submit_query()
return submit_query()
else
_, m.state.total_auctions = GetNumAuctionItems(m.state.params.type)
return m.wait_for_callback(
m.state.params.on_page_loaded,
m.state.page - (m.query.blizzard_query.first_page or 0) + 1,
m.last_page(m.state.total_auctions) - (m.query.blizzard_query.first_page or 0) + 1,
m.total_pages(m.state.total_auctions) - 1,
m.scan_page
_, state.total_auctions = GetNumAuctionItems(state.params.type)
return wait_for_callback(
state.params.on_page_loaded,
state.page - (query.blizzard_query.first_page or 0) + 1,
last_page(state.total_auctions) - (query.blizzard_query.first_page or 0) + 1,
total_pages(state.total_auctions) - 1,
scan_page
)
end
end)
aux.control.thread(aux.control.when, timeout, send_signal)
if m.state.params.type == 'bidder' then
if state.params.type == 'bidder' then
return aux.control.thread(aux.control.when, function() return aux.bids_loaded end, send_signal)
elseif m.state.params.type == 'owner' then
return m.wait_for_owner_results(send_signal)
elseif m.state.params.type == 'list' then
return m.wait_for_list_results(send_signal, signal_received)
elseif state.params.type == 'owner' then
return wait_for_owner_results(send_signal)
elseif state.params.type == 'list' then
return wait_for_list_results(send_signal, signal_received)
end
end
function wait_for_owner_results(send_signal)
if m.state.page == aux.current_owner_page then
if state.page == aux.current_owner_page then
return send_signal()
else
return aux.control.on_next_event('AUCTION_OWNED_LIST_UPDATE', send_signal)
@@ -216,17 +216,17 @@ function wait_for_list_results(send_signal, signal_received)
last_update = GetTime()
updated = true
end)
local ignore_owner = m.state.params.ignore_owner or _G.aux_ignore_owner
local ignore_owner = state.params.ignore_owner or _G.aux_ignore_owner
return aux.control.thread(aux.control.when, function()
-- short circuiting order important, owner_data_complete must be called iif an update has happened.
local ok = updated and (ignore_owner or m.owner_data_complete('list')) or last_update and GetTime() - last_update > 5
local ok = updated and (ignore_owner or owner_data_complete('list')) or last_update and GetTime() - last_update > 5
updated = false
return ok
end, send_signal)
end
function owner_data_complete(type)
for i=1,m.PAGE_SIZE do
for i=1,PAGE_SIZE do
local auction_info = aux.info.auction(i, type)
if auction_info and not auction_info.owner then
return false
+14 -17
View File
@@ -13,9 +13,6 @@ do
__index = function(self, key)
return data[self].getter{public=self, private=data[self].state}[key]
end,
__call = function(self)
return data[self].getter{public=self, private=data[self].state}
end,
}
function public.dynamic_table(state, getter)
local self = {}
@@ -50,34 +47,34 @@ function public.tab(index, name)
local module_env = getfenv(2)
local tab = {name=name, env=module_env}
module_env.public.ACTIVE = function()
return tab == m.active_tab()
return tab == active_tab
end
for _, handler in {'OPEN', 'CLOSE', 'CLICK_LINK', 'USE_ITEM'} do
module_env.mutable[handler] = nil
end
m.tabs[index] = tab
tabs[index] = tab
end
do
local active_tab_index
active_tab = m.dynamic_table(nil, function()
return m.tabs[active_tab_index]
end)
function accessor.active_tab()
return tabs[active_tab_index]
end
function on_tab_click(index)
if active_tab_index then
m.call(m.active_tab.env.m.CLOSE)
m.call(active_tab.env.CLOSE)
end
active_tab_index = index
if active_tab_index then
m.call(m.active_tab.env.m.OPEN)
m.call(active_tab.env.OPEN)
end
end
end
function public.VARIABLES_LOADED()
do
local frame = CreateFrame('Frame', aux.gui.name(), UIParent)
tinsert(UISpecialFrames, '_G.aux_frame1')
m.gui.set_window_style(frame)
local frame = CreateFrame('Frame', aux.gui.name, UIParent)
tinsert(UISpecialFrames, 'aux_frame1')
gui.set_window_style(frame)
frame:SetWidth(768)
frame:SetHeight(447)
frame:SetPoint('LEFT', 100, 0)
@@ -284,20 +281,20 @@ function AuctionFrameAuctions_OnEvent(...)
end
function SetItemRef(...)
if arg[3] ~= 'RightButton' or not m.index(m.active_tab(), 'env', 'CLICK_LINK') or not strfind(arg[1], '^item:%d+') then
if arg[3] ~= 'RightButton' or not m.index(active_tab, 'env', 'CLICK_LINK') or not strfind(arg[1], '^item:%d+') then
return m.orig.SetItemRef(unpack(arg))
end
for item_info in aux.util.present(m.info.item(tonumber(({strfind(arg[1], '^item:(%d+)')})[3]))) do
return m.active_tab.env.m.CLICK_LINK(item_info)
return m.active_tab.env.CLICK_LINK(item_info)
end
end
function UseContainerItem(...)
if m.modified() or not m.index(m.active_tab(), 'env', 'USE_ITEM') then
if m.modified() or not m.index(active_tab, 'env', 'USE_ITEM') then
return m.orig.UseContainerItem(unpack(arg))
end
for item_info in aux.util.present(m.info.container_item(arg[1], arg[2])) do
return m.active_tab.env.m.USE_ITEM(item_info)
return m.active_tab.env.USE_ITEM(item_info)
end
end
+76 -68
View File
@@ -60,20 +60,20 @@ do
end
end
}
public.accessor.color = m.color_accessor(function(color)
public.accessor.color = color_accessor(function(color)
local r, g, b, a = unpack(color)
return setmetatable({r/255, g/255, b/255, a}, mt)
end)
end
public.accessor.inline_color = m.color_accessor(function(color)
public.accessor.inline_color = color_accessor(function(color)
local r, g, b, a = unpack(color)
return format('|c%02X%02X%02X%02X', a, r, g, b)
end)
do
local id = 0
function public.name()
function public.accessor.name()
id = id + 1
return 'aux_frame'..id
end
@@ -89,8 +89,8 @@ do
end
function initialize_menu()
menu = CreateFrame('Frame', m.name(), UIParent, 'UIMenuTemplate')
local orig = menu:GetScript('OnShow')
menu = CreateFrame('Frame', name, UIParent, 'UIMenuTemplate')
local orig = menu:GetScript 'OnShow'
menu:SetScript('OnShow', function()
UIMenu_Initialize()
for i=1,getn(structure) do
@@ -105,9 +105,9 @@ do
end
end
function m.LOAD()
m.initialize_menu()
m.initialize_dropdown()
function LOAD()
initialize_menu()
initialize_dropdown()
end
do
@@ -118,18 +118,18 @@ do
aux_border:SetTexture(1, 1, 1, .02)
aux_border:SetPoint('TOPLEFT', DropDownList1Backdrop, 'TOPLEFT', -2, 2)
aux_border:SetPoint('BOTTOMRIGHT', DropDownList1Backdrop, 'BOTTOMRIGHT', 1.5, -1.5)
aux_border:SetBlendMode('ADD')
aux_border:SetBlendMode 'ADD'
aux_background = DropDownList1:CreateTexture(nil, 'OVERLAY')
aux_background:SetTexture(unpack(m.color.content.background))
aux_background:SetTexture(color.content.background())
aux_background:SetAllPoints(DropDownList1Backdrop)
blizzard_backdrop = DropDownList1Backdrop:GetBackdrop()
aux.hook('ToggleDropDownMenu', function(...)
local ret = {aux.orig.ToggleDropDownMenu(unpack(arg))}
local dropdown = getglobal(arg[4] or '') or this:GetParent()
if strfind(dropdown:GetName() or '', '_G.aux_frame') then
m.set_aux_dropdown_style(dropdown)
if strfind(dropdown:GetName() or '', '^aux_frame%d+$') then
set_aux_dropdown_style(dropdown)
else
m.set_blizzard_dropdown_style()
set_blizzard_dropdown_style()
end
return unpack(ret)
end)
@@ -148,7 +148,7 @@ do
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(m.config.font, m.config.small_font_size2)
text:SetFont(config.font, config.small_font_size2)
text:SetPoint('TOPLEFT', 18, 0)
text:SetPoint('BOTTOMRIGHT', -8, 0)
local highlight = getglobal('DropDownList1Button'..i..'Highlight')
@@ -190,39 +190,39 @@ function public.set_size(frame, width, height)
end
function public.set_frame_style(frame, backdrop_color, border_color, left, right, top, bottom)
frame:SetBackdrop{bgFile=[[Interface\Buttons\WHITE8X8]], edgeFile=[[Interface\Buttons\WHITE8X8]], edgeSize=m.config.edge_size, tile=true, insets={left=left, right=right, top=top, bottom=bottom}}
frame:SetBackdropColor(unpack(backdrop_color))
frame:SetBackdropBorderColor(unpack(border_color))
frame:SetBackdrop{bgFile=[[Interface\Buttons\WHITE8X8]], edgeFile=[[Interface\Buttons\WHITE8X8]], edgeSize=config.edge_size, tile=true, insets={left=left, right=right, top=top, bottom=bottom}}
frame:SetBackdropColor(backdrop_color())
frame:SetBackdropBorderColor(border_color())
end
function public.set_window_style(frame, left, right, top, bottom)
m.set_frame_style(frame, m.color.window.background, m.color.window.border, left, right, top, bottom)
set_frame_style(frame, color.window.background, color.window.border, left, right, top, bottom)
end
function public.set_panel_style(frame, left, right, top, bottom)
m.set_frame_style(frame, m.color.panel.background, m.color.panel.border, left, right, top, bottom)
set_frame_style(frame, color.panel.background, color.panel.border, left, right, top, bottom)
end
function public.set_content_style(frame, left, right, top, bottom)
m.set_frame_style(frame, m.color.content.background, m.color.content.border, left, right, top, bottom)
set_frame_style(frame, color.content.background, color.content.border, left, right, top, bottom)
end
function public.panel(parent)
local panel = CreateFrame('Frame', nil, parent)
m.set_panel_style(panel)
set_panel_style(panel)
return panel
end
function public.checkbutton(parent, text_height)
local button = m.button(parent, text_height)
local button = button(parent, text_height)
button.state = false
button:SetBackdropColor(unpack(m.color.state.disabled))
button:SetBackdropColor(color.state.disabled())
function button:SetChecked(state)
if state then
self:SetBackdropColor(unpack(m.color.state.enabled))
self:SetBackdropColor(color.state.enabled())
self.state = true
else
self:SetBackdropColor(unpack(m.color.state.disabled))
self:SetBackdropColor(color.state.disabled())
self.state = false
end
end
@@ -235,7 +235,7 @@ end
function public.button(parent, text_height)
text_height = text_height or 16
local button = CreateFrame('Button', nil, parent)
m.set_content_style(button)
set_content_style(button)
local highlight = button:CreateTexture(nil, 'HIGHLIGHT')
highlight:SetAllPoints()
highlight:SetTexture(1, 1, 1, .2)
@@ -243,22 +243,22 @@ function public.button(parent, text_height)
button.highlight = highlight
do
local label = button:CreateFontString()
label:SetFont(m.config.font, text_height)
label:SetFont(config.font, text_height)
label:SetPoint('CENTER', 0, 0)
label:SetJustifyH('CENTER')
label:SetJustifyV('CENTER')
label:SetHeight(text_height)
label:SetTextColor(unpack(m.color.text.enabled))
label:SetTextColor(color.text.enabled())
button:SetFontString(label)
end
button.default_Enable = button.Enable
function button:Enable()
self:GetFontString():SetTextColor(unpack(m.color.text.enabled))
self:GetFontString():SetTextColor(color.text.enabled())
return self:default_Enable()
end
button.default_Disable = button.Disable
function button:Disable()
self:GetFontString():SetTextColor(unpack(m.color.text.disabled))
self:GetFontString():SetTextColor(color.text.disabled())
return self:default_Disable()
end
@@ -275,12 +275,12 @@ do
function mt.__index:create_tab(text)
local id = getn(self._tabs) + 1
local tab = CreateFrame('Button', m.name(), self._frame)
local tab = CreateFrame('Button', name, self._frame)
tab.id = id
tab.group = self
tab:SetHeight(24)
tab:SetBackdrop{bgFile=[[Interface\Buttons\WHITE8X8]], edgeFile=[[Interface\Buttons\WHITE8X8]], edgeSize=m.config.edge_size}
tab:SetBackdropBorderColor(m.color.panel.border())
tab:SetBackdrop{bgFile=[[Interface\Buttons\WHITE8X8]], edgeFile=[[Interface\Buttons\WHITE8X8]], edgeSize=config.edge_size}
tab:SetBackdropBorderColor(color.panel.border())
local dock = tab:CreateTexture(nil, 'OVERLAY')
dock:SetHeight(3)
if self._orientation == 'UP' then
@@ -290,7 +290,7 @@ do
dock:SetPoint('TOPLEFT', 1, 1)
dock:SetPoint('TOPRIGHT', -1, 1)
end
dock:SetTexture(m.color.panel.background())
dock:SetTexture(color.panel.background())
tab.dock = dock
local highlight = tab:CreateTexture(nil, 'HIGHLIGHT')
highlight:SetAllPoints()
@@ -303,7 +303,7 @@ do
tab.text:SetPoint('RIGHT', -3, -1)
tab.text:SetJustifyH 'CENTER'
tab.text:SetJustifyV 'CENTER'
tab.text:SetFont(m.config.font, m.config.large_font_size2)
tab.text:SetFont(config.font, config.large_font_size2)
tab:SetFontString(tab.text)
tab:SetText(text)
@@ -329,7 +329,7 @@ do
end
end
m.resize_tab(tab, tab:GetFontString():GetStringWidth(), 4)
resize_tab(tab, tab:GetFontString():GetStringWidth(), 4)
tinsert(self._tabs, tab)
end
@@ -341,15 +341,15 @@ do
function mt.__index:update()
for _, tab in self._tabs do
if tab.group._selected == tab.id then
tab.text:SetTextColor(m.color.label.enabled())
tab.text:SetTextColor(color.label.enabled())
tab:Disable()
tab:SetBackdropColor(m.color.panel.background())
tab:SetBackdropColor(color.panel.background())
tab.dock:Show()
tab:SetHeight(29)
else
tab.text:SetTextColor(m.color.text.enabled())
tab.text:SetTextColor(color.text.enabled())
tab:Enable()
tab:SetBackdropColor(m.color.content.background())
tab:SetBackdropColor(color.content.background())
tab.dock:Hide()
tab:SetHeight(24)
end
@@ -371,9 +371,10 @@ function public.editbox(parent)
editbox:SetTextInsets(1, 2, 3, 3)
editbox:SetMaxLetters(256)
editbox:SetHeight(24)
editbox:SetFont(m.config.font, m.config.medium_font_size)
editbox:SetShadowColor(0, 0, 0, 0)
m.set_content_style(editbox)
editbox:SetFont(config.font, config.medium_font_size)
editbox:SetTextColor(0, 0, 0, 0)
-- editbox:SetShadowColor(0, 0, 0, 0)
set_content_style(editbox)
editbox:SetScript('OnEditFocusGained', aux.C(editbox.HighlightText, aux._this))
editbox:SetScript('OnEditFocusLost', aux.C(editbox.HighlightText, aux._this, 0, 0))
editbox:SetScript('OnEscapePressed', aux.C(editbox.ClearFocus, aux._this))
@@ -390,20 +391,27 @@ function public.editbox(parent)
last_click = {t=GetTime(), x=x, y=y}
end)
end
editbox:SetScript('OnTextChanged', function()
this.overlay:SetJustifyH(this:GetJustifyH())
this.overlay:SetText(aux.call(this.formatter, this:GetText()) or this:GetText())
end)
function editbox:Enable()
editbox:EnableMouse(true)
editbox:SetTextColor(unpack(m.color.text.enabled))
editbox:SetTextColor(color.text.enabled())
end
function editbox:Disable()
editbox:EnableMouse(false)
editbox:SetTextColor(unpack(m.color.text.disabled))
editbox:SetTextColor(color.text.disabled())
editbox:ClearFocus()
end
local overlay = aux.gui.label(editbox, m.config.medium_font_size)
local overlay = aux.gui.label(editbox, config.medium_font_size)
overlay:SetPoint('LEFT', 1, 0)
overlay:SetPoint('RIGHT', -2, 0)
overlay:SetJustifyH('RIGHT')
overlay:SetTextColor(unpack(aux.gui.color.text.enabled))
overlay:SetTextColor(aux.gui.color.text.enabled())
editbox.overlay = overlay
local cursor = CreateFrame 'Frame'
cursor:SetBackdrop{bgFile=[[Interface\Buttons\WHITE8X8]]}
cursor:SetBackdropColor(aux.gui.color.text.enabled())
return editbox
end
@@ -456,8 +464,8 @@ function public.status_bar(parent)
local text_frame = CreateFrame('Frame', nil, self)
text_frame:SetFrameLevel(level + 4)
text_frame:SetAllPoints(self)
local text = m.label(text_frame, 15)
text:SetTextColor(unpack(m.color.text.enabled))
local text = label(text_frame, 15)
text:SetTextColor(color.text.enabled())
text:SetPoint('CENTER', 0, 0)
self.text = text
end
@@ -482,7 +490,7 @@ function public.item(parent)
local item = CreateFrame('Frame', nil, parent)
item:SetWidth(260)
item:SetHeight(40)
local btn = CreateFrame('CheckButton', m.name(), item, 'ActionButtonTemplate')
local btn = CreateFrame('CheckButton', name, item, 'ActionButtonTemplate')
item.button = btn
btn:SetPoint('LEFT', 2, .5)
btn:SetHighlightTexture(nil)
@@ -500,8 +508,8 @@ end
function public.label(parent, size)
local label = parent:CreateFontString()
label:SetFont(m.config.font, size or m.config.small_font_size)
label:SetTextColor(unpack(m.color.label.enabled))
label:SetFont(config.font, size or config.small_font_size)
label:SetTextColor(color.label.enabled())
return label
end
@@ -511,9 +519,9 @@ function public.horizontal_line(parent, y_offset, inverted_color)
texture:SetPoint('TOPRIGHT', parent, 'TOPRIGHT', -2, y_offset)
texture:SetHeight(2)
if inverted_color then
texture:SetTexture(unpack(m.color.panel.background))
texture:SetTexture(color.panel.background())
else
texture:SetTexture(unpack(m.color.content.background))
texture:SetTexture(color.content.background())
end
return texture
end
@@ -524,16 +532,16 @@ function public.vertical_line(parent, x_offset, top_offset, bottom_offset, inver
texture:SetPoint('BOTTOMLEFT', parent, 'BOTTOMLEFT', x_offset, bottom_offset or 2)
texture:SetWidth(2)
if inverted_color then
texture:SetTexture(unpack(m.color.panel.background))
texture:SetTexture(color.panel.background())
else
texture:SetTexture(unpack(m.color.content.background))
texture:SetTexture(color.content.background())
end
return texture
end
function public.dropdown(parent)
local dropdown = CreateFrame('Frame', m.name(), parent, 'UIDropDownMenuTemplate')
m.set_content_style(dropdown, 0, 0, 4, 4)
local dropdown = CreateFrame('Frame', name, parent, 'UIDropDownMenuTemplate')
set_content_style(dropdown, 0, 0, 4, 4)
getglobal(dropdown:GetName()..'Left'):Hide()
getglobal(dropdown:GetName()..'Middle'):Hide()
@@ -549,7 +557,7 @@ function public.dropdown(parent)
text:ClearAllPoints()
text:SetPoint('RIGHT', button, 'LEFT', -2, 0)
text:SetPoint('LEFT', 8, 0)
text:SetFont(m.config.font, m.config.medium_font_size)
text:SetFont(config.font, config.medium_font_size)
text:SetShadowColor(0, 0, 0, 0)
return dropdown
@@ -563,10 +571,10 @@ function public.slider(parent)
slider:SetHitRectInsets(0, 0, -12, -12)
slider:SetValue(0)
m.set_panel_style(slider)
set_panel_style(slider)
local thumb_texture = slider:CreateTexture(nil, 'ARTWORK')
thumb_texture:SetPoint('CENTER', 0, 0)
thumb_texture:SetTexture(unpack(m.color.content.background))
thumb_texture:SetTexture(color.content.background())
thumb_texture:SetHeight(18)
thumb_texture:SetWidth(8)
slider:SetThumbTexture(thumb_texture)
@@ -576,15 +584,15 @@ function public.slider(parent)
label:SetPoint('BOTTOMRIGHT', slider, 'TOPRIGHT', 6, 8)
label:SetJustifyH('LEFT')
label:SetHeight(13)
label:SetFont(m.config.font, m.config.small_font_size)
label:SetTextColor(unpack(m.color.label.enabled))
label:SetFont(config.font, config.small_font_size)
label:SetTextColor(color.label.enabled())
local editbox = m.editbox(slider)
local editbox = editbox(slider)
editbox:SetPoint('LEFT', slider, 'RIGHT', 5, 0)
editbox:SetWidth(45)
editbox:SetHeight(18)
editbox:SetJustifyH('CENTER')
editbox:SetFont(m.config.font, 17)
editbox:SetFont(config.font, 17)
slider.label = label
slider.editbox = editbox
@@ -595,12 +603,12 @@ function public.checkbox(parent)
local checkbox = CreateFrame('CheckButton', nil, parent, 'UICheckButtonTemplate')
checkbox:SetWidth(16)
checkbox:SetHeight(16)
m.set_content_style(checkbox)
set_content_style(checkbox)
checkbox:SetNormalTexture(nil)
checkbox:SetPushedTexture(nil)
checkbox:GetHighlightTexture():SetAllPoints()
checkbox:GetHighlightTexture():SetTexture(1, 1, 1, .2)
checkbox:GetCheckedTexture():SetTexCoord(.12, .88, .12, .88)
checkbox:GetHighlightTexture('BLEND')
checkbox:GetHighlightTexture 'BLEND'
return checkbox
end
+1 -1
View File
@@ -1019,7 +1019,7 @@ function public.CreateAuctionResultsTable(parent, config)
rt.contentFrame = contentFrame
-- frame to hold the header columns and the rows
local scrollFrame = CreateFrame('ScrollFrame', aux.gui.name(), rt, 'FauxScrollFrameTemplate')
local scrollFrame = CreateFrame('ScrollFrame', aux.gui.name, rt, 'FauxScrollFrameTemplate')
scrollFrame:SetScript('OnVerticalScroll', function()
if not rt.scrollDisabled then
FauxScrollFrame_OnVerticalScroll(rt.ROW_HEIGHT, function() rt:UpdateRows() end)
+26 -26
View File
@@ -2,34 +2,34 @@ aux.module 'bids_tab'
function create_frames()
frame = CreateFrame('Frame', nil, aux.frame)
m.frame:SetAllPoints()
m.frame:SetScript('OnUpdate', m.on_update)
m.frame:Hide()
frame:SetAllPoints()
frame:SetScript('OnUpdate', on_update)
frame:Hide()
m.frame.listing = aux.gui.panel(m.frame)
m.frame.listing:SetPoint('TOP', aux.frame, 'TOP', 0, -8)
m.frame.listing:SetPoint('BOTTOMLEFT', aux.frame.content, 'BOTTOMLEFT', 0, 0)
m.frame.listing:SetPoint('BOTTOMRIGHT', aux.frame.content, 'BOTTOMRIGHT', 0, 0)
frame.listing = aux.gui.panel(frame)
frame.listing:SetPoint('TOP', aux.frame, 'TOP', 0, -8)
frame.listing:SetPoint('BOTTOMLEFT', aux.frame.content, 'BOTTOMLEFT', 0, 0)
frame.listing:SetPoint('BOTTOMRIGHT', aux.frame.content, 'BOTTOMRIGHT', 0, 0)
listing = aux.auction_listing.CreateAuctionResultsTable(m.frame.listing, aux.auction_listing.bids_config)
m.listing:SetSort(1,2,3,4,5,6,7,8)
m.listing:Reset()
m.listing:SetHandler('OnCellClick', function(cell, button)
if IsAltKeyDown() and m.listing:GetSelection().record == cell.row.data.record then
if button == 'LeftButton' and m.buyout_button:IsEnabled() then
m.buyout_button:Click()
elseif button == 'RightButton' and m.bid_button:IsEnabled() then
m.bid_button:Click()
listing = aux.auction_listing.CreateAuctionResultsTable(frame.listing, aux.auction_listing.bids_config)
listing:SetSort(1,2,3,4,5,6,7,8)
listing:Reset()
listing:SetHandler('OnCellClick', function(cell, button)
if IsAltKeyDown() and listing:GetSelection().record == cell.row.data.record then
if button == 'LeftButton' and buyout_button:IsEnabled() then
buyout_button:Click()
elseif button == 'RightButton' and bid_button:IsEnabled() then
bid_button:Click()
end
end
end)
m.listing:SetHandler('OnSelectionChanged', function(rt, datum)
listing:SetHandler('OnSelectionChanged', function(rt, datum)
if not datum then return end
m.find_auction(datum.record)
find_auction(datum.record)
end)
do
status_bar = aux.gui.status_bar(m.frame)
status_bar = aux.gui.status_bar(frame)
status_bar:SetWidth(265)
status_bar:SetHeight(25)
status_bar:SetPoint('TOPLEFT', aux.frame.content, 'BOTTOMLEFT', 0, -6)
@@ -37,8 +37,8 @@ function create_frames()
status_bar:set_text('')
end
do
local btn = aux.gui.button(m.frame, 16)
btn:SetPoint('TOPLEFT', m.status_bar, 'TOPRIGHT', 5, 0)
local btn = aux.gui.button(frame, 16)
btn:SetPoint('TOPLEFT', status_bar, 'TOPRIGHT', 5, 0)
btn:SetWidth(80)
btn:SetHeight(24)
btn:SetText('Bid')
@@ -46,8 +46,8 @@ function create_frames()
bid_button = btn
end
do
local btn = aux.gui.button(m.frame, 16)
btn:SetPoint('TOPLEFT', m.bid_button, 'TOPRIGHT', 5, 0)
local btn = aux.gui.button(frame, 16)
btn:SetPoint('TOPLEFT', bid_button, 'TOPRIGHT', 5, 0)
btn:SetWidth(80)
btn:SetHeight(24)
btn:SetText('Buyout')
@@ -55,13 +55,13 @@ function create_frames()
buyout_button = btn
end
do
local btn = aux.gui.button(m.frame, 16)
btn:SetPoint('TOPLEFT', m.buyout_button, 'TOPRIGHT', 5, 0)
local btn = aux.gui.button(frame, 16)
btn:SetPoint('TOPLEFT', buyout_button, 'TOPRIGHT', 5, 0)
btn:SetWidth(80)
btn:SetHeight(24)
btn:SetText('Refresh')
btn:SetScript('OnClick', function()
m.scan_bids()
scan_bids()
end)
end
end
+25 -26
View File
@@ -209,27 +209,27 @@ function create_frames()
hide_checkbox = checkbox
end
do
local frame = CreateFrame('Frame', nil, m.frame.parameters)
local frame = CreateFrame('Frame', nil, frame.parameters)
start_price_frame = frame
aux.gui.set_content_style(frame)
frame:SetPoint('TOPRIGHT', m.frame.parameters, 'TOPRIGHT', -71, -60)
frame:SetPoint('TOPRIGHT', frame.parameters, 'TOPRIGHT', -71, -60)
frame:SetWidth(180)
frame:SetHeight(22)
local editbox = aux.gui.editbox(frame)
editbox:SetAllPoints()
editbox:SetJustifyH('RIGHT')
editbox:SetJustifyH 'RIGHT'
editbox:SetFont(aux.gui.config.font, 17)
editbox:SetScript('OnTextChanged', function()
this.pretty:SetText(aux.money.to_string(m.get_unit_start_price(), true, nil, 3))
m.refresh = true
this.pretty:SetText(aux.money.to_string(get_unit_start_price(), true, nil, 3))
refresh = true
end)
editbox:SetScript('OnTabPressed', function()
if IsShiftKeyDown() and m.stack_count_slider.editbox:IsVisible() then
m.stack_count_slider.editbox:SetFocus()
if IsShiftKeyDown() and stack_count_slider.editbox:IsVisible() then
stack_count_slider.editbox:SetFocus()
elseif IsShiftKeyDown() then
m.stack_size_slider.editbox:SetFocus()
stack_size_slider.editbox:SetFocus()
else
m.unit_buyout_price:SetFocus()
unit_buyout_price:SetFocus()
end
end)
editbox:SetScript('OnEditFocusGained', function()
@@ -238,7 +238,7 @@ function create_frames()
this:SetAlpha(1)
end)
editbox:SetScript('OnEditFocusLost', function()
this:SetText(aux.money.to_string(m.get_unit_start_price(), true, nil, 3, nil, true))
this:SetText(aux.money.to_string(get_unit_start_price(), true, nil, 3, nil, true))
this.pretty:Show()
this:SetAlpha(0)
end)
@@ -263,25 +263,25 @@ function create_frames()
unit_start_price = editbox
end
do
local frame = CreateFrame('Frame', nil, m.frame.parameters)
local frame = CreateFrame('Frame', nil, frame.parameters)
buyout_price_frame = frame
aux.gui.set_content_style(frame)
frame:SetPoint('TOPRIGHT', m.unit_start_price, 'BOTTOMRIGHT', 0, -19)
frame:SetPoint('TOPRIGHT', unit_start_price, 'BOTTOMRIGHT', 0, -19)
frame:SetWidth(180)
frame:SetHeight(22)
local editbox = aux.gui.editbox(frame)
editbox:SetAllPoints()
editbox:SetJustifyH('RIGHT')
editbox:SetJustifyH 'RIGHT'
editbox:SetFont(aux.gui.config.font, 17)
editbox:SetScript('OnTextChanged', function()
this.pretty:SetText(aux.money.to_string(m.get_unit_buyout_price(), true, nil, 3))
m.refresh = true
this.pretty:SetText(aux.money.to_string(get_unit_buyout_price(), true, nil, 3))
refresh = true
end)
editbox:SetScript('OnTabPressed', function()
if IsShiftKeyDown() then
m.unit_start_price:SetFocus()
unit_start_price:SetFocus()
else
m.stack_size_slider.editbox:SetFocus()
stack_size_slider.editbox:SetFocus()
end
end)
editbox:SetScript('OnEnterPressed', function()
@@ -293,7 +293,7 @@ function create_frames()
this:SetAlpha(1)
end)
editbox:SetScript('OnEditFocusLost', function()
this:SetText(aux.money.to_string(m.get_unit_buyout_price(), true, nil, 3, nil, true))
this:SetText(aux.money.to_string(get_unit_buyout_price(), true, nil, 3, nil, true))
this.pretty:Show()
this:SetAlpha(0)
end)
@@ -306,33 +306,32 @@ function create_frames()
do
local label = aux.gui.label(frame, aux.gui.config.small_font_size)
label:SetPoint('BOTTOMLEFT', frame, 'TOPLEFT', -2, 1)
label:SetText('Unit Buyout Price')
label:SetText 'Unit Buyout Price'
end
do
local label = aux.gui.label(frame, 14)
label:SetPoint('LEFT', frame, 'RIGHT', 8, 0)
label:SetWidth(50)
label:SetJustifyH('CENTER')
label:SetJustifyH 'CENTER'
buyout_price_percentage = label
end
unit_buyout_price = editbox
end
do
local btn = aux.gui.button(m.frame.parameters, 14)
local btn = aux.gui.button(frame.parameters, 14)
btn:SetPoint('TOPRIGHT', -10, -146)
btn:SetWidth(150)
btn:SetHeight(20)
aux.gui.set_size(btn, 150, 20)
btn:GetFontString():SetJustifyH('RIGHT')
btn:GetFontString():SetPoint('RIGHT', -2, 0)
btn:SetScript('OnClick', function()
if this.amount then
m.set_unit_start_price(this.amount)
m.set_unit_buyout_price(this.amount)
set_unit_start_price(this.amount)
set_unit_buyout_price(this.amount)
end
end)
local label = aux.gui.label(btn, aux.gui.config.small_font_size)
label:SetPoint('BOTTOMLEFT', btn, 'TOPLEFT', -2, 1)
label:SetText('Historical Value')
label:SetText 'Historical Value'
historical_value_button = btn
end
end
+14 -14
View File
@@ -353,41 +353,41 @@ function create_frames()
m.execute()
end)
local btn2 = aux.gui.button(m.frame.filter, 16)
local btn2 = aux.gui.button(frame.filter, 16)
btn2:SetPoint('LEFT', btn1, 'RIGHT', 5, 0)
btn2:SetWidth(80)
btn2:SetHeight(24)
btn2:SetText('Export')
btn2:SetScript('OnClick', m.export_query_string)
btn2:SetScript('OnClick', export_query_string)
local btn3 = aux.gui.button(m.frame.filter, 16)
local btn3 = aux.gui.button(frame.filter, 16)
btn3:SetPoint('LEFT', btn2, 'RIGHT', 5, 0)
btn3:SetWidth(80)
btn3:SetHeight(24)
btn3:SetText('Import')
btn3:SetScript('OnClick', m.import_query_string)
btn3:SetScript('OnClick', import_query_string)
end
do
local editbox = aux.gui.editbox(m.frame.filter)
local editbox = aux.gui.editbox(frame.filter)
editbox.complete_item = aux.completion.complete(function() return _G.aux_auctionable_items end)
editbox:SetPoint('TOPLEFT', 14, -m.FILTER_SPACING)
editbox:SetPoint('TOPLEFT', 14, -FILTER_SPACING)
editbox:SetWidth(260)
editbox:SetScript('OnChar', function()
if m.blizzard_query.exact then
if blizzard_query.exact then
this:complete_item()
end
end)
editbox:SetScript('OnTabPressed', function()
if m.blizzard_query.exact then
if blizzard_query.exact then
return
end
if IsShiftKeyDown() then
m.max_level_input:SetFocus()
max_level_input:SetFocus()
else
m.min_level_input:SetFocus()
min_level_input:SetFocus()
end
end)
editbox:SetScript('OnTextChanged', m.update_form)
editbox:SetScript('OnTextChanged', update_form)
editbox:SetScript('OnEnterPressed', aux.C(editbox.ClearFocus, editbox))
local label = aux.gui.label(editbox, aux.gui.config.small_font_size)
label:SetPoint('BOTTOMLEFT', editbox, 'TOPLEFT', -2, 1)
@@ -395,9 +395,9 @@ function create_frames()
name_input = editbox
end
do
local checkbox = aux.gui.checkbox(m.frame.filter)
checkbox:SetPoint('TOPLEFT', m.name_input, 'TOPRIGHT', 16, 0)
checkbox:SetScript('OnClick', m.update_form)
local checkbox = aux.gui.checkbox(frame.filter)
checkbox:SetPoint('TOPLEFT', name_input, 'TOPRIGHT', 16, 0)
checkbox:SetScript('OnClick', update_form)
local label = aux.gui.label(checkbox, aux.gui.config.small_font_size)
label:SetPoint('BOTTOMLEFT', checkbox, 'TOPLEFT', -2, 1)
label:SetText('Exact')