module refactoring
This commit is contained in:
@@ -9,8 +9,6 @@ public.config = {
|
|||||||
panel = {backdrop = {24, 24, 24, 1}, border = {255, 255, 255, .03}},
|
panel = {backdrop = {24, 24, 24, 1}, border = {255, 255, 255, .03}},
|
||||||
content = {backdrop = {42, 42, 42, 1}, border = {0, 0, 0, 0}},
|
content = {backdrop = {42, 42, 42, 1}, border = {0, 0, 0, 0}},
|
||||||
state = {enabled = {70, 180, 70}, disabled = {190, 70, 70}},
|
state = {enabled = {70, 180, 70}, disabled = {190, 70, 70}},
|
||||||
money1 = {gold = {255, 215, 10, 1}, silver = {252, 199, 207, 1}, copper = {237, 165, 95, 1}},
|
|
||||||
money2 = {gold = {}, silver = {}, copper = {}},
|
|
||||||
},
|
},
|
||||||
edge_size = 1.5,
|
edge_size = 1.5,
|
||||||
font = [[Fonts\ARIALN.TTF]],
|
font = [[Fonts\ARIALN.TTF]],
|
||||||
@@ -95,9 +93,11 @@ function m.LOAD()
|
|||||||
if strfind(dropdown:GetName() or '', 'aux_frame') then
|
if strfind(dropdown:GetName() or '', 'aux_frame') then
|
||||||
DropDownList1Backdrop:SetBackdrop({})
|
DropDownList1Backdrop:SetBackdrop({})
|
||||||
DropDownList1Backdrop.border:Show()
|
DropDownList1Backdrop.border:Show()
|
||||||
|
DropDownList1Backdrop.backdrop:SetAllPoints()
|
||||||
DropDownList1Backdrop.backdrop:Show()
|
DropDownList1Backdrop.backdrop:Show()
|
||||||
DropDownList1:SetWidth(dropdown:GetWidth() * 0.9)
|
DropDownList1:SetWidth(dropdown:GetWidth() * 0.9)
|
||||||
DropDownList1:SetHeight(DropDownList1:GetHeight() - 10)
|
DropDownList1:SetHeight(DropDownList1:GetHeight() - 10)
|
||||||
|
DropDownList1:ClearAllPoints()
|
||||||
DropDownList1:SetPoint('TOPLEFT', dropdown, 'BOTTOMLEFT', -2, -2)
|
DropDownList1:SetPoint('TOPLEFT', dropdown, 'BOTTOMLEFT', -2, -2)
|
||||||
for i=1,UIDROPDOWNMENU_MAXBUTTONS do
|
for i=1,UIDROPDOWNMENU_MAXBUTTONS do
|
||||||
local button = getglobal('DropDownList1Button'..i)
|
local button = getglobal('DropDownList1Button'..i)
|
||||||
|
|||||||
@@ -1,22 +1,28 @@
|
|||||||
local module = aux_module()
|
local addon = aux_module()
|
||||||
aux = tremove(module, 1)
|
aux = tremove(addon, 1)
|
||||||
local m, public, private = unpack(module)
|
local m, public, private = unpack(addon)
|
||||||
|
|
||||||
public.version = '3.9.0'
|
public.version = '3.9.0'
|
||||||
|
|
||||||
local function initialize_module(private_declarator)
|
private.modules = {}
|
||||||
private_declarator.LOAD = nil
|
function public.module(path)
|
||||||
end
|
if path == 'aux' then
|
||||||
initialize_module(public)
|
return unpack(addon)
|
||||||
private.modules = {aux=module}
|
elseif m.modules[path] then
|
||||||
function public.module(name)
|
return unpack(m.modules[path])
|
||||||
if m.modules[name] then
|
|
||||||
return unpack(m.modules[name])
|
|
||||||
else
|
else
|
||||||
local module = aux_module()
|
local module, prefix
|
||||||
initialize_module(module[4])
|
for name in string.gfind(path, '[%a_][%w_]*') do
|
||||||
m.modules[name] = module
|
local qualified_name = prefix and prefix..'.'..name or name
|
||||||
public[name] = tremove(module, 1)
|
module = m.modules[qualified_name]
|
||||||
|
if not module then
|
||||||
|
module = aux_module()
|
||||||
|
module[4].LOAD = nil
|
||||||
|
(prefix and m.modules[prefix] or addon)[2][name] = tremove(module, 1)
|
||||||
|
m.modules[qualified_name] = module
|
||||||
|
end
|
||||||
|
prefix = qualified_name
|
||||||
|
end
|
||||||
return unpack(module)
|
return unpack(module)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
+2
-2
@@ -70,7 +70,7 @@ end
|
|||||||
|
|
||||||
function private.get_unit_start_price()
|
function private.get_unit_start_price()
|
||||||
local money_text = m.unit_start_price:GetText()
|
local money_text = m.unit_start_price:GetText()
|
||||||
return aux.money.from_string(money_text) or (tonumber(money_text) and tonumber(money_text) * 10000) or 0
|
return aux.money.from_string(money_text) or 0
|
||||||
end
|
end
|
||||||
|
|
||||||
function private.set_unit_start_price(amount)
|
function private.set_unit_start_price(amount)
|
||||||
@@ -79,7 +79,7 @@ end
|
|||||||
|
|
||||||
function private.get_unit_buyout_price()
|
function private.get_unit_buyout_price()
|
||||||
local money_text = m.unit_buyout_price:GetText()
|
local money_text = m.unit_buyout_price:GetText()
|
||||||
return aux.money.from_string(money_text) or (tonumber(money_text) and tonumber(money_text) * 10000) or 0
|
return aux.money.from_string(money_text) or 0
|
||||||
end
|
end
|
||||||
|
|
||||||
function private.set_unit_buyout_price(amount)
|
function private.set_unit_buyout_price(amount)
|
||||||
|
|||||||
@@ -1,5 +1,10 @@
|
|||||||
local m, public, private = aux.module'filter'
|
local m, public, private = aux.module'filter'
|
||||||
|
|
||||||
|
private.OPERATOR_COLOR = ''
|
||||||
|
private.FILTER_COLOR = ''
|
||||||
|
private.PARAMETER_COLOR = ''
|
||||||
|
|
||||||
|
|
||||||
function private.default_filter(str)
|
function private.default_filter(str)
|
||||||
return {
|
return {
|
||||||
input_type = '',
|
input_type = '',
|
||||||
|
|||||||
+8
-9
@@ -1,8 +1,8 @@
|
|||||||
local m, public, private = aux.module'money'
|
local m, public, private = aux.module'money'
|
||||||
|
|
||||||
local GOLD_TEXT = '|cffffd70ag|r'
|
private.GOLD_TEXT = '|cffffd70ag|r'
|
||||||
local SILVER_TEXT = '|cffc7c7cfs|r'
|
private.SILVER_TEXT = '|cffc7c7cfs|r'
|
||||||
local COPPER_TEXT = '|cffeda55fc|r'
|
private.COPPER_TEXT = '|cffeda55fc|r'
|
||||||
|
|
||||||
do
|
do
|
||||||
local COPPER_PER_SILVER = 100
|
local COPPER_PER_SILVER = 100
|
||||||
@@ -21,7 +21,6 @@ do
|
|||||||
end
|
end
|
||||||
|
|
||||||
function public.to_string(money, pad, trim, decimal_points, color, no_color)
|
function public.to_string(money, pad, trim, decimal_points, color, no_color)
|
||||||
|
|
||||||
local is_negative = money < 0
|
local is_negative = money < 0
|
||||||
money = abs(money)
|
money = abs(money)
|
||||||
local gold, silver, copper = m.to_GSC(money)
|
local gold, silver, copper = m.to_GSC(money)
|
||||||
@@ -35,7 +34,7 @@ function public.to_string(money, pad, trim, decimal_points, color, no_color)
|
|||||||
if no_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 = m.GOLD_TEXT, m.SILVER_TEXT, m.COPPER_TEXT
|
||||||
end
|
end
|
||||||
|
|
||||||
local text
|
local text
|
||||||
@@ -73,10 +72,12 @@ function public.to_string(money, pad, trim, decimal_points, color, no_color)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function public.from_string(value)
|
function public.from_string(value)
|
||||||
value = strlower(value)
|
for _, number in {tonumber(value)} do
|
||||||
|
return number * COPPER_PER_GOLD
|
||||||
|
end
|
||||||
|
|
||||||
-- remove any colors
|
-- remove any colors
|
||||||
value = gsub(gsub(value, '\124c([0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F])', ''), '\124r', '')
|
value = gsub(gsub(strlower(value), '|c%x%x%x%x%x%x%x%x', ''), '|r', '')
|
||||||
|
|
||||||
-- extract gold/silver/copper values
|
-- extract gold/silver/copper values
|
||||||
local gold = tonumber(({strfind(value, '(%d*%.?%d+)g')})[3])
|
local gold = tonumber(({strfind(value, '(%d*%.?%d+)g')})[3])
|
||||||
@@ -94,10 +95,8 @@ function public.from_string(value)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function public.format_number(num, pad, decimal_padding, color)
|
function public.format_number(num, pad, decimal_padding, color)
|
||||||
|
|
||||||
local padding = pad and 2 + (decimal_padding and decimal_padding + 1 or 0) or 0
|
local padding = pad and 2 + (decimal_padding and decimal_padding + 1 or 0) or 0
|
||||||
num = format('%0'..padding..'.0'..(decimal_padding or 0)..'f', num)
|
num = format('%0'..padding..'.0'..(decimal_padding or 0)..'f', num)
|
||||||
|
|
||||||
if color then
|
if color then
|
||||||
return color..num..FONT_COLOR_CODE_CLOSE
|
return color..num..FONT_COLOR_CODE_CLOSE
|
||||||
else
|
else
|
||||||
|
|||||||
Reference in New Issue
Block a user