restructuring
This commit is contained in:
@@ -0,0 +1,125 @@
|
||||
local private, public = {}, {}
|
||||
Aux.auctions_frame = public
|
||||
|
||||
local auction_records
|
||||
|
||||
function public.on_load()
|
||||
public.create_frames(private, public)
|
||||
end
|
||||
|
||||
function private.update_listing()
|
||||
if not AuxAuctionsFrame:IsVisible() then
|
||||
return
|
||||
end
|
||||
|
||||
private.listing:SetDatabase(auction_records)
|
||||
end
|
||||
|
||||
function public.on_open()
|
||||
public.scan_auctions()
|
||||
end
|
||||
|
||||
function public.on_close()
|
||||
end
|
||||
|
||||
function public.scan_auctions()
|
||||
|
||||
private.status_bar:update_status(0,0)
|
||||
private.status_bar:set_text('Scanning auctions...')
|
||||
|
||||
auction_records = {}
|
||||
private.update_listing()
|
||||
Aux.scan.start{
|
||||
type = 'owner',
|
||||
queries = {{ blizzard_query = {} }},
|
||||
on_page_loaded = function(page, total_pages)
|
||||
private.status_bar:update_status(100 * (page - 1) / total_pages, 0)
|
||||
private.status_bar:set_text(format('Scanning (Page %d / %d)', page, total_pages))
|
||||
end,
|
||||
on_auction = function(auction_record)
|
||||
tinsert(auction_records, auction_record)
|
||||
end,
|
||||
on_complete = function()
|
||||
private.status_bar:update_status(100, 100)
|
||||
private.status_bar:set_text('Done Scanning')
|
||||
private.update_listing()
|
||||
end,
|
||||
on_abort = function()
|
||||
private.status_bar:update_status(100, 100)
|
||||
private.status_bar:set_text('Done Scanning')
|
||||
end,
|
||||
}
|
||||
end
|
||||
|
||||
function private.test(record)
|
||||
return function(index)
|
||||
local auction_info = Aux.info.auction(index, 'owner')
|
||||
return auction_info and auction_info.search_signature == record.search_signature
|
||||
end
|
||||
end
|
||||
|
||||
function private.record_remover(record)
|
||||
return function()
|
||||
private.listing:RemoveAuctionRecord(record)
|
||||
end
|
||||
end
|
||||
|
||||
do
|
||||
local scan_id
|
||||
local IDLE, SEARCHING, FOUND = {}, {}, {}
|
||||
local state = IDLE
|
||||
local found_index
|
||||
|
||||
function private.find_auction(record)
|
||||
if not private.listing:ContainsRecord(record) then
|
||||
return
|
||||
end
|
||||
|
||||
Aux.scan.abort(scan_id)
|
||||
state = SEARCHING
|
||||
scan_id = Aux.scan_util.find(
|
||||
record,
|
||||
private.status_bar,
|
||||
function()
|
||||
state = IDLE
|
||||
end,
|
||||
function()
|
||||
state = IDLE
|
||||
private.record_remover(record)()
|
||||
end,
|
||||
function(index)
|
||||
state = FOUND
|
||||
found_index = index
|
||||
|
||||
private.cancel_button:SetScript('OnClick', function()
|
||||
if private.test(record)(index) and private.listing:ContainsRecord(record) then
|
||||
Aux.cancel_auction(index, private.record_remover(record))
|
||||
end
|
||||
end)
|
||||
private.cancel_button:Enable()
|
||||
end
|
||||
)
|
||||
end
|
||||
|
||||
function public.on_update()
|
||||
if state == IDLE or state == SEARCHING then
|
||||
private.cancel_button:Disable()
|
||||
end
|
||||
|
||||
if state == SEARCHING then
|
||||
return
|
||||
end
|
||||
|
||||
local selection = private.listing:GetSelection()
|
||||
if not selection then
|
||||
state = IDLE
|
||||
elseif selection and state == IDLE then
|
||||
private.find_auction(selection.record)
|
||||
elseif state == FOUND and not private.test(selection.record)(found_index) then
|
||||
private.cancel_button:Disable()
|
||||
-- if not Aux.bid_in_progress() then
|
||||
state = IDLE
|
||||
-- end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,18 @@
|
||||
<Ui xsi:schemaLocation="http://www.blizzard.com/wow/ui/">
|
||||
<Frame name="AuxAuctionsFrame" hidden="true" parent="AuxFrame" setAllPoints="true">
|
||||
<Scripts>
|
||||
<OnUpdate>
|
||||
Aux.auctions_frame.on_update()
|
||||
</OnUpdate>
|
||||
</Scripts>
|
||||
<Frames>
|
||||
<Frame name="$parentListing" inherits="AuxFrameBoxTemplate">
|
||||
<Anchors>
|
||||
<Anchor point="TOP" relativeTo="AuxFrame"><Offset><AbsDimension x="0" y="-8"/></Offset></Anchor>
|
||||
<Anchor point="BOTTOMLEFT" relativeTo="AuxFrameContent"></Anchor>
|
||||
<Anchor point="BOTTOMRIGHT" relativeTo="AuxFrameContent"></Anchor>
|
||||
</Anchors>
|
||||
</Frame>
|
||||
</Frames>
|
||||
</Frame>
|
||||
</Ui>
|
||||
@@ -0,0 +1,43 @@
|
||||
function Aux.auctions_frame.create_frames(private, public)
|
||||
private.listing = Aux.auction_listing.CreateAuctionResultsTable(AuxAuctionsFrameListing, Aux.auction_listing.auctions_config)
|
||||
private.listing:SetSort(1,2,3,4,5,6,7,8)
|
||||
private.listing:Reset()
|
||||
private.listing:SetHandler('OnCellClick', function(cell, button)
|
||||
if IsAltKeyDown() and private.listing:GetSelection().record == cell.row.data.record and private.cancel_button:IsEnabled() then
|
||||
private.cancel_button:Click()
|
||||
end
|
||||
end)
|
||||
private.listing:SetHandler('OnSelectionChanged', function(rt, datum)
|
||||
if not datum then return end
|
||||
private.find_auction(datum.record)
|
||||
end)
|
||||
|
||||
do
|
||||
local status_bar = Aux.gui.status_bar(AuxAuctionsFrame)
|
||||
status_bar:SetWidth(265)
|
||||
status_bar:SetHeight(25)
|
||||
status_bar:SetPoint('TOPLEFT', AuxFrameContent, 'BOTTOMLEFT', 0, -6)
|
||||
status_bar:update_status(100, 100)
|
||||
status_bar:set_text('')
|
||||
private.status_bar = status_bar
|
||||
end
|
||||
do
|
||||
local btn = Aux.gui.button(AuxAuctionsFrame, 16)
|
||||
btn:SetPoint('TOPLEFT', private.status_bar, 'TOPRIGHT', 5, 0)
|
||||
btn:SetWidth(80)
|
||||
btn:SetHeight(24)
|
||||
btn:SetText('Cancel')
|
||||
btn:Disable()
|
||||
private.cancel_button = btn
|
||||
end
|
||||
do
|
||||
local btn = Aux.gui.button(AuxAuctionsFrame, 16)
|
||||
btn:SetPoint('TOPLEFT', private.cancel_button, 'TOPRIGHT', 5, 0)
|
||||
btn:SetWidth(80)
|
||||
btn:SetHeight(24)
|
||||
btn:SetText('Refresh')
|
||||
btn:SetScript('OnClick', function()
|
||||
public.scan_auctions()
|
||||
end)
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,141 @@
|
||||
local private, public = {}, {}
|
||||
Aux.bids_frame = public
|
||||
|
||||
local auction_records
|
||||
|
||||
function public.on_load()
|
||||
public.create_frames(private, public)
|
||||
end
|
||||
|
||||
function private.update_listing()
|
||||
if not AuxBidsFrame:IsVisible() then
|
||||
return
|
||||
end
|
||||
|
||||
private.listing:SetDatabase(auction_records)
|
||||
end
|
||||
|
||||
function public.on_open()
|
||||
public.scan_bids()
|
||||
end
|
||||
|
||||
function public.on_close()
|
||||
end
|
||||
|
||||
function public.scan_bids()
|
||||
|
||||
private.status_bar:update_status(0,0)
|
||||
private.status_bar:set_text('Scanning auctions...')
|
||||
|
||||
auction_records = {}
|
||||
private.update_listing()
|
||||
Aux.scan.start{
|
||||
type = 'bidder',
|
||||
queries = {{ blizzard_query = {} }},
|
||||
on_page_loaded = function(page, total_pages)
|
||||
private.status_bar:update_status(100 * (page - 1) / total_pages, 0)
|
||||
private.status_bar:set_text(format('Scanning (Page %d / %d)', page, total_pages))
|
||||
end,
|
||||
on_auction = function(auction_record)
|
||||
tinsert(auction_records, auction_record)
|
||||
end,
|
||||
on_complete = function()
|
||||
private.status_bar:update_status(100, 100)
|
||||
private.status_bar:set_text('Done Scanning')
|
||||
private.update_listing()
|
||||
end,
|
||||
on_abort = function()
|
||||
private.status_bar:update_status(100, 100)
|
||||
private.status_bar:set_text('Done Scanning')
|
||||
end,
|
||||
}
|
||||
end
|
||||
|
||||
function private.test(record)
|
||||
return function(index)
|
||||
local auction_info = Aux.info.auction(index, 'bidder')
|
||||
return auction_info and auction_info.search_signature == record.search_signature
|
||||
end
|
||||
end
|
||||
|
||||
function private.record_remover(record)
|
||||
return function()
|
||||
private.listing:RemoveAuctionRecord(record)
|
||||
end
|
||||
end
|
||||
|
||||
do
|
||||
local scan_id
|
||||
local IDLE, SEARCHING, FOUND = {}, {}, {}
|
||||
local state = IDLE
|
||||
local found_index
|
||||
|
||||
function private.find_auction(record)
|
||||
if not private.listing:ContainsRecord(record) then
|
||||
return
|
||||
end
|
||||
|
||||
Aux.scan.abort(scan_id)
|
||||
state = SEARCHING
|
||||
scan_id = Aux.scan_util.find(
|
||||
record,
|
||||
private.status_bar,
|
||||
function()
|
||||
state = IDLE
|
||||
end,
|
||||
function()
|
||||
state = IDLE
|
||||
private.record_remover(record)()
|
||||
end,
|
||||
function(index)
|
||||
state = FOUND
|
||||
found_index = index
|
||||
|
||||
if not record.high_bidder then
|
||||
private.bid_button:SetScript('OnClick', function()
|
||||
if private.test(record)(index) and private.listing:ContainsRecord(record) then
|
||||
Aux.place_bid('bidder', index, record.bid_price, record.bid_price < record.buyout_price and function()
|
||||
Aux.info.bid_update(record)
|
||||
private.listing:SetDatabase()
|
||||
end or private.record_remover(record))
|
||||
end
|
||||
end)
|
||||
private.bid_button:Enable()
|
||||
end
|
||||
|
||||
if record.buyout_price > 0 then
|
||||
private.buyout_button:SetScript('OnClick', function()
|
||||
if private.test(record)(index) and private.listing:ContainsRecord(record) then
|
||||
Aux.place_bid('bidder', index, record.buyout_price, private.record_remover(record))
|
||||
end
|
||||
end)
|
||||
private.buyout_button:Enable()
|
||||
end
|
||||
end
|
||||
)
|
||||
end
|
||||
|
||||
function public.on_update()
|
||||
if state == IDLE or state == SEARCHING then
|
||||
private.buyout_button:Disable()
|
||||
private.bid_button:Disable()
|
||||
end
|
||||
|
||||
if state == SEARCHING then
|
||||
return
|
||||
end
|
||||
|
||||
local selection = private.listing:GetSelection()
|
||||
if not selection then
|
||||
state = IDLE
|
||||
elseif selection and state == IDLE then
|
||||
private.find_auction(selection.record)
|
||||
elseif state == FOUND and not private.test(selection.record)(found_index) then
|
||||
private.buyout_button:Disable()
|
||||
private.bid_button:Disable()
|
||||
if not Aux.bid_in_progress() then
|
||||
state = IDLE
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,18 @@
|
||||
<Ui xsi:schemaLocation="http://www.blizzard.com/wow/ui/">
|
||||
<Frame name="AuxBidsFrame" hidden="true" parent="AuxFrame" setAllPoints="true">
|
||||
<Scripts>
|
||||
<OnUpdate>
|
||||
Aux.bids_frame.on_update()
|
||||
</OnUpdate>
|
||||
</Scripts>
|
||||
<Frames>
|
||||
<Frame name="$parentListing" inherits="AuxFrameBoxTemplate">
|
||||
<Anchors>
|
||||
<Anchor point="TOP" relativeTo="AuxFrame"><Offset><AbsDimension x="0" y="-8"/></Offset></Anchor>
|
||||
<Anchor point="BOTTOMLEFT" relativeTo="AuxFrameContent"></Anchor>
|
||||
<Anchor point="BOTTOMRIGHT" relativeTo="AuxFrameContent"></Anchor>
|
||||
</Anchors>
|
||||
</Frame>
|
||||
</Frames>
|
||||
</Frame>
|
||||
</Ui>
|
||||
@@ -0,0 +1,56 @@
|
||||
function Aux.bids_frame.create_frames(private, public)
|
||||
private.listing = Aux.auction_listing.CreateAuctionResultsTable(AuxBidsFrameListing, Aux.auction_listing.bids_config)
|
||||
private.listing:SetSort(1,2,3,4,5,6,7,8)
|
||||
private.listing:Reset()
|
||||
private.listing:SetHandler('OnCellClick', function(cell, button)
|
||||
if IsAltKeyDown() and private.listing:GetSelection().record == cell.row.data.record then
|
||||
if button == 'LeftButton' and private.buyout_button:IsEnabled() then
|
||||
private.buyout_button:Click()
|
||||
elseif button == 'RightButton' and private.bid_button:IsEnabled() then
|
||||
private.bid_button:Click()
|
||||
end
|
||||
end
|
||||
end)
|
||||
private.listing:SetHandler('OnSelectionChanged', function(rt, datum)
|
||||
if not datum then return end
|
||||
private.find_auction(datum.record)
|
||||
end)
|
||||
|
||||
do
|
||||
local status_bar = Aux.gui.status_bar(AuxBidsFrame)
|
||||
status_bar:SetWidth(265)
|
||||
status_bar:SetHeight(25)
|
||||
status_bar:SetPoint('TOPLEFT', AuxFrameContent, 'BOTTOMLEFT', 0, -6)
|
||||
status_bar:update_status(100, 0)
|
||||
status_bar:set_text('')
|
||||
private.status_bar = status_bar
|
||||
end
|
||||
do
|
||||
local btn = Aux.gui.button(AuxBidsFrame, 16)
|
||||
btn:SetPoint('TOPLEFT', private.status_bar, 'TOPRIGHT', 5, 0)
|
||||
btn:SetWidth(80)
|
||||
btn:SetHeight(24)
|
||||
btn:SetText('Bid')
|
||||
btn:Disable()
|
||||
private.bid_button = btn
|
||||
end
|
||||
do
|
||||
local btn = Aux.gui.button(AuxBidsFrame, 16)
|
||||
btn:SetPoint('TOPLEFT', private.bid_button, 'TOPRIGHT', 5, 0)
|
||||
btn:SetWidth(80)
|
||||
btn:SetHeight(24)
|
||||
btn:SetText('Buyout')
|
||||
btn:Disable()
|
||||
private.buyout_button = btn
|
||||
end
|
||||
do
|
||||
local btn = Aux.gui.button(AuxBidsFrame, 16)
|
||||
btn:SetPoint('TOPLEFT', private.buyout_button, 'TOPRIGHT', 5, 0)
|
||||
btn:SetWidth(80)
|
||||
btn:SetHeight(24)
|
||||
btn:SetText('Refresh')
|
||||
btn:SetScript('OnClick', function()
|
||||
public.scan_bids()
|
||||
end)
|
||||
end
|
||||
end
|
||||
+678
@@ -0,0 +1,678 @@
|
||||
local m = {}
|
||||
Aux.gui = m
|
||||
|
||||
--TSM.designDefaults = {
|
||||
-- frameColors = {
|
||||
-- frameBG = { backdrop = { 24, 24, 24, .93 }, border = { 30, 30, 30, 1 } },
|
||||
-- frame = { backdrop = { 24, 24, 24, 1 }, border = { 255, 255, 255, 0.03 } },
|
||||
-- content = { backdrop = { 42, 42, 42, 1 }, border = { 0, 0, 0, 0 } },
|
||||
-- },
|
||||
-- textColors = {
|
||||
-- iconRegion = { enabled = { 249, 255, 247, 1 } },
|
||||
-- text = { enabled = { 255, 254, 250, 1 }, disabled = { 147, 151, 139, 1 } },
|
||||
-- label = { enabled = { 216, 225, 211, 1 }, disabled = { 150, 148, 140, 1 } },
|
||||
-- title = { enabled = { 132, 219, 9, 1 } },
|
||||
-- link = { enabled = { 49, 56, 133, 1 } },
|
||||
-- },
|
||||
-- inlineColors = {
|
||||
-- link = { 153, 255, 255, 1 },
|
||||
-- link2 = { 153, 255, 255, 1 },
|
||||
-- category = { 36, 106, 36, 1 },
|
||||
-- category2 = { 85, 180, 8, 1 },
|
||||
-- tooltip = { 130, 130, 250, 1 },
|
||||
-- },
|
||||
-- edgeSize = 1.5,
|
||||
-- fonts = {
|
||||
-- content = "Fonts\\ARIALN.TTF",
|
||||
-- bold = "Interface\\Addons\\TradeSkillMaster\\Media\\DroidSans-Bold.ttf",
|
||||
-- },
|
||||
-- fontSizes = {
|
||||
-- normal = 15,
|
||||
-- medium = 13,
|
||||
-- small = 12,
|
||||
-- },
|
||||
--}
|
||||
|
||||
m.config = {
|
||||
link_color = { 153, 255, 255, 1 },
|
||||
link_color2 = { 153, 255, 255, 1 }, -- TODO inline color needs 255, others need /255
|
||||
edge_size = 1.5,
|
||||
frame_color = {24/255, 24/255, 24/255, 1},
|
||||
frame_border_color = {1, 1, 1, .03},
|
||||
content_color = {42/255, 42/255, 42/255, 1},
|
||||
content_border_color = {0, 0, 0, 0},
|
||||
content_font = [[Fonts\ARIALN.TTF]],
|
||||
-- content_font = [[Interface\AddOns\Aux-Addon\ARIALN.TTF]],
|
||||
normal_font_size = 15,
|
||||
normal_button_font_size = 16, -- 15 not working for some clients
|
||||
text_color = { enabled = { 255/255, 254/255, 250/255, 1 }, disabled = { 147/255, 151/255, 139/255, 1 } },
|
||||
label_color = { enabled = { 216/255, 225/255, 211/255, 1 }, disabled = { 150/255, 148/255, 140/255, 1 } },
|
||||
|
||||
}
|
||||
|
||||
function m.inline_color(color)
|
||||
local r, g, b, a = unpack(color)
|
||||
return format("|c%02X%02X%02X%02X", a, r, g, b)
|
||||
end
|
||||
|
||||
function m.panel(parent, name)
|
||||
local panel = CreateFrame('Frame', name, parent)
|
||||
panel:SetBackdrop({bgFile='Interface\\Buttons\\WHITE8X8', edgeFile='Interface\\Buttons\\WHITE8X8', edgeSize=m.config.edge_size})
|
||||
panel:SetBackdropColor(unpack(m.config.frame_color))
|
||||
panel:SetBackdropBorderColor(unpack(m.config.frame_border_color))
|
||||
return panel
|
||||
end
|
||||
|
||||
function m.button(parent, text_height, name)
|
||||
local button = CreateFrame('Button', name, parent)
|
||||
button:SetBackdrop({bgFile='Interface\\Buttons\\WHITE8X8', edgeFile='Interface\\Buttons\\WHITE8X8', edgeSize=m.config.edge_size})
|
||||
button:SetBackdropColor(unpack(m.config.content_color))
|
||||
button:SetBackdropBorderColor(unpack(m.config.content_border_color))
|
||||
local highlight = button:CreateTexture(nil, 'HIGHLIGHT')
|
||||
highlight:SetAllPoints()
|
||||
highlight:SetTexture(1, 1, 1, .2)
|
||||
highlight:SetBlendMode('BLEND')
|
||||
button.highlight = highlight
|
||||
do
|
||||
local label = button:CreateFontString()
|
||||
label:SetFont(m.config.content_font, text_height)
|
||||
label:SetPoint('CENTER', 0, 0)
|
||||
label:SetJustifyH('CENTER')
|
||||
label:SetJustifyV('CENTER')
|
||||
label:SetHeight(text_height)
|
||||
label:SetTextColor(unpack(m.config.text_color.enabled))
|
||||
button:SetFontString(label)
|
||||
end
|
||||
button.default_Enable = button.Enable
|
||||
function button:Enable()
|
||||
self:GetFontString():SetTextColor(unpack(m.config.text_color.enabled))
|
||||
return self:default_Enable()
|
||||
end
|
||||
button.default_Disable = button.Disable
|
||||
function button:Disable()
|
||||
self:GetFontString():SetTextColor(unpack(m.config.text_color.disabled))
|
||||
return self:default_Disable()
|
||||
end
|
||||
|
||||
return button
|
||||
end
|
||||
|
||||
|
||||
function m.resize_tab(tab, width, padding)
|
||||
tab:SetWidth(width + padding + 10)
|
||||
end
|
||||
|
||||
function m.update_tab(tab)
|
||||
|
||||
end
|
||||
|
||||
do
|
||||
local id = 0
|
||||
function m.tab_group(parent, position)
|
||||
id = id + 1
|
||||
|
||||
local frame = CreateFrame('Frame', nil, parent)
|
||||
frame:SetHeight(100)
|
||||
frame:SetWidth(100)
|
||||
-- frame:SetFrameStrata('FULLSCREEN_DIALOG')
|
||||
|
||||
-- local border = CreateFrame('Frame', nil, frame)
|
||||
-- border:SetPoint('TOPLEFT', 1, -30)
|
||||
-- border:SetPoint('BOTTOMRIGHT', -1, 3)
|
||||
-- border:SetBackdrop({ bgFile='Interface\\Buttons\\WHITE8X8', edgeFile='Interface\\Buttons\\WHITE8X8', edgeSize=m.config.edge_size })
|
||||
-- border:SetBackdropColor(unpack(m.config.frame_color))
|
||||
-- border:SetBackdropBorderColor(unpack(m.config.frame_border_color))
|
||||
|
||||
-- local content = CreateFrame('Frame', nil, border)
|
||||
-- content:SetPoint('TOPLEFT', 8, -8)
|
||||
-- content:SetPoint('BOTTOMRIGHT', -8, 8)
|
||||
|
||||
local self = {
|
||||
id = id,
|
||||
frame = parent,
|
||||
-- border = border,
|
||||
tabs = {},
|
||||
on_select = function() end,
|
||||
}
|
||||
|
||||
function self:create_tab(text)
|
||||
local id = getn(self.tabs) + 1
|
||||
|
||||
local tab = CreateFrame('Button', 'aux_tab_group'..self.id..'_tab'..id, self.frame)
|
||||
tab.id = id
|
||||
tab.group = self
|
||||
tab:SetHeight(24)
|
||||
tab:SetBackdrop({bgFile='Interface\\Buttons\\WHITE8X8', edgeFile='Interface\\Buttons\\WHITE8X8', edgeSize=m.config.edge_size})
|
||||
tab:SetBackdropColor(0, 0, 0, 0)
|
||||
tab:SetBackdropBorderColor(unpack(m.config.frame_border_color))
|
||||
local image = tab:CreateTexture(nil, 'BACKGROUND')
|
||||
image:SetAllPoints()
|
||||
image:SetTexture(unpack(m.config.content_color))
|
||||
tab.image = image
|
||||
local dock = tab:CreateTexture(nil, 'OVERLAY')
|
||||
dock:SetHeight(3)
|
||||
if position == 'TOP' then
|
||||
dock:SetPoint('BOTTOMLEFT', 1, -1)
|
||||
dock:SetPoint('BOTTOMRIGHT', -1, -1)
|
||||
else
|
||||
dock:SetPoint('TOPLEFT', 1, 1)
|
||||
dock:SetPoint('TOPRIGHT', -1, 1)
|
||||
end
|
||||
dock:SetTexture(unpack(m.config.frame_color))
|
||||
tab.dock = dock
|
||||
local highlight = tab:CreateTexture(nil, 'HIGHLIGHT')
|
||||
highlight:SetAllPoints()
|
||||
highlight:SetTexture(1, 1, 1, .2)
|
||||
highlight:SetBlendMode('BLEND')
|
||||
tab.highlight = highlight
|
||||
|
||||
tab.text = tab:CreateFontString()
|
||||
tab.text:SetPoint('LEFT', 3, -1)
|
||||
tab.text:SetPoint('RIGHT', -3, -1)
|
||||
tab.text:SetJustifyH('CENTER')
|
||||
tab.text:SetJustifyV('CENTER')
|
||||
tab.text:SetFont(m.config.content_font, 18)
|
||||
tab:SetFontString(tab.text)
|
||||
|
||||
tab:SetText(text)
|
||||
|
||||
tab:SetScript('OnClick', function()
|
||||
if this.id ~= this.group.selected then
|
||||
-- PlaySound('igCharacterInfoTab')
|
||||
this.group:set_tab(this.id)
|
||||
end
|
||||
end)
|
||||
|
||||
if getn(self.tabs) == 0 then
|
||||
if position == 'TOP' then
|
||||
tab:SetPoint('BOTTOMLEFT', self.frame, 'TOPLEFT', 4, -1)
|
||||
else
|
||||
tab:SetPoint('TOPLEFT', self.frame, 'BOTTOMLEFT', 4, 1)
|
||||
end
|
||||
else
|
||||
if position == 'TOP' then
|
||||
tab:SetPoint('BOTTOMLEFT', self.tabs[getn(self.tabs)], 'BOTTOMRIGHT', 4, 0)
|
||||
else
|
||||
tab:SetPoint('TOPLEFT', self.tabs[getn(self.tabs)], 'TOPRIGHT', 4, 0)
|
||||
end
|
||||
end
|
||||
|
||||
m.resize_tab(tab, tab:GetFontString():GetStringWidth(), 4)
|
||||
|
||||
-- tab:Show()
|
||||
tinsert(self.tabs, tab)
|
||||
end
|
||||
|
||||
function self:set_tab(id)
|
||||
self.selected = id
|
||||
|
||||
self.update_tabs()
|
||||
|
||||
self.on_select(id)
|
||||
end
|
||||
|
||||
function self.update_tabs()
|
||||
for _, tab in ipairs(self.tabs) do
|
||||
-- if tab.disabled then
|
||||
-- TSMAPI.Design:SetWidgetLabelColor(tab.text, true)
|
||||
-- tab:Disable()
|
||||
-- tab.text = tab:GetText()
|
||||
-- tab.dock:Hide()
|
||||
if tab.group.selected == tab.id then
|
||||
-- TSMAPI.Design:SetWidgetLabelColor(tab.text)
|
||||
tab.text:SetTextColor(216/255, 225/255, 211/255) -- TODO
|
||||
tab:Disable()
|
||||
tab.image:SetTexture(unpack(m.config.frame_color))
|
||||
tab.dock:Show()
|
||||
tab:SetHeight(29)
|
||||
else
|
||||
-- TSMAPI.Design:SetWidgetTextColor(tab.text)
|
||||
tab.text:SetTextColor(255/255, 254/255, 250/255) -- TODO
|
||||
tab:Enable()
|
||||
tab.image:SetTexture(unpack(m.config.content_color))
|
||||
tab.dock:Hide()
|
||||
tab:SetHeight(24)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
-- ["OnWidthSet"] = function(self, width)
|
||||
-- local content = self.content
|
||||
-- local contentwidth = width - 60
|
||||
-- if contentwidth < 0 then
|
||||
-- contentwidth = 0
|
||||
-- end
|
||||
-- content:SetWidth(contentwidth)
|
||||
-- content.width = contentwidth
|
||||
-- self:BuildTabs(self)
|
||||
-- self.frame:SetScript("OnUpdate", BuildTabsOnUpdate)
|
||||
-- end,
|
||||
--
|
||||
-- ["OnHeightSet"] = function(self, height)
|
||||
-- local content = self.content
|
||||
-- local contentheight = height - 30
|
||||
-- if contentheight < 0 then
|
||||
-- contentheight = 0
|
||||
-- end
|
||||
-- content:SetHeight(contentheight)
|
||||
-- content.height = contentheight
|
||||
-- end,
|
||||
--
|
||||
-- ["LayoutFinished"] = function(self, width, height)
|
||||
-- if self.noAutoHeight then return end
|
||||
-- self:SetHeight((height or 0) + 30)
|
||||
-- end
|
||||
|
||||
return self
|
||||
end
|
||||
end
|
||||
|
||||
function m.editbox(parent, name)
|
||||
|
||||
-- local frame = CreateFrame('Frame', name, parent)
|
||||
-- frame:Hide()
|
||||
|
||||
local editbox = CreateFrame('EditBox', name, parent)
|
||||
editbox:SetAutoFocus(false)
|
||||
editbox:SetTextInsets(0, 0, 3, 3)
|
||||
editbox:SetMaxLetters(256)
|
||||
editbox:SetHeight(19)
|
||||
editbox:SetFont(m.config.content_font, m.config.normal_font_size)
|
||||
editbox:SetShadowColor(0, 0, 0, 0)
|
||||
editbox:SetBackdrop({bgFile='Interface\\Buttons\\WHITE8X8', edgeFile='Interface\\Buttons\\WHITE8X8', edgeSize=m.config.edge_size})
|
||||
editbox:SetBackdropColor(unpack(m.config.content_color))
|
||||
editbox:SetBackdropBorderColor(unpack(m.config.content_border_color))
|
||||
|
||||
editbox:SetScript('OnEditFocusLost', function()
|
||||
this:HighlightText(0, 0)
|
||||
end)
|
||||
|
||||
editbox:SetScript('OnEscapePressed', function()
|
||||
this:ClearFocus()
|
||||
end)
|
||||
|
||||
do
|
||||
local last_time, last_x, last_y
|
||||
|
||||
editbox:SetScript('OnEditFocusGained', function()
|
||||
this:HighlightText()
|
||||
end)
|
||||
|
||||
editbox:SetScript('OnMouseUp', function()
|
||||
local x, y = GetCursorPosition()
|
||||
if last_time and last_time > GetTime() - .5 and abs(x - last_x) < 10 and abs(y - last_y) < 10 then
|
||||
this:HighlightText()
|
||||
last_time = nil
|
||||
else
|
||||
last_time = GetTime()
|
||||
last_x, last_y = GetCursorPosition()
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
-- local label = frame:CreateFontString(nil, 'OVERLAY')
|
||||
-- label:SetPoint('TOPLEFT', 0, -2)
|
||||
-- label:SetPoint('TOPRIGHT', 0, -2)
|
||||
-- label:SetJustifyH('LEFT')
|
||||
-- label:SetJustifyV('CENTER')
|
||||
-- label:SetHeight(18)
|
||||
-- label:SetFont(m.config.content_font, m.config.normal_font_size)
|
||||
-- label:SetShadowColor(0, 0, 0, 0)
|
||||
|
||||
return editbox
|
||||
end
|
||||
|
||||
function m.status_bar(parent)
|
||||
local self = CreateFrame('Frame', nil, parent)
|
||||
|
||||
local level = parent:GetFrameLevel()
|
||||
|
||||
self:SetFrameLevel(level + 1)
|
||||
|
||||
do
|
||||
-- minor status bar (gray one)
|
||||
local status_bar = CreateFrame('STATUSBAR', nil, self, 'TextStatusBar')
|
||||
status_bar:SetOrientation('HORIZONTAL')
|
||||
status_bar:SetMinMaxValues(0, 100)
|
||||
status_bar:SetAllPoints()
|
||||
status_bar:SetStatusBarTexture([[Interface\Buttons\WHITE8X8]])
|
||||
status_bar:SetStatusBarColor(.42, .42, .42, .7)
|
||||
status_bar:SetFrameLevel(level + 2)
|
||||
status_bar:SetScript('OnUpdate', function()
|
||||
if this:GetValue() < 100 then
|
||||
this:SetAlpha(1 - ((math.sin(GetTime()*math.pi)+1)/2)/2)
|
||||
else
|
||||
this:SetAlpha(1)
|
||||
end
|
||||
end)
|
||||
-- local ag = status_bar:CreateAnimationGroup()
|
||||
-- local alpha = ag:CreateAnimation('Alpha')
|
||||
-- alpha:SetDuration(1)
|
||||
-- alpha:SetChange(-.5)
|
||||
-- ag:SetLooping('Bounce')
|
||||
-- status_bar.ag = ag
|
||||
self.minor_status_bar = status_bar
|
||||
end
|
||||
|
||||
do
|
||||
-- major status bar (main blue one)
|
||||
local status_bar = CreateFrame('STATUSBAR', nil, self, 'TextStatusBar')
|
||||
status_bar:SetOrientation('HORIZONTAL')
|
||||
status_bar:SetMinMaxValues(0, 100)
|
||||
status_bar:SetAllPoints()
|
||||
status_bar:SetStatusBarTexture([[Interface\Buttons\WHITE8X8]])
|
||||
status_bar:SetStatusBarColor(.19, .22, .33, .9)
|
||||
status_bar:SetFrameLevel(level + 3)
|
||||
status_bar:SetScript('OnUpdate', function()
|
||||
if this:GetValue() < 100 then
|
||||
this:SetAlpha(1 - ((math.sin(GetTime()*math.pi)+1)/2)/2)
|
||||
else
|
||||
this:SetAlpha(1)
|
||||
end
|
||||
end)
|
||||
-- local ag = status_bar:CreateAnimationGroup()
|
||||
-- local alpha = ag:CreateAnimation('Alpha')
|
||||
-- alpha:SetDuration(1)
|
||||
-- alpha:SetChange(-.5)
|
||||
-- ag:SetLooping('Bounce')
|
||||
-- status_bar.ag = ag
|
||||
self.major_status_bar = status_bar
|
||||
end
|
||||
|
||||
do
|
||||
local text_frame = CreateFrame('Frame', nil, self)
|
||||
text_frame:SetFrameLevel(level + 4)
|
||||
text_frame:SetAllPoints(self)
|
||||
local text = m.label(text_frame)
|
||||
text:SetTextColor(unpack(m.config.text_color.enabled))
|
||||
text:SetPoint('CENTER', 0, 0)
|
||||
self.text = text
|
||||
end
|
||||
|
||||
function self:update_status(major_status, minor_status)
|
||||
if major_status then
|
||||
self.major_status_bar:SetValue(major_status)
|
||||
-- if major_status == 100 then
|
||||
-- self.major_status_bar.ag:Stop()
|
||||
-- elseif not self.major_status_bar.ag:IsPlaying() then
|
||||
-- self.major_status_bar.ag:Play()
|
||||
-- end
|
||||
end
|
||||
if minor_status then
|
||||
self.minor_status_bar:SetValue(minor_status)
|
||||
-- if minor_status == 100 then
|
||||
-- self.minor_status_bar.ag:Stop()
|
||||
-- elseif not self.minor_status_bar.ag:IsPlaying() then
|
||||
-- self.minor_status_bar.ag:Play()
|
||||
-- end
|
||||
end
|
||||
end
|
||||
|
||||
function self:set_text(text)
|
||||
self.text:SetText(text)
|
||||
end
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
function m.label(parent, size)
|
||||
local label = parent:CreateFontString()
|
||||
label:SetFont(m.config.content_font, size or m.config.normal_font_size)
|
||||
label:SetTextColor(unpack(m.config.label_color.enabled))
|
||||
return label
|
||||
end
|
||||
|
||||
function m.horizontal_line(parent, y_offset, inverted_color)
|
||||
local texture = parent:CreateTexture()
|
||||
texture:SetPoint('TOPLEFT', parent, 'TOPLEFT', 2, y_offset)
|
||||
texture:SetPoint('TOPRIGHT', parent, 'TOPRIGHT', -2, y_offset)
|
||||
texture:SetHeight(2)
|
||||
if inverted_color then
|
||||
texture:SetTexture(unpack(m.config.frame_color))
|
||||
else
|
||||
texture:SetTexture(unpack(m.config.content_color))
|
||||
end
|
||||
return texture
|
||||
end
|
||||
|
||||
function m.vertical_line(parent, x_offset, inverted_color)
|
||||
local texture = parent:CreateTexture()
|
||||
texture:SetPoint('TOPLEFT', parent, 'TOPLEFT', x_offset, -2)
|
||||
texture:SetPoint('BOTTOMLEFT', parent, 'BOTTOMLEFT', x_offset, 2)
|
||||
texture:SetWidth(2)
|
||||
if inverted_color then
|
||||
texture:SetTexture(unpack(m.config.frame_color))
|
||||
else
|
||||
texture:SetTexture(unpack(m.config.content_color))
|
||||
end
|
||||
return texture
|
||||
end
|
||||
|
||||
do
|
||||
local id = 0
|
||||
function m.dropdown(parent)
|
||||
id = id + 1
|
||||
|
||||
-- local frame = CreateFrame("Frame", nil, UIParent)
|
||||
local dropdown = CreateFrame('Frame', 'aux_dropdown'..id, parent, 'UIDropDownMenuTemplate')
|
||||
|
||||
dropdown:SetBackdrop({bgFile='Interface\\Buttons\\WHITE8X8', edgeFile='Interface\\Buttons\\WHITE8X8', edgeSize=Aux.gui.config.edge_size, insets={top=5,bottom=5}})
|
||||
dropdown:SetBackdropColor(unpack(Aux.gui.config.content_color))
|
||||
dropdown:SetBackdropBorderColor(unpack(Aux.gui.config.content_border_color))
|
||||
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 text = getglobal(dropdown:GetName()..'Text')
|
||||
text:ClearAllPoints()
|
||||
text:SetPoint('RIGHT', button, 'LEFT', -2, 0)
|
||||
text:SetPoint('LEFT', dropdown, 'LEFT', 8, 0)
|
||||
text:SetFont(Aux.gui.config.content_font, 13)
|
||||
text:SetShadowColor(0, 0, 0, 0)
|
||||
|
||||
-- frame:SetScript("OnHide", Dropdown_OnHide)
|
||||
--
|
||||
-- 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
|
||||
|
||||
return dropdown
|
||||
end
|
||||
end
|
||||
|
||||
function m.slider(frame, name)
|
||||
-- local frame = CreateFrame('Frame', nil, UIParent)
|
||||
--
|
||||
-- frame:EnableMouse(true)
|
||||
-- frame:SetScript("OnMouseDown", Frame_OnMouseDown)
|
||||
-- frame:SetScript("OnEnter", Control_OnEnter)
|
||||
-- frame:SetScript("OnLeave", Control_OnLeave)
|
||||
--
|
||||
|
||||
local slider = CreateFrame('Slider', name, frame)
|
||||
slider:SetOrientation('HORIZONTAL')
|
||||
slider:SetHeight(6)
|
||||
slider:SetHitRectInsets(0, 0, -8, -8)
|
||||
-- slider:SetPoint('TOPLEFT', label, 'BOTTOMLEFT', 3, -4)
|
||||
-- slider:SetPoint('TOPRIGHT', label, 'BOTTOMRIGHT', -6, -4)
|
||||
slider:SetValue(0)
|
||||
slider:SetBackdrop({ bgFile='Interface\\Buttons\\WHITE8X8', edgeFile='Interface\\Buttons\\WHITE8X8', edgeSize=m.config.edge_size })
|
||||
slider:SetBackdropColor(unpack(m.config.frame_color))
|
||||
slider:SetBackdropBorderColor(unpack(m.config.frame_border_color))
|
||||
local thumb_texture = slider:CreateTexture(nil, 'ARTWORK')
|
||||
thumb_texture:SetPoint('CENTER', 0, 0)
|
||||
thumb_texture:SetTexture(unpack(m.config.content_color))
|
||||
thumb_texture:SetHeight(15)
|
||||
thumb_texture:SetWidth(8)
|
||||
slider:SetThumbTexture(thumb_texture)
|
||||
|
||||
local label = slider:CreateFontString(nil, 'OVERLAY')
|
||||
label:SetPoint('BOTTOMLEFT', slider, 'TOPLEFT', -3, 6)
|
||||
label:SetPoint('BOTTOMRIGHT', slider, 'TOPRIGHT', 6, 6)
|
||||
label:SetJustifyH('LEFT')
|
||||
label:SetHeight(13)
|
||||
label:SetFont(m.config.content_font, m.config.normal_font_size)
|
||||
label:SetTextColor(unpack(m.config.label_color.enabled))
|
||||
|
||||
|
||||
-- local lowtext = slider:CreateFontString(nil, 'ARTWORK')
|
||||
-- lowtext:SetFont(TSMAPI.Design:GetContentFont('small'))
|
||||
-- lowtext:SetPoint('TOPLEFT', slider, 'BOTTOMLEFT', 2, -4)
|
||||
--
|
||||
-- local hightext = slider:CreateFontString(nil, 'ARTWORK')
|
||||
-- hightext:SetFont(TSMAPI.Design:GetContentFont('small'))
|
||||
-- hightext:SetPoint('TOPRIGHT', slider, 'BOTTOMRIGHT', -2, -4)
|
||||
--
|
||||
local editbox = CreateFrame('EditBox', nil, slider)
|
||||
editbox:SetAutoFocus(false)
|
||||
editbox:SetPoint('LEFT', slider, 'RIGHT', 5, 0)
|
||||
editbox:SetHeight(15)
|
||||
editbox:SetWidth(70)
|
||||
editbox:SetJustifyH('CENTER')
|
||||
editbox:EnableMouse(true)
|
||||
editbox:SetBackdrop({ bgFile='Interface\\Buttons\\WHITE8X8', edgeFile='Interface\\Buttons\\WHITE8X8', edgeSize=m.config.edge_size })
|
||||
editbox:SetBackdropColor(unpack(m.config.content_color))
|
||||
editbox:SetBackdropBorderColor(unpack(m.config.content_border_color))
|
||||
-- editbox:SetScript('OnEnterPressed', EditBox_OnEnterPressed)
|
||||
-- editbox:SetScript('OnEscapePressed', EditBox_OnEscapePressed)
|
||||
-- editbox:SetScript('OnTextChanged', EditBox_OnTextChanged)
|
||||
-- editbox:SetScript('OnEnter', Control_OnEnter)
|
||||
-- editbox:SetScript('OnLeave', Control_OnLeave)
|
||||
-- editbox:SetFont(m.config.content_font, m.config.normal_font_size)
|
||||
editbox:SetFont(m.config.content_font, m.config.normal_button_font_size)
|
||||
editbox:SetShadowColor(0, 0, 0, 0)
|
||||
--
|
||||
-- local button = CreateFrame('Button', nil, editbox, 'UIPanelButtonTemplate')
|
||||
-- button:SetWidth(40)
|
||||
-- button:SetHeight(20)
|
||||
-- button:SetPoint('LEFT', editbox, 'RIGHT', 2, 0)
|
||||
-- button:SetText(OKAY)
|
||||
-- button:SetScript('OnClick', Button_OnClick)
|
||||
-- button:Hide()
|
||||
--
|
||||
-- local widget = {
|
||||
-- label = label,
|
||||
-- slider = slider,
|
||||
-- lowtext = lowtext,
|
||||
-- hightext = hightext,
|
||||
-- editbox = editbox,
|
||||
-- button = button,
|
||||
-- alignoffset = 25,
|
||||
-- frame = frame,
|
||||
-- type = Type
|
||||
-- }
|
||||
-- for method, func in pairs(methods) do
|
||||
-- widget[method] = func
|
||||
-- end
|
||||
-- slider.obj, editbox.obj, button.obj, frame.obj = widget, widget, widget, widget
|
||||
|
||||
|
||||
slider.label = label
|
||||
slider.editbox = editbox
|
||||
return slider
|
||||
end
|
||||
|
||||
--function m.checkbox()
|
||||
-- local frame = CreateFrame('Button', nil, UIParent)
|
||||
-- frame:Hide()
|
||||
-- frame:EnableMouse(true)
|
||||
-- frame:SetScript("OnEnter", Control_OnEnter)
|
||||
-- frame:SetScript("OnLeave", Control_OnLeave)
|
||||
-- frame:SetScript("OnMouseDown", CheckBox_OnMouseDown)
|
||||
-- frame:SetScript("OnMouseUp", CheckBox_OnMouseUp)
|
||||
--
|
||||
-- local checkbox = CreateFrame('Button', nil, frame)
|
||||
-- checkbox:EnableMouse(false)
|
||||
-- checkbox:SetWidth(16)
|
||||
-- checkbox:SetHeight(16)
|
||||
-- checkbox:SetPoint('TOPLEFT', 4, -4)
|
||||
-- checkbox:SetBackdrop({ bgFile='Interface\\Buttons\\WHITE8X8', edgeFile='Interface\\Buttons\\WHITE8X8', edgeSize=m.config.edge_size })
|
||||
-- checkbox:SetBackdropColor(unpack(m.config.content_color))
|
||||
-- checkbox:SetBackdropBorderColor(unpack(m.config.content_border_color))
|
||||
-- local highlight = checkbox:CreateTexture(nil, 'HIGHLIGHT')
|
||||
-- highlight:SetAllPoints()
|
||||
-- highlight:SetTexture(1, 1, 1, .2)
|
||||
-- highlight:SetBlendMode('BLEND')
|
||||
--
|
||||
-- local check = checkbox:CreateTexture(nil, 'OVERLAY')
|
||||
-- check:SetTexture([[Interface\Buttons\UI-CheckBox-Check]])
|
||||
-- check:SetTexCoord(.12, .88, .12, .88)
|
||||
-- check:SetBlendMode('BLEND')
|
||||
-- check:SetPoint('BOTTOMRIGHT')
|
||||
--
|
||||
-- local text = frame:CreateFontString(nil, 'OVERLAY')
|
||||
-- text:SetJustifyH('LEFT')
|
||||
-- text:SetHeight(18)
|
||||
-- text:SetPoint('LEFT', checkbox, 'RIGHT')
|
||||
-- text:SetPoint('RIGHT')
|
||||
-- text:SetFont(m.config.content_font, m.config.normal_font_size)
|
||||
--
|
||||
-- checkbox.text = text
|
||||
-- return checkbox
|
||||
--end
|
||||
@@ -0,0 +1,568 @@
|
||||
local private, public = {}, {}
|
||||
Aux.post_frame = public
|
||||
|
||||
local existing_auctions = {}
|
||||
local inventory_records
|
||||
local scan_id
|
||||
|
||||
local settings_schema = {'record', '#', {stack_size='number'}, {duration='number'}, {start_price='number'}, {buyout_price='number'}, {hidden='boolean'}}
|
||||
|
||||
local DURATION_4, DURATION_8, DURATION_24 = 120, 480, 1440
|
||||
|
||||
function private.default_settings()
|
||||
return {
|
||||
duration = DURATION_8,
|
||||
stack_size = 1,
|
||||
start_price = 0,
|
||||
buyout_price = 0,
|
||||
hidden = false,
|
||||
}
|
||||
end
|
||||
|
||||
function private.read_settings(item_key)
|
||||
item_key = item_key or private.selected_item.key
|
||||
local dataset = Aux.persistence.load_dataset()
|
||||
dataset.post = dataset.post or {}
|
||||
|
||||
local settings
|
||||
if dataset.post[item_key] then
|
||||
settings = Aux.persistence.read(settings_schema, dataset.post[item_key])
|
||||
else
|
||||
settings = private.default_settings()
|
||||
end
|
||||
return settings
|
||||
end
|
||||
|
||||
function private.write_settings(settings, item_key)
|
||||
item_key = item_key or private.selected_item.key
|
||||
|
||||
local dataset = Aux.persistence.load_dataset()
|
||||
dataset.post = dataset.post or {}
|
||||
|
||||
dataset.post[item_key] = Aux.persistence.write(settings_schema, settings)
|
||||
end
|
||||
|
||||
function private.get_unit_start_price()
|
||||
local money_text = private.unit_start_price:GetText()
|
||||
return Aux.money.from_string(money_text) or (tonumber(money_text) and tonumber(money_text) * 10000) or 0
|
||||
end
|
||||
|
||||
function private.set_unit_start_price(amount)
|
||||
private.unit_start_price:SetText(Aux.money.to_string(amount, true, nil, 3))
|
||||
end
|
||||
|
||||
function private.get_unit_buyout_price()
|
||||
local money_text = private.unit_buyout_price:GetText()
|
||||
return Aux.money.from_string(money_text) or (tonumber(money_text) and tonumber(money_text) * 10000) or 0
|
||||
end
|
||||
|
||||
function private.set_unit_buyout_price(amount)
|
||||
private.unit_buyout_price:SetText(Aux.money.to_string(amount, true, nil, 3))
|
||||
end
|
||||
|
||||
function private.update_inventory_listing()
|
||||
if not AuxPostFrame:IsVisible() then
|
||||
return
|
||||
end
|
||||
|
||||
Aux.item_listing.populate(private.item_listing, Aux.util.filter(inventory_records, function(record)
|
||||
local settings = private.read_settings(record.key)
|
||||
return record.aux_quantity > 0 and (not settings.hidden or private.show_hidden_checkbox:GetChecked())
|
||||
end))
|
||||
end
|
||||
|
||||
function private.update_auction_listing()
|
||||
if not AuxPostFrame:IsVisible() then
|
||||
return
|
||||
end
|
||||
|
||||
local auction_rows = {}
|
||||
if private.selected_item then
|
||||
local unit_start_price = private.get_unit_start_price()
|
||||
local unit_buyout_price = private.get_unit_buyout_price()
|
||||
|
||||
for i, auction_record in ipairs(existing_auctions[private.selected_item.key] or {}) do
|
||||
|
||||
local blizzard_bid_undercut, buyout_price_undercut = private.undercut(auction_record, private.stack_size_slider:GetValue())
|
||||
blizzard_bid_undercut = Aux.money.from_string(Aux.money.to_string(blizzard_bid_undercut, true, nil, 3))
|
||||
buyout_price_undercut = Aux.money.from_string(Aux.money.to_string(buyout_price_undercut, true, nil, 3))
|
||||
|
||||
local stack_blizzard_bid_undercut, stack_buyout_price_undercut = private.undercut(auction_record, private.stack_size_slider:GetValue(), true)
|
||||
stack_blizzard_bid_undercut = Aux.money.from_string(Aux.money.to_string(stack_blizzard_bid_undercut, true, nil, 3))
|
||||
stack_buyout_price_undercut = Aux.money.from_string(Aux.money.to_string(stack_buyout_price_undercut, true, nil, 3))
|
||||
|
||||
local stack_size = private.stack_size_slider:GetValue()
|
||||
local historical_value = Aux.history.value(private.selected_item.key)
|
||||
|
||||
local bid_color
|
||||
if blizzard_bid_undercut < unit_start_price and stack_blizzard_bid_undercut < unit_start_price then
|
||||
bid_color = '|cffff0000'
|
||||
elseif blizzard_bid_undercut < unit_start_price then
|
||||
bid_color = '|cffff9218'
|
||||
elseif stack_blizzard_bid_undercut < unit_start_price then
|
||||
bid_color = '|cffffff00'
|
||||
end
|
||||
|
||||
local buyout_color
|
||||
if buyout_price_undercut < unit_buyout_price and stack_buyout_price_undercut < unit_buyout_price then
|
||||
buyout_color = '|cffff0000'
|
||||
elseif buyout_price_undercut < unit_buyout_price then
|
||||
buyout_color = '|cffff9218'
|
||||
elseif stack_buyout_price_undercut < unit_buyout_price then
|
||||
buyout_color = '|cffffff00'
|
||||
end
|
||||
|
||||
tinsert(auction_rows, {
|
||||
cols = {
|
||||
{ value=auction_record.own and GREEN_FONT_COLOR_CODE..auction_record.count..FONT_COLOR_CODE_CLOSE or auction_record.count },
|
||||
{ value=Aux.auction_listing.time_left(auction_record.duration) },
|
||||
{ value=auction_record.stack_size == stack_size and GREEN_FONT_COLOR_CODE..auction_record.stack_size..FONT_COLOR_CODE_CLOSE or auction_record.stack_size },
|
||||
{ value=Aux.money.to_string(auction_record.unit_blizzard_bid, true, nil, 3, bid_color) },
|
||||
{ value=historical_value and Aux.auction_listing.percentage_historical(Aux.round(auction_record.unit_blizzard_bid / historical_value * 100)) or '---' },
|
||||
{ value=auction_record.unit_buyout_price > 0 and Aux.money.to_string(auction_record.unit_buyout_price, true, nil, 3, buyout_color) or '---' },
|
||||
{ value=auction_record.unit_buyout_price > 0 and historical_value and Aux.auction_listing.percentage_historical(Aux.round(auction_record.unit_buyout_price / historical_value * 100)) or '---' },
|
||||
},
|
||||
record = auction_record,
|
||||
})
|
||||
end
|
||||
sort(auction_rows, function(a, b) return Aux.sort.multi_lt(
|
||||
a.record.unit_buyout_price == 0 and Aux.huge or a.record.unit_buyout_price, b.record.unit_buyout_price == 0 and Aux.huge or b.record.unit_buyout_price,
|
||||
a.record.unit_blizzard_bid, b.record.unit_blizzard_bid,
|
||||
a.record.stack_size, b.record.stack_size,
|
||||
b.record.own and 1 or 0, a.record.own and 1 or 0,
|
||||
a.record.duration, b.record.duration
|
||||
) end)
|
||||
end
|
||||
private.auction_listing:SetData(auction_rows)
|
||||
end
|
||||
|
||||
function public.select_item(item_key)
|
||||
for _, inventory_record in ipairs(Aux.util.filter(inventory_records, function(record) return record.aux_quantity > 0 end)) do
|
||||
if inventory_record.key == item_key then
|
||||
private.set_item(inventory_record)
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function public.on_load()
|
||||
public.create_frames(private, public)
|
||||
end
|
||||
|
||||
function private.price_update()
|
||||
if private.selected_item then
|
||||
local settings = private.read_settings()
|
||||
|
||||
local start_price_input = private.get_unit_start_price()
|
||||
settings.start_price = start_price_input
|
||||
local historical_value = Aux.history.value(private.selected_item.key)
|
||||
private.start_price_percentage:SetText(historical_value and Aux.auction_listing.percentage_historical(Aux.round(start_price_input / historical_value * 100)) or '---')
|
||||
|
||||
local buyout_price_input = private.get_unit_buyout_price()
|
||||
settings.buyout_price = buyout_price_input
|
||||
local historical_value = Aux.history.value(private.selected_item.key)
|
||||
private.buyout_price_percentage:SetText(historical_value and Aux.auction_listing.percentage_historical(Aux.round(buyout_price_input / historical_value * 100)) or '---')
|
||||
|
||||
private.write_settings(settings)
|
||||
end
|
||||
end
|
||||
|
||||
function public.on_open()
|
||||
private.deposit:SetText('Deposit: '..Aux.money.to_string(0, nil, nil, nil, Aux.gui.inline_color({255, 254, 250, 1})))
|
||||
|
||||
private.set_unit_start_price(0)
|
||||
private.set_unit_buyout_price(0)
|
||||
|
||||
private.update_inventory_records()
|
||||
|
||||
private.refresh = true
|
||||
end
|
||||
|
||||
function public.on_close()
|
||||
private.selected_item = nil
|
||||
end
|
||||
|
||||
function private.post_auctions()
|
||||
if private.selected_item then
|
||||
local unit_start_price = private.get_unit_start_price()
|
||||
local unit_buyout_price = private.get_unit_buyout_price()
|
||||
local stack_size = private.stack_size_slider:GetValue()
|
||||
local stack_count
|
||||
stack_count = private.stack_count_slider:GetValue()
|
||||
local duration = UIDropDownMenu_GetSelectedValue(private.duration_dropdown)
|
||||
local key = private.selected_item.key
|
||||
|
||||
local duration_code
|
||||
if duration == DURATION_4 then
|
||||
duration_code = 2
|
||||
elseif duration == DURATION_8 then
|
||||
duration_code = 3
|
||||
elseif duration == DURATION_24 then
|
||||
duration_code = 4
|
||||
end
|
||||
|
||||
Aux.post.start(
|
||||
key,
|
||||
stack_size,
|
||||
duration,
|
||||
unit_start_price,
|
||||
unit_buyout_price,
|
||||
stack_count,
|
||||
function(posted)
|
||||
local new_auction_record
|
||||
for i = 1, posted do
|
||||
new_auction_record = private.record_auction(key, stack_size, unit_start_price, unit_buyout_price, duration_code, UnitName('player'))
|
||||
end
|
||||
|
||||
private.update_inventory_records()
|
||||
private.selected_item = nil
|
||||
for _, record in ipairs(inventory_records) do
|
||||
if record.key == key then
|
||||
private.set_item(record)
|
||||
end
|
||||
end
|
||||
|
||||
private.refresh = true
|
||||
end
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
function private.validate_parameters()
|
||||
|
||||
if not private.selected_item then
|
||||
private.post_button:Disable()
|
||||
return
|
||||
end
|
||||
|
||||
if private.get_unit_buyout_price() > 0 and private.get_unit_start_price() > private.get_unit_buyout_price() then
|
||||
private.post_button:Disable()
|
||||
return
|
||||
end
|
||||
|
||||
if private.get_unit_start_price() == 0 then
|
||||
private.post_button:Disable()
|
||||
return
|
||||
end
|
||||
|
||||
if private.stack_count_slider:GetValue() == 0 then
|
||||
private.post_button:Disable()
|
||||
return
|
||||
end
|
||||
|
||||
private.post_button:Enable()
|
||||
end
|
||||
|
||||
function private.update_item_configuration()
|
||||
|
||||
if not private.selected_item then
|
||||
private.refresh_button:Disable()
|
||||
|
||||
AuxPostParametersItemIconTexture:SetTexture(nil)
|
||||
AuxPostParametersItemCount:SetText()
|
||||
AuxPostParametersItemName:SetTextColor(unpack(Aux.gui.config.label_color.enabled))
|
||||
AuxPostParametersItemName:SetText('No item selected')
|
||||
|
||||
private.unit_start_price:Hide()
|
||||
private.unit_buyout_price:Hide()
|
||||
private.stack_size_slider:Hide()
|
||||
private.stack_count_slider:Hide()
|
||||
private.deposit:Hide()
|
||||
private.duration_dropdown:Hide()
|
||||
private.historical_value_button:Hide()
|
||||
private.hide_checkbox:Hide()
|
||||
else
|
||||
private.unit_start_price:Show()
|
||||
private.unit_buyout_price:Show()
|
||||
private.stack_size_slider:Show()
|
||||
private.stack_count_slider:Show()
|
||||
private.deposit:Show()
|
||||
private.duration_dropdown:Show()
|
||||
private.historical_value_button:Show()
|
||||
private.hide_checkbox:Show()
|
||||
|
||||
AuxPostParametersItemIconTexture:SetTexture(private.selected_item.texture)
|
||||
AuxPostParametersItemName:SetText('['..private.selected_item.name..']')
|
||||
local color = ITEM_QUALITY_COLORS[private.selected_item.quality]
|
||||
AuxPostParametersItemName:SetTextColor(color.r, color.g, color.b)
|
||||
if private.selected_item.aux_quantity > 1 then
|
||||
AuxPostParametersItemCount:SetText(private.selected_item.aux_quantity)
|
||||
else
|
||||
AuxPostParametersItemCount:SetText()
|
||||
end
|
||||
|
||||
private.stack_size_slider.editbox:SetNumber(private.stack_size_slider:GetValue())
|
||||
private.stack_count_slider.editbox:SetNumber(private.stack_count_slider:GetValue())
|
||||
|
||||
do
|
||||
local deposit_factor = Aux.neutral_faction() and 0.25 or 0.05
|
||||
local stack_size = private.stack_size_slider:GetValue()
|
||||
local stack_count
|
||||
stack_count = private.stack_count_slider:GetValue()
|
||||
local deposit = floor(private.selected_item.unit_vendor_price * deposit_factor * (private.selected_item.max_charges and 1 or stack_size)) * stack_count * UIDropDownMenu_GetSelectedValue(private.duration_dropdown) / 120
|
||||
|
||||
private.deposit:SetText('Deposit: '..Aux.money.to_string(deposit, nil, nil, nil, Aux.gui.inline_color({255, 254, 250, 1})))
|
||||
end
|
||||
|
||||
private.refresh_button:Enable()
|
||||
end
|
||||
end
|
||||
|
||||
function private.undercut(record, stack_size, stack)
|
||||
local start_price = Aux.round(record.unit_blizzard_bid * (stack and record.stack_size or stack_size))
|
||||
local buyout_price = Aux.round(record.unit_buyout_price * (stack and record.stack_size or stack_size))
|
||||
|
||||
if not record.own then
|
||||
start_price = max(0, start_price - 1)
|
||||
buyout_price = max(0, buyout_price - 1)
|
||||
end
|
||||
|
||||
return start_price / stack_size, buyout_price / stack_size
|
||||
end
|
||||
|
||||
function private.quantity_update(max_count)
|
||||
if private.selected_item then
|
||||
local max_stack_count = private.selected_item.max_charges and private.selected_item.availability[private.stack_size_slider:GetValue()] or floor(private.selected_item.availability[0] / private.stack_size_slider:GetValue())
|
||||
private.stack_count_slider:SetMinMaxValues(1, max_stack_count)
|
||||
if max_count then
|
||||
private.stack_count_slider:SetValue(max_stack_count)
|
||||
end
|
||||
end
|
||||
private.refresh = true
|
||||
end
|
||||
|
||||
function private.unit_vendor_price(item_key)
|
||||
|
||||
for slot in Aux.util.inventory() do
|
||||
|
||||
local item_info = Aux.info.container_item(unpack(slot))
|
||||
if item_info and item_info.item_key == item_key then
|
||||
|
||||
if Aux.info.auctionable(item_info.tooltip, nil, item_info.lootable) then
|
||||
ClearCursor()
|
||||
PickupContainerItem(unpack(slot))
|
||||
ClickAuctionSellItemButton()
|
||||
local auction_sell_item = Aux.info.auction_sell_item()
|
||||
ClearCursor()
|
||||
ClickAuctionSellItemButton()
|
||||
ClearCursor()
|
||||
|
||||
if auction_sell_item then
|
||||
return auction_sell_item.unit_vendor_price
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function private.update_historical_value_button()
|
||||
if private.selected_item then
|
||||
local historical_value = Aux.history.value(private.selected_item.key)
|
||||
private.historical_value_button.amount = historical_value
|
||||
private.historical_value_button:SetText(historical_value and Aux.money.to_string(historical_value, true, nil, 3) or '---')
|
||||
end
|
||||
end
|
||||
|
||||
function private.set_item(item)
|
||||
local settings = private.read_settings(item.key)
|
||||
|
||||
item.unit_vendor_price = private.unit_vendor_price(item.key)
|
||||
if not item.unit_vendor_price then
|
||||
settings.hidden = 1
|
||||
private.write_settings(settings, item.key)
|
||||
private.refresh = true
|
||||
return
|
||||
end
|
||||
|
||||
Aux.scan.abort(scan_id)
|
||||
|
||||
private.selected_item = item
|
||||
|
||||
UIDropDownMenu_Initialize(private.duration_dropdown, private.initialize_duration_dropdown) -- TODO, wtf, why is this needed
|
||||
UIDropDownMenu_SetSelectedValue(private.duration_dropdown, settings.duration)
|
||||
|
||||
private.hide_checkbox:SetChecked(settings.hidden)
|
||||
|
||||
private.stack_size_slider:SetMinMaxValues(1, private.selected_item.max_charges or private.selected_item.max_stack)
|
||||
private.stack_size_slider:SetValue(settings.stack_size)
|
||||
private.quantity_update(true)
|
||||
|
||||
private.unit_start_price:SetText(Aux.money.to_string(settings.start_price, true, nil, 3, nil, true))
|
||||
private.unit_buyout_price:SetText(Aux.money.to_string(settings.buyout_price, true, nil, 3, nil, true))
|
||||
|
||||
if not existing_auctions[private.selected_item.key] then
|
||||
private.refresh_entries()
|
||||
end
|
||||
|
||||
private.write_settings(settings, item.key)
|
||||
private.refresh = true
|
||||
end
|
||||
|
||||
function private.update_inventory_records()
|
||||
inventory_records = {}
|
||||
private.refresh = true
|
||||
|
||||
local auction_candidate_map = {}
|
||||
|
||||
for slot in Aux.util.inventory() do
|
||||
|
||||
local item_info = Aux.info.container_item(unpack(slot))
|
||||
if item_info then
|
||||
local charge_class = item_info.charges or 0
|
||||
|
||||
if Aux.info.auctionable(item_info.tooltip, nil, item_info.lootable) then
|
||||
if not auction_candidate_map[item_info.item_key] then
|
||||
|
||||
local availability = {}
|
||||
for i=0,10 do
|
||||
availability[i] = 0
|
||||
end
|
||||
availability[charge_class] = item_info.count
|
||||
|
||||
auction_candidate_map[item_info.item_key] = {
|
||||
item_id = item_info.item_id,
|
||||
suffix_id = item_info.suffix_id,
|
||||
|
||||
key = item_info.item_key,
|
||||
itemstring = item_info.itemstring,
|
||||
|
||||
name = item_info.name,
|
||||
texture = item_info.texture,
|
||||
quality = item_info.quality,
|
||||
aux_quantity = item_info.charges or item_info.count,
|
||||
max_stack = item_info.max_stack,
|
||||
max_charges = item_info.max_charges,
|
||||
availability = availability,
|
||||
}
|
||||
else
|
||||
local candidate = auction_candidate_map[item_info.item_key]
|
||||
candidate.availability[charge_class] = (candidate.availability[charge_class] or 0) + item_info.count
|
||||
candidate.aux_quantity = candidate.aux_quantity + (item_info.charges or item_info.count)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
inventory_records = {}
|
||||
for _, auction_candidate in pairs(auction_candidate_map) do
|
||||
tinsert(inventory_records, auction_candidate)
|
||||
end
|
||||
sort(inventory_records, function(a, b) return a.name < b.name end)
|
||||
private.refresh = true
|
||||
end
|
||||
|
||||
function private.refresh_entries()
|
||||
if private.selected_item then
|
||||
local item_id, suffix_id = private.selected_item.item_id, private.selected_item.suffix_id
|
||||
local item_key = item_id..':'..suffix_id
|
||||
|
||||
existing_auctions[item_key] = nil
|
||||
|
||||
local query = Aux.scan_util.item_query(item_id)
|
||||
|
||||
private.status_bar:update_status(0,0)
|
||||
private.status_bar:set_text('Scanning auctions...')
|
||||
|
||||
scan_id = Aux.scan.start{
|
||||
type = 'list',
|
||||
ignore_owner = true,
|
||||
queries = { query },
|
||||
on_page_loaded = function(page, total_pages)
|
||||
private.status_bar:update_status(100 * (page - 1) / total_pages, 0) -- TODO
|
||||
private.status_bar:set_text(format('Scanning Page %d / %d', page, total_pages))
|
||||
end,
|
||||
on_auction = function(auction_record)
|
||||
if auction_record.item_key == item_key then
|
||||
private.record_auction(
|
||||
auction_record.item_key,
|
||||
auction_record.aux_quantity,
|
||||
auction_record.unit_blizzard_bid,
|
||||
auction_record.unit_buyout_price,
|
||||
auction_record.duration,
|
||||
auction_record.owner
|
||||
)
|
||||
end
|
||||
end,
|
||||
on_abort = function()
|
||||
existing_auctions[item_key] = nil
|
||||
private.update_historical_value_button()
|
||||
private.status_bar:update_status(100, 100)
|
||||
private.status_bar:set_text('Done Scanning')
|
||||
end,
|
||||
on_complete = function()
|
||||
existing_auctions[item_key] = existing_auctions[item_key] or {}
|
||||
private.refresh = true
|
||||
private.status_bar:update_status(100, 100)
|
||||
private.status_bar:set_text('Done Scanning')
|
||||
end,
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
function private.record_auction(key, aux_quantity, unit_blizzard_bid, unit_buyout_price, duration, owner)
|
||||
existing_auctions[key] = existing_auctions[key] or {}
|
||||
local entry
|
||||
for _, existing_entry in ipairs(existing_auctions[key]) do
|
||||
if unit_blizzard_bid == existing_entry.unit_blizzard_bid and unit_buyout_price == existing_entry.unit_buyout_price and aux_quantity == existing_entry.stack_size and duration == existing_entry.duration and Aux.is_player(owner) == existing_entry.own then
|
||||
entry = existing_entry
|
||||
end
|
||||
end
|
||||
|
||||
if not entry then
|
||||
entry = {
|
||||
stack_size = aux_quantity,
|
||||
unit_blizzard_bid = unit_blizzard_bid,
|
||||
unit_buyout_price = unit_buyout_price,
|
||||
duration = duration,
|
||||
own = Aux.is_player(owner),
|
||||
count = 0,
|
||||
}
|
||||
tinsert(existing_auctions[key], entry)
|
||||
end
|
||||
|
||||
entry.count = entry.count + 1
|
||||
|
||||
return entry
|
||||
end
|
||||
|
||||
function public.on_update()
|
||||
if private.refresh then
|
||||
private.refresh = false
|
||||
private.price_update()
|
||||
private.update_historical_value_button()
|
||||
private.update_item_configuration()
|
||||
private.update_inventory_listing()
|
||||
private.update_auction_listing()
|
||||
end
|
||||
|
||||
private.validate_parameters()
|
||||
end
|
||||
|
||||
function private.initialize_duration_dropdown()
|
||||
|
||||
local function on_click()
|
||||
UIDropDownMenu_SetSelectedValue(private.duration_dropdown, this.value)
|
||||
local settings = private.read_settings()
|
||||
settings.duration = this.value
|
||||
private.write_settings(settings)
|
||||
private.refresh = true
|
||||
end
|
||||
|
||||
UIDropDownMenu_AddButton{
|
||||
text = '2 Hours',
|
||||
value = DURATION_4,
|
||||
func = on_click,
|
||||
}
|
||||
|
||||
UIDropDownMenu_AddButton{
|
||||
text = '8 Hours',
|
||||
value = DURATION_8,
|
||||
func = on_click,
|
||||
}
|
||||
|
||||
UIDropDownMenu_AddButton{
|
||||
text = '24 Hours',
|
||||
value = DURATION_24,
|
||||
func = on_click,
|
||||
}
|
||||
end
|
||||
@@ -0,0 +1,50 @@
|
||||
<Ui xsi:schemaLocation="http://www.blizzard.com/wow/ui/">
|
||||
<Frame name="AuxPostFrame" parent="AuxFrame" hidden="true">
|
||||
<Anchors>
|
||||
<Anchor point="TOPLEFT"><Offset><AbsDimension x="0" y="0"/></Offset></Anchor>
|
||||
<Anchor point="BOTTOMRIGHT"><Offset><AbsDimension x="0" y="0"/></Offset></Anchor>
|
||||
</Anchors>
|
||||
<Scripts>
|
||||
<OnUpdate>
|
||||
Aux.post_frame.on_update()
|
||||
</OnUpdate>
|
||||
</Scripts>
|
||||
<Frames>
|
||||
<Frame name="$parentContent" inherits="AuxFrameBoxTemplate">
|
||||
<Anchors>
|
||||
<Anchor point="TOP" relativeTo="AuxFrame"><Offset><AbsDimension x="0" y="-8"/></Offset></Anchor>
|
||||
<Anchor point="BOTTOMLEFT" relativeTo="AuxFrameContent"></Anchor>
|
||||
<Anchor point="BOTTOMRIGHT" relativeTo="AuxFrameContent"></Anchor>
|
||||
</Anchors>
|
||||
<Frames>
|
||||
<Frame name="AuxPostInventory" inherits="AuxFrameBoxTemplate">
|
||||
<Size><AbsDimension x="212"/></Size>
|
||||
<Anchors>
|
||||
<Anchor point="TOPLEFT"><Offset><AbsDimension x="4" y="-4"/></Offset></Anchor>
|
||||
<Anchor point="BOTTOMLEFT"><Offset><AbsDimension x="4" y="4"/></Offset></Anchor>
|
||||
</Anchors>
|
||||
</Frame>
|
||||
<frame name="AuxPostParameters" inherits="AuxFrameBoxTemplate">
|
||||
<Size><AbsDimension y="177"/></Size>
|
||||
<Anchors>
|
||||
<Anchor point="TOPLEFT" relativePoint="TOPRIGHT" relativeTo="AuxPostInventory"><Offset><AbsDimension x="8" y="0"/></Offset></Anchor>
|
||||
<Anchor point="TOPRIGHT"><Offset><AbsDimension x="-4" y="0"/></Offset></Anchor>
|
||||
</Anchors>
|
||||
<frames>
|
||||
<Frame name="$parentItem" inherits="AuxItemTemplate">
|
||||
<Anchors><Anchor point="TOPLEFT"><Offset><AbsDimension x="10" y="-10"/></Offset></Anchor></Anchors>
|
||||
</Frame>
|
||||
</frames>
|
||||
</frame>
|
||||
<Frame name="AuxPostAuctions" inherits="AuxFrameBoxTemplate">
|
||||
<Size><AbsDimension y="217"/></Size>
|
||||
<Anchors>
|
||||
<Anchor point="BOTTOMLEFT" relativePoint="BOTTOMRIGHT" relativeTo="AuxPostInventory"><Offset><AbsDimension x="8" y="0"/></Offset></Anchor>
|
||||
<Anchor point="BOTTOMRIGHT"><Offset><AbsDimension x="-4" y="0"/></Offset></Anchor>
|
||||
</Anchors>
|
||||
</Frame>
|
||||
</Frames>
|
||||
</Frame>
|
||||
</Frames>
|
||||
</Frame>
|
||||
</Ui>
|
||||
@@ -0,0 +1,308 @@
|
||||
function Aux.post_frame.create_frames(private, public)
|
||||
Aux.gui.vertical_line(AuxPostFrameContent, 219)
|
||||
|
||||
AuxPostParametersItem:EnableMouse()
|
||||
AuxPostParametersItem:SetScript('OnReceiveDrag', function()
|
||||
local item_info = Aux.cursor_item()
|
||||
if item_info then
|
||||
public.select_item(item_info.item_key)
|
||||
end
|
||||
ClearCursor()
|
||||
end)
|
||||
-- AuxPostParametersItemIconTexture:SetScript('OnEnter', function()
|
||||
-- if private.selected_item then
|
||||
-- Aux.info.set_tooltip(private.selected_item.itemstring, this, 'ANCHOR_RIGHT')
|
||||
-- end
|
||||
-- end)
|
||||
-- AuxPostParametersItemIconTexture:SetScript('OnLeave', function()
|
||||
-- GameTooltip:Hide()
|
||||
-- end)
|
||||
|
||||
do
|
||||
local checkbox = CreateFrame('CheckButton', nil, AuxPostInventory, 'UICheckButtonTemplate')
|
||||
checkbox:SetWidth(22)
|
||||
checkbox:SetHeight(22)
|
||||
checkbox:SetPoint('TOPLEFT', 45, -15)
|
||||
checkbox:SetScript('OnClick', function()
|
||||
private.refresh = true
|
||||
end)
|
||||
local label = Aux.gui.label(checkbox, 13)
|
||||
label:SetPoint('LEFT', checkbox, 'RIGHT', 2, 1)
|
||||
label:SetText('Show hidden items')
|
||||
private.show_hidden_checkbox = checkbox
|
||||
end
|
||||
|
||||
Aux.gui.horizontal_line(AuxPostInventory, -48)
|
||||
|
||||
private.item_listing = Aux.item_listing.create(
|
||||
AuxPostInventory,
|
||||
function()
|
||||
if arg1 == 'LeftButton' then
|
||||
private.set_item(this.item_record)
|
||||
elseif arg1 == 'RightButton' then
|
||||
Aux.tab_group:set_tab(1)
|
||||
Aux.search_frame.execute('search', strlower(Aux.info.item(this.item_record.item_id).name)..'/exact')
|
||||
end
|
||||
end,
|
||||
function()
|
||||
Aux.info.set_tooltip(this.item_record.itemstring, this, 'ANCHOR_RIGHT')
|
||||
end,
|
||||
function()
|
||||
GameTooltip:Hide()
|
||||
end,
|
||||
function(item_record)
|
||||
return item_record == private.selected_item
|
||||
end
|
||||
)
|
||||
|
||||
private.auction_listing = Aux.listing.CreateScrollingTable(AuxPostAuctions)
|
||||
private.auction_listing:SetColInfo({
|
||||
{ name='Auctions', width=.12, align='CENTER' },
|
||||
{ name='Left', width=.1, align='CENTER' },
|
||||
{ name='Qty', width=.08, align='CENTER' },
|
||||
{ name='Bid/ea', width=.23, align='RIGHT' },
|
||||
{ name='Bid Pct', width=.12, align='CENTER' },
|
||||
{ name='Buy/ea', width=.23, align='RIGHT' },
|
||||
{ name='Buy Pct', width=.12, align='CENTER' }
|
||||
})
|
||||
private.auction_listing:DisableSelection(true)
|
||||
private.auction_listing:SetHandler('OnClick', function(table, row_data, column, button)
|
||||
local column_index = Aux.util.index_of(column, column.row.cols)
|
||||
local unit_start_price, unit_buyout_price = private.undercut(row_data.record, private.stack_size_slider:GetValue(), button == 'RightButton')
|
||||
if column_index == 3 then
|
||||
private.stack_size_slider:SetValue(row_data.record.stack_size)
|
||||
elseif column_index == 4 then
|
||||
private.set_unit_start_price(unit_start_price)
|
||||
elseif column_index == 6 then
|
||||
private.set_unit_buyout_price(unit_buyout_price)
|
||||
end
|
||||
end)
|
||||
|
||||
do
|
||||
local status_bar = Aux.gui.status_bar(AuxPostFrame)
|
||||
status_bar:SetWidth(265)
|
||||
status_bar:SetHeight(25)
|
||||
status_bar:SetPoint('TOPLEFT', AuxFrameContent, 'BOTTOMLEFT', 0, -6)
|
||||
status_bar:update_status(100, 100)
|
||||
status_bar:set_text('')
|
||||
private.status_bar = status_bar
|
||||
end
|
||||
do
|
||||
local btn = Aux.gui.button(AuxPostParameters, 16)
|
||||
btn:SetPoint('TOPLEFT', private.status_bar, 'TOPRIGHT', 5, 0)
|
||||
btn:SetWidth(80)
|
||||
btn:SetHeight(24)
|
||||
btn:SetText('Post')
|
||||
btn:SetScript('OnClick', private.post_auctions)
|
||||
private.post_button = btn
|
||||
end
|
||||
do
|
||||
local btn = Aux.gui.button(AuxPostParameters, 16)
|
||||
btn:SetPoint('TOPLEFT', private.post_button, 'TOPRIGHT', 5, 0)
|
||||
btn:SetWidth(80)
|
||||
btn:SetHeight(24)
|
||||
btn:SetText('Refresh')
|
||||
btn:SetScript('OnClick', private.refresh)
|
||||
private.refresh_button = btn
|
||||
end
|
||||
do
|
||||
local slider = Aux.gui.slider(AuxPostParameters)
|
||||
slider:SetValueStep(1)
|
||||
slider:SetPoint('TOPLEFT', 16, -75)
|
||||
slider:SetWidth(190)
|
||||
slider:SetScript('OnValueChanged', function()
|
||||
private.quantity_update(true)
|
||||
end)
|
||||
slider.editbox:SetScript('OnTextChanged', function()
|
||||
slider:SetValue(this:GetNumber())
|
||||
private.quantity_update(true)
|
||||
if private.selected_item then
|
||||
local settings = private.read_settings()
|
||||
settings.stack_size = this:GetNumber()
|
||||
private.write_settings(settings)
|
||||
end
|
||||
end)
|
||||
slider.editbox:SetScript('OnTabPressed', function()
|
||||
if IsShiftKeyDown() then
|
||||
private.unit_buyout_price:SetFocus()
|
||||
elseif private.stack_count_slider.editbox:IsVisible() then
|
||||
private.stack_count_slider.editbox:SetFocus()
|
||||
else
|
||||
private.unit_start_price:SetFocus()
|
||||
end
|
||||
end)
|
||||
slider.editbox:SetWidth(50)
|
||||
slider.editbox:SetNumeric(true)
|
||||
slider.editbox:SetMaxLetters(3)
|
||||
slider.label:SetText('Stack Size')
|
||||
slider.label:SetTextHeight(13)
|
||||
private.stack_size_slider = slider
|
||||
end
|
||||
do
|
||||
local slider = Aux.gui.slider(AuxPostParameters)
|
||||
slider:SetValueStep(1)
|
||||
slider:SetPoint('TOPLEFT', private.stack_size_slider, 'BOTTOMLEFT', 0, -30)
|
||||
slider:SetWidth(190)
|
||||
slider:SetScript('OnValueChanged', function()
|
||||
private.quantity_update()
|
||||
end)
|
||||
slider.editbox:SetScript('OnTextChanged', function()
|
||||
slider:SetValue(this:GetNumber())
|
||||
private.quantity_update()
|
||||
end)
|
||||
slider.editbox:SetScript('OnTabPressed', function()
|
||||
if IsShiftKeyDown() then
|
||||
private.stack_size_slider.editbox:SetFocus()
|
||||
else
|
||||
private.unit_start_price:SetFocus()
|
||||
end
|
||||
end)
|
||||
slider.editbox:SetWidth(50)
|
||||
slider.editbox:SetNumeric(true)
|
||||
slider.label:SetText('Stack Count')
|
||||
slider.label:SetTextHeight(13)
|
||||
private.stack_count_slider = slider
|
||||
end
|
||||
do
|
||||
local dropdown = Aux.gui.dropdown(AuxPostParameters)
|
||||
dropdown:SetPoint('TOPLEFT', private.stack_count_slider, 'BOTTOMLEFT', 0, -19)
|
||||
dropdown:SetWidth(90)
|
||||
dropdown:SetHeight(10)
|
||||
local label = Aux.gui.label(dropdown, 13)
|
||||
label:SetPoint('BOTTOMLEFT', dropdown, 'TOPLEFT', -2, -4)
|
||||
label:SetText('Duration')
|
||||
UIDropDownMenu_Initialize(dropdown, private.initialize_duration_dropdown)
|
||||
dropdown:SetScript('OnShow', function()
|
||||
UIDropDownMenu_Initialize(this, private.initialize_duration_dropdown)
|
||||
end)
|
||||
local label = Aux.gui.label(dropdown, 15)
|
||||
label:SetPoint('LEFT', dropdown, 'RIGHT', 25, 0)
|
||||
private.deposit = label
|
||||
private.duration_dropdown = dropdown
|
||||
end
|
||||
do
|
||||
local checkbox = CreateFrame('CheckButton', nil, AuxPostParameters, 'UICheckButtonTemplate')
|
||||
checkbox:SetWidth(22)
|
||||
checkbox:SetHeight(22)
|
||||
checkbox:SetPoint('TOPRIGHT', -85, -6)
|
||||
checkbox:SetScript('OnClick', function()
|
||||
local settings = private.read_settings()
|
||||
settings.hidden = this:GetChecked()
|
||||
private.write_settings(settings)
|
||||
private.refresh = true
|
||||
end)
|
||||
local label = Aux.gui.label(checkbox, 13)
|
||||
label:SetPoint('LEFT', checkbox, 'RIGHT', 2, 1)
|
||||
label:SetText('Hide this item')
|
||||
private.hide_checkbox = checkbox
|
||||
end
|
||||
do
|
||||
local editbox = Aux.gui.editbox(AuxPostParameters)
|
||||
editbox:SetPoint('TOPRIGHT', -65, -66)
|
||||
editbox:SetJustifyH('RIGHT')
|
||||
editbox:SetWidth(150)
|
||||
editbox:SetScript('OnTextChanged', function()
|
||||
this.pretty:SetText(Aux.money.to_string(private.get_unit_start_price(), true, nil, 3))
|
||||
private.refresh = true
|
||||
end)
|
||||
editbox:SetScript('OnTabPressed', function()
|
||||
if IsShiftKeyDown() and private.stack_count_slider.editbox:IsVisible() then
|
||||
private.stack_count_slider.editbox:SetFocus()
|
||||
elseif IsShiftKeyDown() then
|
||||
private.stack_size_slider.editbox:SetFocus()
|
||||
else
|
||||
private.unit_buyout_price:SetFocus()
|
||||
end
|
||||
end)
|
||||
editbox:SetScript('OnEnterPressed', function()
|
||||
this:ClearFocus()
|
||||
end)
|
||||
editbox:SetScript('OnEditFocusGained', function()
|
||||
this:HighlightText()
|
||||
this.pretty:Hide()
|
||||
end)
|
||||
editbox:SetScript('OnEditFocusLost', function()
|
||||
this:SetText(Aux.money.to_string(private.get_unit_start_price(), true, nil, 3, nil, true))
|
||||
this.pretty:Show()
|
||||
end)
|
||||
editbox.pretty = Aux.gui.label(editbox, Aux.gui.config.normal_font_size)
|
||||
editbox.pretty:SetAllPoints()
|
||||
editbox.pretty:SetJustifyH('RIGHT')
|
||||
do
|
||||
local label = Aux.gui.label(editbox, 13)
|
||||
label:SetPoint('BOTTOMLEFT', editbox, 'TOPLEFT', -2, 1)
|
||||
label:SetText('Unit Starting Price')
|
||||
end
|
||||
do
|
||||
local label = Aux.gui.label(editbox, 13)
|
||||
label:SetPoint('LEFT', editbox, 'RIGHT', 3, 0)
|
||||
label:SetWidth(50)
|
||||
label:SetJustifyH('CENTER')
|
||||
private.start_price_percentage = label
|
||||
end
|
||||
private.unit_start_price = editbox
|
||||
end
|
||||
do
|
||||
local editbox = Aux.gui.editbox(AuxPostParameters)
|
||||
editbox:SetPoint('TOPRIGHT', private.unit_start_price, 'BOTTOMRIGHT', 0, -18)
|
||||
editbox:SetJustifyH('RIGHT')
|
||||
editbox:SetWidth(150)
|
||||
editbox:SetScript('OnTextChanged', function()
|
||||
this.pretty:SetText(Aux.money.to_string(private.get_unit_buyout_price(), true, nil, 3))
|
||||
private.refresh = true
|
||||
end)
|
||||
editbox:SetScript('OnTabPressed', function()
|
||||
if IsShiftKeyDown() then
|
||||
private.unit_start_price:SetFocus()
|
||||
else
|
||||
private.stack_size_slider.editbox:SetFocus()
|
||||
end
|
||||
end)
|
||||
editbox:SetScript('OnEnterPressed', function()
|
||||
this:ClearFocus()
|
||||
end)
|
||||
editbox:SetScript('OnEditFocusGained', function()
|
||||
this:HighlightText()
|
||||
this.pretty:Hide()
|
||||
end)
|
||||
editbox:SetScript('OnEditFocusLost', function()
|
||||
this:SetText(Aux.money.to_string(private.get_unit_buyout_price(), true, nil, 3, nil, true))
|
||||
this.pretty:Show()
|
||||
end)
|
||||
editbox.pretty = Aux.gui.label(editbox, Aux.gui.config.normal_font_size)
|
||||
editbox.pretty:SetAllPoints()
|
||||
editbox.pretty:SetJustifyH('RIGHT')
|
||||
do
|
||||
local label = Aux.gui.label(editbox, 13)
|
||||
label:SetPoint('BOTTOMLEFT', editbox, 'TOPLEFT', -2, 1)
|
||||
label:SetText('Unit Buyout Price')
|
||||
end
|
||||
do
|
||||
local label = Aux.gui.label(editbox, 13)
|
||||
label:SetPoint('LEFT', editbox, 'RIGHT', 3, 0)
|
||||
label:SetWidth(50)
|
||||
label:SetJustifyH('CENTER')
|
||||
private.buyout_price_percentage = label
|
||||
end
|
||||
private.unit_buyout_price = editbox
|
||||
end
|
||||
do
|
||||
local btn = Aux.gui.button(AuxPostParameters, 16)
|
||||
btn:SetPoint('TOPRIGHT', -15, -143)
|
||||
btn:SetWidth(150)
|
||||
btn:SetHeight(20)
|
||||
btn:GetFontString():SetTextHeight(15)
|
||||
btn:GetFontString():SetJustifyH('RIGHT')
|
||||
btn:GetFontString():SetPoint('RIGHT', 0, 0)
|
||||
btn:SetScript('OnClick', function()
|
||||
if this.amount then
|
||||
private.set_unit_start_price(this.amount)
|
||||
private.set_unit_buyout_price(this.amount)
|
||||
end
|
||||
end)
|
||||
local label = Aux.gui.label(btn, 13)
|
||||
label:SetPoint('BOTTOMLEFT', btn, 'TOPLEFT', -2, 1)
|
||||
label:SetText('Historical Value')
|
||||
private.historical_value_button = btn
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,571 @@
|
||||
local private, public = {}, {}
|
||||
Aux.search_frame = public
|
||||
|
||||
aux_favorite_searches = {}
|
||||
aux_recent_searches = {}
|
||||
|
||||
local search_scan_id
|
||||
|
||||
private.popup_info = {
|
||||
rename = {}
|
||||
}
|
||||
|
||||
do
|
||||
local function action()
|
||||
private.popup_info.rename.name = getglobal(this:GetParent():GetName()..'EditBox'):GetText()
|
||||
private.update_search_listings()
|
||||
end
|
||||
|
||||
StaticPopupDialogs['AUX_SEARCH_SAVED_RENAME'] = {
|
||||
text = 'Enter a new name for this search.',
|
||||
button1 = 'Accept',
|
||||
button2 = 'Cancel',
|
||||
hasEditBox = 1,
|
||||
OnShow = function()
|
||||
local rename_info = private.popup_info.rename
|
||||
local edit_box = getglobal(this:GetName()..'EditBox')
|
||||
edit_box:SetText(rename_info.name or '')
|
||||
edit_box:SetFocus()
|
||||
edit_box:HighlightText()
|
||||
end,
|
||||
OnAccept = action,
|
||||
EditBoxOnEnterPressed = function()
|
||||
action()
|
||||
this:GetParent():Hide()
|
||||
end,
|
||||
EditBoxOnEscapePressed = function()
|
||||
this:GetParent():Hide()
|
||||
end,
|
||||
timeout = 0,
|
||||
hideOnEscape = 1,
|
||||
}
|
||||
end
|
||||
StaticPopupDialogs['AUX_SEARCH_TABLE_FULL'] = {
|
||||
text = 'Table full!\nFurther results from this search will be discarded.',
|
||||
button1 = 'Ok',
|
||||
showAlert = 1,
|
||||
timeout = 0,
|
||||
hideOnEscape = 1,
|
||||
}
|
||||
|
||||
private.RESULTS, private.SAVED, private.FILTER = 1, 2, 3
|
||||
|
||||
private.elements = {
|
||||
[private.RESULTS] = {},
|
||||
[private.SAVED] = {},
|
||||
[private.FILTER] = {},
|
||||
}
|
||||
|
||||
function private.update_search_listings()
|
||||
local favorite_search_rows = {}
|
||||
for i, favorite_search in ipairs(aux_favorite_searches) do
|
||||
local name = favorite_search.name and LIGHTYELLOW_FONT_COLOR_CODE..favorite_search.name..FONT_COLOR_CODE_CLOSE or strsub(favorite_search.prettified, 1, 250)
|
||||
tinsert(favorite_search_rows, {
|
||||
cols = {{value=name}},
|
||||
search = favorite_search,
|
||||
index = i,
|
||||
name = name,
|
||||
})
|
||||
end
|
||||
private.favorite_searches_listing:SetData(favorite_search_rows)
|
||||
|
||||
local recent_search_rows = {}
|
||||
for i, recent_search in ipairs(aux_recent_searches) do
|
||||
local name = recent_search.name and LIGHTYELLOW_FONT_COLOR_CODE..recent_search.name..FONT_COLOR_CODE_CLOSE or strsub(recent_search.prettified, 1, 250)
|
||||
tinsert(recent_search_rows, {
|
||||
cols = {{value=name}},
|
||||
search = recent_search,
|
||||
index = i,
|
||||
name = name,
|
||||
})
|
||||
end
|
||||
private.recent_searches_listing:SetData(recent_search_rows)
|
||||
end
|
||||
|
||||
function private.update_tab(tab)
|
||||
|
||||
private.search_results_button:UnlockHighlight()
|
||||
private.saved_searches_button:UnlockHighlight()
|
||||
private.new_filter_button:UnlockHighlight()
|
||||
AuxSearchFrameResults:Hide()
|
||||
AuxSearchFrameSaved:Hide()
|
||||
AuxSearchFrameFilter:Hide()
|
||||
|
||||
if tab == private.RESULTS then
|
||||
AuxSearchFrameResults:Show()
|
||||
private.search_results_button:LockHighlight()
|
||||
elseif tab == private.SAVED then
|
||||
AuxSearchFrameSaved:Show()
|
||||
private.saved_searches_button:LockHighlight()
|
||||
elseif tab == private.FILTER then
|
||||
AuxSearchFrameFilter:Show()
|
||||
private.new_filter_button:LockHighlight()
|
||||
end
|
||||
end
|
||||
|
||||
function public.set_filter(filter_string)
|
||||
private.search_box:SetText(filter_string)
|
||||
end
|
||||
|
||||
function private.add_filter(filter_string, replace)
|
||||
filter_string = filter_string or private.get_form_filter()
|
||||
|
||||
|
||||
local old_filter_string
|
||||
if not replace then
|
||||
old_filter_string = private.search_box:GetText()
|
||||
old_filter_string = Aux.util.trim(old_filter_string)
|
||||
|
||||
if strlen(old_filter_string) > 0 then
|
||||
old_filter_string = old_filter_string..';'
|
||||
end
|
||||
end
|
||||
|
||||
private.search_box:SetText((old_filter_string or '')..filter_string)
|
||||
end
|
||||
|
||||
function private.clear_form()
|
||||
AuxSearchFrameFilterNameInputBox:SetText('')
|
||||
AuxSearchFrameFilterExactCheckButton:SetChecked(nil)
|
||||
AuxSearchFrameFilterMinLevel:SetText('')
|
||||
AuxSearchFrameFilterMaxLevel:SetText('')
|
||||
AuxSearchFrameFilterUsableCheckButton:SetChecked(nil)
|
||||
UIDropDownMenu_ClearAll(private.class_dropdown)
|
||||
UIDropDownMenu_ClearAll(private.subclass_dropdown)
|
||||
UIDropDownMenu_ClearAll(private.slot_dropdown)
|
||||
UIDropDownMenu_ClearAll(private.quality_dropdown)
|
||||
private.first_page_editbox:SetText('')
|
||||
private.last_page_editbox:SetText('')
|
||||
end
|
||||
|
||||
function private.get_form_filter()
|
||||
local filter_term = ''
|
||||
|
||||
local function add(part)
|
||||
filter_term = filter_term == '' and part or filter_term..'/'..part
|
||||
end
|
||||
|
||||
add(AuxSearchFrameFilterNameInputBox:GetText())
|
||||
|
||||
if AuxSearchFrameFilterExactCheckButton:GetChecked() then
|
||||
add('exact')
|
||||
end
|
||||
|
||||
if tonumber(AuxSearchFrameFilterMinLevel:GetText()) then
|
||||
add(max(1, min(60, tonumber(AuxSearchFrameFilterMinLevel:GetText()))))
|
||||
end
|
||||
|
||||
if tonumber(AuxSearchFrameFilterMaxLevel:GetText()) then
|
||||
add(max(1, min(60, tonumber(AuxSearchFrameFilterMaxLevel:GetText()))))
|
||||
end
|
||||
|
||||
if AuxSearchFrameFilterUsableCheckButton:GetChecked() then
|
||||
add('usable')
|
||||
end
|
||||
|
||||
local class = UIDropDownMenu_GetSelectedValue(private.class_dropdown) ~= 0 and UIDropDownMenu_GetSelectedValue(private.class_dropdown)
|
||||
if class then
|
||||
local classes = { GetAuctionItemClasses() }
|
||||
add(strlower(classes[class]))
|
||||
local subclass = UIDropDownMenu_GetSelectedValue(private.subclass_dropdown) ~= 0 and UIDropDownMenu_GetSelectedValue(private.subclass_dropdown)
|
||||
if subclass then
|
||||
local subclasses = {GetAuctionItemSubClasses(class)}
|
||||
add(strlower(subclasses[subclass]))
|
||||
local slot = UIDropDownMenu_GetSelectedValue(private.slot_dropdown) ~= 0 and UIDropDownMenu_GetSelectedValue(private.slot_dropdown)
|
||||
if slot then
|
||||
add(strlower(getglobal(slot)))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local quality = UIDropDownMenu_GetSelectedValue(private.quality_dropdown) ~= 0 and UIDropDownMenu_GetSelectedValue(private.quality_dropdown)
|
||||
if quality then
|
||||
add(strlower(getglobal('ITEM_QUALITY'..quality..'_DESC')))
|
||||
end
|
||||
|
||||
local first_page, last_page = tonumber(private.first_page_editbox:GetText()), tonumber(private.last_page_editbox:GetText())
|
||||
first_page = first_page and max(1, first_page)
|
||||
last_page = last_page and max(1, last_page)
|
||||
if first_page or last_page then
|
||||
add((first_page or '') .. ':' .. (last_page or ''))
|
||||
end
|
||||
|
||||
return filter_term
|
||||
end
|
||||
|
||||
function public.on_open()
|
||||
private.update_search_listings()
|
||||
end
|
||||
|
||||
function public.on_close()
|
||||
private.results_listing:SetSelectedRecord(nil)
|
||||
end
|
||||
|
||||
function public.on_load()
|
||||
public.create_frames(private, public)
|
||||
private.update_search()
|
||||
private.update_tab(private.SAVED)
|
||||
end
|
||||
|
||||
function public.execute(mode, filter_string)
|
||||
if filter_string then
|
||||
private.search_box:SetText(filter_string)
|
||||
end
|
||||
|
||||
local queries
|
||||
if mode == 'search' or mode == 'refresh' then
|
||||
if mode == 'refresh' then
|
||||
private.search_box:SetText(private.current_search().filter_string)
|
||||
end
|
||||
|
||||
local filters = Aux.scan_util.parse_filter_string(private.search_box:GetText())
|
||||
if not filters then
|
||||
return
|
||||
end
|
||||
|
||||
queries = Aux.util.map(filters, function(filter)
|
||||
return {
|
||||
blizzard_query = filter.blizzard_query,
|
||||
validator = filter.validator,
|
||||
}
|
||||
end)
|
||||
|
||||
if mode == 'search' then
|
||||
tinsert(aux_recent_searches, 1, {
|
||||
filter_string = private.search_box:GetText(),
|
||||
prettified = Aux.util.join(Aux.util.map(filters, function(filter) return filter.prettified end), ';'),
|
||||
})
|
||||
while getn(aux_recent_searches) > 50 do
|
||||
tremove(aux_recent_searches)
|
||||
end
|
||||
private.update_search_listings()
|
||||
private.new_search()
|
||||
end
|
||||
elseif mode == 'resume' then
|
||||
queries = private.current_search().continuation
|
||||
Aux.scan.abort(search_scan_id)
|
||||
private.current_search().continuation = nil
|
||||
private.resume_button:Disable()
|
||||
private.results_listing:SetSelectedRecord()
|
||||
end
|
||||
|
||||
private.update_tab(private.RESULTS)
|
||||
|
||||
local search = private.current_search()
|
||||
local current_query, current_page
|
||||
search_scan_id = Aux.scan.start{
|
||||
type = 'list',
|
||||
queries = queries,
|
||||
on_scan_start = function()
|
||||
private.status_bar:update_status(0,0)
|
||||
if mode == 'search' then
|
||||
private.status_bar:set_text('Scanning auctions...')
|
||||
elseif mode == 'refresh' then
|
||||
private.status_bar:set_text('Rescanning auctions...')
|
||||
elseif mode == 'resume' then
|
||||
private.status_bar:set_text('Resuming scan...')
|
||||
end
|
||||
end,
|
||||
on_page_loaded = function(page, total_pages)
|
||||
current_page = page
|
||||
private.status_bar:update_status(100 * (current_query - 1) / getn(queries), 100 * (page - 1) / total_pages)
|
||||
private.status_bar:set_text(format('Scanning %d / %d (Page %d / %d)', current_query, getn(queries), page, total_pages))
|
||||
end,
|
||||
on_page_scanned = function()
|
||||
private.results_listing:SetDatabase()
|
||||
end,
|
||||
on_start_query = function(query_index)
|
||||
current_query = query_index
|
||||
end,
|
||||
on_auction = function(auction_record)
|
||||
if getn(search.records) < 1000 then
|
||||
tinsert(search.records, auction_record)
|
||||
if getn(search.records) == 1000 then
|
||||
StaticPopup_Show('AUX_SEARCH_TABLE_FULL')
|
||||
end
|
||||
end
|
||||
end,
|
||||
on_complete = function()
|
||||
private.status_bar:update_status(100, 100)
|
||||
private.status_bar:set_text('Done Scanning')
|
||||
|
||||
if private.current_search() == search and AuxSearchFrameResults:IsVisible() and getn(search.records) == 0 then
|
||||
private.update_tab(private.SAVED)
|
||||
end
|
||||
end,
|
||||
on_abort = function()
|
||||
private.status_bar:update_status(100, 100)
|
||||
private.status_bar:set_text('Done Scanning')
|
||||
|
||||
for i=1,(current_query or 1)-1 do
|
||||
tremove(queries, 1)
|
||||
end
|
||||
if queries[1].blizzard_query then
|
||||
queries[1].blizzard_query.first_page = (current_page and (queries[1].blizzard_query.first_page or 0) + current_page or queries[1].blizzard_query.first_page)
|
||||
end
|
||||
search.continuation = queries
|
||||
if private.current_search() == search then
|
||||
private.resume_button:Enable()
|
||||
end
|
||||
end,
|
||||
}
|
||||
end
|
||||
|
||||
function private.test(record)
|
||||
return function(index)
|
||||
local auction_info = Aux.info.auction(index)
|
||||
return auction_info and auction_info.search_signature == record.search_signature
|
||||
end
|
||||
end
|
||||
|
||||
function private.record_remover(record)
|
||||
return function()
|
||||
private.results_listing:RemoveAuctionRecord(record)
|
||||
end
|
||||
end
|
||||
|
||||
function private.record_bid_updater(record)
|
||||
return
|
||||
end
|
||||
|
||||
do
|
||||
local scan_id
|
||||
local IDLE, SEARCHING, FOUND = {}, {}, {}
|
||||
local state = IDLE
|
||||
local found_index
|
||||
|
||||
function private.find_auction(record)
|
||||
if not private.results_listing:ContainsRecord(record) or Aux.is_player(record.owner) then
|
||||
return
|
||||
end
|
||||
|
||||
Aux.scan.abort(scan_id)
|
||||
state = SEARCHING
|
||||
scan_id = Aux.scan_util.find(
|
||||
record,
|
||||
private.status_bar,
|
||||
function()
|
||||
state = IDLE
|
||||
end,
|
||||
function()
|
||||
state = IDLE
|
||||
private.record_remover(record)()
|
||||
end,
|
||||
function(index)
|
||||
state = FOUND
|
||||
found_index = index
|
||||
|
||||
if not record.high_bidder then
|
||||
private.bid_button:SetScript('OnClick', function()
|
||||
if private.test(record)(index) and private.results_listing:ContainsRecord(record) then
|
||||
Aux.place_bid('list', index, record.bid_price, record.bid_price < record.buyout_price and function()
|
||||
Aux.info.bid_update(record)
|
||||
private.results_listing:SetDatabase()
|
||||
end or private.record_remover(record))
|
||||
end
|
||||
end)
|
||||
private.bid_button:Enable()
|
||||
end
|
||||
|
||||
if record.buyout_price > 0 then
|
||||
private.buyout_button:SetScript('OnClick', function()
|
||||
if private.test(record)(index) and private.results_listing:ContainsRecord(record) then
|
||||
Aux.place_bid('list', index, record.buyout_price, private.record_remover(record))
|
||||
end
|
||||
end)
|
||||
private.buyout_button:Enable()
|
||||
end
|
||||
end
|
||||
)
|
||||
end
|
||||
|
||||
function public.on_update()
|
||||
if state == IDLE or state == SEARCHING then
|
||||
private.buyout_button:Disable()
|
||||
private.bid_button:Disable()
|
||||
end
|
||||
|
||||
if state == SEARCHING then
|
||||
return
|
||||
end
|
||||
|
||||
local selection = private.results_listing:GetSelection()
|
||||
if not selection then
|
||||
state = IDLE
|
||||
elseif selection and state == IDLE then
|
||||
private.find_auction(selection.record)
|
||||
elseif state == FOUND and not private.test(selection.record)(found_index) then
|
||||
private.buyout_button:Disable()
|
||||
private.bid_button:Disable()
|
||||
if not Aux.bid_in_progress() then
|
||||
state = IDLE
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
do
|
||||
local searches = { [0] = {
|
||||
filter_string = '',
|
||||
records = {},
|
||||
}}
|
||||
local search_index = 0
|
||||
|
||||
function private.current_search()
|
||||
return searches[search_index]
|
||||
end
|
||||
|
||||
function private.update_search()
|
||||
Aux.scan.abort(search_scan_id)
|
||||
private.search_box:SetText(searches[search_index].filter_string)
|
||||
private.results_listing:Reset()
|
||||
private.results_listing:SetDatabase(searches[search_index].records)
|
||||
if search_index == 1 or search_index == 0 then
|
||||
private.previous_button:Disable()
|
||||
else
|
||||
private.previous_button:Enable()
|
||||
end
|
||||
if search_index == getn(searches) or search_index == 0 then
|
||||
private.next_button:Hide()
|
||||
private.search_box:SetPoint('LEFT', private.previous_button, 'RIGHT', 4, 0)
|
||||
else
|
||||
private.next_button:Show()
|
||||
private.search_box:SetPoint('LEFT', private.next_button, 'RIGHT', 4, 0)
|
||||
end
|
||||
if search_index > 0 then
|
||||
private.refresh_button:Enable()
|
||||
end
|
||||
if searches[search_index].continuation then
|
||||
private.resume_button:Enable()
|
||||
else
|
||||
private.resume_button:Disable()
|
||||
end
|
||||
end
|
||||
|
||||
function private.new_search()
|
||||
tinsert(searches, search_index + 1, {
|
||||
filter_string = private.search_box:GetText(),
|
||||
records = {},
|
||||
})
|
||||
while getn(searches) > search_index + 1 do
|
||||
tremove(searches)
|
||||
end
|
||||
if getn(searches) > 5 then
|
||||
tremove(searches, 1)
|
||||
end
|
||||
search_index = getn(searches)
|
||||
private.update_search()
|
||||
end
|
||||
|
||||
function private.previous_search()
|
||||
search_index = search_index - 1
|
||||
private.update_search()
|
||||
private.update_tab(private.RESULTS)
|
||||
end
|
||||
|
||||
function private.next_search()
|
||||
search_index = search_index + 1
|
||||
private.update_search()
|
||||
private.update_tab(private.RESULTS)
|
||||
end
|
||||
end
|
||||
|
||||
function private.initialize_class_dropdown()
|
||||
local function on_click()
|
||||
if this.value ~= UIDropDownMenu_GetSelectedValue(private.class_dropdown) then
|
||||
UIDropDownMenu_ClearAll(private.subclass_dropdown)
|
||||
UIDropDownMenu_ClearAll(private.slot_dropdown)
|
||||
end
|
||||
UIDropDownMenu_SetSelectedValue(private.class_dropdown, this.value)
|
||||
end
|
||||
|
||||
UIDropDownMenu_AddButton{
|
||||
text = ALL,
|
||||
value = 0,
|
||||
func = on_click,
|
||||
}
|
||||
|
||||
for i, class in pairs({ GetAuctionItemClasses() }) do
|
||||
UIDropDownMenu_AddButton{
|
||||
text = class,
|
||||
value = i,
|
||||
func = on_click,
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
function private.initialize_subclass_dropdown()
|
||||
|
||||
local function on_click()
|
||||
if this.value ~= UIDropDownMenu_GetSelectedValue(private.subclass_dropdown) then
|
||||
UIDropDownMenu_ClearAll(private.slot_dropdown)
|
||||
end
|
||||
UIDropDownMenu_SetSelectedValue(private.subclass_dropdown, this.value)
|
||||
end
|
||||
|
||||
local class_index = UIDropDownMenu_GetSelectedValue(private.class_dropdown)
|
||||
|
||||
if class_index and GetAuctionItemSubClasses(class_index) then
|
||||
UIDropDownMenu_AddButton{
|
||||
text = ALL,
|
||||
value = 0,
|
||||
func = on_click,
|
||||
}
|
||||
|
||||
for i, subclass in pairs({ GetAuctionItemSubClasses(class_index) }) do
|
||||
UIDropDownMenu_AddButton{
|
||||
text = subclass,
|
||||
value = i,
|
||||
func = on_click,
|
||||
}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function private.initialize_slot_dropdown()
|
||||
|
||||
local function on_click()
|
||||
UIDropDownMenu_SetSelectedValue(private.slot_dropdown, this.value)
|
||||
end
|
||||
|
||||
local class_index = UIDropDownMenu_GetSelectedValue(private.class_dropdown)
|
||||
local subclass_index = UIDropDownMenu_GetSelectedValue(private.subclass_dropdown)
|
||||
|
||||
if class_index and subclass_index and GetAuctionInvTypes(class_index, subclass_index) then
|
||||
UIDropDownMenu_AddButton{
|
||||
text = ALL,
|
||||
value = 0,
|
||||
func = on_click,
|
||||
}
|
||||
|
||||
for i, slot in pairs({ GetAuctionInvTypes(class_index, subclass_index) }) do
|
||||
local slot_name = getglobal(slot)
|
||||
UIDropDownMenu_AddButton{
|
||||
text = slot_name,
|
||||
value = slot,
|
||||
func = on_click,
|
||||
}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function private.initialize_quality_dropdown()
|
||||
|
||||
local function on_click()
|
||||
UIDropDownMenu_SetSelectedValue(private.quality_dropdown, this.value)
|
||||
end
|
||||
|
||||
UIDropDownMenu_AddButton{
|
||||
text = ALL,
|
||||
value = 0,
|
||||
func = on_click,
|
||||
}
|
||||
for i=0,4 do
|
||||
UIDropDownMenu_AddButton{
|
||||
text = getglobal('ITEM_QUALITY'..i..'_DESC'),
|
||||
value = i,
|
||||
func = on_click,
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
<Ui xsi:schemaLocation="http://www.blizzard.com/wow/ui/">
|
||||
<Frame name="AuxSearchFrame" hidden="true" parent="AuxFrame" setAllPoints="true">
|
||||
<Scripts>
|
||||
<OnUpdate>
|
||||
Aux.search_frame.on_update()
|
||||
</OnUpdate>
|
||||
</Scripts>
|
||||
<Frames>
|
||||
<Frame name="$parentFilter" inherits="AuxFrameBoxTemplate">
|
||||
<Anchors>
|
||||
<Anchor point="TOPLEFT" relativeTo="AuxFrameContent"></Anchor>
|
||||
<Anchor point="BOTTOMRIGHT" relativeTo="AuxFrameContent"></Anchor>
|
||||
</Anchors>
|
||||
</Frame>
|
||||
<Frame name="$parentResults" inherits="AuxFrameBoxTemplate">
|
||||
<Anchors>
|
||||
<Anchor point="TOPLEFT" relativeTo="AuxFrameContent"></Anchor>
|
||||
<Anchor point="BOTTOMRIGHT" relativeTo="AuxFrameContent"></Anchor>
|
||||
</Anchors>
|
||||
</Frame>
|
||||
<Frame name="$parentSaved" inherits="AuxFrameBoxTemplate">
|
||||
<Anchors>
|
||||
<Anchor point="TOPLEFT" relativeTo="AuxFrameContent"></Anchor>
|
||||
<Anchor point="BOTTOMRIGHT" relativeTo="AuxFrameContent"></Anchor>
|
||||
</Anchors>
|
||||
<Frames>
|
||||
<Frame name="$parentFavorite" inherits="AuxFrameBoxTemplate">
|
||||
<Size><AbsDimension x="373"/></Size>
|
||||
<Anchors>
|
||||
<Anchor point="TOPLEFT"><Offset><AbsDimension x="4" y="-4"/></Offset></Anchor>
|
||||
<Anchor point="BOTTOMLEFT"><Offset><AbsDimension x="4" y="4"/></Offset></Anchor>
|
||||
</Anchors>
|
||||
</Frame>
|
||||
<Frame name="$parentRecent" inherits="AuxFrameBoxTemplate">
|
||||
<Size><AbsDimension x="373"/></Size>
|
||||
<Anchors>
|
||||
<Anchor point="TOPRIGHT"><Offset><AbsDimension x="-4" y="-4"/></Offset></Anchor>
|
||||
<Anchor point="BOTTOMRIGHT"><Offset><AbsDimension x="-4" y="4"/></Offset></Anchor>
|
||||
</Anchors>
|
||||
</Frame>
|
||||
</Frames>
|
||||
</Frame>
|
||||
</Frames>
|
||||
</Frame>
|
||||
</Ui>
|
||||
@@ -0,0 +1,647 @@
|
||||
function Aux.search_frame.create_frames(private, public)
|
||||
do
|
||||
local btn = Aux.gui.button(AuxSearchFrame, 26)
|
||||
btn:SetPoint('TOPLEFT', 5, -8)
|
||||
btn:SetWidth(30)
|
||||
btn:SetHeight(25)
|
||||
btn:SetText('<')
|
||||
btn:SetScript('OnClick', private.previous_search)
|
||||
private.previous_button = btn
|
||||
end
|
||||
do
|
||||
local btn = Aux.gui.button(AuxSearchFrame, 26)
|
||||
btn:SetPoint('LEFT', private.previous_button, 'RIGHT', 4, 0)
|
||||
btn:SetWidth(30)
|
||||
btn:SetHeight(25)
|
||||
btn:SetText('>')
|
||||
btn:SetScript('OnClick', private.next_search)
|
||||
private.next_button = btn
|
||||
end
|
||||
do
|
||||
local btn = Aux.gui.button(AuxSearchFrame, 22)
|
||||
btn:SetPoint('TOPRIGHT', -5, -8)
|
||||
btn:SetWidth(70)
|
||||
btn:SetHeight(25)
|
||||
btn:SetText('Resume')
|
||||
btn:SetScript('OnClick', function()
|
||||
private.search_box:ClearFocus()
|
||||
public.execute('resume')
|
||||
end)
|
||||
private.resume_button = btn
|
||||
end
|
||||
do
|
||||
local btn = Aux.gui.button(AuxSearchFrame, 22)
|
||||
btn:SetPoint('RIGHT', private.resume_button, 'LEFT', -4, 0)
|
||||
btn:SetWidth(70)
|
||||
btn:SetHeight(25)
|
||||
btn:SetText('Refresh')
|
||||
btn:SetScript('OnClick', function()
|
||||
public.execute('refresh')
|
||||
end)
|
||||
btn:Disable()
|
||||
private.refresh_button = btn
|
||||
end
|
||||
do
|
||||
local editbox = Aux.gui.editbox(AuxSearchFrame)
|
||||
editbox:SetMaxLetters(nil)
|
||||
editbox:EnableMouse(1)
|
||||
editbox.complete = Aux.completion.complete
|
||||
editbox:SetPoint('RIGHT', private.refresh_button, 'LEFT', -4, 0)
|
||||
editbox:SetHeight(25)
|
||||
editbox:SetScript('OnChar', function()
|
||||
this:complete()
|
||||
end)
|
||||
editbox:SetScript('OnTabPressed', function()
|
||||
this:HighlightText(0, 0)
|
||||
end)
|
||||
editbox:SetScript('OnEnterPressed', function()
|
||||
this:HighlightText(0, 0)
|
||||
this:ClearFocus()
|
||||
public.execute('search')
|
||||
end)
|
||||
editbox:SetScript('OnReceiveDrag', function()
|
||||
local item_info = Aux.cursor_item() and Aux.info.item(Aux.cursor_item().item_id)
|
||||
if item_info then
|
||||
public.execute('search', strlower(item_info.name)..'/exact')
|
||||
end
|
||||
ClearCursor()
|
||||
end)
|
||||
private.search_box = editbox
|
||||
end
|
||||
do
|
||||
Aux.gui.horizontal_line(AuxSearchFrame, -40)
|
||||
end
|
||||
do
|
||||
local btn = Aux.gui.button(AuxSearchFrame, 18)
|
||||
btn:SetPoint('BOTTOMLEFT', AuxFrameContent, 'TOPLEFT', 10, 8)
|
||||
btn:SetWidth(243)
|
||||
btn:SetHeight(22)
|
||||
btn:SetText('Search Results')
|
||||
btn:SetScript('OnClick', function() private.update_tab(private.RESULTS) end)
|
||||
private.search_results_button = btn
|
||||
end
|
||||
do
|
||||
local btn = Aux.gui.button(AuxSearchFrame, 18)
|
||||
btn:SetPoint('TOPLEFT', private.search_results_button, 'TOPRIGHT', 5, 0)
|
||||
btn:SetWidth(243)
|
||||
btn:SetHeight(22)
|
||||
btn:SetText('Saved Searches')
|
||||
btn:SetScript('OnClick', function() private.update_tab(private.SAVED) end)
|
||||
private.saved_searches_button = btn
|
||||
end
|
||||
do
|
||||
local btn = Aux.gui.button(AuxSearchFrame, 18)
|
||||
btn:SetPoint('TOPLEFT', private.saved_searches_button, 'TOPRIGHT', 5, 0)
|
||||
btn:SetWidth(243)
|
||||
btn:SetHeight(22)
|
||||
btn:SetText('New Filter')
|
||||
btn:SetScript('OnClick', function() private.update_tab(private.FILTER) end)
|
||||
private.new_filter_button = btn
|
||||
end
|
||||
do
|
||||
local status_bar = Aux.gui.status_bar(AuxSearchFrame)
|
||||
status_bar:SetWidth(265)
|
||||
status_bar:SetHeight(25)
|
||||
status_bar:SetPoint('TOPLEFT', AuxFrameContent, 'BOTTOMLEFT', 0, -6)
|
||||
status_bar:update_status(100, 100)
|
||||
status_bar:set_text('')
|
||||
private.status_bar = status_bar
|
||||
end
|
||||
do
|
||||
local btn = Aux.gui.button(AuxSearchFrameResults, 16)
|
||||
btn:SetPoint('TOPLEFT', private.status_bar, 'TOPRIGHT', 5, 0)
|
||||
btn:SetWidth(80)
|
||||
btn:SetHeight(24)
|
||||
btn:SetText('Bid')
|
||||
btn:Disable()
|
||||
private.bid_button = btn
|
||||
end
|
||||
do
|
||||
local btn = Aux.gui.button(AuxSearchFrameResults, 16)
|
||||
btn:SetPoint('TOPLEFT', private.bid_button, 'TOPRIGHT', 5, 0)
|
||||
btn:SetWidth(80)
|
||||
btn:SetHeight(24)
|
||||
btn:SetText('Buyout')
|
||||
btn:Disable()
|
||||
private.buyout_button = btn
|
||||
end
|
||||
do
|
||||
local btn = Aux.gui.button(AuxSearchFrameResults, 16)
|
||||
btn:SetPoint('TOPLEFT', private.buyout_button, 'TOPRIGHT', 5, 0)
|
||||
btn:SetWidth(80)
|
||||
btn:SetHeight(24)
|
||||
btn:SetText('Clear')
|
||||
btn:SetScript('OnClick', function()
|
||||
while tremove(private:current_search().records) do end
|
||||
private.results_listing:SetDatabase()
|
||||
end)
|
||||
end
|
||||
do
|
||||
local btn = Aux.gui.button(AuxSearchFrameSaved, 16)
|
||||
btn:SetPoint('TOPLEFT', private.status_bar, 'TOPRIGHT', 5, 0)
|
||||
btn:SetWidth(80)
|
||||
btn:SetHeight(24)
|
||||
btn:SetText('Favorite')
|
||||
btn:SetScript('OnClick', function()
|
||||
local filters = Aux.scan_util.parse_filter_string(private.search_box:GetText())
|
||||
if filters then
|
||||
tinsert(aux_favorite_searches, 1, {
|
||||
filter_string = private.search_box:GetText(),
|
||||
prettified = Aux.util.join(Aux.util.map(filters, function(filter) return filter.prettified end), ';'),
|
||||
})
|
||||
end
|
||||
private.update_search_listings()
|
||||
end)
|
||||
end
|
||||
do
|
||||
local btn1 = Aux.gui.button(AuxSearchFrameFilter, 16)
|
||||
btn1:SetPoint('TOPLEFT', private.status_bar, 'TOPRIGHT', 5, 0)
|
||||
btn1:SetWidth(80)
|
||||
btn1:SetHeight(24)
|
||||
btn1:SetText('Search')
|
||||
btn1:SetScript('OnClick', function()
|
||||
private.search_box:SetText('')
|
||||
private.add_filter()
|
||||
private.clear_form()
|
||||
public.execute('search')
|
||||
end)
|
||||
|
||||
local btn2 = Aux.gui.button(AuxSearchFrameFilter, 16)
|
||||
btn2:SetPoint('LEFT', btn1, 'RIGHT', 5, 0)
|
||||
btn2:SetWidth(80)
|
||||
btn2:SetHeight(24)
|
||||
btn2:SetText('Add')
|
||||
btn2:SetScript('OnClick', function()
|
||||
private.add_filter()
|
||||
private.clear_form()
|
||||
end)
|
||||
|
||||
local btn3 = Aux.gui.button(AuxSearchFrameFilter, 16)
|
||||
btn3:SetPoint('LEFT', btn2, 'RIGHT', 5, 0)
|
||||
btn3:SetWidth(80)
|
||||
btn3:SetHeight(24)
|
||||
btn3:SetText('Replace')
|
||||
btn3:SetScript('OnClick', function()
|
||||
private.add_filter(nil, true)
|
||||
private.clear_form()
|
||||
end)
|
||||
end
|
||||
do
|
||||
local editbox = Aux.gui.editbox(AuxSearchFrameFilter, '$parentNameInputBox')
|
||||
editbox.complete_item = Aux.completion.completor(function() return aux_auctionable_items end)
|
||||
editbox:SetPoint('TOPLEFT', 14, -20)
|
||||
editbox:SetWidth(260)
|
||||
editbox:SetScript('OnChar', function()
|
||||
if AuxSearchFrameFilterExactCheckButton:GetChecked() then
|
||||
this:complete_item()
|
||||
end
|
||||
end)
|
||||
editbox:SetScript('OnTabPressed', function()
|
||||
if IsShiftKeyDown() then
|
||||
private.last_page_editbox:SetFocus()
|
||||
else
|
||||
getglobal(this:GetParent():GetName()..'MinLevel'):SetFocus()
|
||||
end
|
||||
end)
|
||||
editbox:SetScript('OnEnterPressed', function()
|
||||
this:ClearFocus()
|
||||
public.execute('search')
|
||||
end)
|
||||
local label = Aux.gui.label(editbox, 13)
|
||||
label:SetPoint('BOTTOMLEFT', editbox, 'TOPLEFT', -2, 1)
|
||||
label:SetText('Name')
|
||||
end
|
||||
do
|
||||
local checkbox = CreateFrame('CheckButton', '$parentExactCheckButton', AuxSearchFrameFilter, 'UICheckButtonTemplate')
|
||||
checkbox:SetWidth(22)
|
||||
checkbox:SetHeight(22)
|
||||
checkbox:SetPoint('TOPLEFT', AuxSearchFrameFilterNameInputBox, 'TOPRIGHT', 10, 0)
|
||||
local label = Aux.gui.label(AuxSearchFrameFilterExactCheckButton, 13)
|
||||
label:SetPoint('BOTTOMLEFT', AuxSearchFrameFilterExactCheckButton, 'TOPLEFT', 1, -3)
|
||||
label:SetText('Exact')
|
||||
private.show_hidden_checkbox = checkbox
|
||||
end
|
||||
do
|
||||
local editbox = Aux.gui.editbox(AuxSearchFrameFilter, '$parentMinLevel')
|
||||
editbox:SetPoint('TOPLEFT', AuxSearchFrameFilterNameInputBox, 'BOTTOMLEFT', 0, -22)
|
||||
editbox:SetWidth(125)
|
||||
editbox:SetNumeric(true)
|
||||
editbox:SetMaxLetters(2)
|
||||
editbox:SetScript('OnTabPressed', function()
|
||||
if IsShiftKeyDown() then
|
||||
getglobal(this:GetParent():GetName()..'NameInputBox'):SetFocus()
|
||||
else
|
||||
getglobal(this:GetParent():GetName()..'MaxLevel'):SetFocus()
|
||||
end
|
||||
end)
|
||||
editbox:SetScript('OnEnterPressed', function()
|
||||
this:ClearFocus()
|
||||
public.execute('search')
|
||||
end)
|
||||
local label = Aux.gui.label(editbox, 13)
|
||||
label:SetPoint('BOTTOMLEFT', editbox, 'TOPLEFT', -2, 1)
|
||||
label:SetText('Level Range')
|
||||
end
|
||||
do
|
||||
local editbox = Aux.gui.editbox(AuxSearchFrameFilter, '$parentMaxLevel')
|
||||
editbox:SetPoint('TOPLEFT', AuxSearchFrameFilterMinLevel, 'TOPRIGHT', 10, 0)
|
||||
editbox:SetWidth(125)
|
||||
editbox:SetNumeric(true)
|
||||
editbox:SetMaxLetters(2)
|
||||
editbox:SetScript('OnTabPressed', function()
|
||||
if IsShiftKeyDown() then
|
||||
getglobal(this:GetParent():GetName()..'MinLevel'):SetFocus()
|
||||
else
|
||||
private.first_page_editbox:SetFocus()
|
||||
end
|
||||
end)
|
||||
editbox:SetScript('OnEnterPressed', function()
|
||||
this:ClearFocus()
|
||||
public.execute('search')
|
||||
end)
|
||||
local label = Aux.gui.label(editbox, 13)
|
||||
label:SetPoint('RIGHT', editbox, 'LEFT', -4, 0)
|
||||
label:SetText('-')
|
||||
end
|
||||
do
|
||||
local checkbox = CreateFrame('CheckButton', '$parentUsableCheckButton', AuxSearchFrameFilter, 'UICheckButtonTemplate')
|
||||
checkbox:SetWidth(22)
|
||||
checkbox:SetHeight(22)
|
||||
checkbox:SetPoint('TOPLEFT', AuxSearchFrameFilterMaxLevel, 'TOPRIGHT', 10, 0)
|
||||
local label = Aux.gui.label(AuxSearchFrameFilterUsableCheckButton, 13)
|
||||
label:SetPoint('BOTTOMLEFT', AuxSearchFrameFilterUsableCheckButton, 'TOPLEFT', 1, -3)
|
||||
label:SetText('Usable')
|
||||
private.show_hidden_checkbox = checkbox
|
||||
end
|
||||
do
|
||||
local dropdown = Aux.gui.dropdown(AuxSearchFrameFilter)
|
||||
dropdown:SetPoint('TOPLEFT', AuxSearchFrameFilterMinLevel, 'BOTTOMLEFT', 0, -18)
|
||||
dropdown:SetWidth(300)
|
||||
dropdown:SetHeight(10)
|
||||
local label = Aux.gui.label(dropdown, 13)
|
||||
label:SetPoint('BOTTOMLEFT', dropdown, 'TOPLEFT', -2, -4)
|
||||
label:SetText('Item Class')
|
||||
UIDropDownMenu_Initialize(dropdown, private.initialize_class_dropdown)
|
||||
dropdown:SetScript('OnShow', function()
|
||||
UIDropDownMenu_Initialize(this, private.initialize_class_dropdown)
|
||||
end)
|
||||
private.class_dropdown = dropdown
|
||||
end
|
||||
do
|
||||
local dropdown = Aux.gui.dropdown(AuxSearchFrameFilter)
|
||||
dropdown:SetPoint('TOPLEFT', private.class_dropdown, 'BOTTOMLEFT', 0, -18)
|
||||
dropdown:SetWidth(300)
|
||||
dropdown:SetHeight(10)
|
||||
local label = Aux.gui.label(dropdown, 13)
|
||||
label:SetPoint('BOTTOMLEFT', dropdown, 'TOPLEFT', -2, -4)
|
||||
label:SetText('Item Subclass')
|
||||
UIDropDownMenu_Initialize(dropdown, private.initialize_subclass_dropdown)
|
||||
dropdown:SetScript('OnShow', function()
|
||||
UIDropDownMenu_Initialize(this, private.initialize_subclass_dropdown)
|
||||
end)
|
||||
private.subclass_dropdown = dropdown
|
||||
end
|
||||
do
|
||||
local dropdown = Aux.gui.dropdown(AuxSearchFrameFilter)
|
||||
dropdown:SetPoint('TOPLEFT', private.subclass_dropdown, 'BOTTOMLEFT', 0, -18)
|
||||
dropdown:SetWidth(300)
|
||||
dropdown:SetHeight(10)
|
||||
local label = Aux.gui.label(dropdown, 13)
|
||||
label:SetPoint('BOTTOMLEFT', dropdown, 'TOPLEFT', -2, -4)
|
||||
label:SetText('Item Slot')
|
||||
UIDropDownMenu_Initialize(dropdown, private.initialize_slot_dropdown)
|
||||
dropdown:SetScript('OnShow', function()
|
||||
UIDropDownMenu_Initialize(this, private.initialize_slot_dropdown)
|
||||
end)
|
||||
private.slot_dropdown = dropdown
|
||||
end
|
||||
do
|
||||
local dropdown = Aux.gui.dropdown(AuxSearchFrameFilter)
|
||||
dropdown:SetPoint('TOPLEFT', private.slot_dropdown, 'BOTTOMLEFT', 0, -18)
|
||||
dropdown:SetWidth(300)
|
||||
dropdown:SetHeight(10)
|
||||
local label = Aux.gui.label(dropdown, 13)
|
||||
label:SetPoint('BOTTOMLEFT', dropdown, 'TOPLEFT', -2, -4)
|
||||
label:SetText('Min Rarity')
|
||||
UIDropDownMenu_Initialize(dropdown, private.initialize_quality_dropdown)
|
||||
dropdown:SetScript('OnShow', function()
|
||||
UIDropDownMenu_Initialize(this, private.initialize_quality_dropdown)
|
||||
end)
|
||||
private.quality_dropdown = dropdown
|
||||
end
|
||||
do
|
||||
local editbox = Aux.gui.editbox(AuxSearchFrameFilter)
|
||||
editbox:SetPoint('TOPLEFT', private.quality_dropdown, 'BOTTOMLEFT', 0, -18)
|
||||
editbox:SetWidth(145)
|
||||
editbox:SetNumeric(true)
|
||||
editbox:SetMaxLetters(2)
|
||||
editbox:SetScript('OnTabPressed', function()
|
||||
if IsShiftKeyDown() then
|
||||
getglobal(this:GetParent():GetName()..'MaxLevel'):SetFocus()
|
||||
else
|
||||
private.last_page_editbox:SetFocus()
|
||||
end
|
||||
end)
|
||||
editbox:SetScript('OnEnterPressed', function()
|
||||
this:ClearFocus()
|
||||
public.execute('search')
|
||||
end)
|
||||
local label = Aux.gui.label(editbox, 13)
|
||||
label:SetPoint('BOTTOMLEFT', editbox, 'TOPLEFT', -2, 1)
|
||||
label:SetText('Page Range')
|
||||
private.first_page_editbox = editbox
|
||||
end
|
||||
do
|
||||
local editbox = Aux.gui.editbox(AuxSearchFrameFilter)
|
||||
editbox:SetPoint('TOPLEFT', private.first_page_editbox, 'TOPRIGHT', 10, 0)
|
||||
editbox:SetWidth(145)
|
||||
editbox:SetNumeric(true)
|
||||
editbox:SetMaxLetters(2)
|
||||
editbox:SetScript('OnTabPressed', function()
|
||||
if IsShiftKeyDown() then
|
||||
private.first_page_editbox:SetFocus()
|
||||
else
|
||||
getglobal(this:GetParent():GetName()..'NameInputBox'):SetFocus()
|
||||
end
|
||||
end)
|
||||
editbox:SetScript('OnEnterPressed', function()
|
||||
this:ClearFocus()
|
||||
public.execute('search')
|
||||
end)
|
||||
local label = Aux.gui.label(editbox, 13)
|
||||
label:SetPoint('RIGHT', editbox, 'LEFT', -4, 0)
|
||||
label:SetText('-')
|
||||
private.last_page_editbox = editbox
|
||||
end
|
||||
Aux.gui.vertical_line(AuxSearchFrameFilter, 332)
|
||||
do
|
||||
local label = Aux.gui.label(AuxSearchFrameFilterUsableCheckButton, 13)
|
||||
label:SetPoint('BOTTOMLEFT', AuxSearchFrameFilterUsableCheckButton, 'TOPLEFT', 1, -3)
|
||||
label:SetText('Usable')
|
||||
end
|
||||
local function add_modifier(...)
|
||||
local current_filter_string = private.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
|
||||
private.search_box:SetText(current_filter_string)
|
||||
end
|
||||
do
|
||||
local btn = Aux.gui.button(AuxSearchFrameFilter, 16)
|
||||
btn:SetPoint('TOPRIGHT', -362, -10)
|
||||
btn:SetWidth(50)
|
||||
btn:SetHeight(19)
|
||||
btn:SetText('and')
|
||||
btn:SetScript('OnClick', function()
|
||||
add_modifier('and')
|
||||
end)
|
||||
private.and_operator_button = btn
|
||||
end
|
||||
do
|
||||
local btn = Aux.gui.button(AuxSearchFrameFilter, 16)
|
||||
btn:SetPoint('LEFT', private.and_operator_button, 'RIGHT', 10, 0)
|
||||
btn:SetWidth(50)
|
||||
btn:SetHeight(19)
|
||||
btn:SetText('or')
|
||||
btn:SetScript('OnClick', function()
|
||||
add_modifier('or')
|
||||
end)
|
||||
private.or_operator_button = btn
|
||||
end
|
||||
do
|
||||
local btn = Aux.gui.button(AuxSearchFrameFilter, 16)
|
||||
btn:SetPoint('LEFT', private.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(AuxSearchFrameFilter, 16)
|
||||
btn:SetPoint('TOPLEFT', private.and_operator_button, 'BOTTOMLEFT', 0, -10)
|
||||
private.modifier_buttons['min-unit-bid'] = btn
|
||||
end
|
||||
do
|
||||
local btn = Aux.gui.button(AuxSearchFrameFilter, 16)
|
||||
btn:SetPoint('TOPLEFT', private.modifier_buttons['min-unit-bid'], 'BOTTOMLEFT', 0, -10)
|
||||
private.modifier_buttons['min-unit-buy'] = btn
|
||||
end
|
||||
do
|
||||
local btn = Aux.gui.button(AuxSearchFrameFilter, 16)
|
||||
btn:SetPoint('TOPLEFT', private.modifier_buttons['min-unit-buy'], 'BOTTOMLEFT', 0, -10)
|
||||
private.modifier_buttons['max-unit-bid'] = btn
|
||||
end
|
||||
do
|
||||
local btn = Aux.gui.button(AuxSearchFrameFilter, 16)
|
||||
btn:SetPoint('TOPLEFT', private.modifier_buttons['max-unit-bid'], 'BOTTOMLEFT', 0, -10)
|
||||
private.modifier_buttons['max-unit-buy'] = btn
|
||||
end
|
||||
do
|
||||
local btn = Aux.gui.button(AuxSearchFrameFilter, 16)
|
||||
btn:SetPoint('TOPLEFT', private.modifier_buttons['max-unit-buy'], 'BOTTOMLEFT', 0, -10)
|
||||
private.modifier_buttons['bid-profit'] = btn
|
||||
end
|
||||
do
|
||||
local btn = Aux.gui.button(AuxSearchFrameFilter, 16)
|
||||
btn:SetPoint('TOPLEFT', private.modifier_buttons['bid-profit'], 'BOTTOMLEFT', 0, -10)
|
||||
private.modifier_buttons['buy-profit'] = btn
|
||||
end
|
||||
do
|
||||
local btn = Aux.gui.button(AuxSearchFrameFilter, 16)
|
||||
btn:SetPoint('TOPLEFT', private.modifier_buttons['buy-profit'], 'BOTTOMLEFT', 0, -10)
|
||||
private.modifier_buttons['bid-vend-profit'] = btn
|
||||
end
|
||||
do
|
||||
local btn = Aux.gui.button(AuxSearchFrameFilter, 16)
|
||||
btn:SetPoint('TOPLEFT', private.modifier_buttons['bid-vend-profit'], 'BOTTOMLEFT', 0, -10)
|
||||
private.modifier_buttons['buy-vend-profit'] = btn
|
||||
end
|
||||
do
|
||||
local btn = Aux.gui.button(AuxSearchFrameFilter, 16)
|
||||
btn:SetPoint('TOPLEFT', private.modifier_buttons['buy-vend-profit'], 'BOTTOMLEFT', 0, -10)
|
||||
private.modifier_buttons['bid-dis-profit'] = btn
|
||||
end
|
||||
do
|
||||
local btn = Aux.gui.button(AuxSearchFrameFilter, 16)
|
||||
btn:SetPoint('TOPLEFT', private.modifier_buttons['bid-dis-profit'], 'BOTTOMLEFT', 0, -10)
|
||||
private.modifier_buttons['buy-dis-profit'] = btn
|
||||
end
|
||||
do
|
||||
local btn = Aux.gui.button(AuxSearchFrameFilter, 16)
|
||||
btn:SetPoint('TOPLEFT', private.and_operator_button, 'BOTTOMLEFT', 205, -10)
|
||||
private.modifier_buttons['bid-pct'] = btn
|
||||
end
|
||||
do
|
||||
local btn = Aux.gui.button(AuxSearchFrameFilter, 16)
|
||||
btn:SetPoint('TOPLEFT', private.modifier_buttons['bid-pct'], 'BOTTOMLEFT', 0, -10)
|
||||
private.modifier_buttons['buy-pct'] = btn
|
||||
end
|
||||
do
|
||||
local btn = Aux.gui.button(AuxSearchFrameFilter, 16)
|
||||
btn:SetPoint('TOPLEFT', private.modifier_buttons['buy-pct'], 'BOTTOMLEFT', 0, -10)
|
||||
private.modifier_buttons['item'] = btn
|
||||
end
|
||||
do
|
||||
local btn = Aux.gui.button(AuxSearchFrameFilter, 16)
|
||||
btn:SetPoint('TOPLEFT', private.modifier_buttons['item'], 'BOTTOMLEFT', 0, -10)
|
||||
private.modifier_buttons['tooltip'] = btn
|
||||
end
|
||||
do
|
||||
local btn = Aux.gui.button(AuxSearchFrameFilter, 16)
|
||||
btn:SetPoint('TOPLEFT', private.modifier_buttons['tooltip'], 'BOTTOMLEFT', 0, -10)
|
||||
private.modifier_buttons['min-lvl'] = btn
|
||||
end
|
||||
do
|
||||
local btn = Aux.gui.button(AuxSearchFrameFilter, 16)
|
||||
btn:SetPoint('TOPLEFT', private.modifier_buttons['min-lvl'], 'BOTTOMLEFT', 0, -10)
|
||||
private.modifier_buttons['max-lvl'] = btn
|
||||
end
|
||||
do
|
||||
local btn = Aux.gui.button(AuxSearchFrameFilter, 16)
|
||||
btn:SetPoint('TOPLEFT', private.modifier_buttons['max-lvl'], 'BOTTOMLEFT', 0, -10)
|
||||
private.modifier_buttons['rarity'] = btn
|
||||
end
|
||||
do
|
||||
local btn = Aux.gui.button(AuxSearchFrameFilter, 16)
|
||||
btn:SetPoint('TOPLEFT', private.modifier_buttons['rarity'], 'BOTTOMLEFT', 0, -10)
|
||||
private.modifier_buttons['left'] = btn
|
||||
end
|
||||
do
|
||||
local btn = Aux.gui.button(AuxSearchFrameFilter, 16)
|
||||
btn:SetPoint('TOPLEFT', private.modifier_buttons['left'], 'BOTTOMLEFT', 0, -10)
|
||||
private.modifier_buttons['utilizable'] = btn
|
||||
end
|
||||
do
|
||||
local btn = Aux.gui.button(AuxSearchFrameFilter, 16)
|
||||
btn:SetPoint('TOPLEFT', private.modifier_buttons['utilizable'], 'BOTTOMLEFT', 0, -10)
|
||||
private.modifier_buttons['discard'] = btn
|
||||
end
|
||||
for modifier_name, btn in private.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(AuxSearchFrameFilter)
|
||||
editbox.complete = Aux.completion.completor(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
|
||||
end
|
||||
|
||||
private.results_listing = Aux.auction_listing.CreateAuctionResultsTable(AuxSearchFrameResults, Aux.auction_listing.search_config)
|
||||
private.results_listing:SetSort(1,2,3,4,5,6,7,8,9)
|
||||
private.results_listing:Reset()
|
||||
private.results_listing:SetHandler('OnCellClick', function(cell, button)
|
||||
if IsAltKeyDown() and private.results_listing:GetSelection().record == cell.row.data.record then
|
||||
if button == 'LeftButton' and private.buyout_button:IsEnabled() then
|
||||
private.buyout_button:Click()
|
||||
elseif button == 'RightButton' and private.bid_button:IsEnabled() then
|
||||
private.bid_button:Click()
|
||||
end
|
||||
end
|
||||
end)
|
||||
private.results_listing:SetHandler('OnSelectionChanged', function(rt, datum)
|
||||
if not datum then return end
|
||||
private.find_auction(datum.record)
|
||||
end)
|
||||
|
||||
local handlers = {
|
||||
OnClick = function(st, data, _, button)
|
||||
if not data then return end
|
||||
if button == 'LeftButton' and IsShiftKeyDown() then
|
||||
private.search_box:SetText(data.search.filter_string)
|
||||
elseif button == 'RightButton' and IsShiftKeyDown() then
|
||||
private.add_filter(data.search.filter_string)
|
||||
elseif button == 'LeftButton' and IsAltKeyDown() then
|
||||
private.popup_info.rename = data.search
|
||||
StaticPopup_Show('AUX_SEARCH_SAVED_RENAME')
|
||||
elseif button == 'RightButton' and IsAltKeyDown() then
|
||||
-- unused
|
||||
elseif button == 'LeftButton' and IsControlKeyDown() then
|
||||
if st == private.favorite_searches_listing and data.index > 1 then
|
||||
local temp = aux_favorite_searches[data.index - 1]
|
||||
aux_favorite_searches[data.index - 1] = data.search
|
||||
aux_favorite_searches[data.index] = temp
|
||||
private.update_search_listings()
|
||||
end
|
||||
elseif button == 'RightButton' and IsControlKeyDown() then
|
||||
if st == private.favorite_searches_listing and data.index < getn(aux_favorite_searches) then
|
||||
local temp = aux_favorite_searches[data.index + 1]
|
||||
aux_favorite_searches[data.index + 1] = data.search
|
||||
aux_favorite_searches[data.index] = temp
|
||||
private.update_search_listings()
|
||||
end
|
||||
elseif button == 'LeftButton' then
|
||||
private.search_box:SetText(data.search.filter_string)
|
||||
public.execute('search')
|
||||
elseif button == 'RightButton' then
|
||||
if st == private.recent_searches_listing then
|
||||
tinsert(aux_favorite_searches, 1, data.search)
|
||||
elseif st == private.favorite_searches_listing then
|
||||
tremove(aux_favorite_searches, data.index)
|
||||
end
|
||||
private.update_search_listings()
|
||||
end
|
||||
end,
|
||||
OnEnter = function(st, data, self)
|
||||
if not data then return end
|
||||
GameTooltip_SetDefaultAnchor(GameTooltip, UIParent)
|
||||
GameTooltip:AddLine(gsub(data.search.prettified, ';', '\n\n'), 255/255, 254/255, 250/255, true)
|
||||
GameTooltip:Show()
|
||||
GameTooltip:Show()
|
||||
end,
|
||||
OnLeave = function()
|
||||
GameTooltip:ClearLines()
|
||||
GameTooltip:Hide()
|
||||
end
|
||||
}
|
||||
|
||||
private.recent_searches_listing = Aux.listing.CreateScrollingTable(AuxSearchFrameSavedRecent)
|
||||
private.recent_searches_listing:DisableSelection(true)
|
||||
private.recent_searches_listing:SetColInfo({{name='Recent Searches', width=1}})
|
||||
private.recent_searches_listing:SetHandler('OnClick', handlers.OnClick)
|
||||
private.recent_searches_listing:SetHandler('OnEnter', handlers.OnEnter)
|
||||
private.recent_searches_listing:SetHandler('OnLeave', handlers.OnLeave)
|
||||
|
||||
Aux.gui.vertical_line(AuxSearchFrameSaved, 379)
|
||||
|
||||
private.favorite_searches_listing = Aux.listing.CreateScrollingTable(AuxSearchFrameSavedFavorite)
|
||||
private.favorite_searches_listing:DisableSelection(true)
|
||||
private.favorite_searches_listing:SetColInfo({{name='Favorite Searches', width=1}})
|
||||
private.favorite_searches_listing:SetHandler('OnClick', handlers.OnClick)
|
||||
private.favorite_searches_listing:SetHandler('OnEnter', handlers.OnEnter)
|
||||
private.favorite_searches_listing:SetHandler('OnLeave', handlers.OnLeave)
|
||||
end
|
||||
Reference in New Issue
Block a user