From 23f1620e16a13b064461e39a66fdada951c1d9e6 Mon Sep 17 00:00:00 2001 From: mskorokhod <30652217+mskorokhod@users.noreply.github.com> Date: Thu, 9 Jun 2022 19:41:38 +0300 Subject: [PATCH] {SEV-0015] Dark theme for the Client Manager (#16) --- src/Cedar/CM.c | 111 ++++++++++++++++++++++++++++---- src/Cedar/CMInner.h | 2 +- src/PenCore/PenCore.rc | 10 +-- src/bin/hamcore/strtable_en.stb | 4 +- src/bin/hamcore/strtable_ru.stb | 4 +- 5 files changed, 107 insertions(+), 24 deletions(-) diff --git a/src/Cedar/CM.c b/src/Cedar/CM.c index 32bc3e0d..8965e24b 100644 --- a/src/Cedar/CM.c +++ b/src/Cedar/CM.c @@ -571,6 +571,16 @@ void CmEasyDlgInit(HWND hWnd, CM_EASY_DLG *d) SetShow(hWnd, B_VGC, cm->Client->IsVgcSupported); + const HWND accountListView = GetDlgItem(hWnd, L_ACCOUNT); + const COLORREF outlineColor = RGB(94, 73, 116); + const COLORREF textColor = RGB(255, 255, 255); + const COLORREF backgroundColor = RGB(62, 62, 62); + const COLORREF textBackColor = RGB(56, 56, 56); + ListView_SetBkColor(accountListView, backgroundColor); + ListView_SetTextBkColor(accountListView, textBackColor); + ListView_SetTextColor(accountListView, textColor); + ListView_SetOutlineColor(accountListView, outlineColor); + CmEasyDlgRefresh(hWnd, d); num = LvNum(hWnd, L_ACCOUNT); @@ -694,12 +704,44 @@ void CmEasyDlgRefresh(HWND hWnd, CM_EASY_DLG *d) CmEasyDlgUpdate(hWnd, d); } +static BOOL CmEasyDrawItem(const WORD itemId, DRAWITEMSTRUCT* drawItem) +{ + switch(itemId) + { + case IDCANCEL: + case B_STATUS: + case B_VGC: + case IDOK: + { + SetBkMode(drawItem->hDC, TRANSPARENT); + SetTextColor(drawItem->hDC, RGB(255, 255, 255)); + const int textLen = GetWindowTextLengthA(drawItem->hwndItem); + char* text = (char*)malloc(textLen + 1); + GetWindowTextA(drawItem->hwndItem, text, textLen + 1); + DrawTextA(drawItem->hDC, text, textLen, &drawItem->rcItem, DT_CENTER | DT_VCENTER | DT_NOCLIP | DT_SINGLELINE | DT_MODIFYSTRING); + free(text); + break; + } + default: + return FALSE; + } + + return TRUE; +} + + // Dialog procedure of the simple connection manager -UINT CmEasyDlg(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam, void *param) +INT_PTR CmEasyDlg(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam, void *param) { CM_EASY_DLG *d = (CM_EASY_DLG *)param; NMHDR *n; UINT i; + + static HBRUSH dialogBrush = NULL; + static HBRUSH buttonBrush = NULL; + static HBRUSH connectButtonBrush = NULL; + static HBRUSH listboxBrush = NULL; + // Validate arguments if (hWnd == NULL) { @@ -711,6 +753,12 @@ UINT CmEasyDlg(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam, void *param) case WM_INITDIALOG: CmEasyDlgInit(hWnd, d); SetTimer(hWnd, 1, 10, NULL); + + dialogBrush = CreateSolidBrush(RGB(22, 22, 22)); + buttonBrush = CreateSolidBrush(RGB(50, 50, 50)); + connectButtonBrush = CreateSolidBrush(RGB(105, 0, 209)); + listboxBrush = CreateSolidBrush(RGB(58, 58, 58)); + break; case WM_TIMER: @@ -733,7 +781,7 @@ UINT CmEasyDlg(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam, void *param) break; case WM_NOTIFY: - n = (NMHDR *)lParam; + n = (NMHDR*)lParam; CmEasyDlgOnNotify(hWnd, d, n); break; @@ -741,7 +789,7 @@ UINT CmEasyDlg(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam, void *param) i = LvGetSelected(hWnd, L_ACCOUNT); if (i != INFINITE) { - wchar_t *s = LvGetStr(hWnd, L_ACCOUNT, i, 0); + wchar_t* s = LvGetStr(hWnd, L_ACCOUNT, i, 0); if (s != NULL) { UniStrCpy(cm->EasyLastSelectedAccountName, sizeof(cm->EasyLastSelectedAccountName), @@ -753,8 +801,52 @@ UINT CmEasyDlg(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam, void *param) { Zero(cm->EasyLastSelectedAccountName, sizeof(cm->EasyLastSelectedAccountName)); } + + DeleteObject(dialogBrush); + DeleteObject(buttonBrush); + DeleteObject(connectButtonBrush); + DeleteObject(listboxBrush); + + dialogBrush = NULL; + buttonBrush = NULL; + connectButtonBrush = NULL; + listboxBrush = NULL; + EndDialog(hWnd, false); + break; + case WM_DRAWITEM: + { + return (INT_PTR)CmEasyDrawItem((WORD)wParam, (DRAWITEMSTRUCT*)lParam); + } + case WM_CTLCOLORDLG: + { + return (INT_PTR)dialogBrush; + } + case WM_CTLCOLORBTN: + { + const int id = GetDlgCtrlID((HWND)lParam); + if (id == IDOK) + { + return (INT_PTR)connectButtonBrush; + } + else + { + return (INT_PTR)buttonBrush; + } + + } + case WM_CTLCOLORSCROLLBAR: + { + return (INT_PTR)dialogBrush; + } + case WM_CTLCOLORSTATIC: + { + HDC hdc = (HDC)wParam; + SetTextColor(hdc, RGB(255, 255, 255)); + SetBkColor(hdc, RGB(22, 22, 22)); + return (INT_PTR)dialogBrush; + } } return 0; @@ -781,7 +873,7 @@ void CmMainWindowOnShowEasy(HWND hWnd) return; } - Dialog(NULL, D_CM_EASY, CmEasyDlg, &d); + DialogEx(NULL, D_CM_EASY, CmEasyDlg, &d, false); cm->hEasyWnd = NULL; } @@ -10488,16 +10580,7 @@ void CmRefreshAccountListEx2(HWND hWnd, bool easy, bool style_changed) // Switching of icon / detail view LvSetView(hWnd, L_ACCOUNT, cm->IconView == false || easy); - - // Show grid - if (cm->ShowGrid || easy) - { - LvSetStyle(hWnd, L_ACCOUNT, LVS_EX_GRIDLINES); - } - else - { - LvRemoveStyle(hWnd, L_ACCOUNT, LVS_EX_GRIDLINES); - } + LvRemoveStyle(hWnd, L_ACCOUNT, LVS_EX_GRIDLINES); if (style_changed) { diff --git a/src/Cedar/CMInner.h b/src/Cedar/CMInner.h index e27c3566..bcae9793 100644 --- a/src/Cedar/CMInner.h +++ b/src/Cedar/CMInner.h @@ -532,7 +532,7 @@ void CmMainWindowOnTrayClicked(HWND hWnd, WPARAM wParam, LPARAM lParam); void CmShowEasy(); void CmCloseEasy(); void CmMainWindowOnShowEasy(HWND hWnd); -UINT CmEasyDlg(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam, void *param); +INT_PTR CmEasyDlg(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam, void *param); void CmEasyDlgInit(HWND hWnd, CM_EASY_DLG *d); void CmEasyDlgUpdate(HWND hWnd, CM_EASY_DLG *d); void CmEasyDlgRefresh(HWND hWnd, CM_EASY_DLG *d); diff --git a/src/PenCore/PenCore.rc b/src/PenCore/PenCore.rc index 5f8aca36..d87c8f06 100644 --- a/src/PenCore/PenCore.rc +++ b/src/PenCore/PenCore.rc @@ -3720,19 +3720,19 @@ BEGIN END D_CM_EASY DIALOGEX 0, 0, 307, 223 -STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU +STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_MINIMIZEBOX | WS_POPUP | WS_SYSMENU CAPTION "@D_CM_EASY" FONT 9, "MS Shell Dlg", 400, 0, 0x80 BEGIN CONTROL ICO_TRAY1,IDC_STATIC,"Static",SS_BITMAP,0,0,308,46 LTEXT "@S_TITLE",S_TITLE,12,52,267,17 CONTROL "",L_ACCOUNT,"SysListView32",LVS_REPORT | LVS_SHOWSELALWAYS | LVS_SHAREIMAGELISTS | LVS_AUTOARRANGE | LVS_EDITLABELS | LVS_NOCOLUMNHEADER | WS_BORDER | WS_TABSTOP,7,88,293,82 - PUSHBUTTON "--BUTTON--",IDOK,92,173,123,21 + PUSHBUTTON "--BUTTON--",IDOK,92,173,123,21,BS_OWNERDRAW LTEXT "--INFO--",S_INFO,12,72,288,14 CONTROL "",IDC_STATIC,"Static",SS_ETCHEDHORZ,7,198,294,1 - PUSHBUTTON "@IDCANCEL",IDCANCEL,247,203,53,16 - PUSHBUTTON "@B_STATUS",B_STATUS,216,176,84,16 - PUSHBUTTON "@B_VGC",B_VGC,112,203,84,16 + PUSHBUTTON "@IDCANCEL",IDCANCEL,247,203,53,16,BS_OWNERDRAW + PUSHBUTTON "@B_STATUS",B_STATUS,216,176,84,16,BS_OWNERDRAW + PUSHBUTTON "@B_VGC",B_VGC,112,203,84,16,BS_OWNERDRAW END D_SM_SETUP DIALOGEX 0, 0, 447, 311 diff --git a/src/bin/hamcore/strtable_en.stb b/src/bin/hamcore/strtable_en.stb index 2ea94bd2..f8fff387 100644 --- a/src/bin/hamcore/strtable_en.stb +++ b/src/bin/hamcore/strtable_en.stb @@ -992,11 +992,11 @@ CM_IMPORT_MESSAGE From file "%S", GAMING LAUNCHER Connection Setting "%s" has b CM_VLAN_CREATING Creating a new Virtual Network Adapter for Windows. \r\n\r\nThis process can take several seconds or over a minute. \r\nPlease wait...\r\n\r\n(Please do not perform other operations while the Virtual Network Adapter is being installed.) CM_SETTING_PASSWORD The setting is locked. To remove the setting-locker, you must enter a password. CM_EASY_MODE_NOT_ON_REMOTE Unable to connect because of the GAMING LAUNCHER Client on the remote computer is running in Easy Mode. -CM_EASY_CONNECT_BUTTON_1 Start GAMING LAUNCHER &Connection +CM_EASY_CONNECT_BUTTON_1 Start &Connection CM_EASY_CONNECT_BUTTON_2 &Disconnect CM_EASY_ACCOUNT_WARNING You can only modify Proxy Server Setting, User Authentication and Virtual Network Adapter Used because the setting has been locked. CM_EASY_INFO_1 Select a GAMING LAUNCHER connection. -CM_EASY_INFO_2 Click Start GAMING LAUNCHER Connection to start a Game connection. +CM_EASY_INFO_2 Click Start Connection to start a Game connection. CM_EASY_INFO_3 GAMING LAUNCHER connection is active. You can disconnect by clicking Disconnect. CM_EXT_VOICE_MSG It is possible that some of the voice message contents of the Extension Voice Guide has not been played normally. \r\nIs the Extension Voice Guide enabled? CM_EASY_TITLE GAMING LAUNCHER Connection Manager diff --git a/src/bin/hamcore/strtable_ru.stb b/src/bin/hamcore/strtable_ru.stb index aef659ae..3b83d77e 100644 --- a/src/bin/hamcore/strtable_ru.stb +++ b/src/bin/hamcore/strtable_ru.stb @@ -991,11 +991,11 @@ CM_IMPORT_MESSAGE From file "%S", GAMING LAUNCHER Connection Setting "%s" has b CM_VLAN_CREATING Creating a new Virtual Network Adapter for Windows. \r\n\r\nThis process can take several seconds or over a minute. \r\nPlease wait...\r\n\r\n(Please do not perform other operations while the Virtual Network Adapter is being installed.) CM_SETTING_PASSWORD The setting is locked. To remove the setting-locker, you must enter a password. CM_EASY_MODE_NOT_ON_REMOTE Unable to connect because of the GAMING LAUNCHER Client on the remote computer is running in Easy Mode. -CM_EASY_CONNECT_BUTTON_1 Start GAMING LAUNCHER &Connection +CM_EASY_CONNECT_BUTTON_1 Start &Connection CM_EASY_CONNECT_BUTTON_2 &Disconnect CM_EASY_ACCOUNT_WARNING You can only modify Proxy Server Setting, User Authentication and Virtual Network Adapter Used because the setting has been locked. CM_EASY_INFO_1 Select a GAMING LAUNCHER connection. -CM_EASY_INFO_2 Click Start GAMING LAUNCHER Connection to start a connection. +CM_EASY_INFO_2 Click Start Connection to start a connection. CM_EASY_INFO_3 GAMING LAUNCHER connection is active. You can disconnect by clicking Disconnect. CM_EXT_VOICE_MSG It is possible that some of the voice message contents of the Extension Voice Guide has not been played normally. \r\nIs the Extension Voice Guide enabled? CM_EASY_TITLE GAMING LAUNCHER Connection Manager