DXGL r840 - Code Review

Jump to navigation Jump to search
Repository:DXGL
Revision:r839‎ | r840 | r841 >
Date:23:11, 3 August 2018
Author:admin
Status:new
Tags:
Comment:
Add edit box for auto expand viewport hack comparison value.
Detect if edit boxes have the "global default" string in them when checking their contents.
Modified paths:
  • /dxgl-example.ini (modified) (history)
  • /dxglcfg/dxglcfg.cpp (modified) (history)

Diff [purge]

Index: dxgl-example.ini
@@ -636,7 +636,10 @@
637637 ; This value is dependent on the color depth of the primary surface, and
638638 ; if using color comparison under 8-bit color uses the the 32-bit color of
639639 ; the pixel's palette lookup, or in value comparison uses the palette index
640 -; of the pixel.
 640+; of the pixel. For 15 and 16 bit modes, value comparison uses the exact
 641+; value in this option while color comparison uses the equivalent 24-bit
 642+; color value. Color values should be specified as RRGGBB, for instance
 643+; red would be 0xFF0000.
641644 ; Default is 0x0
642645 HackAutoExpandViewportValue=0x0
643646
Index: dxglcfg/dxglcfg.cpp
@@ -643,6 +643,15 @@
644644 }
645645 }
646646
 647+void SetRGBHex(HWND hWnd, int DlgItem, DWORD value, DWORD mask)
 648+{
 649+ TCHAR number[32];
 650+ if (mask) _sntprintf(number, 31, _T("%06X"), value);
 651+ else _tcscpy(number, strdefault);
 652+ EditInterlock = TRUE;
 653+ SendDlgItemMessage(hWnd, DlgItem, WM_SETTEXT, 0, (LPARAM)number);
 654+ EditInterlock = FALSE;
 655+}
647656
648657 void SetFloat3place(HWND hWnd, int DlgItem, float value, float mask)
649658 {
@@ -861,11 +870,35 @@
862871 }
863872 }
864873
 874+DWORD GetRGBHex(HWND hWnd, int dlgitem, DWORD *mask)
 875+{
 876+ TCHAR buffer[32];
 877+ SendDlgItemMessage(hWnd, dlgitem, WM_GETTEXT, 32, (LPARAM)buffer);
 878+ if ((buffer[0] == 0) || (!_tcsicmp(buffer, strdefaultshort)) || (!_tcsicmp(buffer, strdefault)))
 879+ {
 880+ if (!current_app)
 881+ {
 882+ *mask = 1;
 883+ return 1;
 884+ }
 885+ else
 886+ {
 887+ *mask = 0;
 888+ return 0;
 889+ }
 890+ }
 891+ else
 892+ {
 893+ *mask = 1;
 894+ return _tcstol(buffer, NULL, 16) & 0xFFFFFF;
 895+ }
 896+}
 897+
865898 float GetFloat(HWND hWnd, int dlgitem, float *mask)
866899 {
867900 TCHAR buffer[32];
868901 SendDlgItemMessage(hWnd, dlgitem, WM_GETTEXT, 32, (LPARAM)buffer);
869 - if (buffer[0] == 0)
 902+ if ((buffer[0] == 0) || (!_tcsicmp(buffer, strdefaultshort)) || (!_tcsicmp(buffer, strdefault)))
870903 {
871904 if (!current_app)
872905 {
@@ -889,7 +922,7 @@
890923 {
891924 TCHAR buffer[32];
892925 SendDlgItemMessage(hWnd, dlgitem, WM_GETTEXT, 32, (LPARAM)buffer);
893 - if (buffer[0] == 0)
 926+ if ((buffer[0] == 0) || (!_tcsicmp(buffer, strdefaultshort)) || (!_tcsicmp(buffer, strdefault)))
894927 {
895928 if (!usemask)
896929 {
@@ -2382,7 +2415,6 @@
23832416
23842417 void UpdateHacksControl(HWND hWnd, int DlgItem, int item)
23852418 {
2386 - TCHAR buffer[64];
23872419 switch (item)
23882420 {
23892421 case 0:
@@ -2435,6 +2467,7 @@
24362468 void DrawHacksItemText(HDC hdc, RECT *r, int item)
24372469 {
24382470 LPCTSTR str = strUnknown;
 2471+ TCHAR buffer[33];
24392472 switch (item)
24402473 {
24412474 case 0:
@@ -2462,6 +2495,14 @@
24632496 else str = strViewportCompare[cfg->HackAutoExpandViewportCompare];
24642497 }
24652498 break;
 2499+ case 3:
 2500+ if (!cfgmask->HackAutoExpandViewportValue) str = strdefault;
 2501+ else
 2502+ {
 2503+ _sntprintf(buffer, 32, _T("%06X"), cfg->HackAutoExpandViewportValue);
 2504+ str = buffer;
 2505+ }
 2506+ break;
24662507 case 4:
24672508 if (!cfgmask->HackNoTVRefresh) str = strdefault;
24682509 else
@@ -2517,6 +2558,21 @@
25182559 case WM_COMMAND:
25192560 switch (LOWORD(wParam))
25202561 {
 2562+ case IDC_HACKSEDIT:
 2563+ if (HIWORD(wParam) == EN_CHANGE)
 2564+ {
 2565+ if (!EditInterlock)
 2566+ {
 2567+ cfg->HackAutoExpandViewportValue = GetRGBHex(GetDlgItem(hWnd,IDC_HACKSLIST), IDC_HACKSEDIT, &cfgmask->HackAutoExpandViewportValue);
 2568+ EnableWindow(GetDlgItem(hDialog, IDC_APPLY), TRUE);
 2569+ *dirty = TRUE;
 2570+ }
 2571+ }
 2572+ if (HIWORD(wParam) == EN_KILLFOCUS)
 2573+ {
 2574+ SetRGBHex(GetDlgItem(hWnd, IDC_HACKSLIST), IDC_HACKSEDIT, cfg->HackAutoExpandViewportValue, cfgmask->HackAutoExpandViewportValue);
 2575+ }
 2576+ break;
25212577 case IDC_HACKSDROPDOWN:
25222578 switch (hackstabitem)
25232579 {
@@ -3408,6 +3464,8 @@
34093465 SendDlgItemMessage(hTabs[5], IDC_HACKSLIST, LB_ADDSTRING, 0, (LPARAM)buffer);
34103466 _tcscpy(buffer, _T("SetCursor hide visibility"));
34113467 SendDlgItemMessage(hTabs[5], IDC_HACKSLIST, LB_ADDSTRING, 0, (LPARAM)buffer);
 3468+ // Auto expand viewport hack value
 3469+ SetRGBHex(GetDlgItem(hTabs[5], IDC_HACKSLIST), IDC_HACKSEDIT, cfg->HackAutoExpandViewportValue, cfgmask->HackAutoExpandViewportValue);
34123470 // About text
34133471 _tcscpy(abouttext, _T("DXGL\r\nVersion "));
34143472 _tcscat(abouttext, _T(DXGLVERSTRING));
@@ -3910,6 +3968,7 @@
39113969 &cfgmask->DebugMaxGLVersionMajor, &cfgmask->DebugMaxGLVersionMinor, tristate, hWnd);
39123970 // Hacks tab
39133971 UpdateHacksControl(GetDlgItem(hTabs[5], IDC_HACKSLIST), IDC_HACKSDROPDOWN, hackstabitem);
 3972+ SetRGBHex(GetDlgItem(hTabs[5], IDC_HACKSLIST), IDC_HACKSEDIT, cfg->HackAutoExpandViewportValue, cfgmask->HackAutoExpandViewportValue);
39143973 RedrawWindow(GetDlgItem(hTabs[5], IDC_HACKSLIST), NULL, NULL, RDW_INVALIDATE);
39153974 }
39163975 break;