Skip to content

Commit

Permalink
Added The Following...
Browse files Browse the repository at this point in the history
- 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...
  • Loading branch information
tilkinsc committed Oct 22, 2019
1 parent 463c0e3 commit cb986e1
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 17 deletions.
10 changes: 5 additions & 5 deletions Command.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion Init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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",
}
}

Expand Down
34 changes: 23 additions & 11 deletions Tooltip.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit cb986e1

Please sign in to comment.