Ejemplo n.º 1
0
        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 += OgmoParse.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 += OgmoParse.Error("There are one or more entities with blank names");
            }

            return(s);
        }
Ejemplo n.º 2
0
        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 += OgmoParse.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 += OgmoParse.Error(container + " contains value(s) with blank name");
            }

            return(s);
        }
Ejemplo n.º 3
0
        public string ErrorCheck()
        {
            string s = "";

            /*
             *  PROJECT SETTINGS
             */

            s += OgmoParse.CheckNonblankString(Name, "Project Name");
            s += OgmoParse.CheckPosSize(LevelDefaultSize, "Default Level");
            s += OgmoParse.CheckPosSize(LevelMinimumSize, "Minimum Level");
            s += OgmoParse.CheckPosSize(LevelMaximumSize, "Maximum Level");
            s += OgmoParse.CheckDefinitionList(LevelValueDefinitions, "Level");

            /*
             *  LAYER DEFINITIONS
             */

            //Must have at least 1 layer
            if (LayerDefinitions.Count == 0)
            {
                s += OgmoParse.Error("No layers are defined");
            }

            //Check for duplicates and blanks
            s += OgmoParse.CheckDefinitionList(LayerDefinitions);

            foreach (var l in LayerDefinitions)
            {
                //All grid sizes must be > 0
                if (l.Grid.Width <= 0)
                {
                    s += OgmoParse.Error("Layer \"" + l.Name + "\" has a grid cell width <= 0");
                }
                if (l.Grid.Height <= 0)
                {
                    s += OgmoParse.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 += OgmoParse.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 += OgmoParse.Error("Object layer(s) are defined, but no objects are defined");
            }

            /*
             *  TILESETS
             */

            //Check for duplicates and blanks
            s += OgmoParse.CheckDefinitionList(Tilesets);

            foreach (var t in Tilesets)
            {
                //File must exist
                s += OgmoParse.CheckPath(t.FilePath, SavedDirectory, "Tileset \"" + t.Name + "\" image file");
            }

            /*
             *  ENTITIES
             */

            //Check for duplicates and blanks
            s += OgmoParse.CheckDefinitionList(EntityDefinitions);

            foreach (var o in EntityDefinitions)
            {
                //Check Entity values for reserved words
                s += OgmoParse.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 += OgmoParse.CheckPath(o.ImageDefinition.ImagePath, SavedDirectory, "Object \"" + o.Name + "\" image file");
                }
            }

            /*
             *  VALUES
             */

            s += OgmoParse.CheckLevelValues(LevelValueDefinitions);

            return(s);
        }