示例#1
0
 /// <summary>
 /// GDRAWCIMG(int ID, str imgName, int destX, int destY, int destWidth, int destHeight)
 /// エラーチェックは呼び出し元でのみ行う
 /// </summary>
 public void GDrawCImg(ASprite img, Rectangle destRect)
 {
     if (g == null)
     {
         throw new NullReferenceException();
     }
     img.GraphicsDraw(g, destRect);
 }
示例#2
0
 static public bool LoadContents()
 {
     if (!Directory.Exists(Program.ContentDir))
     {
         return(true);
     }
     try
     {
         //resourcesフォルダ内の全てのcsvファイルを探索する
         string[] csvFiles = Directory.GetFiles(Program.ContentDir, "*.csv", SearchOption.AllDirectories);
         foreach (var filepath in csvFiles)
         {
             //アニメスプライト宣言。nullでないとき、フレーム追加モード
             SpriteAnime currentAnime = null;
             string      directory    = Path.GetDirectoryName(filepath).ToUpper() + "\\";
             string      filename     = Path.GetFileName(filepath);
             string[]    lines        = File.ReadAllLines(filepath, Config.Encode);
             int         lineNo       = 0;
             foreach (var line in lines)
             {
                 lineNo++;
                 if (line.Length == 0)
                 {
                     continue;
                 }
                 string str = line.Trim();
                 if (str.Length == 0 || str.StartsWith(";"))
                 {
                     continue;
                 }
                 string[] tokens = str.Split(',');
                 //AContentItem item = CreateFromCsv(tokens);
                 ScriptPosition sp   = new ScriptPosition(filename, lineNo, line);
                 ASprite        item = CreateFromCsv(tokens, directory, currentAnime, sp) as ASprite;
                 if (item != null)
                 {
                     //アニメスプライト宣言ならcurrentAnime上書きしてフレーム追加モードにする。そうでないならnull
                     currentAnime = item as SpriteAnime;
                     if (!imageDictionary.ContainsKey(item.Name))
                     {
                         imageDictionary.Add(item.Name, item);
                     }
                     else
                     {
                         ParserMediator.Warn("同名のリソースがすでに作成されています:" + item.Name, sp, 0);
                         item.Dispose();
                     }
                 }
             }
         }
     }
     catch
     {
         return(false);
         //throw new CodeEE("リソースファイルのロード中にエラーが発生しました");
     }
     return(true);
 }
示例#3
0
        /// <summary>
        /// GDRAWCIMG(int ID, str imgName, int destX, int destY, int destWidth, int destHeight, float[][] cm)
        /// エラーチェックは呼び出し元でのみ行う
        /// </summary>
        public void GDrawCImg(ASprite img, Rectangle destRect, float[][] cm)
        {
            //if (g == null)
            //	throw new NullReferenceException();
            //ImageAttributes imageAttributes = new ImageAttributes();
            //ColorMatrix colorMatrix = new ColorMatrix(cm);
            //imageAttributes.SetColorMatrix(colorMatrix, ColorMatrixFlag.Default, ColorAdjustType.Bitmap);

            //img.GraphicsDraw(g, destRect, imageAttributes);
        }
示例#4
0
        static public ASprite GetSprite(string name)
        {
            if (name == null)
            {
                return(null);
            }

            name = name.ToUpper();
            ASprite result = null;

            imageDictionary.TryGetValue(name, out result);
            return(result);
        }
示例#5
0
 /// <summary>
 /// GDRAWCIMG(int ID, str imgName, int destX, int destY, int destWidth, int destHeight)
 /// エラーチェックは呼び出し元でのみ行う
 /// </summary>
 public void GDrawCImg(ASprite img, Rectangle destRect)
 {
     if (g == null)
     {
         throw new NullReferenceException();
     }
     if (!img.Position.IsEmpty)
     {
         destRect.X = destRect.X + img.Position.X * destRect.Width / img.Rectangle.Width;
         destRect.Y = destRect.Y + img.Position.Y * destRect.Height / img.Rectangle.Height;
     }
     g.DrawImage(img.Bitmap, destRect, img.Rectangle, GraphicsUnit.Pixel);
 }
示例#6
0
        static public void LoadContents()
        {
            if (!Directory.Exists(Program.ContentDir))
            {
                return;
            }
            try
            {
                //string[] csvFiles = Directory.GetFiles(Program.ContentDir, "*.csv", SearchOption.TopDirectoryOnly);
                string[] csvFiles = Directory.GetFiles(Program.ContentDir, "*.csv", SearchOption.AllDirectories);
                foreach (var filename in csvFiles)
                {
                    string   directory = Path.GetDirectoryName(filename).ToUpper() + "\\";
                    string[] lines     = File.ReadAllLines(filename, Config.Encode);
                    foreach (var line in lines)
                    {
                        if (line.Length == 0)
                        {
                            continue;
                        }
                        string str = line.Trim();
                        if (str.Length == 0 || str.StartsWith(";"))
                        {
                            continue;
                        }
                        string[] tokens = str.Split(',');
                        //AContentItem item = CreateFromCsv(tokens);

                        ASprite item = CreateFromCsv(tokens, directory) as ASprite;
                        if (item != null)
                        {
                            if (!imageDictionary.ContainsKey(item.Name))
                            {
                                imageDictionary.Add(item.Name, item);
                            }
                            else
                            {
                                item.Dispose();
                            }
                        }
                    }
                }
            }
            catch
            {
                throw new CodeEE("リソースファイルのロード中にエラーが発生しました");
            }
        }
示例#7
0
        static public void SpriteDispose(string name)
        {
            if (name == null)
            {
                return;
            }
            name = name.ToUpper();

            ASprite sprite = null;

            if (imageDictionary.TryGetValue(name, out sprite))
            {
                sprite.Dispose();
                imageDictionary.Remove(name);
            }
        }
示例#8
0
        /// <summary>
        /// GDRAWCIMG(int ID, str imgName, int destX, int destY, int destWidth, int destHeight, float[][] cm)
        /// エラーチェックは呼び出し元でのみ行う
        /// </summary>
        public void GDrawCImg(ASprite img, Rectangle destRect, float[][] cm)
        {
            if (g == null)
            {
                throw new NullReferenceException();
            }
            ImageAttributes imageAttributes = new ImageAttributes();
            ColorMatrix     colorMatrix     = new ColorMatrix(cm);

            imageAttributes.SetColorMatrix(colorMatrix, ColorMatrixFlag.Default, ColorAdjustType.Bitmap);

            Rectangle srcRect = img.Rectangle;

            if (!img.Position.IsEmpty)
            {
                destRect.X = destRect.X + img.Position.X * destRect.Width / srcRect.Width;
                destRect.Y = destRect.Y + img.Position.Y * destRect.Height / srcRect.Height;
            }
            g.DrawImage(img.Bitmap, destRect, srcRect.X, srcRect.Y, srcRect.Width, srcRect.Height, GraphicsUnit.Pixel, imageAttributes);
        }
示例#9
0
        static public bool LoadContents()
        {
            if (!Directory.Exists(Program.ContentDir))
            {
                return(true);
            }
            try
            {
                //				List<string> bmpfilelist = new List<string>();
                //				bmpfilelist.AddRange(Directory.GetFiles(Program.ContentDir, "*.png", SearchOption.TopDirectoryOnly));
                //				bmpfilelist.AddRange(Directory.GetFiles(Program.ContentDir, "*.bmp", SearchOption.TopDirectoryOnly));
                //				bmpfilelist.AddRange(Directory.GetFiles(Program.ContentDir, "*.jpg", SearchOption.TopDirectoryOnly));
                //				bmpfilelist.AddRange(Directory.GetFiles(Program.ContentDir, "*.gif", SearchOption.TopDirectoryOnly));
                //#if(UNITY_ANDROID || UNITY_IOS) && !UNITY_EDITOR
                //                bmpfilelist.AddRange(Directory.GetFiles(Program.ContentDir, "*.PNG", SearchOption.TopDirectoryOnly));
                //				bmpfilelist.AddRange(Directory.GetFiles(Program.ContentDir, "*.BMP", SearchOption.TopDirectoryOnly));
                //				bmpfilelist.AddRange(Directory.GetFiles(Program.ContentDir, "*.JPG", SearchOption.TopDirectoryOnly));
                //				bmpfilelist.AddRange(Directory.GetFiles(Program.ContentDir, "*.GIF", SearchOption.TopDirectoryOnly));
                //#endif
                //            foreach(var filename in bmpfilelist)
                //{//リスト化のみ。Loadはまだ
                //	string name = Path.GetFileName(filename).ToUpper();
                //	resourceDic.Add(name, new BaseImage(name, filename));
                //}
                //var bmpfilelist = uEmuera.Utils.GetContentFiles();
                //foreach(var kv in bmpfilelist)
                //{
                //    resourceDic.Add(kv.Key, new BaseImage(kv.Key, kv.Value));
                //}

                List <string> csvFiles = new List <string>(Directory.GetFiles(Program.ContentDir, "*.csv", SearchOption.TopDirectoryOnly));
#if (UNITY_ANDROID || UNITY_IOS) && !UNITY_EDITOR
                csvFiles.AddRange(Directory.GetFiles(Program.ContentDir, "*.CSV", SearchOption.TopDirectoryOnly));
#endif
                var count = csvFiles.Count;
                for (var i = 0; i < count; ++i)
                {
                    var         filepath     = csvFiles[i];
                    SpriteAnime currentAnime = null;
                    string      directory    = Path.GetDirectoryName(filepath) + "/";
                    string      filename     = Path.GetFileName(filepath);
                    //string[] lines = File.ReadAllLines(filepath, Config.Encode);
                    string[] lines     = uEmuera.Utils.GetResourceCSVLines(filepath, Config.Encode);
                    int      lineNo    = 0;
                    var      linecount = lines.Length;
                    for (var l = 0; l < linecount; ++l)
                    {
                        var line = lines[l];
                        lineNo++;
                        if (line.Length == 0)
                        {
                            continue;
                        }
                        string str = line.Trim();
                        if (str.Length == 0 || str.StartsWith(";"))
                        {
                            continue;
                        }
                        string[] tokens = str.Split(',');
                        //AContentItem item = CreateFromCsv(tokens);
                        ScriptPosition sp   = new ScriptPosition(filename, lineNo, line);
                        ASprite        item = CreateFromCsv(tokens, directory, currentAnime, sp) as ASprite;
                        if (item != null)
                        {
                            currentAnime = item as SpriteAnime;
                            if (!imageDictionary.ContainsKey(item.Name))
                            {
                                imageDictionary.Add(item.Name, item);
                            }
                            else
                            {
                                ParserMediator.Warn("同名のリソースがすでに作成されています:" + item.Name, sp, 0);
                                item.Dispose();
                            }
                        }
                    }
                }
            }
            catch (Exception)
            {
                return(false);
                //throw new CodeEE("リソースファイルのロード中にエラーが発生しました");
            }
            return(true);
        }