Пример #1
0
        private void Open(string fileName)
        {
            try
            {
                using (var file = File.Open(fileName, FileMode.Open))
                {
                    var ent = Bar.Read(file,
                                       (str, type) => str == "lvup" && type == Bar.EntryType.List)
                              .FirstOrDefault();

                    if (ent != null)
                    {
                        FileName   = fileName;
                        stream     = ent.Stream;
                        Characters = new CharactersViewModel(Lvup.Read(stream));
                        Characters.SelectedItem = Characters.Items[0];
                        OnPropertyChanged(nameof(Characters));

                        IsFileLoaded = true;
                        OnPropertyChanged(nameof(IsFileLoaded));
                    }
                    else
                    {
                        MessageBox.Show("This file does not contain an 'lvup' entry!", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                    }
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Пример #2
0
 public void WriteTest() => File.OpenRead(@"kh2/res/lvup_fm.bin").Using(stream =>
 {
     Helpers.AssertStream(stream, inStream =>
     {
         var outStream = new MemoryStream();
         Lvup.Read(inStream).Write(outStream);
         return(outStream);
     });
 });
Пример #3
0
 public LvupViewModel(IEnumerable <Bar.Entry> entries) :
     this(Lvup.Read(entries.GetBattleStream(entryName)))
 {
 }
Пример #4
0
 public LvupViewModel(Stream stream)
 {
     Characters = new CharactersViewModel(Lvup.Read(stream));
     OnPropertyChanged(nameof(Characters));
 }
Пример #5
0
 public void LvupTableTest() => Common.FileOpenRead(@"kh2/res/lvup_fm.bin", x => x.Using(stream =>
 {
     var table = Lvup.Read(stream);
     Assert.Equal(0xE, table.Count);
 }));