Beispiel #1
0
        protected override IRenderableTexture CreateTexture(IDeviceContextHolder contextHolder, string key)
        {
            var result = new RenderableTexture();

            if (_directory == null)
            {
                return(result);
            }
            var filename = Path.Combine(_directory, key);

            if (File.Exists(filename))
            {
                result.Exists = true;
                if (_asyncLoading)
                {
                    TaskExtension.Forget(result.LoadAsync(contextHolder, filename));
                }
                else
                {
                    result.Load(contextHolder, filename);
                }
            }

            return(Textures[filename] = result);
        }
Beispiel #2
0
        protected override IRenderableTexture CreateTexture(IDeviceContextHolder contextHolder, string key)
        {
            var result = new RenderableTexture(key)
            {
                Resource = null
            };

            foreach (var kn5 in Kn5)
            {
                if (kn5.TexturesData.TryGetValue(key, out var data))
                {
                    result.Exists = true;
                    if (AsyncLoading)
                    {
                        result.LoadAsync(contextHolder, data).ContinueWith(t => {
                            contextHolder.RaiseTexturesUpdated();
                        });
                    }
                    else
                    {
                        result.Load(contextHolder, data);
                    }
                    return(result);
                }
            }

            return(result);
        }
Beispiel #3
0
        protected override IRenderableTexture CreateTexture(IDeviceContextHolder contextHolder, string key)
        {
            var result = new RenderableTexture(key)
            {
                Resource = null
            };

            byte[] data;
            if (Kn5.TexturesData.TryGetValue(key, out data))
            {
                if (AsyncLoading)
                {
                    result.LoadAsync(contextHolder, data).Forget();
                }
                else
                {
                    result.Load(contextHolder, data);
                }
            }

            if (CurrentDirectory != null)
            {
                if (AsyncLoading)
                {
                    LoadOverrideAsync(contextHolder, result, key).Forget();
                }
                else
                {
                    LoadOverride(contextHolder, result, key);
                }
            }

            return(result);
        }
        protected override IRenderableTexture CreateTexture(IDeviceContextHolder contextHolder, string key)
        {
            if (_directory == null)
            {
                return(null);
            }
            var filename = Path.Combine(_directory, key);

            var result = new RenderableTexture {
                Resource = null
            };

            if (File.Exists(filename))
            {
                if (_asyncLoading)
                {
                    result.LoadAsync(contextHolder, filename).Forget();
                }
                else
                {
                    result.Load(contextHolder, filename);
                }
            }

            return(Textures[filename] = result);
        }