Skip to content

Commit 7700f29

Browse files
committed
Migrated to the new menu style added in TWW
1 parent d6ae89c commit 7700f29

File tree

3 files changed

+55
-160
lines changed

3 files changed

+55
-160
lines changed

.pkgmeta

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,4 @@ externals:
1010
libs/LibTalentTree-1.0:
1111
url: https://github.com/NumyAddon/LibTalentTree-1.0
1212
curse-slug: libtalenttree
13-
libs/LibUIDropDownMenu: https://github.com/NumyAddon/LibUIDropDownMenu
1413
libs/LibVersionCheck-1.0: https://github.com/NumyAddon/LibVersionCheck-1.0.git

libs/embeds.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ https://raw.githubusercontent.com/Meorawr/wow-ui-schema/main/UI.xsd">
88
<Include file="AceConsole-3.0\AceConsole-3.0.xml"/>
99
<Include file="AceHook-3.0\AceHook-3.0.xml"/>
1010
<Include file="AceEvent-3.0\AceEvent-3.0.xml"/>
11-
<Include file="LibUIDropDownMenu\LibUIDropDownMenu.xml"/>
1211
<Include file="LibTalentTree-1.0\LibTalentTree-1.0.xml"/>
1312
<Include file="LibVersionCheck-1.0\LibVersionCheck-1.0.xml"/>
1413
</Ui>

modules/SideBarMixin.lua

Lines changed: 55 additions & 158 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@ local addonName, ns = ...;
44
local SideBarMixin = {};
55
ns.SideBarMixin = SideBarMixin;
66

7-
--- @type LibUIDropDownMenuNumy-4.0
8-
local LibDD = LibStub("LibUIDropDownMenuNumy-4.0");
9-
107
--- @type TalentLoadoutManagerConfig
118
local Config = ns.Config;
129

@@ -206,7 +203,6 @@ end
206203
function SideBarMixin:SetupHook()
207204
if not self.SideBar then
208205
self.SideBar, self.DataProvider = self:CreateSideBar();
209-
self.DropDown = self:InitDropDown(self.SideBar);
210206
self:SetCollapsed(Config:GetConfig(self.name .. SETTING_SUFFIX_COLLAPSED));
211207
self:UpdatePointsForAnchorLocation();
212208
self:TryIntegrateWithBlizzMove();
@@ -734,142 +730,67 @@ function SideBarMixin:CreateScrollBox(parentContainer)
734730
return ContainerFrame, dataProvider;
735731
end
736732

737-
function SideBarMixin:InitDropDown(parentFrame)
738-
local dropDown = LibDD:Create_UIDropDownMenu(self.name .. "_DropDown", parentFrame);
739-
return dropDown;
740-
end
741-
733+
--- @param rootDescription RootMenuDescriptionProxy
742734
--- @param frame TLM_ElementFrame
743735
--- @param loadoutInfo TLM_SideBarLoadoutInfo
744-
function SideBarMixin:OpenDropDownMenu(dropDown, frame, loadoutInfo)
736+
function SideBarMixin:GenerateMenu(rootDescription, frame, loadoutInfo)
745737
local talentsTab = self:GetTalentsTab();
746738
local classID = talentsTab:GetClassID();
747739
local playerClassID = select(3, UnitClass("player"));
748740

749-
local items = {
750-
title = {
751-
text = loadoutInfo.displayName,
752-
isTitle = true,
753-
notCheckable = true,
754-
},
755-
load = {
756-
text = "Load",
757-
notCheckable = true,
758-
func = function()
759-
local forceApply = false;
760-
self:OnElementClick(frame, loadoutInfo, forceApply);
761-
end,
762-
},
763-
loadAndApply = {
764-
text = "Load & Apply",
765-
notCheckable = true,
766-
func = function()
767-
local forceApply = true;
768-
self:OnElementClick(frame, loadoutInfo, forceApply);
769-
end,
770-
hidden = not self.ShowLoadAndApply,
771-
},
772-
saveCurrentIntoLoadout = {
773-
text = "Save current talents into loadout",
774-
notCheckable = true,
775-
disabled = loadoutInfo.isBlizzardLoadout,
776-
func = function()
777-
self:UpdateCustomLoadoutWithCurrentTalents(loadoutInfo.id);
778-
end,
779-
},
780-
rename = {
781-
text = "Rename",
782-
notCheckable = true,
783-
disabled = not loadoutInfo.playerIsOwner,
784-
func = function()
785-
StaticPopup_Show(self.renameDialogName, loadoutInfo.name, nil, loadoutInfo);
786-
end,
787-
},
788-
setParentLoadout = {
789-
text = "Set Blizzard base loadout",
790-
notCheckable = true,
791-
hidden = classID ~= playerClassID or loadoutInfo.isBlizzardLoadout,
792-
hasArrow = true,
793-
menuList = function()
794-
return self:MakeBlizzardLoadoutsMenuList(loadoutInfo);
795-
end,
796-
},
797-
export = {
798-
text = "Export",
799-
notCheckable = true,
800-
func = function()
801-
self:ExportLoadout(loadoutInfo);
802-
end,
803-
},
804-
linkToChat = {
805-
text = "Link to chat",
806-
notCheckable = true,
807-
func = function()
808-
self:LinkToChat(loadoutInfo.id);
809-
end,
810-
},
811-
openInTTV = {
812-
text = "Open in TalentTreeViewer",
813-
notCheckable = true,
814-
disabled = nil == TalentViewerLoader,
815-
func = function()
816-
self:OpenInTalentTreeViewer(loadoutInfo);
817-
end,
818-
hidden = not self.ShowShowInTTV,
819-
},
820-
delete = {
821-
text = "Delete",
822-
notCheckable = true,
823-
func = function()
824-
StaticPopup_Show(self.deleteDialogName, loadoutInfo.name, nil, loadoutInfo);
825-
end,
826-
hidden = not loadoutInfo.playerIsOwner,
827-
},
828-
removeFromList = {
829-
text = "Remove from list",
830-
notCheckable = true,
831-
func = function()
832-
StaticPopup_Show(self.removeFromListDialogName, loadoutInfo.name, nil, loadoutInfo);
833-
end,
834-
hidden = loadoutInfo.playerIsOwner,
835-
},
836-
removeFromListBulk = {
837-
text = "Remove all loadouts from this character from the list",
838-
notCheckable = true,
839-
func = function()
840-
StaticPopup_Show(self.removeFromListBulkDialogName, loadoutInfo.owner, nil, loadoutInfo);
841-
end,
842-
hidden = loadoutInfo.playerIsOwner,
843-
},
844-
};
845-
846-
local order = {
847-
items.title,
848-
items.setParentLoadout,
849-
items.load,
850-
items.loadAndApply,
851-
items.saveCurrentIntoLoadout,
852-
items.rename,
853-
items.export,
854-
items.linkToChat,
855-
items.openInTTV,
856-
items.delete,
857-
items.removeFromList,
858-
items.removeFromListBulk,
859-
};
860-
861-
self.menuList = {};
862-
for _, v in ipairs(order) do
863-
if not v.hidden then
864-
v.hidden = nil;
865-
if v.menuList and type(v.menuList) == "function" then
866-
v.menuList = v.menuList();
741+
rootDescription:CreateTitle(loadoutInfo.displayName);
742+
rootDescription:CreateButton("Load", function()
743+
local forceApply = false;
744+
self:OnElementClick(frame, loadoutInfo, forceApply);
745+
end);
746+
if self.ShowLoadAndApply then
747+
rootDescription:CreateButton("Load & Apply", function()
748+
local forceApply = true;
749+
self:OnElementClick(frame, loadoutInfo, forceApply);
750+
end);
751+
end
752+
rootDescription:CreateButton("Save current talents into loadout", function()
753+
self:UpdateCustomLoadoutWithCurrentTalents(loadoutInfo.id);
754+
end):SetEnabled(not loadoutInfo.isBlizzardLoadout);
755+
rootDescription:CreateButton("Rename", function()
756+
StaticPopup_Show(self.renameDialogName, loadoutInfo.name, nil, loadoutInfo);
757+
end):SetEnabled(loadoutInfo.playerIsOwner);
758+
if classID == playerClassID and not loadoutInfo.isBlizzardLoadout then
759+
local baseLoadoutElementDescription = rootDescription:CreateButton("Set Blizzard base loadout", function() end);
760+
761+
local function isSelected(data) return data.id == loadoutInfo.parentID; end
762+
local function setSelected(data) CharacterAPI:SetParentLoadout(loadoutInfo.id, data.id); end
763+
--- @type TLM_SideBarDataProviderEntry[]
764+
local elements = self.DataProvider:GetCollection();
765+
for _, element in ipairs(elements) do
766+
if element.data.isBlizzardLoadout and element.data.playerIsOwner then
767+
baseLoadoutElementDescription:CreateRadio(element.data.displayName, isSelected, setSelected, element.data);
867768
end
868-
table.insert(self.menuList, v);
869769
end
870770
end
871-
872-
LibDD:EasyMenu(self.menuList, dropDown, frame, 80, 0);
771+
rootDescription:CreateButton("Export", function()
772+
self:ExportLoadout(loadoutInfo);
773+
end);
774+
rootDescription:CreateButton("Link to chat", function()
775+
self:LinkToChat(loadoutInfo.id);
776+
end);
777+
if self.ShowShowInTTV then
778+
rootDescription:CreateButton("Open in TalentTreeViewer", function()
779+
self:OpenInTalentTreeViewer(loadoutInfo);
780+
end):SetEnabled(nil ~= TalentViewerLoader);
781+
end
782+
if loadoutInfo.playerIsOwner then
783+
rootDescription:CreateButton("Delete", function()
784+
StaticPopup_Show(self.deleteDialogName, loadoutInfo.name, nil, loadoutInfo);
785+
end);
786+
else
787+
rootDescription:CreateButton("Remove from list", function()
788+
StaticPopup_Show(self.removeFromListDialogName, loadoutInfo.name, nil, loadoutInfo);
789+
end);
790+
rootDescription:CreateButton("Remove all loadouts from this character from the list", function()
791+
StaticPopup_Show(self.removeFromListBulkDialogName, loadoutInfo.owner, nil, loadoutInfo);
792+
end);
793+
end
873794
end
874795

875796
--- @param owner string
@@ -884,27 +805,6 @@ function SideBarMixin:RemoveAllLoadoutsByOwner(owner)
884805
end
885806
end
886807

887-
--- @param loadoutInfo TLM_SideBarLoadoutInfo
888-
function SideBarMixin:MakeBlizzardLoadoutsMenuList(loadoutInfo)
889-
local dataProvider = self.DataProvider;
890-
--- @type TLM_SideBarDataProviderEntry[]
891-
local elements = dataProvider:GetCollection();
892-
local menuList = {};
893-
for _, v in ipairs(elements) do
894-
if v.data.isBlizzardLoadout and v.data.playerIsOwner then
895-
table.insert(menuList, {
896-
text = v.data.displayName,
897-
func = function()
898-
CharacterAPI:SetParentLoadout(loadoutInfo.id, v.data.id);
899-
end,
900-
checked = v.data.id == loadoutInfo.parentID,
901-
});
902-
end
903-
end
904-
905-
return menuList;
906-
end
907-
908808
--- @param frame TLM_ElementFrame
909809
--- @param loadoutInfo TLM_SideBarLoadoutInfo
910810
function SideBarMixin:SetElementAsActive(frame, loadoutInfo)
@@ -935,12 +835,9 @@ end
935835
--- @param frame TLM_ElementFrame
936836
--- @param loadoutInfo TLM_SideBarLoadoutInfo
937837
function SideBarMixin:OnElementRightClick(frame, loadoutInfo)
938-
local dropDown = self.DropDown;
939-
if dropDown.currentElement ~= loadoutInfo.id then
940-
LibDD:CloseDropDownMenus();
941-
end
942-
dropDown.currentElement = loadoutInfo.id;
943-
self:OpenDropDownMenu(dropDown, frame, loadoutInfo);
838+
MenuUtil.CreateContextMenu(frame, function(_, rootDescription)
839+
self:GenerateMenu(rootDescription, frame, loadoutInfo);
840+
end);
944841
end
945842

946843
function SideBarMixin:LinkToChat(loadoutId)

0 commit comments

Comments
 (0)