From 836d674814a011248f3db0189973380c2b10d632 Mon Sep 17 00:00:00 2001 From: merstrax Date: Mon, 1 Nov 2021 03:44:48 -0400 Subject: [PATCH] Implemented Difficulty Submenus --- AtlasLoot/Core/AtlasLoot.lua | 126 +++++++++++-- .../DefaultFrame/AtlaslootDefaultFrame.lua | 168 ++++++++++++++++-- 2 files changed, 267 insertions(+), 27 deletions(-) diff --git a/AtlasLoot/Core/AtlasLoot.lua b/AtlasLoot/Core/AtlasLoot.lua index 9b6fd19..194b95a 100644 --- a/AtlasLoot/Core/AtlasLoot.lua +++ b/AtlasLoot/Core/AtlasLoot.lua @@ -490,27 +490,133 @@ end AtlasLoot_Difficulty = { -- table of difficulties and there itemID references - ["ClassicDungeon"] = { {"Normal", "" }, {"Bloodforged", 1 } }; + ["ClassicDungeon"] = { + [1] = { + {"Normal", 2, [4] = "Submenu"}, + }, + [2] = { + {"Bloodforged", 1, [4] = "Submenu"}, + }, + }; - ["ClassicDungeonExt"] = { {"Normal", "" }, {"Heroic", 3 }, {"Mythic", 4 }, {"Mythic 1", 5 }, {"Mythic 2", 6 }, {"Mythic 3", 7 }, {"Mythic 4", 8 }, {"Mythic 5", 9 }, {"Mythic 6", 10 }, - {"Mythic 7", 11 }, {"Mythic 8", 12 }, {"Mythic 9", 13 }, {"Mythic 10", 14 }, {"Mythic 11", 15 }, {"Mythic 12", 16 }, {"Mythic 13", 17 }, {"Mythic 14", 18 }, {"Mythic 15", 19 }, {"Mythic 16", 20 }, - {"Mythic 17", 21 }, {"Mythic 18", 22 }, {"Mythic 19", 23 }, {"Mythic 20", 24 }, {"Bloodforged", 1 }, }; + ["ClassicDungeonExt"] = { + [1] = { + {"Normal", 2, [4] = "Submenu"}, + }, + [2] = { + {"Heroic", 3, [4] = "Submenu"}, + }, + [3] = { + {"Mythic", 4, [4] = "Submenu"}, + }, + [4] = { + ["Mythic+ 1-10"] = { + {"Mythic 1", 5, [4] = "Submenu" }, {"Mythic 2", 6, [4] = "Submenu" }, {"Mythic 3", 7, [4] = "Submenu" }, {"Mythic 4", 8, [4] = "Submenu" }, {"Mythic 5", 9, [4] = "Submenu" }, + {"Mythic 6", 10, [4] = "Submenu" }, {"Mythic 7", 11, [4] = "Submenu" }, {"Mythic 8", 12, [4] = "Submenu" }, {"Mythic 9", 13, [4] = "Submenu" }, {"Mythic 10", 14, [4] = "Submenu" }, + }, + }, + [5] = { + ["Mythic+ 11-20"] = { + {"Mythic 11", 15, [4] = "Submenu" }, {"Mythic 12", 16, [4] = "Submenu" }, {"Mythic 13", 17, [4] = "Submenu" }, {"Mythic 14", 18, [4] = "Submenu" }, {"Mythic 15", 19, [4] = "Submenu" }, + {"Mythic 16", 20, [4] = "Submenu" }, {"Mythic 17", 21, [4] = "Submenu" }, {"Mythic 18", 22, [4] = "Submenu" }, {"Mythic 19", 23, [4] = "Submenu" }, {"Mythic 20", 24, [4] = "Submenu" }, + }, + }, + [6] = { + {"Bloodforged", 1, [4] = "Submenu"}, + }, + }; - ["ClassicRaid"] = { {"Normal Flex", "" }, {"Heroic Flex", 3 }, {"Ascended", 4 }, {"Bloodforged", 1 }, }; + ["ClassicRaid"] = { + [1] = { + {"Normal", 2, [4] = "Submenu"}, + }, + [2] = { + {"Heroic", 3, [4] = "Submenu"}, + }, + [3] = { + {"Ascended", 4, [4] = "Submenu"}, + }, + [4] = { + {"Bloodforged", 1, [4] = "Submenu"}, + }, + }; - ["BCDungeon"] = { {"Normal/Heroic", "" }, {"Mythic", 4 }, {"Mythic 1", 5 }, {"Mythic 2", 6 }, {"Mythic 3", 7 }, {"Mythic 4", 8 }, {"Mythic 5", 9 }, {"Mythic 6", 10 }, - {"Mythic 7", 11 }, {"Mythic 8", 12 }, {"Mythic 9", 13 }, {"Mythic 10", 14 }, {"Bloodforged", 1 }, }; + ["BCDungeon"] = { + [1] = { + {"Normal", 2, [4] = "Submenu"}, + }, + [2] = { + {"Mythic", 4, [4] = "Submenu"}, + }, + [3] = { + ["Mythic+ 1-10"] = { + {"Mythic 1", 5, [4] = "Submenu" }, {"Mythic 2", 6, [4] = "Submenu" }, {"Mythic 3", 7, [4] = "Submenu" }, {"Mythic 4", 8, [4] = "Submenu" }, {"Mythic 5", 9, [4] = "Submenu" }, + {"Mythic 6", 10, [4] = "Submenu" }, {"Mythic 7", 11, [4] = "Submenu" }, {"Mythic 8", 12, [4] = "Submenu" }, {"Mythic 9", 13, [4] = "Submenu" }, {"Mythic 10", 14, [4] = "Submenu" }, + }, + }, + [4] = { + ["Mythic+ 11-20"] = { + {"Mythic 11", 15, [4] = "Submenu" }, {"Mythic 12", 16, [4] = "Submenu" }, {"Mythic 13", 17, [4] = "Submenu" }, {"Mythic 14", 18, [4] = "Submenu" }, {"Mythic 15", 19, [4] = "Submenu" }, + {"Mythic 16", 20, [4] = "Submenu" }, {"Mythic 17", 21, [4] = "Submenu" }, {"Mythic 18", 22, [4] = "Submenu" }, {"Mythic 19", 23, [4] = "Submenu" }, {"Mythic 20", 24, [4] = "Submenu" }, + }, + }, + [5] = { + {"Bloodforged", 1, [4] = "Submenu"}, + }, + }; - ["BCRaid"] = { {"Normal Flex", "" }, {"Heroic Flex", 3 }, {"Ascended", 4 }, {"Bloodforged", 1 }, }; + ["BCRaid"] = { + [1] = { + {"Normal", 2, [4] = "Submenu"}, + }, + [2] = { + {"Heroic", 3, [4] = "Submenu"}, + }, + [3] = { + {"Ascended", 4, [4] = "Submenu"}, + }, + [4] = { + {"Bloodforged", 1, [4] = "Submenu"}, + }, + }; ["WrathDungeon"] = { {"Normal", "" }, {"Mythic", 4 }, {"Mythic1", 5 }, {"Mythic2", 6 }, {"Mythic3", 7 }, {"Mythic4", 8 }, {"Mythic5", 9 }, {"Mythic6", 10 }, {"Mythic7", 11 }, {"Mythic8", 12 }, {"Mythic9", 13 }, {"Mythic10", 14 }, {"Bloodforged", 1 }, }; ["WrathRaid"] = { {"Normal Flex", "" }, {"Heroic Flex", 3 }, {"Ascended", 4 }, {"Bloodforged", 1 }, }; - ["Crafting"] = { {"Crafting Patterns", "" }, {"Item Normal", "=s=Normal" }, {"Bloodforged", 1 }, }; + ["Crafting"] = { + [1] = { + {"Crafting Patterns", "", [4] = "Submenu" }, + }, + [2] = { + {"Item Normal", "=s=Normal", [4] = "Submenu" }, + }, + [3] = { + {"Bloodforged", 1, [4] = "Submenu" }, + }, + }; - ["CraftingExt"] = { {"Crafting Pattern Uncommon", "" }, {"Crafting Patterns Rare", "Rare" }, {"Crafting Patterns Epic", "Epic" }, {"Item Uncommon", "=s=" }, {"Item Rare", "=s=Rare" }, {"Item Epic", "=s=Epic" } }; + ["CraftingExt"] = { + [1] = { + {"Crafting Pattern Uncommon", "", [4] = "Submenu" }, + }, + [2] = { + {"Crafting Patterns Rare", "Rare", [4] = "Submenu" }, + }, + [3] = { + {"Crafting Patterns Epic", "Epic", [4] = "Submenu" }, + }, + [4] = { + {"Item Uncommon", "=s=", [4] = "Submenu" }, + }, + [5] = { + {"Item Rare", "=s=Rare", [4] = "Submenu" }, + }, + [6] = { + {"Item Epic", "=s=Epic", [4] = "Submenu" } + }, + }; --Enums for comparisons in code diff --git a/AtlasLoot/DefaultFrame/AtlaslootDefaultFrame.lua b/AtlasLoot/DefaultFrame/AtlaslootDefaultFrame.lua index 2385b75..48632d1 100644 --- a/AtlasLoot/DefaultFrame/AtlaslootDefaultFrame.lua +++ b/AtlasLoot/DefaultFrame/AtlaslootDefaultFrame.lua @@ -139,8 +139,8 @@ end function AtlasLoot_DewDropSubMenu2Click(raidtablename, itemID, itemColour) if ATLASLOOT_FILTER_ENABLE == true then --used to refresh loottable when filter is enabled - AtlasLoot_FilterEnableButton() - ReEnableFilter = true + AtlasLoot_FilterEnableButton() + ReEnableFilter = true end -- gets itemID reference AtlasLootDefaultFrame_GetRaidDifficulty(raidtablename, itemID, itemColour) @@ -157,24 +157,24 @@ end function AtlasLoot_DifficultyDisable() --Disables Difficulty Menu isTablereference = false - notPattern = false - AtlasLoot_DewdropSubMenu2:Unregister(AtlasLootDefaultFrame_SubMenu2); - AtlasLootDefaultFrame_SubMenu2:Disable(); - AtlasLootDefaultFrame_SelectedTable2:SetText(""); - AtlasLootDefaultFrame_SelectedTable2:Hide(); - DewDrop2Enable = false - SelectedTable2TextSet = false + notPattern = false + AtlasLoot_DewdropSubMenu2:Unregister(AtlasLootDefaultFrame_SubMenu2); + AtlasLootDefaultFrame_SubMenu2:Disable(); + AtlasLootDefaultFrame_SelectedTable2:SetText(""); + AtlasLootDefaultFrame_SelectedTable2:Hide(); + DewDrop2Enable = false + SelectedTable2TextSet = false end function AtlasLoot_DifficultyEnable(dataID, dataSource) --Enables Difficulty Menu AtlasLootDefaultFrame_SubMenu2:Enable(); - AtlasLoot_DewdropSubMenu2:Unregister(AtlasLootDefaultFrame_SubMenu2); - AtlasLoot_DewdropSubMenu2Register(AtlasLoot_Difficulty[dataSource[dataID].Type]); - if SelectedTable2TextSet == false then - AtlasLootDefaultFrame_SelectedTable2:SetText(AtlasLoot_Difficulty[dataSource[dataID].Type][1][1]) - end - AtlasLootDefaultFrame_SelectedTable2:Show(); - SelectedTable2TextSet = true + AtlasLoot_DewdropSubMenu2:Unregister(AtlasLootDefaultFrame_SubMenu2); + AtlasLoot_DewdropSubMenu2Register(AtlasLoot_Difficulty[dataSource[dataID].Type]); + if SelectedTable2TextSet == false then + AtlasLootDefaultFrame_SelectedTable2:SetText(AtlasLoot_Difficulty[dataSource[dataID].Type][1][1]) + end + AtlasLootDefaultFrame_SelectedTable2:Show(); + SelectedTable2TextSet = true end function AtlasLootDefaultFrame_GetRaidDifficulty(raidtablename, itemID, itemColour) @@ -200,7 +200,7 @@ function AtlasLootDefaultFrame_GetRaidDifficulty(raidtablename, itemID, itemColo end DropTablename = raidtablename; end - +--[[ function AtlasLoot_DewdropSubMenu2Register(loottable) AtlasLoot_DewdropSubMenu2:Register(AtlasLootDefaultFrame_SubMenu2, 'point', function(parent) @@ -231,6 +231,140 @@ function AtlasLoot_DewdropSubMenu2Register(loottable) 'dontHook', true ) end +]] + +function AtlasLoot_DewdropSubMenu2Register(loottable) + AtlasLoot_DewdropSubMenu2:Register(AtlasLootDefaultFrame_SubMenu2, + 'point', function(parent) + return "TOP", "BOTTOM" + end, + 'children', function(level, value) + if level == 1 then + if AtlasLoot_Difficulty then + for k,v in ipairs(loottable) do + --If a link to show a submenu + if (type(v[1]) == "table") and (type(v[1][1]) == "string") then + local checked = false; + if v[1][3] == "Submenu" then + AtlasLoot_DewdropSubMenu2:AddLine( + 'text', v[1][1], + 'textR', 1, + 'textG', 0.82, + 'textB', 0, + 'func', AtlasLoot_DewDropSubMenu2Click, + 'arg1', v[1][1], + 'arg2', v[1][2], + 'arg3', v[1][3], + 'arg4', v[1][4], + 'notCheckable', true + ) + elseif v[1][1] ~= "" then + AtlasLoot_DewdropSubMenu2:AddLine( + 'text', v[1][1], + 'textR', 1, + 'textG', 0.82, + 'textB', 0, + 'func', AtlasLoot_DewDropSubMenu2Click, + 'arg1', v[1][1], + 'arg2', v[1][2], + 'arg3', v[1][3], + 'arg4', v[1][4], + 'notCheckable', true + ) + end + else + local lock=0; + --If an entry linked to a subtable + for i,j in pairs(v) do + if lock==0 then + AtlasLoot_DewdropSubMenu2:AddLine( + 'text', i, + 'textR', 1, + 'textG', 0.82, + 'textB', 0, + 'hasArrow', true, + 'value', j, + 'notCheckable', true + ) + lock=1; + end + end + end + end + end + --Close button + AtlasLoot_DewdropSubMenu2:AddLine( + 'text', AL["Close Menu"], + 'textR', 0, + 'textG', 1, + 'textB', 1, + 'func', function() AtlasLoot_DewdropSubMenu2:Close() end, + 'notCheckable', true + ) + elseif level == 2 then + if value then + for k,v in ipairs(value) do + if type(v) == "table" then + if (type(v[1]) == "string") then + local checked = false; + --If an entry to show a submenu + if v[4] == "Header" then + AtlasLoot_Dewdrop:AddLine( + 'text', v[1], + 'textR', 0.2, + 'textG', 0.82, + 'textB', 0.5, + 'func', AtlasLoot_DewDropSubMenu2Click, + 'arg1', v[1], + 'arg2', v[2], + 'arg3', v[3], + 'arg4', v[4], + 'notCheckable', true + ) + elseif v[3] == "Submenu" then + AtlasLoot_DewdropSubMenu2:AddLine( + 'text', v[1], + 'textR', 1, + 'textG', 0.82, + 'textB', 0, + 'func', AtlasLoot_DewDropSubMenu2Click, + 'arg1', v[1], + 'arg2', v[2], + 'arg3', v[3], + 'arg4', v[4], + 'notCheckable', true + ) + else + AtlasLoot_DewdropSubMenu2:AddLine( + 'text', v[1], + 'textR', 1, + 'textG', 0.82, + 'textB', 0, + 'func', AtlasLoot_DewDropSubMenu2Click, + 'arg1', v[1], + 'arg2', v[2], + 'arg3', v[3], + 'arg4', v[4], + 'notCheckable', true + ) + end + end + end + end + end + AtlasLoot_DewdropSubMenu2:AddLine( + 'text', AL["Close Menu"], + 'textR', 0, + 'textG', 1, + 'textB', 1, + 'func', function() AtlasLoot_DewdropSubMenu2:Close() end, + 'notCheckable', true + ) + end + end, + 'dontHook', true + ) +end --[[ AtlasLoot_DewdropSubMenuRegister(loottable):