Exemple #1
0
        private void NESW_CalculateFromSprite(PictureBox picture, NumericUpDown north, NumericUpDown east, NumericUpDown south, NumericUpDown west, bool loadExisting = false, string rotationName = "" /* MUST BE SUPPLIED IF loadExisting = true */)
        {
            SpriteBounds bounds = (loadExisting) ? SpriteAnalysis.LoadData(FilePaths.PathToUnityStreaming + "PROPCONFIGS/" + propName.Text.Trim().ToUpper().Replace(' ', '_') + "/" + Path.GetFileNameWithoutExtension(rotationName) + ".dwb") :
                                  SpriteAnalysis.CalculateSpriteBounds((Bitmap)picture.Image);

            north.Value = bounds.tile_excess_north;
            east.Value  = bounds.tile_excess_east;
            south.Value = bounds.tile_excess_south;
            west.Value  = bounds.tile_excess_west;
        }
Exemple #2
0
        /* Save a sprite from entered data */
        private void SaveSprite(PictureBox picture, string name, bool includeDims = false, /* ALL FOLLOWING NEED TO BE SUPPLIED IF includeDims = true */ decimal _eNorth = 0, decimal _eEast = 0, decimal _eSouth = 0, decimal _eWest = 0)
        {
            string filePath = FilePaths.PathToUnityPropResources + name + ".png";

            if (changedSprites)
            {
                picture.Image.Save(filePath);
            }
            string metaPath = filePath + ".meta";

            if (!File.Exists(metaPath))
            {
                File.WriteAllText(metaPath, Properties.Resources.meta_template.ToString());
            }
            if (includeDims)
            {
                spriteBounds.Add(SpriteAnalysis.CalculateSpriteBounds((Bitmap)picture.Image));
                spriteBounds[spriteBounds.Count - 1].tile_excess_north = _eNorth;
                spriteBounds[spriteBounds.Count - 1].tile_excess_east  = _eEast;
                spriteBounds[spriteBounds.Count - 1].tile_excess_south = _eSouth;
                spriteBounds[spriteBounds.Count - 1].tile_excess_west  = _eWest;
                SpriteAnalysis.SaveData(FilePaths.PathToUnityStreaming + "PROPCONFIGS/" + propName.Text.Trim().ToUpper().Replace(' ', '_') + "/" + Path.GetFileNameWithoutExtension(name) + ".dwb", spriteBounds[spriteBounds.Count - 1]);
            }
        }