public static Transform Load(string ModelName)
    {
        Clear();

        string OpenPath = string.Concat(Configuration.GameFld, Configuration.Mod, ModelName);
        ModelObject = new GameObject(ModelName);

        if (!File.Exists(OpenPath + ".mdl"))
            return ModelObject.transform;

        CRead = new CustomReader(File.OpenRead(OpenPath + ".mdl"));
        MDL_Header = CRead.ReadType<studiohdr_t>();
        ParseMdlFile();

        CRead = new CustomReader(File.OpenRead(OpenPath + ".vvd"));
        VVD_Header = CRead.ReadType<vertexFileHeader_t>();
        ParseVvdFile();

        CRead = new CustomReader(File.OpenRead(OpenPath + ".dx90.vtx"));
        VTX_Header = CRead.ReadType<FileHeader_t>();
        ParseVtxFile();

		if (!Configuration.Models.ContainsKey(ModelObject.name))
			Configuration.Models.Add(ModelName, ModelObject.transform);

        CRead.Dispose();
        return ModelObject.transform;
    }
Esempio n. 2
0
 public void loadFields(CustomReader r, int SavedWithVersion)
 {
 }
    public static Texture2D Load(string TextureName)
    {
        if (!File.Exists(Configuration.GameFld + Configuration.Mod + "/materials/" + TextureName + ".vtf"))
            return new Texture2D(1, 1);

        CRead = new CustomReader(File.OpenRead(Configuration.GameFld + Configuration.Mod + "/materials/" + TextureName + ".vtf"));
        VTF_Header = CRead.ReadType<tagVTFHEADER>();

        Texture2D VTF_Texture = default(Texture2D); TextureFormat ImageFormat;
        long OffsetInFile = VTF_Header.Width * VTF_Header.Height * uiBytesPerPixels[(int)VTF_Header.HighResImageFormat];

        switch (VTF_Header.HighResImageFormat)
        {
            case VTFImageFormat.IMAGE_FORMAT_DXT1:
                OffsetInFile = ((VTF_Header.Width + 3) / 4) * ((VTF_Header.Height + 3) / 4) * 8;
                ImageFormat = TextureFormat.DXT1; break;

            case VTFImageFormat.IMAGE_FORMAT_DXT3:
            case VTFImageFormat.IMAGE_FORMAT_DXT5:
                OffsetInFile = ((VTF_Header.Width + 3) / 4) * ((VTF_Header.Height + 3) / 4) * 16;
                ImageFormat = TextureFormat.DXT5; break;

            case VTFImageFormat.IMAGE_FORMAT_RGB888:
            case VTFImageFormat.IMAGE_FORMAT_BGR888:
                ImageFormat = TextureFormat.RGB24; break;

            case VTFImageFormat.IMAGE_FORMAT_RGBA8888:
                ImageFormat = TextureFormat.RGBA32; break;

            case VTFImageFormat.IMAGE_FORMAT_ARGB8888:
                ImageFormat = TextureFormat.ARGB32; break;

            case VTFImageFormat.IMAGE_FORMAT_BGRA8888:
                ImageFormat = TextureFormat.BGRA32; break;

            default: return new Texture2D(1, 1);
        }

        VTF_Texture = new Texture2D(VTF_Header.Width, VTF_Header.Height, ImageFormat, false);
        byte[] VTF_File = CRead.GetBytes((int)OffsetInFile, CRead.InputStream.Length - OffsetInFile);

        if (VTF_Header.HighResImageFormat == VTFImageFormat.IMAGE_FORMAT_BGR888)
        {
            for (int i = 0; i < VTF_File.Length - 1; i += 3)
            {
                byte Temp = VTF_File[i];
                VTF_File[i] = VTF_File[i + 2];
                VTF_File[i + 2] = Temp;
            }
        }

        VTF_Texture.LoadRawTextureData(VTF_File);

        Texture2D Mip_Texture = new Texture2D(VTF_Header.Width, VTF_Header.Height, TextureFormat.RGBA32, true);
        Mip_Texture.SetPixels32(VTF_Texture.GetPixels32());

        Mip_Texture.Apply(); Mip_Texture.Compress(false);
        Object.DestroyImmediate(VTF_Texture);

        CRead.Dispose();
        return Mip_Texture;
    }
Esempio n. 4
0
        public static void RegisterType <T>(CustomReader reader, CustomWriter writer)
        {
            var type = typeof(T);

            _customSerializers[type] = new CustomSerializer(reader, writer);
        }
Esempio n. 5
0
 public CustomSerializer(CustomReader reader, CustomWriter writer)
 {
     Read  = reader;
     Write = writer;
 }
Esempio n. 6
0
        /// <summary>
        /// This method creates an instance of a
        /// 'FindCustomReaderStoredProcedure' object and
        /// creates the sql parameter[] array needed
        /// to execute the procedure 'CustomReader_Find'.
        /// </summary>
        /// <param name="customReader">The 'CustomReader' to use to
        /// get the primary key parameter.</param>
        /// <returns>An instance of an FetchUserStoredProcedure</returns>
        public static FindCustomReaderStoredProcedure CreateFindCustomReaderStoredProcedure(CustomReader customReader)
        {
            // Initial Value
            FindCustomReaderStoredProcedure findCustomReaderStoredProcedure = null;

            // verify customReader exists
            if (customReader != null)
            {
                // Instanciate findCustomReaderStoredProcedure
                findCustomReaderStoredProcedure = new FindCustomReaderStoredProcedure();

                // Now create parameters for this procedure
                findCustomReaderStoredProcedure.Parameters = CreatePrimaryKeyParameter(customReader);
            }

            // return value
            return(findCustomReaderStoredProcedure);
        }
Esempio n. 7
0
        /// <summary>
        /// This method creates an instance of an
        /// 'DeleteCustomReader'StoredProcedure' object and
        /// creates the sql parameter[] array needed
        /// to execute the procedure 'CustomReader_Delete'.
        /// </summary>
        /// <param name="customReader">The 'CustomReader' to Delete.</param>
        /// <returns>An instance of a 'DeleteCustomReaderStoredProcedure' object.</returns>
        public static DeleteCustomReaderStoredProcedure CreateDeleteCustomReaderStoredProcedure(CustomReader customReader)
        {
            // Initial Value
            DeleteCustomReaderStoredProcedure deleteCustomReaderStoredProcedure = new DeleteCustomReaderStoredProcedure();

            // Now Create Parameters For The DeleteProc
            deleteCustomReaderStoredProcedure.Parameters = CreatePrimaryKeyParameter(customReader);

            // return value
            return(deleteCustomReaderStoredProcedure);
        }
Esempio n. 8
0
        /// <summary>
        /// This method creates an instance of a
        /// 'FetchAllCustomReadersStoredProcedure' object and
        /// creates the sql parameter[] array needed
        /// to execute the procedure 'CustomReader_FetchAll'.
        /// </summary>
        /// <returns>An instance of a(n) 'FetchAllCustomReadersStoredProcedure' object.</returns>
        public static FetchAllCustomReadersStoredProcedure CreateFetchAllCustomReadersStoredProcedure(CustomReader customReader)
        {
            // Initial value
            FetchAllCustomReadersStoredProcedure fetchAllCustomReadersStoredProcedure = new FetchAllCustomReadersStoredProcedure();

            // return value
            return(fetchAllCustomReadersStoredProcedure);
        }
Esempio n. 9
0
        /// <summary>
        /// This method creates an instance of an
        /// 'UpdateCustomReaderStoredProcedure' object and
        /// creates the sql parameter[] array needed
        /// to execute the procedure 'CustomReader_Update'.
        /// </summary>
        /// <param name="customReader"The 'CustomReader' object to update</param>
        /// <returns>An instance of a 'UpdateCustomReaderStoredProcedure</returns>
        public static UpdateCustomReaderStoredProcedure CreateUpdateCustomReaderStoredProcedure(CustomReader customReader)
        {
            // Initial Value
            UpdateCustomReaderStoredProcedure updateCustomReaderStoredProcedure = null;

            // verify customReader exists
            if (customReader != null)
            {
                // Instanciate updateCustomReaderStoredProcedure
                updateCustomReaderStoredProcedure = new UpdateCustomReaderStoredProcedure();

                // Now create parameters for this procedure
                updateCustomReaderStoredProcedure.Parameters = CreateUpdateParameters(customReader);
            }

            // return value
            return(updateCustomReaderStoredProcedure);
        }
Esempio n. 10
0
        /// <summary>
        /// This method creates an instance of an
        /// 'InsertCustomReaderStoredProcedure' object and
        /// creates the sql parameter[] array needed
        /// to execute the procedure 'CustomReader_Insert'.
        /// </summary>
        /// <param name="customReader"The 'CustomReader' object to insert</param>
        /// <returns>An instance of a 'InsertCustomReaderStoredProcedure' object.</returns>
        public static InsertCustomReaderStoredProcedure CreateInsertCustomReaderStoredProcedure(CustomReader customReader)
        {
            // Initial Value
            InsertCustomReaderStoredProcedure insertCustomReaderStoredProcedure = null;

            // verify customReader exists
            if (customReader != null)
            {
                // Instanciate insertCustomReaderStoredProcedure
                insertCustomReaderStoredProcedure = new InsertCustomReaderStoredProcedure();

                // Now create parameters for this procedure
                insertCustomReaderStoredProcedure.Parameters = CreateInsertParameters(customReader);
            }

            // return value
            return(insertCustomReaderStoredProcedure);
        }
        // <Summary>
        // This method is used to export a CustomReader object to xml.
        // </Summary>
        public string ExportCustomReader(CustomReader customReader, int indent = 0)
        {
            // initial value
            string customReaderXml = "";

            // locals
            string indentString  = TextHelper.Indent(indent);
            string indentString2 = TextHelper.Indent(indent + 2);

            // If the customReader object exists
            if (NullHelper.Exists(customReader))
            {
                // Create a StringBuilder
                StringBuilder sb = new StringBuilder();

                // Append the indentString
                sb.Append(indentString);

                // Write the open customReader node
                sb.Append("<CustomReader>" + Environment.NewLine);

                // Write out each property

                // Write out the value for ClassName

                sb.Append(indentString2);
                sb.Append("<ClassName>" + customReader.ClassName + "</ClassName>" + Environment.NewLine);

                // Write out the value for FetchAllForTable

                sb.Append(indentString2);
                sb.Append("<FetchAllForTable>" + customReader.FetchAllForTable + "</FetchAllForTable>" + Environment.NewLine);

                // If the value for the property customReader.HasFieldSet is true
                if (customReader.HasFieldSet)
                {
                    // Write out the value for FieldSet

                    // create a second writer
                    FieldSetsWriter fieldSetsWriter = new FieldSetsWriter();

                    // get the fieldSetsExml
                    string fieldSetXml = fieldSetsWriter.ExportFieldSet(customReader.FieldSet, indent + 1);

                    sb.Append(indentString2);
                    sb.Append(fieldSetXml);
                }

                // Write out the value for FieldSetId

                sb.Append(indentString2);
                sb.Append("<FieldSetId>" + customReader.FieldSetId + "</FieldSetId>" + Environment.NewLine);

                // Write out the value for DataWatcherFileName

                sb.Append(indentString2);
                sb.Append("<DataWatcherFileName>" + customReader.FileName + "</DataWatcherFileName>" + Environment.NewLine);

                // Write out the value for ReaderName

                sb.Append(indentString2);
                sb.Append("<ReaderName>" + customReader.ReaderName + "</ReaderName>" + Environment.NewLine);

                // Write out the value for TableId

                sb.Append(indentString2);
                sb.Append("<TableId>" + customReader.TableId + "</TableId>" + Environment.NewLine);

                // Append the indentString
                sb.Append(indentString);

                // Write out the close customReader node
                sb.Append("</CustomReader>" + Environment.NewLine);

                // set the return value
                customReaderXml = sb.ToString();
            }
            // return value
            return(customReaderXml);
        }
    public static Texture2D Load(string TextureName)
    {
        string TextureDestinationPath = Configuration.GameFld + Configuration.Mod + "/materials/" + TextureName + ".vtf";

        if (!File.Exists(TextureDestinationPath))
        {
            if (File.Exists(Configuration.GameFld + Configuration._Mod + "/materials/" + TextureName + ".vtf"))
                TextureDestinationPath = Configuration.GameFld + Configuration._Mod + "/materials/" + TextureName + ".vtf";
            else
                return new Texture2D(1, 1);
        }

        CRead = new CustomReader(File.OpenRead(TextureDestinationPath));
        VTF_Header = CRead.ReadType<tagVTFHEADER>();

        Texture2D VTF_Texture;
        TextureFormat ImageFormat;

        long OffsetInFile = VTF_Header.Width * VTF_Header.Height * uiBytesPerPixels[(int)VTF_Header.HighResImageFormat];

        switch (VTF_Header.HighResImageFormat)
        {
            case VTFImageFormat.IMAGE_FORMAT_DXT1:
                OffsetInFile = ((VTF_Header.Width + 3) / 4) * ((VTF_Header.Height + 3) / 4) * 8;
                ImageFormat = TextureFormat.DXT1;
                break;

            case VTFImageFormat.IMAGE_FORMAT_DXT3:
            case VTFImageFormat.IMAGE_FORMAT_DXT5:
                OffsetInFile = ((VTF_Header.Width + 3) / 4) * ((VTF_Header.Height + 3) / 4) * 16;
                ImageFormat = TextureFormat.DXT5;
                break;

            case VTFImageFormat.IMAGE_FORMAT_RGB888:
            case VTFImageFormat.IMAGE_FORMAT_BGR888:
                ImageFormat = TextureFormat.RGB24;
                break;

            case VTFImageFormat.IMAGE_FORMAT_RGBA8888:
                ImageFormat = TextureFormat.RGBA32;
                break;

            case VTFImageFormat.IMAGE_FORMAT_ARGB8888:
                ImageFormat = TextureFormat.ARGB32;
                break;

            case VTFImageFormat.IMAGE_FORMAT_BGRA8888:
                ImageFormat = TextureFormat.BGRA32;
                break;

            default:
                return new Texture2D(1, 1);
        }

        VTF_Texture = new Texture2D(VTF_Header.Width, VTF_Header.Height, ImageFormat, false);
        byte[] VTF_File = CRead.GetBytes((int)OffsetInFile, CRead.InputStream.Length - OffsetInFile);

        if (VTF_Header.HighResImageFormat == VTFImageFormat.IMAGE_FORMAT_BGR888)
        {
            for (int i = 0; i < VTF_File.Length - 1; i += 3)
            {
                byte Temp = VTF_File[i];
                VTF_File[i] = VTF_File[i + 2];
                VTF_File[i + 2] = Temp;
            }
        }

        VTF_Texture.LoadRawTextureData(VTF_File);
        CRead.Dispose();

        // MIPMAP NOT WORK!!! VERY SLOWLY!!!
        if (Configuration.AndroidCompression)
        {
            Texture2D Mip_Texture = new Texture2D(VTF_Header.Width, VTF_Header.Height);
            Mip_Texture.SetPixels32(VTF_Texture.GetPixels32());

            EditorUtility.CompressTexture(Mip_Texture, TextureFormat.ETC_RGB4, TextureCompressionQuality.Fast);
            Mip_Texture.Apply();

            return Mip_Texture;
        }

        VTF_Texture.Apply();
        return VTF_Texture;
    }
Esempio n. 13
0
        /// <summary>
        /// This method prepares this control to be shown
        /// </summary>
        public void Setup(MethodInfo methodInfo, Project openProject, CustomReader customReader = null, DTNField orderByField = null, FieldSet orderByFieldSet = null)
        {
            // store the args
            this.MethodInfo  = methodInfo;
            this.OpenProject = openProject;

            // locals
            DataJuggler.Net.DataField        parameter  = null;
            List <DataJuggler.Net.DataField> parameters = null;
            ProcedureWriter writer = null;

            // If the MethodInfo object exists
            if (this.HasMethodInfo)
            {
                // create a new
                MethodsWriter methodsWriter = new MethodsWriter();

                // get the StoredXml
                StoredXml = methodsWriter.ExportMethodInfo(this.MethodInfo);

                // if the OrderByFieldSet object exists
                if (NullHelper.Exists(orderByFieldSet))
                {
                    // set the gateway
                    Gateway gateway = new Gateway();

                    // load the orderByFields
                    orderByFieldSet.FieldSetFields = gateway.LoadFieldSetFieldViewsByFieldSetId(orderByFieldSet.FieldSetId);
                }

                // Set the Name of the Table
                this.SelectedTableControl.Text = this.MethodInfo.SelectedTable.TableName;

                // set the procedureName
                this.ProcedureNameControl.Text = MethodInfo.ProcedureName;

                // Check the button for Manual Update (user clicks Copy and goes to their SQL instance and executes).
                this.ManualUpdateRadioButton.Checked = true;

                // Check the box if UseCustomReader is true
                this.CustomWhereCheckBox.Checked = MethodInfo.UseCustomWhere;

                // Set the CustomWhereText (if any)
                this.WhereTextBox.Text = MethodInfo.WhereText;

                // convert the table
                DataJuggler.Net.DataTable table = DataConverter.ConvertDataTable(MethodInfo.SelectedTable, this.OpenProject);

                // if this is a Single Field Parameter and the Parameter Field exists
                if ((MethodInfo.ParameterType == ParameterTypeEnum.Single_Field) && (MethodInfo.HasParameterField))
                {
                    // convert the field from a DTNField to a DataJuggler.Net.DataField
                    parameter = DataConverter.ConvertDataField(MethodInfo.ParameterField);

                    // Create a new instance of a 'ProcedureWriter' object (in TextWriter mode).
                    writer = new ProcedureWriter(true);

                    // if this is a FindByField method
                    if (writer.HasTextWriter)
                    {
                        // If Delete By is the Method Type
                        if (MethodInfo.MethodType == MethodTypeEnum.Delete_By)
                        {
                            // Write out the Delete Proc
                            writer.CreateDeleteProc(table, MethodInfo.ProcedureName, parameter);
                        }
                        // If Find By is the Method Type
                        if (MethodInfo.MethodType == MethodTypeEnum.Find_By)
                        {
                            // create a find procedure
                            writer.CreateFindProc(table, false, MethodInfo.ProcedureName, parameter, customReader, orderByField, orderByFieldSet, methodInfo.OrderByDescending, methodInfo.TopRows);
                        }
                        // if Load By is the Method Type
                        else if (MethodInfo.MethodType == MethodTypeEnum.Load_By)
                        {
                            // If the orderByField object exists
                            if (NullHelper.Exists(orderByFieldSet))
                            {
                                // if there are not any fields loaded
                                if (!ListHelper.HasOneOrMoreItems(orderByFieldSet.Fields))
                                {
                                    // load the Fields
                                    orderByFieldSet.Fields = FieldSetHelper.LoadFieldSetFields(orderByFieldSet.FieldSetId);
                                }
                            }

                            // create a find procedure
                            writer.CreateFindProc(table, true, MethodInfo.ProcedureName, parameter, customReader, orderByField, orderByFieldSet, methodInfo.OrderByDescending, methodInfo.TopRows);
                        }
                    }
                }
                else if ((MethodInfo.ParameterType == ParameterTypeEnum.Field_Set) && (MethodInfo.HasParameterFieldSet) && (MethodInfo.ParameterFieldSet.HasFields))
                {
                    // convert the DTNFields to DataFields
                    parameters = DataConverter.ConvertDataFields(MethodInfo.ParameterFieldSet.Fields);

                    // If the parameters collection exists and has one or more items
                    if (ListHelper.HasOneOrMoreItems(parameters))
                    {
                        // set the FieldSetName so the description writes the method description correctly
                        parameters[0].FieldSetName = MethodInfo.ParameterFieldSet.Name;
                    }

                    // Create a new instance of a 'ProcedureWriter' object (in TextWriter mode).
                    writer = new ProcedureWriter(true);

                    // if this is a FindByField method
                    if (writer.HasTextWriter)
                    {
                        // If Delete By is the Method Type
                        if (MethodInfo.MethodType == MethodTypeEnum.Delete_By)
                        {
                            // Write out the Delete Proc
                            writer.CreateDeleteProc(table, MethodInfo.ProcedureName, parameters);
                        }
                        // If Find By is the Method Type
                        if (MethodInfo.MethodType == MethodTypeEnum.Find_By)
                        {
                            // create a find procedure
                            writer.CreateFindProc(table, false, MethodInfo.ProcedureName, parameters, MethodInfo.CustomReader, orderByField, orderByFieldSet);
                        }
                        // if Load By is the Method Type
                        else if (MethodInfo.MethodType == MethodTypeEnum.Load_By)
                        {
                            // create a find procedure
                            writer.CreateFindProc(table, true, MethodInfo.ProcedureName, parameters, MethodInfo.CustomReader, orderByField, orderByFieldSet);
                        }
                    }
                }
                else if ((MethodInfo.ParameterType == ParameterTypeEnum.No_Parameters))
                {
                    // Create a new instance of a 'ProcedureWriter' object (in TextWriter mode).
                    writer = new ProcedureWriter(true);

                    // if this is a FindByField method
                    if (writer.HasTextWriter)
                    {
                        // If Delete By is the Method Type
                        if (MethodInfo.MethodType == MethodTypeEnum.Delete_By)
                        {
                            // Write out the Delete Proc
                            writer.CreateDeleteProc(table, MethodInfo.ProcedureName, parameters);
                        }
                        // If Find By is the Method Type
                        if (MethodInfo.MethodType == MethodTypeEnum.Find_By)
                        {
                            // create a find procedure
                            writer.CreateFindProc(table, false, MethodInfo.ProcedureName, parameters, MethodInfo.CustomReader, orderByField, orderByFieldSet);
                        }
                        // if Load By is the Method Type
                        else if (MethodInfo.MethodType == MethodTypeEnum.Load_By)
                        {
                            // create a find procedure
                            writer.CreateFindProc(table, true, MethodInfo.ProcedureName, parameters, MethodInfo.CustomReader, orderByField, orderByFieldSet);
                        }
                    }
                }

                // if the writer exists
                if (NullHelper.Exists(writer))
                {
                    // get the procedureText
                    string procedureText = writer.TextWriter.ToString();

                    // Show the Where Panel if CustomWhere is true
                    WherePanel.Visible = MethodInfo.UseCustomWhere;

                    // if CustomWhere
                    if (MethodInfo.UseCustomWhere)
                    {
                        // now the existing where text must be replaced
                        int whereIndex = procedureText.ToLower().IndexOf("where [");

                        // if the WhereText does not exist yet
                        if ((!MethodInfo.HasWhereText) && (whereIndex > 0))
                        {
                            // Set the text as it is now
                            string whereText = procedureText.Substring(whereIndex);

                            // If the whereText string exists
                            if (TextHelper.Exists(whereText))
                            {
                                // get the textLines
                                List <TextLine> textLines = WordParser.GetTextLines(whereText);

                                // If the textLines collection exists and has one or more items
                                if (ListHelper.HasOneOrMoreItems(textLines))
                                {
                                    // Create a new instance of a 'StringBuilder' object.
                                    StringBuilder sb = new StringBuilder();

                                    // add each textLine of the Where Clause except the last one
                                    foreach (TextLine textLine in textLines)
                                    {
                                        // if this is the End line
                                        if (!textLine.Text.ToLower().StartsWith("end"))
                                        {
                                            // Add this line
                                            sb.Append(textLine.Text);
                                        }
                                    }

                                    // Get the Where Clause
                                    MethodInfo.WhereText = sb.ToString().Trim();
                                }
                            }
                        }

                        // Set the WhereText
                        WhereTextBox.Text = MethodInfo.WhereText;

                        // if the whereIndex was found
                        if (whereIndex >= 0)
                        {
                            // if the WhereText does not already exist
                            if (!TextHelper.Exists(MethodInfo.WhereText))
                            {
                                // Set the default WhereText
                                MethodInfo.WhereText = procedureText.Substring(whereIndex);
                            }

                            // set the new ProcedureText
                            procedureText = procedureText.Substring(0, whereIndex) + MethodInfo.WhereText + Environment.NewLine + Environment.NewLine + "END";
                        }
                    }

                    // Remove any double blank lines
                    procedureText = CodeLineHelper.RemoveDoubleBlankLines(procedureText);

                    // display the procedure As Is for now.
                    this.ProcedureTextBox.Text = procedureText;
                }
            }
        }
    public void Load()
    {
        Clear();

        if (!File.Exists(Configuration.GameFld + Configuration.Mod + "/maps/" + LevelName + ".bsp"))
            throw new FileNotFoundException(Configuration.GameFld + Configuration.Mod + "/maps/" + LevelName + ".bsp");

        Configuration.Initialize(LevelName);
        Configuration.AndroidCompression = AndroidCompression;

        CRead = new CustomReader(File.OpenRead(Configuration.GameFld + Configuration.Mod + "/maps/" + LevelName + ".bsp"));
        BSP_Header = CRead.ReadType<BspSpecification.dheader_t>();

        if (BSP_Header.ident != (('P' << 24) + ('S' << 16) + ('B' << 8) + 'V'))
            throw new FileLoadException("Wrong magic number");

        if (BSP_Header.version < 19 || BSP_Header.version > 21)
            throw new FileLoadException(string.Format("BSP version ({0}) isn't supported", BSP_Header.version));

        if (BSP_Header.lumps[0].fileofs == 0)
        {
            Debug.Log("Found Left 4 Dead 2 header");
            for (int i = 0; i < BSP_Header.lumps.Length; i++)
            {
                BSP_Header.lumps[i].fileofs = BSP_Header.lumps[i].filelen;
                BSP_Header.lumps[i].filelen = BSP_Header.lumps[i].version;
            }
        }

        string input = Encoding.ASCII.GetString(CRead.GetBytes(BSP_Header.lumps[0].filelen, BSP_Header.lumps[0].fileofs));
        foreach (Match match in Regex.Matches(input, @"{[^}]*}", RegexOptions.IgnoreCase))
            BSP_Entities.Add(match.Value);

        if (!HighDynamicRange)
            BSP_Faces.AddRange(CRead.ReadType<BspSpecification.dface_t>(BSP_Header.lumps[7].filelen / 56, BSP_Header.lumps[7].fileofs));
        else
            BSP_Faces.AddRange(CRead.ReadType<BspSpecification.dface_t>(BSP_Header.lumps[58].filelen / 56, BSP_Header.lumps[58].fileofs));

        BSP_Models.AddRange(CRead.ReadType<BspSpecification.dmodel_t>(BSP_Header.lumps[14].filelen / 48, BSP_Header.lumps[14].fileofs));

        BSP_DispInfo.AddRange(CRead.ReadType<BspSpecification.ddispinfo_t>(BSP_Header.lumps[26].filelen / 176, BSP_Header.lumps[26].fileofs));
        BSP_DispVerts.AddRange(CRead.ReadType<BspSpecification.dDispVert>(BSP_Header.lumps[33].filelen / 20, BSP_Header.lumps[33].fileofs));

        BSP_TexData.AddRange(CRead.ReadType<BspSpecification.dtexdata_t>(BSP_Header.lumps[2].filelen / 32, BSP_Header.lumps[2].fileofs));
        BSP_TexInfo.AddRange(CRead.ReadType<BspSpecification.texinfo_t>(BSP_Header.lumps[6].filelen / 72, BSP_Header.lumps[6].fileofs));

        int[] BSP_TexStrTable = CRead.ReadType<int>(BSP_Header.lumps[44].filelen / 4, BSP_Header.lumps[44].fileofs);
        BSP_TexStrData.AddRange(CRead.ReadNullTerminatedString(BSP_TexStrTable, BSP_Header.lumps[43].fileofs));

        BSP_Edges.AddRange(CRead.ReadType<BspSpecification.dedge_t>(BSP_Header.lumps[12].filelen / 4, BSP_Header.lumps[12].fileofs));
        BSP_Vertices.AddRange(CRead.ReadType<Vector3>(BSP_Header.lumps[3].filelen / 12, BSP_Header.lumps[3].fileofs));
        BSP_Surfedges.AddRange(CRead.ReadType<int>(BSP_Header.lumps[13].filelen / 4, BSP_Header.lumps[13].fileofs));

        UnpackPakFile(CRead.GetBytes(BSP_Header.lumps[40].filelen, BSP_Header.lumps[40].fileofs));

        for (int i = 0; i < BSP_Entities.Count; i++)
            LoadEntity(i);

        CRead.Dispose();
    }
        /// <summary>
        /// This method creates an instance of a
        /// 'FetchAllCustomReadersStoredProcedure' object and
        /// creates the sql parameter[] array needed
        /// to execute the procedure 'CustomReader_FetchAll'.
        /// </summary>
        /// <returns>An instance of a(n) 'FetchAllCustomReadersStoredProcedure' object.</returns>
        public static new FetchAllCustomReadersStoredProcedure CreateFetchAllCustomReadersStoredProcedure(CustomReader customReader)
        {
            // Initial value
            FetchAllCustomReadersStoredProcedure fetchAllCustomReadersStoredProcedure = new FetchAllCustomReadersStoredProcedure();

            // If the customReader object exists
            if (customReader != null)
            {
                // if the TableId is set and FetchAllFortable is true
                if ((customReader.HasTableId) && (customReader.FetchAllForTable))
                {
                    // change the procedure name
                    fetchAllCustomReadersStoredProcedure.ProcedureName = "CustomReader_FetchAllForTable";

                    // create the @TableId parameter
                    fetchAllCustomReadersStoredProcedure.Parameters = SqlParameterHelper.CreateSqlParameters("@TableId", customReader.TableId);
                }
            }

            // return value
            return(fetchAllCustomReadersStoredProcedure);
        }
Esempio n. 16
0
 /// <summary>
 /// This method Setup
 /// </summary>
 public void Setup(Project openProject, DTNTable selectedTable, CustomReader selectedReader = null)
 {
     // Setup the form
     CustomReadersEditor.Setup(openProject, selectedTable, selectedReader);
 }