// // Save settings to the module. // public void SaveSettings() { ResourceManager ResMan = ResourceManager.Instance; IResourceEntry Entry; GFFFile File; Stream ResStream; Entry = ResMan.GetEntry(new OEIResRef("CompilerSettings"), (ushort)ResTypes.ResGFF); // // If the settings file did not exist yet, create it in the module proper. // if (Entry == null || Entry is MissingResourceEntry) { Entry = NWN2Toolset.NWN2ToolsetMainForm.App.Module.Repository.CreateResource( new OEIResRef("CompilerSettings"), (ushort)ResTypes.ResGFF); } ResStream = Entry.GetStream(true); try { File = new GFFFile(); GFFStruct Settings = new GFFStruct(); GFFStructField SettingsField = new GFFStructField(); GFFIntField CompilerVersionField = new GFFIntField(); GFFByteField EnableExtensionsField = new GFFByteField(); GFFByteField EnableDebugSymbolsField = new GFFByteField(); CompilerVersionField.ValueInt = CompilerVersion; CompilerVersionField.StringLabel = "CompilerVersion"; EnableExtensionsField.ValueByte = (Byte)(EnableExtensions == true ? 1 : 0); EnableExtensionsField.StringLabel = "EnableExtensions"; EnableDebugSymbolsField.ValueByte = (Byte)(EnableDebugSymbols == true ? 1 : 0); EnableDebugSymbolsField.StringLabel = "EnableDbgSymbols"; Settings.Fields.Add(CompilerVersionField); Settings.Fields.Add(EnableExtensionsField); Settings.Fields.Add(EnableDebugSymbolsField); SettingsField.ValueStruct = Settings; SettingsField.StringLabel = "Settings"; File.TopLevelStruct.Fields.Add(SettingsField); File.Save(ResStream); } finally { Entry.Release(); } }
/// <summary> /// This routine scans module.ifo for haks to add to the hak list. /// </summary> /// <param name="ModuleIfo">Supplies the module.ifo GFF reader.</param> /// <param name="HomeDirectory">Supplies the NWN2 home directory.</param> /// <param name="InstallDirectory">Supplies the NWN2 install directory.</param> private void AddModuleHaks(GFFFile ModuleIfo, string HomeDirectory, string InstallDirectory) { string[] SearchDirs = new string[] { HomeDirectory, InstallDirectory }; GFFList HakList = ModuleIfo.TopLevelStruct.GetListSafe("Mod_HakList"); List <string> HakFiles = new List <string>(); if (HakList.StructList.Count == 0) { string Hak = ModuleIfo.TopLevelStruct.GetExoStringSafe("Mod_Hak").Value; if (!String.IsNullOrEmpty(Hak)) { HakFiles.Add(Hak); } } else { foreach (GFFStruct HakStruct in HakList.StructList) { string Hak = HakStruct.GetExoStringSafe("Mod_Hak").Value; if (String.IsNullOrEmpty(Hak)) { continue; } HakFiles.Add(Hak); } } foreach (string Hak in HakFiles) { bool Added = false; foreach (string DirName in SearchDirs) { string HakFileName = String.Format("{0}\\hak\\{1}.hak", DirName, Hak); if (!File.Exists(HakFileName)) { continue; } Repositories.Add(new ALFAERFResourceRepository(HakFileName)); Added = true; break; } if (!Added) { throw new ApplicationException("Couldn't locate hak " + Hak); } } }
static void Main( string[] CommandLine ) { // Variables. string sError = ""; // Invalid Command-line. // Param0 = Filename; // Param1 = Operation, Param2 = Operation Param1, Param3 = Operation Param 2. if ( ( CommandLine.Length - 1 ) % 3 != 0 ) { sError = "Error: Invalid command-line. Usage: BicFunctions.exe <Filename> <Operation1> <Parameter1> <Parameter2> <OperationN> <ParameterN1> <ParameterN2>"; Log( sError ); return; } // Open the specified BIC file. GFFFile BICFile; try { BICFile = new GFFFile( CommandLine[0] ); } catch { sError = "Error: Cannot open specified filename, " + CommandLine[0] + " for reading/writing."; Log( sError ); return; } // Cycle the command-line. uint uCommandIndex = 1, uCommandLength = (uint)CommandLine.Length - 1; for ( uCommandIndex = 1; uCommandIndex < uCommandLength + 1; uCommandIndex += 3 ) { if ( CommandLine[uCommandIndex] == "SetAbilityScore" ) SetAbilityScore( BICFile, CommandLine[uCommandIndex + 1], CommandLine[uCommandIndex + 2] ); else if ( CommandLine[uCommandIndex] == "SetBaseSkillRank" ) SetBaseSkillRank( BICFile, CommandLine[uCommandIndex + 1], CommandLine[uCommandIndex + 2] ); else if ( CommandLine[uCommandIndex] == "SetHead" ) SetHead( BICFile, CommandLine[uCommandIndex + 1] ); else if ( CommandLine[uCommandIndex] == "SetHair" ) SetHair( BICFile, CommandLine[uCommandIndex + 1] ); else if ( CommandLine[uCommandIndex] == "SetWing" ) SetWing( BICFile, CommandLine[uCommandIndex + 1] ); else if ( CommandLine[uCommandIndex] == "SetTail" ) SetTail( BICFile, CommandLine[uCommandIndex + 1] ); else if ( CommandLine[uCommandIndex] == "SetHairTint" ) SetHairTint( BICFile, CommandLine[uCommandIndex + 1] ); else if ( CommandLine[uCommandIndex] == "SetHeadTint" ) SetHeadTint( BICFile, CommandLine[uCommandIndex + 1] ); else if ( CommandLine[uCommandIndex] == "SetBodyTint" ) SetBodyTint( BICFile, CommandLine[uCommandIndex + 1] ); else if ( CommandLine[uCommandIndex] == "Retint" ) Retint( BICFile ); else Log( "Unknown command!" ); } // Save the data modifications to the BIC file. BICFile.Save( CommandLine[0] ); return; }
// // Load settings from the module. // public void LoadSettings() { if (NeedSettingsLoad == false) { return; } ResourceManager ResMan = ResourceManager.Instance; IResourceEntry Entry; GFFFile File; Stream ResStream; Entry = ResMan.GetEntry(new OEIResRef("CompilerSettings"), (ushort)ResTypes.ResGFF); if (Entry == null || Entry is MissingResourceEntry) { return; } ResStream = Entry.GetStream(false); try { File = new GFFFile(ResStream); GFFStruct Settings = File.TopLevelStruct.GetStructSafe("Settings"); CompilerVersion = Settings.GetIntSafe("CompilerVersion", DEFAULT_COMPILER_VERSION); EnableExtensions = Settings.GetByteSafe("EnableExtensions", 0) != 0 ? true : false; EnableDebugSymbols = Settings.GetByteSafe("EnableDbgSymbols", 0) != 0 ? true : false; } finally { Entry.Release(); } NeedSettingsLoad = false; }
// This function sets the character file's head ID. static void SetHead( GFFFile BICFile, string sHeadId ) { // Variables. byte bHeadID = 0; string sError = ""; // Filter: Hair ID is invalid or exceeds byte size. try { bHeadID = Convert.ToByte( sHeadId ); } catch { sError = "Error: Head ID type is invalid and must be an integer between 0 and 255."; Log( sError ); return; } // If Hair ID exists, modify it. try { BICFile.TopLevelStruct["Appearance_Head"].ValueByte = bHeadID; } catch { sError = "Error: SetHead( " + sHeadId + " ) : Can't update head ID. Please check your command-line. The ID should be an integer between 0 and 255 all inclusive."; Log( sError ); return; } return; }
// This function sets the character file's base skill rank. static void SetBaseSkillRank( GFFFile BICFile, string sSkill, string sRank ) { // Variables. byte bSkill = 0; byte bRank = 0; string sSkillName = ParseSkill( bSkill ); string sError = ""; // Filter: Skill is invalid. try { bSkill = Convert.ToByte( sSkill ); } catch { sError = "Error: Skill value is invalid and must be an integer between 0 and 255."; Log( sError ); return; } // Filter: Rank is invalid. try { bRank = Convert.ToByte( sRank ); } catch { sError = "Error: Rank value is invalid and must be an integer between 0 and 255."; Log( sError ); return; } // Get the skills list. if ( BICFile.TopLevelStruct.Contains( "SkillList" ) ) { GFFList Skills = BICFile.TopLevelStruct["SkillList"].ValueList; //Get the required skill. GFFStruct Skill; try { Skill = Skills[bSkill]; } catch { sError = "Error: SetBaseSkillRank( " + sSkillName + ", " + sRank + " ): Unknown skill. Please check your command-line and the skills.2da file for the skill integers."; Log( sError ); return; } if ( Skill.Contains( "Rank" ) ) // Modify it. BICFile.TopLevelStruct["SkillList"].ValueList[bSkill]["Rank"].ValueByte = bRank; else { sError = "Error: SetBaseSkillRank( " + sSkillName + ", " + sRank + " ): Skill entry corrupted, its missing a byte entry called Rank. Please check with a BIC editor."; Log( sError ); } } else { sError = "Error: SetBaseSkillRank( " + sSkillName + ", " + sRank + " ): Skills list not found. Possible invalid BIC file. Please check with a BIC editor."; Log( sError ); } return; }
/// <summary> /// A utility class that is used to create the blueprint /// </summary> /// <param name="blueprint">The blueprints that will be created</param> /// <param name="text">The tempoary blueprint name</param> /// <param name="repository">The repository that the blueprint is to be saved in</param> /// <param name="num">The file type (I think)</param> private static void createHelp(INWN2Blueprint blueprint, string text, IResourceRepository repository, ushort num) { blueprint.Resource = repository.CreateResource(new OEIResRef(text), num); blueprint.TemplateResRef = new OEIResRef(blueprint.Resource.ResRef.Value); GFFFile file = new GFFFile(); file.FileHeader.FileType = BWResourceTypes.GetFileExtension(num); blueprint.SaveEverythingIntoGFFStruct(file.TopLevelStruct, true); using (Stream stream = blueprint.Resource.GetStream(true)) { file.Save(stream); blueprint.Resource.Release(); } }
public static void TakeArmorStyle(GFFFile armor, ArmorSet set) { armor.TopLevelStruct["ArmorVisualType"].ValueByte = (byte)set.ArmorVisualType; armor.TopLevelStruct["Variation"].ValueByte = (byte)set.ArmorVariation; bool beltSeen = false; bool bootsSeen = false; bool cloakSeen = false; bool glovesSeen = false; bool helmSeen = false; List<GFFField> removals = new List<GFFField>(); foreach (GFFField armorPiece in armor.TopLevelStruct.Fields.Values) { if (armorPiece.StringLabel == "Belt") { beltSeen = true; if (set.BeltVariation < 0 || set.BeltVisualType < 0) { removals.Add(armorPiece); } } else if (armorPiece.StringLabel == "Boots") { bootsSeen = true; if (set.BootsVariation < 0 || set.BootsVisualType < 0) { removals.Add(armorPiece); } } else if (armorPiece.StringLabel == "Cloak") { cloakSeen = true; if (set.BootsVariation < 0 || set.BootsVisualType < 0) { removals.Add(armorPiece); } } else if (armorPiece.StringLabel == "Gloves") { glovesSeen = true; if (set.GlovesVariation < 0 || set.GlovesVisualType < 0) { removals.Add(armorPiece); } } else if (armorPiece.StringLabel == "Helm") { helmSeen = true; if (set.GlovesVariation < 0 || set.GlovesVisualType < 0) { removals.Add(armorPiece); } } } foreach (GFFField toRemove in removals) { armor.TopLevelStruct.Fields.Remove(toRemove); } if (!beltSeen && set.BeltVariation >= 0 && set.BeltVisualType >= 0) { AddArmorPiece(armor, "Belt", ACR_Items.BeltVariations); } if (!bootsSeen && set.BootsVariation >= 0 && set.BootsVisualType >= 0) { AddArmorPiece(armor, "Boots", ACR_Items.BootVariations); } if (!cloakSeen && set.CloakVariation >= 0 && set.CloakVisualType >= 0) { AddArmorPiece(armor, "Cloak", ACR_Items.CloakVariations); } if (!glovesSeen && set.GlovesVariation >= 0 && set.GlovesVisualType >= 0) { AddArmorPiece(armor, "Gloves", ACR_Items.GloveVariations); } if (!helmSeen && set.HelmetVariation >= 0 && set.HelmetVisualType >= 0) { AddArmorPiece(armor, "Helm", ACR_Items.HelmetVariations); } foreach (GFFField armorPiece in armor.TopLevelStruct.Fields.Values) { if (armorPiece.StringLabel == "Belt") { armorPiece.ValueStruct["Variation"].ValueByte = (byte)set.BeltVariation; armorPiece.ValueStruct["ArmorVisualType"].ValueByte = (byte)set.BeltVisualType; } else if (armorPiece.StringLabel == "Boots") { armorPiece.ValueStruct["Variation"].ValueByte = (byte)set.BootsVariation; armorPiece.ValueStruct["ArmorVisualType"].ValueByte = (byte)set.BootsVisualType; } else if (armorPiece.StringLabel == "Cloak") { armorPiece.ValueStruct["Variation"].ValueByte = (byte)set.CloakVariation; armorPiece.ValueStruct["ArmorVisualType"].ValueByte = (byte)set.CloakVisualType; } else if (armorPiece.StringLabel == "Gloves") { armorPiece.ValueStruct["Variation"].ValueByte = (byte)set.GlovesVariation; armorPiece.ValueStruct["ArmorVisualType"].ValueByte = (byte)set.GlovesVisualType; } else if (armorPiece.StringLabel == "Helm") { armorPiece.ValueStruct["Variation"].ValueByte = (byte)set.HelmetVariation; armorPiece.ValueStruct["ArmorVisualType"].ValueByte = (byte)set.HelmetVisualType; } } armor.TopLevelStruct["ACLtAnkle"].ValueStruct["Accessory"].ValueByte = (byte)set.LeftAnkle; armor.TopLevelStruct["ACLtArm"].ValueStruct["Accessory"].ValueByte = (byte)set.LeftArm; armor.TopLevelStruct["ACLtBracer"].ValueStruct["Accessory"].ValueByte = (byte)set.LeftBracer; armor.TopLevelStruct["ACLtElbow"].ValueStruct["Accessory"].ValueByte = (byte)set.LeftElbow; armor.TopLevelStruct["ACLtFoot"].ValueStruct["Accessory"].ValueByte = (byte)set.LeftFoot; armor.TopLevelStruct["ACLtHip"].ValueStruct["Accessory"].ValueByte = (byte)set.LeftHip; armor.TopLevelStruct["ACLtKnee"].ValueStruct["Accessory"].ValueByte = (byte)set.LeftKnee; armor.TopLevelStruct["ACLtLeg"].ValueStruct["Accessory"].ValueByte = (byte)set.LeftLeg; armor.TopLevelStruct["ACLtShin"].ValueStruct["Accessory"].ValueByte = (byte)set.LeftShin; armor.TopLevelStruct["ACLtShoulder"].ValueStruct["Accessory"].ValueByte = (byte)set.LeftShoulder; armor.TopLevelStruct["ACRtAnkle"].ValueStruct["Accessory"].ValueByte = (byte)set.RightAnkle; armor.TopLevelStruct["ACRtArm"].ValueStruct["Accessory"].ValueByte = (byte)set.RightArm; armor.TopLevelStruct["ACRtBracer"].ValueStruct["Accessory"].ValueByte = (byte)set.RightBracer; armor.TopLevelStruct["ACRtElbow"].ValueStruct["Accessory"].ValueByte = (byte)set.RightElbow; armor.TopLevelStruct["ACRtFoot"].ValueStruct["Accessory"].ValueByte = (byte)set.RightFoot; armor.TopLevelStruct["ACRtHip"].ValueStruct["Accessory"].ValueByte = (byte)set.RightHip; armor.TopLevelStruct["ACRtKnee"].ValueStruct["Accessory"].ValueByte = (byte)set.RightKnee; armor.TopLevelStruct["ACRtLeg"].ValueStruct["Accessory"].ValueByte = (byte)set.RightLeg; armor.TopLevelStruct["ACRtShin"].ValueStruct["Accessory"].ValueByte = (byte)set.RightShin; armor.TopLevelStruct["ACRtShoulder"].ValueStruct["Accessory"].ValueByte = (byte)set.RightShoulder; armor.TopLevelStruct["ACFtHip"].ValueStruct["Accessory"].ValueByte = (byte)set.FrontHip; armor.TopLevelStruct["ACBkHip"].ValueStruct["Accessory"].ValueByte = (byte)set.BackHip; }
public static void SetColorThemes(GFFFile armor, int primaryColor, int secondaryColor) { try { ModelColors colors = GetModelColor(LeftAnkleVariationColors, 0, ALFA.Shared.Modules.InfoStore.ModifiedGff[ACR_Items.ModelChangeVarName].TopLevelStruct["ACLtAnkle"].ValueStruct["Accessory"].ValueByte); ItemColors.SetAccessoryColor("ACLtAnkle", 1, colors.OneIsAccent ? secondaryColor : primaryColor); ItemColors.SetAccessoryColor("ACLtAnkle", 2, colors.TwoIsAccent ? secondaryColor : primaryColor); ItemColors.SetAccessoryColor("ACLtAnkle", 3, colors.ThreeIsAccent ? secondaryColor : primaryColor); } catch { } try { ModelColors colors = GetModelColor(LeftArmVariationColors, 0, ALFA.Shared.Modules.InfoStore.ModifiedGff[ACR_Items.ModelChangeVarName].TopLevelStruct["ACLtArm"].ValueStruct["Accessory"].ValueByte); ItemColors.SetAccessoryColor("ACLtArm", 1, colors.OneIsAccent ? secondaryColor : primaryColor); ItemColors.SetAccessoryColor("ACLtArm", 2, colors.TwoIsAccent ? secondaryColor : primaryColor); ItemColors.SetAccessoryColor("ACLtArm", 3, colors.ThreeIsAccent ? secondaryColor : primaryColor); } catch { } try { ModelColors colors = GetModelColor(LeftBracerVariationColors, 0, ALFA.Shared.Modules.InfoStore.ModifiedGff[ACR_Items.ModelChangeVarName].TopLevelStruct["ACLtBracer"].ValueStruct["Accessory"].ValueByte); ItemColors.SetAccessoryColor("ACLtBracer", 1, colors.OneIsAccent ? secondaryColor : primaryColor); ItemColors.SetAccessoryColor("ACLtBracer", 2, colors.TwoIsAccent ? secondaryColor : primaryColor); ItemColors.SetAccessoryColor("ACLtBracer", 3, colors.ThreeIsAccent ? secondaryColor : primaryColor); } catch { } try { ModelColors colors = GetModelColor(LeftElbowVariationColors, 0, ALFA.Shared.Modules.InfoStore.ModifiedGff[ACR_Items.ModelChangeVarName].TopLevelStruct["ACLtElbow"].ValueStruct["Accessory"].ValueByte); ItemColors.SetAccessoryColor("ACLtElbow", 1, colors.OneIsAccent ? secondaryColor : primaryColor); ItemColors.SetAccessoryColor("ACLtElbow", 2, colors.TwoIsAccent ? secondaryColor : primaryColor); ItemColors.SetAccessoryColor("ACLtElbow", 3, colors.ThreeIsAccent ? secondaryColor : primaryColor); } catch { } try { ModelColors colors = GetModelColor(LeftFootVariationColors, 0, ALFA.Shared.Modules.InfoStore.ModifiedGff[ACR_Items.ModelChangeVarName].TopLevelStruct["ACLtFoot"].ValueStruct["Accessory"].ValueByte); ItemColors.SetAccessoryColor("ACLtFoot", 1, colors.OneIsAccent ? secondaryColor : primaryColor); ItemColors.SetAccessoryColor("ACLtFoot", 2, colors.TwoIsAccent ? secondaryColor : primaryColor); ItemColors.SetAccessoryColor("ACLtFoot", 3, colors.ThreeIsAccent ? secondaryColor : primaryColor); } catch { } try { ModelColors colors = GetModelColor(LeftHipVariationColors, 0, ALFA.Shared.Modules.InfoStore.ModifiedGff[ACR_Items.ModelChangeVarName].TopLevelStruct["ACLtHip"].ValueStruct["Accessory"].ValueByte); ItemColors.SetAccessoryColor("ACLtHip", 1, colors.OneIsAccent ? secondaryColor : primaryColor); ItemColors.SetAccessoryColor("ACLtHip", 2, colors.TwoIsAccent ? secondaryColor : primaryColor); ItemColors.SetAccessoryColor("ACLtHip", 3, colors.ThreeIsAccent ? secondaryColor : primaryColor); } catch { } try { ModelColors colors = GetModelColor(LeftKneeVariationColors, 0, ALFA.Shared.Modules.InfoStore.ModifiedGff[ACR_Items.ModelChangeVarName].TopLevelStruct["ACLtKnee"].ValueStruct["Accessory"].ValueByte); ItemColors.SetAccessoryColor("ACLtKnee", 1, colors.OneIsAccent ? secondaryColor : primaryColor); ItemColors.SetAccessoryColor("ACLtKnee", 2, colors.TwoIsAccent ? secondaryColor : primaryColor); ItemColors.SetAccessoryColor("ACLtKnee", 3, colors.ThreeIsAccent ? secondaryColor : primaryColor); } catch { } try { ModelColors colors = GetModelColor(LeftLegVariationColors, 0, ALFA.Shared.Modules.InfoStore.ModifiedGff[ACR_Items.ModelChangeVarName].TopLevelStruct["ACLtLeg"].ValueStruct["Accessory"].ValueByte); ItemColors.SetAccessoryColor("ACLtLeg", 1, colors.OneIsAccent ? secondaryColor : primaryColor); ItemColors.SetAccessoryColor("ACLtLeg", 2, colors.TwoIsAccent ? secondaryColor : primaryColor); ItemColors.SetAccessoryColor("ACLtLeg", 3, colors.ThreeIsAccent ? secondaryColor : primaryColor); } catch { } try { ModelColors colors = GetModelColor(LeftShinVariationColors, 0, ALFA.Shared.Modules.InfoStore.ModifiedGff[ACR_Items.ModelChangeVarName].TopLevelStruct["ACLtShin"].ValueStruct["Accessory"].ValueByte); ItemColors.SetAccessoryColor("ACLtShin", 1, colors.OneIsAccent ? secondaryColor : primaryColor); ItemColors.SetAccessoryColor("ACLtShin", 2, colors.TwoIsAccent ? secondaryColor : primaryColor); ItemColors.SetAccessoryColor("ACLtShin", 3, colors.ThreeIsAccent ? secondaryColor : primaryColor); } catch { } try { ModelColors colors = GetModelColor(LeftShoulderVariationColors, 0, ALFA.Shared.Modules.InfoStore.ModifiedGff[ACR_Items.ModelChangeVarName].TopLevelStruct["ACLtShoulder"].ValueStruct["Accessory"].ValueByte); ItemColors.SetAccessoryColor("ACLtShoulder", 1, colors.OneIsAccent ? secondaryColor : primaryColor); ItemColors.SetAccessoryColor("ACLtShoulder", 2, colors.TwoIsAccent ? secondaryColor : primaryColor); ItemColors.SetAccessoryColor("ACLtShoulder", 3, colors.ThreeIsAccent ? secondaryColor : primaryColor); } catch { } try { ModelColors colors = GetModelColor(RightAnkleVariationColors, 0, ALFA.Shared.Modules.InfoStore.ModifiedGff[ACR_Items.ModelChangeVarName].TopLevelStruct["ACRtAnkle"].ValueStruct["Accessory"].ValueByte); ItemColors.SetAccessoryColor("ACRtAnkle", 1, colors.OneIsAccent ? secondaryColor : primaryColor); ItemColors.SetAccessoryColor("ACRtAnkle", 2, colors.TwoIsAccent ? secondaryColor : primaryColor); ItemColors.SetAccessoryColor("ACRtAnkle", 3, colors.ThreeIsAccent ? secondaryColor : primaryColor); } catch { } try { ModelColors colors = GetModelColor(RightArmVariationColors, 0, ALFA.Shared.Modules.InfoStore.ModifiedGff[ACR_Items.ModelChangeVarName].TopLevelStruct["ACRtArm"].ValueStruct["Accessory"].ValueByte); ItemColors.SetAccessoryColor("ACRtArm", 1, colors.OneIsAccent ? secondaryColor : primaryColor); ItemColors.SetAccessoryColor("ACRtArm", 2, colors.TwoIsAccent ? secondaryColor : primaryColor); ItemColors.SetAccessoryColor("ACRtArm", 3, colors.ThreeIsAccent ? secondaryColor : primaryColor); } catch { } try { ModelColors colors = GetModelColor(RightBracerVariationColors, 0, ALFA.Shared.Modules.InfoStore.ModifiedGff[ACR_Items.ModelChangeVarName].TopLevelStruct["ACRtBracer"].ValueStruct["Accessory"].ValueByte); ItemColors.SetAccessoryColor("ACRtBracer", 1, colors.OneIsAccent ? secondaryColor : primaryColor); ItemColors.SetAccessoryColor("ACRtBracer", 2, colors.TwoIsAccent ? secondaryColor : primaryColor); ItemColors.SetAccessoryColor("ACRtBracer", 3, colors.ThreeIsAccent ? secondaryColor : primaryColor); } catch { } try { ModelColors colors = GetModelColor(RightElbowVariationColors, 0, ALFA.Shared.Modules.InfoStore.ModifiedGff[ACR_Items.ModelChangeVarName].TopLevelStruct["ACRtElbow"].ValueStruct["Accessory"].ValueByte); ItemColors.SetAccessoryColor("ACRtElbow", 1, colors.OneIsAccent ? secondaryColor : primaryColor); ItemColors.SetAccessoryColor("ACRtElbow", 2, colors.TwoIsAccent ? secondaryColor : primaryColor); ItemColors.SetAccessoryColor("ACRtElbow", 3, colors.ThreeIsAccent ? secondaryColor : primaryColor); } catch { } try { ModelColors colors = GetModelColor(RightFootVariationColors, 0, ALFA.Shared.Modules.InfoStore.ModifiedGff[ACR_Items.ModelChangeVarName].TopLevelStruct["ACRtFoot"].ValueStruct["Accessory"].ValueByte); ItemColors.SetAccessoryColor("ACRtFoot", 1, colors.OneIsAccent ? secondaryColor : primaryColor); ItemColors.SetAccessoryColor("ACRtFoot", 2, colors.TwoIsAccent ? secondaryColor : primaryColor); ItemColors.SetAccessoryColor("ACRtFoot", 3, colors.ThreeIsAccent ? secondaryColor : primaryColor); } catch { } try { ModelColors colors = GetModelColor(RightHipVariationColors, 0, ALFA.Shared.Modules.InfoStore.ModifiedGff[ACR_Items.ModelChangeVarName].TopLevelStruct["ACRtHip"].ValueStruct["Accessory"].ValueByte); ItemColors.SetAccessoryColor("ACRtHip", 1, colors.OneIsAccent ? secondaryColor : primaryColor); ItemColors.SetAccessoryColor("ACRtHip", 2, colors.TwoIsAccent ? secondaryColor : primaryColor); ItemColors.SetAccessoryColor("ACRtHip", 3, colors.ThreeIsAccent ? secondaryColor : primaryColor); } catch { } try { ModelColors colors = GetModelColor(RightKneeVariationColors, 0, ALFA.Shared.Modules.InfoStore.ModifiedGff[ACR_Items.ModelChangeVarName].TopLevelStruct["ACRtKnee"].ValueStruct["Accessory"].ValueByte); ItemColors.SetAccessoryColor("ACRtKnee", 1, colors.OneIsAccent ? secondaryColor : primaryColor); ItemColors.SetAccessoryColor("ACRtKnee", 2, colors.TwoIsAccent ? secondaryColor : primaryColor); ItemColors.SetAccessoryColor("ACRtKnee", 3, colors.ThreeIsAccent ? secondaryColor : primaryColor); } catch { } try { ModelColors colors = GetModelColor(RightLegVariationColors, 0, ALFA.Shared.Modules.InfoStore.ModifiedGff[ACR_Items.ModelChangeVarName].TopLevelStruct["ACRtLeg"].ValueStruct["Accessory"].ValueByte); ItemColors.SetAccessoryColor("ACRtLeg", 1, colors.OneIsAccent ? secondaryColor : primaryColor); ItemColors.SetAccessoryColor("ACRtLeg", 2, colors.TwoIsAccent ? secondaryColor : primaryColor); ItemColors.SetAccessoryColor("ACRtLeg", 3, colors.ThreeIsAccent ? secondaryColor : primaryColor); } catch { } try { ModelColors colors = GetModelColor(RightShinVariationColors, 0, ALFA.Shared.Modules.InfoStore.ModifiedGff[ACR_Items.ModelChangeVarName].TopLevelStruct["ACRtShin"].ValueStruct["Accessory"].ValueByte); ItemColors.SetAccessoryColor("ACRtShin", 1, colors.OneIsAccent ? secondaryColor : primaryColor); ItemColors.SetAccessoryColor("ACRtShin", 2, colors.TwoIsAccent ? secondaryColor : primaryColor); ItemColors.SetAccessoryColor("ACRtShin", 3, colors.ThreeIsAccent ? secondaryColor : primaryColor); } catch { } try { ModelColors colors = GetModelColor(RightShoulderVariationColors, 0, ALFA.Shared.Modules.InfoStore.ModifiedGff[ACR_Items.ModelChangeVarName].TopLevelStruct["ACRtShoulder"].ValueStruct["Accessory"].ValueByte); ItemColors.SetAccessoryColor("ACRtShoulder", 1, colors.OneIsAccent ? secondaryColor : primaryColor); ItemColors.SetAccessoryColor("ACRtShoulder", 2, colors.TwoIsAccent ? secondaryColor : primaryColor); ItemColors.SetAccessoryColor("ACRtShoulder", 3, colors.ThreeIsAccent ? secondaryColor : primaryColor); } catch { } try { ModelColors colors = GetModelColor(FrontHipVariationColors, 0, ALFA.Shared.Modules.InfoStore.ModifiedGff[ACR_Items.ModelChangeVarName].TopLevelStruct["ACFtHip"].ValueStruct["Accessory"].ValueByte); ItemColors.SetAccessoryColor("ACFtHip", 1, colors.OneIsAccent ? secondaryColor : primaryColor); ItemColors.SetAccessoryColor("ACFtHip", 2, colors.TwoIsAccent ? secondaryColor : primaryColor); ItemColors.SetAccessoryColor("ACFtHip", 3, colors.ThreeIsAccent ? secondaryColor : primaryColor); } catch { } try { ModelColors colors = GetModelColor(BackHipVariationColors, 0, ALFA.Shared.Modules.InfoStore.ModifiedGff[ACR_Items.ModelChangeVarName].TopLevelStruct["ACBkHip"].ValueStruct["Accessory"].ValueByte); ItemColors.SetAccessoryColor("ACBkHip", 1, colors.OneIsAccent ? secondaryColor : primaryColor); ItemColors.SetAccessoryColor("ACBkHip", 2, colors.TwoIsAccent ? secondaryColor : primaryColor); ItemColors.SetAccessoryColor("ACBkHip", 3, colors.ThreeIsAccent ? secondaryColor : primaryColor); } catch { } try { ModelColors colors = GetModelColor(ArmorVariationColors, ALFA.Shared.Modules.InfoStore.ModifiedGff[ACR_Items.ModelChangeVarName].TopLevelStruct["ArmorVisualType"].ValueByte, ALFA.Shared.Modules.InfoStore.ModifiedGff[ACR_Items.ModelChangeVarName].TopLevelStruct["Variation"].ValueByte); ItemColors.SetArmorColor(1, colors.OneIsAccent ? secondaryColor : primaryColor); ItemColors.SetArmorColor(2, colors.TwoIsAccent ? secondaryColor : primaryColor); ItemColors.SetArmorColor(3, colors.ThreeIsAccent ? secondaryColor : primaryColor); } catch { } try { ModelColors colors = GetModelColor(BeltVariationColors, ALFA.Shared.Modules.InfoStore.ModifiedGff[ACR_Items.ModelChangeVarName].TopLevelStruct["Belt"].ValueStruct["ArmorVisualType"].ValueByte, ALFA.Shared.Modules.InfoStore.ModifiedGff[ACR_Items.ModelChangeVarName].TopLevelStruct["Belt"].ValueStruct["Variation"].ValueByte); ItemColors.SetArmorPieceColor("Belt", 1, colors.OneIsAccent ? secondaryColor : primaryColor); ItemColors.SetArmorPieceColor("Belt", 2, colors.TwoIsAccent ? secondaryColor : primaryColor); ItemColors.SetArmorPieceColor("Belt", 3, colors.ThreeIsAccent ? secondaryColor : primaryColor); } catch { } try { ModelColors colors = GetModelColor(BootVariationColors, ALFA.Shared.Modules.InfoStore.ModifiedGff[ACR_Items.ModelChangeVarName].TopLevelStruct["Boots"].ValueStruct["ArmorVisualType"].ValueByte, ALFA.Shared.Modules.InfoStore.ModifiedGff[ACR_Items.ModelChangeVarName].TopLevelStruct["Boots"].ValueStruct["Variation"].ValueByte); ItemColors.SetArmorPieceColor("Boots", 1, colors.OneIsAccent ? secondaryColor : primaryColor); ItemColors.SetArmorPieceColor("Boots", 2, colors.TwoIsAccent ? secondaryColor : primaryColor); ItemColors.SetArmorPieceColor("Boots", 3, colors.ThreeIsAccent ? secondaryColor : primaryColor); } catch { } try { ModelColors colors = GetModelColor(CloakVariationColors, ALFA.Shared.Modules.InfoStore.ModifiedGff[ACR_Items.ModelChangeVarName].TopLevelStruct["Cloak"].ValueStruct["ArmorVisualType"].ValueByte, ALFA.Shared.Modules.InfoStore.ModifiedGff[ACR_Items.ModelChangeVarName].TopLevelStruct["Cloak"].ValueStruct["Variation"].ValueByte); ItemColors.SetArmorPieceColor("Cloak", 1, colors.OneIsAccent ? secondaryColor : primaryColor); ItemColors.SetArmorPieceColor("Cloak", 2, colors.TwoIsAccent ? secondaryColor : primaryColor); ItemColors.SetArmorPieceColor("Cloak", 3, colors.ThreeIsAccent ? secondaryColor : primaryColor); } catch { } try { ModelColors colors = GetModelColor(GloveVariationColors, ALFA.Shared.Modules.InfoStore.ModifiedGff[ACR_Items.ModelChangeVarName].TopLevelStruct["Gloves"].ValueStruct["ArmorVisualType"].ValueByte, ALFA.Shared.Modules.InfoStore.ModifiedGff[ACR_Items.ModelChangeVarName].TopLevelStruct["Gloves"].ValueStruct["Variation"].ValueByte); ItemColors.SetArmorPieceColor("Gloves", 1, colors.OneIsAccent ? secondaryColor : primaryColor); ItemColors.SetArmorPieceColor("Gloves", 2, colors.TwoIsAccent ? secondaryColor : primaryColor); ItemColors.SetArmorPieceColor("Gloves", 3, colors.ThreeIsAccent ? secondaryColor : primaryColor); } catch { } try { ModelColors colors = GetModelColor(HelmetVariationColors, ALFA.Shared.Modules.InfoStore.ModifiedGff[ACR_Items.ModelChangeVarName].TopLevelStruct["Helm"].ValueStruct["Variation"].ValueByte, ALFA.Shared.Modules.InfoStore.ModifiedGff[ACR_Items.ModelChangeVarName].TopLevelStruct["Helm"].ValueStruct["Variation"].ValueByte); ItemColors.SetArmorPieceColor("Helm", 1, colors.OneIsAccent ? secondaryColor : primaryColor); ItemColors.SetArmorPieceColor("Helm", 2, colors.TwoIsAccent ? secondaryColor : primaryColor); ItemColors.SetArmorPieceColor("Helm", 3, colors.ThreeIsAccent ? secondaryColor : primaryColor); } catch { } }
public static void TakeArmorStyle(GFFFile armor, ArmorSet set) { armor.TopLevelStruct["ArmorVisualType"].ValueByte = (byte)set.ArmorVisualType; armor.TopLevelStruct["Variation"].ValueByte = (byte)set.ArmorVariation; bool beltSeen = false; bool bootsSeen = false; bool cloakSeen = false; bool glovesSeen = false; bool helmSeen = false; List <GFFField> removals = new List <GFFField>(); foreach (GFFField armorPiece in armor.TopLevelStruct.Fields.Values) { if (armorPiece.StringLabel == "Belt") { beltSeen = true; if (set.BeltVariation < 0 || set.BeltVisualType < 0) { removals.Add(armorPiece); } } else if (armorPiece.StringLabel == "Boots") { bootsSeen = true; if (set.BootsVariation < 0 || set.BootsVisualType < 0) { removals.Add(armorPiece); } } else if (armorPiece.StringLabel == "Cloak") { cloakSeen = true; if (set.BootsVariation < 0 || set.BootsVisualType < 0) { removals.Add(armorPiece); } } else if (armorPiece.StringLabel == "Gloves") { glovesSeen = true; if (set.GlovesVariation < 0 || set.GlovesVisualType < 0) { removals.Add(armorPiece); } } else if (armorPiece.StringLabel == "Helm") { helmSeen = true; if (set.GlovesVariation < 0 || set.GlovesVisualType < 0) { removals.Add(armorPiece); } } } foreach (GFFField toRemove in removals) { armor.TopLevelStruct.Fields.Remove(toRemove); } if (!beltSeen && set.BeltVariation >= 0 && set.BeltVisualType >= 0) { AddArmorPiece(armor, "Belt", ACR_Items.BeltVariations); } if (!bootsSeen && set.BootsVariation >= 0 && set.BootsVisualType >= 0) { AddArmorPiece(armor, "Boots", ACR_Items.BootVariations); } if (!cloakSeen && set.CloakVariation >= 0 && set.CloakVisualType >= 0) { AddArmorPiece(armor, "Cloak", ACR_Items.CloakVariations); } if (!glovesSeen && set.GlovesVariation >= 0 && set.GlovesVisualType >= 0) { AddArmorPiece(armor, "Gloves", ACR_Items.GloveVariations); } if (!helmSeen && set.HelmetVariation >= 0 && set.HelmetVisualType >= 0) { AddArmorPiece(armor, "Helm", ACR_Items.HelmetVariations); } foreach (GFFField armorPiece in armor.TopLevelStruct.Fields.Values) { if (armorPiece.StringLabel == "Belt") { armorPiece.ValueStruct["Variation"].ValueByte = (byte)set.BeltVariation; armorPiece.ValueStruct["ArmorVisualType"].ValueByte = (byte)set.BeltVisualType; } else if (armorPiece.StringLabel == "Boots") { armorPiece.ValueStruct["Variation"].ValueByte = (byte)set.BootsVariation; armorPiece.ValueStruct["ArmorVisualType"].ValueByte = (byte)set.BootsVisualType; } else if (armorPiece.StringLabel == "Cloak") { armorPiece.ValueStruct["Variation"].ValueByte = (byte)set.CloakVariation; armorPiece.ValueStruct["ArmorVisualType"].ValueByte = (byte)set.CloakVisualType; } else if (armorPiece.StringLabel == "Gloves") { armorPiece.ValueStruct["Variation"].ValueByte = (byte)set.GlovesVariation; armorPiece.ValueStruct["ArmorVisualType"].ValueByte = (byte)set.GlovesVisualType; } else if (armorPiece.StringLabel == "Helm") { armorPiece.ValueStruct["Variation"].ValueByte = (byte)set.HelmetVariation; armorPiece.ValueStruct["ArmorVisualType"].ValueByte = (byte)set.HelmetVisualType; } } armor.TopLevelStruct["ACLtAnkle"].ValueStruct["Accessory"].ValueByte = (byte)set.LeftAnkle; armor.TopLevelStruct["ACLtArm"].ValueStruct["Accessory"].ValueByte = (byte)set.LeftArm; armor.TopLevelStruct["ACLtBracer"].ValueStruct["Accessory"].ValueByte = (byte)set.LeftBracer; armor.TopLevelStruct["ACLtElbow"].ValueStruct["Accessory"].ValueByte = (byte)set.LeftElbow; armor.TopLevelStruct["ACLtFoot"].ValueStruct["Accessory"].ValueByte = (byte)set.LeftFoot; armor.TopLevelStruct["ACLtHip"].ValueStruct["Accessory"].ValueByte = (byte)set.LeftHip; armor.TopLevelStruct["ACLtKnee"].ValueStruct["Accessory"].ValueByte = (byte)set.LeftKnee; armor.TopLevelStruct["ACLtLeg"].ValueStruct["Accessory"].ValueByte = (byte)set.LeftLeg; armor.TopLevelStruct["ACLtShin"].ValueStruct["Accessory"].ValueByte = (byte)set.LeftShin; armor.TopLevelStruct["ACLtShoulder"].ValueStruct["Accessory"].ValueByte = (byte)set.LeftShoulder; armor.TopLevelStruct["ACRtAnkle"].ValueStruct["Accessory"].ValueByte = (byte)set.RightAnkle; armor.TopLevelStruct["ACRtArm"].ValueStruct["Accessory"].ValueByte = (byte)set.RightArm; armor.TopLevelStruct["ACRtBracer"].ValueStruct["Accessory"].ValueByte = (byte)set.RightBracer; armor.TopLevelStruct["ACRtElbow"].ValueStruct["Accessory"].ValueByte = (byte)set.RightElbow; armor.TopLevelStruct["ACRtFoot"].ValueStruct["Accessory"].ValueByte = (byte)set.RightFoot; armor.TopLevelStruct["ACRtHip"].ValueStruct["Accessory"].ValueByte = (byte)set.RightHip; armor.TopLevelStruct["ACRtKnee"].ValueStruct["Accessory"].ValueByte = (byte)set.RightKnee; armor.TopLevelStruct["ACRtLeg"].ValueStruct["Accessory"].ValueByte = (byte)set.RightLeg; armor.TopLevelStruct["ACRtShin"].ValueStruct["Accessory"].ValueByte = (byte)set.RightShin; armor.TopLevelStruct["ACRtShoulder"].ValueStruct["Accessory"].ValueByte = (byte)set.RightShoulder; armor.TopLevelStruct["ACFtHip"].ValueStruct["Accessory"].ValueByte = (byte)set.FrontHip; armor.TopLevelStruct["ACBkHip"].ValueStruct["Accessory"].ValueByte = (byte)set.BackHip; }
public static void AddArmorPiece(GFFFile armor, string type, Dictionary <int, List <int> > availableTypes) { GFFStructField pieceTop = new GFFStructField(); pieceTop.StringLabel = type; pieceTop.ValueStruct = new GFFStruct(); GFFByteField variation = new GFFByteField(); variation.StringLabel = "Variation"; variation.ValueByte = 0; GFFByteField visualType = new GFFByteField(); visualType.StringLabel = "ArmorVisualType"; visualType.ValueByte = 0; GFFStructField tintTop = new GFFStructField(); tintTop.StringLabel = "ArmorTint"; tintTop.ValueStruct = new GFFStruct(); pieceTop.ValueStruct.Fields.Add("Variation", variation); pieceTop.ValueStruct.Fields.Add("ArmorVisualType", visualType); pieceTop.ValueStruct.Fields.Add("ArmorTint", tintTop); GFFStructField tintOne = new GFFStructField(); tintOne.StringLabel = "1"; tintOne.ValueStruct = new GFFStruct(); GFFStructField tintTwo = new GFFStructField(); tintTwo.StringLabel = "2"; tintTwo.ValueStruct = new GFFStruct(); GFFStructField tintThree = new GFFStructField(); tintThree.StringLabel = "3"; tintThree.ValueStruct = new GFFStruct(); pieceTop.ValueStruct["ArmorTint"].ValueStruct.Fields.Add("1", tintOne); pieceTop.ValueStruct["ArmorTint"].ValueStruct.Fields.Add("2", tintTwo); pieceTop.ValueStruct["ArmorTint"].ValueStruct.Fields.Add("3", tintThree); GFFByteField rOne = new GFFByteField(); rOne.ValueByte = 255; rOne.StringLabel = "r"; GFFByteField gOne = new GFFByteField(); gOne.ValueByte = 255; gOne.StringLabel = "g"; GFFByteField bOne = new GFFByteField(); bOne.ValueByte = 255; bOne.StringLabel = "b"; GFFByteField aOne = new GFFByteField(); aOne.ValueByte = 255; aOne.StringLabel = "a"; pieceTop.ValueStruct["ArmorTint"].ValueStruct["1"].ValueStruct.Fields.Add("r", rOne); pieceTop.ValueStruct["ArmorTint"].ValueStruct["1"].ValueStruct.Fields.Add("g", gOne); pieceTop.ValueStruct["ArmorTint"].ValueStruct["1"].ValueStruct.Fields.Add("b", bOne); pieceTop.ValueStruct["ArmorTint"].ValueStruct["1"].ValueStruct.Fields.Add("a", aOne); GFFByteField rTwo = new GFFByteField(); rTwo.ValueByte = 255; rTwo.StringLabel = "r"; GFFByteField gTwo = new GFFByteField(); gTwo.ValueByte = 255; gTwo.StringLabel = "g"; GFFByteField bTwo = new GFFByteField(); bTwo.ValueByte = 255; bTwo.StringLabel = "b"; GFFByteField aTwo = new GFFByteField(); aTwo.ValueByte = 255; aTwo.StringLabel = "a"; pieceTop.ValueStruct["ArmorTint"].ValueStruct["2"].ValueStruct.Fields.Add("r", rTwo); pieceTop.ValueStruct["ArmorTint"].ValueStruct["2"].ValueStruct.Fields.Add("g", gTwo); pieceTop.ValueStruct["ArmorTint"].ValueStruct["2"].ValueStruct.Fields.Add("b", bTwo); pieceTop.ValueStruct["ArmorTint"].ValueStruct["2"].ValueStruct.Fields.Add("a", aTwo); GFFByteField rThree = new GFFByteField(); rThree.ValueByte = 255; rThree.StringLabel = "r"; GFFByteField gThree = new GFFByteField(); gThree.ValueByte = 255; gThree.StringLabel = "g"; GFFByteField bThree = new GFFByteField(); bThree.ValueByte = 255; bThree.StringLabel = "b"; GFFByteField aThree = new GFFByteField(); aThree.ValueByte = 255; aThree.StringLabel = "a"; pieceTop.ValueStruct["ArmorTint"].ValueStruct["3"].ValueStruct.Fields.Add("r", rThree); pieceTop.ValueStruct["ArmorTint"].ValueStruct["3"].ValueStruct.Fields.Add("g", gThree); pieceTop.ValueStruct["ArmorTint"].ValueStruct["3"].ValueStruct.Fields.Add("b", bThree); pieceTop.ValueStruct["ArmorTint"].ValueStruct["3"].ValueStruct.Fields.Add("a", aThree); armor.TopLevelStruct.Fields.Add(type, pieceTop); }
/// <summary> /// This routine scans module.ifo for a campaign GUID. If found, a /// campaign.cam file with the same GUID is searched for and its /// containing directory is added to the directory resource list. /// </summary> /// <param name="ModuleIfo">Supplies the module.ifo GFF reader.</param> /// <param name="HomeDirectory">Supplies the NWN2 home directory.</param> /// <param name="InstallDirectory">Supplies the NWN2 install directory.</param> private void AddModuleCampaign(GFFFile ModuleIfo, string HomeDirectory, string InstallDirectory) { byte[] GUIDData = ModuleIfo.TopLevelStruct.GetVoidDataSafe("Campaign_ID", null); if (GUIDData == null || GUIDData.Length != 16) { return; } Guid CampaignGUID = new Guid(GUIDData); string[] SearchDirs = new string[] { HomeDirectory, InstallDirectory }; // // Attempt to locate a campaign.cam file with the same GUID as the // module. // foreach (string PathName in SearchDirs) { string CampaignFolder = String.Format("{0}\\Campaigns", PathName); if (!Directory.Exists(CampaignFolder)) { continue; } foreach (string CampaignDir in Directory.EnumerateDirectories(CampaignFolder)) { using (DirectoryResourceRepository Repository = new DirectoryResourceRepository(CampaignDir)) { Repository.PopulateRepository(); IResourceEntry ResEntry = Repository.FindResource(new OEIResRef("campaign"), ResCAM); if (ResEntry == null) { continue; } GFFFile CampaignCAM = new GFFFile(ResEntry.GetStream(false)); GUIDData = CampaignCAM.TopLevelStruct.GetVoidDataSafe("GUID", null); if (GUIDData == null || GUIDData.Length != 16) { continue; } Guid ID = new Guid(GUIDData); if (!CampaignGUID.Equals(ID)) { continue; } Repositories.Add(new DirectoryResourceRepository(CampaignDir)); return; } } } }
// This function sets the character file's head colour. static void SetHeadTint( GFFFile BICFile, string sTint ) { // Variables. byte bTint1r = 0, bTint1g = 0, bTint1b = 0; byte bTint2r = 0, bTint2g = 0, bTint2b = 0; byte bTint3r = 0, bTint3g = 0, bTint3b = 0; string sError = ""; // Filter: Head colour string values are invalid. try { bTint1r = Convert.ToByte( sTint.Substring( 0, 3 ) ); bTint1g = Convert.ToByte( sTint.Substring( 3, 3 ) ); bTint1b = Convert.ToByte( sTint.Substring( 6, 3 ) ); bTint2r = Convert.ToByte( sTint.Substring( 9, 3 ) ); bTint2g = Convert.ToByte( sTint.Substring( 12, 3 ) ); bTint2b = Convert.ToByte( sTint.Substring( 15, 3 ) ); bTint3r = Convert.ToByte( sTint.Substring( 18, 3 ) ); bTint3g = Convert.ToByte( sTint.Substring( 21, 3 ) ); bTint3b = Convert.ToByte( sTint.Substring( 24, 3 ) ); } catch { sError = "Error: Head colour input strings are invalid and must be string integers between 0 and 255."; Log( sError ); return; } // If the Tint_Head structure exists, modify it. try { GFFStruct gffTintHead1 = BICFile.TopLevelStruct.GetStructSafe( "Tint_Head" ).GetStructSafe( "Tintable" ).GetStructSafe( "Tint" ).GetStructSafe( "1" ); GFFStruct gffTintHead2 = BICFile.TopLevelStruct.GetStructSafe( "Tint_Head" ).GetStructSafe( "Tintable" ).GetStructSafe( "Tint" ).GetStructSafe( "2" ); GFFStruct gffTintHead3 = BICFile.TopLevelStruct.GetStructSafe( "Tint_Head" ).GetStructSafe( "Tintable" ).GetStructSafe( "Tint" ).GetStructSafe( "3" ); gffTintHead1["r"].ValueByte = bTint1r; gffTintHead1["g"].ValueByte = bTint1g; gffTintHead1["b"].ValueByte = bTint1b; gffTintHead2["r"].ValueByte = bTint2r; gffTintHead2["g"].ValueByte = bTint2g; gffTintHead2["b"].ValueByte = bTint2b; gffTintHead3["r"].ValueByte = bTint3r; gffTintHead3["g"].ValueByte = bTint3g; gffTintHead3["b"].ValueByte = bTint3b; } catch { sError = "Error: SetHeadTint( " + sTint + " ) : Can't update head tint. Please check your command-line."; Log( sError ); return; } return; }
// // Load settings from the module. // public void LoadSettings() { if (NeedSettingsLoad == false) return; ResourceManager ResMan = ResourceManager.Instance; IResourceEntry Entry; GFFFile File; Stream ResStream; Entry = ResMan.GetEntry(new OEIResRef("CompilerSettings"), (ushort)ResTypes.ResGFF); if (Entry == null || Entry is MissingResourceEntry) return; ResStream = Entry.GetStream(false); try { File = new GFFFile(ResStream); GFFStruct Settings = File.TopLevelStruct.GetStructSafe("Settings"); CompilerVersion = Settings.GetIntSafe("CompilerVersion", DEFAULT_COMPILER_VERSION); EnableExtensions = Settings.GetByteSafe("EnableExtensions", 0) != 0 ? true : false; EnableDebugSymbols = Settings.GetByteSafe("EnableDbgSymbols", 0) != 0 ? true : false; } finally { Entry.Release(); } NeedSettingsLoad = false; }
// This function sets the character file's wing type. static void SetWing( GFFFile BICFile, string sWingType ) { // Variables. byte bWingType = 0; string sError = ""; // Filter: Wing type is invalid or exceeds byte size. try { bWingType = Convert.ToByte( sWingType ); } catch { sError = "Error: Wing type is invalid and must be an integer between 0 and 255."; Log( sError ); return; } // If Wing type exists, modify it. try { BICFile.TopLevelStruct["Wings"].ValueByte = bWingType; } catch { sError = "Error: SetWing( " + sWingType + " ) : Can't update wing type. Please check your command-line. And the wing type should be an integer between 0 and 255 all inclusive."; Log( sError ); return; } Retint( BICFile ); return; }
/// <summary> /// This routine scans module.ifo for a campaign GUID. If found, a /// campaign.cam file with the same GUID is searched for and its /// containing directory is added to the directory resource list. /// </summary> /// <param name="ModuleIfo">Supplies the module.ifo GFF reader.</param> /// <param name="HomeDirectory">Supplies the NWN2 home directory.</param> /// <param name="InstallDirectory">Supplies the NWN2 install directory.</param> private void AddModuleCampaign(GFFFile ModuleIfo, string HomeDirectory, string InstallDirectory) { byte[] GUIDData = ModuleIfo.TopLevelStruct.GetVoidDataSafe("Campaign_ID", null); if (GUIDData == null || GUIDData.Length != 16) return; Guid CampaignGUID = new Guid(GUIDData); string[] SearchDirs = new string[] { HomeDirectory, InstallDirectory }; // // Attempt to locate a campaign.cam file with the same GUID as the // module. // foreach (string PathName in SearchDirs) { string CampaignFolder = String.Format("{0}\\Campaigns", PathName); if (!Directory.Exists(CampaignFolder)) continue; foreach (string CampaignDir in Directory.EnumerateDirectories(CampaignFolder)) { using (DirectoryResourceRepository Repository = new DirectoryResourceRepository(CampaignDir)) { Repository.PopulateRepository(); IResourceEntry ResEntry = Repository.FindResource(new OEIResRef("campaign"), ResCAM); if (ResEntry == null) continue; GFFFile CampaignCAM = new GFFFile(ResEntry.GetStream(false)); GUIDData = CampaignCAM.TopLevelStruct.GetVoidDataSafe("GUID", null); if (GUIDData == null || GUIDData.Length != 16) continue; Guid ID = new Guid(GUIDData); if (!CampaignGUID.Equals(ID)) continue; Repositories.Add(new DirectoryResourceRepository(CampaignDir)); return; } } } }
/// <summary> /// This routine scans module.ifo for haks to add to the hak list. /// </summary> /// <param name="ModuleIfo">Supplies the module.ifo GFF reader.</param> /// <param name="HomeDirectory">Supplies the NWN2 home directory.</param> /// <param name="InstallDirectory">Supplies the NWN2 install directory.</param> private void AddModuleHaks(GFFFile ModuleIfo, string HomeDirectory, string InstallDirectory) { string[] SearchDirs = new string[] { HomeDirectory, InstallDirectory }; GFFList HakList = ModuleIfo.TopLevelStruct.GetListSafe("Mod_HakList"); List<string> HakFiles = new List<string>(); if (HakList.StructList.Count == 0) { string Hak = ModuleIfo.TopLevelStruct.GetExoStringSafe("Mod_Hak").Value; if (!String.IsNullOrEmpty(Hak)) { HakFiles.Add(Hak); } } else { foreach (GFFStruct HakStruct in HakList.StructList) { string Hak = HakStruct.GetExoStringSafe("Mod_Hak").Value; if (String.IsNullOrEmpty(Hak)) continue; HakFiles.Add(Hak); } } foreach (string Hak in HakFiles) { bool Added = false; foreach (string DirName in SearchDirs) { string HakFileName = String.Format("{0}\\hak\\{1}.hak", DirName, Hak); if (!File.Exists(HakFileName)) continue; Repositories.Add(new ERFResourceRepository(HakFileName)); Added = true; break; } if (!Added) throw new ApplicationException("Couldn't locate hak " + Hak); } }
// This function sets the character file's body colour based on their head color. static void ResetBodyTint( GFFFile BICFile ) { // Variables. byte bTintA = 0, bTintR = 0, bTintG = 0, bTintB = 0; string sError = ""; // Filter: Body colour string values are invalid. try { GFFStruct gffTintBody = BICFile.TopLevelStruct.GetStructSafe( "Tint_Head" ).GetStructSafe( "Tintable" ).GetStructSafe( "Tint" ).GetStructSafe( "1" ); bTintA = gffTintBody["a"].ValueByte; bTintR = gffTintBody["r"].ValueByte; bTintG = gffTintBody["g"].ValueByte; bTintB = gffTintBody["b"].ValueByte; } catch { sError = "Error: Head colour could not be gained."; Log( sError ); return; } // If the Tintable structure exists, modify it. try { GFFStruct gffTintBody1 = BICFile.TopLevelStruct.GetStructSafe( "Tintable" ).GetStructSafe( "Tint" ).GetStructSafe( "1" ); GFFStruct gffTintBody2 = BICFile.TopLevelStruct.GetStructSafe( "Tintable" ).GetStructSafe( "Tint" ).GetStructSafe( "2" ); GFFStruct gffTintBody3 = BICFile.TopLevelStruct.GetStructSafe( "Tintable" ).GetStructSafe( "Tint" ).GetStructSafe( "3" ); gffTintBody1["a"].ValueByte = bTintA; Console.WriteLine( bTintA ); gffTintBody1["r"].ValueByte = bTintR; Console.WriteLine( bTintR ); gffTintBody1["g"].ValueByte = bTintG; Console.WriteLine( bTintG ); gffTintBody1["b"].ValueByte = bTintB; Console.WriteLine( bTintB ); gffTintBody2["a"].ValueByte = bTintA; Console.WriteLine( bTintA ); gffTintBody2["r"].ValueByte = bTintR; Console.WriteLine( bTintR ); gffTintBody2["g"].ValueByte = bTintG; Console.WriteLine( bTintG ); gffTintBody2["b"].ValueByte = bTintB; Console.WriteLine( bTintB ); gffTintBody3["a"].ValueByte = bTintA; Console.WriteLine( bTintA ); gffTintBody3["r"].ValueByte = bTintR; Console.WriteLine( bTintR ); gffTintBody3["g"].ValueByte = bTintG; Console.WriteLine( bTintG ); gffTintBody3["b"].ValueByte = bTintB; Console.WriteLine( bTintB ); } catch { sError = "Error: ResetBodyTint() : Can't update body tint."; Log( sError ); return; } return; }
public static void AddArmorPiece(GFFFile armor, string type, Dictionary<int, List<int>> availableTypes) { GFFStructField pieceTop = new GFFStructField(); pieceTop.StringLabel = type; pieceTop.ValueStruct = new GFFStruct(); GFFByteField variation = new GFFByteField(); variation.StringLabel = "Variation"; variation.ValueByte = 0; GFFByteField visualType = new GFFByteField(); visualType.StringLabel = "ArmorVisualType"; visualType.ValueByte = 0; GFFStructField tintTop = new GFFStructField(); tintTop.StringLabel = "ArmorTint"; tintTop.ValueStruct = new GFFStruct(); pieceTop.ValueStruct.Fields.Add("Variation", variation); pieceTop.ValueStruct.Fields.Add("ArmorVisualType", visualType); pieceTop.ValueStruct.Fields.Add("ArmorTint", tintTop); GFFStructField tintOne = new GFFStructField(); tintOne.StringLabel = "1"; tintOne.ValueStruct = new GFFStruct(); GFFStructField tintTwo = new GFFStructField(); tintTwo.StringLabel = "2"; tintTwo.ValueStruct = new GFFStruct(); GFFStructField tintThree = new GFFStructField(); tintThree.StringLabel = "3"; tintThree.ValueStruct = new GFFStruct(); pieceTop.ValueStruct["ArmorTint"].ValueStruct.Fields.Add("1", tintOne); pieceTop.ValueStruct["ArmorTint"].ValueStruct.Fields.Add("2", tintTwo); pieceTop.ValueStruct["ArmorTint"].ValueStruct.Fields.Add("3", tintThree); GFFByteField rOne = new GFFByteField(); rOne.ValueByte = 255; rOne.StringLabel = "r"; GFFByteField gOne = new GFFByteField(); gOne.ValueByte = 255; gOne.StringLabel = "g"; GFFByteField bOne = new GFFByteField(); bOne.ValueByte = 255; bOne.StringLabel = "b"; GFFByteField aOne = new GFFByteField(); aOne.ValueByte = 255; aOne.StringLabel = "a"; pieceTop.ValueStruct["ArmorTint"].ValueStruct["1"].ValueStruct.Fields.Add("r", rOne); pieceTop.ValueStruct["ArmorTint"].ValueStruct["1"].ValueStruct.Fields.Add("g", gOne); pieceTop.ValueStruct["ArmorTint"].ValueStruct["1"].ValueStruct.Fields.Add("b", bOne); pieceTop.ValueStruct["ArmorTint"].ValueStruct["1"].ValueStruct.Fields.Add("a", aOne); GFFByteField rTwo = new GFFByteField(); rTwo.ValueByte = 255; rTwo.StringLabel = "r"; GFFByteField gTwo = new GFFByteField(); gTwo.ValueByte = 255; gTwo.StringLabel = "g"; GFFByteField bTwo = new GFFByteField(); bTwo.ValueByte = 255; bTwo.StringLabel = "b"; GFFByteField aTwo = new GFFByteField(); aTwo.ValueByte = 255; aTwo.StringLabel = "a"; pieceTop.ValueStruct["ArmorTint"].ValueStruct["2"].ValueStruct.Fields.Add("r", rTwo); pieceTop.ValueStruct["ArmorTint"].ValueStruct["2"].ValueStruct.Fields.Add("g", gTwo); pieceTop.ValueStruct["ArmorTint"].ValueStruct["2"].ValueStruct.Fields.Add("b", bTwo); pieceTop.ValueStruct["ArmorTint"].ValueStruct["2"].ValueStruct.Fields.Add("a", aTwo); GFFByteField rThree = new GFFByteField(); rThree.ValueByte = 255; rThree.StringLabel = "r"; GFFByteField gThree = new GFFByteField(); gThree.ValueByte = 255; gThree.StringLabel = "g"; GFFByteField bThree = new GFFByteField(); bThree.ValueByte = 255; bThree.StringLabel = "b"; GFFByteField aThree = new GFFByteField(); aThree.ValueByte = 255; aThree.StringLabel = "a"; pieceTop.ValueStruct["ArmorTint"].ValueStruct["3"].ValueStruct.Fields.Add("r", rThree); pieceTop.ValueStruct["ArmorTint"].ValueStruct["3"].ValueStruct.Fields.Add("g", gThree); pieceTop.ValueStruct["ArmorTint"].ValueStruct["3"].ValueStruct.Fields.Add("b", bThree); pieceTop.ValueStruct["ArmorTint"].ValueStruct["3"].ValueStruct.Fields.Add("a", aThree); armor.TopLevelStruct.Fields.Add(type, pieceTop); }
// This function sets the character file's body colour based on head color. static void Retint( GFFFile BICFile ) { // Variables. byte bTintA = 0, bTintR = 0, bTintG = 0, bTintB = 0; string sError = ""; // Filter: Body colour string values are invalid. try { GFFStruct gffTintBody = BICFile.TopLevelStruct.GetStructSafe( "Tint_Head" ).GetStructSafe( "Tintable" ).GetStructSafe( "Tint" ).GetStructSafe( "1" ); bTintR = Convert.ToByte( gffTintBody["r"].Value ); bTintG = Convert.ToByte( gffTintBody["g"].Value ); bTintB = Convert.ToByte( gffTintBody["b"].Value ); } catch { sError = "Error: Head colour input strings are invalid and must be string integers between 0 and 255."; Log( sError ); return; } // If the Tintable structure exists, modify it. try { GFFStruct gffTintBody1 = BICFile.TopLevelStruct.GetStructSafe( "Tintable" ).GetStructSafe( "Tint" ).GetStructSafe( "1" ); GFFStruct gffTintBody2 = BICFile.TopLevelStruct.GetStructSafe( "Tintable" ).GetStructSafe( "Tint" ).GetStructSafe( "2" ); GFFStruct gffTintBody3 = BICFile.TopLevelStruct.GetStructSafe( "Tintable" ).GetStructSafe( "Tint" ).GetStructSafe( "3" ); gffTintBody1["a"].ValueByte = bTintA; Console.WriteLine( bTintA ); gffTintBody1["r"].ValueByte = bTintR; Console.WriteLine( bTintR ); gffTintBody1["g"].ValueByte = bTintG; Console.WriteLine( bTintG ); gffTintBody1["b"].ValueByte = bTintB; Console.WriteLine( bTintB ); gffTintBody2["a"].ValueByte = bTintA; Console.WriteLine( bTintA ); gffTintBody2["r"].ValueByte = bTintR; Console.WriteLine( bTintR ); gffTintBody2["g"].ValueByte = bTintG; Console.WriteLine( bTintG ); gffTintBody2["b"].ValueByte = bTintB; Console.WriteLine( bTintB ); gffTintBody3["a"].ValueByte = bTintA; Console.WriteLine( bTintA ); gffTintBody3["r"].ValueByte = bTintR; Console.WriteLine( bTintR ); gffTintBody3["g"].ValueByte = bTintG; Console.WriteLine( bTintG ); gffTintBody3["b"].ValueByte = bTintB; Console.WriteLine( bTintB ); } catch { sError = "Error: Retint : Can't update body tint. Please check your command-line."; Log( sError ); return; } return; }
private static void ParseTrapWaypoint(GFFFile trapGff, string resRef) { if (ALFA.Shared.Modules.InfoStore.ModuleTraps.Keys.Contains(resRef)) { // We've already got one of those. We'll crash if we try to // add another. return; } ALFA.Shared.TrapResource addingTrap = new ALFA.Shared.TrapResource() { AttackBonus = -1, ChallengeRating = -1.0f, Classification = "", DamageType = -1, DetectDC = -1, DiceNumber = -1, DiceType = -1, DisarmDC = -1, DisplayName = "", EffectArea = -1, EffectSize = -1.0f, MinimumToTrigger = 1, NumberOfShots = 1, ResRef = resRef, SaveDC = -1, SpellId = -1, SpellTrap = false, Tag = "", TargetAlignment = CLRScriptBase.ALIGNMENT_ALL, TargetRace = CLRScriptBase.RACIAL_TYPE_ALL, TrapOrigin = CLRScriptBase.OBJECT_INVALID, }; try { addingTrap.DisplayName = trapGff.TopLevelStruct["LocalizedName"].Value.ToString().Split('"')[1]; } catch { addingTrap.DisplayName = trapGff.TopLevelStruct["LocalizedName"].Value.ToString(); } if (addingTrap.DisplayName == "") { addingTrap.DisplayName = GetTlkEntry(trapGff.TopLevelStruct["LocalizedName"].ValueCExoLocString.StringRef); } addingTrap.Classification = ParseClassification(trapGff.TopLevelStruct["Classification"].Value.ToString()); addingTrap.Tag = trapGff.TopLevelStruct["Tag"].Value.ToString(); GFFStructCollection variables = trapGff.TopLevelStruct["VarTable"].ValueList.StructList; // Waypoints can be a lot of things. Let's see if we can figure anything out about this one. foreach (GFFStruct var in variables) { string varName = var["Name"].Value.ToString(); if (varName == "ACR_TRAP_TRIGGER_AREA") { addingTrap.TriggerArea = var["Value"].ValueInt; continue; } if (varName == "ACR_TRAP_ATTACK_BONUS") { addingTrap.AttackBonus = var["Value"].ValueInt; continue; } else if (varName == "ACR_TRAP_DAMAGE_TYPE") { addingTrap.DamageType = var["Value"].ValueInt; continue; } else if (varName == "ACR_TRAP_DETECT_DC") { addingTrap.DetectDC = var["Value"].ValueInt; continue; } else if (varName == "ACR_TRAP_DICE_NUMBER") { addingTrap.DiceNumber = var["Value"].ValueInt; continue; } else if (varName == "ACR_TRAP_DICE_TYPE") { addingTrap.DiceType = var["Value"].ValueInt; continue; } else if (varName == "ACR_TRAP_DISARM_DC") { addingTrap.DisarmDC = var["Value"].ValueInt; continue; } else if (varName == "ACR_TRAP_EFFECT_AREA") { addingTrap.EffectArea = var["Value"].ValueInt; continue; } else if (varName == "ACR_TRAP_EFFECT_SIZE") { addingTrap.EffectSize = var["Value"].ValueFloat; continue; } else if (varName == "ACR_TRAP_MINIMUM_TO_TRIGGER") { addingTrap.MinimumToTrigger = var["Value"].ValueInt; continue; } else if (varName == "ACR_TRAP_NUMBER_OF_SHOTS") { addingTrap.NumberOfShots = var["Value"].ValueInt; continue; } else if (varName == "ACR_TRAP_SAVE_DC") { addingTrap.SaveDC = var["Value"].ValueInt; continue; } else if (varName == "ACR_TRAP_SPELL_ID") { addingTrap.SpellId = var["Value"].ValueInt; if (addingTrap.SpellId >= 0) { addingTrap.SpellTrap = true; } else { addingTrap.SpellTrap = false; } continue; } else if (varName == "ACR_TRAP_TARGET_ALIGNMENT") { addingTrap.TargetAlignment = var["Value"].ValueInt; continue; } else if (varName == "ACR_TRAP_TARGET_RACE") { addingTrap.TargetRace = var["Value"].ValueInt; continue; } else if (varName == "ACR_TRAP_DESCRIPTION") { addingTrap.Description = var["Value"].Value.ToString(); continue; } } addingTrap.CalculateCR(); ALFA.Shared.Modules.InfoStore.ModuleTraps.Add(addingTrap.ResRef, addingTrap); }
// This function sets the character file's ability score. static void SetAbilityScore( GFFFile BICFile, string sAbility, string sScore ) { // Variables. byte bScore = 0; string sError = ""; // Filter: Rank is invalid or exceeds byte size. try { bScore = Convert.ToByte( sScore ); } catch { sError = "Error: Score value is invalid and must be an integer between 0 and 255."; Console.WriteLine( sError ); Log( sError ); return; } // Ability score exists, modify it. if ( BICFile.TopLevelStruct.Contains( sAbility ) ) { try { BICFile.TopLevelStruct[sAbility].ValueByte = bScore; } catch { sError = "Error: SetAbilityScore( " + sAbility + ", " + sScore + " ): Can't update ability. Please check your command-line. The acceptable abilities are as follows: Str, Dex, Con, Int, Cha, Wis. And the score value should be an integer between 0 and 255 all inclusive."; Log( sError ); return; } } else { sError = "Error: SetAbilityScore( " + sAbility + ", " + sScore + " ): Ability not found. Possible typographical error. Please check with a BIC editor."; Log( sError ); } return; }
/// <summary> /// Create a new blueprint /// </summary> /// <param name="objectType">The type of the blueprint that is about to be created</param> /// <param name="locationType">The location where the blueprint will be placed</param> /// <returns>The new blueprint</returns> private static INWN2Blueprint createNewBlueprint(NWN2ObjectType objectType, NWN2BlueprintLocationType locationType) { INWN2Blueprint cBlueprint = null; IResourceRepository userOverrideDirectory = null; NWN2Campaign activeCampaign = NWN2CampaignManager.Instance.ActiveCampaign; INWN2BlueprintSet instance = null; switch (locationType) { case NWN2BlueprintLocationType.Global: userOverrideDirectory = NWN2ResourceManager.Instance.UserOverrideDirectory; if (userOverrideDirectory != null) { userOverrideDirectory = NWN2ResourceManager.Instance.OverrideDirectory; } instance = NWN2GlobalBlueprintManager.Instance; break; case NWN2BlueprintLocationType.Module: instance = NWN2Toolset.NWN2ToolsetMainForm.App.Module; userOverrideDirectory = NWN2Toolset.NWN2ToolsetMainForm.App.Module.Repository; break; case NWN2BlueprintLocationType.Campaign: userOverrideDirectory = (activeCampaign != null) ? activeCampaign.Repository : null; instance = activeCampaign; break; default: throw new Exception("Unknown object type in CreateNewBlueprint()" + locationType.ToString()); } if ((userOverrideDirectory == null) || (instance == null)) { return null; } switch (objectType) { case NWN2ObjectType.Creature: cBlueprint = new NWN2CreatureBlueprint(); createHelp(cBlueprint, NWN2GlobalBlueprintManager.GetTemporaryBlueprintName(NWN2ObjectType.Creature, locationType), userOverrideDirectory, BWResourceTypes.GetResourceType("UTC")); break; case NWN2ObjectType.Door: cBlueprint = new NWN2DoorBlueprint(); createHelp(cBlueprint, NWN2GlobalBlueprintManager.GetTemporaryBlueprintName(NWN2ObjectType.Door, locationType), userOverrideDirectory, BWResourceTypes.GetResourceType("UTD")); break; case NWN2ObjectType.Item: cBlueprint = new NWN2ItemBlueprint(); createHelp(cBlueprint, NWN2GlobalBlueprintManager.GetTemporaryBlueprintName(NWN2ObjectType.Item, locationType), userOverrideDirectory, BWResourceTypes.GetResourceType("UTI")); break; case NWN2ObjectType.Placeable: cBlueprint = new NWN2PlaceableBlueprint(); createHelp(cBlueprint, NWN2GlobalBlueprintManager.GetTemporaryBlueprintName(NWN2ObjectType.Placeable, locationType), userOverrideDirectory, BWResourceTypes.GetResourceType("UTP")); break; case NWN2ObjectType.Trigger: cBlueprint = new NWN2TriggerBlueprint(); createHelp(cBlueprint, NWN2GlobalBlueprintManager.GetTemporaryBlueprintName(NWN2ObjectType.Trigger, locationType), userOverrideDirectory, BWResourceTypes.GetResourceType("UTT")); break; default: throw new Exception("Unknown object type in CreateNewBlueprint()"); } NWN2BlueprintCollection blueprintCollectionForType = instance.GetBlueprintCollectionForType(objectType); INWN2Object obj2 = cBlueprint as INWN2Object; obj2.Tag = cBlueprint.ResourceName.Value; obj2.LocalizedName[BWLanguages.CurrentLanguage] = cBlueprint.ResourceName.Value; cBlueprint.BlueprintLocation = instance.BlueprintLocation; blueprintCollectionForType.Add(cBlueprint); GFFFile file = new GFFFile(); file.FileHeader.FileType = BWResourceTypes.GetFileExtension(cBlueprint.Resource.ResourceType); cBlueprint.SaveEverythingIntoGFFStruct(file.TopLevelStruct, true); using (Stream stream = cBlueprint.Resource.GetStream(true)) { file.Save(stream); cBlueprint.Resource.Release(); } return cBlueprint; }
/// <summary> /// This method performs demand loading of resource repositories. /// </summary> /// <param name="ModuleOnly">If true, only load the module core /// resources.</param> private void LoadResourceRepositories(bool ModuleOnly) { string HomeDirectory = SystemInfo.GetHomeDirectory(); string InstallDirectory = SystemInfo.GetGameInstallationDirectory(); string ModPath; string DataPath; // // Create a dummy resource manager to keep OEIShared happy. We do // not use it explicitly, but some OEIShared code uses // ResourceManager.Instance and hopes to get something back. // if (OEIShared.IO.ResourceManager.Instance == null) { new DummyOEIResourceManager(); } if (ModuleResourceName == null) { ModuleResourceName = SystemInfo.GetModuleResourceName(); } if (ModuleResourceName == null) { throw new ApplicationException("Cannot determine module resource name."); } Repositories = new List <ResourceRepository>(); ModPath = String.Format("{0}\\modules\\{1}.mod", HomeDirectory, ModuleResourceName); if (File.Exists(ModPath)) { Repositories.Add(new ALFAERFResourceRepository(ModPath)); } else { ModPath = String.Format("{0}\\modules\\{1}\\", HomeDirectory, ModuleResourceName); Repositories.Add(new DirectoryResourceRepository(ModPath)); } if (!ModuleOnly) { GFFFile ModuleIfo = OpenModuleIfo(); AddModuleHaks(ModuleIfo, HomeDirectory, InstallDirectory); AddModuleCampaign(ModuleIfo, HomeDirectory, InstallDirectory); foreach (string PathName in new string[] { HomeDirectory, InstallDirectory }) { string overrideFolder = String.Format("{0}\\override", PathName); if (Directory.Exists(overrideFolder)) { Repositories.Add(new DirectoryResourceRepository(overrideFolder)); } } DataPath = String.Format("{0}\\Data", InstallDirectory); foreach (string ZipPath in Directory.EnumerateFiles(DataPath, "*.zip")) { Repositories.Add(new ZIPResourceRepository(ZipPath)); } } // // Finally, populate all of the repositories, which may take time. // foreach (ResourceRepository Repository in Repositories) { Repository.PopulateRepository(); } }