예제 #1
0
 public LibrariesForm(Launcher launcher)
 {
     this.launcher = launcher;
     InitializeComponent();
 }
예제 #2
0
        public Dictionary <string, Mod> GetModsList(Launcher launcher)
        {
            Dictionary <string, Mod> mods = LoadMods(launcher);

            return(mods);
        }
예제 #3
0
        /// <summary>
        /// Loads all the mods with the same game app id of the specified game
        /// </summary>
        /// <param name="game">The base game name (i.e. Source SDK Base 2013 Singleplayer)</param>
        /// <returns></returns>
        public Dictionary <string, Mod> LoadMods(Launcher launcher)
        {
            mods = new Dictionary <string, Mod>();

            int    gameAppId = GetAppId();
            string gamePath  = installPath;

            if ((gameAppId == -1 && engine != Engine.GOLDSRC) || gamePath == null)
            {
                return(mods);
            }

            List <string> paths = new List <string>();

            switch (engine)
            {
            case Engine.SOURCE:
                paths.AddRange(GetAllModPaths(launcher));

                foreach (string path in GetAllBaseGameinfoFolders())
                {
                    paths.Add(gamePath + "\\" + path);
                }
                break;

            case Engine.SOURCE2:
                foreach (string path in GetAllBaseGameinfoFolders())
                {
                    paths.Add(gamePath + "\\game\\" + path);
                }
                break;

            case Engine.GOLDSRC:
                foreach (string path in GetAllBaseGameinfoFolders())
                {
                    paths.Add(gamePath + "\\" + path);
                }
                break;
            }

            foreach (string path in paths)
            {
                switch (engine)
                {
                case Engine.SOURCE:
                {
                    SourceSDK.KeyValue gameInfo = SourceSDK.KeyValue.readChunkfile(path + "\\gameinfo.txt");

                    if (gameInfo != null)
                    {
                        string name     = gameInfo.getChildByKey("game").getValue() + " (" + new DirectoryInfo(path).Name + ")";
                        string modAppId = gameInfo.getChildByKey("filesystem").getChildByKey("steamappid").getValue();

                        if (int.Parse(modAppId) == gameAppId || path.Contains(gamePath) && !(mods.Values.Where(p => p.installPath == path).ToList().Count == 0))
                        {
                            bool   containsMod = false;
                            string newModPath  = new FileInfo(path).Name;
                            foreach (Mod mod in mods.Values)
                            {
                                if (new FileInfo(mod.installPath).Name == newModPath)
                                {
                                    containsMod = true;
                                    break;
                                }
                            }
                            if (!containsMod)
                            {
                                while (mods.Keys.Contains(name))
                                {
                                    name = name + "_";
                                }
                                mods.Add(name, new Mod(this, name, path));
                            }
                        }
                    }
                    else
                    {
                        XtraMessageBox.Show("Could not load mod " + path + ". It's gameinfo.txt is broken.");
                    }
                }
                break;

                case Engine.SOURCE2:
                {
                    SourceSDK.KeyValue gameInfo = SourceSDK.KeyValue.readChunkfile(path + "\\gameinfo.gi");

                    if (gameInfo != null)
                    {
                        string name = gameInfo.getChildByKey("game").getValue() + " (" + new DirectoryInfo(path).Name + ")";
                        //string modAppId = gameInfo.getChildByKey("filesystem").getChildByKey("steamappid").getValue();

                        if (path.Contains(gamePath) && (mods.Values.Where(p => p.installPath == path).ToList().Count == 0))
                        {
                            bool   containsMod = false;
                            string newModPath  = new FileInfo(path).Name;
                            foreach (Mod mod in mods.Values)
                            {
                                if (new FileInfo(mod.installPath).Name == newModPath)
                                {
                                    containsMod = true;
                                    break;
                                }
                            }
                            if (!containsMod)
                            {
                                while (mods.Keys.Contains(name))
                                {
                                    name = name + "_";
                                }
                                mods.Add(name, new Mod(this, name, path));
                            }
                        }
                    }
                    else
                    {
                        XtraMessageBox.Show("Could not load mod " + path + ". It's gameinfo.gi is broken.");
                    }
                }
                break;

                case Engine.GOLDSRC:
                {
                    SourceSDK.KeyValue gameInfo = SourceSDK.Config.readChunkfile(path + "\\liblist.gam");

                    if (gameInfo != null)
                    {
                        string name = gameInfo.getChildByKey("game").getValue() + " (" + new DirectoryInfo(path).Name + ")";
                        //string modAppId = gameInfo.getChildByKey("filesystem").getChildByKey("steamappid").getValue();

                        if (path.Contains(gamePath))
                        {
                            bool   containsMod = false;
                            string newModPath  = new FileInfo(path).Name;
                            foreach (Mod mod in mods.Values)
                            {
                                if (new FileInfo(mod.installPath).Name == newModPath)
                                {
                                    containsMod = true;
                                    break;
                                }
                            }
                            if (!containsMod)
                            {
                                while (mods.Keys.Contains(name))
                                {
                                    name = name + "_";
                                }
                                mods.Add(name, new Mod(this, name, path));
                            }
                        }
                    }
                    else
                    {
                        XtraMessageBox.Show("Could not load mod " + path + ". It's liblist.gam is broken.");
                    }
                }
                break;
                }
            }

            return(mods);
        }
 public SearchPathsForm(Launcher launcher)
 {
     this.launcher = launcher;
     InitializeComponent();
 }