/// <summary> /// parses the options.lua file from DCS or returns false if it cannot /// </summary> /// <param name="location"></param> /// <param name="options"></param> /// <returns></returns> public static bool TryReadOptions(InstallationLocation location, out DCSOptions options) { string optionsPath = location.OptionsPath; if (!File.Exists(optionsPath)) { options = null; return(false); } try { string optionsText = File.ReadAllText(optionsPath); NLua.Lua parser = new NLua.Lua(); parser.DoString(optionsText, "options.lua"); object graphics = parser.GetObjectFromPath("options.graphics"); if (graphics is NLua.LuaTable graphicsTable && graphicsTable["width"] is long width && graphicsTable["height"] is long height && graphicsTable["multiMonitorSetup"] is string multiMonitorSetup) { options = new DCSOptions { Graphics = new GraphicsTable(width, height, multiMonitorSetup) }; return(true); } } catch (Exception ex) { // this is sort of ok, we might not have access, so we just don't check this part Logger.Info(ex, "failed to read DCS-owned options.lua file; Helios will not be able to check settings"); } options = null; return(false); }