diff --git a/completion.lua b/completion.lua index 723bbc4..f2437a5 100644 --- a/completion.lua +++ b/completion.lua @@ -68,9 +68,7 @@ function Aux.completion.completor(edit_box) value = suggestion.value, notCheckable = true, func = function() --- self.set_quietly(text) - Aux.item_search_frame.set_item(this.value) - AuxItemSearchFrameItemItemInputBox:ClearFocus() + self.set_quietly(text) end, } end @@ -140,10 +138,9 @@ function Aux.completion.completor(edit_box) index = index > 0 and math.mod(index + 1, getn(suggestions) + 1) or 1 update_highlighting() if index == 0 then --- self.set_quietly(input) + self.set_quietly(input) else --- self.set_quietly(suggestions[index].text) - Aux.item_search_frame.set_item(suggestions[index].value) + self.set_quietly(suggestions[index].text) end end end @@ -154,13 +151,115 @@ function Aux.completion.completor(edit_box) index = index > 0 and index - 1 or getn(suggestions) update_highlighting() if index == 0 then --- self.set_quietly(input) + self.set_quietly(input) else --- self.set_quietly(suggestions[index].text) - Aux.item_search_frame.set_item(suggestions[index].value) + self.set_quietly(suggestions[index].text) end end end return self end + +function Aux.completion.selector(edit_box) + local self = {} + + local suggestions = {} + local index = 0 + local input + + local fill_dropdown, update_dropdown, update_highlighting + + function fill_dropdown() + for i, suggestion in ipairs(suggestions) do + local text = suggestion.text + UIDropDownMenu_AddButton{ + text = suggestion.display_text, + value = i, + notCheckable = true, + func = function() + index = this.value + AuxItemSearchFrameItemItemInputBox:ClearFocus() + end, + } + end + end + + function update_dropdown() + function toggle() + ToggleDropDownMenu(1, nil, AuxCompletionDropDown, edit_box, -12, 4) + end + + if DropDownList1:IsVisible() then + toggle() + end + toggle() + end + + function update_highlighting() + for i=1,32 do + local highlight = getglobal('DropDownList1Button' .. i .. 'Highlight') + if i == index then + highlight:Show() + else + highlight:Hide() + end + end + end + + function self.close() + CloseDropDownMenus(1) + end + + function self.open() + local _, owner = DropDownList1:GetPoint() + return DropDownList1:IsVisible() and owner == edit_box + end + + function self.suggest() + local new_input = edit_box:GetText() + + input = new_input + + if input == '' then + suggestions = {} + else + suggestions = generate_suggestions(input) + UIDropDownMenu_Initialize(AuxCompletionDropDown, function() fill_dropdown() end) + end + + index = 1 + update_highlighting() + + update_dropdown() + end + + function self.next() + update_dropdown() + if getn(suggestions) > 0 then + index = math.mod(index, getn(suggestions)) + 1 + update_highlighting() + Aux.item_search_frame.set_item(suggestions[index].value) + end + end + + function self.previous() + update_dropdown() + if getn(suggestions) > 0 then + index = index > 1 and index - 1 or getn(suggestions) + update_highlighting() + Aux.item_search_frame.set_item(suggestions[index].value) + end + end + + function self.selected_value() + return suggestions[index] and suggestions[index].value + end + + function self.clear() + index = 1 + suggestions = {} + end + + return self +end diff --git a/completion.xml b/completion.xml index c1338bc..4932b22 100644 --- a/completion.xml +++ b/completion.xml @@ -4,5 +4,9 @@ + + this.isCounting = false + UIDropDownMenu_OnUpdate(arg1) + \ No newline at end of file diff --git a/core.lua b/core.lua index 21771d8..2e885f8 100644 --- a/core.lua +++ b/core.lua @@ -32,20 +32,21 @@ function Aux_OnLoad() end function Aux_OnEvent() - if event == "VARIABLES_LOADED" then + if event == 'VARIABLES_LOADED' then Aux_OnLoad() - elseif event == "ADDON_LOADED" then + elseif event == 'ADDON_LOADED' then Aux_OnAddonLoaded() - elseif event == "AUCTION_HOUSE_SHOW" then + elseif event == 'AUCTION_HOUSE_SHOW' then Aux_OnAuctionHouseShow() - elseif event == "AUCTION_HOUSE_CLOSED" then + elseif event == 'AUCTION_HOUSE_CLOSED' then Aux_OnAuctionHouseClosed() - end + elseif event == 'AUCTION_OWNED_LIST_UPDATE' then + Aux.current_owner_page = Aux.last_owner_page_requested + end end function Aux_OnAddonLoaded() if string.lower(arg1) == "blizzard_auctionui" then - AuctionFrame:SetScript('OnHide', nil) Aux_SetupHookFunctions() end end @@ -102,15 +103,23 @@ end function Aux_SetupHookFunctions() + local blizzard_ui_on_hide = function() + Aux.blizzard_ui_shown = false + end + AuctionFrame:SetScript('OnHide', blizzard_ui_on_hide) + Aux.orig.AuctionFrame_OnShow = AuctionFrame_OnShow - -- TODO for some reason this breaks the auction house functionality --- AuctionFrame_OnShow = function() --- if not Aux.blizzard_ui_shown then --- HideUIPanel(AuctionFrame) --- else --- return Aux.orig.AuctionFrame_OnShow() --- end --- end + AuctionFrame_OnShow = function() + if not Aux.blizzard_ui_shown then + Aux.control.as_soon_as(function() return AuctionFrame:GetScript('OnHide') == blizzard_ui_on_hide end, function() + HideUIPanel(AuctionFrame) + end) + end + return Aux.orig.AuctionFrame_OnShow() + end + + Aux.orig.GetOwnerAuctionItems = GetOwnerAuctionItems + GetOwnerAuctionItems = Aux.GetOwnerAuctionItems Aux.orig.PickupContainerItem = PickupContainerItem PickupContainerItem = Aux.PickupContainerItem @@ -123,6 +132,11 @@ function Aux_SetupHookFunctions() end +function Aux.GetOwnerAuctionItems(page) + Aux.last_owner_page_requested = page + return Aux.orig.GetOwnerAuctionItems(page) +end + function Aux.AuctionFrameAuctions_OnEvent() if AuctionFrameAuctions:IsVisible() then Aux.orig.AuctionFrameAuctions_OnEvent() @@ -147,7 +161,7 @@ function Aux_OnAuctionHouseClosed() Aux.stack.stop() Aux.scan.abort() - Aux.buy.on_close() + Aux.filter_search_frame.on_close() Aux.sell.on_close() AuxFrame:Hide() @@ -158,7 +172,7 @@ function Aux.on_tab_click(index) Aux.stack.stop() Aux.scan.abort(function() Aux.item_search_frame.on_close() - Aux.buy.on_close() + Aux.filter_search_frame.on_close() Aux.sell.on_close() Aux.manage_frame.on_close() Aux.history.on_close() @@ -168,7 +182,7 @@ function Aux.on_tab_click(index) end AuxItemSearchFrame:Hide() - AuxBuyFrame:Hide() + AuxFilterSearchFrame:Hide() AuxSellFrame:Hide() AuxManageFrame:Hide() AuxHistoryFrame:Hide() @@ -177,7 +191,7 @@ function Aux.on_tab_click(index) AuxItemSearchFrame:Show() Aux.item_search_frame.on_open() elseif index == 2 then - AuxBuyFrame:Show() + AuxFilterSearchFrame:Show() Aux.filter_search_frame.on_open() elseif index == 3 then AuxSellFrame:Show() @@ -221,23 +235,23 @@ function Aux_ContainerFrameItemButton_OnClick(button) local bag, slot = this:GetParent():GetID(), this:GetID() local container_item = Aux.info.container_item(bag, slot) - if AuctionFrame:IsVisible() and button == "LeftButton" and container_item then - - if IsShiftKeyDown() - and not ChatFrameEditBox:IsVisible() - and AuxBuyFrame:IsVisible() - then - AuxBuyNameInputBox.completor.set_quietly(container_item.name) - return - elseif AUX_BUY_SHORTCUT and IsAltKeyDown() then - if not AuxBuyFrame:IsVisible() then - Aux.on_tab_click(1) - end - AuxBuyNameInputBox.completor.set_quietly(container_item.name) - Aux.buy.SearchButton_onclick() - return - end - end +-- if AuctionFrame:IsVisible() and button == "LeftButton" and container_item then +-- +-- if IsShiftKeyDown() +-- and not ChatFrameEditBox:IsVisible() +-- and AuxBuyFrame:IsVisible() +-- then +-- AuxBuyNameInputBox.completor.set_quietly(container_item.name) +-- return +-- elseif AUX_BUY_SHORTCUT and IsAltKeyDown() then +-- if not AuxBuyFrame:IsVisible() then +-- Aux.on_tab_click(1) +-- end +-- AuxBuyNameInputBox.completor.set_quietly(container_item.name) +-- Aux.filter_search_frame.start_search() +-- return +-- end +-- end return Aux.orig.ContainerFrameItemButton_OnClick(button) end diff --git a/core.xml b/core.xml index 3c660c9..483ac98 100644 --- a/core.xml +++ b/core.xml @@ -5,10 +5,11 @@ - this:RegisterEvent("VARIABLES_LOADED") - this:RegisterEvent("ADDON_LOADED") - this:RegisterEvent("AUCTION_HOUSE_SHOW") - this:RegisterEvent("AUCTION_HOUSE_CLOSED") + this:RegisterEvent('VARIABLES_LOADED') + this:RegisterEvent('ADDON_LOADED') + this:RegisterEvent('AUCTION_HOUSE_SHOW') + this:RegisterEvent('AUCTION_HOUSE_CLOSED') + this:RegisterEvent('AUCTION_OWNED_LIST_UPDATE') Aux_OnEvent() @@ -18,7 +19,7 @@ -