validate shaders when selecting them from display manager config dialog to prevent setting broken shaders. also specifically reject .cgp containing .glsl references
This commit is contained in:
parent
0d5470a713
commit
bd795ed162
|
@ -142,6 +142,20 @@ namespace BizHawk.Client.EmuHawk.Filters
|
|||
|
||||
public List<ShaderPass> Passes = new List<ShaderPass>();
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether any of the passes contain GLSL filenames (these are invalid now)
|
||||
/// </summary>
|
||||
public bool ContainsGLSL
|
||||
{
|
||||
get
|
||||
{
|
||||
foreach (var pass in Passes)
|
||||
if (Path.GetExtension(pass.ShaderPath).ToLowerInvariant() == ".glsl")
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public enum ScaleType
|
||||
{
|
||||
NotSet, Source, Viewport, Absolute
|
||||
|
|
|
@ -176,7 +176,34 @@ namespace BizHawk.Client.EmuHawk.config
|
|||
if (ofd.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
rbUser.Checked = true;
|
||||
PathSelection = Path.GetFullPath(ofd.FileName);
|
||||
var choice = Path.GetFullPath(ofd.FileName);
|
||||
|
||||
//test the preset
|
||||
using (var stream = File.OpenRead(choice))
|
||||
{
|
||||
var cgp = new BizHawk.Client.EmuHawk.Filters.RetroShaderPreset(stream);
|
||||
if (cgp.ContainsGLSL)
|
||||
{
|
||||
MessageBox.Show("Specified CGP contains references to .glsl files. This is illegal. Use .cg");
|
||||
return;
|
||||
}
|
||||
|
||||
//try compiling it
|
||||
bool ok = false;
|
||||
try
|
||||
{
|
||||
var filter = new BizHawk.Client.EmuHawk.Filters.RetroShaderChain(GlobalWin.IGL_GL, cgp, Path.GetDirectoryName(choice));
|
||||
ok = filter.Available;
|
||||
}
|
||||
catch {}
|
||||
if (!ok)
|
||||
{
|
||||
MessageBox.Show("Selected filter could not be compiled.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
PathSelection = choice;
|
||||
RefreshState();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue