Originally Posted by erispope
Not great at wow UI but you are creating one info and reusing it - could that be a problem?
Secondly, perhaps rewrite the inner function to a reusable one instead of recreating it all the time (use self.value +1 instead of i)?
|
info is just a function reference, so it only needs to be made once. The inner function is just a shortcut to iterate through the SLFG_DungeonList creating their respective info. It's basically the equivalent of writing:
Lua Code:
function SLFG_Dungeon_Menu_Init(self)
local level = level or 1
local info = UIDropdownMenu_CreateInfo()
info.text = SLFG_DungeonList[1]
info.value = 0
info.func = SLFG_DungeonMenuClick
info.owner = self
info.check = nil
info.icon = nil
UIDropDownMenu_AddButton(info, level) -- creates menu button with current insert
-- this begins reassigning the data next table data
-- it functions the same as if you did x = 1, immediately followed by x =2
info.text = SLFG_DungeonList[2]
info.value = 1
info.func = SLFG_DungeonMenuClick
info.owner = self
info.check = nil
info.icon = nil
UIDropDownMenu_AddButton(info, level) -- creates menu button with new info
-- repeat 26 more times for each DungeonList entry
end
function SLFG_DungeonMenuClick(self)
UIDropDownMenu_SetSelectedValue(self.owner, self.value) -- button checkmark itself and updates the dropdown text shown
if self.value == 0 then
SLFG_Settings.dungeon = string.match(SLFG_DungeonList[1], "%((%w+)%)")
print(SLFG_DungeonList[1].. " has been set.")
SLFG_UpdateMsg()
elseif self.value == 1 then
SLFG_Settings.dungeon = string.match(SLFG_DungeonList[2], "%((%w+)%)")
print(SLFG_DungeonList[2].. " has been set.")
SLFG_UpdateMsg()
elseif self.value == 2 then
-- repeat 26 more times again
end
end
I have a second dropdown box that is written out the long way, and it does the exact same thing. I compare the functions side by side with the ones I wrote in CFM and from what I've seen they're identical. Yet CFM dropdowns work fine and these don't.