public LoadAsync ( byte data, Device device ) : System.Threading.Tasks.Task | ||
data | byte | |
device | Device | |
Résultat | System.Threading.Tasks.Task |
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); }
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) { 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); }
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); }
public IRenderableTexture GetTexture(string filename, DeviceContextHolder contextHolder) { IRenderableTexture cached; if (_textures.TryGetValue(filename, out cached) && !cached.IsDisposed) return cached; if (!File.Exists(filename)) return null; var result = new RenderableTexture { Resource = null }; result.LoadAsync(filename, contextHolder.Device).Forget(); return _textures[filename] = result; }
public IRenderableTexture GetTexture([NotNull] string kn5Filename, string textureName, DeviceContextHolder contextHolder) { if (kn5Filename == null) throw new ArgumentNullException(nameof(kn5Filename)); var key = kn5Filename + "//" + textureName; IRenderableTexture texture; if (_textures.TryGetValue(key, out texture)) return texture; var result = new RenderableTexture(textureName) { Resource = null }; IOverridedTextureProvider provider; if (_overridedProviders.TryGetValue(kn5Filename, out provider)) { LoadOverrideAsync(result, textureName, provider, contextHolder); } var kn5 = _kn5Entries.Where(x => string.Equals(x.Filename, kn5Filename, StringComparison.OrdinalIgnoreCase)) .Select(x => x.Kn5).FirstOrDefault(x => x.TexturesData.ContainsKey(textureName)); if (kn5 == null) return result; result.LoadAsync(kn5.TexturesData[textureName], contextHolder.Device).Forget(); return _textures[key] = result; }