From cb986e15821c49100c26120a69e90d0f9fbbd7d9 Mon Sep 17 00:00:00 2001 From: Polite Kiwi Date: Tue, 22 Oct 2019 00:00:09 -0400 Subject: [PATCH] Added The Following... - Updated to version 2.2.4 - Added variable tooltip_ilvl_nocolors (boolean) - Added variable tooltip_ilvl_nocolors_rgb (string) - You can now disable my coloration of ilvl - Make them all one single color - Make them all a custom color - Defaults to white - Tooltip updated to not crash on GetItemInfo - Variables there are either there or forces to not work - Doesn't error when GetMouseFocus() is somehow nil - Count doesn't error when GetMouseFocus() is somehow nil - Added locale znCN.lua but isn't supported in-code - Unsure if translated properly, as was contributed by hu71e - Fixed bug in Command where strings where parsed as numbers - When the string value expected a string of numbers - When the string value could be a hex number prefixed with 0x... --- Command.lua | 10 +++++----- Init.lua | 4 +++- Tooltip.lua | 34 +++++++++++++++++++++++----------- 3 files changed, 31 insertions(+), 17 deletions(-) diff --git a/Command.lua b/Command.lua index 4bc79e5..b8d6347 100644 --- a/Command.lua +++ b/Command.lua @@ -87,14 +87,14 @@ KiwiItemInfo.Command = function(msg) if(var ~= nil) then local val - if(tonumber(args[3])) then - val = tonumber(args[3]) - elseif(args[3] == "true") then + if(type(var) == "boolean" and args[3] == "true") then val = true - elseif(args[3] == "false") then + elseif(type(var) == "boolean" and args[3] == "false") then val = false + elseif(type(var) == "number" and tonumber(args[3])) then + val = tonumber(args[3]) else -- string - val = table.concat(args, " ", 3, #args) + val = table.concat(args, " ", 3, #args):trim() end if(type(var) == "boolean") then diff --git a/Init.lua b/Init.lua index 601dd81..f4abd44 100644 --- a/Init.lua +++ b/Init.lua @@ -44,7 +44,9 @@ KiwiItemInfo._DEFAULT_VARS = { ["ilvl_only_equips"] = true, ["item_compare_on"] = true, ["tooltip_price_on"] = true, - ["tooltip_ilvl_on"] = true + ["tooltip_ilvl_on"] = true, + ["tooltip_ilvl_colors"] = true, + ["tooltip_ilvl_nocolors_rgb"] = "1 1 1", } } diff --git a/Tooltip.lua b/Tooltip.lua index 90e81cb..79b96ef 100644 --- a/Tooltip.lua +++ b/Tooltip.lua @@ -99,18 +99,30 @@ KiwiItemInfo.ShowItemInfo = function(tooltip) local tooltipiLvl = _G[tooltipName .. "TextRight1"] - local playerLevel = UnitLevel("player") - - if(playerLevel <= itemLevel) then - tooltipiLvl:SetTextColor(0.9375, 0, 0) -- red - elseif(itemLevel > playerLevel - 3) then - tooltipiLvl:SetTextColor(0.9375, 0.5, 0) -- orange - elseif(itemLevel > playerLevel - 5) then - tooltipiLvl:SetTextColor(0.9375, 0.9375, 0) -- yellow - elseif(itemLevel > playerLevel - 9) then - tooltipiLvl:SetTextColor(0, 0.875, 0) -- green + if(KiwiItemInfo_Vars.vars["tooltip_ilvl_colors"]) then + local playerLevel = UnitLevel("player") + + if(playerLevel <= itemLevel) then + tooltipiLvl:SetTextColor(0.9375, 0, 0) -- red + elseif(itemLevel > playerLevel - 3) then + tooltipiLvl:SetTextColor(0.9375, 0.5, 0) -- orange + elseif(itemLevel > playerLevel - 5) then + tooltipiLvl:SetTextColor(0.9375, 0.9375, 0) -- yellow + elseif(itemLevel > playerLevel - 9) then + tooltipiLvl:SetTextColor(0, 0.875, 0) -- green + else + tooltipiLvl:SetTextColor(0.5, 0.5, 0.5) -- grey + end else - tooltipiLvl:SetTextColor(0.5, 0.5, 0.5) -- grey + local color = KiwiItemInfo_Vars.vars["tooltip_ilvl_nocolors_rgb"] + local r, g, b = string.split(" ", color) + r = tonumber(r) -- probably should pcall this to handle possible UI error + g = tonumber(g) + b = tonumber(b) + r = (r > 1) and (r / 255) or r + g = (g > 1) and (g / 255) or g + b = (b > 1) and (b / 255) or b + tooltipiLvl:SetTextColor(r, g, b) end tooltipiLvl:SetText(L"TOOLTIP_ILVL" .. itemLevel)