Path manager - fix so that paths use their platform base (if there is one), then the global base, then the exe path

This commit is contained in:
andres.delikat 2011-05-07 02:54:09 +00:00
parent b53b9f7a42
commit 0a1dc8c06e
2 changed files with 30 additions and 3 deletions

View File

@ -143,7 +143,8 @@ namespace BizHawk.MultiClient
{
FolderBrowserDialog f = new FolderBrowserDialog();
f.Description = "Set the directory for " + Name;
f.SelectedPath = PathManager.MakeAbsolutePath(box.Text);
//TODO: figure out how to send system parameter
f.SelectedPath = PathManager.MakeAbsolutePath(box.Text, "");
DialogResult result = f.ShowDialog();
if (result == DialogResult.OK)
box.Text = f.SelectedPath;

View File

@ -50,8 +50,31 @@ namespace BizHawk.MultiClient
return GetExePathAbsolute();
}
public static string GetPlatformBase(string system)
{
switch (system)
{
case "NES":
return Global.Config.BaseNES;
case "SG":
case "GG":
case "SMS":
return Global.Config.BaseSMS;
case "SGX":
case "PCE":
return Global.Config.BasePCE;
case "TI83":
return Global.Config.BaseTI83;
case "GEN":
return Global.Config.BaseGenesis;
case "GB":
return Global.Config.BaseGameboy;
default:
return "";
}
}
public static string MakeAbsolutePath(string path)
public static string MakeAbsolutePath(string path, string system)
{
//This function translates relative path and special identifiers in absolute paths
@ -77,11 +100,14 @@ namespace BizHawk.MultiClient
if (path[0] == '.')
{
string tmp = path;
tmp = tmp.Remove(0, 1);
tmp = tmp.Insert(0, GetPlatformBase(system));
if (path.Length == 1)
return GetBasePathAbsolute();
else
{
string tmp = path.Remove(0, 1);
tmp = path.Remove(0, 1);
tmp = tmp.Insert(0, GetBasePathAbsolute());
return tmp;
}