Go to Page... |
Updated: | 07-27-09 08:21 PM |
Created: | 11-23-08 05:58 AM |
Downloads: | 151,921 |
Favorites: | 167 |
MD5: |
Interface Option Creation Utility
Library to register Blizzard Option Panels with an option table syntax.
Purpose
Portfolio was made to act as a bridge to accept a recognizable option table format (similar to Khaos and Ace) and convert it into a fully functional Blizzard Options Panel. Any Ace or Khaos registration should be fairly painless for an author to convert to use Portfolio, and new option sets should be easy to understand and construct without having to make any frames or manually manage controls.
LuaDocs
http://www.karlkfi.com/PortfolioDocs/
PortfolioDocs are also included in the download, but is not inside the addon folder itself to save space when embedding.
Feedback & Support
The best way you can help would be to try and write your own Portfolio config options and see if it behaves the way you'd expect. Report any bugs or confusing implementation using the Report Bugs button or Comments. I'm also always open to suggestions and code donations via the Feature Request link.
If you'd like to donate to show your support, that can be done through paypal with a paypal account or by credit card. Remember donations are much appreciated but non-contractual. Thank you!
Implemented Option Types
-- Get a reference to the lib from LibStub -- If LibStub doesn't exist this will fail silently -- If LibStub exists but Portfolio does not this will print an error in chat and then fail -- Use LibStub("Portfolio", true) to fail silently if you want Portfolio options to be optional. local Portfolio = LibStub and LibStub("Portfolio") if not Portfolio then return end -- Create the option table for registration. local optionSetTable = { -- option frame id, unique, no spaces id = "PortfolioDemo"; text = "Header/Tab Title Text"; subText = "Sub header Text" -- AddOn name for variable loading, if different from id addon = "PortfolioDemo"; options = { -- list of option tables goes here! { id = "option1"; -- option attributes go here }; -- more option tables }; -- (Optional) String or table of your addon's saved variables. Use SavedVariables in your toc! savedVarTable = "PortfolioDemo_SavedVars"; } local optionsFrame = Portfolio.RegisterOptionSet(optionSetTable)
Comment Options |
sykopat |
View Public Profile |
Send a private message to sykopat |
Find More Posts by sykopat |
Add sykopat to Your Buddy List |
12-14-10, 02:00 PM | |
A Kobold Labourer
Forum posts: 0
File comments: 21
Uploads: 0
|
Naitaeti what part should we replace with this?Thanks
|
|
RaiGaL |
View Public Profile |
Send a private message to RaiGaL |
Find More Posts by RaiGaL |
Add RaiGaL to Your Buddy List |
Naitaeti |
View Public Profile |
Send a private message to Naitaeti |
Find More Posts by Naitaeti |
Add Naitaeti to Your Buddy List |
10-15-10, 07:34 PM | |
|
Also note:
Always register your Portfolio Options AFTER your core Lua code. This will save you some stress
__________________
Never be satisfied with satisfactory. |
|
Cralor |
View Public Profile |
Send a private message to Cralor |
Visit Cralor's homepage! |
Find More Posts by Cralor |
Add Cralor to Your Buddy List |
Cralor |
View Public Profile |
Send a private message to Cralor |
Visit Cralor's homepage! |
Find More Posts by Cralor |
Add Cralor to Your Buddy List |
AnduinLothar |
View Public Profile |
Send a private message to AnduinLothar |
Visit AnduinLothar's homepage! |
Find More Posts by AnduinLothar |
Add AnduinLothar to Your Buddy List |
Zasurus |
View Public Profile |
Send a private message to Zasurus |
Visit Zasurus's homepage! |
Find More Posts by Zasurus |
Add Zasurus to Your Buddy List |
evl |
View Public Profile |
Send a private message to evl |
Visit evl's homepage! |
Find More Posts by evl |
Add evl to Your Buddy List |
02-17-09, 04:14 PM | |
|
LibDefaults is not especially big (12KB), which includes LibStub (1.33KB), but that's a lot smaller than Portfolio (92KB). Note that these are file sizes, which only really directly effects load time with parsing and processing. As for processor and memory overhead I haven't run any extensive testing.
You can just embed or require LibDefaults if you want Portfolio to be optional and still want the benefits of LibDefaults. You will still have to delay callbacks until the saved variables load, but you can utilize LibDefaults' SetScript for that so you dont have to make your own frame or event handler. Something like: lua Code:
Note: that "evl_TestDB[option.id]" should be "evl_TestDB[option.id]" but the highlighting ate it! That would mostly emulate what Portfolio does. Except it assumes that you want all your callbacks called. If you use buttons or some other plugin control type that has a callback but not a current value then you'd need to modify your CallCallbacks function to ignore those (something Portfolio does automatically).
Last edited by AnduinLothar : 02-17-09 at 05:10 PM.
|
|
AnduinLothar |
View Public Profile |
Send a private message to AnduinLothar |
Visit AnduinLothar's homepage! |
Find More Posts by AnduinLothar |
Add AnduinLothar to Your Buddy List |
02-17-09, 12:04 PM | ||
|
My point is, idealy I'd like people to be able to run all my addons without any libraries of any sort, but if they have said library they get a nice pretty GUI to play around with. I'm not really sure how much overhead Portfolio adds other than static memory which isn't really a big deal I guess but it would be nice to know! I have about 8-9 addons that are pretty small and I would hate to have to embed Portfolio in all of them.
Last edited by evl : 02-17-09 at 12:13 PM.
|
|
|
evl |
View Public Profile |
Send a private message to evl |
Visit evl's homepage! |
Find More Posts by evl |
Add evl to Your Buddy List |
02-17-09, 11:44 AM | |
|
That works, provided you make a frame and an event driver and run it on ADDON_LOADED. Otherwise your callbacks will always be fired based on the defaults and not on any changed saved variables.
Plus the way you have it written you're not passing the current values to the callbacks anyway, so that doesn't exactly mimic what Portfolio does, even if it works for your usage. Also, some control callbacks are not meant to be called on init, like callbacks for buttons, which are only called when clicked. Of course then if LibDefaults is not present you wont be able to reset to defaults and your saved variables will contain all unchanged defaults (which can increase loading time if there are a lot). But if you want to sacrifice that for the sake of addon size that's your call.
Last edited by AnduinLothar : 02-17-09 at 11:54 AM.
|
|
AnduinLothar |
View Public Profile |
Send a private message to AnduinLothar |
Visit AnduinLothar's homepage! |
Find More Posts by AnduinLothar |
Add AnduinLothar to Your Buddy List |
02-17-09, 06:36 AM | |
|
I've gotten a bit further in my research towards a completely optional approach. My addons are known for their minimal size and I'd like to keep it that way.
I modified the way the initialization of the configuration is done and so far it's working out great. Code:
local optionTable = { id = "evl_Test", text = "Test", savedVarTable = "evl_TestDB", options = { { id = "OptionA", text = "Option A", type = CONTROLTYPE_CHECKBOX, defaultValue = "1", callback = function() print("Option A callback") end }, { id = "OptionB", text = "Option B", type = CONTROLTYPE_CHECKBOX, defaultValue = "0" }, } } -- Check if we have the configuration library local Portfolio = LibStub and LibStub("Portfolio", true) if Portfolio then Portfolio.RegisterOptionSet(optionTable) else evl_TestDB = evl_TestDB and evl_TestDB or {} for _, option in ipairs(optionTable.options) do local id = option.id if not evl_TestDB[id] then evl_TestDB[id] = option.defaultValue end if option.callback then option.callback() end end end
Last edited by evl : 02-17-09 at 06:37 AM.
|
|
evl |
View Public Profile |
Send a private message to evl |
Visit evl's homepage! |
Find More Posts by evl |
Add evl to Your Buddy List |
02-16-09, 02:04 AM | |
|
Thank you!
Oh wonderful!
Your lib seems to be what I have been waiting for!!! I am struggeling with blizzard options for so long now. I have two addons, one is successfully writing the options to the saved variables, the other is not and I am not sure why. Therefore I have not published it yet, though it works fine for me. Both addons use the blizzard interface for customization and it is working fine so far, except making the values persistent. I wanted to write my addon without any other 3rd party lib, but for your fine collection, I'll make an exception. I'll come back and praise you again, when I actually have applied your lib to my addons ) Last Zolex |
|
Last Zolex |
View Public Profile |
Send a private message to Last Zolex |
Visit Last Zolex's homepage! |
Find More Posts by Last Zolex |
Add Last Zolex to Your Buddy List |
02-15-09, 07:57 PM | ||
|
option:SetValue calls self:UpdateText which updates the option text to the value of Portfolio.Control.GetValueText(control, "text") which returns control.text unless the text value is a function or a format string. So by setting the text = "Name (%s)" your slider text will include the value. As for saved variables you have a number of options. Either make your addon depend on or embed Portfolio which includes LibDefaults. Or make your addon depend on or embed LibDefaults. Or you can optionally depend on both. If LibDefaults isn't available then you are obviously going to have to handle your own variables. It was done this way for flexibility. You can decided if you want to go to the extra effort to make Portfolio and/or LibDefaults optional. As for the about page, yes I can make it optional. But I'm going to leave that decision until I revamp the paging to better handle sub-pages, which is on the todo list. In the mean time you can put useful info in your toc file that will get displayed there, like Version, Author, X-Category, X-Website, and X-Email
Last edited by AnduinLothar : 02-15-09 at 08:04 PM.
|
|
|
AnduinLothar |
View Public Profile |
Send a private message to AnduinLothar |
Visit AnduinLothar's homepage! |
Find More Posts by AnduinLothar |
Add AnduinLothar to Your Buddy List |
02-15-09, 05:05 PM | |
|
I've been working on incorporating Portfolio into my small addons and I've run into some design problems.
Firstly I'm having problems using callbacks on other controls, an example I would like to see is a slider that when changed updates the value of a text control (I really think this should be defaut in slider as there is currently no way of knowing the sliders current value). Secondly, the handling of defaults via LibDefaults is nice and all but it creates a tight-coupling between the addon and Portfolio since disabling Portfolio will cause the addon to stop working due to the LibDefaults dependancy, currently I've implemented normal defaults handling to get around this (MyAddonDB = MyAddonDB or defaults) but it's not very pretty. Lastly, would it be possible for the about page to be optional? Currently I feel it's just bloat and adds an extra level to every panel.
Last edited by evl : 02-15-09 at 05:07 PM.
|
|
evl |
View Public Profile |
Send a private message to evl |
Visit evl's homepage! |
Find More Posts by evl |
Add evl to Your Buddy List |
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.