Example #1
0
 public AbstractLmpTreeViewModel(World world, TreeViewItemViewModel parent, LmpFile lmpFile, string entryName)
     : base(parent, true)
 {
     _lmpFile = lmpFile;
     _name    = entryName;
     _world   = world;
 }
Example #2
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));
                if (File.Exists(Path.Combine(DataPath, texFileName)))
                {
                    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");
            }
        }
Example #3
0
        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);
        }
Example #4
0
        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();
                }
            }
        }
Example #5
0
 public WorldFileTreeViewModel(World world, TreeViewItemViewModel parent, LmpFile lmpFile, string entryName)
     : base(world, parent, lmpFile, entryName)
 {
 }
Example #6
0
 public LmpTreeViewModel(World world, TreeViewItemViewModel parent, LmpFile lmpFile)
     : base(world, parent, lmpFile, lmpFile.Name)
 {
 }