private void btnSelectUserFilter_Click(object sender, EventArgs e) { using var ofd = new OpenFileDialog { Filter = ".CGP (*.cgp)|*.cgp", FileName = _pathSelection }; if (ofd.ShowDialog() == DialogResult.OK) { rbUser.Checked = true; 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; string errors = ""; try { var filter = new BizHawk.Client.EmuHawk.Filters.RetroShaderChain(GlobalWin.GL, cgp, Path.GetDirectoryName(choice)); ok = filter.Available; errors = filter.Errors; } catch {} if (!ok) { using var errorForm = new ExceptionBox(errors); errorForm.ShowDialog(); return; } } _pathSelection = choice; RefreshState(); } }
private void btnSelectUserFilter_Click(object sender, EventArgs e) { using var ofd = new OpenFileDialog { Filter = new FilesystemFilter(".CGP Files", new[] { "cgp" }).ToString(), FileName = _pathSelection }; if (ofd.ShowDialog() == DialogResult.OK) { rbUser.Checked = true; var choice = Path.GetFullPath(ofd.FileName); //test the preset using (var stream = File.OpenRead(choice)) { var cgp = new RetroShaderPreset(stream); // try compiling it bool ok = false; string errors = ""; try { var filter = new RetroShaderChain(GlobalWin.GL, cgp, Path.GetDirectoryName(choice)); ok = filter.Available; errors = filter.Errors; } catch {} if (!ok) { using var errorForm = new ExceptionBox(errors); errorForm.ShowDialog(); return; } } _pathSelection = choice; RefreshState(); } }