gsdumpgui: Improve renderer override handling

Instead of faffing around with strings and having to handle a lot of
edge cases when trying to override the renderer, just let
WritePrivateProfileString do all the hard work for us instead.
This commit is contained in:
Jonathan Li 2018-01-16 17:33:41 +00:00
parent fad0a2a55f
commit 8fff11fdee
2 changed files with 7 additions and 17 deletions

View File

@ -163,7 +163,7 @@ namespace GSDumpGUI
private void ExecuteFunction(String Function)
{
txtLog.Text = "";
String GSDXName = lstGSDX.SelectedItem.ToString().Split(new char[] { '|' })[0];
String GSDXName = lstGSDX.SelectedItem.ToString().Split(new char[] { '|' })[0].TrimEnd();
CreateDirs(GSDXName);
@ -191,22 +191,8 @@ namespace GSDumpGUI
}
if (SelectedRenderer != "-1")
{
if (File.Exists(AppDomain.CurrentDomain.BaseDirectory + "GSDumpGSDXConfigs\\" + GSDXName + "\\inis\\gsdx.ini"))
{
String ini = File.ReadAllText(AppDomain.CurrentDomain.BaseDirectory + "GSDumpGSDXConfigs\\" + GSDXName + "\\inis\\gsdx.ini");
int pos = ini.IndexOf("Renderer=", 0);
if (pos != -1)
{
String newini = ini.Substring(0, pos + 9);
newini += SelectedRenderer;
newini += ini.Substring(pos + 10, ini.Length - pos - 10);
File.WriteAllText(AppDomain.CurrentDomain.BaseDirectory + "GSDumpGSDXConfigs\\" + GSDXName + "\\inis\\gsdx.ini", newini);
}
else
{
File.WriteAllText(AppDomain.CurrentDomain.BaseDirectory + "GSDumpGSDXConfigs\\" + GSDXName + "\\inis\\gsdx.ini", ini + Environment.NewLine + "Renderer=" + SelectedRenderer);
}
}
String GSdxIniPath = AppDomain.CurrentDomain.BaseDirectory + "GSDumpGSDXConfigs\\" + GSDXName + "\\inis\\gsdx.ini";
NativeMethods.WritePrivateProfileString("Settings", "Renderer", SelectedRenderer, GSdxIniPath);
}
if (lstDumps.SelectedItem != null)
DumpPath = Properties.Settings.Default.DumpDir + "\\" +

View File

@ -29,6 +29,10 @@ namespace GSDumpGUI
[DllImport("kernel32", CharSet = CharSet.Ansi)]
public extern static int GetLastError();
[SuppressUnmanagedCodeSecurityAttribute]
[DllImport("kernel32", CharSet = CharSet.Ansi)]
public extern static int WritePrivateProfileString(string lpAppName, string lpKeyName, string lpString, string lpFileName);
[SuppressUnmanagedCodeSecurityAttribute]
[DllImport("user32", CharSet = CharSet.Ansi)]
public extern static short GetAsyncKeyState(int key);