// // 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(); } }
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); }
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); }