Ejemplo n.º 1
0
        void FindAtlas(string[] texs)
        {
            string dir = Path.GetDirectoryName(iEdit.Path) + '/';

            CountAtlases = 0;

            for (int i = 0; i < texs.Length; ++i)
            {
                string name     = Path.ChangeExtension(texs[i], ".png");
                string nameDVPL = Path.ChangeExtension(texs[i], ".png.dvpl");
                if (File.Exists(dir + name) || File.Exists(dir + nameDVPL))
                {
                    ++CountAtlases;
                }
                else
                {
                    name     = Path.ChangeExtension(texs[i], ".webp");
                    nameDVPL = Path.ChangeExtension(texs[i], ".webp.dvpl");
                    if (File.Exists(dir + name) || File.Exists(dir + nameDVPL))
                    {
                        PNG = false;


                        Err.Show(Key.ProgramDontWEBPformat, Key.Exception);

                        return;
                    }
                }
            }

            PNG = true;
        }
Ejemplo n.º 2
0
        public void Open(string path, TypeFile type)
        {
            FileState preview = State;

            if (!File.Exists(path))
            {
                if (preview != FileState.OK)
                {
                    State = FileState.FileNotExists;
                }

                string message = Words.Get(Key.FileNotExists);
                string caption = Words.Get(Key.Error);

                Err.Show(message, caption);

                return;
            }

            Path = path;
            string data = File.ReadAllText(Path);

            if (type == TypeFile.txt)
            {
                file = new TXT(data);
            }
            else
            {
                file = new TXT(DVPL.Parse(data));
            }

            State = FileState.OK;
        }
Ejemplo n.º 3
0
        Bitmap TileFromLayer()
        {
            Layer  l   = iEdit.GetLayer();
            Bitmap res = new Bitmap(l.Tile.Width, l.Tile.Height);

            if (PNG)
            {
                string dir  = Path.GetDirectoryName(iEdit.Path) + '/';
                string name = iEdit.GetTex();

                name = Path.ChangeExtension(name, ".png");


                if (!File.Exists(dir + name))
                {
                    string nameDVPL = Path.ChangeExtension(name, ".png.dvpl");

                    if (!File.Exists(dir + nameDVPL))
                    {
                        Err.Show(Key.AtlasNotExists, Key.Error);
                        return(res);
                    }
                    else
                    {
                        name = nameDVPL;
                    }
                }
                res = new Bitmap(dir + name);
                if (l.Tile.X > res.Width ||
                    l.Tile.Y > res.Height ||
                    l.Tile.X < 0 ||
                    l.Tile.Y < 0)
                {
                    Err.Show(Key.TileOverImage, Key.Error);
                    MessageBox.Show(Words.Get(Key.TileSetZeroPosition));
                    l.Tile.X = 0;
                    l.Tile.Y = 0;
                }
                res = res.Clone(l.Tile, res.PixelFormat);
            }

            return(res);
        }
Ejemplo n.º 4
0
        public Layer(string layer)
        {
            string[] param = layer.Split(' ');

            if (param.Length < 8)
            {
                string message = Words.Get(Key.ErrorFewParamsInLayer);
                string caption = Words.Get(Key.Exception);
                Err.Show(message, caption);

                return;
            }

            Tile.X      = Convert.ToInt32(param[0]);
            Tile.Y      = Convert.ToInt32(param[1]);
            Tile.Width  = Convert.ToInt32(param[2]);
            Tile.Height = Convert.ToInt32(param[3]);
            Offset.X    = Convert.ToInt32(param[4]);
            Offset.Y    = Convert.ToInt32(param[5]);
            ImageID     = Convert.ToInt32(param[6]);
            Frame       = param[7];
        }
Ejemplo n.º 5
0
        private static void Read()
        {
            if (File.Exists(currentLang))
            {
                string[] all = File.ReadAllLines(currentLang);
                word.Clear();

                for (int i = 0; i < all.Length; ++i)
                {
                    string[] pair = all[i].Split('=');
                    pair[0] = pair[0].Trim(new char[] { ' ', '"' });
                    pair[1] = pair[1].Trim(new char[] { ' ', '"' });

                    word.Add(pair[0], pair[1]);
                }

                Console.Write(' ');
            }
            else
            {
                Err.Show("Отсутствует файл языка\n", "Предупреждение");
            }
        }