ESOUI

ESOUI (https://www.esoui.com/forums/index.php)
-   Lua/XML Help (https://www.esoui.com/forums/forumdisplay.php?f=175)
-   -   Unnamed outfits don't show up in the dropdown of all outfits in LAM (https://www.esoui.com/forums/showthread.php?t=9895)

Leonardo1123 08/27/21 10:16 PM

Unnamed outfits don't show up in the dropdown of all outfits in LAM
 
Hey there!

I'm not sure if the name of unnamed outfits isn't actually the name but really placeholder text that's failing to trigger my code correctly or what, but any outfit that hasn't been custom-named doesn't show up in my dropdown. All code here, relevant code below.

Initialize:
Lua Code:
  1. function LeonardosWardrobeManager:Initialize()
  2.     LeonardosWardrobeManager.savedVariables = ZO_SavedVars:NewCharacterIdSettings(
  3.             "LeonardosWardrobeManagerVars",
  4.             LeonardosWardrobeManager.variableVersion, nil, LeonardosWardrobeManager.Default, GetWorldName())
  5.  
  6.     self.inCombat = IsUnitInCombat("player")
  7.     self.inStealth = GetUnitStealthState("player")
  8.  
  9.     for i=1,GetNumUnlockedOutfits() do
  10.         self.allOutfits[i + OUTFIT_OFFSET] = GetOutfitName(0, i)
  11.     end
  12.  
  13.     button, LeonardosWardrobeManager.feedback = LibFeedback:initializeFeedbackWindow(
  14.             LeonardosWardrobeManager,
  15.             "Leonardo's Wardrobe Manager",
  16.             WINDOW_MANAGER:CreateTopLevelWindow("LeonardosWardrobeDummyControl"),
  17.             "@Leonardo1123",
  18.             {CENTER , GuiRoot , CENTER , 10, 10},
  19.             {0,5000,50000},
  20.             "Send ")
  21.     button:SetHidden(true)
  22.  
  23.     LAM2:RegisterAddonPanel("LeonardosWardrobeManagerOptions", panelData)
  24.     LAM2:RegisterOptionControls("LeonardosWardrobeManagerOptions", optionsData)
  25.  
  26.     EVENT_MANAGER:RegisterForEvent(self.name, EVENT_OUTFIT_RENAME_RESPONSE, self.OnOutfitRenamed)
  27.     EVENT_MANAGER:RegisterForEvent(self.name, EVENT_PLAYER_ACTIVATED, self.OnPlayerActivated)
  28.     EVENT_MANAGER:RegisterForEvent(self.name, EVENT_PLAYER_COMBAT_STATE, self.OnPlayerCombatState)
  29.     EVENT_MANAGER:RegisterForEvent(self.name, EVENT_STEALTH_STATE_CHANGED, self.OnPlayerStealthState)
  30. end

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.         reference = "LeonardosWardrobeManager_Feedback",
  22.         controls = {
  23.             [1] = {
  24.                 type = "dropdown",
  25.                 name = "Combat Outfit",
  26.                 tooltip = "The outfit to be switched to upon entering combat",
  27.                 choices = LeonardosWardrobeManager.allOutfits,
  28.                 getFunc = function() return LeonardosWardrobeManager.savedVariables.combatOutfit end,
  29.                 setFunc = function(var) LeonardosWardrobeManager.SetStateOutfit("COMBAT", var) end,
  30.                 reference = "LeonardosWardrobeManager_Combat_Dropdown"
  31.             },
  32.             [2] = {
  33.                 type = "dropdown",
  34.                 name = "Stealth Outfit",
  35.                 tooltip = "The outfit to be switched to upon entering stealth",
  36.                 choices = LeonardosWardrobeManager.allOutfits,
  37.                 getFunc = function() return LeonardosWardrobeManager.savedVariables.stealthOutfit end,
  38.                 setFunc = function(var) LeonardosWardrobeManager.SetStateOutfit("STEALTH", var) end,
  39.                 reference = "LeonardosWardrobeManager_Stealth_Dropdown"
  40.             },
  41.         }
  42.     }
  43. }

Leonardo1123 08/28/21 10:51 AM

Fixed it!

When first indexing the outfits to add them to LAM, if an outfit name is an empty string, it renames it to what the name should be (Outfit N)


All times are GMT -6. The time now is 02:30 AM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2014 - 2022 MMOUI