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
3273, -- Apprentice 75
}, --FIRSTAID
{13977860}, --WOODCUTTING
{13977860, Name = "Woodcutting"}, --WOODCUTTING
{
1005011, -- Artisan 300
1005010, -- Expert 225
1005009, -- Journeyman 150
1005008, -- Apprentice 75
Name = "Woodworking",
}, --WOODWORKING
}
@@ -372,7 +373,7 @@ function PM:AddProfessions()
local function getProfessionRanks(compName)
for skillIndex = 1, GetNumSkillLines() do
local name, _, _, rank, _, _, maxRank, _, _, _, _, _, _ = GetSkillLineInfo(skillIndex)
if compName:match(name) then
if compName == name then
return rank, maxRank
end
end
@@ -391,13 +392,13 @@ function PM:AddProfessions()
end
local rank, maxRank = getProfessionRanks(profName)
if not self.db.hideRank and self.db.hideMaxRank then
name = name .. " |cFF00FFFF("..rank..")"
if rank then name = name .. " |cFF00FFFF("..rank..")" end
end
if not self.db.hideMaxRank and self.db.hideRank then
name = name .. " |cFF00FFFF("..maxRank..")"
if maxRank then name = name .. " |cFF00FFFF("..maxRank..")" end
end
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
local secure = {
type1 = 'spell',
@@ -604,11 +605,13 @@ function PM:CreateUI()
end
PM:CreateUI()
InterfaceOptionsFrame:HookScript("OnShow", function()
if InterfaceOptionsFrame and ProfessionMenuOptionsFrame:IsVisible() then
ProfessionMenu_OpenOptions()
end
end)
if InterfaceOptionsFrame then
InterfaceOptionsFrame:HookScript("OnShow", function()
if InterfaceOptionsFrame and ProfessionMenuOptionsFrame:IsVisible() then
ProfessionMenu_OpenOptions()
end
end)
end
-- toggle the main button frame
function PM:ToggleMainFrame()
+12 -7
View File
@@ -1,15 +1,18 @@
local PM = LibStub("AceAddon-3.0"):GetAddon("ProfessionMenu")
function PM:Options_Toggle()
if not InterfaceOptionsFrame then return end
if InterfaceOptionsFrame:IsVisible() then
InterfaceOptionsFrame:Hide()
else
InterfaceOptionsFrame_OpenToCategory("ProfessionMenu")
if InterfaceOptionsFrame_OpenToCategory then
InterfaceOptionsFrame_OpenToCategory("ProfessionMenu")
end
end
end
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()
UIDropDownMenu_SetText(ProfessionMenuOptions_TxtSizeMenu, PM.db.txtSize)
end
@@ -17,14 +20,16 @@ end
--Creates the options frame and all its assets
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 = {}
mainframe.panel = CreateFrame("FRAME", "ProfessionMenuOptionsFrame", UIParent, nil)
local fstring = mainframe.panel:CreateFontString(mainframe, "OVERLAY", "GameFontNormal")
fstring:SetText("Profession Menu Settings")
fstring:SetPoint("TOPLEFT", 15, -15)
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")
hideMenu:SetPoint("TOPLEFT", 15, -60)
@@ -143,9 +148,9 @@ PM:CreateOptionsUI()
for i = 10, 25 do
info = {
text = i;
func = function()
PM.db.txtSize = i
local thisID = this:GetID();
func = function()
PM.db.txtSize = i
local thisID = UIDropDownMenu_GetSelectedID(ProfessionMenuOptions_TxtSizeMenu)
UIDropDownMenu_SetSelectedID(ProfessionMenuOptions_TxtSizeMenu, thisID)
end;
};