public bool PatchLayouts(LayoutPatch Patch, string PartName, bool FixFor8)
        {
            if (PartName == "home" && Patch.PatchAppletColorAttrib)
            {
                PatchBntxTextureAttribs(new Tuple <string, uint>("RdtIcoPvr_00^s", 0x5050505),
                                        new Tuple <string, uint>("RdtIcoNews_00^s", 0x5050505), new Tuple <string, uint>("RdtIcoNews_01^s", 0x5050505),
                                        new Tuple <string, uint>("RdtIcoSet^s", 0x5050505), new Tuple <string, uint>("RdtIcoShop^s", 0x5050505),
                                        new Tuple <string, uint>("RdtIcoCtrl_00^s", 0x5050505), new Tuple <string, uint>("RdtIcoCtrl_01^s", 0x5050505),
                                        new Tuple <string, uint>("RdtIcoCtrl_02^s", 0x5050505), new Tuple <string, uint>("RdtIcoPwrForm^s", 0x5050505));
            }

            List <LayoutFilePatch> Files = new List <LayoutFilePatch>();

            Files.AddRange(Patch.Files);
            if (FixFor8 && !Patch.Ready8X)
            {
                var extra = NewFirmFixes.GetFix(Patch.PatchName);
                if (extra != null)
                {
                    Files.AddRange(extra);
                }
            }

            foreach (var p in Files)
            {
                var res = PatchSingleLayout(p);
                if (!res)
                {
                    return(res);
                }
            }
            return(true);
        }
        public bool PatchLayouts(LayoutPatch Patch, string PartName, PatchTemplate context)
        {
            if (PartName == "home" && Patch.PatchAppletColorAttrib)
            {
                PatchBntxTextureAttribs(new Tuple <string, uint>("RdtIcoPvr_00^s", 0x5050505),
                                        new Tuple <string, uint>("RdtIcoNews_00^s", 0x5050505), new Tuple <string, uint>("RdtIcoNews_01^s", 0x5050505),
                                        new Tuple <string, uint>("RdtIcoSet^s", 0x5050505), new Tuple <string, uint>("RdtIcoShop^s", 0x5050505),
                                        new Tuple <string, uint>("RdtIcoCtrl_00^s", 0x5050505), new Tuple <string, uint>("RdtIcoCtrl_01^s", 0x5050505),
                                        new Tuple <string, uint>("RdtIcoCtrl_02^s", 0x5050505), new Tuple <string, uint>("RdtIcoPwrForm^s", 0x5050505));
            }

            List <LayoutFilePatch> Files = new List <LayoutFilePatch>();

            Files.AddRange(Patch.Files);

            int fixVer = 0;

            if (context != null)
            {
                if (context.NXThemeName == "home")
                {
                    fixVer = 8;
                }
                if (context.FirmName == "9.0")
                {
                    fixVer = 9;
                }
            }
            if (fixVer >= 8 && !Patch.Ready8X)
            {
                var extra = NewFirmFixes.GetFix(Patch.PatchName, context);
                if (extra != null)
                {
                    Files.AddRange(extra);
                }
            }

            foreach (var p in Files)
            {
                var res = PatchSingleLayout(p);
                if (!res)
                {
                    return(res);
                }
            }
            return(true);
        }
示例#3
0
        public bool PatchLayouts(LayoutPatch Patch, string PartName, int PatchRevision)
        {
            if (PartName == "home" && Patch.PatchAppletColorAttrib)
            {
                PatchBntxTextureAttribs(new Tuple <string, uint>("RdtIcoPvr_00^s", 0x5050505),
                                        new Tuple <string, uint>("RdtIcoNews_00^s", 0x5050505), new Tuple <string, uint>("RdtIcoNews_01^s", 0x5050505),
                                        new Tuple <string, uint>("RdtIcoSet^s", 0x5050505), new Tuple <string, uint>("RdtIcoShop^s", 0x5050505),
                                        new Tuple <string, uint>("RdtIcoCtrl_00^s", 0x5050505), new Tuple <string, uint>("RdtIcoCtrl_01^s", 0x5050505),
                                        new Tuple <string, uint>("RdtIcoCtrl_02^s", 0x5050505), new Tuple <string, uint>("RdtIcoPwrForm^s", 0x5050505));
            }

            List <LayoutFilePatch> Files = new List <LayoutFilePatch>();

            Files.AddRange(Patch.Files);

            LayoutFilePatch[] extra;
            //Legacy fixes based on name and version
            if (PatchRevision != 0 && Patch.UsesOldFixes)
            {
                extra = NewFirmFixes.GetFixLegacy(Patch.PatchName, PatchRevision, PartName);
                if (extra != null)
                {
                    Files.AddRange(extra);
                }
            }
            //Modern fixes based on layout ID
            else if (Patch.ID != null)
            {
                extra = NewFirmFixes.GetFix(PartName, Patch.ID, PatchRevision);
                if (extra != null)
                {
                    Files.AddRange(extra);
                }
            }

            foreach (var p in Files)
            {
                var res = PatchSingleLayout(p);
                if (!res)
                {
                    return(res);
                }
            }
            return(true);
        }
示例#4
0
        public static BflytFile.PatchResult PatchLayouts(SARCExt.SarcData sarc, LayoutPatch Patch, bool FixFor8, bool AddAnimations = false)
        {
            List <LayoutFilePatch> Files = new List <LayoutFilePatch>();

            Files.AddRange(Patch.Files);
            if (FixFor8 && !Patch.Ready8X)
            {
                var extra = NewFirmFixes.GetFix(Patch.PatchName);
                if (extra != null)
                {
                    Files.AddRange(extra);
                }
            }

            foreach (var p in Files)
            {
                if (!sarc.Files.ContainsKey(p.FileName))
                {
                    return(BflytFile.PatchResult.Fail);
                }
                var target = new BflytFile(sarc.Files[p.FileName]);
                var res    = target.ApplyLayoutPatch(p.Patches);
                if (res != BflytFile.PatchResult.OK)
                {
                    return(res);
                }
                if (AddAnimations)
                {
                    res = target.AddGroupNames(p.AddGroups);
                    if (res != BflytFile.PatchResult.OK)
                    {
                        return(res);
                    }
                }
                sarc.Files[p.FileName] = target.SaveFile();
            }
            return(BflytFile.PatchResult.OK);
        }
示例#5
0
        private bool PatchLayouts(LayoutPatch Patch, string PartName)
        {
            var fw = FirmwareDetection.Detect(PartName, sarc);

            if (PartName == "home" && Patch.PatchAppletColorAttrib)
            {
                PatchBntxTextureAttribs(new Tuple <string, uint>("RdtIcoPvr_00^s", 0x5050505),
                                        new Tuple <string, uint>("RdtIcoNews_00^s", 0x5050505), new Tuple <string, uint>("RdtIcoNews_01^s", 0x5050505),
                                        new Tuple <string, uint>("RdtIcoSet^s", 0x5050505), new Tuple <string, uint>("RdtIcoShop^s", 0x5050505),
                                        new Tuple <string, uint>("RdtIcoCtrl_00^s", 0x5050505), new Tuple <string, uint>("RdtIcoCtrl_01^s", 0x5050505),
                                        new Tuple <string, uint>("RdtIcoCtrl_02^s", 0x5050505), new Tuple <string, uint>("RdtIcoPwrForm^s", 0x5050505));
            }

            List <LayoutFilePatch> Files = new List <LayoutFilePatch>();

            Files.AddRange(Patch.Files);

            LayoutFilePatch[] extra;
            //Legacy fixes based on name and version
            if (fw != FirmwareDetection.Firmware.Invariant && Patch.UsesOldFixes)
            {
                extra = NewFirmFixes.GetFixLegacy(Patch.PatchName, fw, PartName);
                if (extra != null)
                {
                    Files.AddRange(extra);
                }
            }
            //Modern fixes based on layout ID
            else if (Patch.ID != null)
            {
                extra = NewFirmFixes.GetFix(PartName, Patch.ID, fw);
                if (extra != null)
                {
                    Files.AddRange(extra);
                }
            }

            foreach (var p in Files)
            {
                var res = PatchSingleLayout(p);
                if (!res)
                {
                    return(res);
                }
            }

            List <AnimFilePatch> Anims = new List <AnimFilePatch>();

            if (Patch.Anims != null)
            {
                Anims.AddRange(Patch.Anims);
            }

            if (PartName == "home")
            {
                AnimFilePatch[] animExtra = null;
                if (Patch.HideOnlineBtn ?? true)
                {
                    animExtra = NewFirmFixes.GetNoOnlineButtonFix(fw);
                }
                else if (NewFirmFixes.ShouldApplyAppletPositionFix(Anims))
                {
                    animExtra = NewFirmFixes.GetAppletsPositionFix(fw);
                }

                if (animExtra != null)
                {
                    Anims.AddRange(animExtra);
                }
            }

            if (Anims.Any())
            {
                // The bflan version varies between firmwares, load a file from the list to detect the right one
                BflanFile b             = new BflanFile(sarc.Files[Anims[0].FileName]);
                var       TargetVersion = b.Version;
                b = null;

                foreach (var p in Anims)
                {
                    if (!sarc.Files.ContainsKey(p.FileName))
                    {
                        continue;
                    }

                    var n = BflanSerializer.FromJson(p.AnimJson);
                    n.Version              = TargetVersion;
                    n.byteOrder            = Syroot.BinaryData.ByteOrder.LittleEndian;
                    sarc.Files[p.FileName] = n.WriteFile();
                }
            }

            return(true);
        }