main_command.cpp 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916
  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 "../Plugins/General/gen_crasher/GetWinVer.h"
  10. #include "resource.h"
  11. #include "../Plugins/General/gen_ml/ml.h"
  12. #include "../nu/AutoWide.h"
  13. #include "api.h"
  14. #include "ExplorerFindFile.h"
  15. #include <assert.h>
  16. #include "vis.h"
  17. LRESULT sendMlIpc(int msg, WPARAM param);
  18. int g_open_ml_item_in_pe = 0;
  19. EXTERN_C BOOL eggTyping;
  20. void showLibrary()
  21. {
  22. SendMessageW(hMainWindow, WM_COMMAND, ID_FILE_SHOWLIBRARY, 0);
  23. }
  24. static void ToggleWindowShade_PL()
  25. {
  26. if (config_pe_height == 14)
  27. {
  28. if (config_pe_height_ws < 116) config_pe_height_ws = 116;
  29. config_pe_height = config_pe_height_ws;
  30. config_pe_height_ws = 0;
  31. }
  32. else
  33. {
  34. config_pe_height_ws = config_pe_height;
  35. config_pe_height = 14;
  36. }
  37. set_aot(1);
  38. }
  39. static void ToggleWindowShade_EQ()
  40. {
  41. config_eq_ws = !config_eq_ws;
  42. set_aot(1);
  43. draw_eq_tbar(GetForegroundWindow() == hEQWindow ? 1 : (config_hilite ? 0 : 1));
  44. }
  45. static void ToggleWindowShade_Main()
  46. {
  47. config_windowshade = !config_windowshade;
  48. set_aot(1);
  49. draw_tbar(1, config_windowshade, eggstat);
  50. SendMessageW(hMainWindow, WM_TIMER, UPDATE_DISPLAY_TIMER + 4, 0);
  51. sa_setthread(config_sa);
  52. }
  53. // Big nasty command handler.
  54. // it calls Main_OnButtonX() for the button controls
  55. LRESULT Main_OnCommand(HWND hwnd, int wID, HWND hwndCtl, UINT codeNotify)
  56. {
  57. if (codeNotify == THBN_CLICKED && !atti_present)
  58. {
  59. switch (wID)
  60. {
  61. case 0: //previous
  62. {
  63. wID = WINAMP_BUTTON1;
  64. }
  65. break;
  66. case 1: //play
  67. {
  68. wID = WINAMP_BUTTON2;
  69. }
  70. break;
  71. case 2: //pause
  72. {
  73. wID = WINAMP_BUTTON3;
  74. }
  75. break;
  76. case 3: //stop
  77. {
  78. wID = WINAMP_BUTTON4;
  79. }
  80. break;
  81. case 4: //next
  82. {
  83. wID = WINAMP_BUTTON5;
  84. }
  85. break;
  86. default:
  87. return 1;
  88. }
  89. }
  90. if (1 == codeNotify && eggTyping)
  91. {
  92. BYTE kb[256] = {0};
  93. if(GetKeyboardState(kb))
  94. {
  95. for (INT i = 0x30; i < 0x87; i++)
  96. {
  97. if (0 != (0x80 & kb[i]))
  98. SendMessageW(hwnd, WM_KEYDOWN, i, 0L);
  99. }
  100. if (0 != (0x80 & kb[0x20]))
  101. SendMessageW(hwnd, WM_KEYDOWN, 0x20, 0L);
  102. }
  103. }
  104. if (LOWORD(wID) >= 34768 && LOWORD(wID) < g_BookmarkTop)
  105. {
  106. FILE *fp = _wfopen(BOOKMARKFILE8, L"rt");
  107. if (fp)
  108. {
  109. int x = 0, id = LOWORD(wID)-34768;
  110. for (;;)
  111. {
  112. char ft[4096] = {0}, fn[MAX_PATH] = {0};
  113. fgets(fn, MAX_PATH, fp);
  114. if (feof(fp)) break;
  115. fgets(ft, 4096, fp);
  116. if (feof(fp)) break;
  117. if (ft[0] && fn[0])
  118. {
  119. if (fn[lstrlenA(fn) - 1] == '\n') fn[lstrlenA(fn) - 1] = 0;
  120. if (ft[lstrlenA(ft) - 1] == '\n') ft[lstrlenA(ft) - 1] = 0;
  121. if (ft[0] && fn[0])
  122. {
  123. if (x++ == id)
  124. {
  125. // this will track the gen_ml or main play/enqueue setting
  126. // done as something which koopa requested back in 09/2011
  127. // including following 'shift' to invert the default mode.
  128. int addtolist, enqplay = 0;
  129. if (got_ml)
  130. {
  131. enqplay = GetPrivateProfileIntW(L"MLEnqPlay", L"enqueuedef", -1, INI_FILE);
  132. if (enqplay != -1)
  133. {
  134. addtolist = (!!enqplay) ^ (!!(GetAsyncKeyState(VK_SHIFT)&0x8000));
  135. }
  136. else
  137. {
  138. addtolist = (!!GetPrivateProfileIntW(L"gen_ml_config", L"enqueuedef", 0, ML_INI_FILE)) ^ (!!(GetAsyncKeyState(VK_SHIFT)&0x8000));
  139. }
  140. }
  141. else
  142. addtolist = (!!config_addtolist) ^ (!!(GetAsyncKeyState(VK_SHIFT)&0x8000));
  143. if(!addtolist) PlayList_delete();
  144. PlayList_appendthing(AutoWideDup(fn, CP_UTF8), 0, 0);
  145. if(!addtolist)
  146. {
  147. if (config_shuffle) PlayList_setposition(PlayList_getNextPosition());
  148. else PlayList_setposition(0);
  149. PlayList_getcurrent(FileName, FileTitle, FileTitleNum);
  150. }
  151. else
  152. {
  153. if (enqplay == 2) PlayList_setposition(PlayList_getlength());
  154. }
  155. plEditRefresh();
  156. if(!addtolist || enqplay == 2)
  157. StartPlaying();
  158. break;
  159. }
  160. }
  161. }
  162. }
  163. fclose(fp);
  164. }
  165. return 1;
  166. }
  167. if (LOWORD(wID) >= 32767 && LOWORD(wID) < g_SkinTop)
  168. {
  169. wchar_t curfilename[MAX_PATH] = {0};
  170. int id = LOWORD(wID);
  171. if (id >= 32768)
  172. {
  173. MENUITEMINFOW mi = {sizeof(mi), MIIM_DATA | MIIM_TYPE, MFT_STRING};
  174. mi.dwTypeData = curfilename;
  175. mi.cch = MAX_PATH;
  176. GetMenuItemInfoW(main_menu, id, FALSE, &mi);
  177. if (mi.dwItemData == 1)
  178. StringCchCatW(curfilename, MAX_PATH, L".zip");
  179. else if (mi.dwItemData == 2)
  180. StringCchCatW(curfilename, MAX_PATH, L".wsz");
  181. else if (mi.dwItemData == 4)
  182. StringCchCatW(curfilename, MAX_PATH, L".wal");
  183. }
  184. if (_wcsicmp(config_skin, curfilename))
  185. {
  186. StringCchCopyW(config_skin, MAX_PATH, curfilename);
  187. SendMessageW(hMainWindow, WM_COMMAND, WINAMP_REFRESHSKIN, 0);
  188. if (prefs_last_page == 40 && IsWindow(prefs_hwnd))
  189. {
  190. prefs_last_page = 0;
  191. prefs_dialog(1);
  192. prefs_last_page = 40;
  193. prefs_dialog(1);
  194. }
  195. }
  196. return 1;
  197. }
  198. if (LOWORD(wID) >= 34700 && LOWORD(wID) < g_LangTop && config_wlz_menu)
  199. {
  200. wchar_t curfilename[MAX_PATH]={0};
  201. int id = LOWORD(wID);
  202. if (id >= 34701)
  203. {
  204. MENUITEMINFOW mi = {sizeof(mi), MIIM_DATA | MIIM_TYPE, MFT_STRING};
  205. mi.dwTypeData = curfilename;
  206. mi.cch = MAX_PATH;
  207. GetMenuItemInfoW(main_menu, id, FALSE, &mi);
  208. if (mi.dwItemData == 1)
  209. StringCchCatW(curfilename, MAX_PATH, L".zip");
  210. else if (mi.dwItemData == 2)
  211. StringCchCatW(curfilename, MAX_PATH, L".wlz");
  212. }
  213. if (_wcsicmp(config_langpack, curfilename))
  214. {
  215. LangSwitchToLangPrompt(hMainWindow, curfilename);
  216. }
  217. return 1;
  218. }
  219. if (LOWORD(wID) >= 45000 && LOWORD(wID) < 55000)
  220. {
  221. int id = LOWORD(wID);
  222. HWND mlhwnd = (HWND)sendMlIpc(0, 0);
  223. if (mlhwnd != NULL)
  224. {
  225. if (!g_open_ml_item_in_pe && !IsWindowVisible(mlhwnd))
  226. SendMessageW(hMainWindow, WM_COMMAND, ID_FILE_SHOWLIBRARY, 0);
  227. // should switching the ml view to the target be disabled if we only want to play the playlist entry in the pe ?
  228. if (!g_open_ml_item_in_pe)
  229. SendMessageW(mlhwnd, WM_ML_IPC, id - 45000, ML_IPC_SETCURTREEITEM);
  230. }
  231. return 1;
  232. }
  233. switch (LOWORD(wID))
  234. {
  235. case ID_HELP_HELPTOPICS:
  236. myOpenURL(hwnd, L"https://help.winamp.com/hc/sections/8103009633300-Winamp-Desktop-Player-");
  237. break;
  238. case ID_HELP_FEEDBACK:
  239. {
  240. wchar_t url[512] = {0}, winVer[32] = {0}, build[32] = {0};
  241. int nWinVer = 0;
  242. GetWinVer(winVer, &nWinVer, build);
  243. // May 2022 - this services url is dead and we currently don't have a replacement
  244. StringCchPrintfW(url, 512, L"http://services.winamp.com/redirect/support?reason=Feedback&subject=Winamp Feedback&product=Winamp Desktop&v=%s Build %d&platform=%s (%s)",
  245. WIDEN(APP_VERSION), BUILD_NUMBER, winVer, build);
  246. myOpenURL(hwnd, url);
  247. break;
  248. }
  249. case ID_VIS_NEXT:
  250. case ID_VIS_PREV:
  251. case ID_VIS_RANDOM:
  252. case ID_VIS_FS:
  253. case ID_VIS_CFG:
  254. case ID_VIS_MENU:
  255. if (hExternalVisWindow != NULL)
  256. SendMessageW(hExternalVisWindow, WM_COMMAND, LOWORD(wID) | (codeNotify << 16), 0);
  257. break;
  258. case EQ_ENABLE:
  259. case IDM_EQ_LOADPRE:
  260. case IDM_EQ_LOADMP3:
  261. case IDM_EQ_LOADDEFAULT:
  262. case ID_LOAD_EQF:
  263. case IDM_EQ_SAVEPRE:
  264. case IDM_EQ_SAVEMP3:
  265. case IDM_EQ_SAVEDEFAULT:
  266. case ID_SAVE_EQF:
  267. case IDM_EQ_DELPRE:
  268. case IDM_EQ_DELMP3:
  269. return SendMessageW(hEQWindow, WM_COMMAND, LOWORD(wID), 0);
  270. case ID_POST_PLAY_PLAYLIST: g_open_ml_item_in_pe = 0; return 0;
  271. case ID_MAIN_PLAY_AUDIOCD:
  272. case ID_MAIN_PLAY_AUDIOCD2:
  273. case ID_MAIN_PLAY_AUDIOCD3:
  274. case ID_MAIN_PLAY_AUDIOCD4:
  275. if (g_audiocdletter[LOWORD(wID) - ID_MAIN_PLAY_AUDIOCD])
  276. {
  277. wchar_t s[32] = {0};
  278. StopPlaying(0);
  279. StringCchPrintfW(s, 32, L"cda://%c", g_audiocdletter[LOWORD(wID) - ID_MAIN_PLAY_AUDIOCD]);
  280. PlayList_delete();
  281. PlayList_appendthing(s, 0, 0);
  282. BeginPlayback();
  283. plEditRefresh();
  284. }
  285. return 1;
  286. case ID_PE_OPEN:
  287. {
  288. if (!playlist_open(g_dialog_box_parent ? g_dialog_box_parent : hMainWindow)) break;
  289. }
  290. return 1;
  291. case ID_PE_SAVEAS:
  292. savepls(DIALOG_PARENT(hMainWindow));
  293. return 1;
  294. case WINAMP_EDIT_BOOKMARKS:
  295. MessageBoxW(hwnd, getStringW(IDS_ML_MISSING_FOR_BOOKMARKS,NULL,0), L"Winamp", MB_OK);
  296. return 1;
  297. case WINAMP_MAKECURBOOKMARK:
  298. {
  299. wchar_t fn[FILENAME_SIZE] = {0}, ft[FILETITLE_SIZE] = {0};
  300. PlayList_getitem2W(PlayList_getPosition(), fn, ft);
  301. Bookmark_additem(fn, ft);
  302. }
  303. return 1;
  304. case WINAMP_LIGHTNING_CLICK: about_dialog(); return 1;
  305. case WINAMP_NEW_INSTANCE:
  306. {
  307. char buf[MAX_PATH] = "\"";
  308. STARTUPINFO si = {sizeof(si), };
  309. PROCESS_INFORMATION pi;
  310. GetModuleFileNameA(NULL, buf + 1, sizeof(buf) - 1);
  311. StringCchCatA(buf, MAX_PATH, "\" /NEW");
  312. config_write(1);
  313. CreateProcessA(NULL, buf, NULL, NULL, FALSE, 0, NULL, NULL,(LPSTARTUPINFOA)&si, &pi);
  314. }
  315. return 1;
  316. #if 0
  317. case WINAMP_VIS_OPTIONS:
  318. {
  319. extern int last_classic_skin_page;
  320. last_classic_skin_page = 1;
  321. prefs_last_page = 22;
  322. prefs_dialog(1);
  323. }
  324. return 1;
  325. #endif
  326. case WINAMP_REFRESHSKIN:
  327. {
  328. g_skinloadedmanually = 1;
  329. SendMessageW(hwnd, WM_DISPLAYCHANGE, 0, 0);
  330. g_skinloadedmanually = 0;
  331. }
  332. if (config_pe_open) InvalidateRect(hPLWindow, NULL, FALSE);
  333. #if 0
  334. if (config_mb_open)
  335. {
  336. RECT r;
  337. r.left = 0;r.top = 0;r.right = 11;r.bottom = config_mb_height;
  338. InvalidateRect(hMBWindow, &r, FALSE);
  339. r.left = 11;r.top = 0;r.right = config_mb_width;r.bottom = 20;
  340. InvalidateRect(hMBWindow, &r, FALSE);
  341. r.left = config_mb_width - 8;r.top = 20;r.right = config_mb_width;r.bottom = config_mb_height;
  342. InvalidateRect(hMBWindow, &r, FALSE);
  343. r.left = 11;r.top = config_mb_height - 38;r.right = config_mb_width - 8;r.bottom = config_mb_height;
  344. InvalidateRect(hMBWindow, &r, FALSE);
  345. }
  346. #endif
  347. if (config_eq_open) InvalidateRect(hEQWindow, NULL, FALSE);
  348. if (config_video_open) InvalidateRect(hVideoWindow, NULL, FALSE);
  349. // plugin wnds get the WM_DISPLAYCHANGE which is all they need
  350. return 1;
  351. case WINAMP_SELSKIN:
  352. prefs_last_page = 40;
  353. prefs_dialog(1);
  354. return 1;
  355. case WINAMP_VISPLUGIN:
  356. if (vis_running()) vis_stop();
  357. else vis_start(hMainWindow, NULL);
  358. return 1;
  359. case WINAMP_PLGSETUP:
  360. prefs_last_page = 33;
  361. prefs_dialog(1);
  362. return 1;
  363. case WINAMP_TOGGLE_AUTOSCROLL:
  364. config_autoscrollname ^= 1;
  365. if (config_autoscrollname == 1) SetTimer(hwnd, UPDATE_DISPLAY_TIMER + 1, 200, NULL);
  366. else if (config_autoscrollname == 0)
  367. {
  368. KillTimer(hwnd, UPDATE_DISPLAY_TIMER + 1);
  369. ui_songposition = 0;
  370. draw_songname(FileTitle, &ui_songposition, playing ? in_getlength() : PlayList_getcurrentlength());
  371. }
  372. return 1;
  373. case WINAMP_EDIT_ID3:
  374. if (FileName[0]) in_infobox(DIALOG_PARENT(hMainWindow), FileName);
  375. return 1;
  376. case WINAMP_OPTIONS_WINDOWSHADE_PL: // toggle windowshade
  377. ToggleWindowShade_PL();
  378. return 1;
  379. case WINAMP_OPTIONS_WINDOWSHADE_EQ:
  380. ToggleWindowShade_EQ();
  381. return 1;
  382. case WINAMP_OPTIONS_WINDOWSHADE: // toggle windowshade
  383. ToggleWindowShade_Main();
  384. return 1;
  385. case WINAMP_OPTIONS_WINDOWSHADE_GLOBAL: // toggle windowshade
  386. {
  387. HWND hFocus = GetForegroundWindow();
  388. if (hFocus == hPLWindow || IsChild(hFocus, hPLWindow))
  389. ToggleWindowShade_PL();
  390. else if (hFocus == hEQWindow || IsChild(hFocus, hEQWindow))
  391. ToggleWindowShade_EQ();
  392. else
  393. ToggleWindowShade_Main();
  394. }
  395. return 1;
  396. case ID_PE_CLOSE:
  397. case WINAMP_MAIN_WINDOW:
  398. config_mw_open = !config_mw_open;
  399. if (config_mw_open)
  400. {
  401. if (config_pe_open && config_pe_width >= 350 && config_pe_height != 14)
  402. {
  403. RECT r = {config_pe_width - 150 - 75, config_pe_height - 26, r.left + 77, r.top + 16};
  404. InvalidateRect(hPLWindow, &r, FALSE);
  405. }
  406. }
  407. else
  408. {
  409. MoveOffscreen(hwnd);
  410. }
  411. //sa_setthread(-1);
  412. CheckMenuItem(main_menu, WINAMP_MAIN_WINDOW, config_mw_open ? MF_CHECKED : MF_UNCHECKED);
  413. set_aot(0);
  414. Ipc_WindowToggle(IPC_CB_WND_MAIN, config_mw_open);
  415. case WINAMP_NEXT_WINDOW:
  416. EnterCriticalSection(&embedcs);
  417. {
  418. embedWindowState *p = embedwndlist;
  419. int x;
  420. int state = 0;
  421. for (x = 0; ; x ++)
  422. {
  423. HWND dockwnd = NULL;
  424. int vis = 0;
  425. if ( x == 0 )
  426. {
  427. dockwnd = hMainWindow;
  428. vis = config_mw_open;
  429. }
  430. else if ( x == 1 )
  431. {
  432. dockwnd = hEQWindow;
  433. vis = config_eq_open;
  434. }
  435. else if ( x == 2 )
  436. {
  437. dockwnd = hPLWindow;
  438. vis = config_pe_open;
  439. }
  440. //else if (x == 3) { /*dockwnd = hMBWindow; vis = 0;*/ } // config_mb_open; }
  441. else if ( x == 4 )
  442. {
  443. dockwnd = hVideoWindow;
  444. vis = config_video_open;
  445. }
  446. else
  447. {
  448. if ( !p )
  449. {
  450. if ( state == 1 )
  451. {
  452. p = embedwndlist;
  453. x = -1;
  454. state = 2;
  455. continue;
  456. }
  457. else
  458. break;
  459. }
  460. dockwnd = p->me;
  461. vis = IsWindowVisible( p->me );
  462. }
  463. if (!state)
  464. {
  465. HWND fg = GetForegroundWindow();
  466. if (fg == dockwnd || IsChild(dockwnd, fg))
  467. {
  468. state = 1;
  469. }
  470. }
  471. else if (vis)
  472. {
  473. SetForegroundWindow(dockwnd);
  474. break;
  475. }
  476. // changed for 5.58 to cope with x == 3 as this can otherwise cause
  477. // one embedwnd to stay as the active window irrespective of doing
  478. // additional ctrl+tab actions as it was not wanting to handle x==3
  479. if (x == 3 || x > 4)
  480. p = p->link;
  481. }
  482. }
  483. LeaveCriticalSection(&embedcs);
  484. return 1;
  485. case WINAMP_HELP_ABOUT: // about box
  486. about_dialog();
  487. return 1;
  488. case WINAMP_PE_SEARCH:
  489. case WINAMP_JUMPFILE:
  490. jump_file_dialog(hMainWindow);
  491. return 1;
  492. case WINAMP_TOGGLE_LIBRARY:
  493. sendMlIpc(ML_IPC_TOGGLE_VISIBLE, 0);
  494. return 1;
  495. case WINAMP_JUMP:
  496. if (playing && in_mod && in_mod->is_seekable)
  497. {
  498. jump_dialog(hMainWindow);
  499. }
  500. return 1;
  501. case WINAMP_FFWD5S: // left and right arrows, fastforward and rewind by 5 seconds
  502. case WINAMP_REW5S:
  503. {
  504. int i;
  505. if (!in_mod || !in_mod->is_seekable || PlayList_ishidden(PlayList_getPosition())) return 1;
  506. if (LOWORD(wID) == WINAMP_FFWD5S) i = 5000;
  507. else i = -5000;
  508. if (playing)
  509. {
  510. int t;
  511. t = in_getouttime() + i;
  512. if (t < 0) t = 0;
  513. if (in_seek(t) < 0)
  514. SendMessageW(hwnd, WM_WA_MPEG_EOF, 0, 0);
  515. else
  516. {
  517. ui_drawtime(in_getouttime() / 1000, 0);
  518. }
  519. }
  520. }
  521. return 1;
  522. case WINAMP_MAINMENU: // alt-f for mainmenu
  523. {
  524. POINT p = { 6, 13 };
  525. if (config_dsize)
  526. {
  527. p.x *= 2;
  528. p.y *= 2;
  529. }
  530. ClientToScreen(hwnd, &p);
  531. if ( /*p.x > 3000 || */p.y > OFFSCREEN_Y_POS && p.y < (OFFSCREEN_Y_POS + 2000) )
  532. GetCursorPos(&p);
  533. DoTrackPopup(main_menu, TPM_LEFTALIGN | TPM_RIGHTBUTTON, p.x, p.y, hwnd);
  534. }
  535. return 1;
  536. case WINAMP_PREVSONG:
  537. {
  538. int s = 1;
  539. if (!config_shuffle && PlayList_advance( -1) < 0)
  540. {
  541. s = 0;
  542. if (config_repeat)
  543. {
  544. s = 1;
  545. PlayList_advance(BIGINT);
  546. }
  547. }
  548. if (s)
  549. {
  550. if (PlayList_getlength())
  551. {
  552. if (config_shuffle)
  553. {
  554. if (PlayList_randpos( -1)) return 1;
  555. }
  556. PlayList_getcurrent(FileName, FileTitle, FileTitleNum);
  557. if (playing)
  558. {
  559. StopPlaying(0);
  560. StartPlaying();
  561. }
  562. else StopPlaying(0);
  563. }
  564. }
  565. }
  566. return 0;
  567. case WINAMP_BUTTON1_SHIFT: // button 1 (previous), sent from either windowshade,
  568. case WINAMP_BUTTON1_CTRL: // keyboard shortcut, or normal buttons (ui.c)
  569. case WINAMP_BUTTON1:
  570. return (Main_OnButton1(hwnd, LOWORD(wID), hwndCtl, codeNotify));
  571. case WINAMP_BUTTON2_SHIFT: // button 2 (play)
  572. case WINAMP_BUTTON2_CTRL:
  573. case WINAMP_BUTTON2:
  574. return (Main_OnButton2(hwnd, LOWORD(wID), hwndCtl, codeNotify));
  575. case WINAMP_BUTTON3: // button 3 (pause)
  576. return (Main_OnButton3(hwnd, LOWORD(wID), hwndCtl, codeNotify));
  577. case WINAMP_BUTTON4_CTRL: // button 4 (stop)
  578. case WINAMP_BUTTON4_SHIFT: // button 4 (stop)
  579. case WINAMP_BUTTON4:
  580. return (Main_OnButton4(hwnd, LOWORD(wID), hwndCtl, codeNotify));
  581. case WINAMP_BUTTON5_CTRL: // button 5 (next)
  582. case WINAMP_BUTTON5_SHIFT: // button 5 (next)
  583. case WINAMP_BUTTON5:
  584. return (Main_OnButton5(hwnd, LOWORD(wID), hwndCtl, codeNotify));
  585. case WINAMP_FILE_QUIT: // keyboard Alt-X or menu option
  586. if (g_exit_disabled) return 0;
  587. SendMessageW(hwnd, WM_CLOSE, 0, 0);
  588. return 1;
  589. case WINAMP_FILE_LOC: // open location
  590. getNewLocation(1, DIALOG_PARENT(hwnd));
  591. plEditRefresh();
  592. return 1;
  593. case WINAMP_FILE_PLAY: // open file(s)
  594. getNewFile(1, /*NULL*/DIALOG_PARENT(hwnd), 0);
  595. plEditRefresh();
  596. return 1;
  597. case WINAMP_FILE_DIR: // open directory
  598. {
  599. BROWSEINFOW bi = {0};
  600. wchar_t name[MAX_PATH] = {0};
  601. bi.hwndOwner = DIALOG_PARENT(hwnd);
  602. bi.pszDisplayName = name;
  603. bi.lpszTitle = L"__foo";
  604. bi.ulFlags = BIF_RETURNONLYFSDIRS | BIF_NEWDIALOGSTYLE;
  605. bi.lpfn = BrowseCallbackProc;
  606. ITEMIDLIST *idlist = SHBrowseForFolderW(&bi);
  607. if (idlist)
  608. {
  609. wchar_t path[MAX_PATH] = {0};
  610. SHGetPathFromIDListW( idlist, path );
  611. Shell_Free(idlist);
  612. WASABI_API_APP->path_setWorkingPath(path);
  613. PlayList_delete();
  614. PlayList_adddir(path, (config_rofiob&2) ? 0 : 1);
  615. if (config_rofiob&1) PlayList_sort(2, 0);
  616. BeginPlayback();
  617. plEditRefresh();
  618. }
  619. }
  620. return 1;
  621. case WINAMP_OPTIONS_PREFS: // open preferences
  622. prefs_dialog(0);
  623. return 1;
  624. case WINAMP_OPTIONS_AOT: // toggle always on top
  625. config_aot = !config_aot;
  626. set_aot(0);
  627. return 1;
  628. case WINAMP_OPTIONS_DSIZE: // toggle doublesize mode
  629. config_dsize = !config_dsize;
  630. if (!config_bifont && config_bifont_alt) draw_reinit_plfont(1);
  631. set_aot(1);
  632. return 1;
  633. case WINAMP_OPTIONS_EASYMOVE: // toggle easymove (easy window moving)
  634. config_easymove = !config_easymove;
  635. CheckMenuItem(main_menu, WINAMP_OPTIONS_EASYMOVE, config_easymove ? MF_CHECKED : MF_UNCHECKED);
  636. return 1;
  637. case WINAMP_FILE_SHUFFLE: // toggle shuffle (and draw button)
  638. config_shuffle = !config_shuffle;
  639. CheckMenuItem(main_menu, WINAMP_FILE_SHUFFLE, config_shuffle ? MF_CHECKED : MF_UNCHECKED);
  640. draw_shuffle(config_shuffle, 0);
  641. if (config_shuffle) PlayList_updaterandpos();
  642. if (config_shuffle && !playing)
  643. {
  644. PlayList_randpos( -BIGINT);
  645. PlayList_getcurrent(FileName, FileTitle, FileTitleNum);
  646. //draw_songname(FileTitle, &ui_songposition, playing ? in_getlength() : PlayList_getcurrentlength());
  647. }
  648. draw_songname(getStringW((config_shuffle ? IDS_SHUFFLE_ON : IDS_SHUFFLE_OFF), NULL, 0), &ui_songposition, -2);
  649. return 1;
  650. case WINAMP_FILE_REPEAT: // toggle repeat
  651. {
  652. config_repeat = !config_repeat;
  653. CheckMenuItem(main_menu, WINAMP_FILE_REPEAT, config_repeat ? MF_CHECKED : MF_UNCHECKED);
  654. draw_repeat(config_repeat, 0);
  655. UINT id = 0;
  656. if (!config_repeat) id = IDS_REPEAT_OFF;
  657. else if (config_repeat && config_pladv) id = IDS_REPEAT_PL;
  658. else if (config_repeat && !config_pladv) id = IDS_REPEAT_TRACK;
  659. if (id) draw_songname(getStringW(id, NULL, 0), &ui_songposition, -2);
  660. return 1;
  661. }
  662. case WINAMP_FILE_MANUALPLADVANCE: // toggle manual playlist advance
  663. {
  664. config_pladv = !config_pladv;
  665. UpdateManualAdvanceState();
  666. UINT id = 0;
  667. if (!config_repeat) id = (config_pladv ? IDS_MAN_ADV_OFF : IDS_MAN_ADV_ON);
  668. else if (config_repeat && config_pladv) id = IDS_REPEAT_PL;
  669. else if (config_repeat && !config_pladv) id = IDS_REPEAT_TRACK;
  670. if (id) draw_songname(getStringW(id, NULL, 0), &ui_songposition, -2);
  671. return 1;
  672. }
  673. case WINAMP_OPTIONS_EQ: // toggle EQ window
  674. eq_dialog(hwnd,0);
  675. return 1;
  676. case WINAMP_OPTIONS_PLEDIT: // toggle playlist editor
  677. // if we get a 2 then it came from gen_ff so that we can work around a docking/position issue
  678. pleditDlg(hwnd,codeNotify==2);
  679. return 1;
  680. case WINAMP_OPTIONS_VIDEO:
  681. config_video_open ? HideVideoWindow(1) : ShowVideoWindow(0);
  682. return 1;
  683. case WINAMP_OPTIONS_TOGTIME:
  684. config_timeleftmode = !config_timeleftmode;
  685. CheckMenuItem(main_menu, WINAMP_OPTIONS_ELAPSED, config_timeleftmode ? MF_UNCHECKED : MF_CHECKED);
  686. CheckMenuItem(main_menu, WINAMP_OPTIONS_REMAINING, config_timeleftmode ? MF_CHECKED : MF_UNCHECKED);
  687. SendMessageW(hwnd, WM_TIMER, UPDATE_DISPLAY_TIMER + 4, 0);
  688. return 1;
  689. case WINAMP_OPTIONS_ELAPSED: // set time mode to elapsed
  690. config_timeleftmode = 0;
  691. CheckMenuItem(main_menu, WINAMP_OPTIONS_ELAPSED, MF_CHECKED);
  692. CheckMenuItem(main_menu, WINAMP_OPTIONS_REMAINING, MF_UNCHECKED);
  693. SendMessageW(hwnd, WM_TIMER, UPDATE_DISPLAY_TIMER + 4, 0);
  694. return 1;
  695. case WINAMP_OPTIONS_REMAINING: // set time mode to remaining
  696. config_timeleftmode = 1;
  697. CheckMenuItem(main_menu, WINAMP_OPTIONS_ELAPSED, MF_UNCHECKED);
  698. CheckMenuItem(main_menu, WINAMP_OPTIONS_REMAINING, MF_CHECKED);
  699. SendMessageW(hwnd, WM_TIMER, UPDATE_DISPLAY_TIMER + 4, 0);
  700. return 1;
  701. case WINAMP_VOLUMEUP: // increase volume by ~2%
  702. case WINAMP_VOLUMEDOWN: // decrease volume by ~2%
  703. if (LOWORD(wID) == WINAMP_VOLUMEUP)
  704. {
  705. if (config_volume <= 251) config_volume += 4;
  706. else config_volume = 255;
  707. }
  708. else
  709. {
  710. if (config_volume > 3) config_volume -= 4;
  711. else config_volume = 0;
  712. }
  713. in_setvol(config_volume);
  714. draw_volumebar(config_volume, 0);
  715. update_volume_text(-2);
  716. return 1;
  717. case WINAMP_JUMP10BACK:
  718. {
  719. int x;
  720. int i = playing;
  721. if (i) StopPlaying(0);
  722. for (x = 0; x < 10; x ++)
  723. SendMessageW(hwnd, WM_COMMAND, WINAMP_BUTTON1, 0);
  724. if (i) StartPlaying();
  725. }
  726. return 1;
  727. case WINAMP_JUMP10FWD:
  728. {
  729. int x;
  730. int i = playing;
  731. if (i) StopPlaying(0);
  732. for (x = 0; x < 10; x ++)
  733. SendMessageW(hwnd, WM_COMMAND, WINAMP_BUTTON5, 0);
  734. if (i) StartPlaying();
  735. }
  736. return 1;
  737. case WINAMP_GETMORESKINS:
  738. myOpenURLWithFallback(hwnd, L"http://www.google.com/search?q=Winamp+Skins", L"http://www.google.com/search?q=Winamp+Skins");
  739. return 0;
  740. case WINAMP_VISCONF:
  741. {
  742. wchar_t b[MAX_PATH] = {0};
  743. HINSTANCE hLib;
  744. PathCombineW(b, VISDIR, config_visplugin_name);
  745. hLib = LoadLibraryW(b);
  746. if (hLib)
  747. {
  748. winampVisModule *module = NULL;
  749. winampVisGetHeaderType pr = (winampVisGetHeaderType) GetProcAddress(hLib, "winampVisGetHeader");
  750. winampVisHeader* pv = pr(hMainWindow);
  751. if (pv) module = pv->getModule(config_visplugin_num);
  752. if (module)
  753. {
  754. module->hDllInstance = hLib;
  755. module->hwndParent = hMainWindow;
  756. if (!(config_no_visseh&1))
  757. {
  758. __try {
  759. module->Config(module);
  760. }
  761. __except(EXCEPTION_EXECUTE_HANDLER)
  762. {
  763. LPMessageBox(hwnd, IDS_PLUGINERROR, IDS_ERROR, MB_OK | MB_ICONEXCLAMATION);
  764. }
  765. }
  766. else
  767. {
  768. module->Config(module);
  769. }
  770. }
  771. else
  772. {
  773. LPMessageBox(hwnd, IDS_ERRORLOADINGPLUGIN, IDS_ERROR, MB_OK);
  774. }
  775. FreeLibrary(hLib);
  776. }
  777. }
  778. return 1;
  779. case WINAMP_MINIMIZE:
  780. if (GetAsyncKeyState(VK_SHIFT) >> 15)
  781. minimize_hack_winamp = 1;
  782. else
  783. minimize_hack_winamp = 0;
  784. ShowWindow(hMainWindow, SW_MINIMIZE);
  785. return 1;
  786. case WINAMP_VIDEO_TOGGLE_FS:
  787. videoToggleFullscreen();
  788. return 1;
  789. case ID_MLFILE_NEWPLAYLIST:
  790. {
  791. HWND h = (HWND)sendMlIpc(0, 0);
  792. HWND fgw = GetForegroundWindow();
  793. if (h && IsWindow(h) && IsWindowVisible(h) && IsChild(fgw, h))
  794. sendMlIpc(ML_IPC_NEWPLAYLIST, (WPARAM)h);
  795. else sendMlIpc(ML_IPC_NEWPLAYLIST, (WPARAM)(g_dialog_box_parent ? g_dialog_box_parent : hMainWindow));
  796. showLibrary();
  797. }
  798. return 1;
  799. case ID_MLFILE_SAVEPLAYLIST:
  800. showLibrary();
  801. {
  802. HWND h = (HWND)sendMlIpc(0, 0);
  803. HWND fgw = GetForegroundWindow();
  804. if (h && IsWindow(h) && IsWindowVisible(h) && IsChild(fgw, h))
  805. sendMlIpc(ML_IPC_SAVEPLAYLIST, (WPARAM)h);
  806. else sendMlIpc(ML_IPC_SAVEPLAYLIST, (WPARAM)(g_dialog_box_parent ? g_dialog_box_parent : hMainWindow));
  807. }
  808. return 1;
  809. case ID_MLFILE_LOADPLAYLIST:
  810. {
  811. HWND h = (HWND)sendMlIpc(0, 0);
  812. HWND fgw = GetForegroundWindow();
  813. if (h && IsWindow(h) && IsWindowVisible(h) && IsChild(fgw, h))
  814. sendMlIpc(ML_IPC_IMPORTPLAYLIST, (WPARAM)h);
  815. else
  816. sendMlIpc(ML_IPC_IMPORTPLAYLIST, (WPARAM)(g_dialog_box_parent ? g_dialog_box_parent : hMainWindow));
  817. showLibrary();
  818. }
  819. return 1;
  820. case ID_MLFILE_IMPORTCURRENTPLAYLIST:
  821. sendMlIpc(ML_IPC_IMPORTCURRENTPLAYLIST, 0);
  822. showLibrary();
  823. return 1;
  824. case ID_MLVIEW_MEDIA:
  825. #define TREE_LOCALMEDIA 1000
  826. showLibrary();
  827. sendMlIpc(ML_IPC_SETCURTREEITEM, TREE_LOCALMEDIA);
  828. return 1;
  829. case ID_MLVIEW_PLAYLISTS:
  830. #define TREE_PLAYLISTS 3001
  831. showLibrary();
  832. sendMlIpc(ML_IPC_SETCURTREEITEM, TREE_PLAYLISTS);
  833. return 1;
  834. case ID_MLVIEW_DEVICES:
  835. #define TREE_DEVICES 10000
  836. showLibrary();
  837. sendMlIpc(ML_IPC_SETCURTREEITEM, TREE_DEVICES);
  838. return 1;
  839. case ID_MLVIEW_INTERNETRADIO:
  840. #define TREE_INTERNET_RADIO 11000
  841. showLibrary();
  842. sendMlIpc(ML_IPC_SETCURTREEITEM, TREE_INTERNET_RADIO);
  843. return 1;
  844. case ID_MLVIEW_INTERNETTV:
  845. #define TREE_INTERNET_VIDEO 11001
  846. showLibrary();
  847. sendMlIpc(ML_IPC_SETCURTREEITEM, TREE_INTERNET_VIDEO);
  848. return 1;
  849. case ID_MLVIEW_LIBRARYPREFERENCES:
  850. showLibrary();
  851. sendMlIpc(ML_IPC_OPENPREFS, 0);
  852. return 1;
  853. case ID_PLAY_VOLUMEUP: // increase by ~ 10%
  854. {
  855. int a = 5;
  856. while (a--) SendMessageW(hwnd, WM_COMMAND, WINAMP_VOLUMEUP, 0);
  857. }
  858. return 1;
  859. case ID_PLAY_VOLUMEDOWN: // decrease by ~10%
  860. {
  861. int a = 5;
  862. while (a--)
  863. SendMessageW(hwnd, WM_COMMAND, WINAMP_VOLUMEDOWN, 0);
  864. }
  865. return 1;
  866. case ID_RATING5: return setCurrentRating(5);
  867. case ID_RATING4: return setCurrentRating(4);
  868. case ID_RATING3: return setCurrentRating(3);
  869. case ID_RATING2: return setCurrentRating(2);
  870. case ID_RATING1: return setCurrentRating(1);
  871. case ID_RATING0: return setCurrentRating(0);
  872. case ID_PL_RATING5: return setPlRating(5);
  873. case ID_PL_RATING4: return setPlRating(4);
  874. case ID_PL_RATING3: return setPlRating(3);
  875. case ID_PL_RATING2: return setPlRating(2);
  876. case ID_PL_RATING1: return setPlRating(1);
  877. case ID_PL_RATING0: return setPlRating(0);
  878. case ID_PE_FFOD:
  879. {
  880. wchar_t fn[FILENAME_SIZE] = {0};
  881. if (!PlayList_getitem2W(PlayList_getPosition(), fn, NULL))
  882. {
  883. explorerFindFileManager->AddFile(fn);
  884. explorerFindFileManager->ShowFiles();
  885. }
  886. }
  887. return 1;
  888. } // switch()
  889. return 0;
  890. } // Main_OnCommand()