Esempio n. 1
0
        /// <summary>
        /// Returns the argument string to launch the game with.
        /// </summary>
        /// <returns>Argument string.</returns>
        private string GetLaunchArguments(GameArguments gameArgs)
        {
            var args = new StringBuilder();

            // Add Six Updater arguments
            foreach (var param in gameArgs.AppParams)
            {
                if (!String.IsNullOrEmpty(param) && param != "-")
                {
                    args.AppendFormat("{0} ", param);
                }
            }

            // Add custom arguments
            if (!String.IsNullOrEmpty(cmdOptions.CustomArguments))
            {
                foreach (var arg in cmdOptions.CustomArguments.Split(' '))
                {
                    args.AppendFormat("-{0} ", arg);
                }
            }

            // Add -mod argument if there are any mods
            if (!String.IsNullOrEmpty(gameArgs.Mods) || gameArgs.Folders.Count() > 0)
            {
                args.Append("\"-mod=");

                // Add six updater defined mods
                if (!String.IsNullOrEmpty(gameArgs.Mods))
                {
                    args.AppendFormat("{0};", gameArgs.Mods);
                }

                // Add preset mods
                if (gameArgs.Folders.Count() > 0)
                {
                    foreach (var folder in gameArgs.Folders)
                    {
                        // If modpath is empty, then we use the default app mod path
                        var modPath = folder.Path;
                        if (String.IsNullOrEmpty(folder.Path))
                        {
                            modPath = gameArgs.AppModPath;
                        }

                        // Add each mod defined in a folder
                        foreach (var mod in folder.Mods)
                        {
                            args.AppendFormat(@"{0}\{1};", modPath, mod);
                        }
                    }
                }

                // Close the -mod argument
                args.Append("\"");
            }

            return(args.ToString());
        }
Esempio n. 2
0
        /// <summary>
        /// Returns the game arguemnts mapped to six-updater-yml file.
        /// </summary>
        /// <returns>Mapped game arguments.</returns>
        public GameArguments GetGameArguments()
        {
            GameArguments gameArgs = null;

            try
            {
                // Open file and initialize YamlStream.
                using (FileStream fs = new FileStream(FindConfigPath(), FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
                {
                    using (StreamReader input = new StreamReader(fs))
                    {
                        yaml = new YamlStream();
                        yaml.Load(input);

                        var rootChildren = (yaml.Documents[0].RootNode as YamlMappingNode).Children;

                        // Read game arguemnts from YAML file.
                        gameArgs           = new GameArguments();
                        gameArgs.AppParams = (GetChildNodeByKey(rootChildren, ":app_params") as YamlSequenceNode).Select(par => (par as YamlScalarNode).Value).ToList();
                        gameArgs.AppPath   = (GetChildNodeByKey(rootChildren, ":app_path") as YamlScalarNode).Value;
                        gameArgs.AppExe    = (GetChildNodeByKey(rootChildren, ":app_exe") as YamlScalarNode).Value;
                        gameArgs.Mods      = (GetChildNodeByKey(rootChildren, ":mods") as YamlScalarNode).Value;

                        // If no mod forlder is given, use the game's folder
                        var appModPath = GetChildNodeByKey(rootChildren, ":app_modpath") as YamlScalarNode;
                        if (appModPath == null)
                        {
                            gameArgs.AppModPath = gameArgs.AppPath;
                        }
                        else
                        {
                            gameArgs.AppModPath = appModPath.Value;
                        }

                        var yamlFolders = (GetChildNodeByKey(rootChildren, ":folders") as YamlSequenceNode).Children;
                        gameArgs.Folders = (from fold in yamlFolders
                                            let path = (GetChildNodeByKey((fold as YamlMappingNode).Children, ":path") as YamlScalarNode).Value
                                                       let mods = (GetChildNodeByKey((fold as YamlMappingNode).Children, ":mods") as YamlSequenceNode).Select(m => (m as YamlScalarNode).Value).ToList()
                                                                  select new Folder {
                            Path = path, Mods = mods
                        }).ToList();
                    }
                }
            }
            catch (Exception e)
            {
                throw e;
            }

            return(gameArgs);
        }
Esempio n. 3
0
        /// <summary>
        /// Returns the game arguemnts mapped to six-updater-yml file.
        /// </summary>
        /// <returns>Mapped game arguments.</returns>
        public GameArguments GetGameArguments()
        {
            GameArguments gameArgs = null;
            try
            {
                // Open file and initialize YamlStream.
                using (FileStream fs = new FileStream(FindConfigPath(), FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
                {
                    using (StreamReader input = new StreamReader(fs))
                    {
                        yaml = new YamlStream();
                        yaml.Load(input);

                        var rootChildren = (yaml.Documents[0].RootNode as YamlMappingNode).Children;

                        // Read game arguemnts from YAML file.
                        gameArgs = new GameArguments();
                        gameArgs.AppParams   = (GetChildNodeByKey(rootChildren, ":app_params") as YamlSequenceNode).Select(par => (par as YamlScalarNode).Value).ToList();
                        gameArgs.AppPath     = (GetChildNodeByKey(rootChildren, ":app_path") as YamlScalarNode).Value;
                        gameArgs.AppExe      = (GetChildNodeByKey(rootChildren, ":app_exe") as YamlScalarNode).Value;
                        gameArgs.Mods        = (GetChildNodeByKey(rootChildren, ":mods") as YamlScalarNode).Value;

                        // If no mod forlder is given, use the game's folder
                        var appModPath = GetChildNodeByKey(rootChildren, ":app_modpath") as YamlScalarNode;
                        if (appModPath == null)
                        {
                            gameArgs.AppModPath = gameArgs.AppPath;
                        }
                        else
                        {
                            gameArgs.AppModPath = appModPath.Value;
                        }

                        var yamlFolders = (GetChildNodeByKey(rootChildren, ":folders") as YamlSequenceNode).Children;
                        gameArgs.Folders = (from fold in yamlFolders
                                               let path = (GetChildNodeByKey((fold as YamlMappingNode).Children, ":path") as YamlScalarNode).Value
                                               let mods = (GetChildNodeByKey((fold as YamlMappingNode).Children, ":mods") as YamlSequenceNode).Select(m => (m as YamlScalarNode).Value).ToList()
                                               select new Folder { Path = path, Mods = mods }).ToList();
                    }
                }
            }
            catch (Exception e)
            {
                throw e;
            }

            return gameArgs;
        }
Esempio n. 4
0
        /// <summary>
        /// Returns the argument string to launch the game with.
        /// </summary>
        /// <returns>Argument string.</returns>
        private string GetLaunchArguments(GameArguments gameArgs)
        {
            var args = new StringBuilder();

            // Add Six Updater arguments
            foreach (var param in gameArgs.AppParams)
            {
                if (!String.IsNullOrEmpty(param) && param != "-")
                {
                    args.AppendFormat("{0} ", param);
                }
            }

            // Add custom arguments
            if (!String.IsNullOrEmpty(cmdOptions.CustomArguments))
            {
                foreach (var arg in cmdOptions.CustomArguments.Split(' '))
                {
                    args.AppendFormat("-{0} ", arg);
                }
            }

            // Add -mod argument if there are any mods
            if (!String.IsNullOrEmpty(gameArgs.Mods) || gameArgs.Folders.Count() > 0)
            {

                args.Append("\"-mod=");

                // Add six updater defined mods
                if (!String.IsNullOrEmpty(gameArgs.Mods))
                {

                    args.AppendFormat("{0};", gameArgs.Mods);
                }

                // Add preset mods
                if (gameArgs.Folders.Count() > 0)
                {
                    foreach (var folder in gameArgs.Folders)
                    {
                        // If modpath is empty, then we use the default app mod path
                        var modPath = folder.Path;
                        if (String.IsNullOrEmpty(folder.Path))
                        {
                            modPath = gameArgs.AppModPath;
                        }

                        // Add each mod defined in a folder
                        foreach (var mod in folder.Mods)
                        {
                            args.AppendFormat(@"{0}\{1};", modPath, mod);
                        }
                    }
                }

                // Close the -mod argument
                args.Append("\"");
            }

            return args.ToString();
        }