Skip to content

Commit

Permalink
Add tooltip health bar and text size options
Browse files Browse the repository at this point in the history
  • Loading branch information
ls- committed Jan 14, 2021
1 parent 4a81497 commit 2a0c11c
Show file tree
Hide file tree
Showing 3 changed files with 152 additions and 20 deletions.
158 changes: 141 additions & 17 deletions config/tooltips.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,41 @@ local TOOLTIPS = P:GetModule("Tooltips")
-- Lua
local _G = getfenv(0)

function CONFIG.CreateTooltipsPanel(_, order)
--[[ luacheck: globals
]]

-- Mine
local offsets = {"", " ", " "}
local function d(c, o, v)
print(offsets[o].."|cff"..c..v.."|r")
end

local orders = {0, 0}

local function reset(order)
orders[order] = 1
-- d("d20000", order, orders[order])
return orders[order]
end

local function inc(order)
orders[order] = orders[order] + 1
-- d("00d200", order, orders[order])
return orders[order]
end

local function isModuleDisabled()
return not TOOLTIPS:IsInit()
end

function CONFIG:CreateTooltipsPanel(order)
C.options.args.tooltips = {
order = order,
type = "group",
name = L["TOOLTIPS"],
args = {
enabled = {
order = 1,
order = reset(1),
type = "toggle",
name = L["ENABLE"],
get = function()
Expand All @@ -31,89 +58,186 @@ function CONFIG.CreateTooltipsPanel(_, order)
CONFIG:ShowStaticPopup("RELOAD_UI")
end
end
end
end,
},
reset = {
type = "execute",
order = inc(1),
name = L["RESTORE_DEFAULTS"],
confirm = CONFIG.ConfirmReset,
disabled = isModuleDisabled,
func = function()
CONFIG:CopySettings(D.profile.tooltips, C.db.profile.tooltips)

TOOLTIPS:Update()
end,
},
spacer_1 = {
order = 9,
order = inc(1),
type = "description",
name = "",
width = "full",
},
title = {
order = 10,
order = inc(1),
type = "toggle",
name = L["PLAYER_TITLE"],
disabled = isModuleDisabled,
get = function()
return C.db.profile.tooltips.title
end,
set = function(_, value)
C.db.profile.tooltips.title = value
end
end,
},
target = {
order = 11,
order = inc(1),
type = "toggle",
name = L["TARGET_INFO"],
desc = L["TARGET_INFO_DESC"],
disabled = isModuleDisabled,
get = function()
return C.db.profile.tooltips.target
end,
set = function(_, value)
C.db.profile.tooltips.target = value
end
end,
},
inspect = {
order = 12,
order = inc(1),
type = "toggle",
name = L["INSPECT_INFO"],
desc = L["INSPECT_INFO_DESC"],
disabled = isModuleDisabled,
get = function()
return C.db.profile.tooltips.inspect
end,
set = function(_, value)
C.db.profile.tooltips.inspect = value

TOOLTIPS:Update()
end
end,
},
id = {
order = 13,
order = inc(1),
type = "toggle",
name = L["TOOLTIP_IDS"],
disabled = isModuleDisabled,
get = function()
return C.db.profile.tooltips.id
end,
set = function(_, value)
C.db.profile.tooltips.id = value
end
end,
},
count = {
order = 14,
order = inc(1),
type = "toggle",
name = L["ITEM_COUNT"],
desc = L["ITEM_COUNT_DESC"],
disabled = isModuleDisabled,
get = function()
return C.db.profile.tooltips.count
end,
set = function(_, value)
C.db.profile.tooltips.count = value
end
end,
},
spacer_2 = {
order = 20,
order = inc(1),
type = "description",
name = "",
width = "full",
},
anchor_cursor = {
order = 21,
order = inc(1),
type = "toggle",
name = L["ANCHOR_TO_CURSOR"],
disabled = isModuleDisabled,
get = function()
return C.db.profile.tooltips.anchor_cursor
end,
set = function(_, value)
C.db.profile.tooltips.anchor_cursor = value
end
end,
},
spacer_3 = {
order = inc(1),
type = "description",
name = "",
width = "full",
},
health = {
order = inc(1),
type = "group",
inline = true,
name = L["HEALTH"],
disabled = isModuleDisabled,
get = function(info)
return C.db.profile.tooltips.health[info[#info]]
end,
set = function(info, value)
if C.db.profile.tooltips.health[info[#info]] ~= value then
C.db.profile.tooltips.health[info[#info]] = value

TOOLTIPS:Update()
end
end,
args = {
reset = {
type = "execute",
order = reset(2),
name = L["RESTORE_DEFAULTS"],
confirm = CONFIG.ConfirmReset,
func = function()
CONFIG:CopySettings(D.profile.tooltips.health, C.db.profile.tooltips.health)

TOOLTIPS:Update()
end,
},
spacer_1 = {
order = inc(2),
type = "description",
name = "",
width = "full",
},
height = {
order = inc(2),
type = "range",
name = L["HEIGHT"],
min = 8, max = 32, step = 4,
},
spacer_2 = {
order = inc(2),
type = "description",
name = "",
width = "full",
},
text = {
order = inc(2),
type = "group",
name = L["TEXT"],
inline = true,
get = function(info)
return C.db.profile.tooltips.health.text[info[#info]]
end,
set = function(info, value)
if C.db.profile.tooltips.health.text[info[#info]] ~= value then
C.db.profile.tooltips.health.text[info[#info]] = value

TOOLTIPS:Update()
end
end,
args = {
size = {
order = 1,
type = "range",
name = L["SIZE"],
min = 8, max = 32, step = 1,
},
},
},
},
},
},
}
Expand Down
6 changes: 6 additions & 0 deletions core/defaults.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2876,6 +2876,12 @@ D.profile = {
target = true,
inspect = true,
anchor_cursor = false,
health = {
height = 12,
text = {
size = 12,
},
},
point = {
p = "BOTTOMRIGHT",
anchor = "UIParent",
Expand Down
8 changes: 5 additions & 3 deletions modules/tooltips/tooltips.lua
Original file line number Diff line number Diff line change
Expand Up @@ -794,7 +794,6 @@ function MODULE:Init()

-- Status Bars
E:HandleStatusBar(GameTooltipStatusBar)
E:SetStatusBarSkin(GameTooltipStatusBar, "HORIZONTAL-12")
GameTooltipStatusBar:ClearAllPoints()
GameTooltipStatusBar:SetPoint("TOPLEFT", GameTooltip, "BOTTOMLEFT", 8, -2)
GameTooltipStatusBar:SetPoint("TOPRIGHT", GameTooltip, "BOTTOMRIGHT", -8, -2)
Expand All @@ -811,8 +810,11 @@ function MODULE:Init()
end
end

function MODULE.Update()
function MODULE:Update()
if isInit then
-- local config = C.db.profile.tooltips
GameTooltipStatusBar:SetHeight(C.db.profile.tooltips.health.height)
E:SetStatusBarSkin(GameTooltipStatusBar, "HORIZONTAL-" .. C.db.profile.tooltips.health.height)

GameTooltipStatusBar.Text:UpdateFont(C.db.profile.tooltips.health.text.size)
end
end

0 comments on commit 2a0c11c

Please sign in to comment.