From f1bcc1a6bb0f0a65051f42f65cafa7d87a8a45e3 Mon Sep 17 00:00:00 2001 From: Anch Date: Thu, 2 Nov 2023 03:30:41 +1300 Subject: [PATCH] added option to display profession rank and max rank beside the name --- ProfessionMenu/ProfessionMenu.lua | 84 ++++++++++++++++-------- ProfessionMenu/ProfessionMenu.toc | 2 +- ProfessionMenu/ProfessionMenuOptions.lua | 18 ++++- 3 files changed, 73 insertions(+), 31 deletions(-) diff --git a/ProfessionMenu/ProfessionMenu.lua b/ProfessionMenu/ProfessionMenu.lua index a0fd6e0..f0eb3fc 100644 --- a/ProfessionMenu/ProfessionMenu.lua +++ b/ProfessionMenu/ProfessionMenu.lua @@ -26,7 +26,9 @@ local DefaultSettings = { { TableName = "autoMenu", false, CheckBox = "ProfessionMenuOptions_AutoMenu"}, { TableName = "FilterList", {false,false,false,false} }, { TableName = "BagFilter", {false,false,false,false,false} }, - { TableName = "ItemBlacklist", { [9149] = true }} + { TableName = "ItemBlacklist", { [9149] = true }}, + { TableName = "hideMaxRank", false, CheckBox = "ProfessionMenuOptions_HideMaxRank"}, + { TableName = "hideRank", false, CheckBox = "ProfessionMenuOptions_HideRank"} } --[[ TableName = Name of the saved setting @@ -264,7 +266,55 @@ function PM:AddDividerLine(maxLenght) return true end +function PM:GetProfessions() + local function getProfessionRanks(compName) + for skillIndex = 1, GetNumSkillLines() do + local name, _, _, rank, _, _, maxRank, _, _, _, _, _, _ = GetSkillLineInfo(skillIndex) + if compName:match(name) then + return rank, maxRank + end + end + end + for _, prof in ipairs(profList) do + for _, spellID in ipairs(prof) do + if CA_IsSpellKnown(spellID) then + local name, _, icon = GetSpellInfo(spellID) + local rank, maxRank = getProfessionRanks(name) + if not PM.db.hideRank and PM.db.hideMaxRank then + name = name .. " |cFF00FFFF("..rank..")" + end + if not PM.db.hideMaxRank and PM.db.hideRank then + name = name .. " |cFF00FFFF("..maxRank..")" + end + if not PM.db.hideMaxRank and not PM.db.hideRank then + name = name .. " |cFF00FFFF("..rank.."/"..maxRank..")" + end + local secure = { + type1 = 'spell', + spell = spellID + } + local openFrame, tooltipTitle, tooltipText + if prof.frame then + openFrame = true + tooltipTitle = prof.frame[2] + tooltipText = prof.frame[3] + end + dewdrop:AddLine( + 'text', name, + 'icon', icon, + 'secure', secure, + 'closeWhenClicked', true, + 'funcRight', function() PM:InventoryFrame_Open(openFrame) end, + 'textHeight', PM.db.txtSize, + 'textWidth', PM.db.txtSize, + 'tooltipTitle', tooltipTitle, + 'tooltipText', tooltipText + ) + end + end + end +end --sets up the drop down menu for specs local function ProfessionMenu_DewdropRegister(self) @@ -281,34 +331,7 @@ local function ProfessionMenu_DewdropRegister(self) 'isTitle', true, 'notCheckable', true ) - for _, prof in ipairs(profList) do - for _, spellID in ipairs(prof) do - if CA_IsSpellKnown(spellID) then - local name, _, icon = GetSpellInfo(spellID) - local secure = { - type1 = 'spell', - spell = spellID - } - local openFrame, tooltipTitle, tooltipText - if prof.frame then - openFrame = true - tooltipTitle = prof.frame[2] - tooltipText = prof.frame[3] - end - dewdrop:AddLine( - 'text', name, - 'icon', icon, - 'secure', secure, - 'closeWhenClicked', true, - 'funcRight', function() PM:InventoryFrame_Open(openFrame) end, - 'textHeight', PM.db.txtSize, - 'textWidth', PM.db.txtSize, - 'tooltipTitle', tooltipTitle, - 'tooltipText', tooltipText - ) - end - end - end + PM:GetProfessions() local divider local SummonItems = returnItemIDs() @@ -537,6 +560,9 @@ function PM:OnEnable() SlashCommand(msg) end PM:RegisterEvent("ADDON_LOADED") + + --Add the ProfessionMenu Extract Frame to the special frames tables to enable closing wih the ESC key + tinsert(UISpecialFrames, "ProfessionMenuExtractFrame") end local function GetTipAnchor(frame) diff --git a/ProfessionMenu/ProfessionMenu.toc b/ProfessionMenu/ProfessionMenu.toc index d6cd137..6edfa4f 100644 --- a/ProfessionMenu/ProfessionMenu.toc +++ b/ProfessionMenu/ProfessionMenu.toc @@ -7,6 +7,6 @@ ## X-Category: Profession ## X-OptionsFrame: ProfessionMenuOptionsFrame ## DefaultState: enabled -## Version: 1.1 +## Version: 1.2 embeds.xml diff --git a/ProfessionMenu/ProfessionMenuOptions.lua b/ProfessionMenu/ProfessionMenuOptions.lua index f660bf1..53ec2b7 100644 --- a/ProfessionMenu/ProfessionMenuOptions.lua +++ b/ProfessionMenu/ProfessionMenuOptions.lua @@ -85,8 +85,24 @@ end autoMenu.Lable:SetText("Show menu on hover") autoMenu:SetScript("OnClick", function() PM.db.autoMenu = not PM.db.autoMenu end) + local hideRank = CreateFrame("CheckButton", "ProfessionMenuOptions_HideRank", ProfessionMenuOptionsFrame, "UICheckButtonTemplate") + hideRank:SetPoint("TOPLEFT", 15, -235) + hideRank.Lable = hideRank:CreateFontString(nil , "BORDER", "GameFontNormal") + hideRank.Lable:SetJustifyH("LEFT") + hideRank.Lable:SetPoint("LEFT", 30, 0) + hideRank.Lable:SetText("Hide profession rank") + hideRank:SetScript("OnClick", function() PM.db.hideRank = not PM.db.hideRank end) + + local hideMaxRank = CreateFrame("CheckButton", "ProfessionMenuOptions_HideMaxRank", ProfessionMenuOptionsFrame, "UICheckButtonTemplate") + hideMaxRank:SetPoint("TOPLEFT", 15, -270) + hideMaxRank.Lable = hideMaxRank:CreateFontString(nil , "BORDER", "GameFontNormal") + hideMaxRank.Lable:SetJustifyH("LEFT") + hideMaxRank.Lable:SetPoint("LEFT", 30, 0) + hideMaxRank.Lable:SetText("Hide profession max rank") + hideMaxRank:SetScript("OnClick", function() PM.db.hideMaxRank = not PM.db.hideMaxRank end) + local txtSize = CreateFrame("Button", "ProfessionMenuOptions_TxtSizeMenu", ProfessionMenuOptionsFrame, "UIDropDownMenuTemplate") - txtSize:SetPoint("TOPLEFT", 15, -240) + txtSize:SetPoint("TOPLEFT", 15, -310) txtSize.Lable = txtSize:CreateFontString(nil , "BORDER", "GameFontNormal") txtSize.Lable:SetJustifyH("LEFT") txtSize.Lable:SetPoint("LEFT", txtSize, 190, 0)