Ejemplo n.º 1
0
        private void LoadIniFiles()
        {
            assemblyIniFiles.Clear();
            assemblyItemsToExport.Clear();

            foreach (KeyValuePair <string, AssemblyType> assembly in assemblies)
            {
                string iniPath = Path.Combine(projectFolder, assembly.Key + "_data.ini");
                Dictionary <string, bool> itemsToExport = new Dictionary <string, bool>();

                switch (assembly.Value)
                {
                case AssemblyType.Exe:
                    SplitTools.IniData iniData = StructConverter.StructConverter.LoadINI(iniPath, ref itemsToExport);
                    assemblyItemsToExport.Add(assembly.Key, itemsToExport);
                    assemblyIniFiles.Add(assembly.Key, iniData);
                    break;

                case AssemblyType.DLL:
                    DllIniData dllIniData = DLLModGenerator.DLLModGen.LoadINI(iniPath, ref itemsToExport);
                    assemblyItemsToExport.Add(assembly.Key, itemsToExport);
                    assemblyIniFiles.Add(assembly.Key, dllIniData);
                    break;

                default:
                    break;
                }
            }
        }
Ejemplo n.º 2
0
        private void FillListViewIniData(ListView listView, AssemblyType assemblyType, string assemblyname,
                                         SplitTools.IniData iniData, Dictionary <string, bool> itemsToExport)
        {
            listView.BeginUpdate();
            listView.Items.Clear();

            foreach (KeyValuePair <string, SplitTools.FileInfo> item in iniData.Files)
            {
                KeyValuePair <string, bool> exportStatus = itemsToExport.First(export => export.Key == item.Key);

                bool modified = exportStatus.Value;

                listView.Items.Add(new ListViewItem
                                   (
                                       new[]
                {
                    item.Key, StructConverter.StructConverter.DataTypeList[item.Value.Type],
                    (modified ? "Yes" : "No")
                })
                {
                    Checked = modified
                });
            }

            listView.EndUpdate();
        }
Ejemplo n.º 3
0
        private List <string> FindRelevantINIFiles(string file, Templates.SplitTemplate splitTemplate)
        {
            bool          dllmode     = false;
            string        extension   = Path.GetExtension(file).ToLowerInvariant();
            List <string> relevantini = new List <string>();

            if (extension == ".dll")
            {
                if (file.ToLowerInvariant().Contains("_orig"))
                {
                    file = file.ToLowerInvariant().Replace("_orig", "");
                }
                dllmode = true;
            }
            else if (extension == ".nb")
            {
                return(relevantini);
            }
            Console.WriteLine("Finding relevant split INI files for {0} in {1}", Path.GetFileName(file), splitTemplate.GameInfo.DataFolder);
            foreach (Templates.SplitEntry entry in splitTemplate.SplitEntries)
            {
                if ((Path.GetFileName(entry.SourceFile).ToLowerInvariant() == Path.GetFileName(file).ToLowerInvariant()) || (Path.GetFileName(entry.SourceFile).ToLowerInvariant() == Path.GetFileName(Path.ChangeExtension(file, ".prs")).ToLowerInvariant()))
                {
                    string inifilename = Path.Combine(templateFolder, splitTemplate.GameInfo.DataFolder, entry.IniFile + ".ini");
                    if (dllmode)
                    {
                        SplitTools.SplitDLL.IniDataSplitDLL inifile = IniSerializer.Deserialize <SplitTools.SplitDLL.IniDataSplitDLL>(inifilename);
                        if (inifile.ModuleName != null)
                        {
                            relevantini.Add(Path.GetFullPath(inifilename));
                            Console.WriteLine("Found split file {0}", inifilename);
                        }
                    }
                    else
                    {
                        string             filewithoutprs = Path.ChangeExtension(file, ".bin");
                        SplitTools.IniData inifile        = IniSerializer.Deserialize <SplitTools.IniData>(inifilename);
                        if (inifile.DataFilename != null && (inifile.DataFilename.ToLowerInvariant() == Path.GetFileName(file).ToLowerInvariant() || inifile.DataFilename.ToLowerInvariant() == Path.GetFileName(filewithoutprs).ToLowerInvariant()))
                        {
                            relevantini.Add(Path.GetFullPath(inifilename));
                            Console.WriteLine("Found split file {0}", inifilename);
                        }
                        else if (inifile.DataFilename != null)
                        {
                            Console.WriteLine("Datafilename: {0}", inifile.DataFilename);
                        }
                        else
                        {
                            Console.WriteLine("Datafilename in {0} is null", inifilename);
                        }
                    }
                }
            }
            return(relevantini);
        }
Ejemplo n.º 4
0
        private void IniExportButton_Click(object sender, EventArgs e)
        {
            var folderDialog = new FolderBrowserDialog();

            if (folderDialog.ShowDialog() == DialogResult.OK)
            {
                string                    outputFolder     = folderDialog.SelectedPath;
                List <string>             listIni_exe      = new List <string>();
                Dictionary <string, bool> itemsEXEToExport = new Dictionary <string, bool>();
                foreach (KeyValuePair <string, AssemblyType> assembly in assemblies)
                {
                    string iniPath = Path.Combine(projectFolder, assembly.Key + "_data.ini");
                    switch (assembly.Value)
                    {
                    case AssemblyType.Exe:
                        listIni_exe.Add(iniPath);
                        foreach (var item in assemblyItemsToExport[assembly.Key])
                        {
                            if (item.Value)
                            {
                                itemsEXEToExport.Add(item.Key, item.Value);
                            }
                        }
                        break;

                    case AssemblyType.DLL:
                        DLLModGenerator.DLLModGen.ExportINI((DllIniData)assemblyIniFiles[assembly.Key],
                                                            assemblyItemsToExport[assembly.Key], Path.Combine(folderDialog.SelectedPath, assembly.Key + "_data.ini"));
                        break;

                    default:
                        break;
                    }
                }
                if (listIni_exe.Count > 0)
                {
                    SplitTools.IniData EXEiniData = SAModel.SAEditorCommon.StructConverter.StructConverter.LoadMultiINI(listIni_exe, ref itemsEXEToExport, true);
                    SAModel.SAEditorCommon.StructConverter.StructConverter.ExportINI(EXEiniData,
                                                                                     itemsEXEToExport, Path.Combine(outputFolder, gameEXE + "_data.ini"));
                }
                MessageBox.Show(string.Format("INI Files have been exported to {0}", outputFolder), "Success", MessageBoxButtons.OK);
            }
            else
            {
                MessageBox.Show("No folder was provided.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }