private static void AddParserTestStructs(TCODFileParser parser) { string[] strList = new string[3]; strList[0] = "moo"; strList[1] = "foo"; strList[2] = "bar"; TCODParserStructure item = parser.RegisterNewStructure("item_type"); item.AddProperty("cost", TCODValueType.TCOD_TYPE_INT, true); item.AddProperty("weight", TCODValueType.TCOD_TYPE_FLOAT, true); item.AddProperty("deal_damage", TCODValueType.TCOD_TYPE_BOOL, true); item.AddProperty("damages", TCODValueType.TCOD_TYPE_DICE, true); item.AddProperty("color", TCODValueType.TCOD_TYPE_COLOR, true); item.AddProperty("damaged_color", TCODValueType.TCOD_TYPE_COLOR, true); item.AddProperty("damage_type", TCODValueType.TCOD_TYPE_STRING, true); item.AddValueList("list", strList, true); item.AddFlag("abstract"); TCODParserStructure video = parser.RegisterNewStructure("video"); video.AddProperty("mode", TCODValueType.TCOD_TYPE_STRING, true); video.AddProperty("fullscreen", TCODValueType.TCOD_TYPE_BOOL, true); TCODParserStructure input = parser.RegisterNewStructure("input"); TCODParserStructure mouse = parser.RegisterNewStructure("mouse"); mouse.AddProperty("sensibility", TCODValueType.TCOD_TYPE_FLOAT, true); input.AddSubStructure(mouse); }
private static bool NewStructCallbackTest(TCODParserStructure cur, string name) { switch (currentState) { case currentStructType.none: if (name.ToString() != "blade" && cur.GetName() != "item_type") { return(false); } if (!cur.IsMandatory("cost")) { return(false); } if (cur.GetType("cost") != TCODValueType.TCOD_TYPE_INT) { return(false); } currentState = currentStructType.item; break; case currentStructType.item: if (name != null && cur.GetName() != "video") { return(false); } currentState = currentStructType.video; break; case currentStructType.video: if (name != null && cur.GetName() != "input") { return(false); } currentState = currentStructType.input; break; case currentStructType.input: if (name != null && cur.GetName() != "mouse") { return(false); } currentState = currentStructType.mouse; break; case currentStructType.inputDone: return(false); //Should never get here case currentStructType.mouse: return(false); //Should never get here } return(true); }
private static bool EndStructCallbackTest(TCODParserStructure cur, string name) { switch (currentState) { case currentStructType.none: return(false); case currentStructType.item: if (name.ToString() != "blade" || cur.GetName() != "item_type") { return(false); } break; case currentStructType.video: if (name != null || cur.GetName() != "video") { return(false); } break; case currentStructType.mouse: if (name != null || cur.GetName() != "mouse") { return(false); } currentState = currentStructType.inputDone; break; case currentStructType.inputDone: if (name != null || cur.GetName() != "input") { return(false); } break; case currentStructType.input: return(false); } return(true); }