private void hexTextBox_Validated(object sender, EventArgs e) { OrisonColor col = color; OrisonParse.Parse(ref col, hexTextBox); Color = col; }
static public string CheckDefinitionList(List <EntityDefinition> defs) { string s = ""; //Check for duplicate value names List <string> found = new List <string>(); foreach (EntityDefinition v in defs) { if (v.Name != "" && !found.Contains(v.Name) && defs.FindAll(e => e.Name == v.Name).Count > 1) { s += OrisonParse.Error("There are multiple entities with the name \"" + v.Name + "\""); found.Add(v.Name); } } //Check for blank value names if (defs.Find(e => e.Name == "") != null) { s += OrisonParse.Error("There are one or more entities with blank names"); } return(s); }
static public string CheckDefinitionList(List <ValueDefinition> defs, string container) { string s = ""; //Check for duplicate value names List <string> found = new List <string>(); foreach (ValueDefinition v in defs) { if (v.Name != "" && !found.Contains(v.Name) && defs.FindAll(e => e.Name == v.Name).Count > 1) { s += OrisonParse.Error(container + " contains multiple values with the name \"" + v.Name + "\""); found.Add(v.Name); } } //Check for blank value names if (defs.Find(e => e.Name == "") != null) { s += OrisonParse.Error(container + " contains value(s) with blank name"); } return(s); }
public string ErrorCheck() { string s = ""; /* * PROJECT SETTINGS */ s += OrisonParse.CheckNonblankString(Name, "Project Name"); s += OrisonParse.CheckPosSize(LevelDefaultSize, "Default Level"); s += OrisonParse.CheckPosSize(LevelMinimumSize, "Minimum Level"); s += OrisonParse.CheckPosSize(LevelMaximumSize, "Maximum Level"); s += OrisonParse.CheckDefinitionList(LevelValueDefinitions, "Level"); /* * LAYER DEFINITIONS */ //Must have at least 1 layer if (LayerDefinitions.Count == 0) { s += OrisonParse.Error("No layers are defined"); } //Check for duplicates and blanks s += OrisonParse.CheckDefinitionList(LayerDefinitions); foreach (var l in LayerDefinitions) { //All grid sizes must be > 0 if (l.Grid.Width <= 0) { s += OrisonParse.Error("Layer \"" + l.Name + "\" has a grid cell width <= 0"); } if (l.Grid.Height <= 0) { s += OrisonParse.Error("Layer \"" + l.Name + "\" has a grid cell height <= 0"); } } //Must have a tileset if you have a tile layer if (LayerDefinitions.Find(l => l is TileLayerDefinition) != null && Tilesets.Count == 0) { s += OrisonParse.Error("Tile layer(s) are defined, but no tilesets are defined"); } //Must have an entity if you have an entity layer if (LayerDefinitions.Find(l => l is EntityLayerDefinition) != null && EntityDefinitions.Count == 0) { s += OrisonParse.Error("Object layer(s) are defined, but no objects are defined"); } /* * TILESETS */ //Check for duplicates and blanks s += OrisonParse.CheckDefinitionList(Tilesets); foreach (var t in Tilesets) { //File must exist s += OrisonParse.CheckPath(t.FilePath, SavedDirectory, "Tileset \"" + t.Name + "\" image file"); } /* * ENTITIES */ //Check for duplicates and blanks s += OrisonParse.CheckDefinitionList(EntityDefinitions); foreach (var o in EntityDefinitions) { //Check Entity values for reserved words s += OrisonParse.CheckEntityValues(o, o.ValueDefinitions); //Image file must exist if it is using an image file to draw if (o.ImageDefinition.DrawMode == EntityImageDefinition.DrawModes.Image) { s += OrisonParse.CheckPath(o.ImageDefinition.ImagePath, SavedDirectory, "Object \"" + o.Name + "\" image file"); } } /* * VALUES */ s += OrisonParse.CheckLevelValues(LevelValueDefinitions); return(s); }