-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
108 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
|
||
function loadOptions() | ||
local optionsIni = "options.ini" | ||
|
||
if (FS.exists(optionsIni))then | ||
local f1 = function(setting) | ||
local param = string.find(setting, "true") | ||
stateSettingsVideoDisplay.optionFullscreen = param | ||
stateSettingsVideoDisplay.chkFullscreen.checked = param --TODO: this should be done inside the settings page | ||
end | ||
local f2= function(setting) | ||
stateSettingsVideoDisplay.optionLarge=setting --TODO this needs to be sanitized | ||
local resolutionIndex = stateSettingsVideoDisplay.findResolution(setting) | ||
stateSettingsVideoDisplay.comboLarge.updateSelection(resolutionIndex) | ||
end | ||
local options = {{name="display.video.fullscreen", execute= f1},{name="display.video.resolution",execute = f2}} | ||
local optionLines = {} | ||
local lines = {} | ||
|
||
for line in love.filesystem.lines(optionsIni) do | ||
table.insert(lines, line) | ||
end | ||
|
||
for i,line in ipairs(lines)do | ||
for j,option in ipairs(options) do | ||
local m1, m2 = string.find(line, option.name.."=") | ||
print (i, m1,m2) | ||
if m2 then | ||
|
||
local setting = string.sub(line, m2+1) | ||
option.execute(setting) | ||
end | ||
end | ||
end | ||
end | ||
stateSettingsVideoDisplay.checkOptionsLarge() --TODO: provide a function that changes the option and immediately switches | ||
end | ||
function saveOptions() | ||
local optionsIni = "options.ini" | ||
local data = "" | ||
local f1 = function(setting) | ||
local param =stateSettingsVideoDisplay.optionFullscreen or false | ||
data = data..setting.."="..tostring(param).."\n" | ||
end | ||
local f2= function(setting) | ||
local width, height, flags = love.window.getMode() | ||
local param = width.."x"..height | ||
|
||
data = data..setting.."="..tostring(param).."\n" | ||
end | ||
local options = {{name="display.video.fullscreen", execute= f1},{name="display.video.resolution",execute = f2}} | ||
for _, option in ipairs(options) do | ||
option.execute(option.name) | ||
end | ||
|
||
love.filesystem.rename(optionsIni,optionsIni.."_old") | ||
local success = love.filesystem.write( optionsIni, data ) | ||
print ("options saved successfully: ", success) | ||
end |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters