huge filter tab improvements
This commit is contained in:
+8
-8
@@ -122,27 +122,27 @@ function private.update_auction_listing()
|
||||
|
||||
local bid_color
|
||||
if blizzard_bid_undercut < unit_start_price and stack_blizzard_bid_undercut < unit_start_price then
|
||||
bid_color = aux.auction_listing.COLORS.RED
|
||||
bid_color = aux.auction_listing.colors.RED
|
||||
elseif blizzard_bid_undercut < unit_start_price then
|
||||
bid_color = aux.auction_listing.COLORS.ORANGE
|
||||
bid_color = aux.auction_listing.colors.ORANGE
|
||||
elseif stack_blizzard_bid_undercut < unit_start_price then
|
||||
bid_color = aux.auction_listing.COLORS.YELLOW
|
||||
bid_color = aux.auction_listing.colors.YELLOW
|
||||
end
|
||||
|
||||
local buyout_color
|
||||
if buyout_price_undercut < unit_buyout_price and stack_buyout_price_undercut < unit_buyout_price then
|
||||
buyout_color = aux.auction_listing.COLORS.RED
|
||||
buyout_color = aux.auction_listing.colors.RED
|
||||
elseif buyout_price_undercut < unit_buyout_price then
|
||||
buyout_color = aux.auction_listing.COLORS.ORANGE
|
||||
buyout_color = aux.auction_listing.colors.ORANGE
|
||||
elseif stack_buyout_price_undercut < unit_buyout_price then
|
||||
buyout_color = aux.auction_listing.COLORS.YELLOW
|
||||
buyout_color = aux.auction_listing.colors.YELLOW
|
||||
end
|
||||
|
||||
tinsert(auction_rows, {
|
||||
cols = {
|
||||
{ value=auction_record.own and aux.auction_listing.COLORS.GREEN..auction_record.count..FONT_COLOR_CODE_CLOSE or auction_record.count },
|
||||
{ value=auction_record.own and aux.auction_listing.colors.GREEN..auction_record.count..FONT_COLOR_CODE_CLOSE or auction_record.count },
|
||||
{ value=aux.auction_listing.time_left(auction_record.duration) },
|
||||
{ value=auction_record.stack_size == stack_size and aux.auction_listing.COLORS.GREEN..auction_record.stack_size..FONT_COLOR_CODE_CLOSE or auction_record.stack_size },
|
||||
{ value=auction_record.stack_size == stack_size and aux.auction_listing.colors.GREEN..auction_record.stack_size..FONT_COLOR_CODE_CLOSE or auction_record.stack_size },
|
||||
{ value=aux.money.to_string(auction_record.unit_blizzard_bid, true, nil, 3, bid_color) },
|
||||
{ value=historical_value and aux.auction_listing.percentage_historical(aux.util.round(auction_record.unit_blizzard_bid / historical_value * 100)) or '---' },
|
||||
{ value=auction_record.unit_buyout_price > 0 and aux.money.to_string(auction_record.unit_buyout_price, true, nil, 3, buyout_color) or '---' },
|
||||
|
||||
+90
-20
@@ -85,7 +85,9 @@ function private.set_form(components)
|
||||
end
|
||||
end
|
||||
|
||||
m.post_components = components.post
|
||||
for _, component in components.post do
|
||||
m.add_component(component)
|
||||
end
|
||||
m.update_filter_display()
|
||||
end
|
||||
|
||||
@@ -103,7 +105,8 @@ function private.clear_form()
|
||||
UIDropDownMenu_ClearAll(m.slot_dropdown)
|
||||
UIDropDownMenu_ClearAll(m.quality_dropdown)
|
||||
m.filter_input:ClearFocus()
|
||||
m.post_components = {}
|
||||
m.post_filter = {}
|
||||
m.filter_builder_state = {selected=0}
|
||||
m.update_filter_display()
|
||||
end
|
||||
|
||||
@@ -119,7 +122,7 @@ end
|
||||
function private.export_query_string()
|
||||
local components, error = aux.filter.parse_query_string(m.get_form())
|
||||
if components then
|
||||
m.search_box:SetText(aux.filter.query_string({blizzard=components.blizzard, post=m.post_components}))
|
||||
m.search_box:SetText(aux.filter.query_string({blizzard=components.blizzard, post=m.post_filter}))
|
||||
m.filter_input:ClearFocus()
|
||||
m.update_filter_display()
|
||||
else
|
||||
@@ -127,29 +130,101 @@ function private.export_query_string()
|
||||
end
|
||||
end
|
||||
|
||||
private.post_components = {}
|
||||
function public.formatted_post_filter(components)
|
||||
local no_line_break
|
||||
local stack = {}
|
||||
local str = ''
|
||||
|
||||
function private.add_post_component()
|
||||
local name = UIDropDownMenu_GetSelectedValue(m.filter_dropdown)
|
||||
if name then
|
||||
local filter = name
|
||||
if not aux.filter.filters[name] and filter == 'and' or filter == 'or' then
|
||||
for i, component in components do
|
||||
if no_line_break then
|
||||
str = str..' '
|
||||
elseif i > 1 then
|
||||
str = str..'</p><p>'
|
||||
for _=1,getn(stack) do
|
||||
str = str..aux.gui.inline_color.content.backdrop..'----'..FONT_COLOR_CODE_CLOSE
|
||||
end
|
||||
end
|
||||
no_line_break = component[1] == 'operator' and component[2] == 'not'
|
||||
|
||||
local OPERATOR_COLOR, FILTER_COLOR, PARAMETER_COLOR
|
||||
if m.filter_builder_state.selected == i then
|
||||
OPERATOR_COLOR, FILTER_COLOR, PARAMETER_COLOR = aux.auction_listing.colors.GREEN, aux.auction_listing.colors.GREEN, aux.auction_listing.colors.ORANGE
|
||||
else
|
||||
OPERATOR_COLOR, FILTER_COLOR, PARAMETER_COLOR = aux.auction_listing.colors.YELLOW, aux.auction_listing.colors.YELLOW, aux.auction_listing.colors.ORANGE
|
||||
end
|
||||
local component_text
|
||||
if component[1] == 'operator' then
|
||||
component_text = OPERATOR_COLOR..component[2]..(component[2] ~= 'not' and tonumber(component[3]) or '')..FONT_COLOR_CODE_CLOSE
|
||||
tinsert(stack, component[3])
|
||||
elseif component[1] == 'filter' then
|
||||
component_text = FILTER_COLOR..component[2]..FONT_COLOR_CODE_CLOSE
|
||||
if component[3] then
|
||||
component_text = component_text..': '..PARAMETER_COLOR..component[3]..FONT_COLOR_CODE_CLOSE
|
||||
end
|
||||
while getn(stack) > 0 and stack[getn(stack)] do
|
||||
local top = tremove(stack)
|
||||
if tonumber(top) and top > 1 then
|
||||
tinsert(stack, top - 1)
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
str = str..m.data_link(i, component_text)
|
||||
end
|
||||
|
||||
return '<html><body><p>'..str..'</p></body></html>'
|
||||
end
|
||||
|
||||
function private.data_link(id, str)
|
||||
return '|H'..id..'|h'..str..'|h'
|
||||
end
|
||||
|
||||
private.post_filter = {}
|
||||
private.filter_builder_state = {selected = 0}
|
||||
|
||||
function private.data_link_click()
|
||||
local button = arg3
|
||||
local index = tonumber(arg1)
|
||||
if button == 'LeftButton' then
|
||||
m.filter_builder_state.selected = index
|
||||
elseif button == 'RightButton' then
|
||||
m.remove_component(index)
|
||||
end
|
||||
m.update_filter_display()
|
||||
end
|
||||
|
||||
function private.remove_component(index)
|
||||
if m.filter_builder_state.selected == index then
|
||||
m.filter_builder_state.selected = max(index - 1, min(1, getn(m.post_filter)))
|
||||
end
|
||||
m.filter_builder_state[m.post_filter[index]] = nil
|
||||
tremove(m.post_filter, index)
|
||||
end
|
||||
|
||||
function private.add_component(component)
|
||||
m.filter_builder_state.selected = m.filter_builder_state.selected + 1
|
||||
tinsert(m.post_filter, m.filter_builder_state.selected, component)
|
||||
end
|
||||
|
||||
function private.add_dropdown_component()
|
||||
for _, str in {UIDropDownMenu_GetSelectedValue(m.filter_dropdown)} do
|
||||
if not aux.filter.filters[str] and str == 'and' or str == 'or' then
|
||||
local arity = m.filter_input:GetText()
|
||||
arity = tonumber(arity) and aux.util.round(tonumber(arity))
|
||||
if arity and arity < 2 then
|
||||
aux.log('Invalid operator suffix')
|
||||
return
|
||||
end
|
||||
filter = filter..(arity or '')
|
||||
str = str..(arity or '')
|
||||
end
|
||||
if aux.filter.filters[name] and aux.filter.filters[name].input_type ~= '' then
|
||||
filter = filter..'/'..m.filter_input:GetText()
|
||||
if aux.index(aux.filter.filters[str], 'input_type') ~= '' then
|
||||
str = str..'/'..m.filter_input:GetText()
|
||||
end
|
||||
|
||||
local components, error, suggestions = aux.filter.parse_query_string(filter)
|
||||
local components, error, suggestions = aux.filter.parse_query_string(str)
|
||||
|
||||
if components then
|
||||
tinsert(m.post_components, components.post[1])
|
||||
m.add_component(components.post[1])
|
||||
m.update_filter_display()
|
||||
m.filter_input:SetText('')
|
||||
m.filter_input:ClearFocus()
|
||||
@@ -159,16 +234,11 @@ function private.add_post_component()
|
||||
end
|
||||
end
|
||||
|
||||
function private.remove_post_filter()
|
||||
tremove(m.post_components)
|
||||
m.update_filter_display()
|
||||
end
|
||||
|
||||
do
|
||||
local text
|
||||
|
||||
function private.update_filter_display()
|
||||
text = aux.filter.indented_post_query_string(m.post_components)
|
||||
text = m.formatted_post_filter(m.post_filter)
|
||||
m.filter_display:SetWidth(m.filter_display_size())
|
||||
m.set_filter_display_offset()
|
||||
m.filter_display:SetText(text)
|
||||
|
||||
@@ -225,7 +225,7 @@ function private.create_frames()
|
||||
btn:SetPoint('RIGHT', m.start_button, 'LEFT', -4, 0)
|
||||
btn:SetWidth(70)
|
||||
btn:SetHeight(25)
|
||||
btn:SetText(aux.auction_listing.COLORS.GREEN..'Resume'..FONT_COLOR_CODE_CLOSE)
|
||||
btn:SetText(aux.auction_listing.colors.GREEN..'Resume'..FONT_COLOR_CODE_CLOSE)
|
||||
btn:SetScript('OnClick', function()
|
||||
m.execute(true)
|
||||
end)
|
||||
@@ -508,9 +508,9 @@ function private.create_frames()
|
||||
btn:RegisterForClicks('LeftButtonUp', 'RightButtonUp')
|
||||
btn:SetScript('OnClick', function()
|
||||
if arg1 == 'LeftButton' then
|
||||
m.add_post_component()
|
||||
m.add_dropdown_component()
|
||||
elseif arg1 == 'RightButton' then
|
||||
m.remove_post_filter()
|
||||
m.remove_post_component()
|
||||
end
|
||||
end)
|
||||
private.filter_button = btn
|
||||
@@ -522,7 +522,7 @@ function private.create_frames()
|
||||
input:SetScript('OnChar', function()
|
||||
this:complete()
|
||||
end)
|
||||
input:SetScript('OnEnterPressed', m.add_post_component)
|
||||
input:SetScript('OnEnterPressed', m.add_dropdown_component)
|
||||
input:Hide()
|
||||
private.filter_input = input
|
||||
end
|
||||
@@ -563,9 +563,7 @@ function private.create_frames()
|
||||
scroll_child:SetFont('p', [[Fonts\ARIALN.TTF]], 26)
|
||||
scroll_child:SetWidth(1)
|
||||
scroll_child:SetHeight(1)
|
||||
scroll_child:SetScript('OnHyperlinkClick', function()
|
||||
aux.log(arg1, arg2, arg3)
|
||||
end)
|
||||
scroll_child:SetScript('OnHyperlinkClick', m.data_link_click)
|
||||
-- scroll_child:SetHyperlinkFormat("format")
|
||||
scroll_child.measure = scroll_child:CreateFontString()
|
||||
private.filter_display = scroll_child
|
||||
|
||||
Reference in New Issue
Block a user