Exemplo n.º 1
0
        //
        // 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();
            }
        }
Exemplo n.º 2
0
        /// <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;
        }
Exemplo n.º 3
0
 /// <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();
         }
 }
Exemplo n.º 4
0
        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;
        }
Exemplo n.º 5
0
        //
        // 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();
            }
        }