options_plugins.cpp 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. /** (c) Nullsoft, Inc. C O N F I D E N T I A L
  2. ** Filename:
  3. ** Project:
  4. ** Description:
  5. ** Author:
  6. ** Created:
  7. **/
  8. #include "main.h"
  9. #include "Options.h"
  10. #include "resource.h"
  11. static int CALLBACK WINAPI BrowseCallbackProc_VIS( HWND hwnd, UINT uMsg, LPARAM lParam, LPARAM lpData)
  12. {
  13. if (uMsg == BFFM_INITIALIZED)
  14. {
  15. SendMessageW(hwnd, BFFM_SETSELECTIONW, 1, (LPARAM)VISDIR);
  16. // this is not nice but it fixes the selection not working correctly on all OSes
  17. EnumChildWindows(hwnd, browseEnumProc, 0);
  18. }
  19. if (uMsg == WM_CREATE) SetWindowTextW(hwnd,getStringW(IDS_SELVISDIR,NULL,0));
  20. return 0;
  21. }
  22. static int CALLBACK WINAPI BrowseCallbackProc_DSP( HWND hwnd, UINT uMsg, LPARAM lParam, LPARAM lpData)
  23. {
  24. if (uMsg == BFFM_INITIALIZED)
  25. {
  26. SendMessageW(hwnd, BFFM_SETSELECTIONW, 1, (LPARAM)DSPDIR);
  27. // this is not nice but it fixes the selection not working correctly on all OSes
  28. EnumChildWindows(hwnd, browseEnumProc, 0);
  29. }
  30. if (uMsg == WM_CREATE) SetWindowTextW(hwnd,getStringW(IDS_SELDSPDIR,NULL,0));
  31. return 0;
  32. }
  33. void SetButtonText(HWND hwndDlg, int id, wchar_t* path)
  34. {
  35. HWND control = GetDlgItem(hwndDlg, id);
  36. HDC hdc = GetDC(control);
  37. RECT r = {0};
  38. wchar_t temp[MAX_PATH] = {0};
  39. lstrcpynW(temp, path, MAX_PATH);
  40. SelectObject(hdc, (HFONT)SendMessageW(control, WM_GETFONT, 0, 0));
  41. GetClientRect(control, &r);
  42. r.left += 5;
  43. r.right -= 5;
  44. DrawTextW(hdc, temp, -1, &r, DT_PATH_ELLIPSIS | DT_WORD_ELLIPSIS | DT_MODIFYSTRING);
  45. SetWindowTextW(control, temp);
  46. ReleaseDC(control, hdc);
  47. }
  48. INT_PTR CALLBACK PlugProc(HWND hwndDlg, UINT uMsg, WPARAM wParam,LPARAM lParam)
  49. {
  50. hi helpinfo[]={
  51. {IDC_VISDIR, IDS_P_PLUG_VISDIR},
  52. {IDC_DSPDIR, IDS_P_PLUG_DSPDIR},
  53. {IDC_VISPRIO, IDS_P_PLUG_PRIO},
  54. {IDC_AUTOEXEC, IDS_P_PLUG_AUTO},
  55. {IDC_DISVIS, IDS_P_PLUG_DIS},
  56. {IDC_SAFEMODE, IDS_P_PLUG_SAFEMODE},
  57. {IDC_SAFEMODEALWAYS, IDS_P_PLUG_SAFEMODEALWAYS},
  58. {IDC_CHECK1, IDS_P_PLUG_DISSEHVIS},
  59. {IDC_CHECK5, IDS_P_PLUG_DISSEHGEN},
  60. {IDC_CHECK6, IDS_P_PLUG_DISSEHDSP},
  61. };
  62. DO_HELP();
  63. if (uMsg == WM_INITDIALOG)
  64. {
  65. CheckDlgButton(hwndDlg, IDC_AUTOEXEC, config_visplugin_autoexec ? BST_CHECKED : BST_UNCHECKED);
  66. CheckDlgButton(hwndDlg, IDC_DISVIS, config_disvis ? BST_CHECKED : BST_UNCHECKED);
  67. CheckDlgButton(hwndDlg, IDC_CHECK1, (config_no_visseh & 1) ? BST_CHECKED : BST_UNCHECKED);
  68. CheckDlgButton(hwndDlg, IDC_CHECK6, (config_no_visseh & 2) ? BST_CHECKED : BST_UNCHECKED);
  69. CheckDlgButton(hwndDlg, IDC_CHECK5, (config_no_visseh & 4) ? BST_CHECKED : BST_UNCHECKED);
  70. CheckDlgButton(hwndDlg, IDC_SAFEMODEALWAYS, _r_i("safemode", 0) ? BST_CHECKED : BST_UNCHECKED);
  71. SendDlgItemMessage(hwndDlg, IDC_VISPRIO, TBM_SETRANGE, TRUE, MAKELONG(0, 4));
  72. SendDlgItemMessage(hwndDlg, IDC_VISPRIO, TBM_SETPOS, TRUE, config_visplugin_priority);
  73. SetDlgItemTextW(hwndDlg, IDC_VISDIR, VISDIR);
  74. SetButtonText(hwndDlg, IDC_VISDIR, VISDIR);
  75. SetDlgItemTextW(hwndDlg, IDC_DSPDIR, DSPDIR);
  76. SetButtonText(hwndDlg, IDC_DSPDIR, DSPDIR);
  77. if (g_safeMode)
  78. {
  79. SetDlgItemTextW(hwndDlg, IDC_SAFEMODE, getStringW(IDS_RESTART_NORMAL, NULL, 0));
  80. }
  81. }
  82. if (uMsg == WM_HSCROLL)
  83. {
  84. HWND swnd = (HWND)lParam;
  85. if (swnd == GetDlgItem(hwndDlg, IDC_VISPRIO))
  86. {
  87. config_visplugin_priority = (unsigned char) SendDlgItemMessage(hwndDlg, IDC_VISPRIO, TBM_GETPOS, 0, 0);
  88. vis_setprio();
  89. }
  90. }
  91. if (uMsg == WM_COMMAND)
  92. {
  93. switch (LOWORD(wParam))
  94. {
  95. case IDC_CHECK1:
  96. case IDC_CHECK5:
  97. case IDC_CHECK6:
  98. config_no_visseh =
  99. (IsDlgButtonChecked(hwndDlg, IDC_CHECK1) ? 1 : 0) |
  100. (IsDlgButtonChecked(hwndDlg, IDC_CHECK6) ? 2 : 0) |
  101. (IsDlgButtonChecked(hwndDlg, IDC_CHECK5) ? 4 : 0);
  102. break;
  103. case IDC_AUTOEXEC:
  104. config_visplugin_autoexec = IsDlgButtonChecked(hwndDlg, IDC_AUTOEXEC) ? 1 : 0;
  105. break;
  106. case IDC_DISVIS:
  107. config_disvis = IsDlgButtonChecked(hwndDlg, IDC_DISVIS) ? 1 : 0;
  108. break;
  109. case IDC_VISDIR:
  110. {
  111. BROWSEINFOW bi = {0};
  112. wchar_t name[MAX_PATH] = {0};
  113. bi.hwndOwner = hMainWindow;
  114. bi.pszDisplayName = name;
  115. bi.ulFlags = BIF_RETURNONLYFSDIRS | BIF_NEWDIALOGSTYLE;
  116. bi.lpfn = BrowseCallbackProc_VIS;
  117. ITEMIDLIST *idlist = SHBrowseForFolderW(&bi);
  118. if (idlist)
  119. {
  120. wchar_t path[MAX_PATH] = {0};
  121. SHGetPathFromIDListW(idlist, path);
  122. Shell_Free(idlist);
  123. lstrcpynW(VISDIR, path, MAX_PATH);
  124. SetDlgItemTextW(hwndDlg, IDC_VISDIR,VISDIR);
  125. _w_sW("VISDir", VISDIR);
  126. SetButtonText(hwndDlg, IDC_VISDIR, VISDIR);
  127. }
  128. }
  129. return FALSE;
  130. case IDC_DSPDIR:
  131. {
  132. BROWSEINFOW bi = {0};
  133. wchar_t name[MAX_PATH] = {0};
  134. bi.hwndOwner = hMainWindow;
  135. bi.pszDisplayName = name;
  136. bi.ulFlags = BIF_RETURNONLYFSDIRS | BIF_NEWDIALOGSTYLE;
  137. bi.lpfn = BrowseCallbackProc_DSP;
  138. ITEMIDLIST *idlist = SHBrowseForFolderW(&bi);
  139. if (idlist)
  140. {
  141. wchar_t path[MAX_PATH] = {0};
  142. SHGetPathFromIDListW(idlist, path);
  143. Shell_Free(idlist);
  144. lstrcpynW(DSPDIR, path, MAX_PATH);
  145. SetDlgItemTextW(hwndDlg, IDC_DSPDIR, DSPDIR);
  146. _w_sW("DSPDir", DSPDIR);
  147. SetButtonText(hwndDlg, IDC_DSPDIR, DSPDIR);
  148. }
  149. }
  150. return FALSE;
  151. case IDC_SAFEMODE:
  152. if (LPMessageBox(hwndDlg, IDS_RESTART_SAFE, IDS_RESTART, MB_YESNO | MB_ICONQUESTION | MB_TOPMOST) == IDYES)
  153. {
  154. _w_i("show_prefs", 30);
  155. PostMessageW(hMainWindow, WM_USER, 0, (!g_safeMode ? IPC_RESTARTSAFEWINAMP : IPC_RESTARTWINAMP));
  156. }
  157. return FALSE;
  158. case IDC_SAFEMODEALWAYS:
  159. {
  160. int mode = (IsDlgButtonChecked(hwndDlg, IDC_SAFEMODEALWAYS) ? 1 : 0);
  161. _w_i("safemode", mode);
  162. if (mode != !!g_safeMode)
  163. {
  164. if (LPMessageBox(hwndDlg, IDS_RESTART_SAFE, IDS_RESTART, MB_YESNO | MB_ICONQUESTION | MB_TOPMOST) == IDYES)
  165. {
  166. _w_i("show_prefs", 30);
  167. PostMessageW(hMainWindow, WM_USER, 0, (!g_safeMode ? IPC_RESTARTSAFEWINAMP : IPC_RESTARTWINAMP));
  168. }
  169. }
  170. return FALSE;
  171. }
  172. }
  173. }
  174. const int controls[] =
  175. {
  176. IDC_VISPRIO,
  177. };
  178. if (FALSE != DirectMouseWheel_ProcessDialogMessage(hwndDlg, uMsg, wParam, lParam, controls, ARRAYSIZE(controls)))
  179. return TRUE;
  180. return FALSE;
  181. } //audio