public AbstractLmpTreeViewModel(World world, TreeViewItemViewModel parent, LmpFile lmpFile, string entryName)
     : base(parent, true)
 {
     _lmpFile = lmpFile;
     _name = entryName;
     _world = world;
 }
Beispiel #2
0
 public void ReadDirectory()
 {
     int index = 0;
     String s = DataUtil.GetString(FileData, index);
     while (s.Length > 0) {
         int lmpOffset = BitConverter.ToInt32(FileData, index + 0x20);
         int lmpLen = BitConverter.ToInt32(FileData, index + 0x24);
         Directory[s] = new LmpFile(_engineVersion, s, FileData, lmpOffset, lmpLen);
         index += 0x28;
         s = DataUtil.GetString(FileData, index);
     }
 }
Beispiel #3
0
        public void ReadDirectory()
        {
            int    index = 0;
            String s     = DataUtil.GetString(FileData, index);

            while (s.Length > 0)
            {
                int lmpOffset = BitConverter.ToInt32(FileData, index + 0x20);
                int lmpLen    = BitConverter.ToInt32(FileData, index + 0x24);
                Directory[s] = new LmpFile(_engineVersion, s, FileData, lmpOffset, lmpLen);
                index       += 0x28;
                s            = DataUtil.GetString(FileData, index);
            }
        }
Beispiel #4
0
        public void Load()
        {
            var ext = (Path.GetExtension(Name) ?? "").ToLower();

            switch (ext)
            {
                case ".gob":
                    var texFileName = Path.GetFileNameWithoutExtension(Name) + ".tex";
                    WorldGob = new GobFile(EngineVersion, Path.Combine(DataPath, Name));
                    WorldTex = new WorldTexFile(EngineVersion, Path.Combine(DataPath, texFileName));
                    break;
                case ".lmp":
                    // TODO: Support just passing the filepath instead of having to load data here
                    var data = File.ReadAllBytes(Path.Combine(DataPath, Name));
                    WorldLmp = new LmpFile(EngineVersion, Name, data, 0, data.Length);
                    break;
                case ".yak":
                    var yakData = File.ReadAllBytes(Path.Combine(DataPath, Name));
                    WorldYak = new YakFile(EngineVersion, Name, yakData);
                    break;
                default:
                    throw new NotSupportedException("Unsupported file type");
            }
        }
 private List<AnimData> LoadFirstAnim(LmpFile lmpFile)
 {
     List<AnimData> animList = new List<AnimData>();
     var animEntry = lmpFile.FindFirstEntryWithSuffix(".anm");
     if (animEntry != null)
     {
         var engineVersion = App.Settings.Get("Core.EngineVersion", EngineVersion.DarkAlliance);
         animList.Add(AnmDecoder.Decode(engineVersion, lmpFile.FileData, animEntry.StartOffset, animEntry.Length));
     }
     return animList;
 }
 public WorldFileTreeViewModel(World world, TreeViewItemViewModel parent, LmpFile lmpFile, string entryName)
     : base(world, parent, lmpFile, entryName)
 {
 }
 public LmpTreeViewModel(World world, TreeViewItemViewModel parent, LmpFile lmpFile)
     : base(world, parent, lmpFile, lmpFile.Name)
 {
 }
        void SaveLmpEntryData(LmpFile lmpFile, string entryName)
        {
            var entry = lmpFile.Directory[entryName];

            var dialog = new SaveFileDialog();
            dialog.FileName = entryName;

            bool? result = dialog.ShowDialog();
            if (result.GetValueOrDefault(false))
            {
                using (var stream = new FileStream(dialog.FileName, FileMode.Create))
                {
                    stream.Write(lmpFile.FileData, entry.StartOffset, entry.Length);

                    stream.Flush();
                }
            }
        }