mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-05-02 08:49:20 -05:00
* Add nil checks for boolean parameters in config helper (closes #2364) * remove some trailing spaces
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
-- Helper functions that are useful to customize the openspace.cfg loading
|
||||
|
||||
-- #######################################################################################
|
||||
-- #######################################################################################
|
||||
-- ## Public functions ##
|
||||
-- #######################################################################################
|
||||
-- #######################################################################################
|
||||
|
||||
-- SGCT related functions
|
||||
sgct = {}
|
||||
@@ -79,9 +79,9 @@ sgctconfiginitializeString = ""
|
||||
|
||||
|
||||
--[[
|
||||
##########################################################################################
|
||||
##########################################################################################
|
||||
Internal helper functions
|
||||
##########################################################################################
|
||||
##########################################################################################
|
||||
]]--
|
||||
|
||||
function generateSingleViewportFOV(down, up, left, right, tracked)
|
||||
@@ -89,7 +89,7 @@ function generateSingleViewportFOV(down, up, left, right, tracked)
|
||||
|
||||
table.insert(result, [[ {]])
|
||||
|
||||
if tracked then
|
||||
if tracked ~= nil then
|
||||
table.insert(result, [[ "tracked": ]] .. tostring(tracked) .. [[,]])
|
||||
end
|
||||
|
||||
@@ -114,7 +114,7 @@ function generateFisheyeViewport(fov, quality, tilt, background, crop, offset, t
|
||||
|
||||
table.insert(result, [[ {]])
|
||||
|
||||
if tracked then
|
||||
if tracked ~= nil then
|
||||
table.insert(result, [[ "tracked": ]] .. tostring(tracked) .. [[,]])
|
||||
end
|
||||
|
||||
@@ -162,7 +162,7 @@ function generateWindow(result, fullScreen, msaa, border, monitor, tags, stereo,
|
||||
size, res, viewport)
|
||||
table.insert(result, [[ "name": "OpenSpace",]])
|
||||
|
||||
if fullScreen then
|
||||
if fullScreen ~= nil then
|
||||
table.insert(result, [[ "fullscreen": ]] .. tostring(fullScreen) .. [[,]])
|
||||
end
|
||||
|
||||
@@ -170,7 +170,7 @@ function generateWindow(result, fullScreen, msaa, border, monitor, tags, stereo,
|
||||
table.insert(result, [[ "msaa": ]] .. msaa .. [[,]])
|
||||
end
|
||||
|
||||
if border then
|
||||
if border ~= nil then
|
||||
table.insert(result, [[ "border": ]] .. tostring(border) .. [[,]])
|
||||
end
|
||||
|
||||
@@ -253,7 +253,7 @@ end
|
||||
function generateSettings(result, refreshRate, vsync)
|
||||
table.insert(result, [[ "display": {]])
|
||||
|
||||
if (refreshRate) then
|
||||
if refreshRate then
|
||||
table.insert(result, [[ "refreshrate": ]] .. refreshRate .. [[,]])
|
||||
end
|
||||
|
||||
@@ -275,7 +275,7 @@ function generateCluster(arg, viewport)
|
||||
table.insert(result, [[ "version": 1,]])
|
||||
table.insert(result, [[ "masteraddress": "127.0.0.1",]])
|
||||
|
||||
if arg["sgctDebug"] then
|
||||
if arg["sgctDebug"] ~= nil then
|
||||
table.insert(result, [[ "debug": ]] .. tostring(arg["sgctdebug"]) .. [[,]])
|
||||
end
|
||||
|
||||
@@ -321,7 +321,7 @@ function check(type_str, arg, param, subparam_type)
|
||||
type(v) == subparam_type,
|
||||
param .. "[" .. k .. "] must be a " .. subparam_type
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -347,8 +347,8 @@ function generateSingleWindowConfig(arg, viewport)
|
||||
check("table", arg["scene"], "orientation", "number")
|
||||
check("number", arg["scene"], "scale")
|
||||
end
|
||||
|
||||
if arg["shared"] then
|
||||
|
||||
if arg["shared"] ~= nil then
|
||||
local t = arg["tags"]
|
||||
t[#t + 1] = "Spout"
|
||||
end
|
||||
@@ -420,9 +420,9 @@ function sgct.config.single(arg)
|
||||
|
||||
arg["tracked"] = arg["tracked"] or true
|
||||
|
||||
local viewport = generateSingleViewportFOV(arg["fov"]["down"], arg["fov"]["up"],
|
||||
local viewport = generateSingleViewportFOV(arg["fov"]["down"], arg["fov"]["up"],
|
||||
arg["fov"]["left"], arg["fov"]["right"], arg["tracked"])
|
||||
|
||||
|
||||
return sgct.makeConfig(generateSingleWindowConfig(arg, viewport))
|
||||
end
|
||||
|
||||
@@ -445,7 +445,7 @@ function sgct.config.fisheye(arg)
|
||||
-- OpenSpace code prior to loading this file
|
||||
|
||||
local scale_factor = 2.0/3.0;
|
||||
arg["size"] = { ScreenResolution.x * scale_factor, ScreenResolution.y * scale_factor }
|
||||
arg["size"] = { ScreenResolution.x * scale_factor, ScreenResolution.y * scale_factor }
|
||||
end
|
||||
|
||||
check("number", arg, "fov")
|
||||
|
||||
Reference in New Issue
Block a user