コード例 #1
0
 private static void AddArchiveToSection(ModuleFile moduleFile, string sectionName, string archivePath)
 {
     ModuleFile.ModuleSectionFileList moduleSection;
     if (!moduleFile.HasSection(sectionName))
     {
         moduleSection = new ModuleFile.ModuleSectionFileList(sectionName);
         moduleFile.AddSection(moduleSection);
     }
     else
     {
         moduleSection = moduleFile[sectionName] as ModuleFile.ModuleSectionFileList;
     }
     moduleSection.AddArchive(archivePath, true);
 }
コード例 #2
0
 private static void AddArchiveToSection(ModuleFile moduleFile, string sectionName, string archivePath)
 {
     ModuleFile.ModuleSectionFileList moduleSection;
     if (!moduleFile.HasSection(sectionName))
     {
         moduleSection = new ModuleFile.ModuleSectionFileList(sectionName);
         moduleFile.AddSection(moduleSection);
     }
     else
         moduleSection = moduleFile[sectionName] as ModuleFile.ModuleSectionFileList;
     moduleSection.AddArchive(archivePath, true);
 }
コード例 #3
0
        public void WriteMod()
        {
            LoggingManager.SendMessage("ModCreator - Creating new mod...");

            ModManager.GameDirectory = m_sBaseModulePath.SubstringBeforeLast('\\');
            var baseModule = new ModuleFile(m_sBaseModulePath);
            baseModule.Close();

            if (!baseModule.HasSection("attrib:common"))
            {
                 UIHelper.ShowError(
                    "The selected base module file " + baseModule.FileName + " does not have a [attrib:common] section! Fix it first!");
                return;
            }

            if (!baseModule.HasSection("data:common"))
            {
                 UIHelper.ShowError(
                    "The selected module file " + baseModule.FileName + " does not have a [data:common] section! Fix it first!");
                return;
            }

            if (!baseModule.HasSection("global"))
            {
                 UIHelper.ShowError(
                    "The selected module file " + baseModule.FileName + " does not have a [global] section! Fix it first!");
                return;
            }

            string modulePath = ModManager.GameDirectory + m_sModName + ".module";
            if (File.Exists(modulePath))
            {
                if (
                    UIHelper.ShowYNQuestion("Warning",
                                            "There already exists a module file with the specified name " + m_sModName +
                                            ".module. Overwrite it?") == DialogResult.No)
                {
                     UIHelper.ShowError("Mod creation failed!");
                    return;
                }
            }



            LoggingManager.SendMessage("ModCreator - Generating module file for new mod");
            ModuleFile newMod = baseModule.GClone();
            var globalSection = (ModuleFile.ModuleSectionKeyValue)newMod["global"];
            globalSection["Name"] = m_sModName;
            globalSection["UIName"] = m_sDisplayedModName;
            globalSection["ModVersion"] = m_sModVersion;
            globalSection["ModFolder"] = m_sModName;
            globalSection["Description"] = m_sModDescription;
            globalSection["UCSBaseIndex"] = m_uUCSBaseIndex.ToString();

            var attribSection = (ModuleFile.ModuleSectionFileList)newMod["attrib:common"];
            attribSection.AddFolder(m_sModName + "\\DataAttrib", true);
            Directory.CreateDirectory(ModManager.GameDirectory + m_sModName + "\\DataAttrib");

            var dataSection = (ModuleFile.ModuleSectionFileList)newMod["data:common"];
            dataSection.AddFolder(m_sModName + "\\Data", true);
            Directory.CreateDirectory(ModManager.GameDirectory + m_sModName + "\\Data");

            if (m_bRepackAttribArchive)
            {
                string attribArchivePath = ModManager.GameDirectory + "GameAssets\\Archives\\GameAttrib.sga";
                string newArchivePath = m_sModName + "\\Archives\\GameAttrib_orig.sga";
                
                if (!File.Exists(attribArchivePath))
                {
                     UIHelper.ShowError("Tried to repack GameAttrib.sga but could not find it! Search at: " +
                                              attribArchivePath);
                }
                else
                {
                    if (RepackAttribArchive(attribArchivePath))
                    {
                        attribSection.RemoveArchive("GameAssets\\Archives\\GameAttrib.sga");
                        attribSection.AddArchive(newArchivePath, true);
                    }
                    else
                         UIHelper.ShowError("Failed to repack GameAttrib.sga.");
                }
            }

            newMod.WriteDataTo(modulePath);
            ModulePath = modulePath;

            LoggingManager.SendMessage("ModCreator - New mod successfully created!");
        }
コード例 #4
0
        public void WriteMod()
        {
            LoggingManager.SendMessage("ModCreator - Creating new mod...");

            ModManager.GameDirectory = m_sBaseModulePath.SubstringBeforeLast('\\');
            var baseModule = new ModuleFile(m_sBaseModulePath);

            baseModule.Close();

            if (!baseModule.HasSection("attrib:common"))
            {
                UIHelper.ShowError(
                    "The selected base module file " + baseModule.FileName + " does not have a [attrib:common] section! Fix it first!");
                return;
            }

            if (!baseModule.HasSection("data:common"))
            {
                UIHelper.ShowError(
                    "The selected module file " + baseModule.FileName + " does not have a [data:common] section! Fix it first!");
                return;
            }

            if (!baseModule.HasSection("global"))
            {
                UIHelper.ShowError(
                    "The selected module file " + baseModule.FileName + " does not have a [global] section! Fix it first!");
                return;
            }

            string modulePath = ModManager.GameDirectory + m_sModName + ".module";

            if (File.Exists(modulePath))
            {
                if (
                    UIHelper.ShowYNQuestion("Warning",
                                            "There already exists a module file with the specified name " + m_sModName +
                                            ".module. Overwrite it?") == DialogResult.No)
                {
                    UIHelper.ShowError("Mod creation failed!");
                    return;
                }
            }



            LoggingManager.SendMessage("ModCreator - Generating module file for new mod");
            ModuleFile newMod        = baseModule.GClone();
            var        globalSection = (ModuleFile.ModuleSectionKeyValue)newMod["global"];

            globalSection["Name"]         = m_sModName;
            globalSection["UIName"]       = m_sDisplayedModName;
            globalSection["ModVersion"]   = m_sModVersion;
            globalSection["ModFolder"]    = m_sModName;
            globalSection["Description"]  = m_sModDescription;
            globalSection["UCSBaseIndex"] = m_uUCSBaseIndex.ToString();

            var attribSection = (ModuleFile.ModuleSectionFileList)newMod["attrib:common"];

            attribSection.AddFolder(m_sModName + "\\DataAttrib", true);
            Directory.CreateDirectory(ModManager.GameDirectory + m_sModName + "\\DataAttrib");

            var dataSection = (ModuleFile.ModuleSectionFileList)newMod["data:common"];

            dataSection.AddFolder(m_sModName + "\\Data", true);
            Directory.CreateDirectory(ModManager.GameDirectory + m_sModName + "\\Data");

            if (m_bRepackAttribArchive)
            {
                string attribArchivePath = ModManager.GameDirectory + "GameAssets\\Archives\\GameAttrib.sga";
                string newArchivePath    = m_sModName + "\\Archives\\GameAttrib_orig.sga";

                if (!File.Exists(attribArchivePath))
                {
                    UIHelper.ShowError("Tried to repack GameAttrib.sga but could not find it! Search at: " +
                                       attribArchivePath);
                }
                else
                {
                    if (RepackAttribArchive(attribArchivePath))
                    {
                        attribSection.RemoveArchive("GameAssets\\Archives\\GameAttrib.sga");
                        attribSection.AddArchive(newArchivePath, true);
                    }
                    else
                    {
                        UIHelper.ShowError("Failed to repack GameAttrib.sga.");
                    }
                }
            }

            newMod.WriteDataTo(modulePath);
            ModulePath = modulePath;

            LoggingManager.SendMessage("ModCreator - New mod successfully created!");
        }