Quantcast
Download
(4 Kb)
Download
Updated: 04/29/15 12:17 PM
Pictures
File Info
Compatibility:
Update 6 (1.6.5)
Updated:04/29/15 12:17 PM
Created:03/23/15 02:07 PM
Monthly downloads:93
Total downloads:1,341
Favorites:7
MD5:
LibMainMenu
Version: 5
by: Ayantir [More]
LibMainMenu is intended to help you to create Main Menus (Scenes with multiple tabs like in Journal or Quest).

It's Mainly 2 functions added to help developpers to add a Menu (a category)
Lua Code:
  1. menuIndex = LMM:MainMenuAddCategory(arrayOfCategoryData)
  2. LMM:MainMenuAddSceneGroup(menuIndex, GroupSceneString, iconData)

And 2 for calling the Menus themselves :
Lua Code:
  1. -- Toggle
  2. LMM:ToggleCategory(menuIndex)
  3. -- Specific scene
  4. LMM:Update(menuIndex, "MyAddonAnotherScene")




The Library is handled by LibStub, so you should first define in your metafile (.txt)by addind LibMainMenu to your includes like this :
libs/LibMainMenu/LibMainMenu.lua

And enable it in your code like this :
Lua Code:
  1. local LMM = LibStub("LibMainMenu")





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")


For a more deeply debug, LibMainmenu is available trought global LIBMAINMENU.
functionalities of LibMainMenu are similar to ESOUI MAIN_MENU
v5
======
- Fixed duplicate controls at startup, sorry.

v4
======
- Completly disabled the handler which emulated Main Menu top bar and which could trigger randomly when altabbing. This function was unused, so 0 changes.

v3
======
- Little fix, caused by bad a bad copy/paste which triggered error sometimes when alt-tabing.

v2
======
- No longer rewrites MAIN_MENU but emulates it. As consequence, Menus added by LibMainMenu won't be anymore added to Main menu at top of the screen. Also call to LibMainMenu has been a little bit modified.

v1
======
Initial release
Optional Files (0)


Archived Files (4)
File Name
Version
Size
Author
Date
4
4kB
Ayantir
04/16/15 09:35 PM
3
4kB
Ayantir
04/03/15 12:43 PM
2
4kB
Ayantir
03/30/15 11:04 AM
1
3kB
Ayantir
03/23/15 02:07 PM


Post A Reply Comment Options
Unread 10/27/16, 05:34 PM  
Mitsarugi
 
Mitsarugi's Avatar
AddOn Author - Click to view AddOns

Forum posts: 23
File comments: 236
Uploads: 12
could you make a demo file for people to build on? please
__________________
@xMitsarugix - (EU server)
Report comment to moderator  
Reply With Quote
Unread 03/09/16, 03:18 PM  
JohnnyKing94
 
JohnnyKing94's Avatar

Forum posts: 45
File comments: 6
Uploads: 0
I'd like to have this library reborn... i alread saw a LibMainMenu 2.0 but it doesn't have all the functions already present here
Report comment to moderator  
Reply With Quote
Unread 05/15/15, 03:46 AM  
JohnnyKing94
 
JohnnyKing94's Avatar

Forum posts: 45
File comments: 6
Uploads: 0
Originally Posted by votan
Originally Posted by JohnnyKing94
I tried to use this library and the scene works, all except the chance to add the button on the menu... then i saw your code and this part was commented, why?
See QuadroTony's comment. While using the lib in SuperStar Ayantir trapped into what I describe here.
The crone market does not like custom code in MAIN_MENU.
First, are there no alternatives to have a button in the MenuCategoryBar???
Second, how to correctly scale the scenes?? When i set a custom scale in the videosettings, all the scene get fu*ed up, are there any ways to fix it?
Report comment to moderator  
Reply With Quote
Unread 05/15/15, 02:23 AM  
votan
 
votan's Avatar
AddOn Author - Click to view AddOns

Forum posts: 418
File comments: 780
Uploads: 21
Originally Posted by JohnnyKing94
I tried to use this library and the scene works, all except the chance to add the button on the menu... then i saw your code and this part was commented, why?
See QuadroTony's comment. While using the lib in SuperStar Ayantir trapped into what I describe here.
The crone market does not like custom code in MAIN_MENU.
__________________
@votan73 (EU - megaserver)
Last edited by votan : 05/15/15 at 02:25 AM.
Report comment to moderator  
Reply With Quote
Unread 05/15/15, 02:07 AM  
JohnnyKing94
 
JohnnyKing94's Avatar

Forum posts: 45
File comments: 6
Uploads: 0
I tried to use this library and the scene works, all except the chance to add the button on the menu... then i saw your code and this part was commented, why?
Report comment to moderator  
Reply With Quote
Unread 03/30/15, 11:05 AM  
Ayantir
 
Ayantir's Avatar
AddOn Author - Click to view AddOns

Forum posts: 978
File comments: 1527
Uploads: 31
LMM has been updated and don't interfere anymore in MAIN_MENU, but just emulates it.
I've tested with 1 addon and another fake addon, all is fine now
__________________
Obsessive Compulsive Coder

My little french Guild: Cercle de l'Eveil
Report comment to moderator  
Reply With Quote
Unread 03/29/15, 02:27 PM  
QuadroTony
Banned
 
QuadroTony's Avatar
AddOn Author - Click to view AddOns

Forum posts: 828
File comments: 3956
Uploads: 3
Originally Posted by Ayantir
Just a Word to say that after a long moment to study if I could do this, I think I can't anymore use this library as it's actually writen because of some problems this library introduce.

So.. this library is loaded by addon manager. and so on, it's an insecure code who handles scenes. 0 problemes for all scenes in whole game (there are 134 scenes in game). Except 1, the new market.

It's a "remote scene" and one of it's main functions (ChangeRemoteSceneVisibility) is protected.
It use the fragment STOP_MOVEMENT_FRAGMENT which calls StopAllMovement() which is also protected.

If I could bypass the fragment by deleting it in some dirty way, I can clearly not touch to ChangeRemoteSceneVisibility which is clearly here to protect the market itself from addon modifications

Modifying MAIN_MENU in other way in order maybe to add a nice menu is not really possible due to the local var CATEGORY_LAYOUT_INFO which handle everything and this library was bypassing by calling the global subarray dumped by this var, so I'll rewrite everything and "emulate" menus as they were real ones without using MAIN_MENU itself.

bit sad
im not really a developer, but mby this will help you

http://www.esoui.com/forums/showthread.php?t=4469
__________________
Report comment to moderator  
Reply With Quote
Unread 03/26/15, 06:42 PM  
Ayantir
 
Ayantir's Avatar
AddOn Author - Click to view AddOns

Forum posts: 978
File comments: 1527
Uploads: 31
Just a Word to say that after a long moment to study if I could do this, I think I can't anymore use this library as it's actually writen because of some problems this library introduce.

So.. this library is loaded by addon manager. and so on, it's an insecure code who handles scenes. 0 problemes for all scenes in whole game (there are 134 scenes in game). Except 1, the new market.

It's a "remote scene" and one of it's main functions (ChangeRemoteSceneVisibility) is protected.
It use the fragment STOP_MOVEMENT_FRAGMENT which calls StopAllMovement() which is also protected.

If I could bypass the fragment by deleting it in some dirty way, I can clearly not touch to ChangeRemoteSceneVisibility which is clearly here to protect the market itself from addon modifications

Modifying MAIN_MENU in other way in order maybe to add a nice menu is not really possible due to the local var CATEGORY_LAYOUT_INFO which handle everything and this library was bypassing by calling the global subarray dumped by this var, so I'll rewrite everything and "emulate" menus as they were real ones without using MAIN_MENU itself.

bit sad
__________________
Obsessive Compulsive Coder

My little french Guild: Cercle de l'Eveil
Report comment to moderator  
Reply With Quote
Unread 03/23/15, 06:15 PM  
Randactyl
 
Randactyl's Avatar
AddOn Author - Click to view AddOns

Forum posts: 253
File comments: 439
Uploads: 17
Awesome. This should make a few things I'm working on more manageable
__________________
Randactyl | NA Megaserver | Blood for the Pact! | Sun's Death, Chrysamere Pact

My Addons
Beta Addons
Check out my GitHub repos to follow my latest changes and see some addons before they are released.
Report comment to moderator  
Reply With Quote
Unread 03/23/15, 02:50 PM  
dominoid
AddOn Author - Click to view AddOns

Forum posts: 34
File comments: 269
Uploads: 2
This looks spiffy. Thanks.
Last edited by dominoid : 03/23/15 at 02:50 PM.
Report comment to moderator  
Reply With Quote
Post A Reply



Category Jump: