DXGL r771 - Code Review

Jump to navigation Jump to search
Repository:DXGL
Revision:r770‎ | r771 | r772 >
Date:07:04, 7 December 2017
Author:admin
Status:new
Tags:
Comment:
Implement enabling and disabling edit controls for fixed scaling and custom resolution.
Implement fixed scaling in DXGL Config.
Modified paths:
  • /cfgmgr/cfgmgr.c (modified) (history)
  • /dxglcfg/dxglcfg.cpp (modified) (history)
  • /dxglcfg/dxglcfg.rc (modified) (history)
  • /dxglcfg/resource.h (modified) (history)

Diff [purge]

Index: cfgmgr/cfgmgr.c
@@ -696,7 +696,7 @@
697697 WriteDWORD(hKey, cfg->CustomResolutionY, cfgmask->CustomResolutionY, _T("CustomResolutionY"));
698698 WriteDWORD(hKey, cfg->CustomRefresh, cfgmask->CustomRefresh, _T("CustomRefresh"));
699699 WriteFloat(hKey, cfg->DisplayMultiplierX, cfgmask->DisplayMultiplierX, _T("DisplayMultiplierX"));
700 - WriteFloat(hKey, cfg->DisplayMultiplierY, cfgmask->DisplayMultiplierX, _T("DisplayMultiplierY"));
 700+ WriteFloat(hKey, cfg->DisplayMultiplierY, cfgmask->DisplayMultiplierY, _T("DisplayMultiplierY"));
701701 WriteDWORD(hKey,cfg->vsync,cfgmask->vsync,_T("VSync"));
702702 WriteDWORD(hKey,cfg->TextureFormat,cfgmask->TextureFormat,_T("TextureFormat"));
703703 WriteDWORD(hKey,cfg->TexUpload,cfgmask->TexUpload,_T("TexUpload"));
Index: dxglcfg/dxglcfg.cpp
@@ -537,6 +537,14 @@
538538 SendDlgItemMessage(hWnd,DlgItem,CB_SETCURSEL,value,0);
539539 }
540540
 541+void SetFloat3place(HWND hWnd, int DlgItem, float value, float mask)
 542+{
 543+ TCHAR number[32];
 544+ if(mask) _sntprintf(number, 31, _T("%.4g"), value);
 545+ else number[0] = 0;
 546+ SendDlgItemMessage(hWnd, DlgItem, WM_SETTEXT, 0, (LPARAM)number);
 547+}
 548+
541549 __inline DWORD EncodePrimaryScale(DWORD scale)
542550 {
543551 switch (scale)
@@ -631,6 +639,30 @@
632640 }
633641 }
634642
 643+float GetFloat(HWND hWnd, int dlgitem, float *mask)
 644+{
 645+ TCHAR buffer[32];
 646+ SendDlgItemMessage(hWnd, dlgitem, WM_GETTEXT, 32, (LPARAM)buffer);
 647+ if (buffer[0] == 0)
 648+ {
 649+ if (!current_app)
 650+ {
 651+ *mask = 1.0f;
 652+ return 1.0f;
 653+ }
 654+ else
 655+ {
 656+ *mask = 0.0f;
 657+ return 0.0f;
 658+ }
 659+ }
 660+ else
 661+ {
 662+ *mask = 1.0f;
 663+ return _ttof(buffer);
 664+ }
 665+}
 666+
635667 void GetPostScaleCombo(HWND hWnd, int DlgItem, float *x, float *y, float *maskx, float *masky)
636668 {
637669 TCHAR buffer[32];
@@ -1069,7 +1101,59 @@
10701102 cfg->scaler = GetCombo(hWnd, IDC_VIDMODE, &cfgmask->scaler);
10711103 EnableWindow(GetDlgItem(hDialog, IDC_APPLY), TRUE);
10721104 *dirty = TRUE;
 1105+ if (cfg->scaler == 8)
 1106+ {
 1107+ EnableWindow(GetDlgItem(hWnd, IDC_FIXEDSCALELABEL), TRUE);
 1108+ EnableWindow(GetDlgItem(hWnd, IDC_FIXEDSCALELABELX), TRUE);
 1109+ EnableWindow(GetDlgItem(hWnd, IDC_FIXEDSCALELABELY), TRUE);
 1110+ EnableWindow(GetDlgItem(hWnd, IDC_FIXEDSCALEX), TRUE);
 1111+ EnableWindow(GetDlgItem(hWnd, IDC_FIXEDSCALEY), TRUE);
 1112+ }
 1113+ else
 1114+ {
 1115+ EnableWindow(GetDlgItem(hWnd, IDC_FIXEDSCALELABEL), FALSE);
 1116+ EnableWindow(GetDlgItem(hWnd, IDC_FIXEDSCALELABELX), FALSE);
 1117+ EnableWindow(GetDlgItem(hWnd, IDC_FIXEDSCALELABELY), FALSE);
 1118+ EnableWindow(GetDlgItem(hWnd, IDC_FIXEDSCALEX), FALSE);
 1119+ EnableWindow(GetDlgItem(hWnd, IDC_FIXEDSCALEY), FALSE);
 1120+ }
 1121+ if ((cfg->scaler == 9) || (cfg->scaler == 10))
 1122+ {
 1123+ EnableWindow(GetDlgItem(hWnd, IDC_CUSTOMMODELABEL), TRUE);
 1124+ EnableWindow(GetDlgItem(hWnd, IDC_CUSTOMMODE), TRUE);
 1125+ EnableWindow(GetDlgItem(hWnd, IDC_SETMODE), TRUE);
 1126+ }
 1127+ else
 1128+ {
 1129+ EnableWindow(GetDlgItem(hWnd, IDC_CUSTOMMODELABEL), FALSE);
 1130+ EnableWindow(GetDlgItem(hWnd, IDC_CUSTOMMODE), FALSE);
 1131+ EnableWindow(GetDlgItem(hWnd, IDC_SETMODE), FALSE);
 1132+ }
10731133 break;
 1134+ case IDC_FIXEDSCALEX:
 1135+ if (HIWORD(wParam) == EN_CHANGE)
 1136+ {
 1137+ cfg->DisplayMultiplierX = GetFloat(hWnd, IDC_FIXEDSCALEX, &cfgmask->DisplayMultiplierX);
 1138+ EnableWindow(GetDlgItem(hDialog, IDC_APPLY), TRUE);
 1139+ *dirty = TRUE;
 1140+ }
 1141+ if (HIWORD(wParam) == EN_KILLFOCUS)
 1142+ {
 1143+ SetFloat3place(hWnd, IDC_FIXEDSCALEX, cfg->DisplayMultiplierX, cfgmask->DisplayMultiplierX);
 1144+ }
 1145+ break;
 1146+ case IDC_FIXEDSCALEY:
 1147+ if (HIWORD(wParam) == EN_CHANGE)
 1148+ {
 1149+ cfg->DisplayMultiplierY = GetFloat(hWnd, IDC_FIXEDSCALEY, &cfgmask->DisplayMultiplierY);
 1150+ EnableWindow(GetDlgItem(hDialog, IDC_APPLY), TRUE);
 1151+ *dirty = TRUE;
 1152+ }
 1153+ if (HIWORD(wParam) == EN_KILLFOCUS)
 1154+ {
 1155+ SetFloat3place(hWnd, IDC_FIXEDSCALEY, cfg->DisplayMultiplierY, cfgmask->DisplayMultiplierY);
 1156+ }
 1157+ break;
10741158 case IDC_SCALE:
10751159 cfg->scalingfilter = GetCombo(hWnd, IDC_SCALE, &cfgmask->scalingfilter);
10761160 EnableWindow(GetDlgItem(hDialog, IDC_APPLY), TRUE);
@@ -1799,6 +1883,37 @@
18001884 _tcscpy(buffer, _T("Custom size, centered"));
18011885 SendDlgItemMessage(hTabs[0], IDC_VIDMODE, CB_ADDSTRING, 10, (LPARAM)buffer);
18021886 SendDlgItemMessage(hTabs[0],IDC_VIDMODE,CB_SETCURSEL,cfg->scaler,0);
 1887+ if (cfg->scaler == 8)
 1888+ {
 1889+ EnableWindow(GetDlgItem(hTabs[0], IDC_FIXEDSCALELABEL), TRUE);
 1890+ EnableWindow(GetDlgItem(hTabs[0], IDC_FIXEDSCALELABELX), TRUE);
 1891+ EnableWindow(GetDlgItem(hTabs[0], IDC_FIXEDSCALELABELY), TRUE);
 1892+ EnableWindow(GetDlgItem(hTabs[0], IDC_FIXEDSCALEX), TRUE);
 1893+ EnableWindow(GetDlgItem(hTabs[0], IDC_FIXEDSCALEY), TRUE);
 1894+ }
 1895+ else
 1896+ {
 1897+ EnableWindow(GetDlgItem(hTabs[0], IDC_FIXEDSCALELABEL), FALSE);
 1898+ EnableWindow(GetDlgItem(hTabs[0], IDC_FIXEDSCALELABELX), FALSE);
 1899+ EnableWindow(GetDlgItem(hTabs[0], IDC_FIXEDSCALELABELY), FALSE);
 1900+ EnableWindow(GetDlgItem(hTabs[0], IDC_FIXEDSCALEX), FALSE);
 1901+ EnableWindow(GetDlgItem(hTabs[0], IDC_FIXEDSCALEY), FALSE);
 1902+ }
 1903+ if ((cfg->scaler == 9) || (cfg->scaler == 10))
 1904+ {
 1905+ EnableWindow(GetDlgItem(hTabs[0], IDC_CUSTOMMODELABEL), TRUE);
 1906+ EnableWindow(GetDlgItem(hTabs[0], IDC_CUSTOMMODE), TRUE);
 1907+ EnableWindow(GetDlgItem(hTabs[0], IDC_SETMODE), TRUE);
 1908+ }
 1909+ else
 1910+ {
 1911+ EnableWindow(GetDlgItem(hTabs[0], IDC_CUSTOMMODELABEL), FALSE);
 1912+ EnableWindow(GetDlgItem(hTabs[0], IDC_CUSTOMMODE), FALSE);
 1913+ EnableWindow(GetDlgItem(hTabs[0], IDC_SETMODE), FALSE);
 1914+ }
 1915+ // custom scale
 1916+ SetFloat3place(hTabs[0], IDC_FIXEDSCALEX, cfg->DisplayMultiplierX, cfgmask->DisplayMultiplierX);
 1917+ SetFloat3place(hTabs[0], IDC_FIXEDSCALEY, cfg->DisplayMultiplierY, cfgmask->DisplayMultiplierY);
18031918 // fullscreen window mode
18041919 _tcscpy(buffer, _T("Exclusive fullscreen"));
18051920 SendDlgItemMessage(hTabs[0], IDC_FULLMODE, CB_ADDSTRING, 0, (LPARAM)buffer);
@@ -2079,6 +2194,8 @@
20802195 /*_tcscpy(buffer, _T("Disable OpenGL errors (OpenGL 4.6+)"));
20812196 SendDlgItemMessage(hTabs[4], IDC_DEBUGLIST, LB_ADDSTRING, 0, (LPARAM)buffer);*/
20822197
 2198+ EnableWindow(GetDlgItem(hWnd, IDC_APPLY), FALSE);
 2199+
20832200 // Check install path
20842201 installpath = NULL;
20852202 error = RegOpenKeyEx(HKEY_LOCAL_MACHINE, _T("Software\\DXGL"), 0, KEY_READ, &hKey);
@@ -2436,6 +2553,36 @@
24372554 SetCheck(hTabs[0], IDC_COLOR, cfg->colormode, cfgmask->colormode, tristate);
24382555 SetCheck(hTabs[0], IDC_SINGLEBUFFER, cfg->SingleBufferDevice, cfgmask->SingleBufferDevice, tristate);
24392556 SetCombo(hTabs[1], IDC_POSTSCALE, cfg->postfilter, cfgmask->postfilter, tristate);
 2557+ if (cfg->scaler == 8)
 2558+ {
 2559+ EnableWindow(GetDlgItem(hTabs[0], IDC_FIXEDSCALELABEL), TRUE);
 2560+ EnableWindow(GetDlgItem(hTabs[0], IDC_FIXEDSCALELABELX), TRUE);
 2561+ EnableWindow(GetDlgItem(hTabs[0], IDC_FIXEDSCALELABELY), TRUE);
 2562+ EnableWindow(GetDlgItem(hTabs[0], IDC_FIXEDSCALEX), TRUE);
 2563+ EnableWindow(GetDlgItem(hTabs[0], IDC_FIXEDSCALEY), TRUE);
 2564+ }
 2565+ else
 2566+ {
 2567+ EnableWindow(GetDlgItem(hTabs[0], IDC_FIXEDSCALELABEL), FALSE);
 2568+ EnableWindow(GetDlgItem(hTabs[0], IDC_FIXEDSCALELABELX), FALSE);
 2569+ EnableWindow(GetDlgItem(hTabs[0], IDC_FIXEDSCALELABELY), FALSE);
 2570+ EnableWindow(GetDlgItem(hTabs[0], IDC_FIXEDSCALEX), FALSE);
 2571+ EnableWindow(GetDlgItem(hTabs[0], IDC_FIXEDSCALEY), FALSE);
 2572+ }
 2573+ if ((cfg->scaler == 9) || (cfg->scaler == 10))
 2574+ {
 2575+ EnableWindow(GetDlgItem(hTabs[0], IDC_CUSTOMMODELABEL), TRUE);
 2576+ EnableWindow(GetDlgItem(hTabs[0], IDC_CUSTOMMODE), TRUE);
 2577+ EnableWindow(GetDlgItem(hTabs[0], IDC_SETMODE), TRUE);
 2578+ }
 2579+ else
 2580+ {
 2581+ EnableWindow(GetDlgItem(hTabs[0], IDC_CUSTOMMODELABEL), FALSE);
 2582+ EnableWindow(GetDlgItem(hTabs[0], IDC_CUSTOMMODE), FALSE);
 2583+ EnableWindow(GetDlgItem(hTabs[0], IDC_SETMODE), FALSE);
 2584+ }
 2585+ SetFloat3place(hTabs[0], IDC_FIXEDSCALEX, cfg->DisplayMultiplierX, cfgmask->DisplayMultiplierX);
 2586+ SetFloat3place(hTabs[0], IDC_FIXEDSCALEY, cfg->DisplayMultiplierY, cfgmask->DisplayMultiplierY);
24402587 SetPostScaleCombo(hTabs[1], IDC_POSTSCALESIZE, cfg->postsizex, cfg->postsizey,
24412588 cfgmask->postsizex , cfgmask->postsizey, tristate);
24422589 SetCombo(hTabs[1], IDC_PRIMARYSCALE, cfg->primaryscale, cfgmask->primaryscale, tristate);
Index: dxglcfg/dxglcfg.rc
@@ -70,14 +70,14 @@
7171 COMBOBOX IDC_VSYNC, 114, 68, 102, 30, CBS_DROPDOWNLIST | CBS_HASSTRINGS, WS_EX_LEFT
7272 LTEXT "Fullscreen window mode", IDC_STATIC, 221, 57, 79, 9, SS_LEFT, WS_EX_LEFT
7373 COMBOBOX IDC_FULLMODE, 221, 68, 101, 30, CBS_DROPDOWNLIST | CBS_HASSTRINGS, WS_EX_LEFT
74 - LTEXT "Fixed scaling", IDC_FIXEDSCALELABEL, 7, 83, 47, 9, WS_DISABLED | SS_LEFT, WS_EX_LEFT
75 - LTEXT "X", IDC_FIXEDSCALELABELX, 7, 97, 8, 9, WS_DISABLED | SS_LEFT, WS_EX_LEFT
76 - EDITTEXT IDC_FIXEDSCALEX, 15, 94, 40, 14, WS_DISABLED | ES_AUTOHSCROLL, WS_EX_LEFT
77 - LTEXT "Y", IDC_FIXEDSCALELABELY, 57, 97, 8, 9, WS_DISABLED | SS_LEFT, WS_EX_LEFT
78 - EDITTEXT IDC_FIXEDSCALEY, 65, 94, 40, 14, WS_DISABLED | ES_AUTOHSCROLL, WS_EX_LEFT
79 - LTEXT "Custom resolution", 0, 114, 83, 58, 9, SS_LEFT, WS_EX_LEFT
80 - EDITTEXT IDC_CUSTOMMODE, 114, 94, 71, 14, WS_DISABLED | ES_AUTOHSCROLL, WS_EX_LEFT
81 - PUSHBUTTON "Select", IDC_SETMODE, 187, 94, 29, 14, WS_DISABLED, WS_EX_LEFT
 74+ LTEXT "Fixed scaling", IDC_FIXEDSCALELABEL, 7, 83, 47, 9, SS_LEFT, WS_EX_LEFT
 75+ LTEXT "X", IDC_FIXEDSCALELABELX, 7, 97, 8, 9, SS_LEFT, WS_EX_LEFT
 76+ EDITTEXT IDC_FIXEDSCALEX, 15, 94, 40, 14, ES_AUTOHSCROLL, WS_EX_LEFT
 77+ LTEXT "Y", IDC_FIXEDSCALELABELY, 57, 97, 8, 9, SS_LEFT, WS_EX_LEFT
 78+ EDITTEXT IDC_FIXEDSCALEY, 65, 94, 40, 14, ES_AUTOHSCROLL, WS_EX_LEFT
 79+ LTEXT "Custom resolution", IDC_CUSTOMMODELABEL, 114, 83, 58, 9, SS_LEFT, WS_EX_LEFT
 80+ EDITTEXT IDC_CUSTOMMODE, 114, 94, 71, 14, ES_AUTOHSCROLL, WS_EX_LEFT
 81+ PUSHBUTTON "Select", IDC_SETMODE, 187, 94, 29, 14, 0, WS_EX_LEFT
8282 AUTOCHECKBOX "Change display color depth", IDC_COLOR, 7, 113, 100, 10, 0, WS_EX_LEFT
8383 AUTOCHECKBOX "Single buffered display", IDC_SINGLEBUFFER, 114, 114, 87, 8, 0, WS_EX_LEFT
8484 }
Index: dxglcfg/resource.h
@@ -71,10 +71,11 @@
7272 #define IDC_FIXEDSCALEX 2012
7373 #define IDC_FIXEDSCALELABELY 2013
7474 #define IDC_FIXEDSCALEY 2014
75 -#define IDC_CUSTOMMODE 2015
76 -#define IDC_SETMODE 2016
77 -#define IDC_COLOR 2017
78 -#define IDC_SINGLEBUFFER 2018
 75+#define IDC_CUSTOMMODELABEL 2015
 76+#define IDC_CUSTOMMODE 2016
 77+#define IDC_SETMODE 2017
 78+#define IDC_COLOR 2018
 79+#define IDC_SINGLEBUFFER 2019
7980
8081 // Controls - Effects Tab
8182 #define IDC_POSTSCALE 2101