/// <summary> /// Parses a decalgroup defition /// </summary> /// <param name="parser">The DecalDefsParser that right before the decalgroup definition block</param> /// <returns></returns> private bool ParseDecalGroup(DecalDefsParser parser) { parser.SkipWhitespace(true); string token = parser.ReadToken(); if (token != "{") { parser.ReportError("Expected \"{\", got " + token); return(false); } while (true) { parser.SkipWhitespace(true); token = parser.ReadToken().ToLowerInvariant(); if (string.IsNullOrEmpty(token)) { parser.ReportError("Expected property of }, got nothing"); return(false); } // Decal ends here if (token == "}") { break; } // Add name of child to the list of children if (childdecals.ContainsKey(token)) { // TODO: report problem // Overwrite existing decal with new one (who knows if that's the correct way do handle duplicate entries?) childdecals[token] = null; } else { childdecals.Add(token, null); } // Read the probability wheight. We don't use it, though int weight = 0; parser.SkipWhitespace(false); token = parser.ReadToken(); if (string.IsNullOrEmpty(token) || !parser.ReadSignedInt(token, ref weight)) { parser.ReportError("Expected probability weight as number, got \"" + token + "\""); return(false); } } return(true); }
/// <summary> /// Parses a decal definition /// </summary> /// <param name="parser">the DecalDefsParser that right before the decal definition block</param> /// <returns></returns> private bool ParseDecal(DecalDefsParser parser) { parser.SkipWhitespace(true); string token = parser.ReadToken(); if (token != "{") { parser.ReportError("Expected \"{\", got " + token); return(false); } while (true) { parser.SkipWhitespace(true); token = parser.ReadToken().ToLowerInvariant(); if (string.IsNullOrEmpty(token)) { parser.ReportError("Expected property of }, got nothing"); return(false); } // Decal ends here if (token == "}") { break; } switch (token) { case "pic": parser.SkipWhitespace(false); token = parser.ReadToken(); if (string.IsNullOrEmpty(token)) { parser.ReportError("Expected image name, got nothing"); return(false); } picturename = token; break; } } return(true); }