LibMainMenu is intended to help you to create
Main Menus (
Scenes with multiple
tabs like in Journal or Quest).
It is also able to add a new icon to the main menu icon's line (just like LibMainMenu2 does) but the 2 libraries are different and cannot be replaced by each other.
If addons request LibMainMenu you need to use LibMainMenu, NOT LibMainMenu
2
Attention: With version 9 LibMainMenu will NOT support LibStub anymore! Switch your addon code to the global variable LibMainMenu (please read below).
The Library is handled by it's global variable LibMainMenu, so you should first define in your metafile (.txt)by addind LibMainMenu to your includes like this :
## DependsOn: LibMainMenu
|
And reference it in your code like this :
It's 2 main functions were added to help developers to add a menu (a
category)
Lua Code:
local menuIndex = LMM:MainMenuAddCategory(arrayOfCategoryData)
LMM:MainMenuAddSceneGroup(menuIndex, GroupSceneString, iconData)
And another 2 functions for calling the menus themselves :
Lua Code:
-- Toggle
LMM:ToggleCategory(menuIndex)
-- Specific scene
LMM:Update(menuIndex, "MyAddonAnotherScene")
menuIndex = LMM:MainMenuAddCategory(arrayOfCategoryData)
arrayOfCategoryData is an array with the following parameters :
binding = stringOfYourKeyBinding
categoryName = stringOfCategoryName
normal = texturePath
pressed = texturePath
highlight = texturePath
|
- binding is a name of a keybinding defined with ZO_CreateStringId("SI_BINDING_NAME_XXXXXXX", "Some string")
- categoryName is the name of your Menu
menuIndex is the ID of your Menu defined by LibMainMenu. It will be used in later calls.
So it should look like this :
Lua Code:
MYADDON_MAIN_MENU_CATEGORY_DATA =
{
binding = "MYADDON_SHOW_PANEL",
categoryName = SI_MYADDON_MAIN_MENU_TITLE,
normal = "EsoUI/Art/MainMenu/menuBar_champion_up.dds",
pressed = "EsoUI/Art/MainMenu/menuBar_champion_down.dds",
highlight = "EsoUI/Art/MainMenu/menuBar_champion_over.dds",
}
LMM:MainMenuAddSceneGroup(menuIndex, GroupSceneString, iconData)
- menuIndex is the value of your call to LMM:AddCategory
- GroupSceneString is the string who will be used as reference for calling the category (ex: "myAddonSceneGroup")
- iconData is an array which define all icons of all tabs of your category (menu)
Each subkey of iconData is an array of 1 tab
each subkey must have the subkey defined :
categoryName = string
descriptor = integer
normal = texturePath
pressed = texturePath
highlight = texturePath
|
- categoryName will be the tab name (shown near the buttons at the right)
- descriptor is the name of your Scene defined in ZO_Scene:New()
- visible (optionnal) is a function which return a boolean. If false the tab won't be displayed.
ex:
Lua Code:
local iconData = {
{
categoryName = SI_MYADDON_MAIN_MENU_TITLE, -- the title at the right (near the buttons)
descriptor = "MyAddonMain",
normal = "EsoUI/Art/MainMenu/menuBar_champion_up.dds",
pressed = "EsoUI/Art/MainMenu/menuBar_champion_down.dds",
highlight = "EsoUI/Art/MainMenu/menuBar_champion_over.dds",
},
{
categoryName = SI_MYADDON_ANOTHER_MENU_TITLE, -- the title at the right (near the buttons)
visible = function() return IsChampionSystemUnlocked() end, -- is tab visible ?
descriptor = "MyAddonAnother",
normal = "EsoUI/Art/Guild/tabicon_history_up.dds",
pressed = "EsoUI/Art/Guild/tabicon_history_down.dds",
highlight = "EsoUI/Art/Guild/tabicon_history_over.dds",
},
}
-- Register the group and add the buttons
LMM:MainMenuAddSceneGroup(menuIndex, "MyAddonSceneGroup", iconData)
Long How-To: Create a Main menu (experienced addon developpers)
1st part : Creating Simple Scene
Creating a
simple scene is not so hard :
1st step, make your xml.
The TopLevelControl will get one of the Scene inheritance : the most used is
ZO_RightPanelFootPrint
So your XML wll look like this :
Lua Code:
<GuiXml>
<Controls>
<TopLevelControl name="MyUINameInXML" inherits="ZO_RightPanelFootPrint" hidden="true">
<OnInitialized>
MyAddon.initData(self)
</OnInitialized>
<Controls>
</Controls>
</TopLevelControl>
</Controls>
</GuiXml>
Then, in your onAddonLoaded, you'll need to create your scene
Here how you can do :
Lua Code:
function MyAddon.CreateScene()
-- Main Scene
MYADDON_MAIN_SCENE = ZO_Scene:New("MyAddonMain", SCENE_MANAGER)
-- Mouse standard position and background
MYADDON_MAIN_SCENE:AddFragmentGroup(FRAGMENT_GROUP.MOUSE_DRIVEN_UI_WINDOW)
MYADDON_MAIN_SCENE:AddFragmentGroup(FRAGMENT_GROUP.FRAME_TARGET_STANDARD_RIGHT_PANEL)
-- Background Right, it will set ZO_RightPanelFootPrint and its stuff.
MYADDON_MAIN_SCENE:AddFragment(RIGHT_BG_FRAGMENT)
-- The title fragment
MYADDON_MAIN_SCENE:AddFragment(TITLE_FRAGMENT)
-- Set Title
ZO_CreateStringId("SI_MYADDON_MAIN_MENU_TITLE", "My Addon Name")
MYADDON_MAIN_TITLE_FRAGMENT = ZO_SetTitleFragment:New(SI_MYADDON_MAIN_MENU_TITLE)
MYADDON_MAIN_SCENE:AddFragment(MYADDON_MAIN_TITLE_FRAGMENT)
-- Add the XML to our scene
MYADDON_MAIN_WINDOW = ZO_FadeSceneFragment:New(MyUINameInXML)
MYADDON_MAIN_SCENE:AddFragment(MYADDON_MAIN_WINDOW)
end
2nd Part : Create your Menu
Lua Code:
-- Build the Menu
-- Its name for the menu (the meta scene)
ZO_CreateStringId("SI_MYADDON_MAIN_MENU_TITLE", "My Addon Name")
-- Its infos,
ZO_CreateStringId("SI_BINDING_NAME_MYADDON_SHOW_PANEL", "Toggle My Addon") -- you also need to use a bindings.xml in order to display your keybind in options.
MYADDON_MAIN_MENU_CATEGORY_DATA =
{
binding = "MYADDON_SHOW_PANEL",
categoryName = SI_MYADDON_MAIN_MENU_TITLE,
normal = "EsoUI/Art/MainMenu/menuBar_champion_up.dds",
pressed = "EsoUI/Art/MainMenu/menuBar_champion_down.dds",
highlight = "EsoUI/Art/MainMenu/menuBar_champion_over.dds",
}
-- Then the scenes
-- Main Scene is created trought our function described in 1st section
MyAddon.CreateScene()
-- Another Scene , because using main menu without having 2 scenes should be avoided.
MYADDON_ANOTHER_SCENE = ZO_Scene:New("MyAddonAnother", SCENE_MANAGER)
-- Mouse standard position and background
MYADDON_ANOTHER_SCENE:AddFragmentGroup(FRAGMENT_GROUP.MOUSE_DRIVEN_UI_WINDOW)
MYADDON_ANOTHER_SCENE:AddFragmentGroup(FRAGMENT_GROUP.FRAME_TARGET_STANDARD_RIGHT_PANEL)
-- Background Right, it will set ZO_RightPanelFootPrint and its stuff.
MYADDON_ANOTHER_SCENE:AddFragment(RIGHT_BG_FRAGMENT)
-- The title fragment
MYADDON_ANOTHER_SCENE:AddFragment(TITLE_FRAGMENT)
-- Set Title
ZO_CreateStringId("SI_MYADDON_IMPORT_MENU_TITLE", "Another title")
MYADDON_ANOTHER_TITLE_FRAGMENT = ZO_SetTitleFragment:New(SI_MYADDON_MAIN_MENU_TITLE) -- The title at the left of the scene is the "global one" but we can change it
MYADDON_ANOTHER_SCENE:AddFragment(MYADDON_ANOTHER_TITLE_FRAGMENT)
-- Add the XML to our scene
MYADDON_ANOTHER_WINDOW = ZO_FadeSceneFragment:New(AnotherPieceofXML)
MYADDON_ANOTHER_SCENE:AddFragment(MYADDON_ANOTHER_WINDOW)
-- Set tabs and visibility, etc
do
local iconData = {
{
categoryName = SI_MYADDON_MAIN_MENU_TITLE, -- the title at the right (near the buttons)
descriptor = "MyAddonMain",
normal = "EsoUI/Art/MainMenu/menuBar_champion_up.dds",
pressed = "EsoUI/Art/MainMenu/menuBar_champion_down.dds",
highlight = "EsoUI/Art/MainMenu/menuBar_champion_over.dds",
},
{
categoryName = SI_MYADDON_ANOTHER_MENU_TITLE, -- the title at the right (near the buttons)
visible = function() return IsChampionSystemUnlocked() end, -- is tab visible ?
descriptor = "MyAddonAnother",
normal = "EsoUI/Art/Guild/tabicon_history_up.dds",
pressed = "EsoUI/Art/Guild/tabicon_history_down.dds",
highlight = "EsoUI/Art/Guild/tabicon_history_over.dds",
},
}
-- Register Scenes and the group name
SCENE_MANAGER:AddSceneGroup("MyAddonSceneGroup", ZO_SceneGroup:New("MyAddonMain", "MyAddonAnother"))
-- ZOS have hardcoded its categories, so here is LibMainMenu utility.
MENU_CATEGORY_MYADDON = LMM:MainMenuAddCategory(MYADDON_MAIN_MENU_CATEGORY_DATA)
-- Register the group and add the buttons
LMM:MainMenuAddSceneGroup(MENU_CATEGORY_MYADDON, "MyAddonSceneGroup", iconData)
end
If you want to display your Menu, juste use :
Lua Code:
-- Toggle
LMM:ToggleCategory(MENU_CATEGORY_MYADDON)
If you want to display a specific scene, juste use :
Lua Code:
-- Toggle
LMM:Update(MENU_CATEGORY_MYADDON, "MyAddonAnother")
For a more deeply debug, LibMainmenu is available trought global variable
LIBMAINMENU.
functionalities of "LibMainMenu" are similar to ESOUI MAIN_MENU.
Addons using this library, providing sample code e.g.
pChat