private void OnOkButtonClick(object sender, RoutedEventArgs e) { try { IEnumerable <LocationView> items = ((IEnumerable <LocationView>)LocationsListBox.ItemsSource).Where(i => i.IsSelected); foreach (LocationView view in items) { switch (_mode) { case Mode.Save: view.Location.SaveRequestedData(); break; case Mode.Import: view.Location.ImportRequestedData(); break; } } Archives.GetInfo(ArchiveName.Field).Update(); DialogResult = true; } catch (Exception ex) { UIHelper.ShowError(ex); } }
public static void HiResToGameData(GameFont gameFont) { using (DisposableStack disposables = new DisposableStack(2)) { GLTexture leftTexture; GLTexture rightTexture; GLTextureFactory.HorizontalSplit(gameFont.CharactersImage.Layer, out leftTexture, out rightTexture); disposables.Add(leftTexture); disposables.Add(rightTexture); ArchiveDirectoryEntry mainDirectory = Archives.GetEntry <ArchiveDirectoryEntry>(GameFontReader.MainPath); ArchiveDirectoryEntry menuDirectory = Archives.GetEntry <ArchiveDirectoryEntry>(GameFontReader.MenuPath); ArchiveDirectoryEntry hiresDirectory = menuDirectory.GetChildEntry <ArchiveDirectoryEntry>(GameFontReader.HiResDirectoryName); ArchiveFileEntry tdwEntry = mainDirectory.GetChildEntry <ArchiveFileEntry>(GameFontReader.HiResCharactersWidthsFileName); ArchiveFileEntry image01 = hiresDirectory.GetChildEntry <ArchiveFileEntry>(GameFontReader.HiResFontImage1FileName); ArchiveFileEntry image02 = hiresDirectory.GetChildEntry <ArchiveFileEntry>(GameFontReader.HiResFontImage2FileName); using (Stream output = tdwEntry.OpenWritableCapacityStream()) using (TdwFileWriter tdwWriter = new TdwFileWriter(output)) { tdwWriter.WriteFontCharactersWidths(gameFont.CharactersWidths); tdwEntry.UpdateMetrics((int)output.Position, tdwEntry.ContentOffset, Compression.None); } using (Stream output = image01.OpenWritableCapacityStream()) using (TexFileWriter texWriter = new TexFileWriter(output)) { texWriter.WriteImage(leftTexture, gameFont.CharactersImage.Palettes); image01.UpdateMetrics((int)output.Position, image01.ContentOffset, Compression.None); } using (Stream output = image02.OpenWritableCapacityStream()) using (TexFileWriter texWriter = new TexFileWriter(output)) { texWriter.WriteImage(rightTexture, gameFont.CharactersImage.Palettes); image02.UpdateMetrics((int)output.Position, image02.ContentOffset, Compression.None); } Archives.GetInfo(ArchiveName.Main).Update(); Archives.GetInfo(ArchiveName.Menu).Update(); } }