mirror of https://github.com/snes9xgit/snes9x.git
win32: Shaders: Save parameters and restore on cancel.
Also, change "Parameters" button to "Parameters..." to indicate it opens a dialog box. Adjust the spacing and remove the message about custom shader files.
This commit is contained in:
parent
b46a954874
commit
28d668fff7
|
@ -164,49 +164,59 @@ CShaderParamDlg::~CShaderParamDlg()
|
|||
|
||||
bool CShaderParamDlg::show()
|
||||
{
|
||||
saved_parameters = shader.param;
|
||||
|
||||
if(DialogBoxParam(GUI.hInstance, MAKEINTRESOURCE(IDD_DIALOG_SHADER_PARAMS), GUI.hWnd, DlgShaderParams, (LPARAM)this) == IDOK)
|
||||
{
|
||||
save_custom_shader();
|
||||
return true;
|
||||
}
|
||||
|
||||
shader.param = saved_parameters;
|
||||
WinRefreshDisplay();
|
||||
return false;
|
||||
}
|
||||
|
||||
void CShaderParamDlg::createContent(HWND hDlg)
|
||||
{
|
||||
#define LEFT_OFFSET 10
|
||||
#define TOP_OFFSET 10
|
||||
#define HORIZONTAL_SPACE 20
|
||||
#define VERTICAL_SPACE 15
|
||||
#define DESC_WIDTH_CHARS 50
|
||||
#define EDIT_WIDTH_CHARS 10
|
||||
|
||||
HWND parent = GetDlgItem(hDlg, IDC_STATIC_CONTAINER);
|
||||
// override static wndproc so we can handle the up/down messages, save original proc so we can forward everything else
|
||||
oldStaticProc = (WNDPROC)GetWindowLongPtr(parent, GWLP_WNDPROC);
|
||||
SetWindowLongPtr(parent, GWLP_WNDPROC, (LONG_PTR)WndProcContainerStatic);
|
||||
SetWindowLongPtr(parent, GWLP_USERDATA, (LONG_PTR)this);
|
||||
|
||||
unsigned int top = TOP_OFFSET;
|
||||
RECT clientRect;
|
||||
GetClientRect(parent, &clientRect);
|
||||
|
||||
const int HORIZONTAL_MARGIN = 10;
|
||||
const int VERTICAL_MARGIN = 10;
|
||||
const int HORIZONTAL_SPACE = 20;
|
||||
const int VERTICAL_SPACE = 5;
|
||||
|
||||
unsigned int desc_left = HORIZONTAL_MARGIN;
|
||||
unsigned int desc_width = (clientRect.right - clientRect.left) * 3 / 4 - desc_left - HORIZONTAL_SPACE / 2;
|
||||
unsigned int edit_left = desc_left + desc_width + HORIZONTAL_SPACE;
|
||||
unsigned int edit_width = clientRect.right - clientRect.left - edit_left - HORIZONTAL_MARGIN;
|
||||
unsigned int top = VERTICAL_MARGIN;
|
||||
|
||||
for(int i = 0; i < shader.param.size(); i++) {
|
||||
GLSLParam &p = shader.param[i];
|
||||
TCHAR desc[270];
|
||||
_stprintf(desc, TEXT("%s [%g-%g]"), (TCHAR*)_tFromChar(p.name), p.min, p.max);
|
||||
HWND item = CreateWindow(TEXT("STATIC"), desc, SS_LEFTNOWORDWRAP | WS_VISIBLE | WS_CHILD, LEFT_OFFSET, (INT)(top + avgCharHeight * 0.2), DESC_WIDTH_CHARS * avgCharWidth, avgCharHeight, parent, (HMENU)(UINT_PTR)(IDC_PARAMS_START_STATIC + i), GUI.hInstance, NULL);
|
||||
HWND item = CreateWindow(TEXT("STATIC"), desc, SS_LEFTNOWORDWRAP | WS_VISIBLE | WS_CHILD, desc_left, (INT)(top + avgCharHeight * 0.3), desc_width, avgCharHeight, parent, (HMENU)(UINT_PTR)(IDC_PARAMS_START_STATIC + i), GUI.hInstance, NULL);
|
||||
SendMessage(item, WM_SETFONT, (WPARAM)hFont, MAKELPARAM(FALSE, 0));
|
||||
TCHAR val[100];
|
||||
_stprintf(val, TEXT("%g"), p.val);
|
||||
unsigned int edit_left = LEFT_OFFSET + DESC_WIDTH_CHARS * avgCharWidth + HORIZONTAL_SPACE;
|
||||
item = CreateWindowEx(WS_EX_CLIENTEDGE, TEXT("EDIT"), val, ES_AUTOHSCROLL | WS_VISIBLE | WS_CHILD | WS_TABSTOP, edit_left , top, EDIT_WIDTH_CHARS * avgCharWidth, (INT)(avgCharHeight * 1.7), parent, (HMENU)(UINT_PTR)(IDC_PARAMS_START_EDIT + i), GUI.hInstance, NULL);
|
||||
item = CreateWindowEx(WS_EX_CLIENTEDGE, TEXT("EDIT"), val, ES_AUTOHSCROLL | WS_VISIBLE | WS_CHILD | WS_TABSTOP, edit_left , top, edit_width, (INT)(avgCharHeight * 1.7), parent, (HMENU)(UINT_PTR)(IDC_PARAMS_START_EDIT + i), GUI.hInstance, NULL);
|
||||
SendMessage(item, WM_SETFONT, (WPARAM)hFont, MAKELPARAM(FALSE, 0));
|
||||
|
||||
item = CreateWindow(UPDOWN_CLASS, NULL, WS_CHILDWINDOW | WS_VISIBLE | UDS_AUTOBUDDY | UDS_ALIGNRIGHT | UDS_ARROWKEYS | UDS_HOTTRACK, 0, 0, 0, 0, parent, (HMENU)(UINT_PTR)(IDC_PARAMS_START_UPDOWN + i), GUI.hInstance, NULL);
|
||||
SendMessage(item, UDM_SETRANGE, 0, MAKELONG(10, -10)); // we don't use this range, simply set it so the up arrow is positive and down arrow negative
|
||||
|
||||
top += avgCharHeight + VERTICAL_SPACE;
|
||||
top += (INT)(avgCharHeight * 1.7 + VERTICAL_SPACE);
|
||||
}
|
||||
|
||||
RECT clientRect, windowRect;
|
||||
RECT windowRect;
|
||||
GetClientRect(parent, &clientRect);
|
||||
HWND scrollbar = GetDlgItem(hDlg,IDC_SCROLLBAR_PARAMS);
|
||||
SCROLLINFO si = { 0 };
|
||||
|
|
|
@ -20,6 +20,7 @@ private:
|
|||
unsigned int avgCharWidth;
|
||||
unsigned int avgCharHeight;
|
||||
int scrollpos;
|
||||
std::vector<GLSLParam> saved_parameters;
|
||||
|
||||
WNDPROC oldStaticProc;
|
||||
|
||||
|
|
|
@ -540,9 +540,9 @@
|
|||
//
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||
#define _APS_NEXT_RESOURCE_VALUE 161
|
||||
#define _APS_NEXT_RESOURCE_VALUE 162
|
||||
#define _APS_NEXT_COMMAND_VALUE 40178
|
||||
#define _APS_NEXT_CONTROL_VALUE 3030
|
||||
#define _APS_NEXT_CONTROL_VALUE 3032
|
||||
#define _APS_NEXT_SYMED_VALUE 101
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
@ -222,7 +222,7 @@ BEGIN
|
|||
CONTROL "Reduce Input Lag",IDC_REDUCEINPUTLAG,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,11,118,76,10
|
||||
CONTROL "Scale messages with EPX if possible",IDC_MESSAGES_SCALE,
|
||||
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,187,162,153,10
|
||||
PUSHBUTTON "Parameters",IDC_SHADER_GLSL_PARAMETERS,112,222,49,12,WS_DISABLED
|
||||
PUSHBUTTON "Parameters...",IDC_SHADER_GLSL_PARAMETERS,112,222,60,12,WS_DISABLED
|
||||
END
|
||||
|
||||
IDD_CHEATER DIALOGEX 0, 0, 375, 194
|
||||
|
@ -540,17 +540,16 @@ BEGIN
|
|||
COMBOBOX IDC_HOSTNAME,60,5,110,40,CBS_DROPDOWN | WS_VSCROLL | WS_TABSTOP
|
||||
END
|
||||
|
||||
IDD_DIALOG_SHADER_PARAMS DIALOGEX 0, 0, 309, 205
|
||||
IDD_DIALOG_SHADER_PARAMS DIALOGEX 0, 0, 306, 204
|
||||
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "Shader Parameters"
|
||||
FONT 8, "MS Shell Dlg", 400, 0, 0x1
|
||||
BEGIN
|
||||
DEFPUSHBUTTON "OK",IDOK,144,184,50,14
|
||||
PUSHBUTTON "Cancel",IDCANCEL,198,184,50,14
|
||||
LTEXT "",IDC_STATIC_CONTAINER,7,35,282,142,WS_BORDER
|
||||
SCROLLBAR IDC_SCROLLBAR_PARAMS,289,35,12,142,SBS_VERT
|
||||
PUSHBUTTON "Apply",IDAPPLY,253,184,50,14
|
||||
LTEXT "Changing these parameters will create a new ""custom_shader_params.glslp / .slangp"" file in the snes9x directory that contains the parameters and references to your currently loaded shader. This will then be used as your current OpenGL shader.",IDC_STATIC,7,7,295,28
|
||||
PUSHBUTTON "OK",IDOK,144,186,50,14
|
||||
PUSHBUTTON "Cancel",IDCANCEL,198,186,50,14
|
||||
SCROLLBAR IDC_SCROLLBAR_PARAMS,288,6,12,174,SBS_VERT
|
||||
DEFPUSHBUTTON "Apply",IDAPPLY,252,186,50,14
|
||||
LTEXT "",IDC_STATIC_CONTAINER,6,6,282,174,WS_BORDER
|
||||
END
|
||||
|
||||
IDD_DIALOG_XAUDIO2_INIT_ERROR DIALOGEX 0, 0, 277, 92
|
||||
|
@ -701,9 +700,9 @@ BEGIN
|
|||
IDD_DIALOG_SHADER_PARAMS, DIALOG
|
||||
BEGIN
|
||||
LEFTMARGIN, 7
|
||||
RIGHTMARGIN, 302
|
||||
RIGHTMARGIN, 299
|
||||
TOPMARGIN, 7
|
||||
BOTTOMMARGIN, 198
|
||||
BOTTOMMARGIN, 197
|
||||
END
|
||||
|
||||
IDD_DIALOG_XAUDIO2_INIT_ERROR, DIALOG
|
||||
|
@ -757,6 +756,11 @@ BEGIN
|
|||
0
|
||||
END
|
||||
|
||||
IDD_DIALOG_SHADER_PARAMS AFX_DIALOG_LAYOUT
|
||||
BEGIN
|
||||
0
|
||||
END
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
|
|
Loading…
Reference in New Issue