Rip out old path system and replace with new

This commit is contained in:
adelikat 2013-08-11 21:48:17 +00:00
parent e2aeab5ad2
commit 625f9c2fcd
24 changed files with 173 additions and 422 deletions

View File

@ -215,12 +215,6 @@
<Compile Include="config\NewHotkeyWindow.Designer.cs">
<DependentUpon>NewHotkeyWindow.cs</DependentUpon>
</Compile>
<Compile Include="config\PathConfig.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="config\PathConfig.Designer.cs">
<DependentUpon>PathConfig.cs</DependentUpon>
</Compile>
<Compile Include="config\PathInfo.cs">
<SubType>Form</SubType>
</Compile>
@ -942,9 +936,6 @@
<DependentUpon>MessageConfig.cs</DependentUpon>
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="config\PathConfig.resx">
<DependentUpon>PathConfig.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="config\SoundConfig.resx">
<DependentUpon>SoundConfig.cs</DependentUpon>
<SubType>Designer</SubType>

View File

@ -18,149 +18,9 @@ namespace BizHawk.MultiClient
PathEntries.ResolveWithDefaults();
}
public string BaseINTV = Path.Combine(".", "Intellivision");
public string PathINTVROMs = ".";
public string PathINTVSavestates = Path.Combine(".", "State");
public string PathINTVSaveRAM = Path.Combine(".", "SaveRAM");
public string PathINTVScreenshots = Path.Combine(".", "Screenshots");
public string PathINTVCheats = Path.Combine(".", "Cheats");
public string BaseNES = Path.Combine(".", "NES");
public string PathNESROMs = ".";
public string PathNESSavestates = Path.Combine(".", "State");
public string PathNESSaveRAM = Path.Combine(".", "SaveRAM");
public string PathNESScreenshots = Path.Combine(".", "Screenshots");
public string PathNESCheats = Path.Combine(".", "Cheats");
public string PathNESPalette = Path.Combine(".", "Palettes");
public string BaseSNES = Path.Combine(".", "SNES");
public string PathSNESROMs = ".";
public string PathSNESSavestates = Path.Combine(".", "State");
public string PathSNESSaveRAM = Path.Combine(".", "SaveRAM");
public string PathSNESScreenshots = Path.Combine(".", "Screenshots");
public string PathSNESCheats = Path.Combine(".", "Cheats");
//public string PathSNESFirmwares = Path.Combine(".", "Firmwares");
public string BaseGBA = Path.Combine(".", "GBA");
public string PathGBAROMs = ".";
public string PathGBASavestates = Path.Combine(".", "State");
public string PathGBASaveRAM = Path.Combine(".", "SaveRAM");
public string PathGBAScreenshots = Path.Combine(".", "Screenshots");
public string PathGBACheats = Path.Combine(".", "Cheats");
public string BaseSMS = Path.Combine(".", "SMS");
public string PathSMSROMs = ".";
public string PathSMSSavestates = Path.Combine(".", "State");
public string PathSMSSaveRAM = Path.Combine(".", "SaveRAM");
public string PathSMSScreenshots = Path.Combine(".", "Screenshots");
public string PathSMSCheats = Path.Combine(".", "Cheats");
public string BaseGG = Path.Combine(".", "Game Gear");
public string PathGGROMs = ".";
public string PathGGSavestates = Path.Combine(".", "State");
public string PathGGSaveRAM = Path.Combine(".", "SaveRAM");
public string PathGGScreenshots = Path.Combine(".", "Screenshots");
public string PathGGCheats = Path.Combine(".", "Cheats");
public string BaseSG = Path.Combine(".", "SG-1000");
public string PathSGROMs = ".";
public string PathSGSavestates = Path.Combine(".", "State");
public string PathSGSaveRAM = Path.Combine(".", "SaveRAM");
public string PathSGScreenshots = Path.Combine(".", "Screenshots");
public string PathSGCheats = Path.Combine(".", "Cheats");
public string BaseGenesis = Path.Combine(".", "Genesis");
public string PathGenesisROMs = ".";
public string PathGenesisSavestates = Path.Combine(".", "State");
public string PathGenesisSaveRAM = Path.Combine(".", "SaveRAM");
public string PathGenesisScreenshots = Path.Combine(".", "Screenshots");
public string PathGenesisCheats = Path.Combine(".", "Cheats");
public string BasePCE = Path.Combine(".", "PC Engine");
public string PathPCEROMs = ".";
public string PathPCESavestates = Path.Combine(".", "State");
public string PathPCESaveRAM = Path.Combine(".", "SaveRAM");
public string PathPCEScreenshots = Path.Combine(".", "Screenshots");
public string PathPCECheats = Path.Combine(".", "Cheats");
public string BaseGameboy = Path.Combine(".", "Gameboy");
public string PathGBROMs = ".";
public string PathGBSavestates = Path.Combine(".", "State");
public string PathGBSaveRAM = Path.Combine(".", "SaveRAM");
public string PathGBScreenshots = Path.Combine(".", "Screenshots");
public string PathGBCheats = Path.Combine(".", "Cheats");
public string PathGBPalettes = Path.Combine(".", "Palettes");
public string BaseTI83 = Path.Combine(".", "TI83");
public string PathTI83ROMs = ".";
public string PathTI83Savestates = Path.Combine(".", "State");
public string PathTI83SaveRAM = Path.Combine(".", "SaveRAM");
public string PathTI83Screenshots = Path.Combine(".", "Screenshots");
public string PathTI83Cheats = Path.Combine(".", "Cheats");
public string BaseAtari2600 = Path.Combine(".", "Atari 2600");
public string PathAtari2600ROMs = ".";
public string PathAtari2600Savestates = Path.Combine(".", "State");
public string PathAtari2600Screenshots = Path.Combine(".", "Screenshots");
public string PathAtari2600Cheats = Path.Combine(".", "Cheats");
public string BaseAtari7800 = Path.Combine(".", "Atari 7800");
public string PathAtari7800ROMs = ".";
public string PathAtari7800Savestates = Path.Combine(".", "State");
public string PathAtari7800SaveRAM = Path.Combine(".", "SaveRAM");
public string PathAtari7800Screenshots = Path.Combine(".", "Screenshots");
public string PathAtari7800Cheats = Path.Combine(".", "Cheats");
//public string PathAtari7800Firmwares = Path.Combine(".", "Firmwares");
public string BaseC64 = Path.Combine(".", "C64");
public string PathC64ROMs = ".";
public string PathC64Savestates = Path.Combine(".", "State");
public string PathC64Screenshots = Path.Combine(".", "Screenshots");
public string PathC64Cheats = Path.Combine(".", "Cheats");
//public string PathC64Firmwares = Path.Combine(".", "Firmwares");
public string BasePSX = Path.Combine(".", "PSX");
public string PathPSXROMs = ".";
public string PathPSXSavestates = Path.Combine(".", "State");
public string PathPSXSaveRAM = Path.Combine(".", "SaveRAM");
public string PathPSXScreenshots = Path.Combine(".", "Screenshots");
public string PathPSXCheats = Path.Combine(".", "Cheats");
//public string PathPSXFirmwares = Path.Combine(".", "Firmwares");
public string BaseCOL = Path.Combine(".", "Coleco");
public string PathCOLROMs = ".";
public string PathCOLSavestates = Path.Combine(".", "State");
public string PathCOLScreenshots = Path.Combine(".", "Screenshots");
public string PathCOLCheats = Path.Combine(".", "Cheats");
public string BaseN64 = Path.Combine(".", "N64");
public string PathN64ROMs = ".";
public string PathN64Savestates = Path.Combine(".", "State");
public string PathN64SaveRAM = Path.Combine(".", "SaveRAM");
public string PathN64Screenshots = Path.Combine(".", "Screenshots");
public string PathN64Cheats = Path.Combine(".", "Cheats");
public string BaseSaturn = Path.Combine(".", "Saturn");
public string PathSaturnROMs = ".";
public string PathSaturnSavestates = Path.Combine(".", "State");
public string PathSaturnSaveRAM = Path.Combine(".", "SaveRAM");
public string PathSaturnScreenshots = Path.Combine(".", "Screenshots");
public string PathSaturnCheats = Path.Combine(".", "Cheats");
public string MoviesPath = Path.Combine(".", "Movies");
public string MoviesBackupPath = Path.Combine(".", "Movies", "backup");
public string LuaPath = Path.Combine(".", "Lua");
public string WatchPath = ".";
public string AVIPath = ".";
public string LogPath = ".";
public string FirmwaresPath = Path.Combine(".", "Firmware");
//Path Settings ************************************/
public bool UseRecentForROMs = false;
public string LastRomPath = ".";
public string BasePath = ".";
public string BaseROMPath = ".";
public PathEntryCollection PathEntries = new PathEntryCollection();
//BIOS Paths
@ -913,7 +773,7 @@ namespace BizHawk.MultiClient
{
get
{
return Paths.FirstOrDefault(x => x.System == system && x.Type == type) ?? new PathEntry();
return Paths.FirstOrDefault(x => x.System == system && x.Type == type);
}
}
@ -947,6 +807,15 @@ namespace BizHawk.MultiClient
}
}
//Some frequently requested paths, made into a property for convenience
public string WatchPath { get { return Global.Config.PathEntries["Global", "Watch (.wch)"].Path; } }
public string MoviesPath { get { return Global.Config.PathEntries["Global", "Movies"].Path; } }
public string LuaPath { get { return Global.Config.PathEntries["Global", "Lua"].Path; } }
public string LogPath { get { return Global.Config.PathEntries["Global", "Debug Logs"].Path; } }
public string FirmwaresPath { get { return Global.Config.PathEntries["Global", "Firmware"].Path; } }
public string AVPath { get { return Global.Config.PathEntries["Global", "A/V Dumps"].Path; } }
public string GlobalBase { get { return Global.Config.PathEntries["Global", "Base"].Path; } }
public static List<PathEntry> DefaultValues
{
get
@ -961,6 +830,7 @@ namespace BizHawk.MultiClient
new PathEntry() { System = "Global", Type = "Debug Logs", Path = ".", Ordinal = 5 },
new PathEntry() { System = "Global", Type = "Firmware", Path = Path.Combine(".", "Firmware"), Ordinal = 6 },
new PathEntry() { System = "Global", Type = "Base ROM", Path = ".", Ordinal = 6 },
new PathEntry() { System = "Global", Type = "Base", Path = ".", Ordinal = 6 },
new PathEntry() { System = "INTV", Type = "Base", Path = Path.Combine(".", "Intellivision"), Ordinal = 0 },
new PathEntry() { System = "INTV", Type = "ROM", Path = ".", Ordinal = 1 },

View File

@ -87,7 +87,7 @@ namespace BizHawk.MultiClient
RealFirmwareReader reader = new RealFirmwareReader();
//build a list of files under the global firmwares path, and build a hash for each of them while we're at it
var todo = new Queue<DirectoryInfo>(new[] { new DirectoryInfo(Global.Config.FirmwaresPath) });
var todo = new Queue<DirectoryInfo>(new[] { new DirectoryInfo(Global.Config.PathEntries.FirmwaresPath) });
while (todo.Count != 0)
{

View File

@ -316,7 +316,7 @@ namespace BizHawk.MultiClient.GBtools
{
using (var ofd = new OpenFileDialog())
{
ofd.InitialDirectory = PathManager.MakeAbsolutePath(Global.Config.PathGBPalettes, "GB");
ofd.InitialDirectory = PathManager.MakeAbsolutePath(Global.Config.PathEntries["GB", "Palettes"].Path, "GB");
ofd.Filter = "Gambatte Palettes (*.pal)|*.pal|All Files|*.*";
ofd.RestoreDirectory = true;
@ -361,7 +361,7 @@ namespace BizHawk.MultiClient.GBtools
}
else
{
sfd.InitialDirectory = PathManager.MakeAbsolutePath(Global.Config.PathGBPalettes, "GB");
sfd.InitialDirectory = PathManager.MakeAbsolutePath(Global.Config.PathEntries["GB", "Palettes"].Path, "GB");
sfd.FileName = Global.Game.Name + ".pal";
}
sfd.Filter = "Gambatte Palettes (*.pal)|*.pal|All Files|*.*";

View File

@ -60,7 +60,7 @@ namespace BizHawk.MultiClient.GBtools
{
using (var ofd = new OpenFileDialog())
{
ofd.InitialDirectory = PathManager.MakeAbsolutePath(Global.Config.PathGBROMs, "GB");
ofd.InitialDirectory = PathManager.MakeAbsolutePath(Global.Config.PathEntries["GB", "Palettes"].Path, "GB");
ofd.Filter = "GB Roms (*.gb,*.gbc)|*.gb;*.gbc|All Files|*.*";
ofd.RestoreDirectory = true;
var result = ofd.ShowDialog(this);

View File

@ -700,14 +700,7 @@ namespace BizHawk.MultiClient
private void pathsToolStripMenuItem_Click(object sender, EventArgs e)
{
if (INTERIM)
{
new NewPathConfig().ShowDialog();
}
else
{
new PathConfig().ShowDialog();
}
new NewPathConfig().ShowDialog();
}
private void displayRerecordCountToolStripMenuItem_Click(object sender, EventArgs e)
@ -2393,7 +2386,7 @@ namespace BizHawk.MultiClient
private void pathsToolStripMenuItem1_Click(object sender, EventArgs e)
{
new PathConfig().ShowDialog();
new NewPathConfig().ShowDialog();
}
private void soundToolStripMenuItem1_Click(object sender, EventArgs e)

View File

@ -455,11 +455,11 @@ namespace BizHawk.MultiClient
target.SMS_ShowBG = Global.Config.SMSDispBG;
target.SMS_ShowOBJ = Global.Config.SMSDispOBJ;
target.PSX_FirmwaresPath = PathManager.MakeAbsolutePath(Global.Config.FirmwaresPath); // PathManager.MakeAbsolutePath(Global.Config.PathPSXFirmwares, "PSX");
target.PSX_FirmwaresPath = PathManager.MakeAbsolutePath(Global.Config.PathEntries.FirmwaresPath); // PathManager.MakeAbsolutePath(Global.Config.PathPSXFirmwares, "PSX");
target.C64_FirmwaresPath = PathManager.MakeAbsolutePath(Global.Config.FirmwaresPath); // PathManager.MakeAbsolutePath(Global.Config.PathC64Firmwares, "C64");
target.C64_FirmwaresPath = PathManager.MakeAbsolutePath(Global.Config.PathEntries.FirmwaresPath); // PathManager.MakeAbsolutePath(Global.Config.PathC64Firmwares, "C64");
target.SNES_FirmwaresPath = PathManager.MakeAbsolutePath(Global.Config.FirmwaresPath); // PathManager.MakeAbsolutePath(Global.Config.PathSNESFirmwares, "SNES");
target.SNES_FirmwaresPath = PathManager.MakeAbsolutePath(Global.Config.PathEntries.FirmwaresPath); // PathManager.MakeAbsolutePath(Global.Config.PathSNESFirmwares, "SNES");
target.SNES_ShowBG1_0 = Global.Config.SNES_ShowBG1_0;
target.SNES_ShowBG1_1 = Global.Config.SNES_ShowBG1_1;
target.SNES_ShowBG2_0 = Global.Config.SNES_ShowBG2_0;
@ -3618,12 +3618,12 @@ namespace BizHawk.MultiClient
if (!(Global.Emulator is NullEmulator))
{
sfd.FileName = PathManager.FilesystemSafeName(Global.Game);
sfd.InitialDirectory = PathManager.MakeAbsolutePath(Global.Config.AVIPath);
sfd.InitialDirectory = PathManager.MakeAbsolutePath(Global.Config.PathEntries.AVPath);
}
else
{
sfd.FileName = "NULL";
sfd.InitialDirectory = PathManager.MakeAbsolutePath(Global.Config.AVIPath);
sfd.InitialDirectory = PathManager.MakeAbsolutePath(Global.Config.PathEntries.AVPath);
}
sfd.Filter = String.Format("{0} (*.{0})|*.{0}|All Files|*.*", aw.DesiredExtension());
@ -3819,7 +3819,7 @@ namespace BizHawk.MultiClient
void ProcessMovieImport(string fn)
{
string d = PathManager.MakeAbsolutePath(Global.Config.MoviesPath);
string d = PathManager.MakeAbsolutePath(Global.Config.PathEntries.MoviesPath);
string errorMsg;
string warningMsg;
Movie m = MovieImport.ImportFile(fn, out errorMsg, out warningMsg);

View File

@ -47,7 +47,7 @@ namespace BizHawk.MultiClient
{
OpenFileDialog ofd = new OpenFileDialog
{
InitialDirectory = PathManager.MakeAbsolutePath(Global.Config.PathNESPalette, "NES"),
InitialDirectory = PathManager.MakeAbsolutePath(Global.Config.PathEntries["NES", "Palettes"].Path, "NES"),
Filter = "Palette Files (.pal)|*.PAL|All Files (*.*)|*.*",
RestoreDirectory = true
};

View File

@ -69,7 +69,7 @@ namespace BizHawk.MultiClient
var sfd = new SaveFileDialog
{
FileName = PathManager.FilesystemSafeName(Global.Game) + "-Nametables",
InitialDirectory = PathManager.MakeAbsolutePath(Global.Config.PathNESScreenshots, "NES"),
InitialDirectory = PathManager.MakeAbsolutePath(Global.Config.PathEntries["NES", "Screenshots"].Path, "NES"),
Filter = "PNG (*.png)|*.png|Bitmap (*.bmp)|*.bmp|All Files|*.*",
RestoreDirectory = true
};

View File

@ -76,7 +76,7 @@ namespace BizHawk.MultiClient
var sfd = new SaveFileDialog
{
FileName = PathManager.FilesystemSafeName(Global.Game) + "-Palettes",
InitialDirectory = PathManager.MakeAbsolutePath(Global.Config.PathNESScreenshots, "NES"),
InitialDirectory = PathManager.MakeAbsolutePath(Global.Config.PathEntries["NES", "Screenshots"].Path, "NES"),
Filter = "PNG (*.png)|*.png|Bitmap (*.bmp)|*.bmp|All Files|*.*",
RestoreDirectory = true
};

View File

@ -37,7 +37,7 @@ namespace BizHawk.MultiClient
var sfd = new SaveFileDialog
{
FileName = PathManager.FilesystemSafeName(Global.Game) + "-Patterns",
InitialDirectory = PathManager.MakeAbsolutePath(Global.Config.PathNESScreenshots, "NES"),
InitialDirectory = PathManager.MakeAbsolutePath(Global.Config.PathEntries["NES", "Screenshots"].Path, "NES"),
Filter = "PNG (*.png)|*.png|Bitmap (*.bmp)|*.bmp|All Files|*.*",
RestoreDirectory = true
};

View File

@ -42,7 +42,7 @@ namespace BizHawk.MultiClient
var sfd = new SaveFileDialog
{
FileName = PathManager.FilesystemSafeName(Global.Game) + "-Sprites",
InitialDirectory = PathManager.MakeAbsolutePath(Global.Config.PathNESScreenshots, "NES"),
InitialDirectory = PathManager.MakeAbsolutePath(Global.Config.PathEntries["NES", "Screenshots"].Path, "NES"),
Filter = "PNG (*.png)|*.png|Bitmap (*.bmp)|*.bmp|All Files|*.*",
RestoreDirectory = true
};

View File

@ -77,7 +77,7 @@ namespace BizHawk.MultiClient
private void BrowseMovies_Click(object sender, EventArgs e)
{
OpenFileDialog ofd = new OpenFileDialog {InitialDirectory = PathManager.MakeAbsolutePath(Global.Config.MoviesPath)};
OpenFileDialog ofd = new OpenFileDialog { InitialDirectory = PathManager.MakeAbsolutePath(Global.Config.PathEntries.MoviesPath) };
string filter = "Movie Files (*." + Global.Config.MovieExtension + ")|*." + Global.Config.MovieExtension + "|Savestates|*.state|All Files|*.*";
ofd.Filter = filter;
@ -286,7 +286,7 @@ namespace BizHawk.MultiClient
{
ClearList();
string d = PathManager.MakeAbsolutePath(Global.Config.MoviesPath);
string d = PathManager.MakeAbsolutePath(Global.Config.PathEntries.MoviesPath);
if (!Directory.Exists(d))
{
Directory.CreateDirectory(d);

View File

@ -31,7 +31,7 @@ namespace BizHawk.MultiClient
{
if (path[0] != '\\')
path = path.Insert(0, "\\");
path = PathManager.MakeAbsolutePath(Global.Config.MoviesPath) + path;
path = PathManager.MakeAbsolutePath(Global.Config.PathEntries.MoviesPath) + path;
if (path[path.Length - 4] != '.') //If no file extension, add movie extension
path += "." + Global.Config.MovieExtension;
@ -181,7 +181,7 @@ namespace BizHawk.MultiClient
string filename = "";
SaveFileDialog sfd = new SaveFileDialog
{
InitialDirectory = PathManager.MakeAbsolutePath(Global.Config.MoviesPath),
InitialDirectory = PathManager.MakeAbsolutePath(Global.Config.PathEntries.MoviesPath),
DefaultExt = "." + Global.Config.MovieExtension,
FileName = RecordBox.Text,
OverwritePrompt = false

View File

@ -78,7 +78,7 @@ namespace BizHawk.MultiClient
listviewSorter = new ListViewSorter(this, -1);
currSelectorDir = PathManager.MakeAbsolutePath(Global.Config.FirmwaresPath);
currSelectorDir = PathManager.MakeAbsolutePath(Global.Config.PathEntries.FirmwaresPath);
}
//makes sure that the specified SystemId is selected in the list (and that all the firmwares for it are visible)
@ -197,7 +197,7 @@ namespace BizHawk.MultiClient
else
{
//lazy substring extraction. really should do a better job
var basePath = PathManager.MakeAbsolutePath(Global.Config.FirmwaresPath) + Path.DirectorySeparatorChar;
var basePath = PathManager.MakeAbsolutePath(Global.Config.PathEntries.FirmwaresPath) + Path.DirectorySeparatorChar;
var path = ri.FilePath.Replace(basePath, "");

View File

@ -42,7 +42,7 @@ namespace BizHawk.MultiClient
private void LoadSettings()
{
RecentForROMs.Checked = Global.Config.UseRecentForROMs;
BasePathBox.Text = Global.Config.BasePath;
BasePathBox.Text = Global.Config.PathEntries.GlobalBase;
DoTabs(Global.Config.PathEntries.Paths);
SetDefaultFocusedTab();
DoROMToggle();
@ -216,7 +216,7 @@ namespace BizHawk.MultiClient
private void SaveSettings()
{
Global.Config.UseRecentForROMs = RecentForROMs.Checked;
Global.Config.BasePath = BasePathBox.Text;
Global.Config.PathEntries["Global", "Base"].Path = BasePathBox.Text;
foreach (TextBox t in AllPathBoxes)
{

View File

@ -37,24 +37,24 @@ namespace BizHawk.MultiClient
/// <returns></returns>
public static string GetBasePathAbsolute()
{
if (Global.Config.BasePath.Length < 1) //If empty, then EXE path
if (Global.Config.PathEntries.GlobalBase.Length < 1) //If empty, then EXE path
return GetExeDirectoryAbsolute();
if (Global.Config.BasePath.Length >= 5 &&
Global.Config.BasePath.Substring(0, 5) == "%exe%")
if (Global.Config.PathEntries.GlobalBase.Length >= 5 &&
Global.Config.PathEntries.GlobalBase.Substring(0, 5) == "%exe%")
return GetExeDirectoryAbsolute();
if (Global.Config.BasePath[0] == '.')
if (Global.Config.PathEntries.GlobalBase[0] == '.')
{
if (Global.Config.BasePath.Length == 1)
if (Global.Config.PathEntries.GlobalBase.Length == 1)
return GetExeDirectoryAbsolute();
else
{
if (Global.Config.BasePath.Length == 2 &&
Global.Config.BasePath == ".\\")
if (Global.Config.PathEntries.GlobalBase.Length == 2 &&
Global.Config.PathEntries.GlobalBase == ".\\")
return GetExeDirectoryAbsolute();
else
{
string tmp = Global.Config.BasePath;
string tmp = Global.Config.PathEntries.GlobalBase;
tmp = tmp.Remove(0, 1);
tmp = tmp.Insert(0, GetExeDirectoryAbsolute());
return tmp;
@ -62,8 +62,8 @@ namespace BizHawk.MultiClient
}
}
if (Global.Config.BasePath.Substring(0, 2) == "..")
return RemoveParents(Global.Config.BasePath, GetExeDirectoryAbsolute());
if (Global.Config.PathEntries.GlobalBase.Substring(0, 2) == "..")
return RemoveParents(Global.Config.PathEntries.GlobalBase, GetExeDirectoryAbsolute());
//In case of error, return EXE path
return GetExeDirectoryAbsolute();
@ -71,55 +71,16 @@ namespace BizHawk.MultiClient
public static string GetPlatformBase(string system)
{
switch (system)
if (system == "SGX" || system == "PCECD")
{
case "C64":
return Global.Config.BaseC64;
case "PSX":
return Global.Config.BasePSX;
case "INTV":
return Global.Config.BaseINTV;
case "A26":
return Global.Config.BaseAtari2600;
case "A78":
return Global.Config.BaseAtari7800;
case "NES":
return Global.Config.BaseNES;
case "SG":
return Global.Config.BaseSG;
case "GG":
return Global.Config.BaseGG;
case "SMS":
return Global.Config.BaseSMS;
case "SGX":
case "PCE":
case "PCECD":
return Global.Config.BasePCE;
case "TI83":
return Global.Config.BaseTI83;
case "GEN":
return Global.Config.BaseGenesis;
case "GB":
return Global.Config.BaseGameboy;
case "SNES":
return Global.Config.BaseSNES;
case "Coleco":
return Global.Config.BaseCOL;
case "GBA":
return Global.Config.BaseGBA;
case "N64":
return Global.Config.BaseN64;
case "SAT":
return Global.Config.BaseSaturn;
case "NULL":
default:
return "";
system = "PCE";
}
return Global.Config.PathEntries[system, "Base"].Path;
}
public static string StandardFirmwareName(string name)
{
return Path.Combine(MakeAbsolutePath(Global.Config.FirmwaresPath), name);
return Path.Combine(MakeAbsolutePath(Global.Config.PathEntries.FirmwaresPath), name);
}
public static string MakeAbsolutePath(string path, string system = null)
@ -228,80 +189,33 @@ namespace BizHawk.MultiClient
public static string GetLuaPath()
{
return MakeAbsolutePath(Global.Config.LuaPath);
return MakeAbsolutePath(Global.Config.PathEntries.LuaPath);
}
public static string GetRomsPath(string sysID)
{
string path;
if (Global.Config.UseRecentForROMs)
return Environment.SpecialFolder.Recent.ToString();
switch (sysID)
{
case "C64":
path = MakeAbsolutePath(Global.Config.PathC64ROMs, "C64");
break;
case "PSX":
path = MakeAbsolutePath(Global.Config.PathPSXROMs, "PSX");
break;
case "INTV":
path = MakeAbsolutePath(Global.Config.PathINTVROMs, "INTV");
break;
case "SNES":
path = MakeAbsolutePath(Global.Config.PathSNESROMs, "SNES");
break;
case "A26":
path = MakeAbsolutePath(Global.Config.PathAtari2600ROMs, "A26");
break;
case "A78":
path = MakeAbsolutePath(Global.Config.PathAtari7800ROMs, "A78");
break;
case "NES":
path = MakeAbsolutePath(Global.Config.PathNESROMs, "NES");
break;
case "SMS":
path = MakeAbsolutePath(Global.Config.PathSMSROMs, "SMS");
break;
case "SG":
path = MakeAbsolutePath(Global.Config.PathSGROMs, "SG");
break;
case "GG":
path = MakeAbsolutePath(Global.Config.PathGGROMs, "GG");
break;
case "GEN":
path = MakeAbsolutePath(Global.Config.PathGenesisROMs, "GEN");
break;
case "SFX":
case "PCE":
case "PCECD":
path = MakeAbsolutePath(Global.Config.PathPCEROMs, "PCE");
break;
case "GB":
path = MakeAbsolutePath(Global.Config.PathGBROMs, "GB");
break;
case "GBA":
path = MakeAbsolutePath(Global.Config.PathGBAROMs, "GBA");
break;
case "TI83":
path = MakeAbsolutePath(Global.Config.PathTI83ROMs, "TI83");
break;
case "Coleco":
path = MakeAbsolutePath(Global.Config.PathCOLROMs, "Coleco");
break;
case "N64":
path = MakeAbsolutePath(Global.Config.PathN64ROMs, "N64");
break;
case "SAT":
path = MakeAbsolutePath(Global.Config.PathSaturnROMs, "SAT");
break;
default:
path = MakeAbsolutePath(Global.Config.BaseROMPath);
break;
return Environment.SpecialFolder.Recent.ToString();
}
return path;
if (sysID == "SGX" || sysID == "PCECD") //Yucky
{
sysID = "PCE";
}
else if (sysID == "NULL")
{
sysID = "Global";
}
PathEntry path = Global.Config.PathEntries[sysID, "ROM"];
if (path == null)
{
path = Global.Config.PathEntries[sysID, "Base"];
}
return path.Path;
}
public static string RemoveInvalidFileSystemChars(string name)
@ -326,59 +240,59 @@ namespace BizHawk.MultiClient
string name = FilesystemSafeName(game);
if (Global.MovieSession.Movie.IsActive)
{
name += "." + Path.GetFileNameWithoutExtension(Global.MovieSession.Movie.Filename);
}
string sysId = "";
switch (game.System)
{
case "INTV": return Path.Combine(MakeAbsolutePath(Global.Config.PathINTVSaveRAM, "INTV"), name + ".SaveRAM");
case "SMS": return Path.Combine(MakeAbsolutePath(Global.Config.PathSMSSaveRAM, "SMS"), name + ".SaveRAM");
case "GG": return Path.Combine(MakeAbsolutePath(Global.Config.PathGGSaveRAM, "GG"), name + ".SaveRAM");
case "SG": return Path.Combine(MakeAbsolutePath(Global.Config.PathSGSaveRAM, "SG"), name + ".SaveRAM");
case "SGX": return Path.Combine(MakeAbsolutePath(Global.Config.PathPCESaveRAM, "PCE"), name + ".SaveRAM");
case "PCE": return Path.Combine(MakeAbsolutePath(Global.Config.PathPCESaveRAM, "PCE"), name + ".SaveRAM");
case "PCECD": return Path.Combine(MakeAbsolutePath(Global.Config.PathPCESaveRAM, "PCE"), name + ".SaveRAM");
case "GB": case "GBC": return Path.Combine(MakeAbsolutePath(Global.Config.PathGBSaveRAM, "GB"), name + ".SaveRAM");
case "GBA": return Path.Combine(MakeAbsolutePath(Global.Config.PathGBASaveRAM, "GBA"), name + ".SaveRAM");
case "GEN": return Path.Combine(MakeAbsolutePath(Global.Config.PathGenesisSaveRAM, "GEN"), name + ".SaveRAM");
case "NES": return Path.Combine(MakeAbsolutePath(Global.Config.PathNESSaveRAM, "NES"), name + ".SaveRAM");
case "TI83": return Path.Combine(MakeAbsolutePath(Global.Config.PathTI83SaveRAM, "TI83"), name + ".SaveRAM");
case "A78": return Path.Combine(MakeAbsolutePath(Global.Config.PathAtari7800SaveRAM, "A78"), name + ".SaveRAM");
case "SNES": return Path.Combine(MakeAbsolutePath(Global.Config.PathSNESSaveRAM, "SNES"), name + ".SaveRAM");
case "PSX": return Path.Combine(MakeAbsolutePath(Global.Config.PathPSXSaveRAM, "PSX"), name + ".SaveRAM");
case "SAT": return Path.Combine(MakeAbsolutePath(Global.Config.PathSaturnSaveRAM, "SAT"), name + ".SaveRAM");
case "N64": return Path.Combine(MakeAbsolutePath(Global.Config.PathN64SaveRAM, "N64"), name + ".SaveRAM");
default: return Path.Combine(GetBasePathAbsolute(), name + ".SaveRAM");
case "SGX":
case "PCECD":
sysId = "PCE";
break;
case "NULL":
sysId = "Global";
break;
default:
sysId = game.System;
break;
}
PathEntry pathEntry = Global.Config.PathEntries[sysId, "Save RAM"];
if (pathEntry == null)
{
pathEntry = Global.Config.PathEntries[game.System, "Base"];
}
return Path.Combine(MakeAbsolutePath(pathEntry.Path), name);
}
public static string GetSaveStatePath(GameInfo game)
{
string sysId = "";
switch (game.System)
{
default: return GetRomsPath(game.System);
case "INTV": return MakeAbsolutePath(Global.Config.PathINTVSavestates, "INTV");
case "A26": return MakeAbsolutePath(Global.Config.PathAtari2600Savestates, "A26");
case "A78": return MakeAbsolutePath(Global.Config.PathAtari7800Savestates, "A78");
case "SMS": return MakeAbsolutePath(Global.Config.PathSMSSavestates, "SMS");
case "GG": return MakeAbsolutePath(Global.Config.PathGGSavestates, "GG");
case "SG": return MakeAbsolutePath(Global.Config.PathSGSavestates, "SG");
case "SGX": return MakeAbsolutePath(Global.Config.PathPCESavestates, "PCE");
case "PCE": return MakeAbsolutePath(Global.Config.PathPCESavestates, "PCE");
case "PCECD": return MakeAbsolutePath(Global.Config.PathPCESavestates, "PCE");
case "GB": case "GBC": return MakeAbsolutePath(Global.Config.PathGBSavestates, "GB");
case "GBA": return MakeAbsolutePath(Global.Config.PathGBASavestates, "GBA");
case "GEN": return MakeAbsolutePath(Global.Config.PathGenesisSavestates, "GEN");
case "NES": return MakeAbsolutePath(Global.Config.PathNESSavestates, "NES");
case "TI83": return MakeAbsolutePath(Global.Config.PathTI83Savestates, "TI83");
case "SNES": return MakeAbsolutePath(Global.Config.PathSNESSavestates, "SNES");
case "PSX": return MakeAbsolutePath(Global.Config.PathPSXSavestates, "PSX");
case "C64": return MakeAbsolutePath(Global.Config.PathC64Savestates, "C64");
case "Coleco": return MakeAbsolutePath(Global.Config.PathCOLSavestates, "Coleco");
case "SAT": return MakeAbsolutePath(Global.Config.PathSaturnSavestates, "SAT");
case "N64": return MakeAbsolutePath(Global.Config.PathN64Savestates, "N64");
case "SGX":
case "PCECD":
sysId = "PCE";
break;
case "NULL":
sysId = "Global";
break;
default:
sysId = game.System;
break;
}
PathEntry pathEntry = Global.Config.PathEntries[sysId, "Savestates"];
if (pathEntry == null)
{
pathEntry = Global.Config.PathEntries[game.System, "Base"];
}
return MakeAbsolutePath(pathEntry.Path, sysId == "Global" ? null : sysId);
}
public static string SaveStatePrefix(GameInfo game)
@ -389,59 +303,59 @@ namespace BizHawk.MultiClient
{
name += "." + Path.GetFileNameWithoutExtension(Global.MovieSession.Movie.Filename);
}
string sysId = "";
switch (game.System)
{
case "INTV": return Path.Combine(MakeAbsolutePath(Global.Config.PathINTVSavestates, "INTV"), name);
case "A26": return Path.Combine(MakeAbsolutePath(Global.Config.PathAtari2600Savestates, "A26"), name);
case "A78": return Path.Combine(MakeAbsolutePath(Global.Config.PathAtari7800Savestates, "A78"), name);
case "SMS": return Path.Combine(MakeAbsolutePath(Global.Config.PathSMSSavestates, "SMS"), name);
case "GG": return Path.Combine(MakeAbsolutePath(Global.Config.PathGGSavestates, "GG"), name);
case "SG": return Path.Combine(MakeAbsolutePath(Global.Config.PathSGSavestates, "SG"), name);
case "SGX": return Path.Combine(MakeAbsolutePath(Global.Config.PathPCESavestates, "PCE"), name);
case "PCE": return Path.Combine(MakeAbsolutePath(Global.Config.PathPCESavestates, "PCE"), name);
case "PCECD": return Path.Combine(MakeAbsolutePath(Global.Config.PathPCESavestates, "PCE"), name);
case "GB": case "GBC": return Path.Combine(MakeAbsolutePath(Global.Config.PathGBSavestates, "GB"), name);
case "GBA": return Path.Combine(MakeAbsolutePath(Global.Config.PathGBASavestates, "GBA"), name);
case "GEN": return Path.Combine(MakeAbsolutePath(Global.Config.PathGenesisSavestates, "GEN"), name);
case "NES": return Path.Combine(MakeAbsolutePath(Global.Config.PathNESSavestates, "NES"), name);
case "TI83": return Path.Combine(MakeAbsolutePath(Global.Config.PathTI83Savestates, "TI83"), name);
case "SNES": return Path.Combine(MakeAbsolutePath(Global.Config.PathSNESSavestates, "SNES"), name);
case "PSX": return Path.Combine(MakeAbsolutePath(Global.Config.PathPSXSavestates, "PSX"), name);
case "C64": return Path.Combine(MakeAbsolutePath(Global.Config.PathC64Savestates, "C64"), name);
case "Coleco": return Path.Combine(MakeAbsolutePath(Global.Config.PathCOLSavestates, "Coleco"), name);
case "SAT": return Path.Combine(MakeAbsolutePath(Global.Config.PathSaturnSavestates, "SAT"), name);
case "N64": return Path.Combine(MakeAbsolutePath(Global.Config.PathN64Savestates, "N64"), name);
case "SGX":
case "PCECD":
sysId = "PCE";
break;
case "NULL":
sysId = "Global";
break;
default:
sysId = game.System;
break;
}
return "";
PathEntry pathEntry = Global.Config.PathEntries[sysId, "Savestates"];
if (pathEntry == null)
{
pathEntry = Global.Config.PathEntries[sysId, "Base"];
}
return Path.Combine(pathEntry.Path, name);
}
public static string ScreenshotPrefix(GameInfo game)
{
string name = FilesystemSafeName(game);
string sysId = "";
switch (game.System)
{
case "INTV": return Path.Combine(MakeAbsolutePath(Global.Config.PathINTVScreenshots, "INTV"), name);
case "A26": return Path.Combine(MakeAbsolutePath(Global.Config.PathAtari2600Screenshots, "A26"), name);
case "A78": return Path.Combine(MakeAbsolutePath(Global.Config.PathAtari7800Screenshots, "A78"), name);
case "SMS": return Path.Combine(MakeAbsolutePath(Global.Config.PathSMSScreenshots, "SMS"), name);
case "GG": return Path.Combine(MakeAbsolutePath(Global.Config.PathGGScreenshots, "GG"), name);
case "SG": return Path.Combine(MakeAbsolutePath(Global.Config.PathSGScreenshots, "SG"), name);
case "SGX": return Path.Combine(MakeAbsolutePath(Global.Config.PathPCEScreenshots, "PCE"), name);
case "PCE": return Path.Combine(MakeAbsolutePath(Global.Config.PathPCEScreenshots, "PCE"), name);
case "PCECD": return Path.Combine(MakeAbsolutePath(Global.Config.PathPCEScreenshots, "PCE"), name);
case "GB": case "GBC": return Path.Combine(MakeAbsolutePath(Global.Config.PathGBScreenshots, "GB"), name);
case "GBA": return Path.Combine(MakeAbsolutePath(Global.Config.PathGBAScreenshots, "GBA"), name);
case "GEN": return Path.Combine(MakeAbsolutePath(Global.Config.PathGenesisScreenshots, "GEN"), name);
case "NES": return Path.Combine(MakeAbsolutePath(Global.Config.PathNESScreenshots, "NES"), name);
case "TI83": return Path.Combine(MakeAbsolutePath(Global.Config.PathTI83Screenshots, "TI83"), name);
case "SNES": return Path.Combine(MakeAbsolutePath(Global.Config.PathSNESScreenshots, "SNES"), name);
case "PSX": return Path.Combine(MakeAbsolutePath(Global.Config.PathPSXScreenshots, "PSX"), name);
case "Coleco": return Path.Combine(MakeAbsolutePath(Global.Config.PathCOLScreenshots, "Coleco"), name);
case "SAT": return Path.Combine(MakeAbsolutePath(Global.Config.PathSaturnScreenshots, "SAT"), name);
case "N64": return Path.Combine(MakeAbsolutePath(Global.Config.PathN64Screenshots, "N64"), name);
case "SGX":
case "PCECD":
sysId = "PCE";
break;
case "NULL":
sysId = "Global";
break;
default:
sysId = game.System;
break;
}
return "";
PathEntry pathEntry = Global.Config.PathEntries[sysId, "Screenshots"];
if (pathEntry == null)
{
pathEntry = Global.Config.PathEntries[game.System, "Base"];
}
return Path.Combine(MakeAbsolutePath(pathEntry.Path), name);
}
}
}

View File

@ -367,7 +367,7 @@ namespace BizHawk.MultiClient
string BackupName = Filename;
BackupName = BackupName.Insert(Filename.LastIndexOf("."), String.Format(".{0:yyyy-MM-dd HH.mm.ss}", DateTime.Now));
BackupName = Global.Config.MoviesBackupPath + "\\" + Path.GetFileName(BackupName);
BackupName = Path.Combine(Global.Config.PathEntries["Global", "Movie backups"].Path, Path.GetFileName(BackupName));
var directory_info = new FileInfo(BackupName).Directory;
if (directory_info != null) Directory.CreateDirectory(directory_info.FullName);

View File

@ -168,38 +168,21 @@ namespace BizHawk.MultiClient
{
get
{
string path;
switch (Global.Emulator.SystemId)
string sysId = Global.Emulator.SystemId;
//Exceptions. TODO: There are more of these I'm sure
if (sysId == "SGX" || sysId == "PCECD")
{
case "NES":
path = PathManager.MakeAbsolutePath(Global.Config.PathNESCheats, "NES");
break;
case "SMS":
path = PathManager.MakeAbsolutePath(Global.Config.PathSMSCheats, "SMS");
break;
case "SG":
path = PathManager.MakeAbsolutePath(Global.Config.PathSGCheats, "SG");
break;
case "GG":
path = PathManager.MakeAbsolutePath(Global.Config.PathGGCheats, "GG");
break;
case "GEN":
path = PathManager.MakeAbsolutePath(Global.Config.PathGenesisCheats, "GEN");
break;
case "SFX":
case "PCE":
path = PathManager.MakeAbsolutePath(Global.Config.PathPCECheats, "PCE");
break;
case "GB":
path = PathManager.MakeAbsolutePath(Global.Config.PathGBCheats, "GB");
break;
case "TI83":
path = PathManager.MakeAbsolutePath(Global.Config.PathTI83Cheats, "TI83");
break;
default:
path = PathManager.GetBasePathAbsolute();
break;
sysId = "PCE";
}
PathEntry pathEntry = Global.Config.PathEntries[sysId, "Cheats"];
if (pathEntry == null)
{
pathEntry = Global.Config.PathEntries[sysId, "Base"];
}
string path = pathEntry.Path;
var f = new FileInfo(path);
if (f.Directory != null && f.Directory.Exists == false)
{

View File

@ -1878,7 +1878,7 @@ namespace BizHawk.MultiClient
var ofd = new OpenFileDialog();
if (currentFile.Length > 0)
ofd.FileName = Path.GetFileNameWithoutExtension(currentFile);
ofd.InitialDirectory = PathManager.MakeAbsolutePath(Global.Config.WatchPath);
ofd.InitialDirectory = PathManager.MakeAbsolutePath(Global.Config.PathEntries.WatchPath);
ofd.Filter = "Watch Files (*.wch)|*.wch|All Files|*.*";
ofd.RestoreDirectory = true;
if (currentFile.Length > 0)

View File

@ -562,7 +562,7 @@ namespace BizHawk.MultiClient
var ofd = new OpenFileDialog();
if (currentFile.Length > 0)
ofd.FileName = Path.GetFileNameWithoutExtension(currentFile);
ofd.InitialDirectory = PathManager.MakeAbsolutePath(Global.Config.WatchPath);
ofd.InitialDirectory = PathManager.MakeAbsolutePath(Global.Config.PathEntries.WatchPath);
ofd.Filter = "Watch Files (*.wch)|*.wch|All Files|*.*";
ofd.RestoreDirectory = true;

View File

@ -451,7 +451,7 @@ namespace BizHawk.MultiClient
{
SaveFileDialog sfd = new SaveFileDialog
{
InitialDirectory = PathManager.MakeAbsolutePath(Global.Config.MoviesPath),
InitialDirectory = PathManager.MakeAbsolutePath(Global.Config.PathEntries.MoviesPath),
DefaultExt = "." + Global.Config.MovieExtension,
FileName = Global.MovieSession.Movie.Filename
};

View File

@ -232,7 +232,7 @@ namespace BizHawk.MultiClient
FileBox.Visible = true;
BrowseBox.Visible = true;
string name = PathManager.FilesystemSafeName(Global.Game);
string filename = Path.Combine(PathManager.MakeAbsolutePath(Global.Config.LogPath), name) + ".txt";
string filename = Path.Combine(PathManager.MakeAbsolutePath(Global.Config.PathEntries.LogPath), name) + ".txt";
LogFile = new FileInfo(filename);
if (LogFile.Directory != null && !LogFile.Directory.Exists)
{
@ -303,7 +303,7 @@ namespace BizHawk.MultiClient
{
string name = PathManager.FilesystemSafeName(Global.Game);
sfd.FileName = name + ".txt";
sfd.InitialDirectory = PathManager.MakeAbsolutePath(Global.Config.LogPath);
sfd.InitialDirectory = PathManager.MakeAbsolutePath(Global.Config.PathEntries.LogPath);
}
else if (!String.IsNullOrWhiteSpace(LogFile.FullName))
{
@ -313,7 +313,7 @@ namespace BizHawk.MultiClient
else
{
sfd.FileName = Path.GetFileNameWithoutExtension(LogFile.FullName);
sfd.InitialDirectory = PathManager.MakeAbsolutePath(Global.Config.LogPath);
sfd.InitialDirectory = PathManager.MakeAbsolutePath(Global.Config.PathEntries.LogPath);
}
sfd.Filter = "Text Files (*.txt)|*.txt|Log Files (*.log)|*.log|All Files|*.*";

View File

@ -187,12 +187,12 @@ namespace BizHawk.MultiClient
else if (!(Global.Emulator is NullEmulator))
{
sfd.FileName = PathManager.FilesystemSafeName(Global.Game);
sfd.InitialDirectory = PathManager.MakeAbsolutePath(Global.Config.WatchPath);
sfd.InitialDirectory = PathManager.MakeAbsolutePath(Global.Config.PathEntries.WatchPath);
}
else
{
sfd.FileName = "NULL";
sfd.InitialDirectory = PathManager.MakeAbsolutePath(Global.Config.WatchPath);
sfd.InitialDirectory = PathManager.MakeAbsolutePath(Global.Config.PathEntries.WatchPath);
}
sfd.Filter = "Watch Files (*.wch)|*.wch|All Files|*.*";
sfd.RestoreDirectory = true;