11
|
1 #include "dialog/dlg_config.h"
|
|
2 #include "config.h" /* global config */
|
|
3 #include "plugin.h" /* update_rich_presence_details() */
|
|
4 #include "resource.h" /* TITLE_CHECK, ... */
|
|
5
|
|
6 #include <winuser.h>
|
|
7
|
|
8 #define conf_item_to_dlg(hwnd, cons, var) \
|
|
9 do { \
|
|
10 HWND checkboxHwnd = GetDlgItem(hwnd, cons); \
|
|
11 SendMessage(checkboxHwnd, BM_SETCHECK, (var) ? BST_CHECKED : BST_UNCHECKED, 0); \
|
|
12 } while (0);
|
|
13 #define dlg_item_to_conf(hwnd, cons, var) \
|
|
14 do { \
|
|
15 HWND checkboxHwnd = GetDlgItem(hwnd, cons); \
|
|
16 (var) = (SendMessage(checkboxHwnd, BM_GETCHECK, 0, 0) == BST_CHECKED); \
|
|
17 } while (0);
|
|
18 static void cfg_get_controls(HWND hWnd) {
|
|
19 dlg_item_to_conf(hWnd, TITLE_CHECK, config.display_title);
|
|
20 dlg_item_to_conf(hWnd, ALBUM_ART_CHECK, config.display_album_art);
|
|
21 dlg_item_to_conf(hWnd, ALBUM_NAME_CHECK, config.display_album_name);
|
|
22 dlg_item_to_conf(hWnd, ARTIST_NAME_CHECK, config.display_artist_name);
|
|
23 dlg_item_to_conf(hWnd, SONG_INFO_CHECK, config.display_song_info);
|
|
24 dlg_item_to_conf(hWnd, ELAPSED_TIME_CHECK, config.show_elapsed_time);
|
|
25 }
|
|
26
|
|
27 static void cfg_set_controls(HWND hWnd) {
|
|
28 conf_item_to_dlg(hWnd, TITLE_CHECK, config.display_title);
|
|
29 conf_item_to_dlg(hWnd, ALBUM_ART_CHECK, config.display_album_art);
|
|
30 conf_item_to_dlg(hWnd, ALBUM_NAME_CHECK, config.display_album_name);
|
|
31 conf_item_to_dlg(hWnd, ARTIST_NAME_CHECK, config.display_artist_name);
|
|
32 conf_item_to_dlg(hWnd, SONG_INFO_CHECK, config.display_song_info);
|
|
33 conf_item_to_dlg(hWnd, ELAPSED_TIME_CHECK, config.show_elapsed_time);
|
|
34 }
|
|
35 #undef conf_item_to_dlg
|
|
36 #undef dlg_item_to_conf
|
|
37
|
|
38 static void cfg_on_confirm_settings_dialog(HWND hWnd) {
|
|
39 cfg_get_controls(hWnd);
|
|
40 cfg_save(&config);
|
|
41 update_rich_presence_details();
|
|
42 }
|
|
43
|
|
44 BOOL CALLBACK cfg_win_proc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) {
|
|
45 switch (msg) {
|
|
46 case WM_INITDIALOG:
|
|
47 /* do nothing if this is a child window (tab page) callback, pass to the parent */
|
|
48 if (GetWindowLong(hWnd, GWL_STYLE) & WS_CHILD)
|
|
49 return FALSE;
|
|
50
|
|
51 cfg_set_controls(hWnd);
|
|
52 return TRUE;
|
|
53 case WM_COMMAND:
|
|
54 switch (LOWORD(wParam)) {
|
|
55 case IDOK:
|
|
56 cfg_on_confirm_settings_dialog(hWnd);
|
|
57 EndDialog(hWnd, 0);
|
|
58 return TRUE;
|
|
59 case IDCANCEL:
|
|
60 EndDialog(hWnd, 0);
|
|
61 return TRUE;
|
|
62 }
|
|
63 break;
|
|
64 default:
|
|
65 break;
|
|
66 }
|
|
67
|
|
68 return FALSE;
|
|
69 }
|