ZAM's Minion, currently in open beta, is a new AddOn manager optimized for use with ESO. Install, update & manage AddOns... Learn more!
Download
(26 Kb)
Download
Updated: 07/27/14 10:17 PM
Pictures
File Info
Compatibility:
Craglorn (1.1)
Updated:07/27/14 10:17 PM
Created:02/14/14 09:28 PM
Downloads:8,363
Favorites:81
MD5:
LibAddonMenu  Updated less than 3 days ago!  Popular! (More than 5000 hits)
Version: 2.0 r14
by: Seerah [More]
LibAddonMenu-2.0 is now released!
Your addons will continue to work under LAM-1.0, however that version of the library will no longer be receiving updates, and you will not receive any benefits of LAM-2.0.

** NOTE: If you have already updated your addon's settings panel to LAM2, but are using a version earlier than r6, please update your copy of the lib in the addon. This will avoid duplicate LAM entries in the game's Settings menu. (This bug does not occur in revisions 6+.)**


LibAddonMenu-2.0 is a library to aid addon authors in creating a configuration GUI for their addons which is located in the game's Settings menu. It supports the ability to have all of a user's addon options located in the same panel.

You may see ZAM_Stats for an example of usage.


HOW TO USE:

--Including the library with your addon--
You may either embed the library and LibStub in your addon and load the files from your addon manifest, or have the library installed like any other normal addon.

If your addon embeds the library, you may place this line in your manifest file, just in case the user also has a standalone version installed.
Code:
## OptionalDependsOn: LibAddonMenu-2.0
If you are depending on the library being installed separately and are not embedding it, then you must include this line in your text file.
Code:
## DependsOn: LibAddonMenu-2.0
Either way you choose, LibStub will ensure that only one copy of the library (the newest revision) is loaded into memory.

When embedding the libary, remove the internal LibAddonMenu-2.0 folder from the main library download. I usually place my libraries in a sub-folder called "libs", but you may put them wherever you like in your addon directory. This is how I would then list the files in my manifest. (LAM2's widget controls are broken out into their own files to keep their code clean - this is why there is so many. Good thing you only have to copy-paste this once!)

Code:
libs\LibAddonMenu-2.0\LibAddonMenu-2.0.lua
libs\LibAddonMenu-2.0\controls\panel.lua
libs\LibAddonMenu-2.0\controls\submenu.lua
libs\LibAddonMenu-2.0\controls\button.lua
libs\LibAddonMenu-2.0\controls\checkbox.lua
libs\LibAddonMenu-2.0\controls\colorpicker.lua
libs\LibAddonMenu-2.0\controls\custom.lua
libs\LibAddonMenu-2.0\controls\description.lua
libs\LibAddonMenu-2.0\controls\dropdown.lua
libs\LibAddonMenu-2.0\controls\editbox.lua
libs\LibAddonMenu-2.0\controls\header.lua
libs\LibAddonMenu-2.0\controls\slider.lua
libs\LibAddonMenu-2.0\controls\texture.lua
(Don't forget to also embed LibStub and have it listed to load prior to LibAddonMenu!)


--Getting the library from LibStub (required)--
Lua Code:
  1. local LAM = LibStub:GetLibrary("LibAddonMenu-2.0")
  2. --OR--
  3. local LAM = LibStub("LibAddonMenu-2.0")
  4.      --returns a reference to the library table


Please see the LAM-2.0 page on my portal for guides and docs, as well as a list of differences between LAM-1.0 and LAM-2.0

Details on LAM2 data tables
2.0 r14
- fixed bug where the LAM-RefreshPanel callback was being registered with CALLBACK_MANAGER multiple times
- fixed highlighting of entries in the game Settings menu (Addon Settings now properly highlights and other entries go back to normal)

2.0 r13
- one last bug ran out from anunder the dresser - I smashed it hopefully!

2.0 r12
- fix one bug another shows up...

2.0 r11
- don't overwrite widgets list if table already exists (in case an external lib or addon registers a new widget type)
- headers, descriptions, submenus and custom widgets now have the ability to update their text when the panel and other controls refresh (simply change the name/text in the controlData table)
- custom controls now have the ability to refresh with other controls and your panel - there is a new optional field in the data table called refreshFunc (when the panel refreshes, this function will be called)

2.0 r10
- fixed display of warning icon for dropdown controls
- update LibStub.lua

2.0 r9
- added Russian locale support for RuESO project
- fixed anchoring issue with addon list (addon names are now properly in the scroll frame, so the few of you with tons installed should have no issue any longer)
- added ability to close submenus from the bottom of the submenu (there is a small strip along the bottom of the submenu that is clickable)
- edited each control to better support custom-created UIs via LAM and the parent passed through to the create functions

2.0 r8
- changed border texture around panel and addon list
- expanded maximum size of submenus from 1500 to 2500

2.0 r7
- shortened game menu entry for French and German localizations (so the text doesn't get cut off)
- fixed checkbox label coloring bug (when a checkbox that is set to "off" is re-enabled by another setting)
- fixed multi-line editbox bug (where text didn't display)
- added mousewheel scrolling for multi-line editboxes

2.0 r6
- added "LAM-PanelControlsCreated" callback when you panel has been shown for the first time and your controls have now been created
- fixed duplicate Addon Settings panels when you have a newer version of LAM overwriting an older version
- finished localizing stuff that wasn't localized yet
- added "sort" field to dropdown control

2.0 r5
- fix RefreshPanel function so that all controls now update
- add RefreshPanel call to ForceDefaults function

2.0 r4
- fix for me being an idiot. Sorry guys ><

2.0 r3
- fixed checkboxes making a sound when just refreshing
- fixed error when the lib is loaded standalone, but no addons are registered with it
- fixed error when LAM updates itself to a newer version (won't try to create two of the same frame)

2.0 r2
- LAM-2.0 is now released! See http://www.esoui.com/portal.php?&id=5&pageid=10 for a list of differences between LAM1 and LAM2, as well as a guide for usage and the library's docs

-----------------
1.0 r8
- updated APIVersion to 100004
- changed submenu so scroll bar doesn't overlap contents
- submenu should hopefully no longer occasionally show up behind the options panel

1.0 r7
- the defaults button now properly hides for each panel (Note: the keybind still works, I can't seem to get rid of that, but at least the prompt is hidden now)
- LAM now supports sub menus! See the description page for docs on usage

1.0 r6
- copy/paste fail when changing the name of an arg. Description titles will no longer hide from you.

1.0 r5
- exposed the widgets created via return

1.0 r4
-new widget: Description

1.0 r3
-fixed error with color picker in new patch

1.0 r2
-fixed bug when more than one addon panel is created
Archived Files (13)
File Name
Version
Size
Author
Date
2.0 r13
26kB
Seerah
07/20/14 09:35 PM
2.0 r12
26kB
Seerah
07/20/14 07:55 PM
2.0 r11
26kB
Seerah
07/19/14 02:49 PM
2.0 r10
25kB
Seerah
07/13/14 09:18 PM
2.0 r9
25kB
Seerah
07/05/14 06:55 PM
2.0 r8
25kB
Seerah
06/22/14 09:47 PM
2.0 r7
25kB
Seerah
06/15/14 05:17 PM
2.0 r6
25kB
Seerah
06/13/14 11:28 PM
2.0 r5
25kB
Seerah
06/12/14 10:32 PM
2.0 r4
25kB
Seerah
06/11/14 08:56 PM
2.0 r3
25kB
Seerah
06/11/14 07:49 PM
2.0 r2
24kB
Seerah
06/10/14 10:06 PM
1.0 r8
6kB
Seerah
05/24/14 10:01 PM


Post A Reply Comment Options
Old Yesterday, 03:50 PM  
Seerah
Fishing Trainer
 
Seerah's Avatar
ESOUI Super Moderator
AddOn Author - Click to view AddOns

Forum posts: 611
File comments: 106
Uploads: 1
Originally Posted by Atropos
Turns out this is the link I need: http://www.esoui.com/portal.php?&id=5&pageid=15
Yep, that's linked at the bottom of the main docs page.
Seerah is offline Report comment to moderator  
Reply With Quote
Old Yesterday, 01:04 PM  
Atropos
 
Atropos's Avatar
AddOn Author - Click to view AddOns

Forum posts: 0
File comments: 55
Uploads: 1
Hi Seerah,

Thanks for the response, glad to know this is easier than I initially thought. I looked over the docs on your portal but it wasn't obvious to me at the time that this was possible.

Turns out this is the link I need: http://www.esoui.com/portal.php?&id=5&pageid=15

I'll take another crack at this and try to get FTC running on AddonMenu2.0 for my next update. Thanks for your support.

Atropos
__________________
Founder and Creator of Tamriel Foundry
Guildmaster of Entropy Rising
Atropos is offline Report comment to moderator  
Reply With Quote
Old 07/27/14, 09:15 PM  
Seerah
Fishing Trainer
 
Seerah's Avatar
ESOUI Super Moderator
AddOn Author - Click to view AddOns

Forum posts: 611
File comments: 106
Uploads: 1
@Atropos
What you want to do is 100% possible with LAM-2.0. Especially since you reload the UI when enabling/disabling modules in FTC - this becomes even simpler. There are several ways this can be accomplished. You can set the controls for that module to be disabled (and greyed out) if the module is not active (this is actually the easiest way, and then you don't even need to reload the UI), or you can do the below if you don't want the settings to show up at all (and still reload the UI when modules are turned on/off).

Lua Code:
  1. local optionsTable = {
  2.      [1] = {
  3.           type = "checkbox",
  4.           name = "Frames Module",
  5.           etc...
  6.      },
  7.      [2] = {
  8.           type = "checkbox",
  9.           name = "Combat Text Module",
  10.           etc...
  11.      },
  12. }
  13. local ufModuleOptions = {
  14.      type = "submenu",
  15.      name = "Unit Frames",
  16.      controls = {
  17.           [1] = {option 1 table data stuff},
  18.           [2] = {option 2 table data stuff},
  19.           [3] = {ect...},
  20.      }
  21. }
  22. local textModuleOptions = {
  23.      type = "submenu",
  24.      name = "Combat Text",
  25.      controls = {
  26.           [1] = {option 1 table data stuff},
  27.           [2] = {option 2 table data stuff},
  28.           [3] = {ect...},
  29.      }
  30. }
  31. local function SetUpOptions()
  32.      if ufModuleEnabled then
  33.           table.insert(optionsTable, ufModuleOptions)
  34.      end
  35.      if textModuleEnabled then
  36.           table.insert(optionsTable, textModuleOptions)
  37.      end
  38.  
  39.      LAM2:RegisterOptionControls("FoundryTacticalCombat", optionsTable)
  40. end
Last edited by Seerah : 07/27/14 at 09:16 PM.
Seerah is offline Report comment to moderator  
Reply With Quote
Old 07/27/14, 10:07 AM  
Atropos
 
Atropos's Avatar
AddOn Author - Click to view AddOns

Forum posts: 0
File comments: 55
Uploads: 1
Hello Seerah,

Thank you for your hard work on providing this (and other) libraries, I'm certain they make the lives of addon authors much easier.

I put in some time this weekend on finally bringing my addon, Foundry Tactical Combat, up to speed with the 2.0 version of LibAddonMenu. Unfortunately, I abandoned the work halfway through and have decided to stick with the 1.0 version of the lib (at least for now). I thought I would give a bit of feedback as to why.

My addon is modular, there are 5 different "core components", each of which has the option of being toggled outright (enable/disable). For components that are enabled, each component has several options for its configuration. In the 1.0 version of the lib, I was able to generate my addon menu controls using conditional logic, if the component is enabled, display the sub-options for that component, if it's not enabled, display nothing (or something else).

In the 2.0 version of the lib, it seems like I have to declare all my menu controls at once, and pass the construction of them through an arguments table. While this is probably easier for most users of the lib, it's definitely less flexible than the 1.0 version.

Perhaps there is already a way to do this in a clever way with the 2.0 lib, and I'm missing it. If so please let me know. Otherwise, it would be nice for a future version if you would consider a way to allow menu controls to be configured conditionally. I hope this feedback is clear. Keep up the good work!
__________________
Founder and Creator of Tamriel Foundry
Guildmaster of Entropy Rising
Atropos is offline Report comment to moderator  
Reply With Quote
Old 07/25/14, 09:53 PM  
Seerah
Fishing Trainer
 
Seerah's Avatar
ESOUI Super Moderator
AddOn Author - Click to view AddOns

Forum posts: 611
File comments: 106
Uploads: 1
I'm... sorry? You seem as if you're angry with me for some reason.

It's a table. You can name it whatever you want, so long as you pass the correct variable reference to the function. In fact, you don't even *need* to assign your table to a variable - you can make an anonymous table right within the function call, so long as you don't need to access it later. (Though this is bad for readability. )

In fact, I believe the reason why I named it differently in exampleOptions.lua (I'm pretty sure it was always called optionsTable in that file - I don't remember changing it at least) was to show that the reference *can* be different from what's in the docs. It's just an example, though, not something that has to be followed literally. But I'm just a teacher, so what do I know? hehe

/edit: oh, and you're welcome
Last edited by Seerah : 07/25/14 at 09:54 PM.
Seerah is offline Report comment to moderator  
Reply With Quote
Old 07/25/14, 12:49 AM  
Deome
 
Deome's Avatar
AddOn Author - Click to view AddOns

Forum posts: 8
File comments: 28
Uploads: 2
Unhappy Not quite a bug...

Just realized I've been using pre r6 version of LibAddonMenu-2.0 in DataDaedra. Felt like an idiot and updated it, and double-checked the instructions on the doc on your portal page, copied and pasted the new LAM2:Registeretc. lines.

And poof, all the settings disappeared, but only in my addon's settings (I have many addons that use LibAddonMenu-2.0; this makes me happy. Everything in one place).

It's not quite a bug--error occurred between chair and keyboard--but I have a few clumps of hair and a half hour missing to show for the fact that you've renamed "optionsTable" (previous LAM2 versions, exampleoptions.lua) to "optionsData". And that little change was oh so easy to miss. Now that I know what the issue is, of course, I'll name that table whatever I please, but you may want to update either the portal doc or the exampleoptions.lua; I'm pretty sure I'm not the only one who does most of their coding late at night, long after useful consciousness has ended.

Otherwise quite pleased, you took all the work out of something I really wasn't looking forward to writing on my own (a GUI settings menu); thank you
__________________
Deome, GM of Abecean Mercantile
"I am alive because that one is dead. I exist because I have the will to do so."
Deome is offline Report comment to moderator  
Reply With Quote
Old 07/24/14, 09:29 PM  
Seerah
Fishing Trainer
 
Seerah's Avatar
ESOUI Super Moderator
AddOn Author - Click to view AddOns

Forum posts: 611
File comments: 106
Uploads: 1
Yes, but that isn't intuitive for the user (to not have an apply button). If all of their other addons update in real-time and yours does not, and they don't see a way that they have to apply their settings, they'll think something's broken.

If it is indeed causing a delay, then you'll want to either
  1. optimize your function call
  2. only change the saved variable in the setFunc function and provide an "Apply" button
  3. switch from using a slider to an editbox control
Seerah is offline Report comment to moderator  
Reply With Quote
Old 07/24/14, 05:50 PM  
dvstans

Forum posts: 0
File comments: 3
Uploads: 0
Re: Re: Re: Re: How to handle setting updates on close

Originally Posted by Seerah
Originally Posted by dvstans
Yep, I'd prefer to apply settings once without resorting to an "apply" button. I was guessing that there would be a way to hook into a close/hide event for the settings panel to trigger the re-initialization of the module. Applying in real-time works, but it seems that it may lead to unresponsiveness with, say, slider controls (I'm assuming your lib calls the setval function as it's moving?)
Yes, the setFunc function is called as the slider updates. I'm not certain what you expect to become unresponsive or are trying to avoid though.
Sorry, I'm not being very clear... In my current mod, this isn't a big deal since the (re)initialization process my module has to perform when any settings are changed is very fast. What I was trying to get at was: if it is somewhat computationally expensive to initialize a module from settings, then an update-on-setting-change philosophy could lead to poor performance of the entire UI due to the module's initialization functions being called in rapid succession (i.e. as the user drags a slider).

So, in this case a delayed module init might be a better choice. A good time to perform the (re)init in this case is when the settings panel is closed or hidden (or you could require the user to press a button, but the automagic way would be nicer!).
dvstans is offline Report comment to moderator  
Reply With Quote
Old 07/24/14, 03:00 PM  
Seerah
Fishing Trainer
 
Seerah's Avatar
ESOUI Super Moderator
AddOn Author - Click to view AddOns

Forum posts: 611
File comments: 106
Uploads: 1
Re: Re: Re: How to handle setting updates on close

Originally Posted by dvstans
Yep, I'd prefer to apply settings once without resorting to an "apply" button. I was guessing that there would be a way to hook into a close/hide event for the settings panel to trigger the re-initialization of the module. Applying in real-time works, but it seems that it may lead to unresponsiveness with, say, slider controls (I'm assuming your lib calls the setval function as it's moving?)
Yes, the setFunc function is called as the slider updates. I'm not certain what you expect to become unresponsive or are trying to avoid though.
Seerah is offline Report comment to moderator  
Reply With Quote
Old 07/23/14, 09:01 PM  
dvstans

Forum posts: 0
File comments: 3
Uploads: 0
Re: Re: How to handle setting updates on close

Originally Posted by Seerah
Originally Posted by dvstans
re-inits
who-what-now?

Are you talking about when your settings actually take place and the set function is called? If you want all of the settings to be applied at once then you would create an "Apply" button for your config. Otherwise, most everyone has their settings take effect in real-time.
Yep, I'd prefer to apply settings once without resorting to an "apply" button. I was guessing that there would be a way to hook into a close/hide event for the settings panel to trigger the re-initialization of the module. Applying in real-time works, but it seems that it may lead to unresponsiveness with, say, slider controls (I'm assuming your lib calls the setval function as it's moving?)
dvstans is offline Report comment to moderator  
Reply With Quote
Old 07/23/14, 07:32 PM  
Seerah
Fishing Trainer
 
Seerah's Avatar
ESOUI Super Moderator
AddOn Author - Click to view AddOns

Forum posts: 611
File comments: 106
Uploads: 1
Re: How to handle setting updates on close

Originally Posted by dvstans
re-inits
who-what-now?

Are you talking about when your settings actually take place and the set function is called? If you want all of the settings to be applied at once then you would create an "Apply" button for your config. Otherwise, most everyone has their settings take effect in real-time.
Seerah is offline Report comment to moderator  
Reply With Quote
Old 07/22/14, 09:51 PM  
dvstans

Forum posts: 0
File comments: 3
Uploads: 0
Question How to handle setting updates on close

Hi, very new to ESOUI and Lua, but have managed to get my add-on working with LibAddOnMenu2 (cool stuff!). I'm wondering if there's an easy way to handle re-inits once - only when the settings page is closed. I have it working now where updates are triggered each time an individual setting is changed, but this is very tedious to code, and all I need is a one-time re-init. I could also add an "apply" button, but that's far from ideal.

Thanks!
dvstans is offline Report comment to moderator  
Reply With Quote
Old 07/19/14, 02:50 PM  
Seerah
Fishing Trainer
 
Seerah's Avatar
ESOUI Super Moderator
AddOn Author - Click to view AddOns

Forum posts: 611
File comments: 106
Uploads: 1
Originally Posted by merlight
Originally Posted by Seerah
You can already add anything you want to the controlData table. It's just a table. But I can add a table to each panel that contains all of the children. This might be useful since there is no real control:GetChildren() method.
Now that I think of it, it would probably be best to just have controlsToRefresh filled unconditionally. So that you don't end up with two tables containing the same. Not sure whether name-keyed table of children would be useful. I'll probably be better off with for i, ctl in ipairs(ctls) do ctl.data.onShow(ctl) end.
Current changelog
2.0 r11
- don't overwrite widgets list if table already exists (in case an external lib or addon registers a new widget type)
- headers, descriptions, submenus and custom widgets now have the ability to update their text when the panel and other controls refresh (simply change the name/text in the controlData table)
- custom controls now have the ability to refresh with other controls and your panel - there is a new optional field in the data table called refreshFunc (when the panel refreshes, this function will be called)
Seerah is offline Report comment to moderator  
Reply With Quote
Old 07/18/14, 06:55 AM  
merlight

Forum posts: 49
File comments: 9
Uploads: 0
Originally Posted by Seerah
You can already add anything you want to the controlData table. It's just a table. But I can add a table to each panel that contains all of the children. This might be useful since there is no real control:GetChildren() method.
Now that I think of it, it would probably be best to just have controlsToRefresh filled unconditionally. So that you don't end up with two tables containing the same. Not sure whether name-keyed table of children would be useful. I'll probably be better off with for i, ctl in ipairs(ctls) do ctl.data.onShow(ctl) end.
merlight is offline Report comment to moderator  
Reply With Quote
Old 07/17/14, 09:05 PM  
Seerah
Fishing Trainer
 
Seerah's Avatar
ESOUI Super Moderator
AddOn Author - Click to view AddOns

Forum posts: 611
File comments: 106
Uploads: 1
Originally Posted by merlight
  1. optionData.reference - I named the checkboxes and hooked after panel "OnShow", so everytime the panel is shown, I update labels. Simple, I only hate there're globals just because of this. Could you add "panelReference/localReference/controlKey" whatever you name it to optionData, and a table to the panel so that the controls are accessible as panel.controls[optionData.controlKey]?
You can already add anything you want to the controlData table. It's just a table. But I can add a table to each panel that contains all of the children. This might be useful since there is no real control:GetChildren() method.
Seerah is offline Report comment to moderator  
Reply With Quote
Post A Reply



Category Jump:

Support AddOn Development!

You have just downloaded by the author . If you like this AddOn why not consider supporting the author? This author has set up a donation account. Donations ensure that authors can continue to develop useful tools for everyone.