Download
(4 Kb)
Download
Updated: 04/12/21 10:54 AM
Pictures
File Info
Compatibility:
Flames of Ambition (6.3.5)
Markarth (6.2.5)
Updated:04/12/21 10:54 AM
Created:08/30/18 11:49 AM
Monthly downloads:27,413
Total downloads:1,987,112
Favorites:1,142
MD5:
LibMainMenu-2.0  Popular! (More than 5000 hits)
Version: 4.4.0
by: votan [More]
Description
Library to add main menu entries.
For example used in Potion Maker and Votan's Settings Menu and FCOItemSaver.

The Library is handled by it's global variable LibMainMenu2, so you should first define in your metafile (.txt) by adding LibMainMenu to your includes like this:
## DependsOn: LibMainMenu-2.0

And reference it in your code like this:
Lua Code:
  1. local LMM = LibMainMenu2

Example
Lua Code:
  1. local descriptor = "Unique Name" -- e.g. your addon name
  2.  
  3. -- this as part of the EVENT_ADD_ON_LOADED
  4. local LMM2 = LibMainMenu2
  5. LMM2:Init()
  6.  
  7. local sceneName = "gameMenuInGame" -- Your scene name. This is just a working example.
  8.  
  9. -- Add to main menu
  10. local categoryLayoutInfo =
  11. {
  12.     binding = "YOUR_KEYBIND_ACTION_NAME",
  13.     categoryName = SI_BINDING_NAME_YOUR_KEYBIND_ACTION_NAME,
  14.     callback = function(buttonData)
  15.         if not SCENE_MANAGER:IsShowing(sceneName) then
  16.             SCENE_MANAGER:Show(sceneName)
  17.         else
  18.             SCENE_MANAGER:ShowBaseScene()
  19.         end
  20.     end,
  21.     visible = function(buttonData) return true end,
  22.  
  23.     normal = "esoui/art/inventory/inventory_tabicon_consumables_up.dds",
  24.     pressed = "esoui/art/inventory/inventory_tabicon_consumables_down.dds",
  25.     highlight = "esoui/art/inventory/inventory_tabicon_consumables_over.dds",
  26.     disabled = "esoui/art/inventory/inventory_tabicon_consumables_disabled.dds",
  27. }
  28.  
  29. LMM2:AddMenuItem(descriptor, sceneName, categoryLayoutInfo, nil)
  30. -- end part of the EVENT_ADD_ON_LOADED

Force refresh of visibility:
Code:
LMM2:Refresh()
Click on the menu entry by code:
Code:
LMM2:SelectMenuItem(descriptor)
Former LibMainMenu 1 support
It's 2 main functions were added to help developers to add a menu (a category)
Lua Code:
  1. local menuIndex = LMM:MainMenuAddCategory(arrayOfCategoryData)
  2. LMM:MainMenuAddSceneGroup(menuIndex, GroupSceneString, iconData)

And another 2 functions for calling the menus themselves :
Lua Code:
  1. -- Toggle
  2. LMM:ToggleCategory(menuIndex)
  3. -- Specific scene
  4. 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:
  1. MYADDON_MAIN_MENU_CATEGORY_DATA =
  2.     {
  3.         binding = "MYADDON_SHOW_PANEL",
  4.         categoryName = SI_MYADDON_MAIN_MENU_TITLE,
  5.         normal = "EsoUI/Art/MainMenu/menuBar_champion_up.dds",
  6.         pressed = "EsoUI/Art/MainMenu/menuBar_champion_down.dds",
  7.         highlight = "EsoUI/Art/MainMenu/menuBar_champion_over.dds",
  8.     }



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:
  1. local iconData = {
  2.             {
  3.                 categoryName = SI_MYADDON_MAIN_MENU_TITLE, -- the title at the right (near the buttons)
  4.                 descriptor = "MyAddonMain",
  5.                 normal = "EsoUI/Art/MainMenu/menuBar_champion_up.dds",
  6.                 pressed = "EsoUI/Art/MainMenu/menuBar_champion_down.dds",
  7.                 highlight = "EsoUI/Art/MainMenu/menuBar_champion_over.dds",
  8.             },
  9.             {
  10.                 categoryName = SI_MYADDON_ANOTHER_MENU_TITLE, -- the title at the right (near the buttons)
  11.                 visible = function() return IsChampionSystemUnlocked() end, -- is tab visible ?
  12.                 descriptor = "MyAddonAnother",
  13.                 normal = "EsoUI/Art/Guild/tabicon_history_up.dds",
  14.                 pressed = "EsoUI/Art/Guild/tabicon_history_down.dds",
  15.                 highlight = "EsoUI/Art/Guild/tabicon_history_over.dds",
  16.             },
  17.         }
  18.        
  19.         -- Register the group and add the buttons
  20.         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:
  1. <GuiXml>
  2.     <Controls>
  3.         <TopLevelControl name="MyUINameInXML" inherits="ZO_RightPanelFootPrint" hidden="true">
  4.             <OnInitialized>
  5.                 MyAddon.initData(self)
  6.             </OnInitialized>
  7.             <Controls>
  8.             </Controls>
  9.         </TopLevelControl>
  10.     </Controls>
  11. </GuiXml>

Then, in your onAddonLoaded, you'll need to create your scene
Here how you can do :

Lua Code:
  1. function MyAddon.CreateScene()
  2.  
  3.     -- Main Scene
  4.     MYADDON_MAIN_SCENE = ZO_Scene:New("MyAddonMain", SCENE_MANAGER)
  5.    
  6.     -- Mouse standard position and background
  7.     MYADDON_MAIN_SCENE:AddFragmentGroup(FRAGMENT_GROUP.MOUSE_DRIVEN_UI_WINDOW)
  8.     MYADDON_MAIN_SCENE:AddFragmentGroup(FRAGMENT_GROUP.FRAME_TARGET_STANDARD_RIGHT_PANEL)
  9.    
  10.     --  Background Right, it will set ZO_RightPanelFootPrint and its stuff.
  11.     MYADDON_MAIN_SCENE:AddFragment(RIGHT_BG_FRAGMENT)
  12.    
  13.     -- The title fragment
  14.     MYADDON_MAIN_SCENE:AddFragment(TITLE_FRAGMENT)
  15.    
  16.     -- Set Title
  17.     ZO_CreateStringId("SI_MYADDON_MAIN_MENU_TITLE", "My Addon Name")
  18.     MYADDON_MAIN_TITLE_FRAGMENT = ZO_SetTitleFragment:New(SI_MYADDON_MAIN_MENU_TITLE)
  19.     MYADDON_MAIN_SCENE:AddFragment(MYADDON_MAIN_TITLE_FRAGMENT)
  20.    
  21.     -- Add the XML to our scene
  22.     MYADDON_MAIN_WINDOW = ZO_FadeSceneFragment:New(MyUINameInXML)
  23.     MYADDON_MAIN_SCENE:AddFragment(MYADDON_MAIN_WINDOW)
  24.    
  25.    
  26. end


2nd Part : Create your Menu

Lua Code:
  1. -- Build the Menu
  2.     -- Its name for the menu (the meta scene)
  3.     ZO_CreateStringId("SI_MYADDON_MAIN_MENU_TITLE", "My Addon Name")
  4.    
  5.     -- Its infos,
  6.     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.
  7.     MYADDON_MAIN_MENU_CATEGORY_DATA =
  8.     {
  9.         binding = "MYADDON_SHOW_PANEL",
  10.         categoryName = SI_MYADDON_MAIN_MENU_TITLE,
  11.         normal = "EsoUI/Art/MainMenu/menuBar_champion_up.dds",
  12.         pressed = "EsoUI/Art/MainMenu/menuBar_champion_down.dds",
  13.         highlight = "EsoUI/Art/MainMenu/menuBar_champion_over.dds",
  14.     }
  15.    
  16.     -- Then the scenes
  17.    
  18.     -- Main Scene is created trought our function described in 1st section
  19.     MyAddon.CreateScene()
  20.    
  21.     -- Another Scene , because using main menu without having 2 scenes should be avoided.
  22.     MYADDON_ANOTHER_SCENE = ZO_Scene:New("MyAddonAnother", SCENE_MANAGER)  
  23.    
  24.     -- Mouse standard position and background
  25.     MYADDON_ANOTHER_SCENE:AddFragmentGroup(FRAGMENT_GROUP.MOUSE_DRIVEN_UI_WINDOW)
  26.     MYADDON_ANOTHER_SCENE:AddFragmentGroup(FRAGMENT_GROUP.FRAME_TARGET_STANDARD_RIGHT_PANEL)
  27.    
  28.     --  Background Right, it will set ZO_RightPanelFootPrint and its stuff.
  29.     MYADDON_ANOTHER_SCENE:AddFragment(RIGHT_BG_FRAGMENT)
  30.    
  31.     -- The title fragment
  32.     MYADDON_ANOTHER_SCENE:AddFragment(TITLE_FRAGMENT)
  33.    
  34.     -- Set Title
  35.     ZO_CreateStringId("SI_MYADDON_IMPORT_MENU_TITLE", "Another title")
  36.     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
  37.     MYADDON_ANOTHER_SCENE:AddFragment(MYADDON_ANOTHER_TITLE_FRAGMENT)
  38.    
  39.     -- Add the XML to our scene
  40.     MYADDON_ANOTHER_WINDOW = ZO_FadeSceneFragment:New(AnotherPieceofXML)
  41.     MYADDON_ANOTHER_SCENE:AddFragment(MYADDON_ANOTHER_WINDOW)
  42.  
  43.     -- Set tabs and visibility, etc
  44.    
  45.     do
  46.         local iconData = {
  47.             {
  48.                 categoryName = SI_MYADDON_MAIN_MENU_TITLE, -- the title at the right (near the buttons)
  49.                 descriptor = "MyAddonMain",
  50.                 normal = "EsoUI/Art/MainMenu/menuBar_champion_up.dds",
  51.                 pressed = "EsoUI/Art/MainMenu/menuBar_champion_down.dds",
  52.                 highlight = "EsoUI/Art/MainMenu/menuBar_champion_over.dds",
  53.             },
  54.             {
  55.                 categoryName = SI_MYADDON_ANOTHER_MENU_TITLE, -- the title at the right (near the buttons)
  56.                 visible = function() return IsChampionSystemUnlocked() end, -- is tab visible ?
  57.                 descriptor = "MyAddonAnother",
  58.                 normal = "EsoUI/Art/Guild/tabicon_history_up.dds",
  59.                 pressed = "EsoUI/Art/Guild/tabicon_history_down.dds",
  60.                 highlight = "EsoUI/Art/Guild/tabicon_history_over.dds",
  61.             },
  62.         }
  63.        
  64.         -- Register Scenes and the group name
  65.         SCENE_MANAGER:AddSceneGroup("MyAddonSceneGroup", ZO_SceneGroup:New("MyAddonMain", "MyAddonAnother"))
  66.        
  67.         -- ZOS have hardcoded its categories, so here is LibMainMenu utility.
  68.         MENU_CATEGORY_MYADDON = LMM:MainMenuAddCategory(MYADDON_MAIN_MENU_CATEGORY_DATA)
  69.        
  70.         -- Register the group and add the buttons
  71.         LMM:MainMenuAddSceneGroup(MENU_CATEGORY_MYADDON, "MyAddonSceneGroup", iconData)
  72.        
  73.     end

If you want to display your Menu, juste use :

Lua Code:
  1. -- Toggle
  2. LMM:ToggleCategory(MENU_CATEGORY_MYADDON)

If you want to display a specific scene, juste use :

Lua Code:
  1. -- Toggle
  2. LMM:Update(MENU_CATEGORY_MYADDON, "MyAddonAnother")
version 4.4.0:
- Including LibMainMenu, too. No more confusion about which is "newer".

version 4.3.6:
- Update to API 100034 "Flames of Ambition".

version 4.3.5:
- Update to API 100033 "Markarth".

version 4.3.4:
- Update to API 100032 "Stonethorn".

version 4.3.3:
- Update to API 100031 "Greymoor".

version 4.3.2:
- Update to API 100030 "Harrowstorm".

version 4.3.1:
- Update to API 100029 "Dragonhold".

version 1.4.3:
- Update to "Scalebreaker".
- Fixed: Keep menu item selected.

version 4.2.0:
- Fixed selected menu item not been highlighted.

version 4.1.0:
- API bump 100027 "Elsweyr".
- Accessible via LibMainMenu2.
- Use of LibStub is optional.

version 3.0.2:
- Update to API 100026 "Wrathstone".

version 3.0.1:
- API bump 100025 "Murkmire".
Optional Files (0)


Archived Files (12)
File Name
Version
Size
Uploader
Date
4.3.6
2kB
votan
02/20/21 09:11 AM
4.3.5
2kB
votan
11/01/20 08:58 AM
4.3.4
2kB
votan
08/22/20 04:55 AM
4.3.3
2kB
votan
05/24/20 10:39 AM
4.3.2
2kB
votan
02/15/20 11:44 AM
4.3.1
2kB
votan
10/19/19 08:27 AM
4.3.0
2kB
votan
07/17/19 11:17 AM
4.2.0
2kB
votan
06/01/19 09:32 AM
4.1.0
2kB
votan
05/18/19 08:07 AM
3.0.2
11kB
votan
02/23/19 10:15 AM
3.0.1
3kB
votan
10/13/18 09:25 AM
3.0
9kB
votan
08/30/18 11:49 AM


Post A Reply Comment Options
Unread 05/18/19, 09:58 AM  
Anceane
 
Anceane's Avatar
AddOn Author - Click to view AddOns

Forum posts: 306
File comments: 1018
Uploads: 1
there is 2 version of this lib

Hervestmap is using Ayantir version 5 of this lib https://www.esoui.com/downloads/info...bMainMenu.html

So which is the good one ? is there not a risk of conflict ?

Thank you
Report comment to moderator  
Reply With Quote
Unread 04/30/19, 10:54 AM  
Baertram
Super Moderator
 
Baertram's Avatar
ESOUI Super Moderator
AddOn Author - Click to view AddOns

Forum posts: 4989
File comments: 6040
Uploads: 78
LibMainMenu-2.0 for PTS with stripped LibStub + added TXT file IsLibrray etc.

-> Global variable:
Lua Code:
  1. LibMainMenu2

Edit - 2019-05-11
Updated and fixed to be compatible without LibStub and with it
Last edited by Baertram : 05/11/19 at 09:57 AM.
Report comment to moderator  
Reply With Quote
Unread 09/02/18, 01:18 AM  
votan
 
votan's Avatar
AddOn Author - Click to view AddOns

Forum posts: 577
File comments: 1671
Uploads: 40
Re: LibMainMenu-2.0 ..... Who needs it?

Originally Posted by Shadowshire
Which TESO players must download and install this "add-on"?? IMHO, the developers of the add-ons which use its functions should include it with the installation of their add-on.

ZOS (?) has added a Libraries category at the bottom of the list of addons. It evidently lists the "libraries" which are installed in the respective addon folders in the ...\Elder Scrolls \live\Addons folder. Unfortunately, I haven't been able to find any mention of it in the Patch Notes for Update 17, after which it appeared. What purpose does it serve?
You need to download it, if an addon tells you, that it is missing. I include all required libs in my addons. You may just have to check if they are enabled.
Others prefer that Minion updates them automatically by explicitly downloading them.
The purpose is to filter out duplicates and older versions by the game client and not by Lua (LibStub).
Report comment to moderator  
Reply With Quote
Unread 09/01/18, 05:17 PM  
Shadowshire

Forum posts: 1
File comments: 402
Uploads: 0
Arrow LibMainMenu-2.0 ..... Who needs it?

Which TESO players must download and install this "add-on"?? IMHO, the developers of the add-ons which use its functions should include it with the installation of their add-on.

ZOS (?) has added a Libraries category at the bottom of the list of addons. It evidently lists the "libraries" which are installed in the respective addon folders in the ...\Elder Scrolls \live\Addons folder. Unfortunately, I haven't been able to find any mention of it in the Patch Notes for Update 17, after which it appeared. What purpose does it serve?
Report comment to moderator  
Reply With Quote
Post A Reply



Category Jump: