preferences_adts.cpp 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. #include "../Agave/Language/api_language.h"
  2. #include "config.h"
  3. #include "preferences.h"
  4. #include "../Winamp/wa_ipc.h"
  5. #include <windows.h>
  6. #include <assert.h>
  7. #include "resource.h"
  8. #include "link_control.h"
  9. #include "../nu/ComboBox.h"
  10. #include "../nu/Slider.h"
  11. #include <strsafe.h>
  12. extern HWND winampwnd;
  13. INT_PTR CALLBACK Preferences_ADTS_DlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
  14. {
  15. switch(msg)
  16. {
  17. case WM_INITDIALOG:
  18. {
  19. AACConfigurationFile *cfg = (AACConfigurationFile *)lParam;
  20. cfg->changing = false;
  21. SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR)cfg);
  22. if (cfg->shoutcast == 1)
  23. {
  24. ShowWindow(GetDlgItem(hwnd, IDC_WARNING), SW_HIDE);
  25. }
  26. ComboBox profile_list(hwnd, IDC_PROFILE);
  27. profile_list.AddString(WASABI_API_LNGSTRINGW(IDS_AUTOMATIC), AAC_PROFILE_AUTOMATIC); assert(AAC_PROFILE_AUTOMATIC == 0);
  28. profile_list.AddString(L"AAC LC", AAC_PROFILE_LC); assert(AAC_PROFILE_LC == 1);
  29. profile_list.AddString(L"HE-AAC", AAC_PROFILE_HE); assert(AAC_PROFILE_HE == 2);
  30. profile_list.AddString(L"HE-AAC v2", AAC_PROFILE_HE_V2); assert(AAC_PROFILE_HE_V2 == 3);
  31. UpdateUI(hwnd, cfg);
  32. UpdateInfo(hwnd, &cfg->config);
  33. link_startsubclass(hwnd, IDC_URL);
  34. link_startsubclass(hwnd, IDC_LOGO);
  35. link_startsubclass(hwnd, IDC_HELPLINK);
  36. char temp[128] = {0};
  37. if (Preferences_GetEncoderVersion(temp, sizeof(temp)/sizeof(*temp)) == 0)
  38. {
  39. SetDlgItemTextA(hwnd, IDC_VERSION, temp);
  40. }
  41. // this will make sure that we've got the aacplus logo shown even when using a localised version
  42. SendDlgItemMessage(hwnd,IDC_LOGO,STM_SETIMAGE,IMAGE_BITMAP, (LPARAM)LoadImage(WASABI_API_ORIG_HINST?WASABI_API_ORIG_HINST:enc_fhg_HINST,MAKEINTRESOURCE(IDB_FHGLOGO),IMAGE_BITMAP,0,0,LR_SHARED));
  43. }
  44. break;
  45. case WM_COMMAND:
  46. switch (LOWORD(wParam))
  47. {
  48. case IDC_HELPLINK:
  49. SendMessage(winampwnd, WM_WA_IPC, (WPARAM)"http://help.winamp.com/", IPC_OPEN_URL);
  50. break;
  51. case IDC_LOGO:
  52. case IDC_URL:
  53. SendMessage(winampwnd, WM_WA_IPC, (WPARAM)"http://www.iis.fraunhofer.de/en/bf/amm", IPC_OPEN_URL);
  54. break;
  55. case IDC_EDIT_PRESET:
  56. if (HIWORD(wParam) == EN_CHANGE)
  57. {
  58. AACConfigurationFile *cfg = (AACConfigurationFile *)GetWindowLongPtr(hwnd, GWLP_USERDATA);
  59. if (!cfg->changing)
  60. {
  61. BOOL s=0;
  62. unsigned int t=GetDlgItemInt(hwnd,IDC_EDIT_PRESET,&s,0);
  63. if (s)
  64. {
  65. cfg->config.bitrate = t;
  66. UpdateUI(hwnd, cfg);
  67. UpdateInfo(hwnd, &cfg->config);
  68. AACConfig_Save(cfg);
  69. }
  70. }
  71. }
  72. break;
  73. case IDC_PROFILE:
  74. if (HIWORD(wParam) == CBN_SELCHANGE)
  75. {
  76. AACConfigurationFile *cfg = (AACConfigurationFile *)GetWindowLongPtr(hwnd, GWLP_USERDATA);
  77. cfg->config.profile = (unsigned int)ComboBox(hwnd, IDC_PROFILE).GetSelection();
  78. UpdateUI(hwnd, cfg);
  79. UpdateInfo(hwnd, &cfg->config);
  80. AACConfig_Save(cfg);
  81. }
  82. break;
  83. }
  84. break;
  85. case WM_HSCROLL:
  86. if (GetDlgItem(hwnd, IDC_SLIDER_PRESET) == (HWND)lParam)
  87. {
  88. wchar_t temp[128] = {0};
  89. AACConfigurationFile *cfg = (AACConfigurationFile *)GetWindowLongPtr(hwnd, GWLP_USERDATA);
  90. cfg->config.bitrate = GetSliderBitrate(hwnd);
  91. StringCbPrintf(temp, sizeof(temp), L"%u", cfg->config.bitrate);
  92. SetDlgItemText(hwnd, IDC_EDIT_PRESET, temp);
  93. UpdateInfo(hwnd, &cfg->config);
  94. AACConfig_Save(cfg);
  95. }
  96. break;
  97. }
  98. link_handledraw(hwnd,msg,wParam,lParam);
  99. const int controls[] =
  100. {
  101. IDC_SLIDER_PRESET,
  102. };
  103. if (FALSE != WASABI_API_APP->DirectMouseWheel_ProcessDialogMessage(hwnd, msg, wParam, lParam, controls, ARRAYSIZE(controls)))
  104. {
  105. return 1;
  106. }
  107. return 0;
  108. }