Ejemplo n.º 1
0
        private void ReadNewFilesFromRestore()
        {
            RestoreNewFilesList.Clear();
            AAPakFileInfo rnfl = restorepak.nullAAPakFileInfo;

            if (restorepak.GetFileByName(ModNewFilesFileName, ref rnfl))
            {
                var rf = restorepak.ExportFileAsStream(rnfl);
                var s  = AAPak.StreamToString(rf);
                RestoreNewFilesList.AddRange(s.Split('\n').ToArray());
            }
        }
Ejemplo n.º 2
0
        private bool HandleArgs()
        {
            bool showHelp = false;

            var args = Environment.GetCommandLineArgs();

            for (int i = 1; i < args.Length; i++)
            {
                var    larg    = args[i].ToLower();
                string nextArg = "";
                if (i < args.Length - 1)
                {
                    nextArg = args[i + 1];
                }


                switch (larg)
                {
                case "-m":
                    // Mod source
                    ModPakFileName = nextArg;
                    i++;
                    break;

                case "-g":
                    // Game_Pak
                    GamePakFileName = nextArg;
                    i++;
                    break;

                case "-r":
                    // restore pak
                    RestorePakFileName = nextArg;
                    i++;
                    break;

                case "-?":
                case "-h":
                case "-help":
                case "/?":
                case "/h":
                case "/help":
                    // Help
                    showHelp = true;
                    break;
                }
            }


            if (showHelp)
            {
                Hide();
                MessageBox.Show(helpText, "AAMod - Command-Line Help", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return(false);
            }

            // if nothing specified, try self
            if (ModPakFileName == string.Empty)
            {
                ModPakFileName = Application.ExecutablePath;
                Text           = DefaultTitle + " - Self-Extractor - " + Path.GetFileNameWithoutExtension(Application.ExecutablePath);
            }
            else
            {
                Text = DefaultTitle + " - " + ModPakFileName;
            }

            if (!File.Exists(ModPakFileName))
            {
                MessageBox.Show("Mod-file not found\n" + ModPakFileName, "aamod Open Error", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                return(false);
            }
            if (!modpak.OpenPak(ModPakFileName, true))
            {
                if (ModPakFileName == Application.ExecutablePath)
                {
                    // show a different error if you tried to open it without any parameters and tried to use the exe as a pak and failed
                    Visible = false;
                    MessageBox.Show("This program cannot be used as a stand-alone program.\n" +
                                    "You either need to provide command-line arguments or this file needs to be generated by AAPakEditor to contain pak information.\n\n" +
                                    "Use -? to get a list of possible arguments.", "AAMod Open Error", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                }
                else
                {
                    MessageBox.Show("Failed to open mod-file for reading\n" + ModPakFileName, "aamod Open Error", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                }
                return(false);
            }


            if (modpak.FileExists(ModInfoFileName))
            {
                var infoStream = modpak.ExportFileAsStream(ModInfoFileName);
                var tw         = AAPak.StreamToString(infoStream);
                tDescription.Text = tw;
            }
            else
            {
                tDescription.Text = "No description provided for this mod file.";
            }
            tDescription.SelectionLength = 0;

            if (modpak.FileExists(ModPNGImageFileName))
            {
                var picStream = modpak.ExportFileAsStream(ModPNGImageFileName);
                var img       = Image.FromStream(picStream);
                modIcon.Image = img;
            }
            else
            if (modpak.FileExists(ModJPGImageFileName))
            {
                var picStream = modpak.ExportFileAsStream(ModJPGImageFileName);
                var img       = Image.FromStream(picStream);
                modIcon.Image = img;
            }


            while (!File.Exists(GamePakFileName))
            {
                if (openGamePakDlg.ShowDialog() == DialogResult.OK)
                {
                    GamePakFileName = openGamePakDlg.FileName;
                }
                else
                {
                    return(false);
                }
            }
            Refresh();
            lInstallLocation.Text = "Loading, please wait ...";
            lInstallLocation.Refresh();
            TryLoadCustomKey(gamepak, GamePakFileName);
            if (gamepak.OpenPak(GamePakFileName, false))
            {
                lInstallLocation.Text = GamePakFileName;
            }
            else
            {
                MessageBox.Show("Failed to open ArcheAge game pak for writing\n" + GamePakFileName, "game_pak Open Error", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                return(false);
            }

            if (RestorePakFileName == string.Empty)
            {
                RestorePakFileName = Path.GetDirectoryName(GamePakFileName).TrimEnd(Path.DirectorySeparatorChar) + Path.DirectorySeparatorChar + ".aamod" + Path.DirectorySeparatorChar + "restore_pak";
            }

            if (File.Exists(RestorePakFileName))
            {
                if (!restorepak.OpenPak(RestorePakFileName, false))
                {
                    MessageBox.Show("Failed to open mod uninstall file for writing\n" + RestorePakFileName + "\n\nThis is most likely due to a corrupted restore file. Previously backed-up data is lost !", "restore_pak Open Error", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                    restorepak.ClosePak();
                    if (MessageBox.Show("Do you want to create a new restore file ?\nThis step is required to be able to continue.", "Re-Create backup file", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                    {
                        if (!restorepak.NewPak(RestorePakFileName))
                        {
                            MessageBox.Show("Failed to re-create mod uninstall file\n" + RestorePakFileName, "restore_pak Create Error", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                            return(false);
                        }
                    }
                    else
                    {
                        return(false);
                    }
                }
            }
            else
            {
                try
                {
                    Directory.CreateDirectory(Path.GetDirectoryName(RestorePakFileName));
                }
                catch
                {
                    MessageBox.Show("Failed to create mod uninstall directory for \n" + RestorePakFileName, "restore_pak Directory Error", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                    return(false);
                }
                // create a new one if none exists yet
                if (!restorepak.NewPak(RestorePakFileName))
                {
                    MessageBox.Show("Failed to create mod uninstall file\n" + RestorePakFileName, "restore_pak Create Error", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                    return(false);
                }
            }

            ReadNewFilesFromRestore();
            // TODO: continue work here

            return(true);
        }