public void LaunchSettings_CtorTests()
        {
            var profiles = new List <LaunchProfile>()
            {
                new LaunchProfile("abc", null, commandLineArgs: "test"),
                new LaunchProfile("def", null),
                new LaunchProfile("ghi", null),
                new LaunchProfile("foo", null),
            };

            var globals = ImmutableDictionary <string, object> .Empty
                          .Add("var1", true)
                          .Add("var2", "some string");

            var settings = new LaunchSettings(profiles);

            Assert.NotNull(settings.ActiveProfile);
            Assert.True(settings.ActiveProfile.Name == "abc");
            Assert.Equal(profiles.Count, settings.Profiles.Count);
            Assert.Empty(settings.GlobalSettings);

            settings = new LaunchSettings(profiles, activeProfileName: "ghi");
            Assert.NotNull(settings.ActiveProfile);
            Assert.True(settings.ActiveProfile.Name == "ghi");

            // Test
            settings = new LaunchSettings(profiles, globals, activeProfileName: "foo");
            Assert.Equal(globals.Count, settings.GlobalSettings.Count);
        }
Example #2
0
        public void Read(UserProfile profile, out BindableCollection <Addon> addons, out BindableCollection <LaunchParameter> parameters, out LaunchSettings launchSettings)
        {
            Logger.LogDebug("ProfileService", "Reading profile from disk");

            try
            {
                ProfileFile profileFile = new ProfileFile {
                    Profile = profile
                };

                var settings = new JsonSerializerSettings {
                    Converters = { new JsonLaunchParameterConverter() }
                };
                JsonConvert.PopulateObject(_fileAccessor.ReadAllText(Path.Combine(ApplicationConfig.ConfigPath, ApplicationConfig.ProfilesFolder,
                                                                                  string.Format(ApplicationConfig.ProfileNameFormat, profile.Id))), profileFile, settings);

                addons         = profileFile.Addons;
                parameters     = profileFile.Parameters;
                launchSettings = profileFile.LaunchSettings;
            }
            catch (Exception e)
            {
                Logger.LogException("ProfileService", "Error reading profile", e);
                addons         = new BindableCollection <Addon>();
                parameters     = new BindableCollection <LaunchParameter>();
                launchSettings = new LaunchSettings();
            }
        }
Example #3
0
 /// <summary>
 /// Creates a new instance of the <see cref="ProfileLoadedMessage"/> class, with the specified settings.
 /// </summary>
 public ProfileLoadedMessage(UserProfile profile, BindableCollection <Addon> addons,
                             BindableCollection <LaunchParameter> parameters, LaunchSettings launchSettings)
 {
     Profile        = profile;
     Addons         = addons;
     Parameters     = parameters;
     LaunchSettings = launchSettings;
 }
        private static Profile GetFirstOrEmptyProfile(LaunchSettings launchSettings)
        {
            var profiles = launchSettings.GetProfiles();

            var actual = profiles.FirstOrEmpty();

            return(actual);
        }
Example #5
0
            static void AlterLaunchSettings()
            {
                var filePath       = @"Properties\launchSettings.json";
                var content        = File.ReadAllText(filePath);
                var launchSettings = LaunchSettings.FromJson(content);

                launchSettings.Profiles.IisExpress.LaunchBrowser = false;
                launchSettings.Profiles.IisExpress.LaunchUrl     = "";
                File.WriteAllText(filePath, launchSettings.ToJson());
            }
Example #6
0
 public Settings()
 {
     ExtraFolders          = new List <string>();
     ProgramsToLaunchPrior = new List <ProgramLaunchInfo>();
     Subscriptions         = new List <Subscription>();
     Options              = new List <GeneralOptions>();
     AutoUpdateSource     = "#F!yBlHTYiJ!SFpmT2xII7iXcgXAmNYLJg";
     DateTimeStringFormat = "MM/dd/yyyy";
     IsFirstStart         = false;
     GameLaunchSettings   = LaunchSettings.DefaultSettings();
     UserColumnSettings   = new ColumnSettings();
 }
Example #7
0
        public GameService(IProcessAccessor processAccessor, IClipboardAccessor clipboardAccessor, ILogger logger, ISettingsService settingsService,
                           IAddonService addonService, IParameterService parameterService, ISecurityService securityService) : base(logger)
        {
            _processAccessor   = processAccessor;
            _clipboardAccessor = clipboardAccessor;

            _settingsService  = settingsService;
            _addonService     = addonService;
            _parameterService = parameterService;
            _securityService  = securityService;

            LaunchSettings = new LaunchSettings();
        }
Example #8
0
        private void LoadSettings(LaunchSettings launchSettings)
        {
            HasLoaded = false;

            if (Sys.Settings.GameLaunchSettings == null)
            {
                Logger.Warn("No game launcher settings found, initializing to defaults.");
                Sys.Settings.GameLaunchSettings = LaunchSettings.DefaultSettings();
                launchSettings = Sys.Settings.GameLaunchSettings;
            }

            ProgramList = new ObservableCollection <ProgramToRunViewModel>(Sys.Settings.ProgramsToLaunchPrior.Select(s => new ProgramToRunViewModel(s.PathToProgram, s.ProgramArgs)));

            AutoUpdatePathChecked  = launchSettings.AutoUpdateDiscPath;
            DoWorkaroundErrorCode5 = launchSettings.WorkaroundErrorCode5;
            IsShowLauncherChecked  = launchSettings.ShowLauncherWindow;


            IsAutoMountSupported = GameDiscMounter.OSHasBuiltInMountSupport();
            AutoMountChecked     = launchSettings.AutoMountGameDisc;
            AutoUnmountChecked   = launchSettings.AutoUnmountGameDisc;

            // options to select mount method is disabled if user OS does not support and forced to use wincdemu  (i.e. does not support PowerShell Mount-DiskImage)
            if (IsAutoMountSupported)
            {
                SelectedMountOption = MountOptions[(int)launchSettings.MountingOption];
            }
            else
            {
                SelectedMountOption = MountOptions[(int)MountDiscOption.MountWithWinCDEmu];
            }

            SetSelectedSoundDeviceFromSettings(launchSettings);

            SelectedMidiData = MidiDataFormats.Where(s => s.Value == launchSettings.SelectedMidiData)
                               .Select(s => s.Key)
                               .FirstOrDefault();

            GetVolumesFromRegistry();

            SetSelectedMidiDeviceFromSettings();

            IsReverseSpeakersChecked = launchSettings.ReverseSpeakers;
            IsLogVolumeChecked       = launchSettings.LogarithmicVolumeControl;

            HasLoaded = true;
        }
Example #9
0
        private void SetSelectedSoundDeviceFromSettings(LaunchSettings launchSettings)
        {
            if (SoundDeviceGuids == null || SoundDeviceGuids.Count == 0)
            {
                return;
            }

            SelectedSoundDevice = SoundDeviceGuids.Where(s => s.Value == launchSettings.SelectedSoundDevice)
                                  .Select(s => s.Key)
                                  .FirstOrDefault();

            // switch back to 'Auto' if device not found
            if (SelectedSoundDevice == null)
            {
                SelectedSoundDevice = SoundDeviceGuids.Where(s => s.Value == Guid.Empty)
                                      .Select(s => s.Key)
                                      .FirstOrDefault();
            }
        }
        public WritableLaunchSettings(ILaunchSettings settings)
        {
            if (settings.Profiles != null)
            {
                foreach (ILaunchProfile profile in settings.Profiles)
                {
                    // Make a mutable/writable copy of each profile
                    Profiles.Add(new WritableLaunchProfile(profile));
                }
            }

            foreach ((string key, object value) in LaunchSettings.CloneGlobalSettingsValues(settings.GlobalSettings))
            {
                GlobalSettings.Add(key, value);
            }

            if (settings.ActiveProfile != null)
            {
                ActiveProfile = Profiles.Find(profile => LaunchProfile.IsSameProfileName(profile.Name, settings.ActiveProfile.Name));
            }
        }
Example #11
0
        public BLaunchWindow(BState startState)
        {
            InitializeComponent();
            this.startState = startState;

            if (!Directory.Exists(SETTINGS_PATH))
            {
                Directory.CreateDirectory(SETTINGS_PATH);
            }

            if (!File.Exists(Path.Combine(SETTINGS_PATH, $"{AppInfo.APP_FILESAFENAME}.json")))
            {
                this.CloseBox.Checked      = this.close;
                this.FullscreenBox.Checked = AppSettings.SETTING_FULLSCREEN;
                this.VsyncBox.Checked      = AppSettings.SETTING_VSYNC;
                this.VsyncBox.Enabled      = AppSettings.SETTING_FULLSCREEN;
                this.FpsBox.Text           = AppSettings.SETTING_FPS.ToString();
                this.WidthBox.Text         = AppSettings.SETTING_WIDTH.ToString();
                this.HeightBox.Text        = AppSettings.SETTING_HEIGHT.ToString();

                settings = new LaunchSettings(false, AppSettings.SETTING_FULLSCREEN, AppSettings.SETTING_VSYNC, AppSettings.SETTING_FPS, AppSettings.SETTING_WIDTH, AppSettings.SETTING_HEIGHT);
                settings.Save(Path.Combine(SETTINGS_PATH, $"{AppInfo.APP_FILESAFENAME}.json"));
            }
            else
            {
                settings                   = LaunchSettings.Load(Path.Combine(SETTINGS_PATH, $"{AppInfo.APP_FILESAFENAME}.json"));
                this.close                 = settings.CloseOnLaunch;
                this.CloseBox.Checked      = settings.CloseOnLaunch;
                this.FullscreenBox.Checked = settings.Fullscreen;
                this.VsyncBox.Checked      = settings.Vsync;
                this.VsyncBox.Enabled      = settings.Fullscreen;
                this.FpsBox.Text           = settings.Fps.ToString();
                this.WidthBox.Text         = settings.WindowWidth.ToString();
                this.HeightBox.Text        = settings.WindowHeight.ToString();
            }

            this.Text = $"Made with BEngine2D - {AppInfo.APP_NAME}";
        }
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="launchSettings">启动设置</param>
        /// <param name="launcherProfileParser">Mojang官方launcher_profiles.json适配组件</param>
        /// <param name="versionLocator"></param>
        /// <param name="authResult"></param>
        /// <param name="rootPath"></param>
        /// <param name="rootVersion"></param>
        public DefaultLaunchArgumentParser(LaunchSettings launchSettings, ILauncherProfileParser launcherProfileParser, IVersionLocator versionLocator, AuthResult authResult, string rootPath, string rootVersion)
        {
            if (launchSettings == null || launcherProfileParser == null)
            {
                throw new ArgumentNullException();
            }

            AuthResult            = authResult;
            VersionLocator        = versionLocator;
            RootPath              = rootPath;
            LaunchSettings        = launchSettings;
            LauncherProfileParser = launcherProfileParser;
            VersionInfo           = LaunchSettings.VersionLocator.GetGame(LaunchSettings.Version);
            GameProfile           = LauncherProfileParser.GetGameProfile(LaunchSettings.GameName);

            ClassPath = string.Join(string.Empty,
                                    VersionInfo.Libraries.Select(l =>
                                                                 $"{GamePathHelper.GetLibraryPath(launchSettings.GameResourcePath, l.Path.Replace('/', '\\'))};"));
            ClassPath += string.IsNullOrEmpty(rootVersion)
                ? GamePathHelper.GetGameExecutablePath(rootPath, launchSettings.Version)
                : GamePathHelper.GetGameExecutablePath(rootPath, rootVersion);
            LastAuthResult = LaunchSettings.Authenticator.GetLastAuthResult();
        }
Example #13
0
        private static async Task Main(string[] args)
        {
            var jl = SystemInfoHelper.FindJava();

            foreach (var java in jl)
            {
                Console.WriteLine(java);
            }
            InitLauncherCore();
            Console.WriteLine(core.VersionLocator.GetAllGames().Count());
            var gameList = core.VersionLocator.GetAllGames().ToList();

            foreach (var game in gameList)
            {
                Console.WriteLine(game.Name);
            }
            Console.WriteLine(core.VersionLocator.GetGame(gameList[0].Id).JvmArguments);

            var javaPath = jl.ToList()[0];

            Console.WriteLine(javaPath);
            var versionId = gameList[0].Id;

            Console.WriteLine(versionId);

            var launchSettings = new LaunchSettings
            {
                FallBackGameArguments =
                    new GameArguments                    // 游戏启动参数缺省值,适用于以该启动设置启动的所有游戏,对于具体的某个游戏,可以设置(见下)具体的启动参数,如果所设置的具体参数出现缺失,将使用这个补全
                {
                    GcType         = GcType.G1Gc,        // GC类型
                    JavaExecutable = javaPath,           // Java路径
                    Resolution     = new ResolutionModel // 游戏窗口分辨率
                    {
                        Height = 600,                    // 高度
                        Width  = 800                     // 宽度
                    },
                    MinMemory = 512,                     // 最小内存
                    MaxMemory = 1024                     // 最大内存
                },
                Version           = versionId,           // 需要启动的游戏ID
                VersionInsulation = false,               // 版本隔离
                GameResourcePath  = core.RootPath,       // 资源根目录
                GamePath          = core.RootPath,       // 游戏根目录,如果有版本隔离则应该改为GamePathHelper.GetGamePath(Core.RootPath, versionId)
                VersionLocator    = core.VersionLocator, // 游戏定位器
                GameName          = gameList[0].Name,
                GameArguments     = new GameArguments    // (可选)具体游戏启动参数
                {
                    AdvanceArguments = "",               // GC类型
                    JavaExecutable   = javaPath,         // JAVA路径
                    Resolution       = new ResolutionModel {
                        Height = 600, Width = 800
                    },               // 游戏窗口分辨率
                    MinMemory = 512, // 最小内存
                    MaxMemory = 1024 // 最大内存
                },
                Authenticator = new OfflineAuthenticator
                {
                    Username = "******",
                    LauncherProfileParser = core.VersionLocator.LauncherProfileParser // launcher_profiles.json解析组件
                }
            };


            core.GameLogEventDelegate   += Core_GameLogEventDelegate;
            core.LaunchLogEventDelegate += Core_LaunchLogEventDelegate;
            core.GameExitEventDelegate  += Core_GameExitEventDelegate;
            var result = await core.LaunchTaskAsync(launchSettings);

            Console.WriteLine(result.Error?.Exception);
            Console.ReadLine();
        }
        /// <inheritdoc />
        public override async Task LaunchAsync(DebugLaunchOptions launchOptions)
        {
            var props = ConfiguredProject.Services.ProjectPropertiesProvider.GetCommonProperties();

            var debugDir = await props.GetEvaluatedPropertyValueAsync("OutDir");

            await TaskFactory.SwitchToMainThreadAsync();

            // Collect the source folders to map.
            var properties = await DebuggerProperties.GetEmuliciousDebuggerPropertiesAsync();

            var sourcePaths = (IReadOnlyCollection <string>) await properties.EmuliciousSourcePaths.GetValueAsync();

            // Get the projects for folder mapping.
            var projectPairs = new Dictionary <string, string>();

            if (sourcePaths == null || sourcePaths.Count == 0)
            {
                // Bind every project.
                await RecurseProjectsAsync(VisualStudio.Solution.Projects, projectPairs);
            }
            else
            {
                var index = 0;
                foreach (var path in sourcePaths.Distinct())
                {
                    projectPairs.Add(string.Format("SourcePath{0}", index),
                                     Path.GetFullPath(path).TrimEnd('/', '\\'));
                    ++index;
                }
            }

            if (EmuliciousLegacySourceFolders)
            {
                // Create junctions to the source files.
                CreateProjectJunctions(projectPairs, debugDir);
            }

            var executable = (string)await properties.EmuliciousDebuggerExecutable.GetValueAsync();

            var romName = (string)await properties.EmuliciousLaunchRom.GetValueAsync();

            var attach = (bool)await properties.EmuliciousDebuggerDebuggerAttach.GetValueAsync();

            var stopOnEntry = (bool)await properties.EmuliciousDebuggerDebuggerStopOnEntry.GetValueAsync();

            var debuggerPort = (int)await properties.EmuliciousDebuggerPort.GetValueAsync();

            var startDelay = (int)await properties.EmuliciousDebuggerStartDelay.GetValueAsync();

            var debugPath = (string)await properties.EmuliciousDebugLogPath.GetValueAsync();

            var useLegacySrc = (bool)await properties.EmuliciousLegacySourceFolders.GetValueAsync();

            var useLegacyBreakPointFix = (bool)await properties.EmuliciousLegacyBreakpointFix.GetValueAsync();

            var useRemoteDebugArg = (bool)await properties.EmuliciousRemoteDebugArgument.GetValueAsync();

            // Cache properties used by the launch adapter.
            EmuliciousExecutable          = executable;
            EmuliciousPort                = debuggerPort;
            EmuliciousAttach              = attach;
            EmuliciousLaunchDelay         = startDelay;
            EmuliciousDebugFolder         = debugPath;
            EmuliciousMappingPath         = debugDir;
            EmuliciousRemoteDebugArgument = useRemoteDebugArg;
            EmuliciousLegacySourceFolders = useLegacySrc;
            EmuliciousLegacyBreakpointFix = useLegacyBreakPointFix;


            // Create the PassthroughAdapter settings file.
            var mapping = new PassthroughSettings(EmuliciousLegacySourceFolders, EmuliciousLegacyBreakpointFix, projectPairs.Values,
                                                  EmuliciousMappingPath, EmuliciousDebugFolder);

            mapping.SaveToFile(Path.Combine(debugDir, "ProjectMapping.json"));

            /*
             * File.WriteAllLines(Path.Combine(EmuliciousMappingPath, "LaunchProps.log"),
             *  new []
             *  {
             *      EmuliciousExecutable.ToString(),
             *      EmuliciousPort.ToString(),
             *      EmuliciousAttach.ToString(),
             *      EmuliciousLaunchDelay.ToString(),
             *      EmuliciousDebugFolder.ToString(),
             *      EmuliciousMappingPath.ToString(),
             *      EmuliciousPackage.DebugAdapterPath.ToString()
             *  });
             */

            // Generate the launch.json file for emulicious.
            var jsonFile       = Path.Combine(debugDir, "launch.json");
            var launchSettings = new LaunchSettings((attach) ? LaunchSettings.RequestMode.Attach : LaunchSettings.RequestMode.Launch,
                                                    debuggerPort, romName, stopOnEntry, projectPairs.Values);

            launchSettings.WriteToFile(jsonFile);

            Task.WaitAll();

            // Launch the debug host adapter with our JSON file.
            var launchArgs = "/EngineGuid:{BE99C8E2-969A-450C-8FAB-73BECCC53DF4} " + string.Format("/LaunchJson:\"{0}\"",
                                                                                                   jsonFile);

            VisualStudio.ExecuteCommand("DebugAdapterHost.Launch", launchArgs);
        }
Example #15
0
        /// <summary>
        /// 启动游戏。
        /// Launch the game.
        /// </summary>
        /// <param name="settings">启动设置。Launch Settings.</param>
        /// <returns>启动结果。如果成功则包含消耗的时间,如果失败则包含异常信息。The result contains elapsed time(if successful) or elapsed time plus exception info(if failed).</returns>
        public async Task <LaunchResult> LaunchTaskAsync(LaunchSettings settings)
        {
            try
            {
                //逐步测量启动时间。
                //To measure the launch time step by step.
                var prevSpan  = new TimeSpan();
                var stopwatch = new Stopwatch();
                stopwatch.Start();

                #region 解析游戏 Game Info Resolver
                var version = VersionLocator.GetGame(settings.Version);

                //在以下方法中,我们存储前一个步骤的时间并且重置秒表,以此逐步测量启动时间。
                //In the method InvokeLaunchLogThenStart(args), we storage the time span of the previous process and restart the watch in order that the time used in each step is recorded.
                InvokeLaunchLogThenStart("解析游戏", ref prevSpan, ref stopwatch);

                //错误处理
                //Error processor
                if (version == null)
                {
                    return(new LaunchResult
                    {
                        ErrorType = LaunchErrorType.OperationFailed,
                        Error = new ErrorModel
                        {
                            Error = "解析游戏失败",
                            ErrorMessage = "我们在解析游戏时出现了错误",
                            Cause = "这有可能是因为您的游戏JSON文件损坏所导致的问题"
                        }
                    });
                }
                #endregion

                #region 验证账户凭据 Legal Account Verifier

                //以下代码实现了账户模式从离线到在线的切换。
                //The following code switches account mode between offline and yggdrasil.
                var authResult = settings.Authenticator switch
                {
                    OfflineAuthenticator off => off.Auth(false),
                    YggdrasilAuthenticator ygg => await ygg.AuthTaskAsync(true).ConfigureAwait(true),
                    _ => null
                };
                InvokeLaunchLogThenStart("验证账户凭据", ref prevSpan, ref stopwatch);

                //错误处理
                //Error processor
                if (authResult == null || authResult.AuthStatus == AuthStatus.Failed ||
                    authResult.AuthStatus == AuthStatus.Unknown)
                {
                    return(new LaunchResult
                    {
                        LaunchSettings = settings,
                        Error = new ErrorModel
                        {
                            Error = "验证失败",
                            Cause = authResult == null ? "未知的验证器" : authResult.AuthStatus switch
                            {
                                AuthStatus.Failed => "可能是因为用户名或密码错误,或是验证服务器暂时未响应",
                                AuthStatus.Unknown => "未知错误",
                                _ => "未知错误"
                            },
                            ErrorMessage = "无法验证凭据的有效性"
                        }
 void Start()
 {
     launchSettings = GameObject.Find("LaunchSettings").GetComponent<LaunchSettings>();
 }
Example #17
0
        public void Write(UserProfile profile, BindableCollection <Addon> addons, BindableCollection <LaunchParameter> parameters, LaunchSettings launchSettings)
        {
            Logger.LogDebug("ProfileService", "Writing profile to disk");

            try
            {
                ProfileFile profileFile = new ProfileFile
                {
                    Profile        = profile,
                    Addons         = addons ?? new BindableCollection <Addon>(),
                    Parameters     = parameters ?? new BindableCollection <LaunchParameter>(),
                    LaunchSettings = launchSettings ?? new LaunchSettings()
                };

                if (!_fileAccessor.DirectoryExists(Path.Combine(ApplicationConfig.ConfigPath, ApplicationConfig.ProfilesFolder)))
                {
                    _fileAccessor.CreateDirectory(Path.Combine(ApplicationConfig.ConfigPath, ApplicationConfig.ProfilesFolder));
                }

                _fileAccessor.WriteAllText(Path.Combine(ApplicationConfig.ConfigPath, ApplicationConfig.ProfilesFolder, string.Format(ApplicationConfig.ProfileNameFormat, profile.Id)),
                                           JsonConvert.SerializeObject(profileFile, ApplicationConfig.JsonFormatting));
            }
            catch (Exception e)
            {
                Logger.LogException("ProfileService", "Error writing profile", e);
            }
        }
Example #18
0
        public void PortLegacyProfiles(BindableCollection <UserProfile> profiles)
        {
            Logger.LogInfo("ProfileService", "Porting legacy profiles");

            foreach (var profile in profiles)
            {
                try
                {
                    var profileFile    = Path.Combine(ApplicationConfig.ConfigPath, ApplicationConfig.ProfilesFolder, string.Format(ApplicationConfig.LegacyProfileNameFormat, profile.Name));
                    var profileContent = _fileAccessor.ReadAllText(profileFile);

                    BindableCollection <Addon>           addons     = new BindableCollection <Addon>();
                    BindableCollection <LaunchParameter> parameters = new BindableCollection <LaunchParameter>();
                    LaunchSettings launchSettings = new LaunchSettings();

                    using (StringReader stringReader = new StringReader(profileContent))
                        using (XmlReader reader = XmlReader.Create(stringReader))
                        {
                            while (reader.Read())
                            {
                                if (!reader.IsStartElement())
                                {
                                    continue;
                                }

                                string parameter;
                                string value;
                                bool   parsed;
                                switch (reader.Name)
                                {
                                case "Parameter":
                                    parameter = reader["name"];
                                    reader.Read();
                                    value = reader.Value.Trim();
                                    if (parameter != null)
                                    {
                                        var matchingParameter = _parameterService.Parameters.FirstOrDefault(p => p.LegacyName.Equals(parameter));
                                        if (matchingParameter != null)
                                        {
                                            switch (matchingParameter)
                                            {
                                            case BooleanParameter b:
                                                bool parsedValue;
                                                parsed = bool.TryParse(value, out parsedValue);
                                                b.SetStatus(parsed && parsedValue);
                                                break;

                                            case SelectionParameter s:
                                                //No legacy conversion
                                                break;

                                            case NumericalParameter n:
                                                //No legacy conversion
                                                break;

                                            case TextParameter t:
                                                t.SetStatus(true, value);
                                                break;

                                            default:
                                                Logger.LogException("ProfileService", "Matching parameter type not found", new ArgumentOutOfRangeException());
                                                break;
                                            }
                                            parameters.Add(matchingParameter);
                                        }
                                    }
                                    break;

                                case "A3Addon":
                                    parameter = reader["name"];
                                    reader.Read();
                                    bool enabled;
                                    parsed = bool.TryParse(reader.Value.Trim(), out enabled);
                                    if (parameter != null && parsed)
                                    {
                                        var addon = new Addon
                                        {
                                            IsEnabled = enabled,
                                            Name      = parameter
                                        };
                                        addons.Add(addon);
                                    }
                                    break;

                                case "A3ServerInfo":
                                    parameter = reader["name"];
                                    reader.Read();
                                    value = reader.Value.Trim();
                                    switch (parameter)
                                    {
                                    case "server":
                                        launchSettings.Server = value;
                                        break;

                                    case "port":
                                        launchSettings.Port = value;
                                        break;

                                    case "pass":
                                        launchSettings.Password = _securityService.EncryptPassword(value);
                                        break;

                                    default:
                                        break;
                                    }
                                    break;

                                default:
                                    break;
                                }
                            }
                        }

                    Write(profile, addons, parameters, launchSettings);
                    _fileAccessor.DeleteFile(profileFile);
                }
                catch (Exception e)
                {
                    Logger.LogException("ProfileService", "Error porting legacy profile", e);
                }
            }
        }
    void Start()
    {
        levelDB = GetComponent<LevelDataBase>();
        levelLoad = GetComponent<LevelLoaded>();

        launchSettings = GameObject.Find("LaunchSettings").GetComponent<LaunchSettings>();

        launchSettings.SetAllToFalse();
    }
Example #20
0
 internal void ResetToDefaults()
 {
     Logger.Info("Resetting game launcher settings to defaults.");
     LoadSettings(LaunchSettings.DefaultSettings());
 }
        private void LoadSettings(LaunchSettings launchSettings)
        {
            HasLoaded = false;

            if (Sys.Settings.GameLaunchSettings == null)
            {
                Logger.Warn("No game launcher settings found, initializing to defaults.");
                Sys.Settings.GameLaunchSettings = LaunchSettings.DefaultSettings();
                launchSettings = Sys.Settings.GameLaunchSettings;
            }

            ProgramList = new ObservableCollection <ProgramToRunViewModel>(Sys.Settings.ProgramsToLaunchPrior.Select(s => new ProgramToRunViewModel(s.PathToProgram, s.ProgramArgs)));

            AutoUpdatePathChecked = launchSettings.AutoUpdateDiscPath;
            Code5FixChecked       = launchSettings.Code5Fix;
            HighDpiFixChecked     = launchSettings.HighDpiFix;

            IsShowLauncherChecked    = launchSettings.ShowLauncherWindow;
            SelectedGameConfigOption = InGameConfigurationMap.Where(s => s.Value == launchSettings.InGameConfigOption)
                                       .Select(c => c.Key)
                                       .FirstOrDefault();

            if (string.IsNullOrWhiteSpace(SelectedGameConfigOption))
            {
                // default to first option if their previous option is missing
                SelectedGameConfigOption = InGameConfigOptions[0];
            }


            // disable options to auto-mount if user OS does not support it
            IsAutoMountSupported = GameLauncher.OSHasAutoMountSupport();

            if (IsAutoMountSupported)
            {
                AutoMountChecked   = launchSettings.AutoMountGameDisc;
                AutoUnmountChecked = launchSettings.AutoUnmountGameDisc;
            }
            else
            {
                AutoMountChecked   = false;
                AutoUnmountChecked = false;
            }

            // Have option look unchecked and disabled when user does not have The Reunion installed
            IsReunionInstalled = GameLauncher.IsReunionModInstalled();
            if (IsReunionInstalled)
            {
                DisableReunionChecked = launchSettings.DisableReunionOnLaunch;
            }
            else
            {
                DisableReunionChecked = false;
                IsReunionInstalled    = false;
            }


            SelectedSoundDevice = SoundDeviceGuids.Where(s => s.Value == launchSettings.SelectedSoundDevice)
                                  .Select(s => s.Key)
                                  .FirstOrDefault();

            // switch back to 'Auto' if device not found
            if (SelectedSoundDevice == null)
            {
                SelectedSoundDevice = SoundDeviceGuids.Where(s => s.Value == Guid.Empty)
                                      .Select(s => s.Key)
                                      .FirstOrDefault();
            }

            SelectedMidiDevice = MidiDeviceMap.Where(s => s.Value == launchSettings.SelectedMidiDevice)
                                 .Select(s => s.Key)
                                 .FirstOrDefault();

            MusicVolumeValue         = launchSettings.MusicVolume;
            SfxVolumeValue           = launchSettings.SfxVolume;
            IsReverseSpeakersChecked = launchSettings.ReverseSpeakers;
            IsLogVolumeChecked       = launchSettings.LogarithmicVolumeControl;

            SelectedRenderer = RendererMap.Where(s => s.Value == launchSettings.SelectedRenderer)
                               .Select(s => s.Key)
                               .FirstOrDefault();

            IsRivaOptionChecked    = launchSettings.UseRiva128GraphicsOption;
            IsTntOptionChecked     = launchSettings.UseTntGraphicsOption;
            IsQuarterScreenChecked = launchSettings.QuarterScreenMode;
            IsFullScreenChecked    = launchSettings.FullScreenMode;

            HasLoaded = true;
        }