Skip to content

Commit

Permalink
(Possibly) Fix #21
Browse files Browse the repository at this point in the history
  • Loading branch information
GuglioIsStupid committed Apr 26, 2024
1 parent 5355a3b commit 4165b37
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
21 changes: 21 additions & 0 deletions src/love/lib/ini.lua
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,27 @@ function ini.load( filePath )
return nil
end

function ini.loadString( iniString )
local iniTable = {}
local currentSection = "default"
for line in iniString:gmatch( "[^\r\n]+" ) do
local isComment = string.match( line, "^%s*;.*$")
if line ~= "" and isComment == nil then
local section = string.match( line, "%[%s*(.*)%s*%]" )
if section ~= nil then
currentSection = section
iniTable[section] = {}
else
local variableName, variableValue = string.match( line, "^%s*(.*[^%s])%s*=%s*(.*[^%s])%s*$" )
if variableName and variableValue then
iniTable[currentSection][variableName] = variableValue
end
end
end
end
return iniTable
end

function ini.save( iniTable, file )
if iniTable then
local writeString = ""
Expand Down
2 changes: 1 addition & 1 deletion src/love/settings.lua
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ if curOS == "NX" then
love.filesystem.write("settings.ini", settingsStr)
end

settingsIni = ini.load("settings.ini")
settingsIni = ini.load("settings.ini") or ini.loadString(settingsStr)

if ini.readKey(settingsIni, "Video", "hardwareCompression") == "true" then
settings.hardwareCompression = true
Expand Down

0 comments on commit 4165b37

Please sign in to comment.