some refactoring and autocomplete improvements
This commit is contained in:
+1
-1
@@ -13,9 +13,9 @@ buy.xml
|
||||
scan.lua
|
||||
stack.lua
|
||||
post.lua
|
||||
list.lua
|
||||
info.xml
|
||||
completion.xml
|
||||
list.xml
|
||||
|
||||
options.xml
|
||||
about.xml
|
||||
|
||||
@@ -284,18 +284,6 @@ function AuxBuyEntry_OnClick(entry_index)
|
||||
end
|
||||
end
|
||||
|
||||
function Aux.buy.icon_on_enter()
|
||||
local scroll_frame = getglobal(this:GetParent():GetParent():GetName().."ScrollFrame")
|
||||
local index = this:GetParent():GetID() + FauxScrollFrame_GetOffset(scroll_frame)
|
||||
local entry = entries[index]
|
||||
|
||||
Aux.info.set_game_tooltip(this, entry.tooltip, 'ANCHOR_RIGHT')
|
||||
|
||||
if(EnhTooltip ~= nil) then
|
||||
EnhTooltip.TooltipCall(GameTooltip, entry.name, entry.hyperlink, entry.quality, entry.stack_size)
|
||||
end
|
||||
end
|
||||
|
||||
-----------------------------------------
|
||||
|
||||
function process_auction(auction_item, current_page)
|
||||
|
||||
@@ -99,11 +99,10 @@
|
||||
</OnTabPressed>
|
||||
<OnEnterPressed>
|
||||
if Aux.completion.highlighted() then
|
||||
Aux.completion.select(this)
|
||||
else
|
||||
this:ClearFocus()
|
||||
Aux.buy.SearchButton_onclick()
|
||||
Aux.completion.close(this)
|
||||
end
|
||||
this:ClearFocus()
|
||||
Aux.buy.SearchButton_onclick()
|
||||
</OnEnterPressed>
|
||||
</Scripts>
|
||||
</EditBox>
|
||||
|
||||
+36
-18
@@ -7,7 +7,11 @@ local leven, fuzzy, populate_dropdown, toggle_dropdown, suggestions, highlight
|
||||
local item_names = {}
|
||||
|
||||
local current_suggestions = {}
|
||||
local selected_index
|
||||
local selected_index = 0
|
||||
|
||||
local current_input
|
||||
|
||||
local programmatically_set_input
|
||||
|
||||
|
||||
for item_id=1,30000 do
|
||||
@@ -26,9 +30,10 @@ function fuzzy(input)
|
||||
return function(item_name)
|
||||
local match = { string.find(strupper(item_name), pattern) }
|
||||
if match[1] then
|
||||
local rating = 1
|
||||
for i=3,getn(match) do
|
||||
rating = rating * (strlen(match[i]) + 1)
|
||||
local rating = 0
|
||||
for i=4,getn(match)-1 do
|
||||
if strlen(match[i]) == 0 then
|
||||
rating = rating + 1
|
||||
end
|
||||
return rating
|
||||
end
|
||||
@@ -59,7 +64,8 @@ function suggestions(input)
|
||||
else
|
||||
if best[1].rating > rating then
|
||||
best[1] = { name=name, rating=rating }
|
||||
sort(best, function(a, b) return a.rating < b.rating end)
|
||||
Aux.util.merge_sort(best, function(a, b) return Aux.util.compare(strlen(a), strlen(b)) end)
|
||||
Aux.util.merge_sort(best, function(a, b) return Aux.util.compare(strlen(b.rating), strlen(a.rating)) end)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -69,13 +75,22 @@ function suggestions(input)
|
||||
end
|
||||
|
||||
function Aux.completion.make_suggestions(input_box)
|
||||
selected_index = nil
|
||||
update_highlighting()
|
||||
|
||||
local input = input_box:GetText()
|
||||
if input == '' then
|
||||
if programmatically_set_input == input then
|
||||
programmatically_set_input = nil
|
||||
return
|
||||
end
|
||||
programmatically_set_input = nil
|
||||
|
||||
current_input = input
|
||||
selected_index = 0
|
||||
update_highlighting()
|
||||
|
||||
if current_input == '' then
|
||||
current_suggestions = {}
|
||||
else
|
||||
current_suggestions = suggestions(input)
|
||||
current_suggestions = suggestions(current_input)
|
||||
UIDropDownMenu_Initialize(AuxCompletionDropDown, function() populate_dropdown(input_box, current_suggestions) end)
|
||||
end
|
||||
|
||||
@@ -87,25 +102,28 @@ end
|
||||
|
||||
function Aux.completion.highlight_next(input_box)
|
||||
if getn(current_suggestions) > 0 then
|
||||
selected_index = selected_index and math.mod(selected_index, getn(current_suggestions)) + 1 or 1
|
||||
selected_index = selected_index > 0 and math.mod(selected_index + 1, getn(current_suggestions) + 1) or 1
|
||||
snipe.log(selected_index .. 'after')
|
||||
snipe.log(current_input)
|
||||
update_highlighting()
|
||||
if selected_index == 0 then
|
||||
Aux.completion.set_quietly(input_box, current_input)
|
||||
else
|
||||
Aux.completion.set_quietly(input_box, current_suggestions[selected_index])
|
||||
end
|
||||
end
|
||||
update_highlighting()
|
||||
end
|
||||
|
||||
function Aux.completion.highlighted()
|
||||
return selected_index ~= nil
|
||||
return selected_index ~= 0
|
||||
end
|
||||
|
||||
function Aux.completion.select(input_box)
|
||||
Aux.completion.set_quietly(input_box, current_suggestions[selected_index])
|
||||
selected_index = nil
|
||||
update_highlighting()
|
||||
function Aux.completion.close()
|
||||
CloseDropDownMenus(1)
|
||||
end
|
||||
|
||||
function Aux.completion.set_quietly(edit_box, text)
|
||||
local orig = edit_box:GetScript('OnTextChanged')
|
||||
edit_box:SetScript('OnTextChanged', function() edit_box:SetScript('OnTextChanged', orig) end)
|
||||
programmatically_set_input = text
|
||||
edit_box:SetText(text)
|
||||
end
|
||||
|
||||
|
||||
@@ -87,6 +87,10 @@ function Aux.info.set_game_tooltip(owner, tooltip, anchor)
|
||||
GameTooltip:AddDoubleLine(line[1].text, line[2].text, line[1].r, line[1].b, line[1].g, line[2].r, line[2].b, line[2].g, true)
|
||||
end
|
||||
GameTooltip:Show()
|
||||
|
||||
-- if EnhTooltip and entry then
|
||||
-- EnhTooltip.TooltipCall(GameTooltip, entry.name, entry.hyperlink, entry.quality, entry.stack_size)
|
||||
-- end
|
||||
end
|
||||
|
||||
function Aux.info.tooltip(setter)
|
||||
|
||||
@@ -2,155 +2,4 @@
|
||||
|
||||
<Script file="list.lua"/>
|
||||
|
||||
<Button name="ListItemTemplate" hidden="false" virtual="true">
|
||||
<Size><AbsDimension x="615" y="16"/></Size>
|
||||
<Layers>
|
||||
<Layer level="BORDER">
|
||||
<FontString name="$parentColumn1" inherits="GameFontHighlight" wraponspaces="false" justifyH="RIGHT">
|
||||
<Size><AbsDimension x="100" y="16"/></Size>
|
||||
<Anchors><Anchor point="TOPLEFT"><Offset><AbsDimension x="-2" y="0"/></Offset></Anchor></Anchors>
|
||||
</FontString>
|
||||
<FontString name="$parentColumn2" inherits="GameFontHighlight" wraponspaces="false" justifyH="LEFT">
|
||||
<Size><AbsDimension x="100" y="16"/></Size>
|
||||
<Anchors><Anchor point="TOPLEFT" relativeTo="$parentColumn1" relativePoint="TOPRIGHT"><Offset><AbsDimension x="3" y="0"/></Offset></Anchor></Anchors>
|
||||
</FontString>
|
||||
<FontString name="$parentColumn3" inherits="GameFontHighlight" wraponspaces="false" justifyH="RIGHT">
|
||||
<Size><AbsDimension x="100" y="16"/></Size>
|
||||
<Anchors><Anchor point="TOPLEFT" relativeTo="$parentColumn2" relativePoint="TOPRIGHT"><Offset><AbsDimension x="3" y="0"/></Offset></Anchor></Anchors>
|
||||
</FontString>
|
||||
<FontString name="$parentColumn4" inherits="GameFontHighlight" wraponspaces="false" justifyH="CENTER">
|
||||
<Size><AbsDimension x="100" y="16"/></Size>
|
||||
<Anchors><Anchor point="TOPLEFT" relativeTo="$parentColumn3" relativePoint="TOPRIGHT"><Offset><AbsDimension x="3" y="0"/></Offset></Anchor></Anchors>
|
||||
</FontString>
|
||||
<FontString name="$parentColumn5" inherits="GameFontHighlight" wraponspaces="false" justifyH="LEFT">
|
||||
<Size><AbsDimension x="100" y="16"/></Size>
|
||||
<Anchors><Anchor point="TOPLEFT" relativeTo="$parentColumn4" relativePoint="TOPRIGHT"><Offset><AbsDimension x="3" y="0"/></Offset></Anchor></Anchors>
|
||||
</FontString>
|
||||
<FontString name="$parentColumn6" inherits="GameFontHighlight" wraponspaces="false" justifyH="RIGHT">
|
||||
<Size><AbsDimension x="100" y="16"/></Size>
|
||||
<Anchors><Anchor point="TOPLEFT" relativeTo="$parentColumn5" relativePoint="TOPRIGHT"><Offset><AbsDimension x="3" y="0"/></Offset></Anchor></Anchors>
|
||||
</FontString>
|
||||
<FontString name="$parentColumn7" inherits="GameFontHighlight" wraponspaces="false" justifyH="RIGHT">
|
||||
<Size><AbsDimension x="100" y="16"/></Size>
|
||||
<Anchors><Anchor point="TOPLEFT" relativeTo="$parentColumn6" relativePoint="TOPRIGHT"><Offset><AbsDimension x="3" y="0"/></Offset></Anchor></Anchors>
|
||||
</FontString>
|
||||
</Layer>
|
||||
</Layers>
|
||||
<Frames>
|
||||
<Button name="$parentColumn2Item">
|
||||
<Size><AbsDimension x="16" y="16"/></Size>
|
||||
<Anchors><Anchor point="TOPLEFT" relativeTo="$parentColumn2"><Offset><AbsDimension x="0" y="0"/></Offset></Anchor></Anchors>
|
||||
<Layers>
|
||||
<Layer level="BORDER">
|
||||
<Texture name="$parentIconTexture"/>
|
||||
<FontString name="$parentCount" inherits="NumberFontNormal" justifyH="RIGHT" hidden="true">
|
||||
<Anchors>
|
||||
<Anchor point="BOTTOMRIGHT">
|
||||
<Offset>
|
||||
<AbsDimension x="-5" y="2"/>
|
||||
</Offset>
|
||||
</Anchor>
|
||||
</Anchors>
|
||||
</FontString>
|
||||
<FontString name="$parentStock" inherits="NumberFontNormalYellow" justifyH="LEFT" hidden="true">
|
||||
<Anchors>
|
||||
<Anchor point="TOPLEFT">
|
||||
<Offset>
|
||||
<AbsDimension x="0" y="-2"/>
|
||||
</Offset>
|
||||
</Anchor>
|
||||
</Anchors>
|
||||
</FontString>
|
||||
</Layer>
|
||||
</Layers>
|
||||
<PushedTexture file="Interface\Buttons\UI-Quickslot-Depress"/>
|
||||
<HighlightTexture file="Interface\Buttons\ButtonHilight-Square" alphaMode="ADD"/>
|
||||
<Scripts>
|
||||
<OnEnter>
|
||||
Aux.buy.icon_on_enter()
|
||||
</OnEnter>
|
||||
<OnLeave>
|
||||
GameTooltip:Hide()
|
||||
</OnLeave>
|
||||
<OnClick>
|
||||
AuxBuyEntry_OnClick(this:GetParent())
|
||||
</OnClick>
|
||||
</Scripts>
|
||||
</Button>
|
||||
</Frames>
|
||||
</Button>
|
||||
|
||||
<Button name="ListSortButtonTemplate" virtual="true">
|
||||
<Layers>
|
||||
<Layer level="BACKGROUND">
|
||||
<Texture name="$parentLeft" file="Interface\FriendsFrame\WhoFrame-ColumnTabs">
|
||||
<Size>
|
||||
<AbsDimension x="5" y="24"/>
|
||||
</Size>
|
||||
<Anchors>
|
||||
<Anchor point="TOPLEFT"/>
|
||||
</Anchors>
|
||||
<TexCoords left="0" right="0.078125" top="0" bottom="0.59375"/>
|
||||
</Texture>
|
||||
<Texture name="$parentRight" file="Interface\FriendsFrame\WhoFrame-ColumnTabs">
|
||||
<Size>
|
||||
<AbsDimension x="4" y="24"/>
|
||||
</Size>
|
||||
<Anchors>
|
||||
<Anchor point="TOPRIGHT"/>
|
||||
</Anchors>
|
||||
<TexCoords left="0.90625" right="0.96875" top="0" bottom="0.59375"/>
|
||||
</Texture>
|
||||
<Texture name="$parentMiddle" file="Interface\FriendsFrame\WhoFrame-ColumnTabs">
|
||||
<Size>
|
||||
<AbsDimension x="10" y="24"/>
|
||||
</Size>
|
||||
<Anchors>
|
||||
<Anchor point="LEFT" relativeTo="$parentLeft" relativePoint="RIGHT"/>
|
||||
<Anchor point="RIGHT" relativeTo="$parentRight" relativePoint="LEFT"/>
|
||||
</Anchors>
|
||||
<TexCoords left="0.078125" right="0.90625" top="0" bottom="0.59375"/>
|
||||
</Texture>
|
||||
</Layer>
|
||||
</Layers>
|
||||
<NormalText name="$parentText" inherits="GameFontHighlightSmall">
|
||||
<Anchors>
|
||||
<Anchor point="LEFT">
|
||||
<Offset>
|
||||
<AbsDimension x="8" y="0"/>
|
||||
</Offset>
|
||||
</Anchor>
|
||||
</Anchors>
|
||||
</NormalText>
|
||||
<NormalTexture name="$parentArrow" hidden="true" file="Interface\Buttons\UI-SortArrow">
|
||||
<Size>
|
||||
<AbsDimension x="9" y="8"/>
|
||||
</Size>
|
||||
<Anchors>
|
||||
<Anchor point="LEFT" relativeTo="$parentText" relativePoint="RIGHT">
|
||||
<Offset>
|
||||
<AbsDimension x="3" y="-2"/>
|
||||
</Offset>
|
||||
</Anchor>
|
||||
</Anchors>
|
||||
<TexCoords left="0" right="0.5625" top="0" bottom="1.0"/>
|
||||
</NormalTexture>
|
||||
<HighlightTexture file="Interface\PaperDollInfoFrame\UI-Character-Tab-Highlight" alphaMode="ADD">
|
||||
<Size>
|
||||
<AbsDimension x="5" y="24"/>
|
||||
</Size>
|
||||
<Anchors>
|
||||
<Anchor point="LEFT">
|
||||
<Offset>
|
||||
<AbsDimension x="0" y="0"/>
|
||||
</Offset>
|
||||
</Anchor>
|
||||
<Anchor point="RIGHT">
|
||||
<Offset>
|
||||
<AbsDimension x="4" y="0"/>
|
||||
</Offset>
|
||||
</Anchor>
|
||||
</Anchors>
|
||||
</HighlightTexture>
|
||||
</Button>
|
||||
</Ui>
|
||||
Reference in New Issue
Block a user