sirinsidiator / ESO-LibAddonMenu

http://www.esoui.com/downloads/info7-LibAddonMenu.html
Artistic License 2.0
41 stars 20 forks source link

Add resetfunc at control of panel #130

Closed Baertram closed 1 year ago

Baertram commented 2 years ago

Add resetfunc at control of panel if you need to set defaults for more than 1 list/table etc. for custom widgets etc.

Baertram commented 1 year ago

-Removed LibStub usage from developer.lua -Updated iconPicker widget to v12

Added OPTIONAL data.useIndex --> boolean or function returning a boolean. If true: The setFunc/getFunc will use/return the index of the table choices. If false: The functions will use/return the texturePath value of table choices (optional) saving the index of textures to the SavedVariables should lower their size compared to saving the whole texturePath

Example usage, comparing texturePath and texture index:

local markerIconTextures = {
    [1]  = [[/esoui/art/campaign/campaignbrowser_fullpop.dds]],
    [2]  = [[/esoui/art/inventory/inventory_tabicon_armor_disabled.dds]],
    [3]  = [[/esoui/art/crafting/smithing_tabicon_research_disabled.dds]],
    [4]  = [[/esoui/art/tradinghouse/tradinghouse_sell_tabicon_disabled.dds]],
    [5]  = [[/esoui/art/campaign/overview_indexicon_bonus_disabled.dds]],
    [6]  = [[/esoui/art/ava/tabicon_bg_score_disabled.dds]],
    [7]  = [[/esoui/art/guild/guild_rankicon_leader_large.dds]],
    [8]  = [[/esoui/art/lfg/lfg_healer_up.dds]],
    [9]  = [[/esoui/art/miscellaneous/timer_32.dds]],
    [10] = [[/esoui/art/crafting/alchemy_tabicon_solvent_up.dds]],
}
        --Test LibAddonMenu-2.0 iconPicker widget
        --Add the icon picker with texturePath
        {
            reference = "LAM_ICONPICKER_TEST_TEXTUREPATH",
            name    = "Icon picker with texturePath",
            tooltip = "Icon picker with texturePath",
            type    = "iconpicker",
            width = "half",
            choices = markerIconTextures,
            useIndex = false, --new attribute: Test with false (default)
            --choicesTooltips = texturesList,
            maxColumns=6,
            visibleRows=5,
            iconSize=32,
            getFunc = function()
d(">1getFunc: " .. tos(yourSv.iconTexturePath))
                return yourSv.iconTexturePath
            end,
            setFunc = function(value)
d(">1setFunc: " ..tos(value))
                  yourSv.iconTexturePath = value
            end,
            default = markerIconTextures[1]
        },

        --Add the icon picker with texturePath index of choices
        {
            reference = "LAM_ICONPICKER_TEST_TEXTUREPATH_INDEX",
            name    = "Icon picker with texturePath index",
            tooltip = "Icon picker with texturePath index",
            type    = "iconpicker",
            width = "half",
            choices = markerIconTextures,
            useIndex = true, --new attribute: Test with true (use index of choices)
            --choicesTooltips = texturesList,
            maxColumns=6,
            visibleRows=5,
            iconSize=32,
            getFunc = function()
d(">2getFunc: " .. tos(1))
                return yourSv.iconIndex
            end,
            setFunc = function(value)
d(">2setFunc: " ..tos(value))
                 yourSv.iconIndex = value
            end,
            default = 1
        },