Exemple #1
0
 internal static Texture2D GetTexture(string filename)
 {
     if (AssetManager.cache.ContainsKey(filename))
     {
         return(AssetManager.cache[filename]);
     }
     if (!AssetManager.loadingImageFilename.ContainsKey(filename))
     {
         AssetManager.LoadTexture(filename, false);
         return(AssetManager.cache[filename]);
     }
     AssetManager.ImageData imageData = null;
     lock (AssetManager.lockObj)
     {
         if (AssetManager.imageCache.ContainsKey(filename))
         {
             imageData = AssetManager.imageCache[filename];
             AssetManager.imageCache.Remove(filename);
         }
     }
     if (imageData != null)
     {
         Texture2D texture2D = new Texture2D(imageData.Size.Width, imageData.Size.Height, false, (PixelFormat)1);
         texture2D.SetPixels(0, imageData.Buffer);
         AssetManager.cache.Add(filename, texture2D);
         AssetManager.loadingImageFilename.Remove(filename);
         return(texture2D);
     }
     return(null);
 }
Exemple #2
0
        private static void asyncLoad(object state)
        {
            string text = state as string;

            lock (AssetManager.lockObj)
            {
                if (AssetManager.imageCache.ContainsKey(text))
                {
                    text = null;
                }
            }
            if (text != null)
            {
                Image image = new Image(text);
                AssetManager.ImageData imageData = new AssetManager.ImageData();
                image.Decode();
                imageData.Size   = image.Size;
                imageData.Buffer = image.ToBuffer();
                image.Dispose();
                lock (AssetManager.lockObj)
                {
                    AssetManager.imageCache.Add(text, imageData);
                }
            }
        }
Exemple #3
0
        private static void asyncLoadFromAssembly(object state)
        {
            string text = state as string;

            lock (AssetManager.lockObj)
            {
                if (AssetManager.imageCache.ContainsKey(text))
                {
                    text = null;
                }
            }
            if (text != null)
            {
#if false
                Assembly executingAssembly = Assembly.GetExecutingAssembly();
                string   text2             = typeof(UISystem).Namespace + "." + text.Replace("/", ".");
                byte[]   array;
                using (Stream manifestResourceStream = executingAssembly.GetManifestResourceStream(text2))
                {
                    if (manifestResourceStream == null)
                    {
                        throw new FileNotFoundException("File not found.", text);
                    }
                    array = new byte[manifestResourceStream.Length];
                    manifestResourceStream.Read(array, 0, array.Length);
                }
                Image image = new Image(array);
#else
                string filename = "/Application/Sce.Pss.HighLevel/UI/" + text;
                Image  image    = new Image(filename);
#endif
                AssetManager.ImageData imageData = new AssetManager.ImageData();
                image.Decode();
                imageData.Size   = image.Size;
                imageData.Buffer = image.ToBuffer();
                image.Dispose();
                lock (AssetManager.lockObj)
                {
                    AssetManager.imageCache.Add(text, imageData);
                }
            }
        }