예제 #1
0
        private void BigBytePropImport_Click(object sender, EventArgs e)
        {
            var arrayProp = checkArrayRow();

            if (arrayProp == null)
            {
                return;
            }

            String[] files = MiscFuncs.GenerateOpenDialog();
            if (files.Length == 0)
            {
                return;
            }
            string path = files[0];

            if (!File.Exists(path))
            {
                return;
            }

            byte[]       data   = File.ReadAllBytes(path);
            DialogResult answer = MessageBox.Show("Add Count bytes?", "TH", MessageBoxButtons.YesNo);

            if (answer == DialogResult.Yes)
            {
                byte[] tmp = new byte[data.Length + 4];
                Array.Copy(BitConverter.GetBytes(data.Length), tmp, 4);
                Array.Copy(data, 0, tmp, 4, data.Length);
                data = tmp;
            }
            arrayProp.value = data;
            DrawGrid(selectedPackage, selectedExport);
        }
예제 #2
0
        private void openToolStripMenuItem_Click(object sender, EventArgs e)
        {
            String[] files = MiscFuncs.GenerateOpenDialog();
            if (files.Length == 0)
            {
                return;
            }

            DateTime         start          = DateTime.Now;
            List <IProgress> runningReaders = new List <IProgress>();
            List <Task>      runningTasks   = new List <Task>();


            foreach (var path in files)
            {
                if (File.Exists(path))
                {
                    Task newTask = new Task(delegate()
                    {
                        Reader reader = new Reader();
                        runningReaders.Add(reader);
                        GpkPackage tmpPack = reader.ReadGpk(path);
                        if (tmpPack != null)
                        {
                            if (Settings.Default.Debug)
                            {
                                tmpPack.Changes = true; //tmp, remove after tests
                            }

                            loadedGpkPackages.Add(tmpPack);
                        }
                    });
                    newTask.Start();
                    runningTasks.Add(newTask);
                }
            }

            //display info while loading
            while (!Task.WaitAll(runningTasks.ToArray(), 50))
            {
                Application.DoEvents();
                DisplayStatus(runningReaders, "Loading", start);
                //Thread.Sleep(50);
            }

            //Diplay end info
            DisplayStatus(runningReaders, "Loading", start);

            //for patchmode
            Array.Resize(ref changedExports, loadedGpkPackages.Count);
            for (int i = 0; i < changedExports.Length; i++)
            {
                changedExports[i] = new List <GpkExport>();
            }

            //gui stuff
            DrawPackages();
        }
예제 #3
0
        private void btnImportOgg_Click(object sender, EventArgs e)
        {
            try
            {
                if (selectedExport != null)
                {
                    String[] files = MiscFuncs.GenerateOpenDialog();
                    if (files.Length == 0)
                    {
                        return;
                    }

                    if (File.Exists(files[0]))
                    {
                        SoundwaveTools.ImportOgg(selectedExport, files[0]);
                        treeMain_AfterSelect(treeMain, new TreeViewEventArgs(treeMain.SelectedNode));
                        logger.Info("Import successful.");
                    }
                    else
                    {
                        logger.Info("File not found.");
                    }
                }
                else if (selectedPackage != null && selectedClass == "Core.SoundNodeWave")
                {
                    List <GpkExport> exports = selectedPackage.GetExportsByClass(selectedClass);

                    FolderBrowserDialog dialog = new FolderBrowserDialog();
                    dialog.SelectedPath = Path.GetDirectoryName(Settings.Default.SaveDir);
                    DialogResult result = dialog.ShowDialog();

                    if (result == DialogResult.OK)
                    {
                        Settings.Default.SaveDir = dialog.SelectedPath;

                        string[] files = Directory.GetFiles(dialog.SelectedPath);

                        foreach (string file in files)
                        {
                            string filename = Path.GetFileName(file); //AttackL_02.ogg
                            string oggname  = filename.Remove(filename.Length - 4);

                            if (oggname == "")
                            {
                                continue;
                            }

                            foreach (GpkExport exp in exports)
                            {
                                if (exp.ObjectName == oggname)
                                {
                                    SoundwaveTools.ImportOgg(exp, file);
                                    logger.Trace("Matched file {0} to export {1}!", filename, exp.ObjectName);
                                    break;
                                }
                            }
                        }


                        logger.Info("Mass import to {0} was successful.", dialog.SelectedPath);
                    }
                }
            }
            catch (Exception ex)
            {
                logger.FatalException("Import failure! " + ex, ex);
            }
        }
예제 #4
0
        private void btnReplace_Click(object sender, EventArgs e)
        {
            if (selectedExport == null)
            {
                logger.Trace("no selected export");
                return;
            }
            if (selectedExport.Data == null)
            {
                logger.Trace("no export data");
                return;
            }

            String[] files = MiscFuncs.GenerateOpenDialog();
            if (files.Length == 0)
            {
                return;
            }
            string path = files[0];

            if (File.Exists(path))
            {
                byte[] buffer = File.ReadAllBytes(path);


                if (Settings.Default.PatchMode)
                {
                    if (treeMain.SelectedNode.Parent.Parent == null)
                    {
                        return;
                    }
                    int packageIndex = Convert.ToInt32(treeMain.SelectedNode.Parent.Parent.Name);

                    if (buffer.Length > selectedExport.Data.Length)
                    {
                        //Too long, not possible without rebuiling the gpk
                        logger.Info("File size too big for PatchMode. Size: " + buffer.Length + " Maximum Size: " +
                                    selectedExport.Data.Length);
                        return;
                    }

                    //selectedExport.data = buffer;
                    Array.Copy(buffer, selectedExport.Data, buffer.Length);

                    changedExports[packageIndex].Add(selectedExport);
                }
                else
                {
                    //Rebuild Mode
                    //We force the rebuilder to recalculate the size. (atm we dont know how big the propertys are)
                    logger.Trace(String.Format("rebuild mode old size {0} new size {1}", selectedExport.Data.Length,
                                               buffer.Length));

                    selectedExport.Data = buffer;
                    selectedExport.GetDataSize();
                    selectedPackage.Changes = true;
                }


                logger.Info(String.Format("Replaced the data of {0} successfully! Dont forget to save.",
                                          selectedExport.ObjectName));
            }
        }