public Option[] GetAdvancedOptions(string optionsCategory)
        {
            var options = _profileSettingsService.GetAdvancedOptions(optionsCategory);

            foreach (var option in options)
            {
                if (_profileSettingsService.TryGetValue <object>(ProfileSettingsCategories.AdvancedOptions, option.Id, out var value))
                {
                    option.Value = value;
                }
            }

            return(options);
        }
        public Task WriteOptionsAsync(bool isVr)
        {
            return(Task.Run(() =>
            {
                var install = _settingsService.SelectedInstall;
                var categories = _profileSettingsService.GetDcsOptions();
                var optionsFile = Path.Combine(install.SavedGamesPath, "Config", "options.lua");

                if (!File.Exists(optionsFile))
                {
                    Tracer.Warn($"options.lua was not found in path {optionsFile}");
                    return Task.FromResult(true);
                }

                string contents = null;

                try
                {
                    contents = File.ReadAllText(optionsFile);
                }
                catch (Exception ex)
                {
                    Tracer.Error(ex);
                    return Task.FromResult(true);
                }

                try
                {
                    using (var context = new OptionLuaContext(install))
                    {
                        foreach (var category in categories)
                        {
                            foreach (var option in category.Options)
                            {
                                if (_profileSettingsService.TryGetValue <object>(ProfileSettingsCategories.GameOptions, option.Id, out var value))
                                {
                                    if (option.Id == "options.VR.enabled")
                                    {
                                        context.SetValue(category.Id, option.Id, isVr);
                                    }
                                    else
                                    {
                                        //Tracker.Instance.SendEvent(AnalyticsCategories.DcsOptions, $"{category.Id}_{option.Id}", value.ToString());
                                        context.SetValue(category.Id, option.Id, value);
                                    }
                                }
                            }
                        }

                        context.Save();
                    }
                }
                catch (Exception ex)
                {
                    Tracer.Error(ex);

                    if (!string.IsNullOrEmpty(contents))
                    {
                        File.WriteAllText(optionsFile, contents);
                    }
                }

                return Task.FromResult(true);
            }));
        }