View Single Post
08/27/21, 12:46 PM   #4
Leonardo1123
AddOn Author - Click to view addons
Join Date: Aug 2021
Posts: 19
Hey there! Sorry for not searching, definitely will in the future! So I feel like I'm super close but there's something basic I'm not understanding. Here's my attempt to implement what you suggested:

LAM
Lua Code:
  1. optionsData = {
  2.     [1] = {
  3.         type = "description",
  4.         title = nil,
  5.         text = "Warning: If you rename an outfit, you will need to reload the UI for those changes to take effect here",
  6.         width = "full",
  7.     },
  8.     [2] = {
  9.         type = "dropdown",
  10.         name = "Default Outfit",
  11.         tooltip = "The outfit to be worn by default",
  12.         choices = LeonardosWardrobeManager.allOutfits,
  13.         getFunc = function() return LeonardosWardrobeManager.savedVariables.defaultOutfit end,
  14.         setFunc = function(var) LeonardosWardrobeManager.SetStateOutfit("DEFAULT", var) end,
  15.         reference = "LeonardosWardrobeManager_Default_Dropdown"
  16.     },
  17.     [3] = {
  18.         type = "submenu",
  19.         name = "Combat",
  20.         tooltip = "Options related to combat and stealth", --(optional)
  21.         controls = {
  22.             [1] = {
  23.                 type = "dropdown",
  24.                 name = "Combat Outfit",
  25.                 tooltip = "The outfit to be switched to upon entering combat",
  26.                 choices = LeonardosWardrobeManager.allOutfits,
  27.                 getFunc = function() return LeonardosWardrobeManager.savedVariables.combatOutfit end,
  28.                 setFunc = function(var) LeonardosWardrobeManager.SetStateOutfit("COMBAT", var) end,
  29.                 reference = "LeonardosWardrobeManager_Combat_Dropdown"
  30.             },
  31.             [2] = {
  32.                 type = "dropdown",
  33.                 name = "Stealth Outfit",
  34.                 tooltip = "The outfit to be switched to upon entering stealth",
  35.                 choices = LeonardosWardrobeManager.allOutfits,
  36.                 getFunc = function() return LeonardosWardrobeManager.savedVariables.stealthOutfit end,
  37.                 setFunc = function(var) LeonardosWardrobeManager.SetStateOutfit("STEALTH", var) end,
  38.                 reference = "LeonardosWardrobeManager_Stealth_Dropdown"
  39.             },
  40.         }
  41.     }
  42. }

Update
Lua Code:
  1. function LeonardosWardrobeManager.OnOutfitRenamed(event, response, index) -- TODO: Still not working
  2.     for i=1,GetNumUnlockedOutfits() do
  3.         LeonardosWardrobeManager.allOutfits[i + OUTFIT_OFFSET] = GetOutfitName(0, i)
  4.     end
  5.     LeonardosWardrobeManager_Default_Dropdown:UpdateChoices(LeonardosWardrobeManager.allOutfits)
  6.     LeonardosWardrobeManager_Combat_Dropdown:UpdateChoices(LeonardosWardrobeManager.allOutfits)
  7.     LeonardosWardrobeManager_Stealth_Dropdown:UpdateChoices(LeonardosWardrobeManager.allOutfits)
  8. end

Event Registers
Lua Code:
  1. ...
  2.  
  3.     LAM2:RegisterAddonPanel("LeonardosWardrobeManagerOptions", panelData)
  4.     LAM2:RegisterOptionControls("LeonardosWardrobeManagerOptions", optionsData)
  5.  
  6.     EVENT_MANAGER:RegisterForEvent(self.name, EVENT_OUTFIT_RENAME_RESPONSE, self.OnOutfitRenamed)
  7.     EVENT_MANAGER:RegisterForEvent(self.name, EVENT_PLAYER_ACTIVATED, self.OnPlayerActivated)
  8.     EVENT_MANAGER:RegisterForEvent(self.name, EVENT_PLAYER_COMBAT_STATE, self.OnPlayerCombatState)
  9.     EVENT_MANAGER:RegisterForEvent(self.name, EVENT_STEALTH_STATE_CHANGED, self.OnPlayerStealthState)
  10. end


Originally Posted by Baertram View Post
There are other threads/posts about this already. Please use the forum search before posting new threads. Searching for LibAddonMenu or LAM would have provided them easily.

But basically you need to use the "reference" tag of the lam options to give it a name you can reference to.
And then use <referenceVariableOfDropdownBox>:UpdateChoices(listOfChoices, choicesValues, choicesTooltips)
choicesValues and choicesTooltips are optional. But I'd at least always provide choices and choicesValues so that the getfunc and setFunc uses the choicesValues easily, instead of having to check all entries in choices to match the string of your getFunc/setFunc parameter!

Searching for LAM or UpdateChoices (you could not know the later until now I assume :-)) will give you example forum threads, e.g.
https://www.esoui.com/forums/showthr...=UpdateChoices

I've added it to the Wiki as well now:
https://wiki.esoui.com/LibAddonMenu:...wn_box_entries
  Reply With Quote