fix modmenu

This commit is contained in:
quaK 2024-08-11 23:49:13 +03:00
parent b3f7437487
commit 71843c3821

View File

@ -57,14 +57,16 @@ end
local populateModList = function(menuElement, controllerIndex) local populateModList = function(menuElement, controllerIndex)
local modList = {} local modList = {}
local mods = io.listfiles("mods/") if io.directoryexists("mods") then
for i = 1, #mods do local mods = io.listfiles("mods/")
local name, desc = getModName(mods[i]) for i = 1, #mods do
modList[#modList + 1] = { local name, desc = getModName(mods[i])
buttonLabel = ToUpperCase(name), modList[#modList + 1] = {
modName = name, buttonLabel = ToUpperCase(name),
objectiveText = desc modName = name,
} objectiveText = desc
}
end
end end
local dataSource = LUI.DataSourceFromList.new(#modList) local dataSource = LUI.DataSourceFromList.new(#modList)
dataSource.MakeDataSourceAtIndex = function(dataSource, index, controllerIndex) dataSource.MakeDataSourceAtIndex = function(dataSource, index, controllerIndex)
@ -101,6 +103,11 @@ local function postLoadFunction(menuElement, controllerIndex, controller)
populateModList(menuElement, controllerIndex) populateModList(menuElement, controllerIndex)
menuElement:addEventHandler("gain_focus", function(focusElement, controllerIndex) menuElement:addEventHandler("gain_focus", function(focusElement, controllerIndex)
local modSelectionList = focusElement.ModSelectionList local modSelectionList = focusElement.ModSelectionList
if modSelectionList:getNumChildren() == 0 then
return
end
local contentOffset = modSelectionList:GetContentOffset(LUI.DIRECTION.vertical) local contentOffset = modSelectionList:GetContentOffset(LUI.DIRECTION.vertical)
modSelectionList:SetFocusedPosition({ modSelectionList:SetFocusedPosition({
x = 0, x = 0,