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 static string CreateTestPatches()
        {
            var p = new LayoutPatch()
            {
                PatchName  = "test patch",
                AuthorName = "exelix",
                Files      = new LayoutFilePatch[]
                {
                    new LayoutFilePatch()
                    {
                        FileName = "blyt/RdtBase.bflyt",
                        Patches  = new PanePatch[]
                        {
                            new PanePatch()
                            {
                                PaneName = "L_BtnNoti",
                                Position = new Vector3 {
                                    Y = -500
                                },
                                Scale = new Vector2 {
                                    X = 10
                                }
                            }
                        }
                    }
                }
            };

            return(p.AsJson());
        }
        public static void CreateTestTemplates()
        {
            var p = new LayoutPatch()
            {
                PatchName  = "test patch",
                AuthorName = "exelix",
                Files      = new LayoutFilePatch[]
                {
                    new LayoutFilePatch()
                    {
                        FileName = "blyt/RdtBase.bflyt",
                        Patches  = new PanePatch[]
                        {
                            new PanePatch()
                            {
                                PaneName = "L_BtnNoti",
                                Position = new NullableVector3 {
                                    X = 0, Y = -500
                                },
                            }
                        }
                    }
                }
            };

            System.IO.File.WriteAllText("ExtraLayouts.json", JsonConvert.SerializeObject(p));
        }
 public void AddMainLayout(LayoutPatch l)
 {
     if (l == null)
     {
         return;
     }
     AddFile("layout.json", l.AsByteArray());
     info.LayoutInfo = l.PatchName + " by " + l.AuthorName;
 }
        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);
        }
Esempio n. 6
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);
        }
        public bool PatchLayouts(LayoutPatch Patch, PatchTemplate context)
        {
            int fixVer = 0;

            if (context != null)
            {
                if (context.NXThemeName == "home")
                {
                    fixVer = 8;
                }
                if (context.FirmName == "9.0")
                {
                    fixVer = 9;
                }
            }

            return(PatchLayouts(Patch, context?.NXThemeName ?? "", context?.FirmName ?? "", fixVer));
        }
Esempio n. 8
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);
        }
 public void AddMainLayout(string text) =>
 AddMainLayout(LayoutPatch.LoadTemplate(text));
Esempio n. 10
0
 public bool PatchLayouts(LayoutPatch Patch, PatchTemplate context) =>
 PatchLayouts(Patch, context?.NXThemeName ?? "", context?.PatchRevision ?? 0);
Esempio n. 11
0
 public void AddCommonLayout(string json) =>
 AddFile("common.json", LayoutPatch.Load(json).AsByteArray());
Esempio n. 12
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);
        }
Esempio n. 13
0
 public bool PatchLayouts(LayoutPatch Patch) =>
 PatchLayouts(Patch, PatchTemplate?.NXThemeName ?? "");
Esempio n. 14
0
 public void AddCommonLayout(LayoutPatch data) =>
 AddFile("common.json", data.AsByteArray());
 public bool PatchLayouts(LayoutPatch Patch) =>
 PatchLayouts(Patch, PatchTemplate);