diff --git a/WhatsTrainingUI.lua b/WhatsTrainingUI.lua index 34458f8..6b148ee 100644 --- a/WhatsTrainingUI.lua +++ b/WhatsTrainingUI.lua @@ -282,74 +282,35 @@ function wt.CreateFrame() wt.MainFrame = mainFrame end - wt.ClickHook = function(spell, afterClick, row) local tomeId = spell.id if (not wt.TomeIds or not wt.TomeIds[tomeId]) then PlaySound(SOUNDKIT.U_CHAT_SCROLL_BUTTON) local isIgnored = ignoreStore:IsIgnored(spell.id) local menuTitle = spell.formattedFullName - if (WOW_PROJECT_ID == WOW_PROJECT_CATACLYSM_CLASSIC) then - local menu = { - {text = menuTitle, isTitle = true, classicChecks = true}, - { - text = wt.L.IGNORED_TT, - checked = isIgnored, - func = function() - PlaySound(SOUNDKIT.U_CHAT_SCROLL_BUTTON) - ignoreStore:Flip(spell.id) - afterClick() - end, - isNotRadio = true - -- classicChecks = true - } - } - + MenuUtil.CreateContextMenu(row, function(owner, rootDescription) + rootDescription:CreateTitle(menuTitle) + rootDescription:CreateCheckbox(wt.L.IGNORED_TT, function() return isIgnored end, function() + PlaySound(SOUNDKIT.U_CHAT_SCROLL_BUTTON) + ignoreStore:Flip(spell.id) + afterClick() + return MenuResponse.Close + end) + local allRanks = wt:AllRanks(spell.id) - if allRanks and #allRanks > 1 then local allIgnored = true for _, id in ipairs(allRanks) do allIgnored = allIgnored and ignoreStore:IsIgnored(id) end - tinsert(menu, { - text = wt.L.IGNORE_ALL_TT, - checked = allIgnored, - func = function() - PlaySound(SOUNDKIT.U_CHAT_SCROLL_BUTTON) - ignoreStore:UpdateMany(allRanks, not allIgnored) - afterClick() - end, - isNotRadio = true, - }) - end - - EasyMenu(menu, menuFrame, "cursor", 10, 35, "MENU") - else - MenuUtil.CreateContextMenu(row, function(owner, rootDescription) - rootDescription:CreateTitle(menuTitle) - rootDescription:CreateCheckbox(wt.L.IGNORED_TT, function() return isIgnored end, function() + rootDescription:CreateCheckbox(wt.L.IGNORE_ALL_TT, function() return allIgnored end, function () PlaySound(SOUNDKIT.U_CHAT_SCROLL_BUTTON) - ignoreStore:Flip(spell.id) + ignoreStore:UpdateMany(allRanks, not allIgnored) afterClick() return MenuResponse.Close end) - - local allRanks = wt:AllRanks(spell.id) - if allRanks and #allRanks > 1 then - local allIgnored = true - for _, id in ipairs(allRanks) do - allIgnored = allIgnored and ignoreStore:IsIgnored(id) - end - rootDescription:CreateCheckbox(wt.L.IGNORE_ALL_TT, function() return allIgnored end, function () - PlaySound(SOUNDKIT.U_CHAT_SCROLL_BUTTON) - ignoreStore:UpdateMany(allRanks, not allIgnored) - afterClick() - return MenuResponse.Close - end) - end - end) - end + end + end) return end @@ -357,49 +318,20 @@ wt.ClickHook = function(spell, afterClick, row) local checked = wt.learnedPetAbilityMap[tomeId] PlaySound(SOUNDKIT.U_CHAT_SCROLL_BUTTON) local isIgnored = ignoreStore:IsIgnored(spell.id) - if (WOW_PROJECT_ID == WOW_PROJECT_CATACLYSM_CLASSIC) then - local menu = { - {text = wt.L.TOME_HEADER, isTitle = true, classicChecks = true}, - { - text = wt.L.TOME_LEARNED, - checked = checked, - func = function() - PlaySound(SOUNDKIT.U_CHAT_SCROLL_BUTTON) - wt.learnedPetAbilityMap[tomeId] = not checked - afterClick() - end, - isNotRadio = true - }, - {text = spell.name, isTitle = true, classicChecks = true}, - { - text = wt.L.IGNORED_TT, - checked = isIgnored, - func = function() - PlaySound(SOUNDKIT.U_CHAT_SCROLL_BUTTON) - ignoreStore:Flip(spell.id) - afterClick() - end, - isNotRadio = true - -- classicChecks = true - } - } - EasyMenu(menu, menuFrame, "cursor", 10, 35, "MENU") - else - MenuUtil.CreateContextMenu(row, function(owner, rootDescription) - rootDescription:CreateTitle(wt.L.TOME_HEADER) - rootDescription:CreateCheckbox(wt.L.TOME_LEARNED, function() return checked end, function() - PlaySound(SOUNDKIT.U_CHAT_SCROLL_BUTTON) - wt.learnedPetAbilityMap[tomeId] = not checked - afterClick() - return MenuResponse.Close - end) - rootDescription:CreateTitle(spell.name) - rootDescription:CreateCheckbox(wt.L.IGNORED_TT, function() return isIgnored end, function() - PlaySound(SOUNDKIT.U_CHAT_SCROLL_BUTTON) - ignoreStore:Flip(spell.id) - afterClick() - return MenuResponse.Close - end) + MenuUtil.CreateContextMenu(row, function(owner, rootDescription) + rootDescription:CreateTitle(wt.L.TOME_HEADER) + rootDescription:CreateCheckbox(wt.L.TOME_LEARNED, function() return checked end, function() + PlaySound(SOUNDKIT.U_CHAT_SCROLL_BUTTON) + wt.learnedPetAbilityMap[tomeId] = not checked + afterClick() + return MenuResponse.Close end) - end + rootDescription:CreateTitle(spell.name) + rootDescription:CreateCheckbox(wt.L.IGNORED_TT, function() return isIgnored end, function() + PlaySound(SOUNDKIT.U_CHAT_SCROLL_BUTTON) + ignoreStore:Flip(spell.id) + afterClick() + return MenuResponse.Close + end) + end) end