more progress on the filter tab
This commit is contained in:
+40
-21
@@ -1,27 +1,9 @@
|
||||
local m = {}
|
||||
Aux.groups = m
|
||||
Aux.test = m
|
||||
|
||||
|
||||
function m.parse_group(datastring)
|
||||
return Aux.persistence.deserialize(datastring, ',')
|
||||
end
|
||||
|
||||
function m.parse_item_key(item_key)
|
||||
local _, _, item_id, suffix_id = strfind(item_key, '(%d+):?(%d*)')
|
||||
return tonumber(item_id), suffix_id == '' and 0 or tonumber(suffix_id)
|
||||
end
|
||||
|
||||
m.test_group = '13127;9510;4438;16254;12006;13131;13012;4413;1482'
|
||||
|
||||
|
||||
function m.test()
|
||||
local array = Aux.persistence.deserialize(';', ';')
|
||||
snipe.log(getn(array))
|
||||
end
|
||||
|
||||
function on_char()
|
||||
function m.on_char()
|
||||
for _, data in ipairs(TSM.db.global.savedSearches) do
|
||||
if data.searchMode == "normal" then
|
||||
if data.searchMode == 'normal' then
|
||||
local prevSearch = strlower(data.filter)
|
||||
if strsub(prevSearch, 1, textLen) == text then
|
||||
self:SetText(prevSearch)
|
||||
@@ -30,4 +12,41 @@ function on_char()
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function m.prettify_search(search)
|
||||
local item_pattern = '([^/;]+)([^;]*)/exact'
|
||||
while true do
|
||||
local _, _, name, in_between = strfind(search, item_pattern)
|
||||
if name then
|
||||
search = gsub(search, item_pattern, m.display_name(Aux.static.auctionable_items[strupper(name)])..in_between, 1)
|
||||
else
|
||||
return search
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function m.display_name(item_id)
|
||||
local item_info = Aux.static.item_info(item_id)
|
||||
return '|c'..Aux.quality_color(item_info.quality)..'['..item_info.name..']'..'|r'
|
||||
end
|
||||
|
||||
function m:complete()
|
||||
local options = {'exact', 'even', 'discard' }
|
||||
|
||||
for _, class in ipairs({ GetAuctionItemClasses() }) do
|
||||
tinsert(options, class)
|
||||
end
|
||||
|
||||
local filter_string = this:GetText()
|
||||
local start_index, _, current_modifier = strfind(filter_string, '([^/;]*)$')
|
||||
current_modifier = current_modifier or ''
|
||||
|
||||
for _, option in ipairs(options) do
|
||||
if strfind(strupper(option), '^'..strupper(current_modifier)) then
|
||||
this:SetText(string.sub(filter_string, 1, start_index - 1)..option)
|
||||
this:HighlightText(strlen(filter_string), -1)
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user