Skill level mismatch warning

This commit is contained in:
Gonçalo Correia 2026-05-08 16:33:36 +01:00
parent 961d642018
commit 0d9ec1913d
2 changed files with 70 additions and 6 deletions

41
UI.lua
View file

@ -83,18 +83,53 @@ function AltSystem:CreateMainFrame()
-- Skill dropdown
-------------------------
local skillOptions = BuildSkillOptions()
local UpdateSkillWarning -- forward declaration
local skillDropdown, getSkillIndex, setSkillIndex = CreateDropdown(
f, "AltSystemSkillDropdown", yPos, "Skill:", skillOptions,
AltSystem.State.selectedSkillIndex,
function(index)
AltSystem.State.selectedSkillIndex = index
UpdateSkillWarning(index)
end)
-- Warning icon for skill mismatch (shown next to dropdown when value doesn't match keyword)
local skillWarning = CreateFrame("Frame", nil, f)
skillWarning:SetSize(20, 20)
skillWarning:SetPoint("LEFT", skillDropdown, "RIGHT", 4, 0)
local skillWarningIcon = skillWarning:CreateTexture(nil, "ARTWORK")
skillWarningIcon:SetAllPoints()
skillWarningIcon:SetAtlas("services-icon-warning")
skillWarning:SetScript("OnEnter", function(self)
if self.tooltipText then
GameTooltip:SetOwner(self, "ANCHOR_RIGHT")
GameTooltip:SetText(self.tooltipText, 1, 0.82, 0)
GameTooltip:Show()
end
end)
skillWarning:SetScript("OnLeave", function()
GameTooltip:Hide()
end)
skillWarning:Hide()
-- Update the warning icon visibility based on the currently selected skill
UpdateSkillWarning = function(index)
local skill = AltSystem.Data.Skills[index]
if skill and skill.warning then
skillWarning.tooltipText = skill.warning
skillWarning:Show()
else
skillWarning:Hide()
end
end
-- Store references for refreshing
AltSystem.SkillDropdown = skillDropdown
AltSystem.GetSkillIndex = getSkillIndex
AltSystem.SetSkillIndex = setSkillIndex
AltSystem.UpdateSkillWarning = UpdateSkillWarning
yPos = yPos - ROW_HEIGHT - 8
-------------------------
@ -261,6 +296,9 @@ function AltSystem:RefreshSkillDropdown()
if AltSystem.SetSkillIndex then
AltSystem.SetSkillIndex(1)
end
if AltSystem.UpdateSkillWarning then
AltSystem.UpdateSkillWarning(1)
end
-- Rebuild the dropdown menu with the new skill list
if AltSystem.SkillDropdown then
@ -275,6 +313,9 @@ function AltSystem:RefreshSkillDropdown()
if AltSystem.SetSkillIndex then
AltSystem.SetSkillIndex(data)
end
if AltSystem.UpdateSkillWarning then
AltSystem.UpdateSkillWarning(data)
end
end,
i
)