working on new filter tab

This commit is contained in:
Manuel Simon Hirsig
2016-07-31 19:21:46 +02:00
parent a0e0728298
commit 353820ede2
7 changed files with 159 additions and 286 deletions
+42 -97
View File
@@ -14,15 +14,6 @@ public.config = {
off_color = {0.7, 0.3, 0.3},
}
do
local x = 0
function private.id()
x = x + 1
return 'Aux_frame'..x
end
end
function public.inline_color(color)
local r, g, b, a = unpack(color)
return format('|c%02X%02X%02X%02X', a, r, g, b)
@@ -329,7 +320,7 @@ function public.item(parent)
local item = CreateFrame('Button', nil, parent)
item:SetWidth(193)
item:SetHeight(40)
local icon = CreateFrame('CheckButton', m.id(), item, 'ActionButtonTemplate')
local icon = CreateFrame('CheckButton', 'aux_frame'..Aux.unique(), item, 'ActionButtonTemplate')
icon:SetPoint('LEFT', 2, 0.5)
icon:SetHighlightTexture(nil)
icon:RegisterForClicks()
@@ -379,99 +370,53 @@ function public.vertical_line(parent, x_offset, top_offset, bottom_offset, inver
return texture
end
do
local id = 0
function public.dropdown(parent)
id = id + 1
local dropdown = CreateFrame('Frame', 'aux_dropdown'..id, parent, 'UIDropDownMenuTemplate')
function public.dropdown(parent)
local dropdown = CreateFrame('Frame', 'aux_frame'..Aux.unique(), parent, 'UIDropDownMenuTemplate')
dropdown:SetBackdrop{bgFile=[[Interface\Buttons\WHITE8X8]], edgeFile=[[Interface\Buttons\WHITE8X8]], edgeSize=m.config.edge_size, insets={top=5,bottom=5}}
dropdown:SetBackdropColor(unpack(m.config.content_color.backdrop))
dropdown:SetBackdropBorderColor(unpack(m.config.content_color.border))
local left = getglobal(dropdown:GetName()..'Left'):Hide()
local middle = getglobal(dropdown:GetName()..'Middle'):Hide()
local right = getglobal(dropdown:GetName()..'Right'):Hide()
dropdown:SetBackdrop{bgFile=[[Interface\Buttons\WHITE8X8]], edgeFile=[[Interface\Buttons\WHITE8X8]], edgeSize=m.config.edge_size, insets={top=5,bottom=5}}
dropdown:SetBackdropColor(unpack(m.config.content_color.backdrop))
dropdown:SetBackdropBorderColor(unpack(m.config.content_color.border))
local left = getglobal(dropdown:GetName()..'Left'):Hide()
local middle = getglobal(dropdown:GetName()..'Middle'):Hide()
local right = getglobal(dropdown:GetName()..'Right'):Hide()
local button = getglobal(dropdown:GetName()..'Button')
button:ClearAllPoints()
button:SetPoint('RIGHT', dropdown, 0, 0)
local button = getglobal(dropdown:GetName()..'Button')
button:ClearAllPoints()
button:SetPoint('RIGHT', dropdown, 0, 0)
local text = getglobal(dropdown:GetName()..'Text')
text:ClearAllPoints()
text:SetPoint('RIGHT', button, 'LEFT', -2, 0)
text:SetPoint('LEFT', dropdown, 'LEFT', 8, 0)
text:SetFont(m.config.content_font, 13)
text:SetShadowColor(0, 0, 0, 0)
local text = getglobal(dropdown:GetName()..'Text')
text:ClearAllPoints()
text:SetPoint('RIGHT', button, 'LEFT', -2, 0)
text:SetPoint('LEFT', dropdown, 'LEFT', 8, 0)
text:SetFont(m.config.content_font, 13)
text:SetShadowColor(0, 0, 0, 0)
--
-- dropdown:ClearAllPoints()
-- dropdown:SetPoint("BOTTOMRIGHT", frame, "BOTTOMRIGHT", -7, 0)
-- dropdown:SetScript("OnHide", nil)
-- dropdown:SetScript("OnEnter", Control_OnEnter)
-- dropdown:SetScript("OnLeave", Control_OnLeave)
-- dropdown:SetScript("OnMouseUp", function(self, button) Dropdown_TogglePullout(self.obj.button, button) end)
-- TSMAPI.Design:SetContentColor(dropdown)
--
-- local left = _G[dropdown:GetName().."Left"]
-- local middle = _G[dropdown:GetName().."Middle"]
-- local right = _G[dropdown:GetName().."Right"]
--
-- middle:ClearAllPoints()
-- right:ClearAllPoints()
--
-- middle:SetPoint("LEFT", left, "RIGHT", 0, 0)
-- middle:SetPoint("RIGHT", right, "LEFT", 0, 0)
-- right:SetPoint("TOPRIGHT", dropdown, "TOPRIGHT", 0, 17)
--
-- local button = _G[dropdown:GetName().."Button"]
-- button:RegisterForClicks("AnyUp")
-- button:SetScript("OnEnter", Control_OnEnter)
-- button:SetScript("OnLeave", Control_OnLeave)
-- button:SetScript("OnClick", Dropdown_TogglePullout)
-- button:ClearAllPoints()
-- button:SetPoint("RIGHT", dropdown, 0, 0)
--
-- local text = _G[dropdown:GetName().."Text"]
-- text:ClearAllPoints()
-- text:SetPoint("RIGHT", button, "LEFT", -2, 0)
-- text:SetPoint("LEFT", dropdown, "LEFT", 8, 0)
-- text:SetFont(TSMAPI.Design:GetContentFont("normal"))
-- text:SetShadowColor(0, 0, 0, 0)
--
-- local label = frame:CreateFontString(nil, "OVERLAY")
-- label:SetPoint("TOPLEFT", frame, "TOPLEFT", 0, 0)
-- label:SetPoint("TOPRIGHT", frame, "TOPRIGHT", 0, 0)
-- label:SetJustifyH("LEFT")
-- label:SetHeight(18)
-- label:SetFont(TSMAPI.Design:GetContentFont("small"))
-- label:SetShadowColor(0, 0, 0, 0)
-- label:Hide()
--
-- left:Hide()
-- middle:Hide()
-- right:Hide()
--
-- local widget = {
-- frame = frame,
-- label = label,
-- dropdown = dropdown,
-- text = text,
-- button = button,
-- count = count,
-- alignoffset = 30,
-- type = Type,
-- }
-- for method, func in pairs(methods) do
-- widget[method] = func
-- end
-- frame.obj = widget
-- dropdown.obj = widget
-- text.obj = widget
-- button.obj = widget
--
-- dropdown:ClearAllPoints()
-- dropdown:SetPoint("BOTTOMRIGHT", frame, "BOTTOMRIGHT", -7, 0)
-- dropdown:SetScript("OnHide", nil)
-- dropdown:SetScript("OnEnter", Control_OnEnter)
-- dropdown:SetScript("OnLeave", Control_OnLeave)
-- dropdown:SetScript("OnMouseUp", function(self, button) Dropdown_TogglePullout(self.obj.button, button) end)
-- TSMAPI.Design:SetContentColor(dropdown)
--
-- middle:ClearAllPoints()
-- right:ClearAllPoints()
--
-- middle:SetPoint("LEFT", left, "RIGHT", 0, 0)
-- middle:SetPoint("RIGHT", right, "LEFT", 0, 0)
-- right:SetPoint("TOPRIGHT", dropdown, "TOPRIGHT", 0, 17)
--
-- local button = _G[dropdown:GetName().."Button"]
-- button:RegisterForClicks("AnyUp")
-- button:SetScript("OnEnter", Control_OnEnter)
-- button:SetScript("OnLeave", Control_OnLeave)
-- button:SetScript("OnClick", Dropdown_TogglePullout)
-- button:ClearAllPoints()
-- button:SetPoint("RIGHT", dropdown, 0, 0)
return dropdown
end
return dropdown
end
function public.slider(frame)
+3 -3
View File
@@ -900,7 +900,7 @@ local methods = {
end,
RemoveAuctionRecord = function(self, record)
local index = Aux.util.index_of(record, self.records)
local index = Aux.util.key(record, self.records)
if index then
tremove(self.records, index)
end
@@ -910,7 +910,7 @@ local methods = {
RemoveSelectedRecord = function(self, count)
count = count or 1
for i=1, count do
local index = Aux.util.index_of(self.selected, self.records)
local index = Aux.util.key(self.selected, self.records)
if index then
tremove(self.records, index)
end
@@ -927,7 +927,7 @@ local methods = {
end,
ContainsRecord = function(rt, record)
if Aux.util.index_of(record, rt.records) then
if Aux.util.key(record, rt.records) then
return true
end
end,
+1 -1
View File
@@ -75,7 +75,7 @@ Aux.post_tab.FRAMES(function(m, public, private)
m.auction_listing:EnableSorting(false)
m.auction_listing:DisableSelection(true)
m.auction_listing:SetHandler('OnClick', function(table, row_data, column, button)
local column_index = Aux.util.index_of(column, column.row.cols)
local column_index = Aux.util.key(column, column.row.cols)
local unit_start_price, unit_buyout_price = m.undercut(row_data.record, m.stack_size_slider:GetValue(), button == 'RightButton')
if column_index == 3 then
m.stack_size_slider:SetValue(row_data.record.stack_size)
+58 -2
View File
@@ -229,7 +229,7 @@ function private.get_form_filter()
end
end
local quality = UIDropDownMenu_GetSelectedValue(m.quality_dropdown) ~= 0 and UIDropDownMenu_GetSelectedValue(m.quality_dropdown)
local quality = UIDropDownMenu_GetSelectedValue(m.quality_dropdown) >= 0 and UIDropDownMenu_GetSelectedValue(m.quality_dropdown)
if quality then
add(strlower(getglobal('ITEM_QUALITY'..quality..'_DESC')))
end
@@ -765,7 +765,7 @@ function private.initialize_quality_dropdown()
UIDropDownMenu_AddButton{
text = ALL,
value = 0,
value = -1,
func = on_click,
}
for i=0,4 do
@@ -777,3 +777,59 @@ function private.initialize_quality_dropdown()
end
end
function private.initialize_filter_dropdown()
local function on_click()
UIDropDownMenu_SetSelectedValue(m.filter_dropdown, this.value)
m.filter_button:SetText(this.value)
if Aux.safe(Aux).scan_util.filters[this.value].arity/0 == 0 then
m.filter_input:Hide()
else
m.filter_input:Show()
end
end
for _, filter in {'and', 'or', 'not', 'min-unit-buy', 'max-unit-bid', 'max-unit-bid', 'max-unit-buy', 'bid-profit', 'buy-profit', 'bid-vend-profit', 'buy-vend-profit', 'bid-dis-profit', 'buy-dis-profit', 'bid-pct', 'buy-pct', 'item', 'tooltip', 'min-lvl', 'max-lvl', 'rarity', 'left', 'utilizable', 'discard'} do
UIDropDownMenu_AddButton{
text = filter,
value = filter,
func = on_click,
}
end
end
do
local stack = {}
function private.add_post_filter()
local name = UIDropDownMenu_GetSelectedValue(m.filter_dropdown) or ''
local input = m.filter_input:GetText()
if Aux.safe(Aux).scan_util.filters[name].test(input)/true then
local filter = name
if Aux.safe(Aux).scan_util.filters[name].arity/0 > 0 then
filter = filter..'/'..input
end
local filters = m.filter_display:GetText() or ''
if filters ~= '' then
filters = filters..'|n'
end
for _=1,getn(stack) do
filters = filters..' '
end
m.filter_display:SetText(filters..filter)
m.filter_input:SetText('')
m.filter_input:ClearFocus()
if Aux.util.set('and', 'or')[filter] then
tinsert(stack, 2)
else
local top = tremove(stack)
if top and top > 1 then
tinsert(stack, top - 1)
end
end
end
end
end
+32 -172
View File
@@ -517,186 +517,46 @@ Aux.search_tab.FRAMES(function(m, public, private)
private.quality_dropdown = dropdown
end
Aux.gui.vertical_line(m.frame.filter, 332)
local function add_modifier(...)
local current_filter_string = m.search_box:GetText()
for i=1,arg.n do
if current_filter_string ~= '' and strsub(current_filter_string, -1) ~= '/' then
current_filter_string = current_filter_string..'/'
end
current_filter_string = current_filter_string..arg[i]
end
m.search_box:SetText(current_filter_string)
end
do
local btn = Aux.gui.button(m.frame.filter, 16)
btn:SetPoint('TOPRIGHT', -362, -10)
btn:SetWidth(50)
btn:SetHeight(19)
btn:SetText('and')
btn:SetScript('OnClick', function()
add_modifier('and')
local dropdown = Aux.gui.dropdown(m.frame.filter)
dropdown:SetPoint('TOPRIGHT', -200, -10)
dropdown:SetWidth(170)
dropdown:SetHeight(10)
UIDropDownMenu_Initialize(dropdown, m.initialize_filter_dropdown)
dropdown:SetScript('OnShow', function()
UIDropDownMenu_Initialize(this, m.initialize_filter_dropdown)
end)
private.and_operator_button = btn
getglobal(dropdown:GetName()..'Text'):Hide()
private.filter_dropdown = dropdown
end
do
local btn = Aux.gui.button(m.frame.filter, 16)
btn:SetPoint('LEFT', m.and_operator_button, 'RIGHT', 10, 0)
btn:SetWidth(50)
btn:SetHeight(19)
btn:SetText('or')
btn:SetScript('OnClick', function()
add_modifier('or')
btn:SetWidth(170)
btn:SetHeight(25)
btn:SetPoint('CENTER', m.filter_dropdown, 'CENTER', 0, 0)
btn:SetScript('OnClick', m.add_post_filter)
private.filter_button = btn
end
do
local input = Aux.gui.editbox(m.frame.filter)
input:SetPoint('LEFT', m.filter_dropdown, 'RIGHT', 10, 0)
input:SetWidth(150)
input:SetHeight(25)
-- editbox:SetNumeric(true)
-- editbox:SetMaxLetters(2)
input:SetScript('OnChar', function()
local filter = Aux.safe(Aux).scan_util.filters[UIDropDownMenu_GetSelectedValue(m.filter_dropdown)]
Aux.completion.complete(this, function() return ({filter.test()/nil})[2] end)
end)
private.or_operator_button = btn
input:SetScript('OnEnterPressed', m.add_post_filter)
private.filter_input = input
end
do
local btn = Aux.gui.button(m.frame.filter, 16)
btn:SetPoint('LEFT', m.or_operator_button, 'RIGHT', 10, 0)
btn:SetWidth(50)
btn:SetHeight(19)
btn:SetText('not')
btn:SetScript('OnClick', function()
add_modifier('not')
end)
private.not_operator_button = btn
end
private.modifier_buttons = {}
do
local btn = Aux.gui.button(m.frame.filter, 16)
btn:SetPoint('TOPLEFT', m.and_operator_button, 'BOTTOMLEFT', 0, -10)
m.modifier_buttons['min-unit-bid'] = btn
end
do
local btn = Aux.gui.button(m.frame.filter, 16)
btn:SetPoint('TOPLEFT', m.modifier_buttons['min-unit-bid'], 'BOTTOMLEFT', 0, -10)
m.modifier_buttons['min-unit-buy'] = btn
end
do
local btn = Aux.gui.button(m.frame.filter, 16)
btn:SetPoint('TOPLEFT', m.modifier_buttons['min-unit-buy'], 'BOTTOMLEFT', 0, -10)
m.modifier_buttons['max-unit-bid'] = btn
end
do
local btn = Aux.gui.button(m.frame.filter, 16)
btn:SetPoint('TOPLEFT', m.modifier_buttons['max-unit-bid'], 'BOTTOMLEFT', 0, -10)
m.modifier_buttons['max-unit-buy'] = btn
end
do
local btn = Aux.gui.button(m.frame.filter, 16)
btn:SetPoint('TOPLEFT', m.modifier_buttons['max-unit-buy'], 'BOTTOMLEFT', 0, -10)
m.modifier_buttons['bid-profit'] = btn
end
do
local btn = Aux.gui.button(m.frame.filter, 16)
btn:SetPoint('TOPLEFT', m.modifier_buttons['bid-profit'], 'BOTTOMLEFT', 0, -10)
m.modifier_buttons['buy-profit'] = btn
end
do
local btn = Aux.gui.button(m.frame.filter, 16)
btn:SetPoint('TOPLEFT', m.modifier_buttons['buy-profit'], 'BOTTOMLEFT', 0, -10)
m.modifier_buttons['bid-vend-profit'] = btn
end
do
local btn = Aux.gui.button(m.frame.filter, 16)
btn:SetPoint('TOPLEFT', m.modifier_buttons['bid-vend-profit'], 'BOTTOMLEFT', 0, -10)
m.modifier_buttons['buy-vend-profit'] = btn
end
do
local btn = Aux.gui.button(m.frame.filter, 16)
btn:SetPoint('TOPLEFT', m.modifier_buttons['buy-vend-profit'], 'BOTTOMLEFT', 0, -10)
m.modifier_buttons['bid-dis-profit'] = btn
end
do
local btn = Aux.gui.button(m.frame.filter, 16)
btn:SetPoint('TOPLEFT', m.modifier_buttons['bid-dis-profit'], 'BOTTOMLEFT', 0, -10)
m.modifier_buttons['buy-dis-profit'] = btn
end
do
local btn = Aux.gui.button(m.frame.filter, 16)
btn:SetPoint('TOPLEFT', m.and_operator_button, 'BOTTOMLEFT', 205, -10)
m.modifier_buttons['bid-pct'] = btn
end
do
local btn = Aux.gui.button(m.frame.filter, 16)
btn:SetPoint('TOPLEFT', m.modifier_buttons['bid-pct'], 'BOTTOMLEFT', 0, -10)
m.modifier_buttons['buy-pct'] = btn
end
do
local btn = Aux.gui.button(m.frame.filter, 16)
btn:SetPoint('TOPLEFT', m.modifier_buttons['buy-pct'], 'BOTTOMLEFT', 0, -10)
m.modifier_buttons['item'] = btn
end
do
local btn = Aux.gui.button(m.frame.filter, 16)
btn:SetPoint('TOPLEFT', m.modifier_buttons['item'], 'BOTTOMLEFT', 0, -10)
m.modifier_buttons['tooltip'] = btn
end
do
local btn = Aux.gui.button(m.frame.filter, 16)
btn:SetPoint('TOPLEFT', m.modifier_buttons['tooltip'], 'BOTTOMLEFT', 0, -10)
m.modifier_buttons['min-lvl'] = btn
end
do
local btn = Aux.gui.button(m.frame.filter, 16)
btn:SetPoint('TOPLEFT', m.modifier_buttons['min-lvl'], 'BOTTOMLEFT', 0, -10)
m.modifier_buttons['max-lvl'] = btn
end
do
local btn = Aux.gui.button(m.frame.filter, 16)
btn:SetPoint('TOPLEFT', m.modifier_buttons['max-lvl'], 'BOTTOMLEFT', 0, -10)
m.modifier_buttons['rarity'] = btn
end
do
local btn = Aux.gui.button(m.frame.filter, 16)
btn:SetPoint('TOPLEFT', m.modifier_buttons['rarity'], 'BOTTOMLEFT', 0, -10)
m.modifier_buttons['left'] = btn
end
do
local btn = Aux.gui.button(m.frame.filter, 16)
btn:SetPoint('TOPLEFT', m.modifier_buttons['left'], 'BOTTOMLEFT', 0, -10)
m.modifier_buttons['utilizable'] = btn
end
do
local btn = Aux.gui.button(m.frame.filter, 16)
btn:SetPoint('TOPLEFT', m.modifier_buttons['utilizable'], 'BOTTOMLEFT', 0, -10)
m.modifier_buttons['discard'] = btn
end
for modifier_name, btn in m.modifier_buttons do
local modifier_name = modifier_name
local btn = btn
local filter = Aux.scan_util.filters[modifier_name]
btn:SetWidth(100)
btn:SetHeight(19)
btn:SetText(modifier_name)
btn:SetScript('OnClick', function()
local args = Aux.util.map(btn.inputs, function(input) return input:GetText() end)
if filter.test(unpack(args)) then
add_modifier(modifier_name, unpack(args))
for _, input in btn.inputs do
input:SetText('')
input:ClearFocus()
end
end
end)
btn.inputs = {}
if filter.arity > 0 then
local editbox = Aux.gui.editbox(m.frame.filter)
editbox.complete = Aux.completion.complete(function() return ({filter.test()})[2] end)
editbox:SetPoint('LEFT', btn, 'RIGHT', 10, 0)
editbox:SetWidth(80)
-- editbox:SetNumeric(true)
-- editbox:SetMaxLetters(2)
editbox:SetScript('OnChar', function()
this:complete()
end)
local on_click = btn:GetScript('OnClick')
editbox:SetScript('OnEnterPressed', function()
on_click()
end)
tinsert(btn.inputs, editbox)
end
local label = Aux.gui.label(m.frame.filter, 13)
label:SetPoint('TOPLEFT', 340, -50)
label:SetWidth(200)
label:SetJustifyH('LEFT')
private.filter_display = label
end
private.status_bars = {}
+20 -4
View File
@@ -3,6 +3,22 @@ local m, public, private = Aux.module'util'
function public.pass()
end
function public.sum(...)
local x = 0
for i=1,arg.n do
x = x + arg[i]
end
return x
end
function public.product(...)
local x = 0
for i=1,arg.n do
x = x * arg[i]
end
return x
end
function public.id(value)
return value
end
@@ -179,10 +195,10 @@ function public.take(n, xs)
return ys
end
function public.index_of(value, array)
for i, item in ipairs(array) do
if item == value then
return i
function public.key(value, t)
for k, v in t do
if v == value then
return k
end
end
end
+3 -7
View File
@@ -79,13 +79,9 @@ public.filters = {
return false, {'poor', 'common', 'uncommon', 'rare', 'epic'}, 'Erroneous rarity modifier'
end
local code = ({
['poor'] = 0,
['common'] = 1,
['uncommon'] = 2,
['rare'] = 3,
['epic'] = 4,
})[rarity or '']
local code = Aux.util.key(rarity, {'poor', 'common', 'uncommon', 'rare', 'epic'})
code = code and code - 1
if not code then
return false, {}, 'Erroneous rarity modifier'
end