diff --git a/gui.lua b/gui.lua index 64443b3..cacd3a3 100644 --- a/gui.lua +++ b/gui.lua @@ -8,7 +8,14 @@ public.config = { window = {backdrop = {24, 24, 24, .93}, border = {30, 30, 30, 1}}, panel = {backdrop = {24, 24, 24, 1}, border = {255, 255, 255, .03}}, 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, 1}, disabled = {190, 70, 70, 1}}, + + blue = {41, 146, 255, 1}, + green = {22, 255, 22, 1}, + yellow = {255, 255, 0, 1}, + orange = {255, 146, 24, 1}, + red = {255, 0, 0, 1}, + gray = {187, 187, 187, 1}, }, edge_size = 1.5, font = [[Fonts\ARIALN.TTF]], @@ -34,10 +41,22 @@ function private.color_accessor(callback) end) end -public.color = m.color_accessor(function(color) - local r, g, b, a = unpack(color) - return {r/255, g/255, b/255, a} -end) +do + local mt = { + __call = function(self, text) + local r, g, b, a = unpack(self) + if text then + return format('|c%02X%02X%02X%02X', a*255, r*255, g*255, b)..text..FONT_COLOR_CODE_CLOSE + else + return r, g, b, a + end + end + } + public.color = m.color_accessor(function(color) + local r, g, b, a = unpack(color) + return setmetatable({r/255, g/255, b/255, a}, mt) + end) +end public.inline_color = m.color_accessor(function(color) local r, g, b, a = unpack(color) diff --git a/util/filter.lua b/util/filter.lua index 1ef04fa..dcb45d4 100644 --- a/util/filter.lua +++ b/util/filter.lua @@ -555,16 +555,17 @@ function private.prettified_query_string(components) prettified.append(aux.auction_listing.colors.YELLOW..component[2]..(component[2] ~= 'not' and tonumber(component[3]) or '')..FONT_COLOR_CODE_CLOSE) elseif component[1] == 'filter' then if component[2] ~= 'tooltip' then - prettified.append(aux.auction_listing.colors.YELLOW..component[2]..FONT_COLOR_CODE_CLOSE) + prettified.append(aux.gui.color.yellow(component[2])) end for parameter in aux.util.present(component[3]) do if component[2] == 'item' then - prettified.append(aux.info.display_name(aux.cache.item_id(parameter)) or aux.auction_listing.colors.ORANGE..'['..parameter..']'..FONT_COLOR_CODE_CLOSE) + prettified.append(aux.info.display_name(aux.cache.item_id(parameter)) or aux.gui.color.orange('['..parameter..']')) else if m.filters[component[2]].input_type == 'money' then - parameter = aux.money.to_string(aux.money.from_string(parameter), nil, true, nil, nil, true) + prettified.append(aux.money.to_string(aux.money.from_string(parameter), nil, true, nil, aux.auction_listing.colors.ORANGE)) + else + prettified.append(aux.gui.color.orange(parameter)) end - prettified.append(aux.auction_listing.colors.ORANGE..parameter..FONT_COLOR_CODE_CLOSE) end end end diff --git a/util/money.lua b/util/money.lua index 25264b1..d8789f5 100644 --- a/util/money.lua +++ b/util/money.lua @@ -102,7 +102,7 @@ function public.to_string(money, pad, trim, decimal_points, color, no_color) text = m.format_number(copper, false, decimal_points, color)..copper_text end end - + if is_negative then if color then text = color..'-'..FONT_COLOR_CODE_CLOSE..text @@ -115,7 +115,8 @@ function public.to_string(money, pad, trim, decimal_points, color, no_color) end function public.from_string(value) - for _, number in {tonumber(value)} do + local number = tonumber(value) + if number and number >= 0 then return number * COPPER_PER_GOLD end