public static List <Model> LoadModelObj(int id)
        {
            string bndPath = "";

            if (Type == InterrootType.InterrootDS3)
            {
                bndPath = $@"obj\o{id:D6}.objbnd";
            }
            else
            {
                bndPath = $@"obj\o{id:D4}.objbnd";
            }

            var bndName = GetInterrootPath(bndPath);

            BND bnd = LoadDecompressedBND(bndName);

            if (bnd != null)
            {
                var models = LoadModelsFromBnd(bnd);
                TexturePool.AddTextureBnd(bnd, null);
                return(models);
            }

            return(new List <Model>());
        }
Пример #2
0
 public ActionResult Edit([Bind(Include = "BNDID,ChildName,Gender,DateOfBirth,TDate,PlaceOfBirth,PlaceOfBirthHouse,NameOfMother,UIDmother,NameOfFather,UIDfather,GrandFather,GrandMother,AddressParentsBirth,PermAddress,InformantsName,InformantAddress,NameOfTown,TownOrVillage,NameOfDistrict,NameOfState,ReligionOfFamily,AnyOtherReligion,FEduc,MEduc,FOccup,MOccup,AgeOfMotherMarraige,AgeOfMotherBirth,NoOfChild,AttentionType,DeliveryMethod,BirthWeight,DurationOfPregnancy,UserID,WEBstatusID,RegisterTypeID")] BND bND)
 {
     if (ModelState.IsValid)
     {
         db.Entry(bND).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index", new { rt = bND.RegisterTypeID }));
     }
     ViewBag.RegisterTypeID = new SelectList(db.RegisterTypes, "RegisterTypeID", "RegisterType1", bND.RegisterTypeID);
     ViewBag.WEBstatusID    = new SelectList(db.WEBstatus, "WebStatusID", "Status", bND.WEBstatusID);
     return(View(bND));
 }
        public static List <Model> LoadModelsFromBnd(BND bnd)
        {
            var modelEntries = bnd.Where(x => x.Name.ToUpper().EndsWith(".FLVER"));

            if (modelEntries.Any())
            {
                return(modelEntries.Select(x => new Model(SoulsFormats.FLVER.Read(x.GetBytes()))).ToList());
            }
            else
            {
                return(new List <Model>());
            }
        }
Пример #4
0
        // GET: BNDs/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            BND bND = db.BNDs.Find(id);

            if (bND == null)
            {
                return(HttpNotFound());
            }
            return(View(bND));
        }
Пример #5
0
        public static void AddTextureBnd(BND chrbnd, IProgress <double> prog)
        {
            var tpfFiles = chrbnd.Where(x => x.Name.EndsWith(".tpf")).ToList();
            int i        = 0;

            foreach (var t in tpfFiles)
            {
                SoulsFormats.TPF tpf = null;
                lock (_lock_IO)
                {
                    tpf = SoulsFormats.TPF.Read(t.GetBytes());
                }
                AddTpf(tpf);
                prog?.Report(1.0 * (++i) / tpfFiles.Count);
            }
        }
Пример #6
0
        // GET: BNDs/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            BND bND = db.BNDs.Find(id);

            ViewBag.RegisterTypeID = bND.RegisterTypeID;

            if (bND == null)
            {
                return(HttpNotFound());
            }
            ViewBag.WEBstatusID = new SelectList(db.WEBstatus, "WebStatusID", "Status", bND.WEBstatusID);
            return(View(bND));
        }
        public static List <Model> LoadModelChr(int id)
        {
            var bndName    = GetInterrootPath($@"chr\c{id:D4}.chrbnd");
            var texBndName = GetInterrootPath($@"chr\c{id:D4}.texbnd");
            // Used in Bloodborne
            var texExtendedTpf = GetInterrootPath($@"chr\c{id:D4}_2.tpf.dcx");

            BND bnd = LoadDecompressedBND(bndName);

            if (bnd != null)
            {
                var models = LoadModelsFromBnd(bnd);
                if (Type == InterrootType.InterrootDS3)
                {
                    // DS3 has separate texbnds for textures
                    BND texbnd = LoadDecompressedBND(texBndName);
                    if (texbnd != null)
                    {
                        TexturePool.AddTextureBnd(texbnd, null);
                    }
                }
                else
                {
                    if (File.Exists(texExtendedTpf))
                    {
                        SoulsFormats.TPF tpf = null;
                        lock (_lock_IO)
                        {
                            tpf = SoulsFormats.TPF.Read(texExtendedTpf);
                        }
                        TexturePool.AddTpf(tpf);
                    }
                    TexturePool.AddTextureBnd(bnd, null);
                }
                return(models);
            }

            return(new List <Model>());
        }
        // Utility function to detect and load a potentially DCX compressed BND
        public static BND LoadDecompressedBND(string path)
        {
            // Search for the decompressed bnd
            BND bnd = null;

            if (File.Exists(path))
            {
                lock (_lock_IO)
                {
                    bnd = DataFile.LoadFromFile <BND>(path);
                }
            }
            // Look for a compressed one if no decompressed one exists
            else if (File.Exists(path + ".dcx"))
            {
                lock (_lock_IO)
                {
                    bnd = DataFile.LoadFromDcxFile <BND>(path + ".dcx");
                }
            }
            return(bnd);
        }
 public static void LoadDragDroppedFiles(string[] fileNames)
 {
     LoadingTaskMan.DoLoadingTask("LoadDragDroppedFiles_" + DateTime.Now.Ticks, "Loading dropped models...", prog =>
     {
         var spawnTransform = GFX.World.GetSpawnPointFromMouseCursor(10.0f, false, true, true);
         int i = 0;
         foreach (var fn in fileNames)
         {
             var shortName = Path.GetFileNameWithoutExtension(fn);
             var upper     = fn.ToUpper();
             if (upper.EndsWith(".CHRBND") || upper.EndsWith(".OBJBND") || upper.EndsWith(".PARTSBND"))
             {
                 BND bnd = null;
                 lock (_lock_IO)
                 {
                     bnd = DataFile.LoadFromFile <BND>(fn);
                 }
                 TexturePool.AddTextureBnd(bnd, null);
                 var models = LoadModelsFromBnd(bnd);
                 foreach (var m in models)
                 {
                     GFX.ModelDrawer.AddModelInstance(
                         new ModelInstance(shortName, m, spawnTransform, -1, -1, -1, -1));
                 }
             }
             else if (upper.EndsWith(".FLVER") || upper.EndsWith(".FLVER.DCX"))
             {
                 var flver         = SoulsFormats.FLVER.Read(File.ReadAllBytes(fn));
                 var model         = new Model(flver);
                 var modelInstance = new ModelInstance(shortName, model, spawnTransform, -1, -1, -1, -1);
                 GFX.ModelDrawer.AddModelInstance(modelInstance);
             }
             prog?.Report(1.0 * (++i) / fileNames.Length);
         }
     });
 }
Пример #10
0
        public static void AddAllExternalDS1TexturesInBackground()
        {
            LoadingTaskMan.DoLoadingTask($"AddAllExternalDS1TexturesInBackground_UDSFM_MAP", $"Loading external map textures for DS1...", prog =>
            {
                //UDSFM MAP TEX
                var dir = InterrootLoader.GetInterrootPath(@"map\tx");
                if (Directory.Exists(dir))
                {
                    var mapTpfFileNames = Directory.GetFiles(dir);
                    int i = 0;
                    foreach (var t in mapTpfFileNames)
                    {
                        AddTpfFromPath(t);
                        prog?.Report(1.0 * (++i) / mapTpfFileNames.Length);
                    }
                }
                GFX.ModelDrawer.RequestTextureLoad();
            });

            LoadingTaskMan.DoLoadingTask($"AddAllExternalDS1TexturesInBackground_UDSFM_CHR", $"Loading external boss character textures for DS1...", prog =>
            {
                // UDSFM CHR TEX
                var udsfmTexFolderPath = InterrootLoader.GetInterrootPath($@"chr");
                if (Directory.Exists(udsfmTexFolderPath))
                {
                    var subDirectories = Directory.GetDirectories(udsfmTexFolderPath);
                    int i = 0;
                    foreach (var subDir in subDirectories)
                    {
                        var chrTpfFileNames = Directory.GetFiles(subDir, "*.tpf");
                        foreach (var t in chrTpfFileNames)
                        {
                            AddTpfFromPath(t);
                        }
                        prog?.Report(1.0 * (++i) / subDirectories.Length);
                    }
                }

                GFX.ModelDrawer.RequestTextureLoad();
            });

            LoadingTaskMan.DoLoadingTask($"AddAllExternalDS1TexturesInBackground_CHRBND_9", $"Loading external character textures for DS1...", prog =>
            {
                // CHRBND-9
                var chrbndsThatEndWith9 = Directory.GetFiles(InterrootLoader.GetInterrootPath(@"chr"), "*9.chrbnd");
                foreach (var ctew9 in chrbndsThatEndWith9)
                {
                    BND entityBnd = null;
                    lock (_lock_IO)
                    {
                        entityBnd = DataFile.LoadFromFile <BND>(ctew9);
                    }
                    AddTextureBnd(entityBnd, prog);
                }

                GFX.ModelDrawer.RequestTextureLoad();
            });

            LoadingTaskMan.DoLoadingTask($"AddAllExternalDS1TexturesInBackground_OBJBND_9", $"Loading external object textures for DS1...", prog =>
            {
                // CHRBND-9
                var chrbndsThatEndWith9 = Directory.GetFiles(InterrootLoader.GetInterrootPath(@"obj"), "*9.objbnd");
                foreach (var ctew9 in chrbndsThatEndWith9)
                {
                    BND entityBnd = null;
                    lock (_lock_IO)
                    {
                        entityBnd = DataFile.LoadFromFile <BND>(ctew9);
                    }
                    AddTextureBnd(entityBnd, prog);
                }

                GFX.ModelDrawer.RequestTextureLoad();
            });
        }
Пример #11
0
        private void iterateFiles(ConcurrentQueue <string> filepaths)
        {
            while (!stop && filepaths.TryDequeue(out string filepath))
            {
                // These are already full paths, but trust no one, not even yourself
                string absolute = Path.GetFullPath(filepath);
                string relative = absolute.Substring(gameDir.Length + 1);

                if (repack)
                {
                    appendLog("Checking: " + relative);
                }
                else
                {
                    appendLog("Unpacking: " + relative);
                }

                bool   dcx       = false;
                byte[] bytes     = File.ReadAllBytes(absolute);
                string extension = Path.GetExtension(absolute);
                string subpath   = Path.GetDirectoryName(relative) + "\\" + Path.GetFileNameWithoutExtension(absolute);
                if (extension == ".dcx")
                {
                    dcx       = true;
                    bytes     = DCX.Decompress(bytes);
                    extension = Path.GetExtension(Path.GetFileNameWithoutExtension(absolute));
                    subpath   = subpath.Substring(0, subpath.Length - extension.Length);
                }

                bool edited = false;
                switch (extension)
                {
                case ".tpf":
                    TPF tpf = TPF.Read(bytes);
                    if (processTPF(tpf, looseDir, subpath))
                    {
                        edited = true;
                        byte[] tpfBytes = tpf.Write();
                        if (dcx)
                        {
                            tpfBytes = DCX.Compress(tpfBytes);
                        }
                        writeRepack(absolute, tpfBytes);
                        lock (countLock)
                            fileCount++;
                    }
                    break;

                case ".tpfbhd":
                    string dir     = Path.GetDirectoryName(absolute);
                    string name    = Path.GetFileNameWithoutExtension(absolute);
                    string bdtPath = dir + "\\" + name + ".tpfbdt";
                    if (File.Exists(bdtPath))
                    {
                        byte[] bdtBytes = File.ReadAllBytes(bdtPath);
                        BDT    bdt      = BDT.Read(bytes, bdtBytes);
                        if (processBDT(bdt, looseDir, subpath))
                        {
                            edited = true;
                            (byte[], byte[])repacked = bdt.Write();
                            if (dcx)
                            {
                                repacked.Item1 = DCX.Compress(repacked.Item1);
                            }
                            writeRepack(absolute, repacked.Item1);
                            writeRepack(bdtPath, repacked.Item2);
                            lock (countLock)
                                fileCount++;
                        }
                    }
                    else
                    {
                        throw new FileNotFoundException("Data file not found for header: " + relative);
                    }
                    break;

                case ".chrbnd":
                case ".ffxbnd":
                case ".fgbnd":
                case ".objbnd":
                case ".partsbnd":
                    BND bnd = BND.Read(bytes);
                    foreach (BND.File entry in bnd.Files)
                    {
                        if (stop)
                        {
                            break;
                        }

                        string entryExtension = Path.GetExtension(entry.Name);
                        if (entryExtension == ".tpf")
                        {
                            TPF bndTPF = TPF.Read(entry.Bytes);
                            if (processTPF(bndTPF, looseDir, subpath))
                            {
                                entry.Bytes = bndTPF.Write();
                                edited      = true;
                            }
                        }
                        else if (entryExtension == ".chrtpfbhd")
                        {
                            string bndDir  = Path.GetDirectoryName(absolute);
                            string bndName = Path.GetFileNameWithoutExtension(absolute);
                            if (dcx)
                            {
                                bndName = Path.GetFileNameWithoutExtension(bndName);
                            }
                            string bndBDTPath = bndDir + "\\" + bndName + ".chrtpfbdt";
                            if (File.Exists(bndBDTPath))
                            {
                                byte[] bdtBytes = File.ReadAllBytes(bndBDTPath);
                                BDT    bndBDT   = BDT.Read(entry.Bytes, bdtBytes);
                                if (processBDT(bndBDT, looseDir, subpath))
                                {
                                    (byte[], byte[])repacked = bndBDT.Write();
                                    entry.Bytes = repacked.Item1;
                                    writeRepack(bndBDTPath, repacked.Item2);
                                    edited = true;
                                }
                            }
                            else
                            {
                                throw new FileNotFoundException("Data file not found for header: " + relative);
                            }
                        }
                    }

                    if (edited && !stop)
                    {
                        byte[] bndBytes = bnd.Write();
                        if (dcx)
                        {
                            bndBytes = DCX.Compress(bndBytes);
                        }
                        writeRepack(absolute, bndBytes);
                        lock (countLock)
                            fileCount++;
                    }
                    break;
                }

                if (repack && !edited && !stop)
                {
                    appendError("Notice: {0}\r\n\u2514\u2500 No overrides found.", relative);
                }

                lock (progressLock)
                    progress++;
            }
        }