ConsumeString() public method

public ConsumeString ( string _ExpectedString, bool _caseSensitive ) : void
_ExpectedString string
_caseSensitive bool
return void
Example #1
0
                public Texture( string _textureLine )
                {
                    m_rawTextureLine = _textureLine;

                    // Parse texture name
                    Parser	P = new Parser( _textureLine );
                    m_name = P.ReadString( true, false );

                    try {
                        // Check if it's a constant color
                        m_name = m_name.ToLower();
                        if ( m_name.StartsWith( "_" ) ) {
                            // Procedural texture
                            switch ( m_name ) {
                                case "_default":			m_constantColorType = CONSTANT_COLOR_TYPE.DEFAULT; break;
                                case "_black":				m_constantColorType = CONSTANT_COLOR_TYPE.BLACK; break;
                                case "_blackalphawhite":	m_constantColorType = CONSTANT_COLOR_TYPE.BLACK_ALPHA_WHITE; break;
                                case "_white":				m_constantColorType = CONSTANT_COLOR_TYPE.WHITE; break;
                                case "_invalid":			m_constantColorType = CONSTANT_COLOR_TYPE.INVALID; break;
                                default: throw new Exception( "Unsupported procedural texture type \"" + m_name + "\"!" );
                            }
                        } else if ( m_name.StartsWith( "ipr_constantcolor" ) ) {
                            m_constantColorType = CONSTANT_COLOR_TYPE.CUSTOM;
                            P = new Parser( _textureLine );
                            P.ConsumeString( "ipr_constantColor", false );
                            string	strColor = P.ReadBlock( '(', ')' );
                            m_customConstantColor = P.ReadFloat4( strColor );

                            // Compare known colors to revert to basic types
                            if ( CompareFloat4( m_customConstantColor, float4.Zero ) ) {
                                m_constantColorType = CONSTANT_COLOR_TYPE.BLACK;
                            } else if ( CompareFloat4( m_customConstantColor, float4.UnitW ) ) {
                                m_constantColorType = CONSTANT_COLOR_TYPE.BLACK_ALPHA_WHITE;
                            } else if ( CompareFloat4( m_customConstantColor, float4.One ) ) {
                                m_constantColorType = CONSTANT_COLOR_TYPE.WHITE;
                            }
                        }

                        if ( m_constantColorType == CONSTANT_COLOR_TYPE.TEXTURE ) {
                            // Build file name
                            string	fullPath = Path.Combine( ms_TexturesBasePath.FullName, m_name );
                            if ( Path.GetExtension( fullPath.ToLower() ) == "" )
                                fullPath += ".tga";	// Assume tga files if unspecified
                            m_fileName = new FileInfo( fullPath );
                        }
                    } catch ( Exception _e ) {
                        m_error = _e;
                    }
                }