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>
        /// 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);
            }
        }