public TexData LoadImage(string name) { // Check if the sprite is loaded if (!LoadedImages.ContainsKey(name)) { // If spritename is set, attempt to load sprite bool hasSprite = false; hasSprite = WindowAPI.LoadImage(name, renderer, out TexData data); LoadedImages.Add(name, data); // If no sprite is found, use EmptyImage for this article if (!hasSprite) { BitmapImage overrideSpr = FindResource("EmptyImage") as BitmapImage; WindowAPI.RegisterTexture(renderer, name, AppDomain.CurrentDomain.BaseDirectory + overrideSpr.UriSource.LocalPath, 1, out int texture); LoadedImages[name] = new TexData(false, texture, null); } } return(LoadedImages[name]); }
private void FindSprites(object sender, RoutedEventArgs e) { var directory = Path.Combine(Path.GetDirectoryName(ApplicationSettings.Instance.ActiveProject.ProjectPath), "sprites"); Sprites.Clear(); foreach (var spriteFile in Directory.GetFiles(directory)) { var shortname = Path.GetFileNameWithoutExtension(spriteFile); var match = Regex.Match(shortname, "_strip\\d+"); if (match.Success) { shortname = shortname.Remove(match.Index); } if (!RoomEditor.Instance.LoadedImages.ContainsKey(shortname)) { WindowAPI.LoadImage(shortname, RoomEditor.Instance.renderer, out TexData data); RoomEditor.Instance.LoadedImages.Add(shortname, data); } Sprites.Add(shortname); } }