Пример #1
0
        public static void ReloadMtds()
        {
            IBinder mtdBinder = null;

            if (AssetLocator.Type == GameType.DarkSoulsIII || AssetLocator.Type == GameType.Sekiro)
            {
                mtdBinder = BND4.Read(AssetLocator.GetAssetPath($@"mtd\allmaterialbnd.mtdbnd.dcx"));
            }

            if (mtdBinder == null)
            {
                return;
            }

            _mtds = new Dictionary <string, MTD>();
            foreach (var f in mtdBinder.Files)
            {
                var mtdname = Path.GetFileNameWithoutExtension(f.Name);
                // Because *certain* mods contain duplicate entries for the same material
                if (!_mtds.ContainsKey(mtdname))
                {
                    _mtds.Add(mtdname, MTD.Read(f.Bytes));
                }
            }
        }
Пример #2
0
        public static void LoadMTDBND()
        {
            MtdDict.Clear();
            MTDBND = null;

            if (GameType == GameTypes.SDT)
            {
                MTDBND = BND4.Read(GetInterrootPath($@"mtd\allmaterialbnd.mtdbnd.dcx"));

                foreach (var f in MTDBND.Files)
                {
                    var key = Utils.GetShortIngameFileName(f.Name);
                    if (!MtdDict.ContainsKey(key))
                    {
                        MtdDict.Add(key, MTD.Read(f.Bytes));
                    }
                    else
                    {
                        MtdDict[key] = MTD.Read(f.Bytes);
                    }
                }
            }
        }
Пример #3
0
        private void LoadFile(string path, bool silent = false)
        {
            statusStripMTDPath.Text = "";
            if (!File.Exists(path))
            {
                ShowError($"File not found:\r\n{path}", silent);
                return;
            }

            string filename  = Path.GetFileName(path);
            string extension = SFUtil.GetRealExtension(filename);

            cmbMTD.Enabled = false;
            cmbMTD.Items.Clear();

            mtdBnd = null;
            mtd    = null;

            var mtdItems = new List <MTDWrapper>();

            try
            {
                if (MTD.Is(path))
                {
                    mtdItems.Add(new MTDWrapper(MTD.Read(path), filename));
                }
                else if (BND3.Is(path))
                {
                    mtdBnd = BND3.Read(path);
                    foreach (BinderFile file in mtdBnd.Files)
                    {
                        if (MTD.Is(file.Bytes))
                        {
                            mtdItems.Add(new MTDWrapper(MTD.Read(file.Bytes), file.Name));
                        }
                    }
                }
                else if (BND4.Is(path))
                {
                    mtdBnd = BND4.Read(path);
                    foreach (BinderFile file in mtdBnd.Files)
                    {
                        if (MTD.Is(file.Bytes))
                        {
                            mtdItems.Add(new MTDWrapper(MTD.Read(file.Bytes), file.Name));
                        }
                    }
                }
                else
                {
                    ShowError($"Unrecognized file type:\r\n{path}", silent);
                    return;
                }
            }
            catch (Exception ex)
            {
                ShowError($"Failed to load file:\r\n{path}\r\n{ex}", silent);
                return;
            }

            statusStripMTDPath.Text = path;
            mtdItems.Sort((i1, i2) => i1.Name.CompareTo(i2.Name));
            cmbMTD.Items.AddRange(mtdItems.ToArray());
            cmbMTD.SelectedIndex = 0;

            if (mtdItems.Count > 1)
            {
                cmbMTD.Enabled = true;
            }
        }