experimental: add %rom% to path manager, so files related to a rom can be located relative to the rom
also refactored how %exe% worked because it blew my mind
This commit is contained in:
parent
c7f717981b
commit
7a72bf72e6
|
@ -100,17 +100,10 @@ namespace BizHawk.Client.Common
|
||||||
return Environment.SpecialFolder.Recent.ToString();
|
return Environment.SpecialFolder.Recent.ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (path.Length >= 5 && path.Substring(0, 5) == "%exe%")
|
if (path.StartsWith("%exe%"))
|
||||||
{
|
return GetExeDirectoryAbsolute() + path.Substring(5);
|
||||||
if (path.Length == 5)
|
if (path.StartsWith("%rom%"))
|
||||||
{
|
return Global.Config.LastRomPath + path.Substring(5);
|
||||||
return GetExeDirectoryAbsolute();
|
|
||||||
}
|
|
||||||
|
|
||||||
var tmp = path.Remove(0, 5);
|
|
||||||
tmp = tmp.Insert(0, GetExeDirectoryAbsolute());
|
|
||||||
return tmp;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (path[0] == '.')
|
if (path[0] == '.')
|
||||||
{
|
{
|
||||||
|
|
|
@ -128,14 +128,14 @@ namespace BizHawk.Client.Common
|
||||||
|
|
||||||
private static string ResolveToolsPath(string subPath)
|
private static string ResolveToolsPath(string subPath)
|
||||||
{
|
{
|
||||||
if (Path.IsPathRooted(subPath))
|
if (Path.IsPathRooted(subPath) || subPath.StartsWith("%"))
|
||||||
{
|
{
|
||||||
return subPath;
|
return subPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
var toolsPath = Global.Config.PathEntries["Global", "Tools"].Path;
|
var toolsPath = Global.Config.PathEntries["Global", "Tools"].Path;
|
||||||
|
|
||||||
// Hack for backwards compabitilbity, preior to 1.11.5, .wch files were in .\Tools, we don't want that to turn into .Tools\Tools
|
// Hack for backwards compatibility, prior to 1.11.5, .wch files were in .\Tools, we don't want that to turn into .Tools\Tools
|
||||||
if (subPath == "Tools")
|
if (subPath == "Tools")
|
||||||
{
|
{
|
||||||
return toolsPath;
|
return toolsPath;
|
||||||
|
|
|
@ -2133,8 +2133,8 @@ namespace BizHawk.Client.EmuHawk
|
||||||
"Apple II", "*.dsk;*.do;*.po;%ARCH%",
|
"Apple II", "*.dsk;*.do;*.po;%ARCH%",
|
||||||
"Virtual Boy", "*.vb;%ARCH%",
|
"Virtual Boy", "*.vb;%ARCH%",
|
||||||
"Neo Geo Pocket", "*.ngp;*.ngc;%ARCH%",
|
"Neo Geo Pocket", "*.ngp;*.ngc;%ARCH%",
|
||||||
"Sinclair ZX Spectrum", "*.tzx;*.tap;*.dsk;*.pzx;*.csw;*.wav;%ARCH%",
|
"Sinclair ZX Spectrum", "*.tzx;*.tap;*.dsk;*.pzx;*.csw;*.wav;%ARCH%",
|
||||||
"Amstrad CPC", "*.cdt;*.dsk;%ARCH%",
|
"Amstrad CPC", "*.cdt;*.dsk;%ARCH%",
|
||||||
"All Files", "*.*");
|
"All Files", "*.*");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2164,8 +2164,8 @@ namespace BizHawk.Client.EmuHawk
|
||||||
"Virtual Boy", "*.vb;%ARCH%",
|
"Virtual Boy", "*.vb;%ARCH%",
|
||||||
"Neo Geo Pocket", "*.ngp;*.ngc;%ARCH%",
|
"Neo Geo Pocket", "*.ngp;*.ngc;%ARCH%",
|
||||||
"Commodore 64", "*.prg; *.d64, *.g64; *.crt; *.tap;%ARCH%",
|
"Commodore 64", "*.prg; *.d64, *.g64; *.crt; *.tap;%ARCH%",
|
||||||
"Sinclair ZX Spectrum", "*.tzx;*.tap;*.dsk;*.pzx;*.csw;*.wav;%ARCH%",
|
"Sinclair ZX Spectrum", "*.tzx;*.tap;*.dsk;*.pzx;*.csw;*.wav;%ARCH%",
|
||||||
"All Files", "*.*");
|
"All Files", "*.*");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2186,7 +2186,6 @@ namespace BizHawk.Client.EmuHawk
|
||||||
}
|
}
|
||||||
|
|
||||||
var file = new FileInfo(ofd.FileName);
|
var file = new FileInfo(ofd.FileName);
|
||||||
Global.Config.LastRomPath = file.DirectoryName;
|
|
||||||
_lastOpenRomFilter = ofd.FilterIndex;
|
_lastOpenRomFilter = ofd.FilterIndex;
|
||||||
|
|
||||||
var lra = new LoadRomArgs { OpenAdvanced = new OpenAdvanced_OpenRom { Path = file.FullName } };
|
var lra = new LoadRomArgs { OpenAdvanced = new OpenAdvanced_OpenRom { Path = file.FullName } };
|
||||||
|
@ -3550,8 +3549,16 @@ namespace BizHawk.Client.EmuHawk
|
||||||
|
|
||||||
private LoadRomArgs _currentLoadRomArgs;
|
private LoadRomArgs _currentLoadRomArgs;
|
||||||
|
|
||||||
// Still needs a good bit of refactoring
|
|
||||||
public bool LoadRom(string path, LoadRomArgs args)
|
public bool LoadRom(string path, LoadRomArgs args)
|
||||||
|
{
|
||||||
|
bool ret = _LoadRom(path, args);
|
||||||
|
if(!ret) return false;
|
||||||
|
Global.Config.LastRomPath = Path.GetFullPath(Path.GetDirectoryName(path));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Still needs a good bit of refactoring
|
||||||
|
public bool _LoadRom(string path, LoadRomArgs args)
|
||||||
{
|
{
|
||||||
path = HawkFile.Util_ResolveLink(path);
|
path = HawkFile.Util_ResolveLink(path);
|
||||||
|
|
||||||
|
@ -3696,7 +3703,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Emulator is TI83 && Global.Config.TI83autoloadKeyPad)
|
if (Emulator is TI83 && Global.Config.TI83autoloadKeyPad)
|
||||||
{
|
{
|
||||||
GlobalWin.Tools.Load<TI83KeyPad>();
|
GlobalWin.Tools.Load<TI83KeyPad>();
|
||||||
}
|
}
|
||||||
|
@ -3725,15 +3732,15 @@ namespace BizHawk.Client.EmuHawk
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Emulator.CoreComm.RomStatusDetails == null && loader.Rom != null)
|
if (Emulator.CoreComm.RomStatusDetails == null && loader.Rom != null)
|
||||||
{
|
{
|
||||||
Emulator.CoreComm.RomStatusDetails = $"{loader.Game.Name}\r\nSHA1:{loader.Rom.RomData.HashSHA1()}\r\nMD5:{loader.Rom.RomData.HashMD5()}\r\n";
|
Emulator.CoreComm.RomStatusDetails = $"{loader.Game.Name}\r\nSHA1:{loader.Rom.RomData.HashSHA1()}\r\nMD5:{loader.Rom.RomData.HashMD5()}\r\n";
|
||||||
}
|
}
|
||||||
else if (Emulator.CoreComm.RomStatusDetails == null && loader.Rom == null)
|
else if (Emulator.CoreComm.RomStatusDetails == null && loader.Rom == null)
|
||||||
{
|
{
|
||||||
// single disc game
|
// single disc game
|
||||||
Emulator.CoreComm.RomStatusDetails = $"{loader.Game.Name}\r\nSHA1:N/A\r\nMD5:N/A\r\n";
|
Emulator.CoreComm.RomStatusDetails = $"{loader.Game.Name}\r\nSHA1:N/A\r\nMD5:N/A\r\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Emulator.HasBoardInfo())
|
if (Emulator.HasBoardInfo())
|
||||||
{
|
{
|
||||||
|
|
|
@ -33,6 +33,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
{
|
{
|
||||||
"%recent%",
|
"%recent%",
|
||||||
"%exe%",
|
"%exe%",
|
||||||
|
"%rom%",
|
||||||
".\\",
|
".\\",
|
||||||
"..\\",
|
"..\\",
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue