public OverworldPicEditorWindow(EventObjectPic initialPic) { InitializeComponent(); ViewModel.CurrentPic = initialPic; var identifierSortDesc = new SortDescription("Identifier", ListSortDirection.Ascending); spritePicList.Items.SortDescriptions.Add(identifierSortDesc); spritePicList.Items.IsLiveSorting = true; }
private void addPicButton_Click(object sender, RoutedEventArgs e) { if (!FileUtils.uploadImage(out string path, EventPicDir)) { return; } ObservableCollection <EventObjectPic> pics = Project.Instance.EventObjects.Pics; string identifier = "__new_pic_" + pics.Count; var newPic = new EventObjectPic() { Identifier = identifier, Path = identifier, FullPath = path, }; pics.Add(newPic); ViewModel.CurrentPic = newPic; }
void loadPicsAndPalettes(ProjectDeserializer deserializer) { var picPaths = new HashSet <string>(); var fileDeserializer = new FileDeserializer(); fileDeserializer.add(new IncBinDeserializer("gObjectEventPic_", "u32", (cppVar, fileName) => { string path = Path.ChangeExtension(fileName, ".png"); var pic = new EventObjectPic() { Identifier = cppVar, Path = Path.ChangeExtension(path.Remove(0, "graphics/object_events/pics/".Length), null), FullPath = Path.Combine(deserializer.project.ProjectDir, path) }; picPaths.Add(path); idToPic.Add(cppVar, pic); pics.Add(pic); })); fileDeserializer.add(new IncBinDeserializer("gObjectEventPalette", "u16", (cppVar, fileName) => { cppVar = "gObjectEventPalette" + cppVar; varToPalette.Add(cppVar, new EventObjectPalette() { Identifier = cppVar.fromPascalToSnake(), FilePath = fileName }); })); deserializer.deserializeFile(fileDeserializer, "src", "data", "object_events", "object_event_graphics.h"); // Remove all of the palettes whose file paths match a present picture, these // palettes will be generated from that image. var toRemove = new List <string>(); foreach (KeyValuePair <string, EventObjectPalette> kv in varToPalette) { if (picPaths.Contains(kv.Value.FilePath + ".png")) { toRemove.Add(kv.Key); } } foreach (string key in toRemove) { varToPalette.Remove(key); } }