fix: name+guard Woodcutting/Woodworking, drop regex+deprecated this+InterfaceOptions guards

ProfessionMenu.lua:
- profList: add Name="Woodcutting" (spell 13977860) and Name="Woodworking"
  (spells 1005008-1005011) so getProfessionRanks can find the matching
  GetSkillLineInfo entry. Without Name, both fell through GetSpellInfo+match
  with no result and returned nil,nil.
- getProfessionRanks: replace compName:match(name) (regex) with compName == name
  (plain compare); GetSkillLineInfo names are exact, regex was a bug magnet.
- Guard rank concat at lines ~394/397/400: skip the " (rank)" / " (max)" /
  " (rank/max)" append when getProfessionRanks returns nil so unknown
  skill lines don't error.
- InterfaceOptionsFrame:HookScript: wrap in 'if InterfaceOptionsFrame then';
  CoA's reworked FrameXML has no InterfaceOptionsFrame.

ProfessionMenuOptions.lua:
- Guard InterfaceOptionsFrame / InterfaceOptionsFrame_OpenToCategory /
  InterfaceOptions_AddCategory call sites (Options_Toggle, ProfessionMenu_
  OpenOptions, CreateOptionsUI). All nil on CoA's FrameXML.
- TxtSize dropdown func: drop deprecated WoW-2.x global 'this'; use
  UIDropDownMenu_GetSelectedID(ProfessionMenuOptions_TxtSizeMenu) instead.
This commit is contained in:
2026-05-24 17:40:22 +02:00
parent 6d099f6db1
commit 6ef1f9dab8
2 changed files with 25 additions and 17 deletions
+13 -10
View File
@@ -197,12 +197,13 @@ local profList = {
3274, -- Journeyman 150 3274, -- Journeyman 150
3273, -- Apprentice 75 3273, -- Apprentice 75
}, --FIRSTAID }, --FIRSTAID
{13977860}, --WOODCUTTING {13977860, Name = "Woodcutting"}, --WOODCUTTING
{ {
1005011, -- Artisan 300 1005011, -- Artisan 300
1005010, -- Expert 225 1005010, -- Expert 225
1005009, -- Journeyman 150 1005009, -- Journeyman 150
1005008, -- Apprentice 75 1005008, -- Apprentice 75
Name = "Woodworking",
}, --WOODWORKING }, --WOODWORKING
} }
@@ -372,7 +373,7 @@ function PM:AddProfessions()
local function getProfessionRanks(compName) local function getProfessionRanks(compName)
for skillIndex = 1, GetNumSkillLines() do for skillIndex = 1, GetNumSkillLines() do
local name, _, _, rank, _, _, maxRank, _, _, _, _, _, _ = GetSkillLineInfo(skillIndex) local name, _, _, rank, _, _, maxRank, _, _, _, _, _, _ = GetSkillLineInfo(skillIndex)
if compName:match(name) then if compName == name then
return rank, maxRank return rank, maxRank
end end
end end
@@ -391,13 +392,13 @@ function PM:AddProfessions()
end end
local rank, maxRank = getProfessionRanks(profName) local rank, maxRank = getProfessionRanks(profName)
if not self.db.hideRank and self.db.hideMaxRank then if not self.db.hideRank and self.db.hideMaxRank then
name = name .. " |cFF00FFFF("..rank..")" if rank then name = name .. " |cFF00FFFF("..rank..")" end
end end
if not self.db.hideMaxRank and self.db.hideRank then if not self.db.hideMaxRank and self.db.hideRank then
name = name .. " |cFF00FFFF("..maxRank..")" if maxRank then name = name .. " |cFF00FFFF("..maxRank..")" end
end end
if not self.db.hideMaxRank and not self.db.hideRank then if not self.db.hideMaxRank and not self.db.hideRank then
name = name .. " |cFF00FFFF("..rank.."/"..maxRank..")" if rank and maxRank then name = name .. " |cFF00FFFF("..rank.."/"..maxRank..")" end
end end
local secure = { local secure = {
type1 = 'spell', type1 = 'spell',
@@ -604,11 +605,13 @@ function PM:CreateUI()
end end
PM:CreateUI() PM:CreateUI()
InterfaceOptionsFrame:HookScript("OnShow", function() if InterfaceOptionsFrame then
if InterfaceOptionsFrame and ProfessionMenuOptionsFrame:IsVisible() then InterfaceOptionsFrame:HookScript("OnShow", function()
ProfessionMenu_OpenOptions() if InterfaceOptionsFrame and ProfessionMenuOptionsFrame:IsVisible() then
end ProfessionMenu_OpenOptions()
end) end
end)
end
-- toggle the main button frame -- toggle the main button frame
function PM:ToggleMainFrame() function PM:ToggleMainFrame()
+12 -7
View File
@@ -1,15 +1,18 @@
local PM = LibStub("AceAddon-3.0"):GetAddon("ProfessionMenu") local PM = LibStub("AceAddon-3.0"):GetAddon("ProfessionMenu")
function PM:Options_Toggle() function PM:Options_Toggle()
if not InterfaceOptionsFrame then return end
if InterfaceOptionsFrame:IsVisible() then if InterfaceOptionsFrame:IsVisible() then
InterfaceOptionsFrame:Hide() InterfaceOptionsFrame:Hide()
else else
InterfaceOptionsFrame_OpenToCategory("ProfessionMenu") if InterfaceOptionsFrame_OpenToCategory then
InterfaceOptionsFrame_OpenToCategory("ProfessionMenu")
end
end end
end end
function ProfessionMenu_OpenOptions() function ProfessionMenu_OpenOptions()
if InterfaceOptionsFrame:GetWidth() < 850 then InterfaceOptionsFrame:SetWidth(850) end if InterfaceOptionsFrame and InterfaceOptionsFrame:GetWidth() < 850 then InterfaceOptionsFrame:SetWidth(850) end
ProfessionMenu_DropDownInitialize() ProfessionMenu_DropDownInitialize()
UIDropDownMenu_SetText(ProfessionMenuOptions_TxtSizeMenu, PM.db.txtSize) UIDropDownMenu_SetText(ProfessionMenuOptions_TxtSizeMenu, PM.db.txtSize)
end end
@@ -17,14 +20,16 @@ end
--Creates the options frame and all its assets --Creates the options frame and all its assets
function PM:CreateOptionsUI() function PM:CreateOptionsUI()
if InterfaceOptionsFrame:GetWidth() < 850 then InterfaceOptionsFrame:SetWidth(850) end if InterfaceOptionsFrame and InterfaceOptionsFrame:GetWidth() < 850 then InterfaceOptionsFrame:SetWidth(850) end
local mainframe = {} local mainframe = {}
mainframe.panel = CreateFrame("FRAME", "ProfessionMenuOptionsFrame", UIParent, nil) mainframe.panel = CreateFrame("FRAME", "ProfessionMenuOptionsFrame", UIParent, nil)
local fstring = mainframe.panel:CreateFontString(mainframe, "OVERLAY", "GameFontNormal") local fstring = mainframe.panel:CreateFontString(mainframe, "OVERLAY", "GameFontNormal")
fstring:SetText("Profession Menu Settings") fstring:SetText("Profession Menu Settings")
fstring:SetPoint("TOPLEFT", 15, -15) fstring:SetPoint("TOPLEFT", 15, -15)
mainframe.panel.name = "ProfessionMenu" mainframe.panel.name = "ProfessionMenu"
InterfaceOptions_AddCategory(mainframe.panel) if InterfaceOptions_AddCategory then
InterfaceOptions_AddCategory(mainframe.panel)
end
local hideMenu = CreateFrame("CheckButton", "ProfessionMenuOptions_HideMenu", ProfessionMenuOptionsFrame, "UICheckButtonTemplate") local hideMenu = CreateFrame("CheckButton", "ProfessionMenuOptions_HideMenu", ProfessionMenuOptionsFrame, "UICheckButtonTemplate")
hideMenu:SetPoint("TOPLEFT", 15, -60) hideMenu:SetPoint("TOPLEFT", 15, -60)
@@ -143,9 +148,9 @@ PM:CreateOptionsUI()
for i = 10, 25 do for i = 10, 25 do
info = { info = {
text = i; text = i;
func = function() func = function()
PM.db.txtSize = i PM.db.txtSize = i
local thisID = this:GetID(); local thisID = UIDropDownMenu_GetSelectedID(ProfessionMenuOptions_TxtSizeMenu)
UIDropDownMenu_SetSelectedID(ProfessionMenuOptions_TxtSizeMenu, thisID) UIDropDownMenu_SetSelectedID(ProfessionMenuOptions_TxtSizeMenu, thisID)
end; end;
}; };