mirror of
https://github.com/kwsch/PKHeX
synced 2025-02-16 21:38:40 +00:00
Merge remote-tracking branch 'upstream/master'
This commit is contained in:
commit
e819be16a9
3 changed files with 75 additions and 4 deletions
41
Misc/Util.cs
41
Misc/Util.cs
|
@ -73,7 +73,13 @@ namespace PKHeX
|
|||
B = 255;
|
||||
return Color.FromArgb(Math.Abs(A), Math.Abs(R), Math.Abs(G), Math.Abs(B));
|
||||
}
|
||||
|
||||
internal static FileInfo GetNewestFile(DirectoryInfo directory)
|
||||
{
|
||||
return directory.GetFiles()
|
||||
.Union(directory.GetDirectories().Select(d => GetNewestFile(d)))
|
||||
.OrderByDescending(f => (f == null ? DateTime.MinValue : f.LastWriteTime))
|
||||
.FirstOrDefault();
|
||||
}
|
||||
internal static string GetTempFolder() // From 3DSSE's decompiled source.
|
||||
{
|
||||
string tempPath = Path.GetTempPath();
|
||||
|
@ -116,6 +122,39 @@ namespace PKHeX
|
|||
Directory.CreateDirectory(path);
|
||||
return path;
|
||||
}
|
||||
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++)
|
||||
{
|
||||
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--)
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
internal static string CleanFileName(string fileName)
|
||||
{
|
||||
return Path.GetInvalidFileNameChars().Aggregate(fileName, (current, c) => current.Replace(c.ToString(), string.Empty));
|
||||
|
|
1
PKX/f1-Main.Designer.cs
generated
1
PKX/f1-Main.Designer.cs
generated
|
@ -2715,6 +2715,7 @@
|
|||
this.L_Save.Size = new System.Drawing.Size(54, 13);
|
||||
this.L_Save.TabIndex = 4;
|
||||
this.L_Save.Text = "SAV: N/A";
|
||||
this.L_Save.Click += new System.EventHandler(this.L_Save_Click);
|
||||
//
|
||||
// tabBoxMulti
|
||||
//
|
||||
|
|
|
@ -169,10 +169,13 @@ namespace PKHeX
|
|||
CB_PPu1.SelectedIndex = CB_PPu2.SelectedIndex = CB_PPu3.SelectedIndex = CB_PPu4.SelectedIndex = 0;
|
||||
CB_Ball.SelectedIndex = 0;
|
||||
|
||||
// Load the command line arguments
|
||||
// Load the arguments
|
||||
string[] args = Environment.GetCommandLineArgs();
|
||||
SDFLoc = Util.GetSDFLocation();
|
||||
if (args.Length > 1)
|
||||
openQuick(args[1]);
|
||||
openQuick(args[1]);
|
||||
else if (SDFLoc != null)
|
||||
openQuick(Path.Combine(SDFLoc,"main"));
|
||||
else if (File.Exists(Util.GetTempFolder() + "\\root\\main"))
|
||||
openQuick(Util.GetTempFolder() + "\\root\\main");
|
||||
|
||||
|
@ -201,6 +204,7 @@ namespace PKHeX
|
|||
public int genderflag, species;
|
||||
public int savindex;
|
||||
public bool savedited;
|
||||
public string SDFLoc = null;
|
||||
public bool HaX = false;
|
||||
|
||||
public static int colorizedbox = 32;
|
||||
|
@ -3957,6 +3961,7 @@ namespace PKHeX
|
|||
B_OpenSecretBase.Visible = oras;
|
||||
|
||||
this.Width = largeWidth;
|
||||
System.Media.SystemSounds.Beep.Play();
|
||||
}
|
||||
// Secondary Windows for Ribbons/Amie/Memories
|
||||
private void openribbons(object sender, EventArgs e)
|
||||
|
@ -4951,7 +4956,15 @@ namespace PKHeX
|
|||
|
||||
// Try for file path
|
||||
string cyberpath = Util.GetTempFolder();
|
||||
if (Directory.Exists(cyberpath + "\\root\\"))
|
||||
if (SDFLoc != null)
|
||||
{
|
||||
if (Directory.Exists(SDFLoc))
|
||||
{
|
||||
cySAV.InitialDirectory = SDFLoc;
|
||||
cySAV.RestoreDirectory = true;
|
||||
}
|
||||
}
|
||||
else if (Directory.Exists(cyberpath + "\\root\\"))
|
||||
{
|
||||
cySAV.InitialDirectory = cyberpath + "\\root\\";
|
||||
cySAV.RestoreDirectory = true;
|
||||
|
@ -6371,6 +6384,24 @@ namespace PKHeX
|
|||
}
|
||||
private byte[] pkm_from = new Byte[0xE8];
|
||||
private int pkm_from_offset;
|
||||
private void L_Save_Click(object sender, EventArgs e)
|
||||
{
|
||||
// Get latest SaveDataFiler save location
|
||||
SDFLoc = Util.GetSDFLocation();
|
||||
string path = null;
|
||||
|
||||
if (SDFLoc != null && ModifierKeys != Keys.Control) // if we have a result
|
||||
path = Path.Combine(SDFLoc, "main");
|
||||
else if (File.Exists(Util.GetTempFolder() + "\\root\\main")) // else if cgse exists
|
||||
path = Util.GetTempFolder() + "\\root\\main";
|
||||
|
||||
if (path != null)
|
||||
{
|
||||
DialogResult sdr = MessageBox.Show("Open save file from the following location?\n\n"+path, "Prompt", MessageBoxButtons.YesNo);
|
||||
if (sdr == DialogResult.Cancel)
|
||||
openQuick(path); // load save
|
||||
}
|
||||
}
|
||||
}
|
||||
#region Structs & Classes
|
||||
public class cbItem
|
||||
|
|
Loading…
Add table
Reference in a new issue