Thread Tools Display Modes
06/04/14, 10:36 PM   #1
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Feb 2014
Posts: 648
LibAddonMenu-2.0 - looking for a few people to poke at it

I finished LAM-2.0 last night. Here is a .zip of the file and some rough starter docs. Hoping to get a few ambitious people to play with it and see if anything breaks.


As usual, you need to grab LAM from LibStub first:
Lua Code:
  1. local lam = LibStub("LibAddonMenu-2.0")


METHOD: REGISTER ADDON PANEL
Lua Code:
  1. --registers your addon with LibAddonMenu and creates a panel
  2. --Usage:
  3. --  addonID = "string"; unique ID which will be the global name of your panel
  4. --  panelData = table; data object for your panel - see controls\panel.lua
  5. lam:RegisterAddonPanel(addonID, panelData)


METHOD: REGISTER OPTION CONTROLS
Lua Code:
  1. --registers the options you want shown for your addon
  2. --these are stored in a table where each key-value pair is the order
  3. --of the options in the panel and the data for that control, respectively
  4. --see exampleoptions.lua for an example
  5. --see controls\<widget>.lua for usage of each widget type
  6. --Usage:
  7. --  addonID = "string"; the same string passed to :RegisterAddonPanel
  8. --  optionsTable = table; the table containing all of the options controls and their data
  9. lam:RegisterOptionControls(addonID, optionsTable)


With the new LAM, you only need to make those two function calls and define your data in tables. (See exampleoptions.lua for an example of usage.) Everything else is handled by the library itself.

For power-users who wish to get their hands dirty, the widget controls are registered under the LAMCreateControls object. You can bypass LAM and create everything manually - either using your own window/panel, or registering for one through LAM. If you're not so ambitious, but still want something in your options panel that LAM doesn't provide, you can either register your own widget type (see the :RegisterWidget method) or use the "custom" widget type, which is basically just a container.


--------------

June 6 Update:
- fixed checkbox control for initial value bug
- localized game Settings menu lookup & encoded LAM-2.0 Lua file in UTF-8

--------------

June 8 Update:
- cleaned up ForceDefaults code
- set bg center of addon panel and addon menu to transparent
- fixed editbox multiline bug
- fixed description anchoring bug
- fixed defaults button and confirm dialog
- added optional custom function for when resetting defaults (will be called after all settings are reset)
Attached Files
File Type: zip LibAddonMenu-2.0.zip (198.2 KB, 1249 views)

Last edited by Seerah : 06/08/14 at 09:44 PM.
 
06/05/14, 06:58 AM   #2
Garkin
 
Garkin's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 832
Wow. It looks really great. Settings for all addons at one place is really good idea. It is much cleaner solution then in LAM 1.0.

I would just suggest adding some kind of transparency to the panel as it will feel more like part of default UI. Also it would be great if you can add an option to turn on/off addon, so all about addons is on the same place.

By the way write somewhere that I should not use the same name for my settings menu as I use for global table in my addon...

EDIT:
I think that default widgets should be "hardcoded" so their functionality will be guaranteed. It is really easy to break other addons, if you replace default widget.

Last edited by Garkin : 06/05/14 at 02:54 PM.
 
06/05/14, 01:44 PM   #3
Vuelhering
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 169
I'll check it out!

edit: btw, I notice you use the term All Rights Reserved, but you probably want to use the actual word "Copyright" followed by the year and your entity name. At least in the US, that is the proper labelling.

I don't believe ARR means anything, legally.

Last edited by Vuelhering : 06/05/14 at 02:36 PM.
 
06/05/14, 07:55 PM   #4
Kentarii
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 42
Cool stuff, will take it for a spin this weekend.
 
06/06/14, 06:57 AM   #5
Froali
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 13
I'm getting this error, when i am trying to open the settings through the defined /-command:
Code:
user:/AddOns/ThurisazGuildInfo/lib/LibAddonMenu-2.0/LibAddonMenu-2.0.lua:52: attempt to index a nil value
stack traceback:
	user:/AddOns/ThurisazGuildInfo/lib/LibAddonMenu-2.0/LibAddonMenu-2.0.lua:52: in function 'func'
	EsoUI/Libraries/Globals/globalapi.lua:156: in function '(anonymous)'
Though the settings menu is accessible via ESC->Addon Settings and works so far.

If you need more information to reproduce it, let me know Great work so far. Thanks Seerah!

Edit: Just clicked through ZO_GameMenu_InGame via /zgoo. This is just dumb... the table
Code:
ZO_GameMenu_InGame.gameMenu.headerControls.Settings
is localized and has a different name in the german client i'm using:
Code:
ZO_GameMenu_InGame.gameMenu.headerControls.Einstellungen

Last edited by Froali : 06/06/14 at 07:01 AM.
 
06/06/14, 07:51 AM   #6
Froali
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 13
I think i found another little bug in checkbox.lua:70

In function UpdateValue. In order to set the checkbox initial value to the actual current value, shouldn't it be
Lua Code:
  1. else
  2.      control.value = control.data.getFunc()
  3. end
In your original code it simple sets value = .... resulting in the checkbox being false all the time
 
06/06/14, 09:18 AM   #7
niocwy
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 11
Yay ! It looks very nice Seerah.

I'll get my eyes and hands on this asap.
 
06/06/14, 12:26 PM   #8
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Feb 2014
Posts: 648
Originally Posted by Froali View Post
Edit: Just clicked through ZO_GameMenu_InGame via /zgoo. This is just dumb... the table
Code:
ZO_GameMenu_InGame.gameMenu.headerControls.Settings
is localized and has a different name in the german client i'm using:
Code:
ZO_GameMenu_InGame.gameMenu.headerControls.Einstellungen
Well, that's annoying. :/ Could someone on the French client let me know what name theirs has, please?

Originally Posted by Froali View Post
I think i found another little bug in checkbox.lua:70

...

In your original code it simple sets value = .... resulting in the checkbox being false all the time
Oooh - good catch, thanks. control.value is something I added in later. I guess I didn't notice thinking I had the checkbox in exampleoptions.lua set to false (it's actually set to true, and I'm just dumb). Fixing!
 
06/06/14, 01:32 PM   #9
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Feb 2014
Posts: 648
I was able to get the French one just by changing the Language.2 cvar. Updating the OP with a new version that includes those two fixes.
 
06/06/14, 01:53 PM   #10
McGuffin
Join Date: Apr 2014
Posts: 5
I am not sure if i do something wrong but in my french client the table is empty:
Attached Thumbnails
Click image for larger version

Name:	Screenshot_20140606_214953.jpg
Views:	1953
Size:	41.8 KB
ID:	281  
 
06/06/14, 04:28 PM   #11
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Feb 2014
Posts: 648
That is odd...
 
06/06/14, 07:42 PM   #12
lyravega
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 93
I'll get my hands dirty with this
 
06/07/14, 02:32 PM   #13
Sasky
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 231
A few suggestions/tweaks:
1) Add an author field to the creation. That way can show authors at the top on the settings page but not in the list.

2) Edit box - in description you have "isMultiline" in the table description in the header but "isMultiLine" used below.

3) Add API for appendOption(). It'd be fairly easy to implement (table.insert) and would allow creating panels in a similar style to the current API. Also, if you depend on well-ordered tables (where # works properly), you might want to do this exclusively instead of having the authors spell out their own tables.

4) Currently the text box/description seems to leave a large margin at the top.

-------------------------

For the major 'poking around at it', I went ahead and made a quick adapter. (It doesn't work for submenus or for addons where they touch the menu panel directly. But all non-submenu API calls translate just fine.) For the ones where the adapter works, LAM2 seems work pretty well.

Last edited by Sasky : 06/12/14 at 02:44 AM.
 
06/07/14, 05:02 PM   #14
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Feb 2014
Posts: 648
Originally Posted by Sasky View Post
A few suggestions/tweaks:
1. I will consider this. (I don't think there is a real need to display author names on the settings panel at all, personally, and you could just use a description box at the top for this info, but I will consider it if other people want it.)

2. Ooh, good catch. I guess I forgot to test multi-line edit boxes.

3. I'm not quite certain what you mean here... Could you explain more/better? The index in the table is the order that the options will be created and ordered in the panel. Though perhaps I will switch to next() instead of ipairs()...

4. Do you have a screenshot for this? I did not have this issue. My guess is that you gave the description a title, but left the title empty. The title field is optional.


I don't have any plans to include an adaptor with the library. But if it works, that's cool.

Thanks!
 
06/07/14, 07:25 PM   #15
Sasky
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 231
1. I was thinking just have it as an optional field. If present, you could show the title for the panel as
"ADDON NAME by Author".

3. First, code of what was thinking for the API function
Lua Code:
  1. function lam:AddOptionControl(addonID, optionParams)
  2.     if addonToOptionsMap[addonID] == nil then
  3.         addonToOptionsMap[addonID] = {}
  4.     end
  5.     table.insert(addonToOptionsMap, optionParams)
  6. end

Two reasons - 1) update based on a settings change. 2) Allow authors to construct settings table in a manner that is (a bit) closer to how it currently works:
Lua Code:
  1. lam:AddOptionControl("Foo", {
  2.     type = "header",
  3.     name = "My Header",
  4. })
  5. lam:AddOptionControl("Foo", {
  6.     type = "dropdown",
  7.     name = "My Dropdown",
  8.     tooltip = "Dropdown's tooltip text.",
  9.     choices = {"table", "of", "choices"},
  10.     getFunc = function() return "of" end,
  11.     setFunc = function(var) print(var) end,
  12. })

The second point was if you need it to have consecutive indexes (like in your example), you might want to only do this method to guarantee you have that. What happens if you're fed in somthing like the following?
Lua Code:
  1. { "header" = { ... }, "some" = {...}, "other" = {...}, "controls" = {...} }

4. A NIL value is being passed in as the title. Screenshot attached.

----------

Yeah, I did an adapter since that's a quick way to test a lot of the functionality with how people are actually using it in addons. I wasn't intending for it to be included, as a lot of addons touch the options panel or the LAM variables directly, making it impossible for them to work through an adapter.
Attached Thumbnails
Click image for larger version

Name:	lam2-ss.jpg
Views:	957
Size:	182.4 KB
ID:	283  
 
06/08/14, 02:59 PM   #16
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Feb 2014
Posts: 648
3. If you want to create controls one by one, you can use the LAMCreateControl methods - this is one of the main reasons why they are exposed. The only thing is that you have to then handle placement yourself. My goal was to make everything easier for people to get their options panels all set up right out of the gate.

If your example table (with non-numerical indexes) is passed through to LAM, then the author isn't following the docs correctly. It would be the same as if they had a typo in a method name, or forgot a required field. Follow the directions (they aren't too complicated), and you'll get your options just the way you want them.

4. Ooh - I see what I did. Copy/paste fail. Fixed now.


Hubby has our company at the casino this afternoon/evening, so I can play with this stuff more myself today, too.
 
06/08/14, 09:42 PM   #17
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Feb 2014
Posts: 648
Updating download in the top post. Unless anything else comes up horribly wrong, the next update may be to the main download page.

In this version...
- cleaned up ForceDefaults code
- set bg center of addon panel and addon menu to transparent
- fixed editbox multiline bug
- fixed description anchoring bug
- fixed defaults button and confirm dialog
- added optional custom function for when resetting defaults (will be called after all settings are reset)

Last edited by Seerah : 06/08/14 at 09:45 PM.
 
06/11/14, 03:53 AM   #18
Sasky
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 231
3. Lua's pass-by-reference does interesting things that let you work around the absence of a one-by-one add API...

Turns out the following code will actually create the header in LAM because tables are passed around as references:
Lua Code:
  1. -- ...
  2. local optionsTable = {}
  3. LAM:RegisterOptionControls("Foo", optionsTable)
  4. table.insert(optionsTable, {
  5.     type = "header",
  6.     name = "Bar"
  7. })
  8. -- ...
 
06/11/14, 06:45 AM   #19
Garkin
 
Garkin's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 832
LibAddonMenu-2.0 r2 fails to update from vertion r1 with this UI error:
Code:
2014-06-11T13:50:30.007+01:00 |cff0000Gui Warning: Failed to create control 'LAMAddonPanelsMenu'.  Duplicate name|r
2014-06-11T13:50:30.007+01:00 |cff0000Lua Error: user:/AddOns/MyLister/LibAddonMenu-2.0/LibAddonMenu-2.0.lua:252: attempt to index a nil value
stack traceback:
	user:/AddOns/MyLister/LibAddonMenu-2.0/LibAddonMenu-2.0.lua:252: in function 'CreateAddonList'
	user:/AddOns/MyLister/LibAddonMenu-2.0/LibAddonMenu-2.0.lua:290: in function '(main chunk)'|r

Suggestions:
In different languages should be "Addon seetings" translated to localized version.
For example use ingame string SI_GAME_MENU_ADDONS (en = "Addons", de = "Erweiterungen", fr = "Extensions").

Instead of:
Lua Code:
  1. local settings = {en = "Settings", de = "Einstellungen", fr = "Réglages"}
  2. local locSettings = settings[GetCVar("Language.2")]
You can use:
Lua Code:
  1. local locSettings = GetString(SI_GAME_MENU_SETTINGS)

Last edited by Garkin : 06/13/14 at 03:10 AM.
 

ESOUI » AddOns » Alpha/Beta AddOns » LibAddonMenu-2.0 - looking for a few people to poke at it

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off