tooltip filter added

This commit is contained in:
Manuel Simon Hirsig
2015-09-30 00:22:07 +02:00
parent 993e98ba9b
commit 00c35632e3
4 changed files with 173 additions and 53 deletions
+61 -9
View File
@@ -1,9 +1,10 @@
Aux.buy = {}
local record_auction, createOrder, updateOrder, set_message, report
local record_auction, createOrder, updateOrder, set_message, report, tooltip_match
local entries
local selectedEntries = {}
local search_query
local tooltip_patterns = {}
-----------------------------------------
@@ -43,9 +44,8 @@ function AuxBuySearchButton_OnClick()
if not auction_item then
return
end
local stack_size = auction_item.charges or auction_item.count
if auction_item.name == search_query.name or name == '' or not AuxBuyExactCheckButton:GetChecked() then
if (auction_item.name == search_query.name or search_query.name == '' or not AuxBuyExactCheckButton:GetChecked()) and tooltip_match(Aux.util.set_to_array(tooltip_patterns), auction_item.tooltip) then
record_auction(auction_item.name, auction_item.tooltip, stack_size, auction_item.buyout_price, auction_item.quality, auction_item.owner, auction_item.hyperlink, auction_item.itemstring)
end
end,
@@ -87,7 +87,7 @@ end
function AuxBuyBuySelectedButton_OnClick()
local order = createOrder(selectedEntries)
local orderedCount = Aux_SetSize(selectedEntries)
local orderedCount = Aux.util.set_size(selectedEntries)
entries = nil
selectedEntries = {}
@@ -162,10 +162,10 @@ function AuxBuyEntry_OnClick()
local i = this:GetID()
local entry = entries[i]
if Aux_SetContains(selectedEntries, entry) then
Aux_RemoveFromSet(selectedEntries, entry)
if Aux.util.set_contains(selectedEntries, entry) then
Aux.util.set_remove(selectedEntries, entry)
else
Aux_AddToSet(selectedEntries, entry)
Aux.util.set_add(selectedEntries, entry)
end
Aux_Buy_ScrollbarUpdate()
@@ -220,7 +220,7 @@ function Aux_Buy_ScrollbarUpdate()
end
MoneyFrame_Update("AuxBuyTotal", Aux_Round(total))
if Aux_SetSize(selectedEntries) > 0 and GetMoney() >= total then
if Aux.util.set_size(selectedEntries) > 0 and GetMoney() >= total then
AuxBuyBuySelectedButton:Enable()
else
AuxBuyBuySelectedButton:Disable()
@@ -262,7 +262,7 @@ function Aux_Buy_ScrollbarUpdate()
lineEntry_name:SetText("\124c" .. color .. entry.name .. "\124r")
if Aux_SetContains(selectedEntries, entry) then
if Aux.util.set_contains(selectedEntries, entry) then
lineEntry:LockHighlight()
else
lineEntry:UnlockHighlight()
@@ -282,6 +282,18 @@ end
-----------------------------------------
function tooltip_match(patterns, tooltip)
return Aux.util.all(patterns, function(pattern)
return Aux.util.any(tooltip, function(line)
local left_match = line[1].text and strfind(strupper(line[1].text), strupper(pattern), 1, true)
local right_match = line[2].text and strfind(strupper(line[2].text), strupper(pattern), 1, true)
return left_match or right_match
end)
end)
end
-----------------------------------------
function report(completed, item_name, ordered_count, progress)
AuxBuyReportHTML:SetText(string.format(
@@ -391,4 +403,44 @@ end
function AuxBuySlotDropDown_OnClick()
UIDropDownMenu_SetSelectedValue(AuxBuySlotDropDown, this.value)
end
function AuxBuyTooltipAddButton_OnClick()
local pattern = AuxBuyTooltipEdit:GetText()
if pattern ~= '' then
Aux.util.set_add(tooltip_patterns, pattern)
end
AuxBuyTooltipEdit:SetText('')
if DropDownList1:IsVisible() then
Aux.buy.toggle_tooltip_dropdown()
end
Aux.buy.toggle_tooltip_dropdown()
end
function AuxBuyTooltipRemoveButton_OnClick()
Aux.util.set_remove(tooltip_patterns, AuxBuyTooltipEdit:GetText())
AuxBuyTooltipEdit:SetText('')
if DropDownList1:IsVisible() then
Aux.buy.toggle_tooltip_dropdown()
end
Aux.buy.toggle_tooltip_dropdown()
end
function AuxBuyTooltipDropDown_Initialize()
for pattern, _ in tooltip_patterns do
UIDropDownMenu_AddButton{
text = pattern,
value = pattern,
func = AuxBuyTooltipDropDown_OnClick,
}
end
end
function AuxBuyTooltipDropDown_OnClick()
AuxBuyTooltipEdit:SetText(this.value)
end
function Aux.buy.toggle_tooltip_dropdown()
ToggleDropDownMenu(1, nil, AuxBuyTooltipDropDown, AuxBuyTooltipEdit, -12, 4)
end
+68 -22
View File
@@ -67,10 +67,10 @@
</HighlightTexture>
<Scripts>
<OnEnter>
AuxBuyEntry_OnEnter();
AuxBuyEntry_OnEnter()
</OnEnter>
<OnLeave>
GameTooltip:Hide();
GameTooltip:Hide()
</OnLeave>
<OnClick>
AuxBuyEntry_OnClick()
@@ -139,22 +139,22 @@
<Frames>
<Frame name="AuxBuyFilters">
<Size><AbsDimension x="1" y="1"/></Size>
<Anchors><Anchor point="TOPLEFT"><Offset><AbsDimension x="80" y="-55"/></Offset></Anchor></Anchors>
<Anchors><Anchor point="TOPLEFT"><Offset><AbsDimension x="80" y="-45"/></Offset></Anchor></Anchors>
<Layers>
<Layer level="BACKGROUND">
<FontString name="AuxBuySearchBoxLabel" inherits="GameFontHighlightSmall" text="Name">
<Anchors><Anchor point="LEFT"><Offset><AbsDimension x="0" y="1" /></Offset></Anchor></Anchors>
<Anchors><Anchor point="TOPLEFT"><Offset><AbsDimension x="0" y="0" /></Offset></Anchor></Anchors>
</FontString>
<FontString name="AuxBuyExactLabel" inherits="GameFontHighlightSmall" text="Exact">
<Anchors><Anchor point="LEFT"><Offset><AbsDimension x="240" y="1" /></Offset></Anchor></Anchors>
<Anchors><Anchor point="TOPLEFT"><Offset><AbsDimension x="225" y="0" /></Offset></Anchor></Anchors>
</FontString>
</Layer>
</Layers>
<Frames>
<EditBox name="AuxBuySearchBox" autoFocus="false" inherits="InputBoxTemplate">
<Size><AbsDimension x="180" y="20"/></Size>
<Anchors><Anchor point="LEFT"><Offset><AbsDimension x="50" y="0"/></Offset></Anchor></Anchors>
<Size><AbsDimension x="180" y="22"/></Size>
<Anchors><Anchor point="TOPLEFT"><Offset><AbsDimension x="40" y="0"/></Offset></Anchor></Anchors>
<Scripts>
<OnChar>
Aux.util.item_name_autocomplete()
@@ -165,23 +165,14 @@
</OnEnterPressed>
</Scripts>
</EditBox>
<CheckButton name="AuxBuyExactCheckButton" inherits="UICheckButtonTemplate" checked="true">
<Size><AbsDimension x="24" y="24"/></Size>
<Anchors><Anchor point="LEFT"><Offset><AbsDimension x="270" y="1" /></Offset></Anchor></Anchors>
</CheckButton>
<Button name="AuxBuySearchButton" inherits="UIPanelButtonTemplate" text="Search">
<Size><AbsDimension x="80" y="22"/></Size>
<Anchors><Anchor point="LEFT"><Offset><AbsDimension x="300" y="1" /></Offset></Anchor></Anchors>
<Scripts>
<OnClick>
AuxBuySearchButton_OnClick()
</OnClick>
</Scripts>
</Button>
<CheckButton name="AuxBuyExactCheckButton" inherits="UICheckButtonTemplate" checked="true">
<Size><AbsDimension x="22" y="22"/></Size>
<Anchors><Anchor point="TOPLEFT"><Offset><AbsDimension x="255" y="0" /></Offset></Anchor></Anchors>
</CheckButton>
<Frame name="AuxBuyCategoryDropDown" inherits="UIDropDownMenuTemplate">
<Anchors><Anchor point="LEFT"><Offset><AbsDimension x="380" y="1" /></Offset></Anchor></Anchors>
<Anchors><Anchor point="TOPLEFT"><Offset><AbsDimension x="270" y="3" /></Offset></Anchor></Anchors>
<Scripts>
<OnLoad>
UIDropDownMenu_Initialize(this, AuxBuyCategoryDropDown_Initialize)
@@ -192,6 +183,61 @@
</Scripts>
</Frame>
<EditBox name="AuxBuyTooltipEdit" autoFocus="false" inherits="InputBoxTemplate">
<Size><AbsDimension x="130" y="22"/></Size>
<Anchors><Anchor point="TOPLEFT"><Offset><AbsDimension x="430" y="0"/></Offset></Anchor></Anchors>
<Scripts>
<OnEnterPressed>
AuxBuyTooltipAddButton_OnClick(this)
</OnEnterPressed>
</Scripts>
</EditBox>
<Frame name="AuxBuyTooltipDropDown" inherits="UIDropDownMenuTemplate">
<Anchors><Anchor point="TOPLEFT"><Offset><AbsDimension x="413" y="0"/></Offset></Anchor></Anchors>
<Scripts>
<OnLoad>
getglobal(this:GetName().."Left"):Hide()
getglobal(this:GetName().."Middle"):Hide()
getglobal(this:GetName().."Right"):Hide()
getglobal(this:GetName().."Text"):Hide()
getglobal(this:GetName().."Button"):SetScript("OnClick", Aux.buy.toggle_tooltip_dropdown)
UIDropDownMenu_SetWidth(115)
UIDropDownMenu_Initialize(this, AuxBuyTooltipDropDown_Initialize)
</OnLoad>
</Scripts>
</Frame>
<Button name="AuxBuyTooltipAddButton" inherits="UIPanelButtonTemplate" text="+">
<Size><AbsDimension x="22" y="22"/></Size>
<Anchors><Anchor point="TOPLEFT"><Offset><AbsDimension x="578" y="0"/></Offset></Anchor></Anchors>
<Scripts>
<OnClick>
AuxBuyTooltipAddButton_OnClick(this)
</OnClick>
</Scripts>
</Button>
<Button name="AuxBuyTooltipRemoveButton" inherits="UIPanelButtonTemplate" text="-">
<Size><AbsDimension x="22" y="22"/></Size>
<Anchors><Anchor point="TOPLEFT"><Offset><AbsDimension x="600" y="0"/></Offset></Anchor></Anchors>
<Scripts>
<OnClick>
AuxBuyTooltipRemoveButton_OnClick(this)
</OnClick>
</Scripts>
</Button>
<Button name="AuxBuySearchButton" inherits="UIPanelButtonTemplate" text="Search">
<Size><AbsDimension x="80" y="22"/></Size>
<Anchors><Anchor point="TOPLEFT"><Offset><AbsDimension x="653" y="0" /></Offset></Anchor></Anchors>
<Scripts>
<OnClick>
AuxBuySearchButton_OnClick()
</OnClick>
</Scripts>
</Button>
<!-- <Frame name="AuxBuySlotDropDown" inherits="UIDropDownMenuTemplate">
<Anchors><Anchor point="LEFT"><Offset><AbsDimension x="500" y="1" /></Offset></Anchor></Anchors>
<Scripts>
-22
View File
@@ -362,28 +362,6 @@ end
-----------------------------------------
function Aux_AddToSet(set, key)
set[key] = true
end
function Aux_RemoveFromSet(set, key)
set[key] = nil
end
function Aux_SetContains(set, key)
return set[key] ~= nil
end
function Aux_SetSize(set)
local size = 0
for _,_ in pairs(set) do
size = size + 1
end
return size
end
-----------------------------------------
function relevel(frame)
local myLevel = frame:GetFrameLevel() + 1
local children = { frame:GetChildren() }
+44
View File
@@ -39,4 +39,48 @@ function Aux.util.format_money(val)
local c_string = (c ~= 0 or g == 0 and s == 0) and c .. 'c' or ''
return g_string .. s_string .. c_string
end
function Aux.util.set_add(set, key)
set[key] = true
end
function Aux.util.set_remove(set, key)
set[key] = nil
end
function Aux.util.set_contains(set, key)
return set[key] ~= nil
end
function Aux.util.set_size(set)
local size = 0
for _,_ in pairs(set) do
size = size + 1
end
return size
end
function Aux.util.set_to_array(set)
local array = {}
for element, _ in pairs(set) do
tinsert(array, element)
end
return array
end
function Aux.util.any(xs, p)
holds = false
for _, x in ipairs(xs) do
holds = holds or p(x)
end
return holds
end
function Aux.util.all(xs, p)
holds = true
for _, x in ipairs(xs) do
holds = holds and p(x)
end
return holds
end