Thread Tools Display Modes
05/08/17, 12:23 AM   #1
Letho
AddOn Author - Click to view addons
Join Date: Apr 2016
Posts: 238
LAM Control setup (Iconpicker)

Hey, I ran into an issue that I don't understand. Here is the code:

Code:
	local	iconSelect = LAMCreateControl.iconpicker(parent, {
		type = "iconpicker",
		name = "",
		tooltip = "Select the aura's appearance.",
		choices = icons,
		choicesTooltips = icons,
		--sort = "name-up", --or "name-down", "numeric-up", "numeric-down" (optional) - if not provided, list will not be sorted
		getFunc = function() d(self) end,
		setFunc = AuraMastery.EditAuraIcon,
		maxColumns = 20,
		visibleRows = 10,
		iconSize = 40,
		reference = "AuraMasteryDisplayMenu_IconSelect"
	})
	
	iconSelect:SetWidth(160)
	iconSelect:ClearAnchors()
	iconSelect:SetAnchor(TOPLEFT, parent, TOPLEFT, 0, 4)
ESO shows an error for the first line: function expected instead of nil, but I don't get, why. The Iconpicker works btw. and this error is NOT! detected by zbug, I just ran into it because I accidently deactivated zbug.

And another question concerning LAM's iconpicker: Is there any way to preselect an icon from the list for the button? The path is saved insinde the saved variables.

Cheers,
Letho
  Reply With Quote
05/08/17, 05:52 AM   #2
rullof
Join Date: May 2017
Posts: 2
The error is comming either fron getFunc or setFunc make sure you're calling your function using : and check if EditAuraIcon doesnt have any errors

Last edited by rullof : 05/08/17 at 06:07 AM.
  Reply With Quote
05/08/17, 07:28 AM   #3
sirinsidiator
 
sirinsidiator's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 1,566
iconSelect is not a ZOS control. You cannot call SetWidth, ClearAnchors and SetAnchor on it directly. Instead you need to access iconSelect.container.

You can set an initial icon via the "default" property on the data table.
  Reply With Quote
05/08/17, 08:46 AM   #4
Letho
AddOn Author - Click to view addons
Join Date: Apr 2016
Posts: 238
Thank you for your answers!

Originally Posted by rullof View Post
The error is comming either fron getFunc or setFunc make sure you're calling your function using : and check if EditAuraIcon doesnt have any errors
It was indeed the GetFunc though I have no idea what actually caused the error, I leave it to be an empty function now. (According to LAM's code the getFunc should return the currently selected icon's texture path, allthough this does not work in my case :/).


Originally Posted by sirinsidiator View Post
iconSelect is not a ZOS control. You cannot call SetWidth, ClearAnchors and SetAnchor on it directly. Instead you need to access iconSelect.container.
You can set an initial icon via the "default" property on the data table.

According to zgoo iconSelect is of type #userData :O
This is the code in LibAddonMenu-2.0.lua where it is created:
Code:
local function CreateBaseControl(parent, controlData, controlName)
    local control = wm:CreateControl(controlName or controlData.reference, parent.scroll or parent, CT_CONTROL)
    control.panel = parent.panel or parent -- if this is in a submenu, panel is the submenu's parent
    control.data = controlData

    control.isHalfWidth = controlData.width == "half"
    local width = 510 -- set default width in case a custom parent object is passed
    if control.panel.GetWidth ~= nil then width = control.panel:GetWidth() - 60 end
    control:SetWidth(width)
    return control
end
So isn't it a ZOS control of type CT_CONTROL?

Additionally:
Code:
iconSelect:SetWidth() --does indeed do nothing
iconSelect.container:SetAnchor() --does not do nothing aswell
iconSelect.SetAnchor(TOPLEFT, parent, TOPLEFT) --is working as intended
Regarding preSelection: I tried using
Code:
iconSelectReference:UpdateValue()
, but it is a local function and only called upon the control's creation. I'm now using

Code:
iconSelectReference.icon:SetTexture(path)
I basically needed the icon to dynamically change to the path returned by a function that is called on clicking another button that selects the aura to be currently edited. This active aura's path is stored in AuraMastery.svars.auraData[activeAura].iconPath.

Last edited by Letho : 05/08/17 at 09:10 AM.
  Reply With Quote
05/08/17, 09:42 AM   #5
Baertram
Super Moderator
 
Baertram's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 4,912
Simply specifying "self" is not returning the icon.
You need to let it return the SavedVariables data where the selected icon from the iconpicker is stored.

e.g.

function AuraMastery.EditAuraIcon(value)
AuraMastery.svars.auraData[activeAura].iconPath = value
end

getFunc = function() return AuraMastery.svars.auraData[activeAura].iconPath end,
setFunc = function(value) AuraMastery.EditAuraIcon(value) end,

basically needed the icon to dynamically change to the path returned by a function that is called on clicking another button that selects the aura to be currently edited. This active aura's path is stored in AuraMastery.svars.auraData[activeAura].iconPath.
default = AuraMastery.svars.DEFAULTS.auraData[activeAura].iconPath

The default values just need to be an array/table with all your possible saved variables as default values, which you use at the SavedVariables creation as the default values/fallback values if the real saved variables are missing (new savedvars version, new addon, settings = nil ...)
Setting the default values at lam controls will let you use the "Set back to defaults" button fo all the LAM controls e.g.

The getfunc will try to read the savedvars and if nothing is found (= nil) it will use the default value.
If the default value is the same that you use for the SavedVars creation the settings probably won't be nil, as they got copied from the defaults. So the getfunc will just automatically use the default variable which is stored in the savedvars now.

Last edited by Baertram : 05/08/17 at 09:48 AM.
  Reply With Quote
05/08/17, 10:51 AM   #6
Letho
AddOn Author - Click to view addons
Join Date: Apr 2016
Posts: 238
Originally Posted by Baertram View Post
Simply specifying "self" is not returning the icon.
You need to let it return the SavedVariables data where the selected icon from the iconpicker is stored.

e.g.

function AuraMastery.EditAuraIcon(value)
AuraMastery.svars.auraData[activeAura].iconPath = value
end
It was d(self) and I dont have any idea how it got there^^

Originally Posted by Baertram View Post
getFunc = function() return AuraMastery.svars.auraData[activeAura].iconPath end,
setFunc = function(value) AuraMastery.EditAuraIcon(value) end,


default = AuraMastery.svars.DEFAULTS.auraData[activeAura].iconPath
Tried it that way and it didn't work for me.

Originally Posted by Baertram View Post
The default values just need to be an array/table with all your possible saved variables as default values, which you use at the SavedVariables creation as the default values/fallback values if the real saved variables are missing (new savedvars version, new addon, settings = nil ...)
Setting the default values at lam controls will let you use the "Set back to defaults" button fo all the LAM controls e.g.

The getfunc will try to read the savedvars and if nothing is found (= nil) it will use the default value.
If the default value is the same that you use for the SavedVars creation the settings probably won't be nil, as they got copied from the defaults. So the getfunc will just automatically use the default variable which is stored in the savedvars now.
Well, that's not exactly what I needed. Here is a screenshot that makes it easier understandable:



The controls on the right side of the menu are all precreated and hidden. As soon as the user "selects" an aura from the left menu it's name is saved to the addons "global" table (AuraMastery.activeAura = auraName), the editboxes will be filled with the appropriate text values and all menu controls will be displayed. If controls are not used, they are simply anchored to an invisible pool-control - the "control structure", meaning which control to display on what position is saved into an array containing the appropriate values.

Last edited by Letho : 05/08/17 at 10:55 AM.
  Reply With Quote
05/08/17, 02:32 PM   #7
Baertram
Super Moderator
 
Baertram's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 4,912
If you save the path of the selected icon, coming from the value parameter of the setFunc of the icon picker, to
AuraMastery.svars.auraData[AuraMastery.activeAura].iconPath

you can use the getfunc to get the icon's path that was saved
return AuraMastery.svars.auraData[AuraMastery.activeAura].iconPath

And the same for the default icon path, if you have a default specified somewhere.


The controls are not inside a LAM panel as it seems (correct?) and thus won't get updated automatically via the getFunc I guess. Maybe you need to set the texture manually to the iconpicker by using the reference of the LAM control and use something like
WINDOW_MANAGER:GetControlByName(reference, "").icon:SetTexture(AuraMastery.svars.auraData[AuraMastery.activeAura].iconPath)

?
  Reply With Quote
05/08/17, 04:16 PM   #8
Letho
AddOn Author - Click to view addons
Join Date: Apr 2016
Posts: 238
As I wrote above, that's the way I do it^^
  Reply With Quote

ESOUI » Developer Discussions » Lua/XML Help » LAM Control setup (Iconpicker)

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