Beispiel #1
0
        private void materialRaisedButton6_Click(object sender, EventArgs e)
        {
            if (CommonSzs == null)
            {
                MessageBox.Show("Open the modded file via SZS PATCHING>OPEN SZS first");
                return;
            }
            OpenFileDialog opn = new OpenFileDialog()
            {
                Title  = "Open the original SZS to diff",
                Filter = "SZS file|*.szs"
            };

            if (opn.ShowDialog() != DialogResult.OK)
            {
                return;
            }
            var         originalSzs = SARCExt.SARC.UnpackRamN(ManagedYaz0.Decompress(File.ReadAllBytes(opn.FileName)));
            LayoutPatch res         = null;

#if !DEBUG
            try
            {
#endif
            string msg;
            (res, msg) = LayoutDiff.Diff(originalSzs, CommonSzs);
            if (msg != null)
            {
                MessageBox.Show(msg);
            }
#if !DEBUG
        }

        catch (Exception ex)
        {
            MessageBox.Show(ex.Message);
            return;
        }
#endif

            SaveFileDialog sav = new SaveFileDialog()
            {
                Title  = "save the patch file",
                Filter = "json patch file|*.json"
            };
            if (sav.ShowDialog() != DialogResult.OK)
            {
                return;
            }
            File.WriteAllText(sav.FileName, res.AsJson());
        }
Beispiel #2
0
        static void MakeNxTheme(string partName, string name, string author, LayoutPatch targetLayout)
        {
            if (LoadedDDS == null)
            {
                Window.Alert("Open a DDS first !");
                return;
            }
            if (!ValidAutoThemeParts.Contains(partName))
            {
                Window.Alert("select a valid Home menu part");
                return;
            }
            if (name.Trim() == "")
            {
                Window.Alert("Enter a valid name");
                return;
            }
            DoActionWithloading(() =>
            {
                var dds = DDSEncoder.LoadDDS(LoadedDDS);                 //this will crash if the dds type is wrong

                var meta = new ThemeFileManifest()
                {
                    Version    = 1,
                    Author     = author,
                    LayoutInfo = targetLayout != null ? targetLayout.ToString() : "",
                    ThemeName  = name,
                    Target     = partName,
                };

                var res              = SwitchThemesCommon.GenerateNXTheme(meta, LoadedDDS, targetLayout == null ? null : System.Text.Encoding.UTF8.GetBytes(targetLayout.AsJson()));
                Uint8Array dwn       = new Uint8Array(res);
                string DownloadFname = name + ".nxtheme";
                Script.Write("downloadBlob(dwn,DownloadFname,'application/octet-stream');");
            });
        }
        static void DoAutoTheme(string type, string url, string layout)
        {
            cardLoad = Document.GetElementById <HTMLDivElement>("CardLoad");
            Document.GetElementById <HTMLDivElement>("CardTutorial").Hidden = true;
            string themeTarget = "<br/><br/>This theme is an nxtheme, download NXThemes Installer to install it on your switch.";

            cardLoad.InnerHTML = "Wait while your theme is being generated.... " + themeTarget;
            cardLoad.Hidden    = false;
            StartLoading();

            byte[]      DDS;
            LayoutPatch targetLayout = null;

            void BuildTheme()
            {
                var urlSplit = url.Split("/");
                var meta     = new ThemeFileManifest()
                {
                    Version    = 1,
                    Author     = "Auto-Theme",
                    LayoutInfo = targetLayout != null?targetLayout.ToString() : "",
                                     ThemeName = urlSplit[urlSplit.Length - 1],
                                     Target    = type
                };

                var res = SwitchThemesCommon.GenerateNXTheme(meta, DDS, targetLayout == null ? null : targetLayout.AsJson());

                if (res == null)
                {
                    endWithError("GenerateNXTheme() failed :(");
                    return;
                }
                Uint8Array dwn           = new Uint8Array(res);
                string     DownloadFname = urlSplit[urlSplit.Length - 1] + ".nxtheme";

                Script.Write("downloadBlob(dwn,DownloadFname,'application/octet-stream');");
                Document.GetElementById <HTMLDivElement>("CardLoad").InnerHTML = "Your theme has been generated !" + themeTarget;
                EndLoading();
            }

            void DDSDownloaded(Uint8Array arr)
            {
                DDS = arr.ToArray();

                if (layout == null)
                {
                    BuildTheme();
                }
                else
                {
                    HttpRequest(layout, LayoutDownloaded, "Layout");
                }
            }

            void LayoutDownloaded(string req)
            {
                targetLayout = LayoutPatch.LoadTemplate(req);
                BuildTheme();
            }

            HttpRequest(url, DDSDownloaded, "DDS");
        }