Skip to content

Commit

Permalink
fix modmenu
Browse files Browse the repository at this point in the history
  • Loading branch information
Joelrau committed Aug 11, 2024
1 parent b3f7437 commit 71843c3
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions data/cdata/ui_scripts/Mods/ModSelectMenu.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 71843c3

Please sign in to comment.