Exemplo n.º 1
0
        /// <summary>
        /// Download the mods archive to the directory selected by user.
        /// </summary>
        /// <param name="modItem"></param>
        public void DownloadModArchive(ModsData.ModItem modItem)
        {
            try
            {
                using (FolderBrowserDialog folderBrowser = new FolderBrowserDialog()
                {
                    ShowNewFolderButton = true
                })
                {
                    if (folderBrowser.ShowDialog() == DialogResult.OK)
                    {
                        SetStatus($"{modItem.Name} ({modItem.GetGameType()}) - Downloading archive...");

                        modItem.DownloadArchiveAtPath(folderBrowser.SelectedPath);

                        SetStatus($"{modItem.Name} ({modItem.GetGameType()}) - Successfully downloaded archive at path: {folderBrowser.SelectedPath}");
                    }
                    else
                    {
                        SetStatus($"{modItem.Name} ({modItem.GetGameType()}) - Cancelled archive download.");
                    }
                }
            }
            catch (Exception ex)
            {
                SetStatus($"Error download archive '{modItem.Name} ({modItem.Id}) (Access maybe denied to this path, try a different one) - {ex.Message}", ex);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Set the UI to display the selected mod details.
        /// </summary>
        /// <param name="modId">Mod Id to display information</param>
        private void ShowModDetails(int modId)
        {
            ModsData.ModItem modItem = Database.Mods.GetModById(modId);

            if (modItem == null)
            {
                return;
            }

            // Get the mod data from the specified modId

            // Set the selected mod item property
            SelectedModItem = modItem;

            // Display details in UI
            LabelHeaderNameNo.Text = modItem.Name;
            LabelGameType.Text     = modItem.GetGameType();
            LabelModType.Text      = modItem.GetModType();
            LabelVersion.Text      = modItem.Version;
            LabelAuthor.Text       = modItem.CreatedBy.Replace("&", "&&");
            LabelSubmittedBy.Text  = modItem.SubmittedBy.Replace("&", "&&");
            LabelDescription.Text  = string.IsNullOrWhiteSpace(modItem.Description) ? "Can't find any description for this yet." : modItem.Description.Replace("&", "&&");

            ToolItemInstall.Enabled = IsConsoleConnected;

            ToolItemUninstall.Enabled = SettingsData.GetInstalledGameMod(modItem.GetGameType()) != null &&
                                        IsConsoleConnected &&
                                        SettingsData.GetInstalledGameMod(modItem.GetGameType()).ModId.Equals(modItem.Id);

            UpdateScrollBarDetails();
        }
Exemplo n.º 3
0
 /// <summary>
 ///     Download modded files from the URL of the ModsData to the path specified by the user
 /// </summary>
 /// <param name="modItem">Mod to download</param>
 /// <param name="downloadPath">Mod to download</param>
 internal static void DownloadModToLocation(ModsData.ModItem modItem, string downloadPath)
 {
     using (var wc = new WebClient())
     {
         wc.Headers.Add("Accept: application/zip");
         wc.Headers.Add("User-Agent: Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)");
         wc.DownloadFile(new Uri(modItem.Url),
                         $"{downloadPath}/{modItem.Name} (v{modItem.Version}) ({modItem.Author}).zip");
     }
 }
Exemplo n.º 4
0
 /// <summary>
 ///     Open a new issue template for reporting mods
 /// </summary>
 /// <param name="modItem">Mod info to fill with</param>
 internal static void OpenReportTemplate(ModsData.ModItem modItem)
 {
     Process.Start($"{ProjectRepoUrl}issues/new?" +
                   $"title=[Report] {modItem.Name} ({modItem.Type}) ({modItem.GameId.ToUpper()})" +
                   $"&labels=report-mod&" +
                   $"body=Mod Id: {modItem.Id}%0A" +
                   $"Author: {modItem.Author}%0A" +
                   $"Version: {modItem.Version}%0A" +
                   $"Configuration: {modItem.Configuration}%0A" +
                   $"Files: {string.Join(" | ", modItem.InstallPaths)}%0A" +
                   "----------------------- %0A" +
                   "*Please include some additional information about the issue you are experiencing, such as how to reproduce the problem, what happened before this occurred, etc...");
 }
Exemplo n.º 5
0
        /// <summary>
        ///     Open a new issue template for reporting mods
        /// </summary>
        /// <param name="modItem">Mod info to fill with</param>
        /// <param name="category">Mod info to fill with</param>
        internal static void OpenReportTemplate(ModsData.ModItem modItem, CategoriesData.Category category)
        {
            var formatModName = modItem.Name.Replace("%", "%25").Replace("(", "%28").Replace(")", "%29")
                                .Replace("&", "%26");

            var reportTemplate = "issues/new?"
                                 + $"title=%5BMOD REPORT%5D {formatModName} ({modItem.GameId.ToUpper()})"
                                 + "&labels=mod report&"
                                 + $"body=- Mod Name: {formatModName} (ID%23{modItem.Id})%0A"
                                 + $"- Category: {category.Title}%0A"
                                 + $"- Mod Type: {modItem.Type}%0A"
                                 + $"- Author: {modItem.Author}%0A"
                                 + $"- Version: {modItem.Version}%0A"
                                 + "----------------------- %0A"
                                 + "*Please include additional information about the issue, details such as how to reproduce the problem, what happened before this occurred, etc...";

            _ = Process.Start(Urls.GitHubRepo + reportTemplate);
        }
Exemplo n.º 6
0
        /// <summary>
        ///     Create/store a backup of the specified file, and then downloads it locally to a known path
        /// </summary>
        /// <param name="modItem"></param>
        /// <param name="fileName"></param>
        /// <param name="installFilePath"></param>
        public void CreateBackupFile(ModsData.ModItem modItem, string fileName, string installFilePath)
        {
            var fileBackupFolder = GetBackupFileFolder(modItem);

            _ = Directory.CreateDirectory(fileBackupFolder);

            var backupFile = new BackupFile
            {
                CategoryId  = modItem.GameId,
                FileName    = fileName,
                LocalPath   = Path.Combine(fileBackupFolder, fileName),
                InstallPath = installFilePath
            };

            FtpExtensions.DownloadFile(backupFile.LocalPath, backupFile.InstallPath);

            BackupFiles.Add(backupFile);
        }
Exemplo n.º 7
0
        /// <summary>
        ///     Uninstall modded files specified in the InstallPath from the users console, ignore game specific files as this
        ///     could cause game to stop working (only .sprx files)
        /// </summary>
        /// <param name="ipAddress">Console address to connect to</param>
        /// <param name="modItem">Mod to uninstall</param>
        internal static void UninstallModFiles(string ipAddress, ModsData.ModItem modItem)
        {
            foreach (string installFilePath in modItem.InstallPaths)
            {
                using (FtpConnection ps3 = new FtpConnection(ipAddress))
                {
                    string dirPath = installFilePath.Contains("/")
                        ? installFilePath.Substring(0, installFilePath.LastIndexOf('/')) + '/'
                        : "dev_hdd0/";

                    string fileName = installFilePath.Contains("/")
                        ? installFilePath.Substring(installFilePath.LastIndexOf('/')).Replace("/", "").Replace("//", "")
                        : installFilePath;

                    if (ps3.FileExists(installFilePath) && !installFilePath.StartsWith("dev_hdd0/game/{REGION}/", StringComparison.InvariantCultureIgnoreCase))
                    {
                        ps3.RemoveFile(installFilePath);
                    }
                }
            }
        }
Exemplo n.º 8
0
        private void DgvMods_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (DgvMods.CurrentRow != null)
            {
                ToolItemInstall.Enabled  = DgvMods.CurrentRow != null && IsConsoleConnected;
                ToolItemDownload.Enabled = DgvMods.CurrentRow != null;

                ModsData.ModItem modItem = Database.Mods.GetModById(int.Parse(DgvMods.CurrentRow.Cells[0].Value.ToString()));

                if (DgvMods.CurrentCell.ColumnIndex.Equals(6) && e.RowIndex != -1)
                {
                    if (IsConsoleConnected)
                    {
                        InjectModItem(modItem);
                    }
                }
                else if (DgvMods.CurrentCell.ColumnIndex.Equals(7) && e.RowIndex != -1)
                {
                    DownloadModArchive(modItem);
                }
            }
        }
Exemplo n.º 9
0
        /// <summary>
        ///     Sets the UI to display the selected mod's details
        /// </summary>
        /// <param name="modId">Id of the mod item</param>
        private void ShowModDetails(long modId)
        {
            ModsData.ModItem modDetails = Utilities.GetModById(ModsData, modId);

            // Set the selected mod item property
            SelectedModItem = modDetails;

            // Display details in UI
            LabelHeaderName.Text    = $"{modDetails.Name} ({modDetails.Type})";
            LabelByAuthor.Text      = $"by {modDetails.Author}";
            LabelVersion.Text       = modDetails.Version;
            LabelConfiguration.Text = modDetails.Configuration;
            LabelDescription.Text   = modDetails.Description;

            DgvInstallPaths.Rows.Clear();
            foreach (string file in modDetails.InstallPaths)
            {
                DgvInstallPaths.Rows.Add(file);
            }

            UpdateScrollBarDetails();
            UpdateScrollBarInstallPaths();
        }
Exemplo n.º 10
0
        /// <summary>
        ///     Downloads the compressed archive for the mods and then extracts the archive to the appdata path
        /// </summary>
        /// <param name="modItem">Mod to download</param>
        internal static void DownloadExtractFiles(ModsData.ModItem modItem)
        {
            string archivePath     = $"{AppDataPath}{modItem.Name}";
            string archiveFilePath = $"{AppDataPath}{modItem.Name}.zip";

            if (Directory.Exists(archivePath))
            {
                Directory.Delete(archivePath, true);
            }

            if (File.Exists(archiveFilePath))
            {
                File.Delete(archiveFilePath);
            }

            using (var wc = new WebClient())
            {
                wc.Headers.Add("Accept: application/zip");
                wc.Headers.Add("User-Agent: Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)");
                wc.DownloadFile(new Uri(modItem.Url), archiveFilePath);
                ZipFile.ExtractToDirectory(archiveFilePath, AppDataPath);
            }
        }
Exemplo n.º 11
0
 /// <summary>
 ///     Creates and returns the backup folder for the specified <see cref="ModsData.ModItem" />.
 /// </summary>
 /// <param name="modItem"></param>
 /// <returns></returns>
 public static string GetBackupFileFolder(ModsData.ModItem modItem)
 {
     return(Path.Combine(UserFolders.AppGameBackupFiles, modItem.GameId));
 }
Exemplo n.º 12
0
        /// <summary>
        /// Injects the specified GSC mods to the their correct game locations
        /// </summary>
        /// <param name="modItem"></param>
        private void InjectModItem(ModsData.ModItem modItem)
        {
            try
            {
                if (IsInGame())
                {
                    SetStatus($"You must be in pre-game lobby before injecting mods.");
                    XtraMessageBox.Show(this, "You must be in pre-game lobby before injecting mods.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    return;
                }

                ClearGscMods();
                LastUsedGscFiles.Clear();

                modItem.DownloadInstallFiles();

                // Free Memory Offsets
                uint freeMemoryOffset;

                if (ConsoleType.Equals("PS3"))
                {
                    freeMemoryOffset = 0x51000000;
                }
                else
                {
                    freeMemoryOffset = 0x40300000;
                }

                foreach (string installFilePath in modItem.InstallPaths)
                {
                    foreach (string localFilePath in Directory.GetFiles(modItem.GetDownloadDataPath(), "*.*", SearchOption.AllDirectories))
                    {
                        string installFileName = Path.GetFileName(installFilePath);

                        if (string.Equals(installFileName, Path.GetFileName(localFilePath), StringComparison.CurrentCultureIgnoreCase))
                        {
                            GscData.FileItem gscFileData = GetGscFileData(ConsoleType, modItem.GameType, installFilePath);

                            LastUsedGscFiles.Add(installFilePath);

                            byte[] gscFile = File.ReadAllBytes(localFilePath);

                            SetStatus($"{modItem.Name} v{modItem.Version} ({modItem.GetGameType()}) - Injecting GSC file: {installFileName} ...");

                            if (ConsoleType.Equals("PS3"))
                            {
                                PS3.Extension.WriteUInt32(gscFileData.Pointer, 0x51000000); // Overwrite script pointer
                                PS3.Extension.WriteBytes(0x51000000, gscFile);              // Write compiled script buffer to free memory location
                            }
                            else if (ConsoleType.Equals("XBOX"))
                            {
                                Xbox.WriteUInt32(gscFileData.Pointer, 0x40300000);
                                Xbox.WriteByte(0x40300000, gscFile);
                            }

                            /* TESTS FOR INJECTING MUTIPLE GSC FILES aZaZ..
                             * if (ConsoleType.Equals("PS3"))
                             * {
                             *  freeMemoryOffset = GET_ALIGNED_DWORD(freeMemoryOffset + 1);
                             *
                             *  PS3.Extension.WriteUInt32(gscFileData.Pointer, freeMemoryOffset); // Overwrite script pointer
                             *  PS3.Extension.WriteBytes(freeMemoryOffset, new byte[gscFile.Length + 1]);
                             *  PS3.Extension.WriteBytes(freeMemoryOffset, gscFile); // Write compiled script buffer to free memory location
                             *
                             *  freeMemoryOffset += (uint)(gscFile.Length + 1);
                             * }
                             * else if (ConsoleType.Equals("XBOX"))
                             * {
                             *  freeMemoryOffset = GET_ALIGNED_DWORD(freeMemoryOffset + 1);
                             *
                             *  XBOX.SetMemory(gscFileData.Pointer, BitConverter.GetBytes(freeMemoryOffset).Reverse().ToArray());
                             *  XBOX.SetMemory(freeMemoryOffset, new byte[gscFile.Length + 1]);
                             *  XBOX.SetMemory(freeMemoryOffset, gscFile);
                             *
                             *
                             *  freeMemoryOffset += (uint)(gscFile.Length + 1);
                             * }
                             *
                             *
                             * Xbox.WriteUInt32(gscFileData.Pointer, freeMemoryOffset);
                             */

                            SetStatus($"{modItem.Name} v{modItem.Version} ({modItem.GetGameType()}) - Injected GSC file: {installFileName}");
                            MenuItemClearGscMods.Enabled = true;
                        }
                    }
                }

                LastInjectedGameType = modItem.GameType;

                SettingsData.UpdateInstalledMod(modItem.GameType, modItem.Id);
                SaveSettingsData();

                if (ConsoleType.Equals("PS3"))
                {
                    NotifyMessagePS3("^2Injected GSC Mods", $"{modItem.Name} v{modItem.Version} by {modItem.CreatedBy}", "party_ready");
                }

                SetStatus($"{modItem.Name} v{modItem.Version} ({modItem.GetGameType()}) - Injected all GSC files.");

                XtraMessageBox.Show(this, $"Injected Mods: {modItem.Name}\nTime: {DateTime.Now:H:mm:ss}", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (Exception ex)
            {
                SetStatus($"Unable to inject GSC files. Error: {ex.Message}", ex);
                XtraMessageBox.Show(this, $"There was a problem injecting gsc files. Error: {ex.Message}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 13
0
        /// <summary>
        ///     Uninstall modded files specified in the InstallPath from the users console, ignore game specific files as this
        ///     could cause game to stop working (only .sprx files)
        /// </summary>
        /// <param name="ipAddress">Mod to uninstall</param>
        /// <param name="remoteFile">Mod to uninstall</param>
        /// <param name="modItem">Mod to uninstall</param>
        internal static void DownloadOriginalGameFile(string ipAddress, string remoteFile, ModsData.ModItem modItem)
        {
            /*foreach (var installFilePath in modInfo.InstallPaths)
             * {
             *  using (var ps3 = new FtpConnection(ipAddress))
             *  {
             *      if (ps3.FileExists(installFilePath) && !installFilePath.StartsWith("dev_hdd0/game/{REGION}/", StringComparison.InvariantCultureIgnoreCase))
             *          ps3.RemoveFile(installFilePath);
             *  }
             * }*/

            using (FtpConnection ps3 = new FtpConnection(ipAddress))
            {
                string dirPath = remoteFile.Contains("/")
                    ? remoteFile.Substring(0, remoteFile.LastIndexOf('/')) + '/'
                    : "dev_hdd0/";

                string fileName = remoteFile.Contains("/")
                    ? remoteFile.Substring(remoteFile.LastIndexOf('/')).Replace("/", "").Replace("//", "")
                    : remoteFile;

                string localFilePath = $@"{AppDataPath}{modItem.GameId}\{modItem.Name}\";

                Directory.CreateDirectory(localFilePath);

                ps3.SetCurrentDirectory(dirPath);
                ps3.GetFile(remoteFile, $@"{localFilePath}{fileName}".Replace("/", @"\"), false);
                //ps3.PutFile(localFile, fileName);
            }
        }