Example #1
0
        public static bool IsModLoaderInstalled(string gameFolderPath)
        {
            try
            {
                if (Directory.Exists(gameFolderPath) == false)
                {
                    return(false);
                }
                if (Directory.Exists(Shrek2Utils.GetGameSystemFolderPath(gameFolderPath)) == false)
                {
                    return(false);
                }
                if (File.Exists(Path.Combine(Shrek2Utils.GetGameSystemFolderPath(gameFolderPath), Shrek2Utils.SHREK2MM_MODLOADER_FILE_EXE)) == false)
                {
                    return(false);
                }
                if (File.Exists(Path.Combine(Shrek2Utils.GetGameSystemFolderPath(gameFolderPath), Shrek2Utils.SHREK2MM_MODLOADER_FILE_INT)) == false)
                {
                    return(false);
                }
                if (File.Exists(Path.Combine(Shrek2Utils.GetGameSystemFolderPath(gameFolderPath), Shrek2Utils.SHREK2MM_MODLOADER_FILE_DLL)) == false)
                {
                    return(false);
                }

                return(true);
            }
            catch (Exception ex)
            {
                Shrek2Utils.LogError(ex);
                return(false);
            }
        }
Example #2
0
        public static bool UpdateDefUserFile(string gameFolderPath, List <Shrek2ModListItem> mods)
        {
            try
            {
                if (mods == null || mods.Count <= 0)
                {
                    return(false);
                }
                if (IsModLoaderInstalled(gameFolderPath) == false)
                {
                    return(false);
                }

                var backupDefUserFilePath = Path.Combine(Shrek2Utils.GetGameSystemFolderPath(gameFolderPath), Shrek2Utils.SHREK2MM_DEF_USER_BACKUP_FILE);
                var defUserFilePath       = Path.Combine(Shrek2Utils.GetGameSystemFolderPath(gameFolderPath), Shrek2Utils.SHREK2MM_DEF_USER_FILE);

                if (File.Exists(backupDefUserFilePath) == false)
                {
                    File.Copy(defUserFilePath, backupDefUserFilePath, true);
                }

                var lines = File.ReadAllLines(defUserFilePath);

                string execString = "";
                int    x          = 1;
                foreach (var installedMod in mods)
                {
                    if (x == mods.Count)
                    {
                        execString += "exec " + installedMod.UUID.Replace(" ", "");
                    }
                    else
                    {
                        execString += "exec " + installedMod.UUID.Replace(" ", "") + " | ";
                    }

                    x++;
                }

                for (int i = 0; i < lines.Length; i++)
                {
                    if (lines[i].Contains("F24="))
                    {
                        lines[i] = "F24=" + execString;
                    }
                }

                File.WriteAllLines(defUserFilePath, lines);
                return(true);
            }
            catch (Exception ex)
            {
                Shrek2Utils.LogError(ex);
                return(false);
            }
        }
Example #3
0
        public static bool InstallModLoader(string gameFolderPath)
        {
            try
            {
                if (IsModLoaderInstalled(gameFolderPath))
                {
                    return(true);
                }

                if (Directory.Exists(gameFolderPath) == false)
                {
                    return(false);
                }
                if (Directory.Exists(Shrek2Utils.GetGameSystemFolderPath(gameFolderPath)) == false)
                {
                    return(false);
                }

                if (Directory.Exists(Shrek2Utils.GetGameSystemModsFolderPath(gameFolderPath)) == false)
                {
                    Directory.CreateDirectory(Shrek2Utils.GetGameSystemModsFolderPath(gameFolderPath));
                }

                var     zipFilePath = Shrek2Utils.GetModLoaderZipFilePath();
                var     targetDir   = Shrek2Utils.GetGameSystemFolderPath(gameFolderPath);
                FastZip fastZip     = new FastZip();

                fastZip.ExtractZip(zipFilePath, targetDir, null);

                return(true);
            }
            catch (Exception ex)
            {
                Shrek2Utils.LogError(ex);
                return(false);
            }
        }