DXGL r838 - Code Review

Jump to navigation Jump to search
Repository:DXGL
Revision:r837‎ | r838 | r839 >
Date:23:38, 31 July 2018
Author:admin
Status:new
Tags:
Comment:
Display text for most Hacks tab items when not selected.
Modified paths:
  • /dxglcfg/dxglcfg.cpp (modified) (history)

Diff [purge]

Index: dxglcfg/dxglcfg.cpp
@@ -2362,6 +2362,24 @@
23632363 return TRUE;
23642364 }
23652365
 2366+LPCTSTR strDisabled = _T("Disabled");
 2367+LPCTSTR strEnabled = _T("Enabled");
 2368+LPCTSTR strExpandViewport[] =
 2369+{
 2370+ _T("512x448 to 640x480"),
 2371+ _T("512x480 to 640x480")
 2372+};
 2373+LPCTSTR strViewportCompare[] =
 2374+{
 2375+ _T("Match color"),
 2376+ _T("Color less than or equal"),
 2377+ _T("Color greater than or equal"),
 2378+ _T("Match palette entry"),
 2379+ _T("Palette less than or equal"),
 2380+ _T("Palette greater than or equal")
 2381+};
 2382+LPCTSTR strUnknown = _T("Unknown");
 2383+
23662384 void UpdateHacksControl(HWND hWnd, int DlgItem, int item)
23672385 {
23682386 TCHAR buffer[64];
@@ -2369,38 +2387,27 @@
23702388 {
23712389 case 0:
23722390 SendDlgItemMessage(hWnd, DlgItem, CB_RESETCONTENT, 0, 0);
2373 - _tcscpy(buffer, _T("Disabled"));
2374 - SendDlgItemMessage(hWnd, DlgItem, CB_ADDSTRING, 0, (LPARAM)buffer);
2375 - _tcscpy(buffer, _T("Enabled"));
2376 - SendDlgItemMessage(hWnd, DlgItem, CB_ADDSTRING, 0, (LPARAM)buffer);
 2391+ SendDlgItemMessage(hWnd, DlgItem, CB_ADDSTRING, 0, (LPARAM)strDisabled);
 2392+ SendDlgItemMessage(hWnd, DlgItem, CB_ADDSTRING, 0, (LPARAM)strEnabled);
23772393 if (tristate) SendDlgItemMessage(hWnd, DlgItem, CB_ADDSTRING, 0, (LPARAM)strdefault);
23782394 SetCombo(hWnd, DlgItem, cfg->HackCrop640480to640400, cfgmask->HackCrop640480to640400, tristate);
23792395 break;
23802396 case 1:
23812397 SendDlgItemMessage(hWnd, DlgItem, CB_RESETCONTENT, 0, 0);
2382 - _tcscpy(buffer, _T("Disabled"));
2383 - SendDlgItemMessage(hWnd, DlgItem, CB_ADDSTRING, 0, (LPARAM)buffer);
2384 - _tcscpy(buffer, _T("512x448 to 640x480"));
2385 - SendDlgItemMessage(hWnd, DlgItem, CB_ADDSTRING, 0, (LPARAM)buffer);
2386 - _tcscpy(buffer, _T("512x480 to 640x480"));
2387 - SendDlgItemMessage(hWnd, DlgItem, CB_ADDSTRING, 0, (LPARAM)buffer);
 2398+ SendDlgItemMessage(hWnd, DlgItem, CB_ADDSTRING, 0, (LPARAM)strDisabled);
 2399+ SendDlgItemMessage(hWnd, DlgItem, CB_ADDSTRING, 0, (LPARAM)strExpandViewport[0]);
 2400+ SendDlgItemMessage(hWnd, DlgItem, CB_ADDSTRING, 0, (LPARAM)strExpandViewport[1]);
23882401 if (tristate) SendDlgItemMessage(hWnd, DlgItem, CB_ADDSTRING, 0, (LPARAM)strdefault);
23892402 SetCombo(hWnd, DlgItem, cfg->HackAutoExpandViewport, cfgmask->HackAutoExpandViewport, tristate);
23902403 break;
23912404 case 2:
23922405 SendDlgItemMessage(hWnd, DlgItem, CB_RESETCONTENT, 0, 0);
2393 - _tcscpy(buffer, _T("Match color"));
2394 - SendDlgItemMessage(hWnd, DlgItem, CB_ADDSTRING, 0, (LPARAM)buffer);
2395 - _tcscpy(buffer, _T("Color less than or equal"));
2396 - SendDlgItemMessage(hWnd, DlgItem, CB_ADDSTRING, 0, (LPARAM)buffer);
2397 - _tcscpy(buffer, _T("Color greater than or equal"));
2398 - SendDlgItemMessage(hWnd, DlgItem, CB_ADDSTRING, 0, (LPARAM)buffer);
2399 - _tcscpy(buffer, _T("Match palette entry"));
2400 - SendDlgItemMessage(hWnd, DlgItem, CB_ADDSTRING, 0, (LPARAM)buffer);
2401 - _tcscpy(buffer, _T("Palette less than or equal"));
2402 - SendDlgItemMessage(hWnd, DlgItem, CB_ADDSTRING, 0, (LPARAM)buffer);
2403 - _tcscpy(buffer, _T("Palette greater than or equal"));
2404 - SendDlgItemMessage(hWnd, DlgItem, CB_ADDSTRING, 0, (LPARAM)buffer);
 2406+ SendDlgItemMessage(hWnd, DlgItem, CB_ADDSTRING, 0, (LPARAM)strViewportCompare[0]);
 2407+ SendDlgItemMessage(hWnd, DlgItem, CB_ADDSTRING, 0, (LPARAM)strViewportCompare[1]);
 2408+ SendDlgItemMessage(hWnd, DlgItem, CB_ADDSTRING, 0, (LPARAM)strViewportCompare[2]);
 2409+ SendDlgItemMessage(hWnd, DlgItem, CB_ADDSTRING, 0, (LPARAM)strViewportCompare[3]);
 2410+ SendDlgItemMessage(hWnd, DlgItem, CB_ADDSTRING, 0, (LPARAM)strViewportCompare[4]);
 2411+ SendDlgItemMessage(hWnd, DlgItem, CB_ADDSTRING, 0, (LPARAM)strViewportCompare[5]);
24052412 if (tristate) SendDlgItemMessage(hWnd, DlgItem, CB_ADDSTRING, 0, (LPARAM)strdefault);
24062413 SetCombo(hWnd, DlgItem, cfg->HackAutoExpandViewportCompare, cfgmask->HackAutoExpandViewportCompare, tristate);
24072414 break;
@@ -2408,19 +2415,15 @@
24092416 break;
24102417 case 4:
24112418 SendDlgItemMessage(hWnd, DlgItem, CB_RESETCONTENT, 0, 0);
2412 - _tcscpy(buffer, _T("Disabled"));
2413 - SendDlgItemMessage(hWnd, DlgItem, CB_ADDSTRING, 0, (LPARAM)buffer);
2414 - _tcscpy(buffer, _T("Enabled"));
2415 - SendDlgItemMessage(hWnd, DlgItem, CB_ADDSTRING, 0, (LPARAM)buffer);
 2419+ SendDlgItemMessage(hWnd, DlgItem, CB_ADDSTRING, 0, (LPARAM)strDisabled);
 2420+ SendDlgItemMessage(hWnd, DlgItem, CB_ADDSTRING, 0, (LPARAM)strEnabled);
24162421 if (tristate) SendDlgItemMessage(hWnd, DlgItem, CB_ADDSTRING, 0, (LPARAM)strdefault);
24172422 SetCombo(hWnd, DlgItem, cfg->HackNoTVRefresh, cfgmask->HackNoTVRefresh, tristate);
24182423 break;
24192424 case 5:
24202425 SendDlgItemMessage(hWnd, DlgItem, CB_RESETCONTENT, 0, 0);
2421 - _tcscpy(buffer, _T("Disabled"));
2422 - SendDlgItemMessage(hWnd, DlgItem, CB_ADDSTRING, 0, (LPARAM)buffer);
2423 - _tcscpy(buffer, _T("Enabled"));
2424 - SendDlgItemMessage(hWnd, DlgItem, CB_ADDSTRING, 0, (LPARAM)buffer);
 2426+ SendDlgItemMessage(hWnd, DlgItem, CB_ADDSTRING, 0, (LPARAM)strDisabled);
 2427+ SendDlgItemMessage(hWnd, DlgItem, CB_ADDSTRING, 0, (LPARAM)strEnabled);
24252428 if (tristate) SendDlgItemMessage(hWnd, DlgItem, CB_ADDSTRING, 0, (LPARAM)strdefault);
24262429 SetCombo(hWnd, DlgItem, cfg->HackSetCursor, cfgmask->HackSetCursor, tristate);
24272430 break;
@@ -2428,6 +2431,59 @@
24292432 break;
24302433 }
24312434 }
 2435+
 2436+void DrawHacksItemText(HDC hdc, RECT *r, int item)
 2437+{
 2438+ LPCTSTR str = strUnknown;
 2439+ switch (item)
 2440+ {
 2441+ case 0:
 2442+ if (!cfgmask->HackCrop640480to640400) str = strdefault;
 2443+ else
 2444+ {
 2445+ if (cfg->HackCrop640480to640400) str = strEnabled;
 2446+ else str = strDisabled;
 2447+ }
 2448+ break;
 2449+ case 1:
 2450+ if (!cfgmask->HackAutoExpandViewport) str = strdefault;
 2451+ else
 2452+ {
 2453+ if (cfg->HackAutoExpandViewport > 2) str = strUnknown;
 2454+ else if (cfg->HackAutoExpandViewport == 0) str = strDisabled;
 2455+ else str = strExpandViewport[cfg->HackAutoExpandViewport-1];
 2456+ }
 2457+ break;
 2458+ case 2:
 2459+ if (!cfgmask->HackAutoExpandViewportCompare) str = strdefault;
 2460+ else
 2461+ {
 2462+ if (cfg->HackAutoExpandViewportCompare > 5) str = strUnknown;
 2463+ else str = strViewportCompare[cfg->HackAutoExpandViewportCompare];
 2464+ }
 2465+ break;
 2466+ case 4:
 2467+ if (!cfgmask->HackNoTVRefresh) str = strdefault;
 2468+ else
 2469+ {
 2470+ if (cfg->HackNoTVRefresh) str = strEnabled;
 2471+ else str = strDisabled;
 2472+ }
 2473+ break;
 2474+ case 5:
 2475+ if (!cfgmask->HackSetCursor) str = strdefault;
 2476+ else
 2477+ {
 2478+ if (cfg->HackSetCursor) str = strEnabled;
 2479+ else str = strDisabled;
 2480+ }
 2481+ break;
 2482+ default:
 2483+ str = strUnknown;
 2484+ }
 2485+ DrawText(hdc, str, _tcslen(str), r, DT_LEFT | DT_SINGLELINE | DT_VCENTER);
 2486+}
 2487+
24322488 LRESULT CALLBACK HacksTabCallback(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
24332489 {
24342490 TCHAR str[64];
@@ -2557,6 +2613,11 @@
25582614 DrawText(drawitem->hDC, str, _tcslen(str), &drawitem->rcItem,
25592615 DT_LEFT | DT_SINGLELINE | DT_VCENTER);
25602616 drawitem->rcItem.left -= 1;
 2617+ if (hackstabitem == 3) GetWindowRect(GetDlgItem(GetDlgItem(hWnd, IDC_HACKSLIST), IDC_HACKSEDIT), &r);
 2618+ else GetWindowRect(GetDlgItem(GetDlgItem(hWnd, IDC_HACKSLIST), IDC_HACKSDROPDOWN), &r);
 2619+ memcpy(&r2, &drawitem->rcItem, sizeof(RECT));
 2620+ r2.left = r2.right - (r.right - r.left);
 2621+ DrawHacksItemText(drawitem->hDC, &r2, drawitem->itemID);
25612622 if (drawitem->itemState & ODS_FOCUS) DrawFocusRect(drawitem->hDC, &drawitem->rcItem);
25622623 SetTextColor(drawitem->hDC, OldTextColor);
25632624 SetBkColor(drawitem->hDC, OldBackColor);