From 71843c38218d5b07e679a23e5e4cddf6cd19cd14 Mon Sep 17 00:00:00 2001 From: quaK Date: Sun, 11 Aug 2024 23:49:13 +0300 Subject: [PATCH] fix modmenu --- data/cdata/ui_scripts/Mods/ModSelectMenu.lua | 23 +++++++++++++------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/data/cdata/ui_scripts/Mods/ModSelectMenu.lua b/data/cdata/ui_scripts/Mods/ModSelectMenu.lua index d4786121..4378631b 100644 --- a/data/cdata/ui_scripts/Mods/ModSelectMenu.lua +++ b/data/cdata/ui_scripts/Mods/ModSelectMenu.lua @@ -57,14 +57,16 @@ end local populateModList = function(menuElement, controllerIndex) local modList = {} - local mods = io.listfiles("mods/") - for i = 1, #mods do - local name, desc = getModName(mods[i]) - modList[#modList + 1] = { - buttonLabel = ToUpperCase(name), - modName = name, - objectiveText = desc - } + if io.directoryexists("mods") then + local mods = io.listfiles("mods/") + for i = 1, #mods do + local name, desc = getModName(mods[i]) + modList[#modList + 1] = { + buttonLabel = ToUpperCase(name), + modName = name, + objectiveText = desc + } + end end local dataSource = LUI.DataSourceFromList.new(#modList) dataSource.MakeDataSourceAtIndex = function(dataSource, index, controllerIndex) @@ -101,6 +103,11 @@ local function postLoadFunction(menuElement, controllerIndex, controller) populateModList(menuElement, controllerIndex) menuElement:addEventHandler("gain_focus", function(focusElement, controllerIndex) local modSelectionList = focusElement.ModSelectionList + + if modSelectionList:getNumChildren() == 0 then + return + end + local contentOffset = modSelectionList:GetContentOffset(LUI.DIRECTION.vertical) modSelectionList:SetFocusedPosition({ x = 0,