no more decimals in post
This commit is contained in:
+1
-1
@@ -291,7 +291,7 @@ function M.editbox(parent)
|
|||||||
set_content_style(editbox)
|
set_content_style(editbox)
|
||||||
editbox:SetScript('OnEscapePressed', function()
|
editbox:SetScript('OnEscapePressed', function()
|
||||||
this:ClearFocus()
|
this:ClearFocus()
|
||||||
;(this.escape or nop)()
|
do (this.escape or nop)() end
|
||||||
end)
|
end)
|
||||||
editbox:SetScript('OnEnterPressed', function() (this.enter or nop)() end)
|
editbox:SetScript('OnEnterPressed', function() (this.enter or nop)() end)
|
||||||
editbox:SetScript('OnEditFocusGained', function()
|
editbox:SetScript('OnEditFocusGained', function()
|
||||||
|
|||||||
+16
-27
@@ -34,7 +34,6 @@ function read_settings(item_key)
|
|||||||
item_key = item_key or selected_item.key
|
item_key = item_key or selected_item.key
|
||||||
return data[item_key] and persistence.read(settings_schema, data[item_key]) or default_settings
|
return data[item_key] and persistence.read(settings_schema, data[item_key]) or default_settings
|
||||||
end
|
end
|
||||||
|
|
||||||
function write_settings(settings, item_key)
|
function write_settings(settings, item_key)
|
||||||
item_key = item_key or selected_item.key
|
item_key = item_key or selected_item.key
|
||||||
data[item_key] = persistence.write(settings_schema, settings)
|
data[item_key] = persistence.write(settings_schema, settings)
|
||||||
@@ -42,19 +41,15 @@ end
|
|||||||
|
|
||||||
do
|
do
|
||||||
local bid_selections, buyout_selections = {}, {}
|
local bid_selections, buyout_selections = {}, {}
|
||||||
|
|
||||||
function get_bid_selection()
|
function get_bid_selection()
|
||||||
return bid_selections[selected_item.key]
|
return bid_selections[selected_item.key]
|
||||||
end
|
end
|
||||||
|
|
||||||
function set_bid_selection(record)
|
function set_bid_selection(record)
|
||||||
bid_selections[selected_item.key] = record
|
bid_selections[selected_item.key] = record
|
||||||
end
|
end
|
||||||
|
|
||||||
function get_buyout_selection()
|
function get_buyout_selection()
|
||||||
return buyout_selections[selected_item.key]
|
return buyout_selections[selected_item.key]
|
||||||
end
|
end
|
||||||
|
|
||||||
function set_buyout_selection(record)
|
function set_buyout_selection(record)
|
||||||
buyout_selections[selected_item.key] = record
|
buyout_selections[selected_item.key] = record
|
||||||
end
|
end
|
||||||
@@ -94,21 +89,23 @@ function USE_ITEM(item_info)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function get_unit_start_price()
|
function get_unit_start_price()
|
||||||
local money_text = unit_start_price_input:GetText()
|
return selected_item and read_settings().start_price or 0
|
||||||
return money.from_string(money_text) or 0
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function set_unit_start_price(amount)
|
function set_unit_start_price(amount)
|
||||||
unit_start_price_input:SetText(money.to_string(amount, true, nil, nil, true))
|
local settings = read_settings()
|
||||||
|
settings.start_price = amount
|
||||||
|
write_settings(settings)
|
||||||
end
|
end
|
||||||
|
|
||||||
function get_unit_buyout_price()
|
function get_unit_buyout_price()
|
||||||
local money_text = unit_buyout_price_input:GetText()
|
return selected_item and read_settings().buyout_price or 0
|
||||||
return money.from_string(money_text) or 0
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function set_unit_buyout_price(amount)
|
function set_unit_buyout_price(amount)
|
||||||
unit_buyout_price_input:SetText(money.to_string(amount, true, nil, nil, true))
|
local settings = read_settings()
|
||||||
|
settings.buyout_price = amount
|
||||||
|
write_settings(settings)
|
||||||
end
|
end
|
||||||
|
|
||||||
function update_inventory_listing()
|
function update_inventory_listing()
|
||||||
@@ -127,7 +124,7 @@ function update_auction_listing(listing, records, reference)
|
|||||||
local stack_size = stack_size_slider:GetValue()
|
local stack_size = stack_size_slider:GetValue()
|
||||||
for i = 1, getn(records[selected_item.key] or empty) do
|
for i = 1, getn(records[selected_item.key] or empty) do
|
||||||
local record = records[selected_item.key][i]
|
local record = records[selected_item.key][i]
|
||||||
local price_color = money.from_string(money.to_string(undercut(record, stack_size_slider:GetValue(), listing == 'bid'), true)) < reference and color.red
|
local price_color = undercut(record, stack_size_slider:GetValue(), listing == 'bid') < reference and color.red
|
||||||
local price = record.unit_price * (listing == 'bid' and record.stack_size / stack_size_slider:GetValue() or 1)
|
local price = record.unit_price * (listing == 'bid' and record.stack_size / stack_size_slider:GetValue() or 1)
|
||||||
tinsert(rows, O(
|
tinsert(rows, O(
|
||||||
'cols', A(
|
'cols', A(
|
||||||
@@ -194,25 +191,17 @@ end
|
|||||||
|
|
||||||
function price_update()
|
function price_update()
|
||||||
if selected_item then
|
if selected_item then
|
||||||
local settings = read_settings()
|
|
||||||
|
|
||||||
local historical_value = history.value(selected_item.key)
|
local historical_value = history.value(selected_item.key)
|
||||||
|
if bid_selection or buyout_selection then
|
||||||
if bid_selection then
|
unit_start_price = undercut(bid_selection or buyout_selection, stack_size_slider:GetValue(), bid_selection)
|
||||||
unit_start_price = undercut(bid_selection, stack_size_slider:GetValue(), true)
|
unit_start_price_input:SetText(money.to_string(unit_start_price, true, nil, nil, true))
|
||||||
elseif buyout_selection then
|
start_price_percentage:SetText(historical_value and al.percentage_historical(round(unit_start_price / historical_value * 100)) or '---')
|
||||||
unit_start_price = undercut(buyout_selection, stack_size_slider:GetValue())
|
|
||||||
end
|
end
|
||||||
settings.start_price = unit_start_price
|
|
||||||
start_price_percentage:SetText(historical_value and al.percentage_historical(round(unit_start_price / historical_value * 100)) or '---')
|
|
||||||
|
|
||||||
if buyout_selection then
|
if buyout_selection then
|
||||||
unit_buyout_price = undercut(buyout_selection, stack_size_slider:GetValue())
|
unit_buyout_price = undercut(buyout_selection, stack_size_slider:GetValue())
|
||||||
|
unit_buyout_price_input:SetText(money.to_string(unit_buyout_price, true, nil, nil, true))
|
||||||
|
buyout_price_percentage:SetText(historical_value and al.percentage_historical(round(unit_buyout_price / historical_value * 100)) or '---')
|
||||||
end
|
end
|
||||||
settings.buyout_price = unit_buyout_price
|
|
||||||
buyout_price_percentage:SetText(historical_value and al.percentage_historical(round(unit_buyout_price / historical_value * 100)) or '---')
|
|
||||||
|
|
||||||
write_settings(settings)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -382,7 +371,7 @@ function update_item(item)
|
|||||||
|
|
||||||
item.unit_vendor_price = unit_vendor_price(item.key)
|
item.unit_vendor_price = unit_vendor_price(item.key)
|
||||||
if not item.unit_vendor_price then
|
if not item.unit_vendor_price then
|
||||||
settings.hidden = 1
|
settings.hidden = true
|
||||||
write_settings(settings, item.key)
|
write_settings(settings, item.key)
|
||||||
refresh = true
|
refresh = true
|
||||||
return
|
return
|
||||||
|
|||||||
+2
-2
@@ -249,7 +249,7 @@ do
|
|||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
editbox.formatter = function() return money.to_string(unit_start_price, true) end
|
editbox.formatter = function() return money.to_string(unit_start_price, true) end
|
||||||
editbox.char = function() bid_selection, buyout_selection = nil, nil end
|
editbox.char = function() bid_selection, buyout_selection = nil, nil; unit_start_price = money.from_string(this:GetText()) end
|
||||||
editbox.change = function() refresh = true end
|
editbox.change = function() refresh = true end
|
||||||
editbox.enter = function() this:ClearFocus() end
|
editbox.enter = function() this:ClearFocus() end
|
||||||
editbox.focus_loss = function()
|
editbox.focus_loss = function()
|
||||||
@@ -284,7 +284,7 @@ do
|
|||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
editbox.formatter = function() return money.to_string(unit_buyout_price, true) end
|
editbox.formatter = function() return money.to_string(unit_buyout_price, true) end
|
||||||
editbox.char = function() buyout_selection = nil end
|
editbox.char = function() buyout_selection = nil; unit_buyout_price = money.from_string(this:GetText()) end
|
||||||
editbox.change = function() refresh = true end
|
editbox.change = function() refresh = true end
|
||||||
editbox.enter = function() this:ClearFocus() end
|
editbox.enter = function() this:ClearFocus() end
|
||||||
editbox.focus_loss = function()
|
editbox.focus_loss = function()
|
||||||
|
|||||||
+19
-12
@@ -34,7 +34,7 @@ function M.to_string2(money, exact, color)
|
|||||||
local NONE = '|cffa0a0a0' .. TEXT_NONE .. FONT_COLOR_CODE_CLOSE
|
local NONE = '|cffa0a0a0' .. TEXT_NONE .. FONT_COLOR_CODE_CLOSE
|
||||||
|
|
||||||
if not exact and money >= COPPER_PER_GOLD then
|
if not exact and money >= COPPER_PER_GOLD then
|
||||||
money = floor(money / COPPER_PER_SILVER + .5) * COPPER_PER_SILVER
|
money = round(money / COPPER_PER_SILVER) * COPPER_PER_SILVER
|
||||||
end
|
end
|
||||||
local g, s, c = to_gsc(money)
|
local g, s, c = to_gsc(money)
|
||||||
|
|
||||||
@@ -58,45 +58,43 @@ function M.to_string2(money, exact, color)
|
|||||||
return str
|
return str
|
||||||
end
|
end
|
||||||
|
|
||||||
function M.to_string(money, pad, trim, number_color, no_coin_color)
|
function M.to_string(money, pad, trim, color, no_color)
|
||||||
local is_negative = money < 0
|
local is_negative = money < 0
|
||||||
money = abs(money)
|
money = abs(money)
|
||||||
local gold, silver, copper = to_gsc(money)
|
local gold, silver, copper = to_gsc(money)
|
||||||
|
|
||||||
local gold_text, silver_text, copper_text
|
local gold_text, silver_text, copper_text
|
||||||
if no_coin_color then
|
if no_color then
|
||||||
gold_text, silver_text, copper_text = 'g', 's', 'c'
|
gold_text, silver_text, copper_text = 'g', 's', 'c'
|
||||||
else
|
else
|
||||||
gold_text, silver_text, copper_text = GOLD_TEXT, SILVER_TEXT, COPPER_TEXT
|
gold_text, silver_text, copper_text = GOLD_TEXT, SILVER_TEXT, COPPER_TEXT
|
||||||
end
|
end
|
||||||
|
|
||||||
number_color = number_color or color.none
|
|
||||||
|
|
||||||
local text
|
local text
|
||||||
if trim then
|
if trim then
|
||||||
local parts = temp-T
|
local parts = temp-T
|
||||||
if gold > 0 then
|
if gold > 0 then
|
||||||
tinsert(parts, number_color(gold) .. gold_text)
|
tinsert(parts, format_number(gold, false, color) .. gold_text)
|
||||||
end
|
end
|
||||||
if silver > 0 then
|
if silver > 0 then
|
||||||
tinsert(parts, number_color(silver) .. silver_text)
|
tinsert(parts, format_number(silver, pad, color) .. silver_text)
|
||||||
end
|
end
|
||||||
if copper > 0 or gold == 0 and silver == 0 then
|
if copper > 0 or gold == 0 and silver == 0 then
|
||||||
tinsert(parts, number_color(copper) .. copper_text)
|
tinsert(parts, format_number(copper, pad, color) .. copper_text)
|
||||||
end
|
end
|
||||||
text = join(parts, ' ')
|
text = join(parts, ' ')
|
||||||
else
|
else
|
||||||
if gold > 0 then
|
if gold > 0 then
|
||||||
text = number_color(gold) .. gold_text .. ' ' .. number_color(silver) .. silver_text .. ' ' .. number_color(copper) .. copper_text
|
text = format_number(gold, false, color) .. gold_text .. ' ' .. format_number(silver, pad, color) .. silver_text .. ' ' .. format_number(copper, pad, color) .. copper_text
|
||||||
elseif silver > 0 then
|
elseif silver > 0 then
|
||||||
text = number_color(silver) .. silver_text .. ' ' .. number_color(copper) .. copper_text
|
text = format_number(silver, false, color) .. silver_text .. ' ' .. format_number(copper, pad, color) .. copper_text
|
||||||
else
|
else
|
||||||
text = number_color(copper) .. copper_text
|
text = format_number(copper, false, color) .. copper_text
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if is_negative then
|
if is_negative then
|
||||||
text = number_color'-' .. text
|
text = (color and color'-' or '-') .. text
|
||||||
end
|
end
|
||||||
|
|
||||||
return text
|
return text
|
||||||
@@ -122,3 +120,12 @@ function M.from_string(value)
|
|||||||
|
|
||||||
return from_gsc(gold or 0, silver or 0, copper or 0)
|
return from_gsc(gold or 0, silver or 0, copper or 0)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function M.format_number(num, pad, color)
|
||||||
|
num = format('%0' .. (pad and 2 or 0) .. 'd', num)
|
||||||
|
if color then
|
||||||
|
return color .. num .. FONT_COLOR_CODE_CLOSE
|
||||||
|
else
|
||||||
|
return num
|
||||||
|
end
|
||||||
|
end
|
||||||
Reference in New Issue
Block a user