public override bool Parse(string text) { idLexer lexer = new idLexer(LexerOptions.NoStringConcatination | LexerOptions.AllowPathNames | LexerOptions.AllowMultiCharacterLiterals | LexerOptions.AllowBackslashStringConcatination | LexerOptions.NoFatalErrors); lexer.LoadMemory(text, this.FileName, this.LineNumber); lexer.SkipUntilString("{"); idToken token; string tokenValue; while (true) { if ((token = lexer.ReadToken()) == null) { break; } tokenValue = token.ToString().ToLower(); if (tokenValue == "}") { break; } if (tokenValue == "audio") { _audio = lexer.ReadToken().ToString(); idE.DeclManager.FindSound(_audio); } else if (tokenValue == "info") { _info = lexer.ReadToken().ToString(); } else if (tokenValue == "name") { _videoName = lexer.ReadToken().ToString(); } else if (tokenValue == "preview") { _preview = lexer.ReadToken().ToString(); } else if (tokenValue == "video") { _video = lexer.ReadToken().ToString(); idE.DeclManager.FindMaterial(_video); } } if (lexer.HadError == true) { lexer.Warning("Video decl '{0}' had a parse error", this.Name); return(false); } return(true); }
public override bool Parse(string text) { if (this.Disposed == true) { throw new ObjectDisposedException(this.GetType().Name); } idLexer lexer = new idLexer(idDeclFile.LexerOptions); lexer.LoadMemory(text, this.FileName, this.LineNumber); lexer.SkipUntilString("{"); idToken token; string tokenValue; idConsole.Warning("TODO: actual fx parsing, we only step over the block"); while (true) { if ((token = lexer.ReadToken()) == null) { break; } tokenValue = token.ToString().ToLower(); if (tokenValue == "}") { break; } if (tokenValue == "bindto") { token = lexer.ReadToken(); idConsole.Warning("TODO: FX: joint = token;"); } else if (tokenValue == "{") { idConsole.Warning("TODO: FX: idFXSingleAction action;"); ParseSingleAction(lexer /*, action*/); // events.Append(action); continue; } } if (lexer.HadError == true) { lexer.Warning("FX decl '{0}' had a parse error", this.Name); return(false); } return(true); }
public virtual bool Parse(string text) { if (this.Disposed == true) { throw new ObjectDisposedException(this.GetType().Name); } idLexer lexer = new idLexer(idDeclFile.LexerOptions); lexer.LoadMemory(text, this.FileName, this.LineNumber); lexer.SkipUntilString("{"); lexer.SkipBracedSection(false); return(true); }
public override bool Parse(string text) { if (this.Disposed == true) { throw new ObjectDisposedException(this.GetType().Name); } idLexer lexer = new idLexer(idDeclFile.LexerOptions); lexer.LoadMemory(text, this.FileName, this.LineNumber); lexer.SkipUntilString("{"); // deeper functions can set this, which will cause MakeDefault() to be called at the end _errorDuringParse = false; if ((ParseMaterial(lexer) == false) || (_errorDuringParse == true)) { MakeDefault(); return(false); } return(true); }
public override bool Parse(string text) { idLexer lexer = new idLexer(LexerOptions.NoStringConcatination | LexerOptions.AllowPathNames | LexerOptions.AllowMultiCharacterLiterals | LexerOptions.AllowBackslashStringConcatination | LexerOptions.NoFatalErrors); lexer.LoadMemory(text, this.FileName, this.LineNumber); lexer.SkipUntilString("{"); idToken token; string tokenValue; while(true) { if((token = lexer.ReadToken()) == null) { break; } tokenValue = token.ToString().ToLower(); if(tokenValue == "}") { break; } if(tokenValue == "audio") { _audio = lexer.ReadToken().ToString(); idE.DeclManager.FindSound(_audio); } else if(tokenValue == "info") { _info = lexer.ReadToken().ToString(); } else if(tokenValue == "name") { _audioName = lexer.ReadToken().ToString(); } else if(tokenValue == "preview") { _preview = lexer.ReadToken().ToString(); } } if(lexer.HadError == true) { lexer.Warning("Video decl '{0}' had a parse error", this.Name); return false; } return true; }
public override bool Parse(string text) { if(this.Disposed == true) { throw new ObjectDisposedException("idDeclTable"); } idLexer lexer = new idLexer(idDeclFile.LexerOptions); lexer.LoadMemory(text, this.FileName, this.LineNumber); lexer.SkipUntilString("{"); idToken token; List<float> values = new List<float>(); string tokenLower; string tokenValue; while(true) { if((token = lexer.ReadToken()) == null) { break; } tokenValue = token.ToString(); tokenLower = tokenValue.ToLower(); if(tokenLower == "}") { break; } else if(tokenLower == "snap") { _snap = true; } else if(tokenLower == "clamp") { _clamp = true; } else if(tokenLower == "{") { while(true) { bool errorFlag; float v = lexer.ParseFloat(out errorFlag); if(errorFlag == true) { // we got something non-numeric MakeDefault(); return false; } values.Add(v); token = lexer.ReadToken(); tokenValue = token.ToString(); if(tokenValue == "}") { break; } else if(tokenValue == ",") { continue; } lexer.Warning("expected comma or brace"); MakeDefault(); return false; } } else { lexer.Warning("unknown token '{0}'", tokenValue); MakeDefault(); return false; } } // copy the 0 element to the end, so lerping doesn't // need to worry about the wrap case float val = values[0]; values.Add(val); _values = values.ToArray(); return true; }
public override bool Parse(string text) { if (this.Disposed == true) { throw new ObjectDisposedException(this.GetType().Name); } idLexer lexer = new idLexer(idDeclFile.LexerOptions); lexer.LoadMemory(text, this.FileName, this.LineNumber); lexer.SkipUntilString("{"); idToken token; idToken token2; string value; while (true) { if ((token = lexer.ReadToken()) == null) { break; } value = token.ToString(); if (value == "}") { break; } if (token.Type != TokenType.String) { lexer.Warning("Expected quoted string, but found '{0}'", value); MakeDefault(); return(false); } if ((token2 = lexer.ReadToken()) == null) { lexer.Warning("Unexpected end of file"); MakeDefault(); return(false); } if (_dict.ContainsKey(value) == true) { lexer.Warning("'{0}' already defined", value); } _dict.Set(value, token2.ToString()); } // we always automatically set a "classname" key to our name _dict.Set("classname", this.Name); // "inherit" keys will cause all values from another entityDef to be copied into this one // if they don't conflict. We can't have circular recursions, because each entityDef will // never be parsed more than once // find all of the dicts first, because copying inherited values will modify the dict List <idDeclEntity> defList = new List <idDeclEntity>(); List <string> keysToRemove = new List <string>(); foreach (KeyValuePair <string, string> kvp in _dict.MatchPrefix("inherit")) { idDeclEntity copy = idE.DeclManager.FindType <idDeclEntity>(DeclType.EntityDef, kvp.Value, false); if (copy == null) { lexer.Warning("Unknown entityDef '{0}' inherited by '{1}'", kvp.Value, this.Name); } else { defList.Add(copy); } // delete this key/value pair keysToRemove.Add(kvp.Key); } _dict.Remove(keysToRemove.ToArray()); // now copy over the inherited key / value pairs foreach (idDeclEntity def in defList) { _dict.SetDefaults(def._dict); } // precache all referenced media // do this as long as we arent in modview idE.Game.CacheDictionaryMedia(_dict); return(true); }
public override bool Parse(string text) { if(this.Disposed == true) { throw new ObjectDisposedException(this.GetType().Name); } idLexer lexer = new idLexer(idDeclFile.LexerOptions); lexer.LoadMemory(text, this.FileName, this.LineNumber); lexer.SkipUntilString("{"); List<SkinMapping> mappings = new List<SkinMapping>(); List<string> associatedModels = new List<string>(); idToken token, token2; string tokenLower; while(true) { if((token = lexer.ReadToken()) == null) { break; } tokenLower = token.ToString().ToLower(); if(tokenLower == "}") { break; } else if((token2 = lexer.ReadToken()) == null) { lexer.Warning("Unexpected end of file"); MakeDefault(); break; } else if(tokenLower == "model") { associatedModels.Add(token2.ToString()); continue; } SkinMapping map = new SkinMapping(); map.To = idE.DeclManager.FindMaterial(token2.ToString()); if(tokenLower == "*") { // wildcard. map.From = null; } else { map.From = idE.DeclManager.FindMaterial(token.ToString()); } mappings.Add(map); } _mappings = mappings.ToArray(); _associatedModels = associatedModels.ToArray(); return false; }
public override bool Parse(string text) { if (this.Disposed == true) { throw new ObjectDisposedException(this.GetType().Name); } idLexer lexer = new idLexer(LexerOptions.NoStringConcatination | LexerOptions.AllowPathNames | LexerOptions.AllowMultiCharacterLiterals | LexerOptions.AllowBackslashStringConcatination | LexerOptions.NoFatalErrors); lexer.LoadMemory(text, this.FileName, this.LineNumber); lexer.SkipUntilString("{"); idToken token; _text = string.Empty; string tokenLower; string tokenValue; // scan through, identifying each individual parameter while (true) { if ((token = lexer.ReadToken()) == null) { break; } tokenValue = token.ToString(); tokenLower = tokenValue.ToLower(); if (tokenValue == "}") { break; } else if (tokenLower == "subject") { _subject = lexer.ReadToken().ToString(); } else if (tokenLower == "to") { _to = lexer.ReadToken().ToString(); } else if (tokenLower == "from") { _from = lexer.ReadToken().ToString(); } else if (tokenLower == "date") { _date = lexer.ReadToken().ToString(); } else if (tokenLower == "text") { token = lexer.ReadToken(); tokenValue = token.ToString(); if (tokenValue != "{") { lexer.Warning("Email dec '{0}' had a parse error", this.Name); return(false); } while (((token = lexer.ReadToken()) != null) && (token.ToString() != "}")) { _text += token.ToString(); } } else if (tokenLower == "image") { _image = lexer.ReadToken().ToString(); } } if (lexer.HadError == true) { lexer.Warning("Email decl '{0}' had a parse error", this.Name); return(false); } return(true); }
public override bool Parse(string text) { if (this.Disposed == true) { throw new ObjectDisposedException(this.GetType().Name); } idToken token; string tokenLower; idLexer lexer = new idLexer(idDeclFile.LexerOptions); lexer.LoadMemory(text, this.FileName, this.LineNumber); lexer.SkipUntilString("{"); while (true) { if ((token = lexer.ReadToken()) == null) { break; } tokenLower = token.ToString().ToLower(); if (tokenLower == "}") { break; } else if (tokenLower == "name") { token = lexer.ReadToken(); _pdaName = (token != null) ? token.ToString() : string.Empty; } else if (tokenLower == "fullname") { token = lexer.ReadToken(); _fullName = (token != null) ? token.ToString() : string.Empty; } else if (tokenLower == "icon") { token = lexer.ReadToken(); _icon = (token != null) ? token.ToString() : string.Empty; } else if (tokenLower == "id") { token = lexer.ReadToken(); _id = (token != null) ? token.ToString() : string.Empty; } else if (tokenLower == "post") { token = lexer.ReadToken(); _post = (token != null) ? token.ToString() : string.Empty; } else if (tokenLower == "title") { token = lexer.ReadToken(); _title = (token != null) ? token.ToString() : string.Empty; } else if (tokenLower == "security") { token = lexer.ReadToken(); _security = (token != null) ? token.ToString() : string.Empty; } else if (tokenLower == "pda_email") { token = lexer.ReadToken(); _emailList.Add(token.ToString()); idE.DeclManager.FindType(DeclType.Email, token.ToString()); } else if (tokenLower == "pda_audio") { token = lexer.ReadToken(); _audioList.Add(token.ToString()); idE.DeclManager.FindType(DeclType.Audio, token.ToString()); } else if (tokenLower == "pda_video") { token = lexer.ReadToken(); _videoList.Add(token.ToString()); idE.DeclManager.FindType(DeclType.Video, token.ToString()); } } if (lexer.HadError == true) { lexer.Warning("PDA decl '{0}' had a parse error", this.Name); return(false); } _originalVideoCount = _videoList.Count; _originalEmailCount = _emailList.Count; return(true); }
public override bool Parse(string text) { if (this.Disposed == true) { throw new ObjectDisposedException(this.GetType().Name); } idLexer lexer = new idLexer(idDeclFile.LexerOptions); lexer.LoadMemory(text, this.FileName, this.LineNumber); lexer.SkipUntilString("{"); int defaultAnimationCount = 0; idToken token; idToken token2; string tokenValue; string fileName; string extension; int count; idMD5Joint[] md5Joints; while (true) { if ((token = lexer.ReadToken()) == null) { break; } tokenValue = token.ToString(); if (tokenValue == "}") { break; } if (tokenValue == "inherit") { idConsole.WriteLine("TODO: inherit"); /*if( !src.ReadToken( &token2 ) ) { * src.Warning( "Unexpected end of file" ); * MakeDefault(); * return false; * } * * const idDeclModelDef *copy = static_cast<const idDeclModelDef *>( declManager->FindType( DECL_MODELDEF, token2, false ) ); * if ( !copy ) { * common->Warning( "Unknown model definition '%s'", token2.c_str() ); * } else if ( copy->GetState() == DS_DEFAULTED ) { * common->Warning( "inherited model definition '%s' defaulted", token2.c_str() ); * MakeDefault(); * return false; * } else { * CopyDecl( copy ); * numDefaultAnims = anims.Num(); * }*/ } else if (tokenValue == "skin") { if ((token2 = lexer.ReadToken()) == null) { lexer.Warning("Unexpected end of file"); MakeDefault(); return(false); } _skin = idE.DeclManager.FindSkin(token2.ToString()); if (_skin == null) { lexer.Warning("Skin '{0}' not found", token2.ToString()); MakeDefault(); return(false); } } else if (tokenValue == "mesh") { if ((token2 = lexer.ReadToken()) == null) { lexer.Warning("Unexpected end of file"); MakeDefault(); return(false); } fileName = token2.ToString(); extension = Path.GetExtension(fileName); if (extension != idRenderModel_MD5.MeshExtension) { lexer.Warning("Invalid model for MD5 mesh"); MakeDefault(); return(false); } _model = idE.RenderModelManager.FindModel(fileName); if (_model == null) { lexer.Warning("Model '{0}' not found", fileName); MakeDefault(); return(false); } else if (_model.IsDefault == true) { lexer.Warning("Model '{0}' defaulted", fileName); MakeDefault(); return(false); } // get the number of joints count = _model.JointCount; if (count == 0) { lexer.Warning("Model '{0}' has no joints", fileName); } // set up the joint hierarchy md5Joints = _model.Joints; _joints = new JointInfo[count]; _jointParents = new int[count]; _channelJoints = new int[(int)AnimationChannel.Count][]; _channelJoints[0] = new int[count]; for (int i = 0; i < count; i++) { _joints[i] = new JointInfo(); _joints[i].Channel = AnimationChannel.All; _joints[i].Index = i; if (md5Joints[i].Parent != null) { _joints[i].ParentIndex = _model.GetJointIndex(md5Joints[i].Parent); } else { _joints[i].ParentIndex = -1; } _jointParents[i] = _joints[i].ParentIndex; _channelJoints[0][i] = i; } } else if (tokenValue == "remove") { idConsole.Warning("TODO: remove"); // removes any anims whos name matches /*if( !src.ReadToken( &token2 ) ) { * src.Warning( "Unexpected end of file" ); * MakeDefault(); * return false; * } * num = 0; * for( i = 0; i < anims.Num(); i++ ) { * if ( ( token2 == anims[ i ]->Name() ) || ( token2 == anims[ i ]->FullName() ) ) { * delete anims[ i ]; * anims.RemoveIndex( i ); * if ( i >= numDefaultAnims ) { * src.Warning( "Anim '%s' was not inherited. Anim should be removed from the model def.", token2.c_str() ); * MakeDefault(); * return false; * } * i--; * numDefaultAnims--; * num++; * continue; * } * } * if ( !num ) { * src.Warning( "Couldn't find anim '%s' to remove", token2.c_str() ); * MakeDefault(); * return false; * }*/ } else if (tokenValue == "anim") { if (_model == null) { lexer.Warning("Must specify mesh before defining anims"); MakeDefault(); return(false); } else if (ParseAnimation(lexer, defaultAnimationCount) == false) { MakeDefault(); return(false); } } else if (tokenValue == "offset") { float[] tmp = lexer.Parse1DMatrix(3); if (tmp == null) { lexer.Warning("Expected vector following 'offset'"); MakeDefault(); return(false); } _offset = new Vector3(tmp[0], tmp[1], tmp[2]); } else if (tokenValue == "channel") { if (_model == null) { lexer.Warning("Must specify mesh before defining channels"); MakeDefault(); return(false); } // set the channel for a group of joints if ((token2 = lexer.ReadToken()) == null) { lexer.Warning("Unexpected end of file"); MakeDefault(); return(false); } if (lexer.CheckTokenString("(") == false) { lexer.Warning("Expected { after '{0}'", token2.ToString()); MakeDefault(); return(false); } int i; int channelCount = (int)AnimationChannel.Count; for (i = (int)AnimationChannel.All + 1; i < channelCount; i++) { if (ChannelNames[i].Equals(token2.ToString(), StringComparison.OrdinalIgnoreCase) == true) { break; } } if (i >= channelCount) { lexer.Warning("Unknown channel '{0}'", token2.ToString()); MakeDefault(); return(false); } int channel = i; StringBuilder jointNames = new StringBuilder(); string token2Value; while (lexer.CheckTokenString(")") == false) { if ((token2 = lexer.ReadToken()) == null) { lexer.Warning("Unexpected end of file"); MakeDefault(); return(false); } token2Value = token2.ToString(); jointNames.Append(token2Value); if ((token2Value != "*") && (token2Value != "-")) { jointNames.Append(" "); } } int[] jointList = GetJointList(jointNames.ToString()); int jointLength = jointList.Length; List <int> channelJoints = new List <int>(); for (count = i = 0; i < jointLength; i++) { int jointIndex = jointList[i]; if (_joints[jointIndex].Channel != AnimationChannel.All) { lexer.Warning("Join '{0}' assigned to multiple channels", _model.GetJointName(jointIndex)); continue; } _joints[jointIndex].Channel = (AnimationChannel)channel; channelJoints.Add(jointIndex); } _channelJoints[channel] = channelJoints.ToArray(); } else { lexer.Warning("unknown token '{0}'", token.ToString()); MakeDefault(); return(false); } } return(true); }
public override bool Parse(string text) { if (this.Disposed == true) { throw new ObjectDisposedException("idDeclTable"); } idLexer lexer = new idLexer(idDeclFile.LexerOptions); lexer.LoadMemory(text, this.FileName, this.LineNumber); lexer.SkipUntilString("{"); idToken token; List <float> values = new List <float>(); string tokenLower; string tokenValue; while (true) { if ((token = lexer.ReadToken()) == null) { break; } tokenValue = token.ToString(); tokenLower = tokenValue.ToLower(); if (tokenLower == "}") { break; } else if (tokenLower == "snap") { _snap = true; } else if (tokenLower == "clamp") { _clamp = true; } else if (tokenLower == "{") { while (true) { bool errorFlag; float v = lexer.ParseFloat(out errorFlag); if (errorFlag == true) { // we got something non-numeric MakeDefault(); return(false); } values.Add(v); token = lexer.ReadToken(); tokenValue = token.ToString(); if (tokenValue == "}") { break; } else if (tokenValue == ",") { continue; } lexer.Warning("expected comma or brace"); MakeDefault(); return(false); } } else { lexer.Warning("unknown token '{0}'", tokenValue); MakeDefault(); return(false); } } // copy the 0 element to the end, so lerping doesn't // need to worry about the wrap case float val = values[0]; values.Add(val); _values = values.ToArray(); return(true); }
public override bool Parse(string text) { if(this.Disposed == true) { throw new ObjectDisposedException(this.GetType().Name); } idLexer lexer = new idLexer(idDeclFile.LexerOptions); lexer.LoadMemory(text, this.FileName, this.LineNumber); lexer.SkipUntilString("{"); idToken token; string tokenValue; idConsole.Warning("TODO: actual fx parsing, we only step over the block"); while(true) { if((token = lexer.ReadToken()) == null) { break; } tokenValue = token.ToString().ToLower(); if(tokenValue == "}") { break; } if(tokenValue == "bindto") { token = lexer.ReadToken(); idConsole.Warning("TODO: FX: joint = token;"); } else if(tokenValue == "{") { idConsole.Warning("TODO: FX: idFXSingleAction action;"); ParseSingleAction(lexer/*, action*/); // events.Append(action); continue; } } if(lexer.HadError == true) { lexer.Warning("FX decl '{0}' had a parse error", this.Name); return false; } return true; }
public override bool Parse(string text) { if (this.Disposed == true) { throw new ObjectDisposedException(this.GetType().Name); } idToken token; string tokenLower; idLexer lexer = new idLexer(idDeclFile.LexerOptions); lexer.LoadMemory(text, this.FileName, this.LineNumber); lexer.SkipUntilString("{"); List <idParticleStage> stages = new List <idParticleStage>(); _depthHack = 0.0f; while (true) { if ((token = lexer.ReadToken()) == null) { break; } tokenLower = token.ToString().ToLower(); if (tokenLower == "}") { break; } else if (tokenLower == "{") { idParticleStage stage = ParseParticleStage(lexer); if (stage == null) { lexer.Warning("Particle stage parse failed"); MakeDefault(); return(false); } stages.Add(stage); } else if (tokenLower == "depthhack") { _depthHack = lexer.ParseFloat(); } else { lexer.Warning("bad token {0}", token.ToString()); MakeDefault(); return(false); } } _stages = stages.ToArray(); // // calculate the bounds // _bounds.Clear(); int count = _stages.Length; for (int i = 0; i < count; i++) { idConsole.Warning("TODO: GetStageBounds"); // TODO: GetStageBounds(stages[i]); _bounds += _stages[i].Bounds; } if (_bounds.Volume <= 0.1f) { _bounds = idBounds.Expand(idBounds.Zero, 8.0f); } return(true); }
public override bool Parse(string text) { if(this.Disposed == true) { throw new ObjectDisposedException(this.GetType().Name); } idToken token; string tokenLower; idLexer lexer = new idLexer(idDeclFile.LexerOptions); lexer.LoadMemory(text, this.FileName, this.LineNumber); lexer.SkipUntilString("{"); while(true) { if((token = lexer.ReadToken()) == null) { break; } tokenLower = token.ToString().ToLower(); if(tokenLower == "}") { break; } else if(tokenLower == "name") { token = lexer.ReadToken(); _pdaName = (token != null) ? token.ToString() : string.Empty; } else if(tokenLower == "fullname") { token = lexer.ReadToken(); _fullName = (token != null) ? token.ToString() : string.Empty; } else if(tokenLower == "icon") { token = lexer.ReadToken(); _icon = (token != null) ? token.ToString() : string.Empty; } else if(tokenLower == "id") { token = lexer.ReadToken(); _id = (token != null) ? token.ToString() : string.Empty; } else if(tokenLower == "post") { token = lexer.ReadToken(); _post = (token != null) ? token.ToString() : string.Empty; } else if(tokenLower == "title") { token = lexer.ReadToken(); _title = (token != null) ? token.ToString() : string.Empty; } else if(tokenLower == "security") { token = lexer.ReadToken(); _security = (token != null) ? token.ToString() : string.Empty; } else if(tokenLower == "pda_email") { token = lexer.ReadToken(); _emailList.Add(token.ToString()); idE.DeclManager.FindType(DeclType.Email, token.ToString()); } else if(tokenLower == "pda_audio") { token = lexer.ReadToken(); _audioList.Add(token.ToString()); idE.DeclManager.FindType(DeclType.Audio, token.ToString()); } else if(tokenLower == "pda_video") { token = lexer.ReadToken(); _videoList.Add(token.ToString()); idE.DeclManager.FindType(DeclType.Video, token.ToString()); } } if(lexer.HadError == true) { lexer.Warning("PDA decl '{0}' had a parse error", this.Name); return false; } _originalVideoCount = _videoList.Count; _originalEmailCount = _emailList.Count; return true; }
public override bool Parse(string text) { if(this.Disposed == true) { throw new ObjectDisposedException(this.GetType().Name); } idToken token; string tokenLower; idLexer lexer = new idLexer(idDeclFile.LexerOptions); lexer.LoadMemory(text, this.FileName, this.LineNumber); lexer.SkipUntilString("{"); List<idParticleStage> stages = new List<idParticleStage>(); _depthHack = 0.0f; while(true) { if((token = lexer.ReadToken()) == null) { break; } tokenLower = token.ToString().ToLower(); if(tokenLower == "}") { break; } else if(tokenLower == "{") { idParticleStage stage = ParseParticleStage(lexer); if(stage == null) { lexer.Warning("Particle stage parse failed"); MakeDefault(); return false; } stages.Add(stage); } else if(tokenLower == "depthhack") { _depthHack = lexer.ParseFloat(); } else { lexer.Warning("bad token {0}", token.ToString()); MakeDefault(); return false; } } _stages = stages.ToArray(); // // calculate the bounds // _bounds.Clear(); int count = _stages.Length; for(int i = 0; i < count; i++) { idConsole.Warning("TODO: GetStageBounds"); // TODO: GetStageBounds(stages[i]); _bounds += _stages[i].Bounds; } if(_bounds.Volume <= 0.1f) { _bounds = idBounds.Expand(idBounds.Zero, 8.0f); } return true; }
public override bool Parse(string text) { if (this.Disposed == true) { throw new ObjectDisposedException(this.GetType().Name); } idLexer lexer = new idLexer(idDeclFile.LexerOptions); lexer.LoadMemory(text, this.FileName, this.LineNumber); lexer.SkipUntilString("{"); List <SkinMapping> mappings = new List <SkinMapping>(); List <string> associatedModels = new List <string>(); idToken token, token2; string tokenLower; while (true) { if ((token = lexer.ReadToken()) == null) { break; } tokenLower = token.ToString().ToLower(); if (tokenLower == "}") { break; } else if ((token2 = lexer.ReadToken()) == null) { lexer.Warning("Unexpected end of file"); MakeDefault(); break; } else if (tokenLower == "model") { associatedModels.Add(token2.ToString()); continue; } SkinMapping map = new SkinMapping(); map.To = idE.DeclManager.FindMaterial(token2.ToString()); if (tokenLower == "*") { // wildcard. map.From = null; } else { map.From = idE.DeclManager.FindMaterial(token.ToString()); } mappings.Add(map); } _mappings = mappings.ToArray(); _associatedModels = associatedModels.ToArray(); return(false); }
public override bool Parse(string text) { if(this.Disposed == true) { throw new ObjectDisposedException(this.GetType().Name); } idLexer lexer = new idLexer(LexerOptions.NoStringConcatination | LexerOptions.AllowPathNames | LexerOptions.AllowMultiCharacterLiterals | LexerOptions.AllowBackslashStringConcatination | LexerOptions.NoFatalErrors); lexer.LoadMemory(text, this.FileName, this.LineNumber); lexer.SkipUntilString("{"); idToken token; _text = string.Empty; string tokenLower; string tokenValue; // scan through, identifying each individual parameter while(true) { if((token = lexer.ReadToken()) == null) { break; } tokenValue = token.ToString(); tokenLower = tokenValue.ToLower(); if(tokenValue == "}") { break; } else if(tokenLower == "subject") { _subject = lexer.ReadToken().ToString(); } else if(tokenLower == "to") { _to = lexer.ReadToken().ToString(); } else if(tokenLower == "from") { _from = lexer.ReadToken().ToString(); } else if(tokenLower == "date") { _date = lexer.ReadToken().ToString(); } else if(tokenLower == "text") { token = lexer.ReadToken(); tokenValue = token.ToString(); if(tokenValue != "{") { lexer.Warning("Email dec '{0}' had a parse error", this.Name); return false; } while(((token = lexer.ReadToken()) != null) && (token.ToString() != "}")) { _text += token.ToString(); } } else if(tokenLower == "image") { _image = lexer.ReadToken().ToString(); } } if(lexer.HadError == true) { lexer.Warning("Email decl '{0}' had a parse error", this.Name); return false; } return true; }