public override void Load(IResourceCache cache, ResourcePath path) { if (!cache.ContentFileExists(path)) { throw new FileNotFoundException("Content file does not exist for texture"); } // Primarily for tracking down iCCP sRGB errors in the image files. Logger.DebugS("res.tex", $"Loading texture {path}."); var loadParameters = _tryLoadTextureParameters(cache, path) ?? TextureLoadParameters.Default; switch (GameController.Mode) { case GameController.DisplayMode.Headless: Texture = new DummyTexture(); break; case GameController.DisplayMode.Godot: _loadGodot(cache, path, loadParameters); break; case GameController.DisplayMode.Clyde: _loadOpenGL(cache, path, loadParameters); break; default: throw new ArgumentOutOfRangeException(); } }
public override void Load(IResourceCache cache, ResourcePath path) { if (!cache.ContentFileExists(path)) { throw new FileNotFoundException("Content file does not exist for font"); } switch (GameController.Mode) { case GameController.DisplayMode.Headless: break; case GameController.DisplayMode.Godot: if (!cache.TryGetDiskFilePath(path, out string diskPath)) { throw new InvalidOperationException("Fonts can only be loaded from disk."); } var res = Godot.ResourceLoader.Load(diskPath); if (!(res is Godot.DynamicFontData fontData)) { throw new InvalidDataException("Path does not point to a font."); } FontData = fontData; break; case GameController.DisplayMode.Clyde: FontFaceHandle = IoCManager.Resolve <IFontManagerInternal>().Load(cache.ContentFileRead(path).ToArray()); break; default: throw new ArgumentOutOfRangeException(); } }
public override void Load(IResourceCache cache, ResourcePath path) { if (!GameController.OnGodot) { return; } if (!cache.ContentFileExists(path)) { throw new FileNotFoundException("Content file does not exist for texture"); } if (!cache.TryGetDiskFilePath(path, out string diskPath)) { throw new InvalidOperationException("Textures can only be loaded from disk."); } var res = Godot.ResourceLoader.Load(diskPath); if (!(res is Godot.DynamicFontData fontData)) { throw new InvalidDataException("Path does not point to a font."); } FontData = fontData; }
public override void Load(IResourceCache cache, ResourcePath path) { if (!cache.ContentFileExists(path)) { throw new FileNotFoundException("Content file does not exist for font"); } FontFaceHandle = IoCManager.Resolve <IFontManagerInternal>().Load(cache.ContentFileRead(path).ToArray()); }
public override void Load(IResourceCache cache, ResourcePath path) { if (!cache.ContentFileExists(path)) { throw new FileNotFoundException("Content file does not exist for texture"); } // Primarily for tracking down iCCP sRGB errors in the image files. Logger.DebugS("res.tex", $"Loading texture {path}."); var loadParameters = _tryLoadTextureParameters(cache, path) ?? TextureLoadParameters.Default; _loadOpenGL(cache, path, loadParameters); }
public override void Load(IResourceCache cache, ResourcePath path) { if (!cache.ContentFileExists(path)) { throw new FileNotFoundException("Content file does not exist for audio sample."); } using (var fileStream = cache.ContentFileRead(path)) { var stream = new Godot.AudioStreamOGGVorbis() { Data = fileStream.ToArray(), }; if (stream.GetLength() == 0) { throw new InvalidDataException(); } AudioStream = new GodotAudioStreamSource(stream); } }
public override void Load(IResourceCache cache, ResourcePath path) { if (!cache.ContentFileExists(path)) { throw new FileNotFoundException("Content file does not exist for audio sample."); } switch (GameController.Mode) { case GameController.DisplayMode.Headless: AudioStream = new AudioStream(); break; case GameController.DisplayMode.Godot: using (var fileStream = cache.ContentFileRead(path)) { var stream = new Godot.AudioStreamOGGVorbis() { Data = fileStream.ToArray(), }; if (stream.GetLength() == 0) { throw new InvalidDataException(); } AudioStream = new AudioStream(stream); } break; case GameController.DisplayMode.Clyde: using (var fileStream = cache.ContentFileRead(path)) { AudioStream = IoCManager.Resolve <IClyde>().LoadAudioOggVorbis(fileStream); } break; default: throw new ArgumentOutOfRangeException(); } }
public override void Load(IResourceCache cache, ResourcePath path) { if (!cache.ContentFileExists(path)) { throw new FileNotFoundException("Content file does not exist for texture"); } if (!cache.TryGetDiskFilePath(path, out string diskPath)) { throw new InvalidOperationException("Textures can only be loaded from disk."); } godotTexture = new Godot.ImageTexture(); godotTexture.Load(diskPath); // If it fails to load it won't change the texture dimensions, so they'll still be at zero. if (godotTexture.GetWidth() == 0) { throw new InvalidDataException(); } // Disable filter by default because pixel art. godotTexture.SetFlags(godotTexture.GetFlags() & ~(int)Godot.Texture.FlagsEnum.Filter); Texture = new GodotTextureSource(godotTexture); // Primarily for tracking down iCCP sRGB errors in the image files. Logger.Debug($"Loaded texture {Path.GetFullPath(diskPath)}."); }
public override void Load(IResourceCache cache, ResourcePath path) { if (!cache.ContentFileExists(path)) { throw new FileNotFoundException("Content file does not exist for audio sample."); } using (var fileStream = cache.ContentFileRead(path)) { var clyde = IoCManager.Resolve <IClydeAudio>(); if (path.Extension == "ogg") { AudioStream = clyde.LoadAudioOggVorbis(fileStream, path.ToString()); } else if (path.Extension == "wav") { AudioStream = clyde.LoadAudioWav(fileStream, path.ToString()); } else { throw new NotSupportedException("Unable to load audio files outside of ogg Vorbis or PCM wav"); } } }