Exemplo n.º 1
0
        private void dLCBlueprintsToolStripMenuItem_Click(object sender, EventArgs e) //Open/ DLC GameTemplates.wsd
        {
            string path = Sabtool_Settings.returnGamePath();

            switch (path)
            {
            case "PathInvalid":
                MessageBox.Show("Has your game been moved? Your Saboteur Game Path is not valid, please re-select your Saboteur Game Path.");
                break;

            case "NoSettingsFile":
                MessageBox.Show("Please set the location of your Game Folder in Settings. Otherwise use Select Other and locate the file manually.");
                break;

            default:
                if (File.Exists(Path.Combine(path + "\\DLC\\01\\", "GameTemplates.wsd")))
                {
                    //MessageBox.Show("GameTemplates.wsd found.");
                    try
                    {
                        fileInput = File.Open(Path.Combine(path + "\\DLC\\01\\", "GameTemplates.wsd"), FileMode.Open);
                        loadBlueprintsWSD();
                    }
                    catch (Exception error)
                    {
                        Console.WriteLine("An error occurred: '{0}'", error);
                    }
                }
                else
                {
                    MessageBox.Show("File not found. Please double check your Game Path in settings. This system isn't perfect, you know.");
                }
                break;
            }
        }
        //////////////////////
        // Open Loose Files //
        //////////////////////
        private void openLoosefilesBinPCToolStripMenuItem_Click(object sender, EventArgs e)
        {
            string path = Sabtool_Settings.returnGamePath();

            switch (path)
            {
            case "PathInvalid":
                MessageBox.Show("Has your game been moved? Your Saboteur Game Path is not valid, please re-select your Saboteur Game Path.");
                break;

            case "NoSettingsFile":
                MessageBox.Show("Please set the location of your Game Folder in Settings. Otherwise use Select Other and locate the file manually.");
                break;

            default:
                if (File.Exists(Path.Combine(path, "LuaScripts.luap")))
                {
                    try
                    {
                        fileInput = File.Open(path + "\\France\\Loosefiles_BinPC.pack", FileMode.Open);
                        loadLoosefiles();
                    }
                    catch (Exception error)
                    {
                        MessageBox.Show("An error occurred: '{0}'" + error);
                    }
                }
                else
                {
                    MessageBox.Show("File not found. Please double check your Game Path in settings. This system isn't perfect, you know.");
                }
                break;
            }
        }
        } //Directly open DLC mega0 megapack file.

        private void dynamic0megapackToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            string path = Sabtool_Settings.returnGamePath();

            switch (path)
            {
            case "PathInvalid":
                MessageBox.Show("Has your game been moved? Your Saboteur Game Path is not valid, please re-select your Saboteur Game Path.");
                break;

            case "NoSettingsFile":
                MessageBox.Show("Please set the location of your Game Folder in Settings. Otherwise use Select Other and locate the file manually.");
                break;

            default:
                if (File.Exists(Path.Combine(path + "\\DLC\\01\\", "Dynamic0.megapack")))
                {
                    //MessageBox.Show("Loosefiles_BinPC.pack found.");
                    try
                    {
                        fileInput = fileInput = File.Open(Path.Combine(path + "\\DLC\\01\\", "Dynamic0.megapack"), FileMode.Open);
                        if (identifyPackFileFormat() == DialogResult.OK)
                        {
                            loadAndParseMegapack();
                        }
                        else
                        {
                            MessageBox.Show("This is not a proper Megapack/Kilopack. The version number for the correct format is 00PM.");
                            fileInput.Dispose();
                            fileInput.Close();
                        }
                    }
                    catch (Exception error)
                    {
                        Console.WriteLine("An error occurred: '{0}'", error);
                    }
                }
                else
                {
                    MessageBox.Show("File not found. Please double check your Game Path in settings. This system isn't perfect, you know.");
                }

                this.Text = "Sab - Toolbox v 0.0 - Megapack Editor - DLC Dynamic0.megapack";

                break;
            }
        } //Directly open DLC Dynamic 0 file.
Exemplo n.º 4
0
        private void openLoosefilesBinPCpackToolStripMenuItem_Click(object sender, EventArgs e)
        {
            string path = Sabtool_Settings.returnGamePath();

            switch (path)
            {
            case "PathInvalid":
                MessageBox.Show("Has your game been moved? Your Saboteur Game Path is not valid, please re-select your Saboteur Game Path.");
                break;

            case "NoSettingsFile":
                MessageBox.Show("Please set the location of your Game Folder in Settings. Otherwise use Select Other and locate the file manually.");
                break;

            default:
                if (File.Exists(Path.Combine(path + "\\France\\", "Loosefiles_BinPC.pack")))
                {
                    //MessageBox.Show("Loosefiles_BinPC.pack found.");
                    try
                    {
                        fileInput = File.Open(Path.Combine(path + "\\France\\", "Loosefiles_BinPC.pack"), FileMode.Open);;
                        extractGameTemplatesFromLooseFiles();
                        loadBlueprintsWSD();
                    }
                    catch (IOException error)
                    {
                        MessageBox.Show("Loosefiles_BinPC.pack is open in another program. Please close it and try again.");
                        Console.WriteLine("An IO error occurred: '{0}'", error);
                    }
                    catch (Exception error)
                    {
                        Console.WriteLine("An error occurred: '{0}'", error);
                    }
                }
                else
                {
                    MessageBox.Show("File not found. Please double check your Game Path in settings. This system isn't perfect, you know.");
                }

                break;
            }
        }
Exemplo n.º 5
0
        private void luaScriptsluapToolStripMenuItem_Click(object sender, EventArgs e) //Directly loads the LuaScripts.luap file from game location.
        {
            string path = Sabtool_Settings.returnGamePath();

            switch (path)
            {
            case "PathInvalid":
                MessageBox.Show("Has your game been moved? Your Saboteur Game Path is not valid, please re-select your Saboteur Game Path.");
                break;

            case "NoSettingsFile":
                MessageBox.Show("Please set the location of your Game Folder in Settings. Otherwise use Select Other and locate the file manually.");
                break;

            default:
                if (File.Exists(Path.Combine(path, "LuaScripts.luap")))
                {
                    //MessageBox.Show("LuaScripts.luap found.");
                    try
                    {
                        //MessageBox.Show(path);
                        fileInput = File.Open(Path.Combine(path, "LuaScripts.luap"), FileMode.Open);
                        loadLuapFile();
                    }
                    catch (Exception error)
                    {
                        MessageBox.Show("An error occurred: '{0}'" + error);
                    }
                }
                else
                {
                    MessageBox.Show("File not found. Please double check your Game Path in settings. This system isn't perfect, you know.");
                }
                break;
            }
            progressBar1.Value = 0;
        }
Exemplo n.º 6
0
        private void editToolStripMenuItem_Click_1(object sender, EventArgs e)
        {
            Sabtool_Settings settings1 = new Sabtool_Settings();

            settings1.Show();
        } //Settings Window
Exemplo n.º 7
0
        private void Pack_Editor_Load(object sender, EventArgs e)
        {
            string path = Sabtool_Settings.returnGamePath();

            if (path != "PathInvalid" && path != "NoSettingsFile")
            {
                String[] allPackFiles    = System.IO.Directory.GetFiles(path, "*.pack*", System.IO.SearchOption.AllDirectories);
                String[] allDynPackFiles = System.IO.Directory.GetFiles(path, "*.dynpack*", System.IO.SearchOption.AllDirectories);
                String[] allCinPackFiles = System.IO.Directory.GetFiles(path, "*.cinpack*", System.IO.SearchOption.AllDirectories);
                String[] allCnvPackFiles = System.IO.Directory.GetFiles(path, "*.cnvpack*", System.IO.SearchOption.AllDirectories);


                List <String[]> allFiles = new List <String[]>();
                allFiles.Add(allPackFiles);
                allFiles.Add(allDynPackFiles);
                allFiles.Add(allCinPackFiles);
                allFiles.Add(allCnvPackFiles);

                foreach (String[] arr in allFiles)
                {
                    foreach (string filePath in arr)
                    {
                        string fileName    = filePath.Substring(filePath.LastIndexOf('\\') + 1);
                        string newFilePath = filePath.Substring(path.Length + 1);

                        string subType = "";
                        using (FileStream fileStream = new FileStream(filePath, FileMode.Open))
                        {
                            using (BinaryReader binaryReader1 = new BinaryReader(fileStream))
                            {
                                subType = Utilities.reverseString(Encoding.Default.GetString(binaryReader1.ReadBytes(4)));
                            }
                        }

                        if (newFilePath.Contains('\\')) //If it isn't in the main directory, remove the file name from the folder path.
                        {
                            newFilePath = newFilePath.Substring(0, newFilePath.LastIndexOf('\\'));
                        }

                        if (fileName == newFilePath)                                             //If it's just a file name (main directory) just add it.
                        {
                            if (!fileName.Contains("loosefiles") && !fileName.Contains(".html")) //unless it's an .html or a loosefile.pack
                            {
                                packFileTreeView.Nodes.Add(fileName + " (" + subType + ")");
                            }
                        }
                        else
                        {
                            if (packFileTreeView.Nodes.ContainsKey(newFilePath))
                            {
                                packFileTreeView.Nodes[newFilePath].Nodes.Add(fileName + " (" + subType + ")");
                            }
                            else
                            {
                                packFileTreeView.Nodes.Add(newFilePath, newFilePath);

                                if (!fileName.Contains("loosefiles") && !fileName.Contains(".html"))
                                {
                                    packFileTreeView.Nodes[newFilePath].Nodes.Add(fileName + " (" + subType + ")");
                                }
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 8
0
        private void settingsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Sabtool_Settings settings1 = new Sabtool_Settings();

            settings1.Show();
        }
        } //Reads each SBLA file and copies the internal MSHA files to memory. Also adds them to tree view.

        private void settingsToolStripMenuItem_Click(object sender, EventArgs e) //Menu Button to open up Settings page.
        {
            Sabtool_Settings settings1 = new Sabtool_Settings();

            settings1.Show();
        }
Exemplo n.º 10
0
        /* ========= */
        /* Save File */
        /* ========= */
        private void saveToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (listOfFileArrays.Count > 0)
            {
                //MessageBox.Show(returnGamePath());
                string path = Sabtool_Settings.returnGamePath();
                if (path != "PathInvalid" && path != "NoSettingsFile") //if settings file exists, use it's path to get the loosefiles_BinPC.pack
                {
                    path += '\\' + "France" + '\\';
                    //MessageBox.Show(path);
                }

                string loosefilesPath       = Path.Combine(path, "loosefiles_BinPC.pack");
                string backupLoosefilesPath = Path.Combine(path, "loosefiles_BinPC.copy.pack");

                if (!File.Exists(backupLoosefilesPath)) //if there's no backup of the file being saved, make a copy
                {
                    File.Copy(loosefilesPath, Path.Combine(path, "loosefiles_BinPC.copy.pack"));
                }

                if (File.Exists(loosefilesPath))
                {
                    FileStream file = File.Open(loosefilesPath, FileMode.Open, FileAccess.ReadWrite);

                    BinaryReader binReader1 = new BinaryReader(file);
                    BinaryWriter binWriter1 = new BinaryWriter(file);

                    binWriter1.Seek(41107032, SeekOrigin.Begin);

                    String versionNumber = System.Text.Encoding.Default.GetString(binReader1.ReadBytes(4));

                    if (!versionNumber.Equals("AULB")) //Check position in the file, if it's not at the start, skip and check if we have skipped to the correct start position
                    {
                        binReader1.ReadBytes(116);
                        versionNumber = System.Text.Encoding.Default.GetString(binReader1.ReadBytes(4));
                    }
                    if (versionNumber.Equals("AULB"))
                    {
                        fileCount = binReader1.ReadInt32(); //Read how many files will need to be extracted

                        int howManyEditsSoFar = 0;


                        //int i = 0;
                        //while (file.Position != file.Length - 1 && file.Position != file.Length) //While we're not at the end..
                        for (int i = 0; i < listOfNames.Count; i++)
                        {
                            {
                                List <string> a = listOfNames;
                                List <byte[]> b = listOfFileArrays;


                                int    size      = binReader1.ReadInt32();
                                String midValues = "" + binReader1.ReadInt64();

                                int    nameLength = binReader1.ReadInt32();
                                String name       = System.Text.Encoding.Default.GetString(binReader1.ReadBytes(nameLength - 1));
                                binReader1.ReadByte();

                                int    subtypeLength = binReader1.ReadInt32();
                                string subtype       = System.Text.Encoding.Default.GetString(binReader1.ReadBytes(subtypeLength - 1)); //Read in the subtype
                                binReader1.ReadByte();

                                if (subtype == "WillToFight")
                                {
                                    int fileLength = listOfFileArrays[howManyEditsSoFar].Length;
                                    binWriter1.Write(listOfFileArrays[howManyEditsSoFar]);
                                    howManyEditsSoFar++;
                                    //byte[] blueprint = null;
                                    //blueprint = binReader1.ReadBytes((size) - 12 - nameLength - 4 - subtypeLength); //Read in the header data.
                                }
                                else
                                {
                                    byte[] blueprint = null;
                                    blueprint = binReader1.ReadBytes((size) - 12 - nameLength - 4 - subtypeLength); //Read in the header data.
                                }

                                if (file.Position != file.Length - 1 && file.Position != file.Length)
                                {
                                    while (binReader1.ReadInt32() == 8)
                                    {
                                        binReader1.ReadInt64();
                                        //Can add line to add current i to List to keep track of every file that has this feature.
                                    }
                                    file.Seek(file.Position - 4, 0);
                                }
                                //i++;
                            }
                        }
                        binReader1.Dispose();
                        binReader1.Close();
                        binWriter1.Close();
                        GC.Collect();
                    }
                    MessageBox.Show("Saving File Complete");
                }
            }
            else
            {
                MessageBox.Show("Please open the loosefiles_BinPC.pack file first.");
            }
        }