From 64cccda076c0731ff2d1e8c2928545e795ee1b14 Mon Sep 17 00:00:00 2001 From: Jonathan Li Date: Mon, 21 Sep 2015 22:32:11 +0100 Subject: [PATCH] gsdx:windows: Add external shader selection to GUI This lets Windows users select the external shader and config file via the GUI. Also, comment out an unused variable in the Hacks dialog code. --- plugins/GSdx/GSSettingsDlg.cpp | 43 +++++++++++++++++++++----- plugins/GSdx/GSdx.rc | 56 +++++++++++++++++++--------------- plugins/GSdx/resource.h | 10 ++++-- 3 files changed, 74 insertions(+), 35 deletions(-) diff --git a/plugins/GSdx/GSSettingsDlg.cpp b/plugins/GSdx/GSSettingsDlg.cpp index 7c8fcc775e..8df191216d 100644 --- a/plugins/GSdx/GSSettingsDlg.cpp +++ b/plugins/GSdx/GSSettingsDlg.cpp @@ -170,6 +170,8 @@ void GSSettingsDlg::OnInit() // External FX shader CheckDlgButton(m_hWnd, IDC_SHADER_FX, theApp.GetConfig("shaderfx", 0)); + SendMessage(GetDlgItem(m_hWnd, IDC_SHADER_FX_EDIT), WM_SETTEXT, 0, (LPARAM)theApp.GetConfig("shaderfx_glsl", "shaders\\GSdx.fx").c_str()); + SendMessage(GetDlgItem(m_hWnd, IDC_SHADER_FX_CONF_EDIT), WM_SETTEXT, 0, (LPARAM)theApp.GetConfig("shaderfx_conf", "shaders\\GSdx_FX_Settings.ini").c_str()); // Hacks CheckDlgButton(m_hWnd, IDC_HACKS_ENABLED, theApp.GetConfig("UserHacks", 0)); @@ -220,6 +222,7 @@ bool GSSettingsDlg::OnCommand(HWND hWnd, UINT id, UINT code) UpdateControls(); break; case IDC_SHADEBOOST: + case IDC_SHADER_FX: case IDC_PALTEX: case IDC_HACKS_ENABLED: if (code == BN_CLICKED) @@ -233,6 +236,14 @@ bool GSSettingsDlg::OnCommand(HWND hWnd, UINT id, UINT code) if (code == BN_CLICKED) HacksDlg.DoModal(); break; + case IDC_SHADER_FX_BUTTON: + if (code == BN_CLICKED) + OpenFileDialog(IDC_SHADER_FX_EDIT, "Select External Shader"); + break; + case IDC_SHADER_FX_CONF_BUTTON: + if (code == BN_CLICKED) + OpenFileDialog(IDC_SHADER_FX_CONF_EDIT, "Select External Shader Config"); + break; case IDOK: { INT_PTR data; @@ -308,8 +319,17 @@ bool GSSettingsDlg::OnCommand(HWND hWnd, UINT id, UINT code) theApp.SetConfig("shaderfx", (int)IsDlgButtonChecked(m_hWnd, IDC_SHADER_FX)); // External FX Shader(OpenGL) - theApp.SetConfig("shaderfx_conf", "shaders/GSdx_FX_Settings.ini"); - theApp.SetConfig("shaderfx_glsl", "shaders/GSdx.fx"); + int shader_fx_length = (int)SendMessage(GetDlgItem(m_hWnd, IDC_SHADER_FX_EDIT), WM_GETTEXTLENGTH, 0, 0); + int shader_fx_conf_length = (int)SendMessage(GetDlgItem(m_hWnd, IDC_SHADER_FX_CONF_EDIT), WM_GETTEXTLENGTH, 0, 0); + int length = std::max(shader_fx_length, shader_fx_conf_length) + 1; + char *buffer = new char[length]; + + SendMessage(GetDlgItem(m_hWnd, IDC_SHADER_FX_EDIT), WM_GETTEXT, (WPARAM)length, (LPARAM)buffer); + theApp.SetConfig("shaderfx_glsl", buffer); // Not really glsl only ;) + SendMessage(GetDlgItem(m_hWnd, IDC_SHADER_FX_CONF_EDIT), WM_GETTEXT, (WPARAM)length, (LPARAM)buffer); + theApp.SetConfig("shaderfx_conf", buffer); + + delete [] buffer; theApp.SetConfig("UserHacks", (int)IsDlgButtonChecked(m_hWnd, IDC_HACKS_ENABLED)); } @@ -416,19 +436,26 @@ void GSSettingsDlg::UpdateControls() EnableWindow(GetDlgItem(m_hWnd, IDC_ACCURATE_BLEND_UNIT_TEXT), ogl && hw); EnableWindow(GetDlgItem(m_hWnd, IDC_TC_DEPTH), ogl && hw); - //EnableWindow(GetDlgItem(m_hWnd, IDC_AA1), sw); // Let uers set software params regardless of renderer used //EnableWindow(GetDlgItem(m_hWnd, IDC_SWTHREADS_EDIT), sw); //EnableWindow(GetDlgItem(m_hWnd, IDC_SWTHREADS), sw); - - // Shade Boost - EnableWindow(GetDlgItem(m_hWnd, IDC_SHADEBUTTON), IsDlgButtonChecked(m_hWnd, IDC_SHADEBOOST) == BST_CHECKED); - // Hacks EnableWindow(GetDlgItem(m_hWnd, IDC_HACKS_ENABLED), hw); EnableWindow(GetDlgItem(m_hWnd, IDC_HACKSBUTTON), hw && IsDlgButtonChecked(m_hWnd, IDC_HACKS_ENABLED)); } + + // External shader + bool external_shader_selected = IsDlgButtonChecked(m_hWnd, IDC_SHADER_FX) == BST_CHECKED; + EnableWindow(GetDlgItem(m_hWnd, IDC_SHADER_FX_TEXT), external_shader_selected); + EnableWindow(GetDlgItem(m_hWnd, IDC_SHADER_FX_EDIT), external_shader_selected); + EnableWindow(GetDlgItem(m_hWnd, IDC_SHADER_FX_BUTTON), external_shader_selected); + EnableWindow(GetDlgItem(m_hWnd, IDC_SHADER_FX_CONF_TEXT), external_shader_selected); + EnableWindow(GetDlgItem(m_hWnd, IDC_SHADER_FX_CONF_EDIT), external_shader_selected); + EnableWindow(GetDlgItem(m_hWnd, IDC_SHADER_FX_CONF_BUTTON), external_shader_selected); + + // Shade Boost + EnableWindow(GetDlgItem(m_hWnd, IDC_SHADEBUTTON), IsDlgButtonChecked(m_hWnd, IDC_SHADEBOOST) == BST_CHECKED); } // Shade Boost Dialog @@ -551,7 +578,7 @@ void GSHacksDlg::OnInit() int renderer = SendMessage(hwnd_renderer, CB_GETITEMDATA, SendMessage(hwnd_renderer, CB_GETCURSEL, 0, 0), 0); // It can only be accessed with a HW renderer, so this is sufficient. bool dx9 = renderer == 0; - bool dx11 = renderer == 3; + // bool dx11 = renderer == 3; bool ogl = renderer == 12; unsigned short cb = 0; diff --git a/plugins/GSdx/GSdx.rc b/plugins/GSdx/GSdx.rc index c11a5c4ddc..3969b6f621 100644 --- a/plugins/GSdx/GSdx.rc +++ b/plugins/GSdx/GSdx.rc @@ -181,13 +181,13 @@ BEGIN CONTROL "Windowed",IDC_WINDOWED,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,129,157,49,10 END -IDD_CONFIG DIALOGEX 0, 0, 185, 391 +IDD_CONFIG DIALOGEX 0, 0, 185, 445 STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU CAPTION "GSdx Settings" FONT 8, "MS Shell Dlg", 400, 0, 0x1 BEGIN CONTROL IDB_LOGO10,IDC_LOGO11,"Static",SS_BITMAP | SS_REALSIZECONTROL,6,6,173,42 - DEFPUSHBUTTON "OK",IDOK,40,371,50,14 + DEFPUSHBUTTON "OK",IDOK,40,425,50,14 LTEXT "Renderer:",IDC_STATIC,6,72,34,8 COMBOBOX IDC_RENDERER,68,70,111,118,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP LTEXT "Interlacing (F5):",IDC_STATIC,6,101,53,8 @@ -197,41 +197,47 @@ BEGIN CONTROL "",IDC_RESX,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | UDS_NOTHOUSANDS,120,146,11,14 EDITTEXT IDC_RESY_EDIT,136,146,39,13,ES_AUTOHSCROLL | ES_NUMBER CONTROL "",IDC_RESY,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | UDS_NOTHOUSANDS,154,146,11,14 - LTEXT "Extra rendering threads:",IDC_STATIC,11,340,83,8 - EDITTEXT IDC_SWTHREADS_EDIT,94,337,35,13,ES_AUTOHSCROLL | ES_NUMBER - CONTROL "",IDC_SWTHREADS,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | UDS_NOTHOUSANDS,130,335,11,14 + LTEXT "Extra rendering threads:",IDC_STATIC,11,393,83,8 + EDITTEXT IDC_SWTHREADS_EDIT,94,390,35,13,ES_AUTOHSCROLL | ES_NUMBER + CONTROL "",IDC_SWTHREADS,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | UDS_NOTHOUSANDS,130,388,11,14 COMBOBOX IDC_UPSCALE_MULTIPLIER,94,130,81,98,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP RTEXT "Internal Resolution:",IDC_STATIC,11,132,79,8 - CONTROL "Edge Anti-aliasing (AA1)",IDC_AA1,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,11,354,93,10 - PUSHBUTTON "Cancel",IDCANCEL,95,371,50,14 + CONTROL "Edge Anti-aliasing (AA1)",IDC_AA1,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,11,407,93,10 + PUSHBUTTON "Cancel",IDCANCEL,95,425,50,14 CONTROL IDB_LOGO9,IDC_LOGO9,"Static",SS_BITMAP | SS_REALSIZECONTROL,6,6,173,44 CONTROL IDB_LOGOGL,IDC_LOGOGL,"Static",SS_BITMAP | SS_REALSIZECONTROL,6,6,173,42 GROUPBOX "Enhancements",IDC_STATIC,6,116,173,58,BS_CENTER - GROUPBOX "Software Mode Settings",IDC_STATIC,6,328,173,41,BS_CENTER - GROUPBOX "Hardware Mode Settings",IDC_STATIC,6,208,173,118,BS_CENTER - CONTROL "Logarithmic Z",IDC_LOGZ,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,11,297,58,8 - CONTROL "Alpha Correction",IDC_FBA,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,94,297,81,8 - CONTROL "Allow 8-Bit Textures",IDC_PALTEX,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,11,219,79,10 + GROUPBOX "Software Mode Settings",IDC_STATIC,6,381,173,41,BS_CENTER + GROUPBOX "Hardware Mode Settings",IDC_STATIC,6,261,173,118,BS_CENTER + CONTROL "Logarithmic Z",IDC_LOGZ,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,11,350,58,8 + CONTROL "Alpha Correction",IDC_FBA,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,94,350,81,8 + CONTROL "Allow 8-Bit Textures",IDC_PALTEX,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,11,272,79,10 CONTROL "Enable Shade Boost",IDC_SHADEBOOST,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,11,178,79,10 - CONTROL "Accurate Date",IDC_ACCURATE_DATE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,94,297,67,8 + CONTROL "Accurate Date",IDC_ACCURATE_DATE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,94,350,67,8 PUSHBUTTON "Settings...",IDC_SHADEBUTTON,94,176,81,14 - CONTROL "Enable HW Hacks",IDC_HACKS_ENABLED,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,11,281,71,10 - PUSHBUTTON "Configure Hacks...",IDC_HACKSBUTTON,94,279,81,14 + CONTROL "Enable HW Hacks",IDC_HACKS_ENABLED,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,11,334,71,10 + PUSHBUTTON "Configure Hacks...",IDC_HACKSBUTTON,94,332,81,14 LTEXT "Adapter:",IDC_STATIC,6,57,30,8 COMBOBOX IDC_ADAPTER,68,55,111,118,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP CONTROL "Enable FXAA",IDC_FXAA,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,11,194,61,10 CONTROL "Enable FX Shader",IDC_SHADER_FX,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,94,194,71,10 - RTEXT "Anisotropic Filtering:",IDC_AFCOMBO_TEXT,18,249,72,8 - COMBOBOX IDC_AFCOMBO,94,247,81,118,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + RTEXT "Anisotropic Filtering:",IDC_AFCOMBO_TEXT,18,302,72,8 + COMBOBOX IDC_AFCOMBO,94,300,81,118,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP LTEXT "OpenCL Device:",IDC_STATIC,6,86,52,8 COMBOBOX IDC_OPENCL_DEVICE,68,84,111,118,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP - CONTROL "Hardware Depth",IDC_TC_DEPTH,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,11,297,72,8 - COMBOBOX IDC_ACCURATE_BLEND_UNIT,94,309,81,63,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP - RTEXT "Blending Unit Accuracy:",IDC_ACCURATE_BLEND_UNIT_TEXT,11,311,79,10 - COMBOBOX IDC_CRC_LEVEL,94,263,81,63,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP - RTEXT "CRC Hack Level:",IDC_CRC_LEVEL_TEXT,36,265,54,8 - COMBOBOX IDC_FILTER,94,231,81,63,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP - RTEXT "Texture Filtering:",IDC_FILTER_TEXT,32,233,58,8 + CONTROL "Hardware Depth",IDC_TC_DEPTH,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,11,350,72,8 + COMBOBOX IDC_ACCURATE_BLEND_UNIT,94,362,81,63,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + RTEXT "Blending Unit Accuracy:",IDC_ACCURATE_BLEND_UNIT_TEXT,11,364,79,10 + COMBOBOX IDC_CRC_LEVEL,94,316,81,63,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + RTEXT "CRC Hack Level:",IDC_CRC_LEVEL_TEXT,36,318,54,8 + COMBOBOX IDC_FILTER,94,284,81,63,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + RTEXT "Texture Filtering:",IDC_FILTER_TEXT,32,286,58,8 + LTEXT "External Shader",IDC_STATIC,11,209,52,8 + EDITTEXT IDC_SHADER_FX_EDIT,11,219,113,14,ES_AUTOHSCROLL + PUSHBUTTON "Browse",IDC_SHADER_FX_BUTTON,128,219,47,14 + LTEXT "External Shader Config",IDC_STATIC,11,236,75,8 + PUSHBUTTON "Browse",IDC_SHADER_FX_CONF_BUTTON,128,246,47,14 + EDITTEXT IDC_SHADER_FX_CONF_EDIT,11,246,113,14,ES_AUTOHSCROLL END @@ -293,7 +299,7 @@ BEGIN VERTGUIDE, 94 VERTGUIDE, 175 TOPMARGIN, 6 - BOTTOMMARGIN, 385 + BOTTOMMARGIN, 439 HORZGUIDE, 194 HORZGUIDE, 297 END diff --git a/plugins/GSdx/resource.h b/plugins/GSdx/resource.h index 6b6ee02aea..c348e8414b 100644 --- a/plugins/GSdx/resource.h +++ b/plugins/GSdx/resource.h @@ -76,7 +76,13 @@ #define IDC_CRC_LEVEL 2071 #define IDC_CRC_LEVEL_TEXT 2072 #define IDC_TC_DEPTH 2073 -#define IDC_COLORSPACE 2075 +#define IDC_COLORSPACE 2074 +#define IDC_SHADER_FX_EDIT 2075 +#define IDC_SHADER_FX_CONF_EDIT 2076 +#define IDC_SHADER_FX_BUTTON 2077 +#define IDC_SHADER_FX_CONF_BUTTON 2078 +#define IDC_SHADER_FX_TEXT 2079 +#define IDC_SHADER_FX_CONF_TEXT 2080 #define IDR_CONVERT_FX 10000 #define IDR_TFX_FX 10001 #define IDR_MERGE_FX 10002 @@ -95,7 +101,7 @@ #ifndef APSTUDIO_READONLY_SYMBOLS #define _APS_NEXT_RESOURCE_VALUE 10013 #define _APS_NEXT_COMMAND_VALUE 32771 -#define _APS_NEXT_CONTROL_VALUE 2074 +#define _APS_NEXT_CONTROL_VALUE 2081 #define _APS_NEXT_SYMED_VALUE 5000 #endif #endif