ZAM's Minion, currently in open beta, is a new AddOn manager optimized for use with ESO. Install, update & manage AddOns... Learn more!
Download
(36 Kb)
Download
Updated: 06/14/15 01:12 PM
Pictures
File Info
Compatibility:
Update 6 (1.6.5)
Updated:06/14/15 01:12 PM
Created:02/14/14 10:28 PM
Downloads:23,641
Favorites:152
MD5:
1.6.5
LibAddonMenu  Popular! (More than 5000 hits)
Version: 2.0 r18
by: sirinsidiator, Seerah
Since I (sirinsidiator) have taken over development of LAM-2.0 I decided it will be in the best interest of everyone to make future development a group effort.
With the consent of Seerah I have put LAM-2.0 under The Artistic License 2.0 and created a github project in order to make collaborations possible.
I also want to thank everyone who participated in planning and realizing upcoming changes, especially votan, merlight and Garkin.

If you came here because a message in chat told you so,
then you are using an outdated addon that relies on an older version of LAM-2.0 which might not be compatible with ESO update 6.
But no need to panic. There are a few things you can do in order to get it to work again:
  1. Update your addons. Maybe the author already fixed the problem.
  2. Try to find out which addon uses the outdated version and ask for help in the comment section.
  3. Ask for help in our comment section.
  4. Replace LibAddonMenu-2.0 in all your addons with the newest version.

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 are using a version of LAM-2.0 earlier than r17, please update your copy of the lib in the addon. This will avoid problems with loading future versions of LAM.**


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
libs\LibAddonMenu-2.0\controls\iconpicker.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 wiki on github 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 r18
- major overhaul of the addon menu style (thanks votan & merlight)
- NOTE: the menu is now a bit wider than before, if you created custom elements you might need to update them accordingly
- added search box to addon list (thanks votan & merlight)
- new icon picker widget
- removed micro freeze when opening a menu with many options for the first time
- changed tooltip property to accept functions that return a string (thanks Ayantir)
- changed the label on the defaults button and menu to avoid a grammar mistake in the french localization (thanks Ayantir)
- updated LibStub to r3 (support for '.' in minor version string, e.g. "17.5")

2.0 r17
- updated for changes in 100011
- fixed OpenToPanel function
- fixed possible error with combobox names
- half width control no longer have a fixed height and instead scale automatically now
- changed controls to no longer use top level windows
- fixed problems with the loading order and added warning if an old version gets initialized first
A big thank you to everyone who helped making these changes, especially votan, merlight and Garkin!

2.0 r16
- updated for changes in 100010
- thanks to Garkin for alerting me of changes needed and for testing on the test server
- Spanish support added, translation provided by Luisen75 for their Spanish project

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 (16)
File Name
Version
Size
Author
Date
2.0 r17
30kB
sirinsidiator
02/22/15 11:09 AM
2.0 r16
27kB
sirinsidiator
11/02/14 02:03 PM
2.0 r14
26kB
Seerah
07/27/14 10:17 PM
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
Unread 07/05/15, 04:54 AM  
sirinsidiator
 
sirinsidiator's Avatar
AddOn Author - Click to view AddOns

Forum posts: 175
File comments: 203
Uploads: 13
Hi Atropos,
Thanks for your request. I created a ticket over at github.

I like the idea of adding callbacks for opening and closing the panel. Certainly makes things a bit easier for some addons.
I'll have to check what the implications are, but it should be easy enough and possible to add it in the next release.
sirinsidiator is offline Report comment to moderator  
Reply With Quote
Unread 07/04/15, 03:47 PM  
merlight
AddOn Author - Click to view AddOns

Forum posts: 376
File comments: 94
Uploads: 8
Originally Posted by Atropos
Hey merlight, thanks for the suggestion. I think I follow you, but I'm not sure. Could I get a more complete minimum working example?

I forgot about the "OnEffectivelyShown" hook... I was trying to use "OnShow" but that is reserved for LAM itself so it breaks the menu.
OnShow is not what you want to handle anyway, because it only triggers when the panel:SetHidden() is called, and this doesn't happen when the LAM settings container is hidden/shown without switching panels.

Lua Code:
  1. local settingsPanel = LAM2:RegisterAddonPanel( "FTC_Menu" , FTC.Menu.panel )
  2. ZO_PreHookHandler(settingsPanel, "OnEffectivelyShown",
  3.     function(control) df("%s shown", control:GetName()) end)
  4. ZO_PreHookHandler(settingsPanel, "OnEffectivelyHidden",
  5.     function(control) df("%s hidden", control:GetName()) end)

Note: right now you could just settingsPanel:SetHandler(...), because LAM itself doesn't handle these. But if it needs them at some point in the future, ZO_PreHookHandler will chain them to run after yours.
Last edited by merlight : 07/04/15 at 04:20 PM.
merlight is offline Report comment to moderator  
Reply With Quote
Unread 07/04/15, 03:25 PM  
Atropos
 
Atropos's Avatar
AddOn Author - Click to view AddOns

Forum posts: 15
File comments: 132
Uploads: 1
Originally Posted by merlight
Originally Posted by Atropos
Perhaps there is already an easy way to achieve what I want to do, but it is not documented and the solution I have developed is pretty clumsy. Please let me know if you have any questions or feedback.
You can simply set a handler (or ZO_PreHookHandler to be future-proof) on your panel control for OnEffectivelyShown / OnEffectivelyHidden.
Hey merlight, thanks for the suggestion. I think I follow you. I forgot about the "OnEffectivelyShown" hook... I was trying to use "OnShow" but that is reserved for LAM itself so it breaks the menu.

I think I can make this work. I still think some documentation added to the LAM wiki pages to make it a little more transparent what the best practices are for doing things while your own addon's menu is displayed would be very valuable for other authors.
__________________
Founder and Creator of Tamriel Foundry
Guildmaster of Entropy Rising
Last edited by Atropos : 07/04/15 at 03:42 PM.
Atropos is offline Report comment to moderator  
Reply With Quote
Unread 07/04/15, 02:51 PM  
merlight
AddOn Author - Click to view AddOns

Forum posts: 376
File comments: 94
Uploads: 8
Originally Posted by Atropos
Perhaps there is already an easy way to achieve what I want to do, but it is not documented and the solution I have developed is pretty clumsy. Please let me know if you have any questions or feedback.
You can simply set a handler (or ZO_PreHookHandler to be future-proof) on your panel control for OnEffectivelyShown / OnEffectivelyHidden.
merlight is offline Report comment to moderator  
Reply With Quote
Unread 07/04/15, 02:10 PM  
Atropos
 
Atropos's Avatar
AddOn Author - Click to view AddOns

Forum posts: 15
File comments: 132
Uploads: 1
Hi Sirinsidiator,

Thanks for your continued work on LAM. I really like the new aesthetic look and some of the new control types seem very useful.

That being said, I have some feedback as a user of your library that I hope you can assist with incorporating into a near future release. Here's a short synopsis:

Objective:
As an addon author, I would like to take advantage of a simple set of callbacks for when my addon settings panel is open, and when it has been closed. I would like to use these callbacks to easily show certain addon elements on screen next to the settings panel so that my users can customize the look of their addon in real-time.

Current Issues:

1) The existing callback "LAM-RefreshPanel" will fire the first time the panel is opened, and when you switch back-and-forth with other panels. It WILL NOT fire when you have already set up the panel, closed the settings, and re-opened the settings panel. This makes it difficult to determine when the settings panel is open.

2) There is no callback for when the panel is closed directly. I can use "LAM-RefreshPanel" to know when the user switches to a different addon's settings panel, but if the user closes the settings menu directly there is no callback.

3) LAM-RefreshPanel fires before the settings menu is actually open, so checking LAM.currentAddonPanel or other conditional checks may be inaccurate if run during the callback.

Proposed Solution

I would like to see two new callbacks added to the library that are very simple for authors to use and understand. It seems like RefreshPanel has become more of a catchall callback for use internally to the workings of the library itself. I would suggest the following:
  • LAM-PanelOpened - passes (panel) and fires whenever a settings panel is first rendered. This includes opening the settings menu from scratch or switching from one panel to another. Authors can easily check within their callback whether panel equals their own panel before proceeding.
  • LAM-PanelClosed - fires whenever the settings menu is deactivated, either by returning to the game layer or by going to some other portion of the game settings.

Perhaps there is already an easy way to achieve what I want to do, but it is not documented and the solution I have developed is pretty clumsy. Please let me know if you have any questions or feedback.
__________________
Founder and Creator of Tamriel Foundry
Guildmaster of Entropy Rising
Atropos is offline Report comment to moderator  
Reply With Quote
Unread 06/23/15, 03:01 AM  
Phinix
 
Phinix's Avatar
AddOn Author - Click to view AddOns

Forum posts: 69
File comments: 303
Uploads: 8
Originally Posted by sirinsidiator
Originally Posted by Phinix
I discovered a bug in the new version:

If you have a checkbox type with a disabled check that evaluates true (so it should be disabled) but the checkbox' option value was previously set to on (or true) before the setting for it's disabled option was changed, the text for the option title does not get properly greyed out.
I just tried it with the resurrection options in sidWarTools and don't see this behavior. Which addon did you try it with?

EDIT: Just saw your other comment from last month. Did you solve that problem?
I will update the addon list sometime soon. It's a lot of work even though I wrote a tool that already makes it a lot easier. Maybe some day I'll have enough motivation to improve it so it can automatically update the list.
Hey, sirinsidiator. Thanks for taking time to respond. Your resources are legendary and it is good to see them being kept up.

The issue with disabled items not going grey seems to have "magically" resolved itself. The only thing I can think is that I was running into another problem that was breaking the reading in of the table and that was the symptom I noticed of a larger issue.

This leads me to a repeatable bug:

On the wiki page the iconpicker (AWESOME by the way) says that the "choicesTooltips" is optional, however it is not in fact optional and will give a "nil value" error if you attempt to load the panel without specifying this field.

I haven't played with the color issue in a while but I'm pretty sure it was a syntax issue on my end as I have seen other addons make it work. I'll have to look at how they did it for examples.
Last edited by Phinix : 06/23/15 at 03:03 AM.
Phinix is offline Report comment to moderator  
Reply With Quote
Unread 06/21/15, 03:23 AM  
sirinsidiator
 
sirinsidiator's Avatar
AddOn Author - Click to view AddOns

Forum posts: 175
File comments: 203
Uploads: 13
Originally Posted by Phinix
I discovered a bug in the new version:

If you have a checkbox type with a disabled check that evaluates true (so it should be disabled) but the checkbox' option value was previously set to on (or true) before the setting for it's disabled option was changed, the text for the option title does not get properly greyed out.
I just tried it with the resurrection options in sidWarTools and don't see this behavior. Which addon did you try it with?

EDIT: Just saw your other comment from last month. Did you solve that problem?
I will update the addon list sometime soon. It's a lot of work even though I wrote a tool that already makes it a lot easier. Maybe some day I'll have enough motivation to improve it so it can automatically update the list.
Last edited by sirinsidiator : 06/21/15 at 03:28 AM.
sirinsidiator is offline Report comment to moderator  
Reply With Quote
Unread 06/19/15, 11:49 AM  
Phinix
 
Phinix's Avatar
AddOn Author - Click to view AddOns

Forum posts: 69
File comments: 303
Uploads: 8
I discovered a bug in the new version:

If you have a checkbox type with a disabled check that evaluates true (so it should be disabled) but the checkbox' option value was previously set to on (or true) before the setting for it's disabled option was changed, the text for the option title does not get properly greyed out.
Last edited by Phinix : 06/19/15 at 11:50 AM.
Phinix is offline Report comment to moderator  
Reply With Quote
Unread 05/14/15, 11:57 AM  
Phinix
 
Phinix's Avatar
AddOn Author - Click to view AddOns

Forum posts: 69
File comments: 303
Uploads: 8
Excellent resource, many thanks!

One quick question. Is it possible to update the display based on set functions? For example, I store the color of a menu item text in a global variable. In my set function for color picker I change this global variable to the new r,g,b,a table, but the text of the menu item that uses it doesn't update unless I do a /reloadui.

Also, ESO Master Recipe List didn't make it to the list of addons using LibAddonMenu-2.0.
Phinix is offline Report comment to moderator  
Reply With Quote
Unread 05/10/15, 07:27 PM  
Ayantir
 
Ayantir's Avatar
AddOn Author - Click to view AddOns

Forum posts: 266
File comments: 392
Uploads: 16
Originally Posted by sirinsidiator
Originally Posted by Ayantir
little request, allow us to execute code when reverting to default.
https://github.com/sirinsidiator/ESO...Menu/issues/23

Originally Posted by Ayantir
Same request for tooltips.
https://github.com/sirinsidiator/ESO...Menu/issues/24

There is still a bit of RL work that eats up all of my daily coding time, but once that is over I'll look into those.
Hello here,

I've just uploaded a modified r-18 for my little feature
Include the metafile, the 18 rev, all modifications done in controls files and updated control revision too. tested, seems working as a charm.

(removed)

It is basically a :


Lua Code:
  1. if checkboxData.tooltip then
  2.     if type(checkboxData.tooltip) == "string" then
  3.         control.data.tooltipText = checkboxData.tooltip
  4.     elseif type(checkboxData.tooltip) == "function" then
  5.         control.data.tooltipText = tostring(checkboxData.tooltip())
  6.     end
  7. end
__________________
Currently working on my Addons

My Addons: pChat, pNames, MultiCraft, Roomba, CraftCompare, Guild Notificator, (...)
My little french Guild: Cercle de l'Eveil
Last edited by Ayantir : 05/14/15 at 12:01 PM.
Ayantir is offline Report comment to moderator  
Reply With Quote
Unread 04/26/15, 04:27 AM  
sirinsidiator
 
sirinsidiator's Avatar
AddOn Author - Click to view AddOns

Forum posts: 175
File comments: 203
Uploads: 13
Originally Posted by Ayantir
little request, allow us to execute code when reverting to default.
https://github.com/sirinsidiator/ESO...Menu/issues/23

Originally Posted by Ayantir
Same request for tooltips.
https://github.com/sirinsidiator/ESO...Menu/issues/24

There is still a bit of RL work that eats up all of my daily coding time, but once that is over I'll look into those.
sirinsidiator is offline Report comment to moderator  
Reply With Quote
Unread 04/26/15, 04:10 AM  
sirinsidiator
 
sirinsidiator's Avatar
AddOn Author - Click to view AddOns

Forum posts: 175
File comments: 203
Uploads: 13
Originally Posted by SnowmanDK
Is there a problem with textures?

The code below just makes a gap in the menu. No graphics are shown.
Not even the tooltip is shown.
All other controls works fine.
Lua Code:
  1. POIsubmenuControls:insert({ -- divider
  2.     type = "texture",
  3.     width = "full",
  4.     image = "Destinations/misc/divider.dds",
  5.     imageWidth = 510,
  6.     imageHeight = 9,
  7.     tooltip = "test",
  8. })
I have added "Libs/LibAddonMenu-2.0/controls/texture.lua" to my config.
I assume image path is based on Addons as root folder.
I also assume that the image format is the same as for pins.
What am I missing?
The options look fine.
I made the experience that image files need to have a width and height with a power of 2. Try to resize the image to 512x16.
If that does not help, you can also try to close the game and delete the ShaderCache.cooked file. That also seems to help with texture problems quite often.
sirinsidiator is offline Report comment to moderator  
Reply With Quote
Unread 04/25/15, 03:11 PM  
SnowmanDK
 
SnowmanDK's Avatar
AddOn Author - Click to view AddOns

Forum posts: 106
File comments: 698
Uploads: 8
Is there a problem with textures?

The code below just makes a gap in the menu. No graphics are shown.
Not even the tooltip is shown.
All other controls works fine.
Lua Code:
  1. POIsubmenuControls:insert({ -- divider
  2.     type = "texture",
  3.     width = "full",
  4.     image = "Destinations/misc/divider.dds",
  5.     imageWidth = 510,
  6.     imageHeight = 9,
  7.     tooltip = "test",
  8. })
I have added "Libs/LibAddonMenu-2.0/controls/texture.lua" to my config.
I assume image path is based on Addons as root folder.
I also assume that the image format is the same as for pins.
What am I missing?
__________________
My addons: Destinations, ChatStamp and Bank Manager Revived
Last edited by SnowmanDK : 04/25/15 at 03:11 PM.
SnowmanDK is offline Report comment to moderator  
Reply With Quote
Unread 04/21/15, 03:33 AM  
Ayantir
 
Ayantir's Avatar
AddOn Author - Click to view AddOns

Forum posts: 266
File comments: 392
Uploads: 16
Same request for tooltips.

Why :
If I disable a control, user don't know why.
So we explain on tooltips.
Sometimes the reason isin LAM, sometime not. Sometimes it can be combinaisons of reasons.
If I try to cheat and changing tooltips when I change an option

ex :

Lua Code:
  1. optionsTable[index] = {
  2.     type = "checkbox",
  3.     name = pChat.lang.useESOcolors,
  4.     tooltip = pChat.lang.useESOcolorsTT,
  5.     getFunc = function() return pChat.opts.useESOcolors end,
  6.     setFunc = function(newValue)
  7.         pChat.opts.useESOcolors = newValue
  8.         pChat.initLAMTooltips()
  9.     end,
  10.     width = "full",
  11.     default = defaults.useESOcolors,
  12. }
  13.  
  14.  
  15. function pChat.initLAMTooltips()
  16.  
  17.     if pChat.opts.useESOcolors then
  18.        
  19.         pChat.lam.sayTT = pChat.lang.useESOcolorsErrorTT
  20.         ....
  21.     end
  22.    
  23. end
  24.  
  25. optionsTable[index] = {
  26.     type = "colorpicker",
  27.     name = pChat.lang.say,
  28.     tooltip = pChat.lam.sayTT,
  29.     getFunc = function() return pChat.getColour(pChat.opts.colours[2*CHAT_CHANNEL_SAY]) end,
  30.     setFunc = function(r, g, b) pChat.opts.colours[2*CHAT_CHANNEL_SAY] = pChat.makeColour(r, g, b) end,
  31.     default = pChat.defaultColour(defaults.colours[2*CHAT_CHANNEL_SAY]),
  32.     disabled = function() return pChat.opts.useESOcolors end,
  33. }

It won't work neither. Control defined with pChat.lang.say will still get its old tooltip because LAM optionTable is only refreshed when you :RegisterOptionControls. I'll could rebuild my optionsTable with

Lua Code:
  1. LAM:RegisterOptionControls("pChatOptions", optionsTable)
in order to work, but generally users change their multiple options before leaving it.
I've also tried to add in my setFunc : LAM:RegisterOptionControls("pChatOptions", optionsTable)
I won't work neither.

If for a lot of addons, building table only at the startup is a good choice, when you get an addon with huge settings panels and complex code to decide if or not an option is enabled, maybe an optional setting in the controls could be interesting.

Lua Code:
  1. name= "blabla",
  2. getfunc = ...
  3. setFunc = ..
  4. refreshPanel = true




-----------


For the default, I found the trick because my need was on a dropdown.
If you cannot set a func in your "default" parameter, set it in your setFunc parameter.

and write something like this :
In this exemple. I set a sound ID in my db and I show its localized string.


Lua Code:
  1. index = index + 1
  2.     optionsTable[index] = {
  3.         type = "dropdown",
  4.         name = pChat.lang.soundforincwhisps,
  5.         tooltip = pChat.lang.soundforincwhispsTT,
  6.         choices = {
  7.             pChat.lang.soundforincwhispschoice[SOUNDS.NONE],
  8.             pChat.lang.soundforincwhispschoice[SOUNDS.NEW_NOTIFICATION],
  9.             pChat.lang.soundforincwhispschoice[SOUNDS.DEFAULT_CLICK],
  10.             pChat.lang.soundforincwhispschoice[SOUNDS.EDIT_CLICK],
  11.         },
  12.         width = "full",
  13.         default = defaults.soundforincwhisps, --> SOUNDS.NEW_NOTIFICATION
  14.         getFunc = function() return pChat.lang.soundforincwhispschoice[pChat.opts.soundforincwhisps] end,
  15.         setFunc = function(choice)
  16.             if choice == pChat.lang.soundforincwhispschoice[SOUNDS.NONE] then
  17.                 pChat.opts.soundforincwhisps = SOUNDS.NONE
  18.                 PlaySound(SOUNDS.NONE)
  19.             elseif choice == pChat.lang.soundforincwhispschoice[SOUNDS.NEW_NOTIFICATION] then
  20.                 pChat.opts.soundforincwhisps = SOUNDS.NEW_NOTIFICATION
  21.                 PlaySound(SOUNDS.NEW_NOTIFICATION)
  22.             elseif choice == pChat.lang.soundforincwhispschoice[SOUNDS.DEFAULT_CLICK] then
  23.                 pChat.opts.soundforincwhisps = SOUNDS.DEFAULT_CLICK
  24.                 PlaySound(SOUNDS.DEFAULT_CLICK)
  25.             elseif choice == pChat.lang.soundforincwhispschoice[SOUNDS.EDIT_CLICK] then
  26.                 pChat.opts.soundforincwhisps = SOUNDS.EDIT_CLICK
  27.                 PlaySound(SOUNDS.EDIT_CLICK)
  28.             else
  29.                 -- When clicking on LAM default button
  30.                 pChat.opts.soundforincwhisps = defaults.soundforincwhisps
  31.             end
  32.            
  33.         end,
  34.     }

When user click on a button, a sound is played (see the setFunc).
When user click on "reinit" button, "default" send value to setFunc and sound is not played. because I send the stored value, not a dropdown one.

When user don't get a saved vars, Zo_VavedVars will set the value to (here) defaults.soundforincwhisps.
Then the getFunc will handle it. I was maybe tired to see it.

If you want some exemple of complex LAM build tables, I recommand you pChat and MiniMap. there is good example inside.
__________________
Currently working on my Addons

My Addons: pChat, pNames, MultiCraft, Roomba, CraftCompare, Guild Notificator, (...)
My little french Guild: Cercle de l'Eveil
Ayantir is offline Report comment to moderator  
Reply With Quote
Unread 04/18/15, 06:21 PM  
Ayantir
 
Ayantir's Avatar
AddOn Author - Click to view AddOns

Forum posts: 266
File comments: 392
Uploads: 16
little request, allow us to execute code when reverting to default.

the code will look like getFunc

Lua Code:
  1. default = function()
  2.  
  3.     -- do stuff
  4.     return value
  5.  
  6. end,

Thank you.
__________________
Currently working on my Addons

My Addons: pChat, pNames, MultiCraft, Roomba, CraftCompare, Guild Notificator, (...)
My little french Guild: Cercle de l'Eveil
Ayantir is offline Report comment to moderator  
Reply With Quote
Post A Reply



Category Jump: