diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..8234285 --- /dev/null +++ b/.gitignore @@ -0,0 +1,13 @@ +/*.vsconfig +/Library/ +/Temp/ +/UserSettings/ +/.vs/ +/*.csproj +/*.sln +/obj/ +/logs/ +/Output/ +**/switch_keys/*.keys +**/switch_keys/*.keys.meta +**/NintendoSDKPlugin/ \ No newline at end of file diff --git a/Assets/AxiProjectTools/AxiNSPack/Editors/AxibugNSPTools.cs b/Assets/AxiProjectTools/AxiNSPack/Editors/AxibugNSPTools.cs index 4da1036..a162085 100644 --- a/Assets/AxiProjectTools/AxiNSPack/Editors/AxibugNSPTools.cs +++ b/Assets/AxiProjectTools/AxiNSPack/Editors/AxibugNSPTools.cs @@ -1,7 +1,9 @@ +#if UNITY_EDITOR_WIN using System; using System.Collections.Generic; using System.IO; using System.Linq; +using System.Runtime.InteropServices; using System.Text; using System.Text.RegularExpressions; using UnityEditor; @@ -37,12 +39,12 @@ namespace AxibugEmuOnline.Editors } [MenuItem("Axibug��ֲ����/Switch/AxibugNSPTools/Build With RepackNSP(���NSP�����¹���NPS��")] - static void BuildWithRepackNSP() + public static void BuildWithRepackNSP() { if (!CheckEnvironmentVariable()) return; - if (!EditorUtility.DisplayDialog("ȷ�ϰ���Ϣ", $"�������?", "����", "ȡ��")) + if (!EditorUtility.DisplayDialog("���", $"ȷ�ϴ��NSP?", "����", "ȡ��")) return; var levels = new List<string>(); @@ -68,7 +70,7 @@ namespace AxibugEmuOnline.Editors #endif string targetName = $"{Application.productName}_{titleid}.nsp"; - string _locationPathName = $"Output/NSPBuild/{targetName}"; + string _locationPathName = $"Output/NSPBuild/{targetName}"; var options = new BuildPlayerOptions { scenes = levels.ToArray(), @@ -81,7 +83,7 @@ namespace AxibugEmuOnline.Editors { BuildReport report = BuildPipeline.BuildPlayer(options); } - catch(Exception ex) + catch (Exception ex) { Debug.LogError($"[AxibugNSPTools] Unity Build NSP ����:{ex.ToString()}"); return; @@ -146,13 +148,13 @@ namespace AxibugEmuOnline.Editors #region ������ʱĿ¼ CleanDirectory(Path.Combine(nspParentDir, "repacker_extract")); CleanDirectory(Path.Combine(Path.GetTempPath(), "NCA")); - CleanDirectory(Path.Combine(WorkRoot, "hacpack_backup")); + CleanDirectory(Path.Combine(nspParentDir, "hacpack_backup")); #endregion EditorUtility.DisplayProgressBar("AxibugNSPTools", $"���NSP�ļ�", 0.2f); #region ���NSP�ļ� string extractPath = Path.Combine(nspParentDir, "repacker_extract"); - ExecuteCommand($"{tools["authoringTool"]} extract -o \"{extractPath}\" \"{nspFilePath}\""); + ExecuteCommand($"{tools["authoringTool"]} extract -o \"{extractPath}\" \"{nspFilePath}\"", nspParentDir); string controlPath = null; string programPath = null; @@ -166,19 +168,32 @@ namespace AxibugEmuOnline.Editors #region �ؽ�NCA/NSP string tmpPath = Path.Combine(Path.GetTempPath(), "NCA"); - EditorUtility.DisplayProgressBar("AxibugNSPTools", $"�ؽ�NCA", 0.6f); - string programNCA = BuildProgramNCA(tmpPath, titleID, programPath); - EditorUtility.DisplayProgressBar("AxibugNSPTools", $"�ؽ�NCA", 0.7f); - string controlNCA = BuildControlNCA(tmpPath, titleID, controlPath); - EditorUtility.DisplayProgressBar("AxibugNSPTools", $"�ؽ�NCA", 0.8f); - BuildMetaNCA(tmpPath, titleID, programNCA, controlNCA); + EditorUtility.DisplayProgressBar("AxibugNSPTools", $"�ؽ� Program NCA", 0.3f); + string programNCA = BuildProgramNCA(tmpPath, titleID, programPath, nspParentDir); + EditorUtility.DisplayProgressBar("AxibugNSPTools", $"�ؽ� Control NCA", 0.4f); + string controlNCA = BuildControlNCA(tmpPath, titleID, controlPath, nspParentDir); + EditorUtility.DisplayProgressBar("AxibugNSPTools", $"�ؽ� Meta NCA", 0.5f); + BuildMetaNCA(tmpPath, titleID, programNCA, controlNCA, nspParentDir); + EditorUtility.DisplayProgressBar("AxibugNSPTools", $"�ؽ�NSP", 0.6f); + string outputNSP = BuildFinalNSP(nspFilePath, nspParentDir, tmpPath, titleID, nspParentDir); EditorUtility.DisplayProgressBar("AxibugNSPTools", $"�ؽ�NSP", 0.9f); - string outputNSP = BuildFinalNSP(nspFilePath, nspParentDir, tmpPath, titleID); - EditorUtility.DisplayProgressBar("AxibugNSPTools", $"�ؽ�NSP", 1f); Debug.Log($"[AxibugNSPTools]Repacking completed: {outputNSP}"); - EditorUtility.ClearProgressBar(); - #endregion - } + + #endregion + + EditorUtility.DisplayProgressBar("AxibugNSPTools", $"������ʱĿ¼", 1); + #region ������ʱĿ¼ + CleanDirectory(Path.Combine(nspParentDir, "repacker_extract")); + CleanDirectory(Path.Combine(Path.GetTempPath(), "NCA")); + CleanDirectory(Path.Combine(nspParentDir, "hacpack_backup")); + #endregion + System.Diagnostics.Process.Start("explorer", "/select,\"" + outputNSP.Trim() + "\""); + EditorUtility.ClearProgressBar(); + + + } + + #region �������� static string GetUserInput() @@ -186,14 +201,12 @@ namespace AxibugEmuOnline.Editors Console.Write("Enter the NSP filepath: "); return Console.ReadLine(); } - static string ExtractTitleID(string path) { var match = Regex.Match(path, @"0100[\dA-Fa-f]{12}"); return match.Success ? match.Value : null; } - static void CleanDirectory(string path) { if (Directory.Exists(path)) @@ -214,8 +227,9 @@ namespace AxibugEmuOnline.Editors } } - static string ExecuteCommand(string command) + static string ExecuteCommand(string command, string workdir) { + Debug.Log($"����cmd=>{command}"); var process = new System.Diagnostics.Process() { StartInfo = new System.Diagnostics.ProcessStartInfo @@ -227,7 +241,8 @@ namespace AxibugEmuOnline.Editors UseShellExecute = false, CreateNoWindow = true, StandardOutputEncoding = Encoding.UTF8, // ��ȷָ������ - StandardErrorEncoding = Encoding.UTF8 + StandardErrorEncoding = Encoding.UTF8, + WorkingDirectory = workdir } }; @@ -274,36 +289,36 @@ namespace AxibugEmuOnline.Editors #endregion #region NCA������ - static string BuildProgramNCA(string tmpPath, string titleID, string programDir) + static string BuildProgramNCA(string tmpPath, string titleID, string programDir, string workdir) { string args = $"-k \"{prodKeysPath}\" -o \"{tmpPath}\" --titleid {titleID} " + $"--type nca --ncatype program --exefsdir \"{programDir}/fs0\" " + $"--romfsdir \"{programDir}/fs1\" --logodir \"{programDir}/fs2\""; - string output = ExecuteCommand($"{tools["hacPack"]} {args}"); + string output = ExecuteCommand($"{tools["hacPack"]} {args}", workdir); return ParseNCAOutput(output, "Program"); } - static string BuildControlNCA(string tmpPath, string titleID, string controlDir) + static string BuildControlNCA(string tmpPath, string titleID, string controlDir, string workdir) { string args = $"-k \"{prodKeysPath}\" -o \"{tmpPath}\" --titleid {titleID} " + $"--type nca --ncatype control --romfsdir \"{controlDir}/fs0\""; - string output = ExecuteCommand($"{tools["hacPack"]} {args}"); + string output = ExecuteCommand($"{tools["hacPack"]} {args}", workdir); return ParseNCAOutput(output, "Control"); } - static void BuildMetaNCA(string tmpPath, string titleID, string programNCA, string controlNCA) + static void BuildMetaNCA(string tmpPath, string titleID, string programNCA, string controlNCA, string workdir) { string args = $"-k \"{prodKeysPath}\" -o \"{tmpPath}\" --titleid {titleID} " + $"--type nca --ncatype meta --titletype application " + $"--programnca \"{programNCA}\" --controlnca \"{controlNCA}\""; - ExecuteCommand($"{tools["hacPack"]} {args}"); + ExecuteCommand($"{tools["hacPack"]} {args}", workdir); } - static string BuildFinalNSP(string origPath, string parentDir, string tmpPath, string titleID) + static string BuildFinalNSP(string origPath, string parentDir, string tmpPath, string titleID, string workdir) { string outputPath = origPath.Replace(".nsp", "_repacked.nsp"); if (File.Exists(outputPath)) File.Delete(outputPath); @@ -311,7 +326,7 @@ namespace AxibugEmuOnline.Editors string args = $"-k \"{prodKeysPath}\" -o \"{parentDir}\" --titleid {titleID} " + $"--type nsp --ncadir \"{tmpPath}\""; - ExecuteCommand($"{tools["hacPack"]} {args}"); + ExecuteCommand($"{tools["hacPack"]} {args}", workdir); File.Move(Path.Combine(parentDir, $"{titleID}.nsp"), outputPath); return outputPath; } @@ -320,8 +335,11 @@ namespace AxibugEmuOnline.Editors { var line = output.Split('\n') .FirstOrDefault(l => l.Contains($"Created {type} NCA:")); - return line?.Split(':').Last().Trim(); + //return line?.Split(':').Last().Trim(); + return line?.Substring(line.IndexOf("NCA:") + "NCA:".Length).Trim(); + } #endregion } } +#endif \ No newline at end of file diff --git a/Assets/AxiProjectTools/AxiNSPack/hacpack/Tools.meta b/Assets/AxiProjectTools/AxiNSPack/hacpack/Tools.meta deleted file mode 100644 index e6fce36..0000000 --- a/Assets/AxiProjectTools/AxiNSPack/hacpack/Tools.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: b31e2ae7250c09548a777d4dcdfe2d1f -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AxiProjectTools/AxiNSPack/hacpack/Tools/hacPackTools-NACP.meta b/Assets/AxiProjectTools/AxiNSPack/hacpack/Tools/hacPackTools-NACP.meta deleted file mode 100644 index 708c152..0000000 --- a/Assets/AxiProjectTools/AxiNSPack/hacpack/Tools/hacPackTools-NACP.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 7be57cd4293e9dc4297ea9b83fe08b18 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AxiProjectTools/AxiNSPack/hacpack/Tools/hacPackTools-NACP/hptnacp.exe b/Assets/AxiProjectTools/AxiNSPack/hacpack/Tools/hacPackTools-NACP/hptnacp.exe deleted file mode 100644 index 7b48599..0000000 Binary files a/Assets/AxiProjectTools/AxiNSPack/hacpack/Tools/hacPackTools-NACP/hptnacp.exe and /dev/null differ diff --git a/Assets/AxiProjectTools/AxiNSPack/hacpack/Tools/hacPackTools-NACP/hptnacp.exe.meta b/Assets/AxiProjectTools/AxiNSPack/hacpack/Tools/hacPackTools-NACP/hptnacp.exe.meta deleted file mode 100644 index 81ccc3b..0000000 --- a/Assets/AxiProjectTools/AxiNSPack/hacpack/Tools/hacPackTools-NACP/hptnacp.exe.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: e1252f6d74d67ee48af0a0342aecc981 -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AxiProjectTools/AxiNSPack/hacpack/Tools/hacPackTools-NACP/sample_hbemnu.nacp.xml b/Assets/AxiProjectTools/AxiNSPack/hacpack/Tools/hacPackTools-NACP/sample_hbemnu.nacp.xml deleted file mode 100644 index 09433f8..0000000 --- a/Assets/AxiProjectTools/AxiNSPack/hacpack/Tools/hacPackTools-NACP/sample_hbemnu.nacp.xml +++ /dev/null @@ -1,152 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<Application> - <Title> - <Language>AmericanEnglish</Language> - <Name>Homebrew Menu</Name> - <Publisher>Yellows8</Publisher> - </Title> - <Title> - <Language>BritishEnglish</Language> - <Name>Homebrew Menu</Name> - <Publisher>Yellows8</Publisher> - </Title> - <Title> - <Language>Japanese</Language> - <Name>Homebrew Menu</Name> - <Publisher>Yellows8</Publisher> - </Title> - <Title> - <Language>French</Language> - <Name>Homebrew Menu</Name> - <Publisher>Yellows8</Publisher> - </Title> - <Title> - <Language>German</Language> - <Name>Homebrew Menu</Name> - <Publisher>Yellows8</Publisher> - </Title> - <Title> - <Language>LatinAmericanSpanish</Language> - <Name>Homebrew Menu</Name> - <Publisher>Yellows8</Publisher> - </Title> - <Title> - <Language>Spanish</Language> - <Name>Homebrew Menu</Name> - <Publisher>Yellows8</Publisher> - </Title> - <Title> - <Language>Italian</Language> - <Name>Homebrew Menu</Name> - <Publisher>Yellows8</Publisher> - </Title> - <Title> - <Language>Dutch</Language> - <Name>Homebrew Menu</Name> - <Publisher>Yellows8</Publisher> - </Title> - <Title> - <Language>CanadianFrench</Language> - <Name>Homebrew Menu</Name> - <Publisher>Yellows8</Publisher> - </Title> - <Title> - <Language>Portuguese</Language> - <Name>Homebrew Menu</Name> - <Publisher>Yellows8</Publisher> - </Title> - <Title> - <Language>Russian</Language> - <Name>Homebrew Menu</Name> - <Publisher>Yellows8</Publisher> - </Title> - <Isbn/> - <StartupUserAccount>Required</StartupUserAccount> - <UserAccountSwitchLock>Disable</UserAccountSwitchLock> - <ParentalControl>None</ParentalControl> - <SupportedLanguage>AmericanEnglish</SupportedLanguage> - <SupportedLanguage>BritishEnglish</SupportedLanguage> - <SupportedLanguage>Japanese</SupportedLanguage> - <SupportedLanguage>French</SupportedLanguage> - <SupportedLanguage>German</SupportedLanguage> - <SupportedLanguage>LatinAmericanSpanish</SupportedLanguage> - <SupportedLanguage>Spanish</SupportedLanguage> - <SupportedLanguage>Italian</SupportedLanguage> - <SupportedLanguage>Dutch</SupportedLanguage> - <SupportedLanguage>CanadianFrench</SupportedLanguage> - <SupportedLanguage>Russian</SupportedLanguage> - <Screenshot>Allow</Screenshot> - <VideoCapture>Disable</VideoCapture> - <PresenceGroupId>0x0104444444441001</PresenceGroupId> - <DisplayVersion>2.0</DisplayVersion> - <Rating> - <Organization>CERO</Organization> - <Age>12</Age> - </Rating> - <Rating> - <Organization>ESRB</Organization> - <Age>10</Age> - </Rating> - <Rating> - <Organization>USK</Organization> - <Age>12</Age> - </Rating> - <Rating> - <Organization>PEGI</Organization> - <Age>12</Age> - </Rating> - <Rating> - <Organization>PEGIPortugal</Organization> - <Age>12</Age> - </Rating> - <Rating> - <Organization>PEGIBBFC</Organization> - <Age>12</Age> - </Rating> - <Rating> - <Organization>Russian</Organization> - <Age>12</Age> - </Rating> - <Rating> - <Organization>ACB</Organization> - <Age>13</Age> - </Rating> - <Rating> - <Organization>OFLC</Organization> - <Age>13</Age> - </Rating> - <DataLossConfirmation>Required</DataLossConfirmation> - <PlayLogPolicy>All</PlayLogPolicy> - <SaveDataOwnerId>0x0104444444441001</SaveDataOwnerId> - <UserAccountSaveDataSize>0x0000000003e00000</UserAccountSaveDataSize> - <UserAccountSaveDataJournalSize>0x0000000000180000</UserAccountSaveDataJournalSize> - <DeviceSaveDataSize>0x0000000000000000</DeviceSaveDataSize> - <DeviceSaveDataJournalSize>0x0000000000000000</DeviceSaveDataJournalSize> - <BcatDeliveryCacheStorageSize>0x0000000000000000</BcatDeliveryCacheStorageSize> - <ApplicationErrorCodeCategory/> - <AddOnContentBaseId>0x0104444444442001</AddOnContentBaseId> - <LogoType>Nintendo</LogoType> - <LocalCommunicationId>0x0104444444441001</LocalCommunicationId> - <LogoHandling>Auto</LogoHandling> - <SeedForPseudoDeviceId>0x0000000000000000</SeedForPseudoDeviceId> - <BcatPassphrase/> - <AddOnContentRegistrationType>AllOnLaunch</AddOnContentRegistrationType> - <UserAccountSaveDataSizeMax>0x0000000000000000</UserAccountSaveDataSizeMax> - <UserAccountSaveDataJournalSizeMax>0x0000000000000000</UserAccountSaveDataJournalSizeMax> - <DeviceSaveDataSizeMax>0x0000000000000000</DeviceSaveDataSizeMax> - <DeviceSaveDataJournalSizeMax>0x0000000000000000</DeviceSaveDataJournalSizeMax> - <TemporaryStorageSize>0x0000000000000000</TemporaryStorageSize> - <CacheStorageSize>0x0000000000000000</CacheStorageSize> - <CacheStorageJournalSize>0x0000000000000000</CacheStorageJournalSize> - <CacheStorageDataAndJournalSizeMax>0x0000000000000000</CacheStorageDataAndJournalSizeMax> - <CacheStorageIndexMax>0x0000000000000000</CacheStorageIndexMax> - <Hdcp>None</Hdcp> - <CrashReport>Deny</CrashReport> - <RuntimeAddOnContentInstall>Deny</RuntimeAddOnContentInstall> - <PlayLogQueryableApplicationId>0x0000000000000000</PlayLogQueryableApplicationId> - <PlayLogQueryCapability>None</PlayLogQueryCapability> - <Repair>None</Repair> - <Attribute>None</Attribute> - <ProgramIndex>0</ProgramIndex> - <RequiredNetworkServiceLicenseOnLaunch>None</RequiredNetworkServiceLicenseOnLaunch> -</Application> diff --git a/Assets/AxiProjectTools/AxiNSPack/hacpack/Tools/hacPackTools-NACP/sample_hbemnu.nacp.xml.meta b/Assets/AxiProjectTools/AxiNSPack/hacpack/Tools/hacPackTools-NACP/sample_hbemnu.nacp.xml.meta deleted file mode 100644 index abd644c..0000000 --- a/Assets/AxiProjectTools/AxiNSPack/hacpack/Tools/hacPackTools-NACP/sample_hbemnu.nacp.xml.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: 42c1295c31de3a948825b9e8e9e8184f -TextScriptImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/README.md b/README.md index 6ff9958..a0e841c 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,32 @@ *���Ľ��������о�����Ϊ�Ϲ�ԭ���IJ��ṩ�κη������кͰ�Ȩ��ص�����SDK���ļ��� +------------ + +Unity Switch ���������ֲ��ص�һϵ�н̳̣�by �������(Sin365) axibug.com +��������� + +������ +*���ºͿ�Դ����ֿ⣬���������о�����Ϊ�Ϲ�ԭ������Ҳ�ṩ�κη������кͰ�Ȩ��ص�����SDK���ļ��� +*�����л�ȡ��������ʹ�ùٷ���Ȩ�Ŀ������� +*л�������κμ�����ģ�����NS��ֲ��Ϸ���������ʵ����������⣬��ֻ�Ǽ��������ߡ�����أ��ѧϰ�� + +���£� + +1.Unity Switch ����/���/��ֲ�̳̣������������Repack NSP,�õ��ĺ�����ۻ����У� +http://note.axibug.com/blog/post/akiragatsu/UnitySwitchDev + +2.Unity��Switch�����ļ��洢�ȿӣ��Լ������������ ��Unity Switch�²�����System.IO,ֻ����nn.fs�� +http://note.axibug.com/blog/post/akiragatsu/UnitySwitchDevForIO + +3.Switchϵͳ�����룬�����Ų����� ����AxiNSApi��Ҳ�ṩ��ת����ӡ�������Ų飩 +http://note.axibug.com/blog/post/akiragatsu/SwitchErrCode + +4.Switch TitleID���� +http://note.axibug.com/blog/post/akiragatsu/SwitchTitleID + + +------------ + ### 1. Nintendo SDK > ����Ҳ����ṩ�κ��ļ������߽�����ʹ�������ùٷ���Ȩ�Ŀ�������Ц��