post selection improvements
This commit is contained in:
+6
-19
@@ -28,7 +28,7 @@ local handlers = {
|
|||||||
OnLeave = function()
|
OnLeave = function()
|
||||||
this.mouseover = false
|
this.mouseover = false
|
||||||
if not this.data then return end
|
if not this.data then return end
|
||||||
if not this.st.selected or this.st.selected ~= key(this.st.rowData, this.data) then
|
if not (this.st.selected and this.st.selected(this.data)) then
|
||||||
this.highlight:Hide()
|
this.highlight:Hide()
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -40,10 +40,6 @@ local handlers = {
|
|||||||
|
|
||||||
OnClick = function()
|
OnClick = function()
|
||||||
if not this.data then return end
|
if not this.data then return end
|
||||||
this.st:ClearSelection()
|
|
||||||
this.st.selected = not this.st.selectionDisabled and key(this.st.rowData, this.data)
|
|
||||||
this.highlight:Show()
|
|
||||||
|
|
||||||
local handler = this.st.handlers.OnClick
|
local handler = this.st.handlers.OnClick
|
||||||
if handler then
|
if handler then
|
||||||
handler(this.st, this.data, this, arg1)
|
handler(this.st, this.data, this, arg1)
|
||||||
@@ -132,7 +128,7 @@ local methods = {
|
|||||||
if not data then break end
|
if not data then break end
|
||||||
self.rows[i].data = data
|
self.rows[i].data = data
|
||||||
|
|
||||||
if self.selected == key(self.rowData, data) or self.rows[i].mouseover then
|
if self.rows[i].mouseover or self.selected and self.selected(data) then
|
||||||
self.rows[i].highlight:Show()
|
self.rows[i].highlight:Show()
|
||||||
else
|
else
|
||||||
self.rows[i].highlight:Hide()
|
self.rows[i].highlight:Hide()
|
||||||
@@ -163,19 +159,6 @@ local methods = {
|
|||||||
self:Update()
|
self:Update()
|
||||||
end,
|
end,
|
||||||
|
|
||||||
GetSelection = function(self)
|
|
||||||
return self.rowData[self.selected]
|
|
||||||
end,
|
|
||||||
|
|
||||||
ClearSelection = function(self)
|
|
||||||
self.selected = nil
|
|
||||||
self:Update()
|
|
||||||
end,
|
|
||||||
|
|
||||||
DisableSelection = function(self, value)
|
|
||||||
self.selectionDisabled = value
|
|
||||||
end,
|
|
||||||
|
|
||||||
AddColumn = function(self)
|
AddColumn = function(self)
|
||||||
local colNum = getn(self.headCols) + 1
|
local colNum = getn(self.headCols) + 1
|
||||||
local col = CreateFrame('Frame', nil, self.contentFrame)
|
local col = CreateFrame('Frame', nil, self.contentFrame)
|
||||||
@@ -258,6 +241,10 @@ local methods = {
|
|||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
|
|
||||||
|
SetSelection = function(self, f)
|
||||||
|
self.selected = f
|
||||||
|
end,
|
||||||
|
|
||||||
SetHandler = function(self, event, handler)
|
SetHandler = function(self, event, handler)
|
||||||
self.handlers[event] = handler
|
self.handlers[event] = handler
|
||||||
end,
|
end,
|
||||||
|
|||||||
+29
-13
@@ -19,7 +19,7 @@ TAB 'Post'
|
|||||||
local DURATION_4, DURATION_8, DURATION_24 = 120, 480, 1440
|
local DURATION_4, DURATION_8, DURATION_24 = 120, 480, 1440
|
||||||
local settings_schema = {'tuple', '#', {duration='number'}, {start_price='number'}, {buyout_price='number'}, {hidden='boolean'}}
|
local settings_schema = {'tuple', '#', {duration='number'}, {start_price='number'}, {buyout_price='number'}, {hidden='boolean'}}
|
||||||
|
|
||||||
local scan_id, inventory_records, bid_records, buyout_records = 0, T, T, T
|
local scan_id, inventory_records, bid_records, buyout_records = 0, {}, {}, {}
|
||||||
|
|
||||||
function get_default_settings()
|
function get_default_settings()
|
||||||
return O('duration', DURATION_8, 'start_price', 0, 'buyout_price', 0, 'hidden', false)
|
return O('duration', DURATION_8, 'start_price', 0, 'buyout_price', 0, 'hidden', false)
|
||||||
@@ -47,6 +47,26 @@ function write_settings(settings, item_key)
|
|||||||
data[item_key] = persistence.write(settings_schema, settings)
|
data[item_key] = persistence.write(settings_schema, settings)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
do
|
||||||
|
local bid_selections, buyout_selections = {}, {}
|
||||||
|
|
||||||
|
function get_bid_selection()
|
||||||
|
return bid_selections[selected_item.key]
|
||||||
|
end
|
||||||
|
|
||||||
|
function set_bid_selection(record)
|
||||||
|
bid_selections[selected_item.key] = record
|
||||||
|
end
|
||||||
|
|
||||||
|
function get_buyout_selection()
|
||||||
|
return buyout_selections[selected_item.key]
|
||||||
|
end
|
||||||
|
|
||||||
|
function set_buyout_selection(record)
|
||||||
|
buyout_selections[selected_item.key] = record
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
function refresh_button_click()
|
function refresh_button_click()
|
||||||
scan.abort(scan_id)
|
scan.abort(scan_id)
|
||||||
refresh_entries()
|
refresh_entries()
|
||||||
@@ -184,16 +204,16 @@ function price_update()
|
|||||||
|
|
||||||
local historical_value = history.value(selected_item.key)
|
local historical_value = history.value(selected_item.key)
|
||||||
|
|
||||||
if bid_listing:GetSelection() then
|
if bid_selection then
|
||||||
unit_start_price = undercut(bid_listing:GetSelection().record, stack_size_slider:GetValue(), true)
|
unit_start_price = undercut(bid_selection, stack_size_slider:GetValue(), true)
|
||||||
elseif buyout_listing:GetSelection() then
|
elseif buyout_selection then
|
||||||
unit_start_price = undercut(buyout_listing:GetSelection().record, stack_size_slider:GetValue())
|
unit_start_price = undercut(buyout_selection, stack_size_slider:GetValue())
|
||||||
end
|
end
|
||||||
settings.start_price = unit_start_price
|
settings.start_price = unit_start_price
|
||||||
start_price_percentage:SetText(historical_value and al.percentage_historical(round(unit_start_price / historical_value * 100)) or '---')
|
start_price_percentage:SetText(historical_value and al.percentage_historical(round(unit_start_price / historical_value * 100)) or '---')
|
||||||
|
|
||||||
if buyout_listing:GetSelection() then
|
if buyout_selection then
|
||||||
unit_buyout_price = undercut(buyout_listing:GetSelection().record, stack_size_slider:GetValue())
|
unit_buyout_price = undercut(buyout_selection, stack_size_slider:GetValue())
|
||||||
end
|
end
|
||||||
settings.buyout_price = unit_buyout_price
|
settings.buyout_price = unit_buyout_price
|
||||||
buyout_price_percentage:SetText(historical_value and al.percentage_historical(round(unit_buyout_price / historical_value * 100)) or '---')
|
buyout_price_percentage:SetText(historical_value and al.percentage_historical(round(unit_buyout_price / historical_value * 100)) or '---')
|
||||||
@@ -375,11 +395,6 @@ function update_item(item)
|
|||||||
|
|
||||||
scan.abort(scan_id)
|
scan.abort(scan_id)
|
||||||
|
|
||||||
if not selected_item or item.key ~= selected_item.key then
|
|
||||||
bid_listing:ClearSelection()
|
|
||||||
buyout_listing:ClearSelection()
|
|
||||||
end
|
|
||||||
|
|
||||||
selected_item = item
|
selected_item = item
|
||||||
|
|
||||||
UIDropDownMenu_Initialize(duration_dropdown, initialize_duration_dropdown)
|
UIDropDownMenu_Initialize(duration_dropdown, initialize_duration_dropdown)
|
||||||
@@ -457,6 +472,7 @@ function refresh_entries()
|
|||||||
if selected_item then
|
if selected_item then
|
||||||
local item_id, suffix_id = selected_item.item_id, selected_item.suffix_id
|
local item_id, suffix_id = selected_item.item_id, selected_item.suffix_id
|
||||||
local item_key = item_id .. ':' .. suffix_id
|
local item_key = item_id .. ':' .. suffix_id
|
||||||
|
bid_selection, buyout_selection = nil, nil
|
||||||
bid_records[item_key], buyout_records[item_key] = nil, nil
|
bid_records[item_key], buyout_records[item_key] = nil, nil
|
||||||
local query = scan_util.item_query(item_id)
|
local query = scan_util.item_query(item_id)
|
||||||
status_bar:update_status(0,0)
|
status_bar:update_status(0,0)
|
||||||
@@ -483,7 +499,7 @@ function refresh_entries()
|
|||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
on_abort = function()
|
on_abort = function()
|
||||||
bid_records[item_key], buyout_records[item_key]= nil, nil
|
bid_records[item_key], buyout_records[item_key] = nil, nil
|
||||||
status_bar:update_status(1, 1)
|
status_bar:update_status(1, 1)
|
||||||
status_bar:set_text('Scan aborted')
|
status_bar:set_text('Scan aborted')
|
||||||
end,
|
end,
|
||||||
|
|||||||
@@ -80,7 +80,11 @@ bid_listing:SetColInfo{
|
|||||||
{name='Auction Bid\n(per item)', width=.4, align='RIGHT'},
|
{name='Auction Bid\n(per item)', width=.4, align='RIGHT'},
|
||||||
{name='% Hist.\nValue', width=.21, align='CENTER'},
|
{name='% Hist.\nValue', width=.21, align='CENTER'},
|
||||||
}
|
}
|
||||||
|
bid_listing:SetSelection(function(data)
|
||||||
|
return data.record == bid_selection
|
||||||
|
end)
|
||||||
bid_listing:SetHandler('OnClick', function(table, row_data, column, button)
|
bid_listing:SetHandler('OnClick', function(table, row_data, column, button)
|
||||||
|
bid_selection = row_data.record
|
||||||
refresh = true
|
refresh = true
|
||||||
end)
|
end)
|
||||||
bid_listing:SetHandler('OnDoubleClick', function(table, row_data, column, button)
|
bid_listing:SetHandler('OnDoubleClick', function(table, row_data, column, button)
|
||||||
@@ -96,7 +100,11 @@ buyout_listing:SetColInfo{
|
|||||||
{name='Auction Buyout\n(per item)', width=.4, align='RIGHT'},
|
{name='Auction Buyout\n(per item)', width=.4, align='RIGHT'},
|
||||||
{name='% Hist.\nValue', width=.20, align='CENTER'},
|
{name='% Hist.\nValue', width=.20, align='CENTER'},
|
||||||
}
|
}
|
||||||
|
buyout_listing:SetSelection(function(data)
|
||||||
|
return data.record == buyout_selection
|
||||||
|
end)
|
||||||
buyout_listing:SetHandler('OnClick', function(table, row_data, column, button)
|
buyout_listing:SetHandler('OnClick', function(table, row_data, column, button)
|
||||||
|
buyout_selection = row_data.record
|
||||||
refresh = true
|
refresh = true
|
||||||
end)
|
end)
|
||||||
buyout_listing:SetHandler('OnDoubleClick', function(table, row_data, column, button)
|
buyout_listing:SetHandler('OnDoubleClick', function(table, row_data, column, button)
|
||||||
|
|||||||
@@ -542,7 +542,6 @@ recent_searches_listing = listing.new(frame.saved.recent)
|
|||||||
recent_searches_listing:SetColInfo{{name='Recent Searches', width=1}}
|
recent_searches_listing:SetColInfo{{name='Recent Searches', width=1}}
|
||||||
|
|
||||||
for listing in temp-S(favorite_searches_listing, recent_searches_listing) do
|
for listing in temp-S(favorite_searches_listing, recent_searches_listing) do
|
||||||
listing:DisableSelection(true)
|
|
||||||
for k, v in handlers do
|
for k, v in handlers do
|
||||||
listing:SetHandler(k, v)
|
listing:SetHandler(k, v)
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user