private void ImportMapMenuButton_Click(object sender, RoutedEventArgs e) { SaveProjectAs(lastSaveLocation); if (lastSaveLocation == null) { MessageBox.Show("Please save your project before importing data!", "Error importing", MessageBoxButton.OK, MessageBoxImage.Error); return; } ImportDialogModel data = new ImportDialogModel("", 0, 0, 0); ImportDialogWindow importDialogWindow = new ImportDialogWindow(data); importDialogWindow.Owner = this; bool result = (bool)importDialogWindow.ShowDialog(); if (result) { //TODO import //TODO warn when map replacement try { MapHeader importedData = AgbImport.HeaderFromStream(new BinaryReader(File.OpenRead(data.ROMPath)), data.Offset, data.Bank, data.Map); } catch (Exception ex) { MessageBox.Show("Error importing: " + ex.Message, "Import error", MessageBoxButton.OK, MessageBoxImage.Error); } } }
static void Main(string[] args) { BinaryReader reader = new BinaryReader(new FileStream(@"D:\onedrive\Hacking\Romhacking\Ressources\Feuerrot\Pokemon Feuerrot (D).gba", FileMode.Open, FileAccess.Read)); MapHeader header = AgbImport.HeaderFromStream(reader, 0x3525CC, 3, 0); header.ExportToFile(header, "test.header"); MapHeader importedHeader = header.ImportFromFile("test.header"); }