Skip to content

Commit

Permalink
Fixed crash and updated tooltip functions
Browse files Browse the repository at this point in the history
* Fixed a crash that occurs when innerShow is false

* Updated both 'pantheonMajorGodTooltip' and 'pantheonMinorGodTooltip'
  functions to be able to show the corresponding tooltip while hovering
  a god from the pantheon list
  • Loading branch information
Ciccooz committed Mar 14, 2024
1 parent c63eea2 commit 2d2cd0f
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 16 deletions.
31 changes: 24 additions & 7 deletions src/Classes/ConfigTab.lua
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,12 @@ local ConfigTabClass = newClass("ConfigTab", "UndoHandler", "ControlHost", "Cont
local innerShown = control.shown
if not varData.doNotHighlight then
control.borderFunc = function()
local shown = type(innerShown) == "boolean" and innerShown or innerShown()
local shown
if type(innerShown) == "function" then
shown = innerShown()
else
shown = innerShown
end
local cur = self.input[varData.var]
local def = self:GetDefaultState(varData.var, type(cur))
if cur ~= nil and cur ~= def then
Expand All @@ -537,15 +542,23 @@ local ConfigTabClass = newClass("ConfigTab", "UndoHandler", "ControlHost", "Cont
if not searchMatch(varData) then
return false
end
local shown = type(innerShown) == "boolean" and innerShown or innerShown()
local cur = self.input[varData.var]
local shown
if type(innerShown) == "function" then
shown = innerShown()
else
shown = innerShown
end local cur = self.input[varData.var]
local def = self:GetDefaultState(varData.var, type(cur))
return not shown and cur ~= nil and cur ~= def or shown
end
local innerLabel = labelControl.label
labelControl.label = function()
local shown = type(innerShown) == "boolean" and innerShown or innerShown()
local cur = self.input[varData.var]
local shown
if type(innerShown) == "function" then
shown = innerShown()
else
shown = innerShown
end local cur = self.input[varData.var]
local def = self:GetDefaultState(varData.var, type(cur))
if not shown and cur ~= nil and cur ~= def then
return colorCodes.NEGATIVE..StripEscapes(innerLabel)
Expand All @@ -565,8 +578,12 @@ local ConfigTabClass = newClass("ConfigTab", "UndoHandler", "ControlHost", "Cont
end
end

local shown = type(innerShown) == "boolean" and innerShown or innerShown()
local cur = self.input[varData.var]
local shown
if type(innerShown) == "function" then
shown = innerShown()
else
shown = innerShown
end local cur = self.input[varData.var]
local def = self:GetDefaultState(varData.var, type(cur))
if not shown and cur ~= nil and cur ~= def then
tooltip:AddLine(14, colorCodes.NEGATIVE.."This config option is conditional with missing source and is invalid.")
Expand Down
33 changes: 24 additions & 9 deletions src/Modules/ConfigOptions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ local function applyPantheonDescription(tooltip, mode, index, value)
end

local function pantheonTooltip(modList, build, selectedGod, selectedSouls, tooltip)
tooltip:Clear()
local souls = data.pantheons[selectedGod].souls
for i, soul in ipairs(souls) do
local name = soul.name
Expand All @@ -53,29 +52,45 @@ end

local function pantheonMajorGodTooltip(modList, build)
local input = build.configTab.input
local majorGod = input.pantheonMajorGod
if majorGod ~= "None" then --tooltip not generated if god is not selected
local majorGodControl = build.configTab.varControls.pantheonMajorGod
local mOver, mOverComp = majorGodControl:IsMouseOver()
local index
if mOver and mOverComp ~= "DROP" then
index = majorGodControl.selIndex
elseif mOver and majorGodControl.dropped and majorGodControl.hoverSel then
index = majorGodControl.hoverSel
end
local majorGod = majorGodControl.list[index]
majorGodControl.tooltip:Clear()
if majorGod and majorGod.val ~= "None" then --tooltip not generated if god is not selected
local majorGodSouls = { --table containing selected souls checkboxes state (booleans)
true, --forcing to true the major god, since it has been selected for sure (make pantheonTooltip cleaner)
input.pantheonMajorGodSoul1,
input.pantheonMajorGodSoul2,
input.pantheonMajorGodSoul3
}
local majorGodTooltip = build.configTab.varControls.pantheonMajorGod.tooltip
pantheonTooltip(modList, build, majorGod, majorGodSouls, majorGodTooltip)
pantheonTooltip(modList, build, majorGod.val, majorGodSouls, majorGodControl.tooltip)
end
end

local function pantheonMinorGodTooltip(modList, build)
local input = build.configTab.input
local minorGod = input.pantheonMinorGod
if minorGod ~= "None" then
local minorGodControl = build.configTab.varControls.pantheonMinorGod
local mOver, mOverComp = minorGodControl:IsMouseOver()
local index
if mOver and mOverComp ~= "DROP" then
index = minorGodControl.selIndex
elseif mOver and minorGodControl.dropped and minorGodControl.hoverSel then
index = minorGodControl.hoverSel
end
local minorGod = minorGodControl.list[index]
minorGodControl.tooltip:Clear()
if minorGod and minorGod.val ~= "None" then
local minorGodSouls = {
true,
input.pantheonMinorGodSoul1
}
local minorGodTooltip = build.configTab.varControls.pantheonMinorGod.tooltip
pantheonTooltip(modList, build, minorGod, minorGodSouls, minorGodTooltip)
pantheonTooltip(modList, build, minorGod.val, minorGodSouls, minorGodControl.tooltip)
end
end

Expand Down

0 comments on commit 2d2cd0f

Please sign in to comment.