コード例 #1
0
        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();
            }
        }
コード例 #2
0
		private void btnSelectUserFilter_Click(object sender, EventArgs e)
		{
			var ofd = new OpenFileDialog();
			ofd.Filter = ".CGP (*.cgp)|*.cgp";
			ofd.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)
					{
						new ExceptionBox(errors).ShowDialog();
						return;
					}
				}

				PathSelection = choice;
				RefreshState();
			}
		}