From 7326a09e6955f74265fe22fee167cf8f3c781068 Mon Sep 17 00:00:00 2001 From: Kurt Date: Fri, 28 Nov 2014 13:18:44 -0800 Subject: [PATCH 1/2] More Fixes --- Misc/Util.cs | 59 ++++++++++++---------- PKHeX.csproj | 1 + PKX/f1-Main.cs | 11 ++++- Properties/Resources.Designer.cs | 82 +++++++++++++------------------ Properties/Resources.resx | 3 ++ Resources/img/item/item_571.png | Bin 0 -> 280 bytes 6 files changed, 81 insertions(+), 75 deletions(-) create mode 100644 Resources/img/item/item_571.png diff --git a/Misc/Util.cs b/Misc/Util.cs index 89afea766..a90b265fc 100644 --- a/Misc/Util.cs +++ b/Misc/Util.cs @@ -123,36 +123,43 @@ internal static string GetBackupLocation() } internal static string GetSDFLocation() { - // start by checking if the 3DS file path exists or not. - string path_SDF = null; - string[] DriveList = Environment.GetLogicalDrives(); - for (int i = 1; i < DriveList.Length; i++) + try { - path_SDF = DriveList[i] + "filer\\UserSaveData\\"; - if (Directory.Exists(path_SDF)) - break; - } - if (path_SDF == null) - return null; - else - { - // 3DS data found in SD card reader. Let's get the title folder location! - string[] folders = Directory.GetDirectories(path_SDF, "*", System.IO.SearchOption.TopDirectoryOnly); - - // Loop through all the folders in the Nintendo 3DS folder to see if any of them contain 'title'. - for (int i = folders.Length - 1; i > 0; i--) + // start by checking if the 3DS file path exists or not. + string path_SDF = null; + string[] DriveList = Environment.GetLogicalDrives(); + for (int i = 1; i < DriveList.Length; i++) { - if (File.Exists(Path.Combine(folders[i], "000011c4\\main"))) return Path.Combine(folders[i], "000011c4"); // OR - if (File.Exists(Path.Combine(folders[i], "000011c5\\main"))) return Path.Combine(folders[i], "000011c5"); // AS - if (File.Exists(Path.Combine(folders[i], "0000055d\\main"))) return Path.Combine(folders[i], "0000055d"); // X - if (File.Exists(Path.Combine(folders[i], "0000055e\\main"))) return Path.Combine(folders[i], "0000055e"); // Y - - // I don't know - if (File.Exists(Path.Combine(folders[i], "00055d00\\main"))) return Path.Combine(folders[i], "00055d00"); // X - if (File.Exists(Path.Combine(folders[i], "00055e00\\main"))) return Path.Combine(folders[i], "00055e00"); // Y + string potentialPath_SDF = Path.Combine(DriveList[i], "filer\\UserSaveData\\"); + if (Directory.Exists(potentialPath_SDF)) + { + path_SDF = potentialPath_SDF; + break; + } + } + if (path_SDF == null) + return null; + else + { + // 3DS data found in SD card reader. Let's get the title folder location! + string[] folders = Directory.GetDirectories(path_SDF, "*", System.IO.SearchOption.TopDirectoryOnly); + + // Loop through all the folders in the Nintendo 3DS folder to see if any of them contain 'title'. + for (int i = folders.Length - 1; i > 0; i--) + { + if (File.Exists(Path.Combine(folders[i], "000011c4\\main"))) return Path.Combine(folders[i], "000011c4"); // OR + if (File.Exists(Path.Combine(folders[i], "000011c5\\main"))) return Path.Combine(folders[i], "000011c5"); // AS + if (File.Exists(Path.Combine(folders[i], "0000055d\\main"))) return Path.Combine(folders[i], "0000055d"); // X + if (File.Exists(Path.Combine(folders[i], "0000055e\\main"))) return Path.Combine(folders[i], "0000055e"); // Y + + // I don't know + if (File.Exists(Path.Combine(folders[i], "00055d00\\main"))) return Path.Combine(folders[i], "00055d00"); // X + if (File.Exists(Path.Combine(folders[i], "00055e00\\main"))) return Path.Combine(folders[i], "00055e00"); // Y + } + return null; } - return null; } + catch { return null; } } internal static string CleanFileName(string fileName) { diff --git a/PKHeX.csproj b/PKHeX.csproj index 649553664..24beac3e4 100644 --- a/PKHeX.csproj +++ b/PKHeX.csproj @@ -328,6 +328,7 @@ + diff --git a/PKX/f1-Main.cs b/PKX/f1-Main.cs index 88839f280..3290bf9ab 100644 --- a/PKX/f1-Main.cs +++ b/PKX/f1-Main.cs @@ -3605,15 +3605,24 @@ private void updateAbilityNumber() private void mainmenuOpen(object sender, EventArgs e) { string cyberpath = Util.GetTempFolder(); - if (Directory.Exists(cyberpath + "\\root\\")) + SDFLoc = Util.GetSDFLocation(); + if (SDFLoc != null) + { + OpenPKX.InitialDirectory = SDFLoc; + OpenPKX.RestoreDirectory = true; + OpenPKX.FilterIndex = 4; + } + else if (Directory.Exists(cyberpath + "\\root\\")) { OpenPKX.InitialDirectory = cyberpath + "\\root\\"; OpenPKX.RestoreDirectory = true; + OpenPKX.FilterIndex = 4; } else if (Directory.Exists(cyberpath)) { OpenPKX.InitialDirectory = cyberpath; OpenPKX.RestoreDirectory = true; + OpenPKX.FilterIndex = 4; } DialogResult result = OpenPKX.ShowDialog(); diff --git a/Properties/Resources.Designer.cs b/Properties/Resources.Designer.cs index ff8f2f95b..97ce5ea9d 100644 --- a/Properties/Resources.Designer.cs +++ b/Properties/Resources.Designer.cs @@ -13319,6 +13319,16 @@ internal class Resources { } } + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap item_571 { + get { + object obj = ResourceManager.GetObject("item_571", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + /// /// Looks up a localized resource of type System.Drawing.Bitmap. /// @@ -21309,8 +21319,7 @@ internal class Resources { ///Medizin ///TM & VM ///Beeren - ///Basis-Items - ///. + ///Basis-Items. /// internal static string text_ItemPouch_de { get { @@ -21323,8 +21332,7 @@ internal class Resources { ///MEDICINE ///TMs & HMs ///BERRIES - ///KEY ITEMS - ///. + ///KEY ITEMS. /// internal static string text_ItemPouch_en { get { @@ -21337,8 +21345,7 @@ internal class Resources { ///Botiquín ///MT/MO ///Bayas - ///Objetos Clave - ///. + ///Objetos Clave. /// internal static string text_ItemPouch_es { get { @@ -21351,8 +21358,7 @@ internal class Resources { ///PV/PP ///CT & CS ///BAIES - ///OBJETS RARES - ///. + ///OBJETS RARES. /// internal static string text_ItemPouch_fr { get { @@ -21365,8 +21371,7 @@ internal class Resources { ///Rimedi ///MT e MN ///Bacche - ///Strumenti Base - ///. + ///Strumenti Base. /// internal static string text_ItemPouch_it { get { @@ -21379,8 +21384,7 @@ internal class Resources { ///かいふく ///わざマシン ///きのみ - ///たいせつなもの - ///. + ///たいせつなもの. /// internal static string text_ItemPouch_ja { get { @@ -21393,8 +21397,7 @@ internal class Resources { ///회복 ///기술머신 ///나무열매 - ///중요한 물건 - ///. + ///중요한 물건. /// internal static string text_ItemPouch_ko { get { @@ -22897,8 +22900,7 @@ internal class Resources { ///Frühlingsdeko-Pofflé ///Sommerdeko-Pofflé ///Herbstdeko-Pofflé - ///Winterdeko-Pofflé - ///. + ///Winterdeko-Pofflé. /// internal static string text_Puff_de { get { @@ -23059,8 +23061,7 @@ internal class Resources { ///フルデコはるポフレ ///フルデコなつポフレ ///フルデコあきポフレ - ///フルデコふゆポフレ - ///. + ///フルデコふゆポフレ. /// internal static string text_Puff_ja { get { @@ -23094,8 +23095,7 @@ internal class Resources { ///풀데코봄포플레 ///풀데코여름포플레 ///풀데코가을포플레 - ///풀데코겨울포플레 - ///. + ///풀데코겨울포플레. /// internal static string text_Puff_ko { get { @@ -23924,8 +23924,7 @@ internal class Resources { ///Dopplungs-Sack ///Flare-Sack ///Tabula Ra-Sack - ///Relax-Sack - ///. + ///Relax-Sack. /// internal static string text_TrainingBag_de { get { @@ -23960,8 +23959,7 @@ internal class Resources { ///Double-Up Bag ///Team Flare Bag ///Reset Bag - ///Soothing Bag - ///. + ///Soothing Bag. /// internal static string text_TrainingBag_en { get { @@ -23996,8 +23994,7 @@ internal class Resources { ///Saco Mejora x2 ///Saco Team Flare ///Saco Reinicio - ///Saco Relax - ///. + ///Saco Relax. /// internal static string text_TrainingBag_es { get { @@ -24032,8 +24029,7 @@ internal class Resources { ///Sac Gain↑ ///Sac Team Flare ///Sac Renouveau - ///Sac Relax - ///. + ///Sac Relax. /// internal static string text_TrainingBag_fr { get { @@ -24068,8 +24064,7 @@ internal class Resources { ///Sacco Raddoppio ///Sacco Team Flare ///Sacco Ripristino - ///Sacco Relax - ///. + ///Sacco Relax. /// internal static string text_TrainingBag_it { get { @@ -24104,8 +24099,7 @@ internal class Resources { ///ダブルUPバッグ ///フレアだんバッグ ///まっさらバッグ - ///リラックスバッグ - ///. + ///リラックスバッグ. /// internal static string text_TrainingBag_ja { get { @@ -24140,8 +24134,7 @@ internal class Resources { ///더블UP백 ///플레어단백 ///신품백 - ///릴랙스백 - ///. + ///릴랙스백. /// internal static string text_TrainingBag_ko { get { @@ -25098,8 +25091,7 @@ internal class Resources { ///---------- ///Einall-Region ///Kalos-Region - ///Pokémon-Link - ///. + ///Pokémon-Link. /// internal static string text_xy_30000_de { get { @@ -25118,8 +25110,7 @@ internal class Resources { ///---------- ///the Unova region ///the Kalos region - ///Pokémon Link - ///. + ///Pokémon Link. /// internal static string text_xy_30000_en { get { @@ -25138,8 +25129,7 @@ internal class Resources { ///---------- ///Teselia ///Kalos - ///Nexo Pokémon - ///. + ///Nexo Pokémon. /// internal static string text_xy_30000_es { get { @@ -25158,8 +25148,7 @@ internal class Resources { ///---------- ///Unys ///Kalos - ///Poké Lien - ///. + ///Poké Lien. /// internal static string text_xy_30000_fr { get { @@ -25178,8 +25167,7 @@ internal class Resources { ///---------- ///Unima ///Kalos - ///Pokémon Link - ///. + ///Pokémon Link. /// internal static string text_xy_30000_it { get { @@ -25198,8 +25186,7 @@ internal class Resources { ///---------- ///イッシュちほう ///カロスちほう - ///ポケモンリンク - ///. + ///ポケモンリンク. /// internal static string text_xy_30000_ja { get { @@ -25218,8 +25205,7 @@ internal class Resources { ///---------- ///하나지방 ///칼로스지방 - ///포켓몬링크 - ///. + ///포켓몬링크. /// internal static string text_xy_30000_ko { get { diff --git a/Properties/Resources.resx b/Properties/Resources.resx index f10c58cd6..eba8bbcb6 100644 --- a/Properties/Resources.resx +++ b/Properties/Resources.resx @@ -5146,4 +5146,7 @@ ..\Resources\img\badges\badge_08.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\img\item\item_571.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + \ No newline at end of file diff --git a/Resources/img/item/item_571.png b/Resources/img/item/item_571.png new file mode 100644 index 0000000000000000000000000000000000000000..d32b2388060f248cc0148cb180fd0dfa1a518c76 GIT binary patch literal 280 zcmeAS@N?(olHy`uVBq!ia0vp^d?3uh1|;P@bT0xa#^NA%Cx&(BWL^R}Ea{HEjtmSN z`?>!lvI6;>1s;*bKn;gMnDKc2iWH!rREcXuNpOBzNqJ&XDnmeGW?qS&pKFLhnX#U! zo}q!km!gG0RqdWGjv*HQQzz}_Z7|?***xia3agh_*g_x~W*~D(QTR`zMxfI3xN}{1 zqYPbK-md!6`zSTs_W9NVH=CA1%XPPPw=e01*U SwQ``77(8A5T-G@yGywqgrDBi( literal 0 HcmV?d00001 From 3edab91b498cc0f5fdd60a38a37b27294540b21a Mon Sep 17 00:00:00 2001 From: Kurt Date: Fri, 28 Nov 2014 13:34:51 -0800 Subject: [PATCH 2/2] Adding Opening Partially Decrypted ORAS Powersaves No saving support, obviously. Untested, but should work as the offset loading is static while the offsets read from within the program to read data are all determined by GameType. --- PKX/f1-Main.cs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/PKX/f1-Main.cs b/PKX/f1-Main.cs index 3290bf9ab..9c7ec3b56 100644 --- a/PKX/f1-Main.cs +++ b/PKX/f1-Main.cs @@ -3758,6 +3758,13 @@ private void openQuick(string path) } private void openFile(byte[] input, string path, string ext) { + #region Powersaves Read-Only Conversion + if (input.Length == 0x10009C) + { + Array.Copy(input, 0x9C, input, 0, 0x100000); + Array.Resize(ref input, 0x100000); + } + #endregion #region Trade Packets if ((input.Length == 363) && (input[0x6B] == 0) && (input[0x6C] == 00)) { @@ -3785,6 +3792,8 @@ private void openFile(byte[] input, string path, string ext) B_ExportSAV.Enabled = false; B_SwitchSAV.Enabled = false; B_JPEG.Enabled = false; + string GameType = "XY"; // Default Game Type to load. + if (BitConverter.ToUInt32(input, 0x7B210) == 0x42454546) GameType = "ORAS"; // BEEF magic in checksum block if ((BitConverter.ToUInt32(input, 0x100) != 0x41534944) && (BitConverter.ToUInt32(input, 0x5234) != 0x6E69616D)) { DialogResult dialogResult = MessageBox.Show("Save file is not decrypted.\r\n\r\nPress Yes to ignore this warning and continue loading the save file.", "Error", MessageBoxButtons.YesNo); @@ -3800,7 +3809,7 @@ private void openFile(byte[] input, string path, string ext) } else savindex = 1; B_SwitchSAV.Enabled = true; - open1MB(input, path, "XY", false); + open1MB(input, path, GameType, false); } } else if (PKX.detectSAVIndex(input, ref savindex) == 2) @@ -3821,7 +3830,7 @@ private void openFile(byte[] input, string path, string ext) } else savindex = 1; B_SwitchSAV.Enabled = true; - open1MB(input, path, "XY", false); + open1MB(input, path, GameType, false); } } else @@ -3829,7 +3838,7 @@ private void openFile(byte[] input, string path, string ext) B_ExportSAV.Enabled = true; B_SwitchSAV.Enabled = true; PKX.detectSAVIndex(input, ref savindex); - open1MB(input, path, "XY", false); + open1MB(input, path, GameType, false); } B_JPEG.Enabled = true; }