1
0

cfgwin.cpp 72 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918
  1. /*
  2. LICENSE
  3. -------
  4. Copyright 2005 Nullsoft, Inc.
  5. All rights reserved.
  6. Redistribution and use in source and binary forms, with or without modification,
  7. are permitted provided that the following conditions are met:
  8. * Redistributions of source code must retain the above copyright notice,
  9. this list of conditions and the following disclaimer.
  10. * Redistributions in binary form must reproduce the above copyright notice,
  11. this list of conditions and the following disclaimer in the documentation
  12. and/or other materials provided with the distribution.
  13. * Neither the name of Nullsoft nor the names of its contributors may be used to
  14. endorse or promote products derived from this software without specific prior written permission.
  15. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
  16. IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  17. FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
  18. CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  19. DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  20. DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
  21. IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  22. OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  23. */
  24. #include <windows.h>
  25. #include <stdio.h>
  26. #include <commctrl.h>
  27. #include "r_defs.h"
  28. #include "vis.h"
  29. #include "cfgwnd.h"
  30. #include "resource.h"
  31. #include "render.h"
  32. #include "rlib.h"
  33. #include "draw.h"
  34. #include "wnd.h"
  35. #include "bpm.h"
  36. #include "avs_eelif.h"
  37. #include "undo.h"
  38. #include "../Agave/Language/api_language.h"
  39. #include "../WAT/WAT.h"
  40. #ifdef LASER
  41. extern "C" {
  42. #include "laser/ld32.h"
  43. }
  44. #endif
  45. static void _do_add(HWND hwnd, HTREEITEM h, C_RenderListClass *list);
  46. static int treeview_hack;
  47. static HTREEITEM g_hroot;
  48. extern int g_config_smp_mt,g_config_smp;
  49. extern struct winampVisModule *g_mod;
  50. extern int cfg_cancelfs_on_deactivate;
  51. HWND g_debugwnd;
  52. char g_noeffectstr[48];
  53. //extern char *verstr;
  54. static HWND cur_hwnd;
  55. int is_aux_wnd=0;
  56. int config_prompt_save_preset=1,config_reuseonresize=1;
  57. //int g_preset_dirty;
  58. // extern BOOL CALLBACK aboutProc(HWND hwndDlg, UINT uMsg, WPARAM wParam,LPARAM lParam);
  59. extern BOOL CALLBACK DlgProc_Bpm(HWND hwndDlg, UINT uMsg, WPARAM wParam,LPARAM lParam);
  60. extern int readyToLoadPreset(HWND parent, int isnew);
  61. extern char *extension(char *fn) ;
  62. int g_dlg_fps,g_dlg_w,g_dlg_h;
  63. int cfg_cfgwnd_x=50,cfg_cfgwnd_y=50,cfg_cfgwnd_open=0;
  64. int cfg_fs_w=0,cfg_fs_h=0,cfg_fs_d=2,cfg_fs_bpp=0,cfg_fs_fps=0,cfg_fs_rnd=1,
  65. #ifdef LASER
  66. cfg_fs_flip=6,
  67. #else
  68. cfg_fs_flip=0,
  69. #endif
  70. cfg_fs_height=80,cfg_speed=5,cfg_fs_rnd_time=10,cfg_fs_use_overlay=0;
  71. int cfg_trans=0,cfg_trans_amount=128;
  72. int cfg_dont_min_avs=0;
  73. int cfg_transitions=4;
  74. int cfg_transitions2=4|32;
  75. int cfg_transitions_speed=8;
  76. int cfg_transition_mode=0x8001;
  77. int cfg_bkgnd_render=0,cfg_bkgnd_render_color=0x1F000F;
  78. int cfg_render_prio=0;
  79. char config_pres_subdir[MAX_PATH];
  80. char last_preset[2048];
  81. static BOOL CALLBACK dlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam,LPARAM lParam);
  82. HWND g_hwndDlg;
  83. extern HWND g_hwnd;
  84. #ifdef WA2_EMBED
  85. #include "wa_ipc.h"
  86. extern embedWindowState myWindowState;
  87. #endif
  88. /*
  89. HINSTANCE g_hDllInstance;
  90. HWND g_hwndParent;
  91. HANDLE hcfgThread;
  92. DWORD WINAPI cfgwnd_thread(LPVOID p)
  93. {
  94. g_hwndDlg=CreateDialog(g_hDllInstance,MAKEINTRESOURCE(IDD_DIALOG1),NULL,dlgProc);
  95. while (1)
  96. {
  97. MSG msg;
  98. if (!GetMessage(&msg,NULL,0,0)) break;
  99. if (!IsDialogMessage(g_hwndDlg,&msg)) DispatchMessage(&msg);
  100. }
  101. return 0;
  102. }
  103. */
  104. static int ExtractWindowsVersion(void)
  105. {
  106. int dwVersion,dwWindowsMajorVersion,dwWindowsMinorVersion,WindowsType,dwBuild;
  107. dwVersion = GetVersion();
  108. // Get major and minor version numbers of Windows
  109. dwWindowsMajorVersion = (DWORD)(LOBYTE(LOWORD(dwVersion)));
  110. dwWindowsMinorVersion = (DWORD)(HIBYTE(LOWORD(dwVersion)));
  111. // Get build numbers for Windows NT or Win32s
  112. if (dwVersion < 0x80000000) // Windows NT
  113. {
  114. dwBuild = (DWORD)(HIWORD(dwVersion));
  115. WindowsType = 0x4; // VER_WINNT
  116. }
  117. else if (dwWindowsMajorVersion < 4) // Win32s
  118. {
  119. dwBuild = (DWORD)(HIWORD(dwVersion) & ~0x8000);
  120. WindowsType = 0x2; // VER_WIN32S
  121. }
  122. else // Windows 95 -- No build numbers provided
  123. {
  124. dwBuild = 0;
  125. WindowsType = 0x1; // VER_WIN95
  126. }
  127. return dwWindowsMajorVersion;
  128. }
  129. void CfgWnd_Create(struct winampVisModule *this_mod)
  130. {
  131. WASABI_API_CREATEDIALOG(IDD_DIALOG1,this_mod->hwndParent,dlgProc);
  132. //CreateDialogA(this_mod->hDllInstance,MAKEINTRESOURCE(IDD_DIALOG1),this_mod->hwndParent,dlgProc);
  133. }
  134. void CfgWnd_Destroy(void)
  135. {
  136. if (g_hwndDlg && IsWindow(g_hwndDlg))
  137. {
  138. RECT r;
  139. GetWindowRect(g_hwndDlg,&r);
  140. cfg_cfgwnd_x=r.left;
  141. cfg_cfgwnd_y=r.top;
  142. DestroyWindow(g_hwndDlg);
  143. }
  144. g_hwndDlg=0;
  145. if (g_debugwnd) DestroyWindow(g_debugwnd);
  146. /*
  147. if (hcfgThread)
  148. {
  149. SendMessage(g_hwndDlg,WM_USER+6,0,0);
  150. g_hwndDlg=0;
  151. WaitForSingleObject(hcfgThread,INFINITE);
  152. CloseHandle(hcfgThread);
  153. hcfgThread=0;
  154. }
  155. */
  156. }
  157. static void recursiveAddDirList(HMENU menu, UINT *id, char *path, int pathlen)
  158. {
  159. HANDLE h;
  160. WIN32_FIND_DATA d;
  161. char dirmask[4096];
  162. wsprintf(dirmask,"%s\\*.*",path);
  163. h = FindFirstFile(dirmask,&d);
  164. if (h != INVALID_HANDLE_VALUE)
  165. {
  166. do {
  167. if (d.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY && d.cFileName[0] != '.')
  168. {
  169. wsprintf(dirmask,"%s\\%s",path,d.cFileName);
  170. MENUITEMINFO i={sizeof(i),};
  171. i.fType=MFT_STRING;
  172. i.fMask=MIIM_TYPE|MIIM_ID;
  173. i.dwTypeData = dirmask+pathlen+1;
  174. i.cch = strlen(i.dwTypeData);
  175. i.wID=*id;
  176. InsertMenuItem(menu,*id+2-1025,TRUE,&i);
  177. (*id)++;
  178. recursiveAddDirList(menu,id,dirmask,pathlen);
  179. }
  180. } while (FindNextFile(h,&d));
  181. FindClose(h);
  182. }
  183. }
  184. static BOOL CALLBACK DlgProc_Preset(HWND hwndDlg, UINT uMsg, WPARAM wParam,LPARAM lParam)
  185. {
  186. switch (uMsg)
  187. {
  188. case WM_INITDIALOG:
  189. {
  190. int x;
  191. for (x = 0; x < 12; x ++)
  192. {
  193. char s[123];
  194. wsprintf(s,"F%d",x+1);
  195. SendDlgItemMessage(hwndDlg,IDC_COMBO1,CB_ADDSTRING,0,(LPARAM)s);
  196. }
  197. for (x = 0; x < 10; x ++)
  198. {
  199. char s[123];
  200. wsprintf(s,"%d",x);
  201. SendDlgItemMessage(hwndDlg,IDC_COMBO1,CB_ADDSTRING,0,(LPARAM)s);
  202. }
  203. for (x = 0; x < 10; x ++)
  204. {
  205. char s[123];
  206. wsprintf(s,WASABI_API_LNGSTRING(IDS_SHIFT_X),x);
  207. SendDlgItemMessage(hwndDlg,IDC_COMBO1,CB_ADDSTRING,0,(LPARAM)s);
  208. }
  209. CheckDlgButton(hwndDlg,IDC_CHECK3,cfg_fs_rnd?BST_CHECKED:BST_UNCHECKED);
  210. SetDlgItemInt(hwndDlg,IDC_EDIT1,cfg_fs_rnd_time,FALSE);
  211. if (config_prompt_save_preset)
  212. CheckDlgButton(hwndDlg,IDC_CHECK1,BST_CHECKED);
  213. if (config_pres_subdir[0])
  214. SetDlgItemText(hwndDlg,IDC_BUTTON3,config_pres_subdir);
  215. else
  216. SetDlgItemText(hwndDlg,IDC_BUTTON3,WASABI_API_LNGSTRING(IDS_ALL));
  217. }
  218. return 1;
  219. case WM_COMMAND:
  220. switch (LOWORD(wParam))
  221. {
  222. case IDC_BUTTON3:
  223. {
  224. MENUITEMINFO i={sizeof(i),};
  225. HMENU hMenu;
  226. hMenu=CreatePopupMenu();
  227. i.fMask=MIIM_TYPE|MIIM_ID;
  228. i.fType=MFT_STRING;
  229. i.wID = 1024;
  230. i.dwTypeData=WASABI_API_LNGSTRING(IDS_ALL);
  231. i.cch=strlen(i.dwTypeData);
  232. InsertMenuItem(hMenu,0,TRUE,&i);
  233. i.wID=0;
  234. i.fType=MFT_SEPARATOR;
  235. InsertMenuItem(hMenu,1,TRUE,&i);
  236. UINT id=1025;
  237. recursiveAddDirList(hMenu,&id,g_path,strlen(g_path));
  238. RECT r;
  239. GetWindowRect(GetDlgItem(hwndDlg,IDC_BUTTON3),&r);
  240. int x=TrackPopupMenu(hMenu,TPM_LEFTALIGN|TPM_TOPALIGN|TPM_RETURNCMD|TPM_RIGHTBUTTON|TPM_LEFTBUTTON|TPM_NONOTIFY,r.left,r.bottom,0,hwndDlg,NULL);
  241. if (x == 1024)
  242. {
  243. config_pres_subdir[0]=0;
  244. SetDlgItemText(hwndDlg,IDC_BUTTON3,WASABI_API_LNGSTRING(IDS_ALL));
  245. }
  246. else if (x >= 1025)
  247. {
  248. MENUITEMINFO mi={sizeof(mi),MIIM_TYPE,};
  249. mi.dwTypeData=config_pres_subdir;
  250. mi.cch = sizeof(config_pres_subdir);
  251. GetMenuItemInfo(hMenu,x,FALSE,&mi);
  252. SetDlgItemText(hwndDlg,IDC_BUTTON3,config_pres_subdir);
  253. }
  254. DestroyMenu(hMenu);
  255. }
  256. return 0;
  257. case IDC_CHECK1:
  258. config_prompt_save_preset=IsDlgButtonChecked(hwndDlg,IDC_CHECK1)?1:0;
  259. return 0;
  260. case IDC_CHECK3:
  261. cfg_fs_rnd=IsDlgButtonChecked(hwndDlg,IDC_CHECK3)?1:0;
  262. #ifdef WA2_EMBED
  263. SendMessage(g_mod->hwndParent,WM_WA_IPC,cfg_fs_rnd,IPC_CB_VISRANDOM);
  264. #endif
  265. return 0;
  266. case IDC_EDIT1:
  267. if (HIWORD(wParam) == EN_CHANGE)
  268. {
  269. BOOL f;
  270. int r=GetDlgItemInt(hwndDlg,IDC_EDIT1,&f,0);
  271. if (f)
  272. {
  273. cfg_fs_rnd_time=r;
  274. }
  275. }
  276. return 0;
  277. case IDC_BUTTON1:
  278. {
  279. int w=SendDlgItemMessage(hwndDlg,IDC_COMBO1,CB_GETCURSEL,0,0);
  280. if (w != CB_ERR)
  281. {
  282. extern void WritePreset(int preset);
  283. WritePreset(w);
  284. }
  285. }
  286. return 0;
  287. case IDC_BUTTON2:
  288. if (readyToLoadPreset(hwndDlg,0))
  289. {
  290. int w=SendDlgItemMessage(hwndDlg,IDC_COMBO1,CB_GETCURSEL,0,0);
  291. if (w != CB_ERR)
  292. {
  293. extern int LoadPreset(int preset);
  294. LoadPreset(w);
  295. }
  296. }
  297. return 0;
  298. }
  299. }
  300. return 0;
  301. }
  302. static BOOL CALLBACK DlgProc_Disp(HWND hwndDlg, UINT uMsg, WPARAM wParam,LPARAM lParam)
  303. {
  304. switch (uMsg)
  305. {
  306. case WM_INITDIALOG:
  307. {
  308. if (ExtractWindowsVersion()<5)
  309. {
  310. EnableWindow(GetDlgItem(hwndDlg,IDC_TRANS_CHECK),0);
  311. EnableWindow(GetDlgItem(hwndDlg,IDC_TRANS_SLIDER),0);
  312. }
  313. else
  314. {
  315. CheckDlgButton(hwndDlg,IDC_TRANS_CHECK,cfg_trans?BST_CHECKED:BST_UNCHECKED);
  316. SendDlgItemMessage(hwndDlg,IDC_TRANS_SLIDER, TBM_SETRANGE, (WPARAM)TRUE, (LPARAM)MAKELONG(16,255));
  317. SendDlgItemMessage(hwndDlg,IDC_TRANS_SLIDER, TBM_SETTICFREQ, 10, (LPARAM)0);
  318. SendDlgItemMessage(hwndDlg,IDC_TRANS_SLIDER, TBM_SETPOS, (WPARAM)TRUE, (LPARAM)cfg_trans_amount);
  319. }
  320. #ifdef LASER
  321. extern int g_laser_nomessage,g_laser_zones;
  322. ShowWindow(GetDlgItem(hwndDlg,IDC_L_SUPPRESS_OUTPUT),SW_SHOWNA);
  323. ShowWindow(GetDlgItem(hwndDlg,IDC_L_SYNC),SW_SHOWNA);
  324. ShowWindow(GetDlgItem(hwndDlg,IDC_L_SUPPRESS_DIALOGS),SW_SHOWNA);
  325. ShowWindow(GetDlgItem(hwndDlg,IDC_L_PROJZONES),SW_SHOWNA);
  326. ShowWindow(GetDlgItem(hwndDlg,IDC_L_FRAME),SW_SHOWNA);
  327. ShowWindow(GetDlgItem(hwndDlg,IDC_L_ACTIVEOUTPUT),SW_SHOWNA);
  328. ShowWindow(GetDlgItem(hwndDlg,IDC_THREADSBORDER),SW_HIDE);
  329. ShowWindow(GetDlgItem(hwndDlg,IDC_CHECK4),SW_HIDE);
  330. ShowWindow(GetDlgItem(hwndDlg,IDC_EDIT1),SW_HIDE);
  331. ShowWindow(GetDlgItem(hwndDlg,IDC_THREADS),SW_HIDE);
  332. CheckDlgButton(hwndDlg,IDC_L_SUPPRESS_DIALOGS,(g_laser_nomessage&1)?BST_CHECKED:BST_UNCHECKED);
  333. CheckDlgButton(hwndDlg,IDC_L_SUPPRESS_OUTPUT,(g_laser_nomessage&4)?BST_CHECKED:BST_UNCHECKED);
  334. CheckDlgButton(hwndDlg,IDC_L_SYNC,(g_laser_nomessage&8)?BST_CHECKED:BST_UNCHECKED);
  335. CheckDlgButton(hwndDlg,IDC_L_ACTIVEOUTPUT,(g_laser_nomessage&2)?BST_CHECKED:BST_UNCHECKED);
  336. #else
  337. CheckDlgButton(hwndDlg,IDC_CHECK4,g_config_smp?BST_CHECKED:0);
  338. SetDlgItemInt(hwndDlg,IDC_EDIT1,g_config_smp_mt,FALSE);
  339. #endif
  340. }
  341. #ifdef WA2_EMBED
  342. {
  343. HWND w = myWindowState.me;
  344. while (GetWindowLong(w, GWL_STYLE) & WS_CHILD) w = GetParent(w);
  345. char classname[256];
  346. GetClassName(w, classname, 255); classname[255] = 0;
  347. if (!stricmp(classname, "BaseWindow_RootWnd"))
  348. {
  349. EnableWindow(GetDlgItem(hwndDlg, IDC_STATIC_ALPHA), FALSE);
  350. EnableWindow(GetDlgItem(hwndDlg, IDC_TRANS_CHECK), FALSE);
  351. EnableWindow(GetDlgItem(hwndDlg, IDC_TRANS_SLIDER), FALSE);
  352. EnableWindow(GetDlgItem(hwndDlg, IDC_STATIC_TRANS_TOTAL), FALSE);
  353. EnableWindow(GetDlgItem(hwndDlg, IDC_STATIC_TRANS_NONE), FALSE);
  354. }
  355. }
  356. #endif
  357. CheckDlgButton(hwndDlg,IDC_CHECK1,(cfg_fs_d&2)?BST_CHECKED:BST_UNCHECKED);
  358. CheckDlgButton(hwndDlg,IDC_CHECK6,(cfg_fs_flip&4)?BST_UNCHECKED:BST_CHECKED);
  359. CheckDlgButton(hwndDlg,IDC_CHECK3,(cfg_fs_fps&2)?BST_CHECKED:BST_UNCHECKED);
  360. CheckDlgButton(hwndDlg,IDC_CHECK5,(cfg_fs_fps&4)?BST_CHECKED:BST_UNCHECKED);
  361. //CheckDlgButton(hwndDlg,IDC_DONT_MIN_AVS,cfg_dont_min_avs?BST_CHECKED:BST_UNCHECKED);
  362. CheckDlgButton(hwndDlg,IDC_CHECK2,config_reuseonresize?BST_CHECKED:BST_UNCHECKED);
  363. CheckDlgButton(hwndDlg,IDC_BKGND_RENDER,(cfg_bkgnd_render&1)?BST_CHECKED:BST_UNCHECKED);
  364. CheckDlgButton(hwndDlg,IDC_SETDESKTOPCOLOR,(cfg_bkgnd_render&2)?BST_CHECKED:BST_UNCHECKED);
  365. SendDlgItemMessage(hwndDlg,IDC_SLIDER1,TBM_SETRANGEMIN,0,0);
  366. SendDlgItemMessage(hwndDlg,IDC_SLIDER1,TBM_SETRANGEMAX,0,80);
  367. SendDlgItemMessage(hwndDlg,IDC_SLIDER1,TBM_SETPOS,1,cfg_speed&0xff);
  368. SendDlgItemMessage(hwndDlg, IDC_THREAD_PRIORITY, CB_ADDSTRING, 0, (LPARAM)WASABI_API_LNGSTRING(IDS_SAME_AS_WINAMP));
  369. SendDlgItemMessage(hwndDlg, IDC_THREAD_PRIORITY, CB_ADDSTRING, 0, (LPARAM)WASABI_API_LNGSTRING(IDS_IDLE));
  370. SendDlgItemMessage(hwndDlg, IDC_THREAD_PRIORITY, CB_ADDSTRING, 0, (LPARAM)WASABI_API_LNGSTRING(IDS_LOWEST));
  371. SendDlgItemMessage(hwndDlg, IDC_THREAD_PRIORITY, CB_ADDSTRING, 0, (LPARAM)WASABI_API_LNGSTRING(IDS_NORMAL));
  372. SendDlgItemMessage(hwndDlg, IDC_THREAD_PRIORITY, CB_ADDSTRING, 0, (LPARAM)WASABI_API_LNGSTRING(IDS_HIGHEST));
  373. SendDlgItemMessage(hwndDlg, IDC_THREAD_PRIORITY, CB_SETCURSEL, cfg_render_prio, 0);
  374. return 1;
  375. case WM_DRAWITEM:
  376. {
  377. DRAWITEMSTRUCT *di=(DRAWITEMSTRUCT *)lParam;
  378. switch (di->CtlID)
  379. {
  380. case IDC_OVERLAYCOLOR:
  381. GR_DrawColoredButton(di,cfg_bkgnd_render_color);
  382. break;
  383. }
  384. }
  385. return 0;
  386. case WM_HSCROLL:
  387. {
  388. HWND swnd = (HWND) lParam;
  389. int t = (int) SendMessage(swnd,TBM_GETPOS,0,0);
  390. if (swnd == GetDlgItem(hwndDlg,IDC_SLIDER1))
  391. {
  392. cfg_speed&=~0xff;
  393. cfg_speed|=t;
  394. }
  395. if (swnd == GetDlgItem(hwndDlg,IDC_TRANS_SLIDER))
  396. {
  397. cfg_trans_amount=t;
  398. SetTransparency(g_hwnd,cfg_trans,cfg_trans_amount);
  399. }
  400. }
  401. return 0;
  402. case WM_COMMAND:
  403. switch (LOWORD(wParam))
  404. {
  405. #ifdef LASER
  406. case IDC_L_PROJZONES:
  407. {
  408. extern int g_laser_zones;
  409. HMENU hMenu=CreatePopupMenu();
  410. int x;
  411. for (x=0;x <20; x++)
  412. {
  413. PROJECTIONZONE pz;
  414. if (ReadProjectionZone(x+1,&pz))
  415. wsprintf(pz.Name,"Zone %d",x);
  416. if (!pz.Name[0]) break;
  417. MENUITEMINFO i={sizeof(i),};
  418. i.wID = x+1;
  419. i.fMask=MIIM_TYPE|MIIM_ID|MIIM_STATE;
  420. i.fState=(g_laser_zones&(1<<x))?MFS_CHECKED:0;
  421. i.fType=MFT_STRING;
  422. i.dwTypeData=pz.Name;
  423. i.cch=strlen(pz.Name);
  424. InsertMenuItem(hMenu,x,TRUE,&i);
  425. }
  426. RECT r;
  427. GetWindowRect(GetDlgItem(hwndDlg,IDC_L_PROJZONES),&r);
  428. int v=TrackPopupMenu(hMenu,TPM_NONOTIFY|TPM_RETURNCMD,r.right,r.top,0,GetDlgItem(hwndDlg,IDC_L_PROJZONES),NULL);
  429. DestroyMenu(hMenu);
  430. if (v > 0)
  431. {
  432. g_laser_zones^=1<<(v-1);
  433. if (!g_laser_zones) g_laser_zones=1;
  434. }
  435. }
  436. return 0;
  437. case IDC_L_SYNC:
  438. {
  439. extern int g_laser_nomessage;
  440. g_laser_nomessage&=~8;
  441. g_laser_nomessage|=IsDlgButtonChecked(hwndDlg,IDC_L_SYNC)?8:0;
  442. }
  443. return 0;
  444. case IDC_L_SUPPRESS_OUTPUT:
  445. {
  446. extern int g_laser_nomessage;
  447. g_laser_nomessage&=~4;
  448. g_laser_nomessage|=IsDlgButtonChecked(hwndDlg,IDC_L_SUPPRESS_OUTPUT)?4:0;
  449. }
  450. return 0;
  451. case IDC_L_SUPPRESS_DIALOGS:
  452. {
  453. extern int g_laser_nomessage;
  454. g_laser_nomessage&=~1;
  455. g_laser_nomessage|=IsDlgButtonChecked(hwndDlg,IDC_L_SUPPRESS_DIALOGS)?1:0;
  456. }
  457. return 0;
  458. case IDC_L_ACTIVEOUTPUT:
  459. {
  460. extern int g_laser_nomessage;
  461. g_laser_nomessage&=~2;
  462. g_laser_nomessage|=IsDlgButtonChecked(hwndDlg,IDC_L_ACTIVEOUTPUT)?2:0;
  463. }
  464. return 0;
  465. #else
  466. case IDC_CHECK4:
  467. g_config_smp=!!IsDlgButtonChecked(hwndDlg,IDC_CHECK4);
  468. return 0;
  469. case IDC_EDIT1:
  470. {
  471. BOOL t;
  472. g_config_smp_mt=GetDlgItemInt(hwndDlg,IDC_EDIT1,&t,FALSE);
  473. }
  474. return 0;
  475. #endif
  476. case IDC_TRANS_CHECK:
  477. cfg_trans=IsDlgButtonChecked(hwndDlg,IDC_TRANS_CHECK)?1:0;
  478. SetTransparency(g_hwnd,cfg_trans,cfg_trans_amount);
  479. return 0;
  480. case IDC_CHECK1:
  481. cfg_fs_d&=~2;
  482. cfg_fs_d|=IsDlgButtonChecked(hwndDlg,IDC_CHECK1)?2:0;
  483. {
  484. RECT r;
  485. extern void GetClientRect_adj(HWND hwnd, RECT *r);
  486. GetClientRect_adj(g_hwnd,&r);
  487. DDraw_Resize(r.right,r.bottom,cfg_fs_d&2);
  488. }
  489. return 0;
  490. case IDC_CHECK6:
  491. cfg_fs_flip&=~4;
  492. cfg_fs_flip|=IsDlgButtonChecked(hwndDlg,IDC_CHECK6)?0:4;
  493. return 0;
  494. case IDC_CHECK3:
  495. cfg_fs_fps&=~2;
  496. cfg_fs_fps|=IsDlgButtonChecked(hwndDlg,IDC_CHECK3)?2:0;
  497. return 0;
  498. case IDC_CHECK5:
  499. cfg_fs_fps&=~4;
  500. cfg_fs_fps|=IsDlgButtonChecked(hwndDlg,IDC_CHECK5)?4:0;
  501. return 0;
  502. case IDC_CHECK2:
  503. config_reuseonresize = !!IsDlgButtonChecked(hwndDlg,IDC_CHECK2);
  504. return 0;
  505. // case IDC_DONT_MIN_AVS:
  506. // cfg_dont_min_avs=IsDlgButtonChecked(hwndDlg,IDC_DONT_MIN_AVS)?1:0;
  507. case IDC_DEFOVERLAYCOLOR:
  508. cfg_bkgnd_render_color=0x1F000F;
  509. InvalidateRect(GetDlgItem(hwndDlg,IDC_OVERLAYCOLOR),NULL,FALSE);
  510. goto update_overlayshit;
  511. case IDC_OVERLAYCOLOR:
  512. GR_SelectColor(hwndDlg,&cfg_bkgnd_render_color);
  513. InvalidateRect(GetDlgItem(hwndDlg,IDC_OVERLAYCOLOR),NULL,FALSE);
  514. goto update_overlayshit;
  515. case IDC_SETDESKTOPCOLOR:
  516. case IDC_BKGND_RENDER:
  517. cfg_bkgnd_render=(IsDlgButtonChecked(hwndDlg,IDC_BKGND_RENDER)?1:0) |
  518. (IsDlgButtonChecked(hwndDlg,IDC_SETDESKTOPCOLOR)?2:0);
  519. update_overlayshit:
  520. {
  521. RECT r;
  522. extern void GetClientRect_adj(HWND hwnd, RECT *r);
  523. GetClientRect_adj(g_hwnd,&r);
  524. DDraw_Resize(r.right,r.bottom,cfg_fs_d&2);
  525. }
  526. return 0;
  527. case IDC_THREAD_PRIORITY:
  528. extern void main_setRenderThreadPriority();
  529. cfg_render_prio=SendDlgItemMessage(hwndDlg,IDC_THREAD_PRIORITY,CB_GETCURSEL,0,0);
  530. main_setRenderThreadPriority();
  531. return 0;
  532. }
  533. return 0;
  534. }
  535. return 0;
  536. }
  537. static void enableFSWindows(HWND hwndDlg, int v)
  538. {
  539. EnableWindow(GetDlgItem(hwndDlg,IDC_BPP_CONV),v);
  540. //EnableWindow(GetDlgItem(hwndDlg,IDC_EDIT1),v);
  541. EnableWindow(GetDlgItem(hwndDlg,IDC_CHECK4),v);
  542. EnableWindow(GetDlgItem(hwndDlg,IDC_CHECK2),v);
  543. EnableWindow(GetDlgItem(hwndDlg,IDC_CHECK3),v);
  544. EnableWindow(GetDlgItem(hwndDlg,IDC_CHECK5),v);
  545. }
  546. extern int cfg_fs_dblclk;
  547. static BOOL CALLBACK DlgProc_FS(HWND hwndDlg, UINT uMsg, WPARAM wParam,LPARAM lParam)
  548. {
  549. switch (uMsg)
  550. {
  551. case WM_INITDIALOG:
  552. {
  553. int l;
  554. DDraw_EnumDispModes(GetDlgItem(hwndDlg,IDC_COMBO1));
  555. l=SendDlgItemMessage(hwndDlg,IDC_COMBO1,CB_GETCOUNT,0,0);
  556. if (l < 1 || l == CB_ERR)
  557. {
  558. SendDlgItemMessage(hwndDlg,IDC_COMBO1,CB_ADDSTRING,0,(LPARAM)WASABI_API_LNGSTRING(IDS_NO_SUITABLE_MODES_FOUND));
  559. SendDlgItemMessage(hwndDlg,IDC_COMBO1,CB_SETCURSEL,0,0);
  560. }
  561. else
  562. {
  563. int x;
  564. for (x = 0; x < l; x ++)
  565. {
  566. char b[256],*p=b;
  567. SendDlgItemMessage(hwndDlg,IDC_COMBO1,CB_GETLBTEXT,x,(long)b);
  568. int w,h,bpp;
  569. w=atoi(p);
  570. while (*p >= '0' && *p <= '9') p++;
  571. if (!*p) continue;
  572. h=atoi(++p);
  573. while (*p >= '0' && *p <= '9') p++;
  574. if (!*p) continue;
  575. bpp=atoi(++p);
  576. if (w == cfg_fs_w && h == cfg_fs_h && bpp == cfg_fs_bpp)
  577. break;
  578. }
  579. if (x != l)
  580. SendDlgItemMessage(hwndDlg,IDC_COMBO1,CB_SETCURSEL,x,0);
  581. }
  582. CheckDlgButton(hwndDlg,IDC_USE_OVERLAY,cfg_fs_use_overlay?BST_CHECKED:BST_UNCHECKED);
  583. enableFSWindows(hwndDlg,!cfg_fs_use_overlay);
  584. EnableWindow(GetDlgItem(hwndDlg, IDC_CHECK8), cfg_fs_use_overlay);
  585. CheckDlgButton(hwndDlg,IDC_CHECK1,(cfg_fs_d&1)?BST_CHECKED:BST_UNCHECKED);
  586. CheckDlgButton(hwndDlg,IDC_CHECK2,(cfg_fs_fps&1)?BST_CHECKED:BST_UNCHECKED);
  587. CheckDlgButton(hwndDlg,IDC_CHECK3,(cfg_fs_fps&8)?BST_CHECKED:BST_UNCHECKED);
  588. CheckDlgButton(hwndDlg,IDC_CHECK5,(cfg_fs_fps&16)?BST_CHECKED:BST_UNCHECKED);
  589. CheckDlgButton(hwndDlg,IDC_CHECK4,(cfg_fs_flip&1)?BST_CHECKED:BST_UNCHECKED);
  590. CheckDlgButton(hwndDlg,IDC_CHECK7,(cfg_fs_flip&2)?BST_UNCHECKED:BST_CHECKED);
  591. CheckDlgButton(hwndDlg,IDC_CHECK8,(cfg_cancelfs_on_deactivate)?BST_UNCHECKED:BST_CHECKED);
  592. CheckDlgButton(hwndDlg,IDC_BPP_CONV,(cfg_fs_flip&8)?BST_UNCHECKED:BST_CHECKED);
  593. SetDlgItemInt(hwndDlg,IDC_EDIT1,cfg_fs_height,FALSE);
  594. SendDlgItemMessage(hwndDlg,IDC_SLIDER1,TBM_SETRANGEMIN,0,0);
  595. SendDlgItemMessage(hwndDlg,IDC_SLIDER1,TBM_SETRANGEMAX,0,80);
  596. SendDlgItemMessage(hwndDlg,IDC_SLIDER1,TBM_SETPOS,1,(cfg_speed>>8)&0xff);
  597. CheckDlgButton(hwndDlg,IDC_CHECK6,cfg_fs_dblclk?BST_CHECKED:BST_UNCHECKED);
  598. }
  599. return 1;
  600. case WM_HSCROLL:
  601. {
  602. HWND swnd = (HWND) lParam;
  603. int t = (int) SendMessage(swnd,TBM_GETPOS,0,0);
  604. if (swnd == GetDlgItem(hwndDlg,IDC_SLIDER1))
  605. {
  606. cfg_speed&=~0xff00;
  607. cfg_speed|=(t<<8);
  608. }
  609. }
  610. return 0;
  611. case WM_COMMAND:
  612. switch (LOWORD(wParam))
  613. {
  614. case IDC_BUTTON1:
  615. if (IsDlgButtonChecked(hwndDlg,IDC_USE_OVERLAY) || DDraw_IsMode(cfg_fs_w,cfg_fs_h,cfg_fs_bpp))
  616. {
  617. SetForegroundWindow(g_hwnd);
  618. PostMessage(g_hwnd,WM_USER+32,0,0);
  619. } else
  620. {
  621. char title[32];
  622. MessageBox(hwndDlg,WASABI_API_LNGSTRING(IDS_CHOOSE_A_VIDEO_MODE),
  623. WASABI_API_LNGSTRING_BUF(IDS_AVS_FULLSCREEN,title,32),MB_OK);
  624. }
  625. return 0;
  626. case IDC_BPP_CONV:
  627. cfg_fs_flip&=~8;
  628. cfg_fs_flip|=IsDlgButtonChecked(hwndDlg,IDC_BPP_CONV)?0:8;
  629. return 0;
  630. case IDC_CHECK6:
  631. cfg_fs_dblclk=!!IsDlgButtonChecked(hwndDlg,IDC_CHECK6);
  632. return 0;
  633. case IDC_CHECK1:
  634. cfg_fs_d&=~1;
  635. cfg_fs_d|=IsDlgButtonChecked(hwndDlg,IDC_CHECK1)?1:0;
  636. return 0;
  637. case IDC_CHECK2:
  638. cfg_fs_fps&=~1;
  639. cfg_fs_fps|=IsDlgButtonChecked(hwndDlg,IDC_CHECK2)?1:0;
  640. return 0;
  641. case IDC_CHECK3:
  642. cfg_fs_fps&=~8;
  643. cfg_fs_fps|=IsDlgButtonChecked(hwndDlg,IDC_CHECK3)?8:0;
  644. return 0;
  645. case IDC_CHECK5:
  646. cfg_fs_fps&=~16;
  647. cfg_fs_fps|=IsDlgButtonChecked(hwndDlg,IDC_CHECK5)?16:0;
  648. return 0;
  649. case IDC_CHECK4:
  650. cfg_fs_flip&=~1;
  651. cfg_fs_flip|=IsDlgButtonChecked(hwndDlg,IDC_CHECK4)?1:0;
  652. return 0;
  653. case IDC_CHECK7:
  654. cfg_fs_flip&=~2;
  655. cfg_fs_flip|=IsDlgButtonChecked(hwndDlg,IDC_CHECK7)?0:2;
  656. return 0;
  657. case IDC_CHECK8:
  658. cfg_cancelfs_on_deactivate = IsDlgButtonChecked(hwndDlg,IDC_CHECK8)?0:1;
  659. return 0;
  660. case IDC_EDIT1:
  661. if (HIWORD(wParam) == EN_CHANGE) {
  662. BOOL t;
  663. int r=GetDlgItemInt(hwndDlg,IDC_EDIT1,&t,FALSE);
  664. if (r > 0 && r <= 100 && t)
  665. cfg_fs_height=r;
  666. }
  667. return 0;
  668. case IDC_COMBO1:
  669. if (HIWORD(wParam) == CBN_SELCHANGE)
  670. {
  671. int bps=-1;
  672. char b[256],*p=b;
  673. int l=SendDlgItemMessage(hwndDlg,IDC_COMBO1,CB_GETCURSEL,0,0);
  674. if (l == CB_ERR) return 0;
  675. SendDlgItemMessage(hwndDlg,IDC_COMBO1,CB_GETLBTEXT,l,(long)b);
  676. int w,h;
  677. while (*p >= '0' && *p <= '9') p++;
  678. if (!*p) return 0;
  679. *p++=0;
  680. w=atoi(b);
  681. while (*p < '0' && *p > '9' && *p) p ++;
  682. h=atoi(p);
  683. while (*p >= '0' && *p <= '9') p++;
  684. if (!*p) return 0;
  685. p++;
  686. bps=atoi(p);
  687. if (w < 1|| h < 1 || bps < 1) return 0;
  688. cfg_fs_h=h;
  689. cfg_fs_w=w;
  690. cfg_fs_bpp=bps;
  691. }
  692. return 0;
  693. case IDC_USE_OVERLAY:
  694. cfg_fs_use_overlay=IsDlgButtonChecked(hwndDlg,IDC_USE_OVERLAY)?1:0;
  695. enableFSWindows(hwndDlg,!cfg_fs_use_overlay);
  696. EnableWindow(GetDlgItem(hwndDlg, IDC_CHECK8), cfg_fs_use_overlay);
  697. return 0;
  698. }
  699. return 0;
  700. }
  701. return 0;
  702. }
  703. static void _insertintomenu2(HMENU hMenu, int wid, int id, char *str)
  704. {
  705. int x;
  706. for (x=0; x < 4096; x ++)
  707. {
  708. MENUITEMINFO mi={sizeof(mi),MIIM_DATA|MIIM_TYPE|MIIM_SUBMENU,MFT_STRING};
  709. char c[512];
  710. mi.dwTypeData=c;
  711. mi.cch = 512;
  712. if (!GetMenuItemInfo(hMenu,x,TRUE,&mi)) break;
  713. if (strcmp(str,c)<0 && !mi.hSubMenu)
  714. break;
  715. }
  716. MENUITEMINFO i={sizeof(i),};
  717. i.wID = wid;
  718. i.fMask=MIIM_TYPE|MIIM_DATA|MIIM_ID;
  719. i.fType=MFT_STRING;
  720. i.dwItemData=id;
  721. i.dwTypeData=str;
  722. i.cch=strlen(str);
  723. InsertMenuItem(hMenu,x,TRUE,&i);
  724. }
  725. static HMENU _findsubmenu(HMENU hmenu, char *str)
  726. {
  727. int x;
  728. for (x=0; x < 4096; x ++)
  729. {
  730. MENUITEMINFO mi={sizeof(mi),MIIM_DATA|MIIM_TYPE|MIIM_SUBMENU,MFT_STRING};
  731. char c[512];
  732. mi.dwTypeData=c;
  733. mi.cch = 512;
  734. if (!GetMenuItemInfo(hmenu,x,TRUE,&mi)) break;
  735. if (!strcmp(str,c) && mi.hSubMenu) return mi.hSubMenu;
  736. }
  737. return 0;
  738. }
  739. static void _insertintomenu(HMENU hMenu, int wid, int id, char *str)
  740. {
  741. char ostr[1024];
  742. strncpy(ostr,str,1023);
  743. char *first=str;
  744. char *second=str;
  745. while (*second && *second != '/') second++;
  746. if (*second) *second++=0;
  747. if (*second)
  748. {
  749. while (*second == ' ' || *second == '/') second++;
  750. if (*second)
  751. {
  752. HMENU hs;
  753. if (!(hs=_findsubmenu(hMenu,first)))
  754. {
  755. MENUITEMINFO i={sizeof(i),};
  756. i.fMask=MIIM_TYPE|MIIM_SUBMENU|MIIM_DATA|MIIM_ID;
  757. i.fType=MFT_STRING;
  758. i.dwTypeData = first;
  759. i.cch = strlen(first);
  760. i.hSubMenu=hs=CreatePopupMenu();
  761. i.wID=0;
  762. InsertMenuItem(hMenu,0,TRUE,&i);
  763. }
  764. _insertintomenu2(hs,wid,id,second);
  765. return;
  766. }
  767. }
  768. _insertintomenu2(hMenu,wid,id,ostr);
  769. }
  770. static HTREEITEM g_dragsource_item,g_dragsource_parent, g_draglastdest, g_dragplace;
  771. static int g_dragplaceisbelow;
  772. extern int findInMenu(HMENU parent, HMENU sub, UINT id, char *buf, int buf_len);
  773. #define UNDO_TIMER_INTERVAL 333
  774. static WNDPROC sniffConfigWindow_oldProc;
  775. static BOOL CALLBACK sniffConfigWindow_newProc(HWND hwndDlg, UINT uMsg, WPARAM wParam,LPARAM lParam)
  776. {
  777. bool dirty = false;
  778. if (uMsg == WM_COMMAND || uMsg == WM_HSCROLL || uMsg == WM_VSCROLL)
  779. {
  780. if (uMsg != WM_COMMAND || HIWORD(wParam) == EN_CHANGE ||
  781. HIWORD(wParam) == BN_CLICKED ||
  782. HIWORD(wParam) == LBN_SELCHANGE ||
  783. HIWORD(wParam) == CBN_SELCHANGE
  784. )
  785. dirty = true;
  786. }
  787. BOOL retval = CallWindowProc(sniffConfigWindow_oldProc,hwndDlg,uMsg,wParam,lParam);
  788. // Don't save the new state until the window proc handles it. :)
  789. if (dirty)
  790. {
  791. KillTimer(GetParent(hwndDlg),69);
  792. SetTimer(GetParent(hwndDlg),69,UNDO_TIMER_INTERVAL,NULL);
  793. // g_preset_dirty=1;
  794. }
  795. return retval;
  796. }
  797. int dosavePreset(HWND hwndDlg)
  798. {
  799. int r=1;
  800. char temp[2048];
  801. OPENFILENAME l={sizeof(l),0};
  802. char buf1[2048],buf2[2048];
  803. char filter[128], *ptr = filter;
  804. char savePreset[64];
  805. WASABI_API_LNGSTRING_BUF(IDS_AVS_FILTER_STRING,filter,128);
  806. while(*ptr)
  807. {
  808. if (*ptr=='|') *ptr=0;
  809. ptr++;
  810. }
  811. temp[0]=0;
  812. GetCurrentDirectory(sizeof(buf2),buf2);
  813. strcpy(buf1,g_path);
  814. l.hwndOwner = hwndDlg;
  815. l.lpstrFilter = filter;
  816. l.lpstrFile = temp;
  817. strcpy(temp,last_preset);
  818. l.nMaxFile = 2048-1;
  819. l.lpstrTitle = WASABI_API_LNGSTRING_BUF(IDS_SAVE_PRESET,savePreset,64);
  820. l.lpstrDefExt = "AVS";
  821. l.lpstrInitialDir = buf1;
  822. l.Flags = OFN_HIDEREADONLY|OFN_EXPLORER|OFN_OVERWRITEPROMPT;
  823. if (GetSaveFileName(&l))
  824. {
  825. strcpy(last_preset,temp); // this was changed from: lstrcpyn(last_preset,temp, 2048);
  826. r=g_render_effects->__SavePreset(temp);
  827. if (r==1) MessageBox(hwndDlg,WASABI_API_LNGSTRING(IDS_ERROR_SAVING_PRESET),savePreset,MB_OK);
  828. else if (r==2) MessageBox(hwndDlg,WASABI_API_LNGSTRING(IDS_PRESET_TOO_LARGE),savePreset,MB_OK);
  829. else if (r==-1) MessageBox(hwndDlg,WASABI_API_LNGSTRING(IDS_OUT_OF_MEMORY),savePreset,MB_OK);
  830. else
  831. {
  832. C_UndoStack::cleardirty();
  833. // g_preset_dirty=0;
  834. }
  835. }
  836. SetCurrentDirectory(buf2);
  837. return r;
  838. }
  839. extern int g_config_seh;
  840. static BOOL CALLBACK debugProc(HWND hwndDlg, UINT uMsg, WPARAM wParam,LPARAM lParam)
  841. {
  842. extern int debug_reg[8];
  843. switch (uMsg)
  844. {
  845. case WM_INITDIALOG:
  846. {
  847. int x;
  848. for (x = 0; x < 8; x ++)
  849. {
  850. SetDlgItemInt(hwndDlg,IDC_DEBUGREG_1+x*2,debug_reg[x],FALSE);
  851. }
  852. SetTimer(hwndDlg,1,250,NULL);
  853. }
  854. if (g_log_errors) CheckDlgButton(hwndDlg,IDC_CHECK1,BST_CHECKED);
  855. if (g_reset_vars_on_recompile) CheckDlgButton(hwndDlg,IDC_CHECK2,BST_CHECKED);
  856. if (!g_config_seh) CheckDlgButton(hwndDlg,IDC_CHECK3,BST_CHECKED);
  857. return 0;
  858. case WM_TIMER:
  859. if (wParam == 1)
  860. {
  861. int x;
  862. for (x = 0; x < 8; x ++)
  863. {
  864. char buf[128];
  865. int v=debug_reg[x];
  866. if (v >=0 && v < 100)
  867. sprintf(buf,"%.14f",NSEEL_getglobalregs()[v]);
  868. else strcpy(buf,"?");
  869. SetDlgItemText(hwndDlg,IDC_DEBUGREG_1+x*2+1,buf);
  870. }
  871. if (g_log_errors)
  872. {
  873. //IDC_EDIT1
  874. EnterCriticalSection(&g_eval_cs);
  875. char buf[1025];
  876. GetDlgItemText(hwndDlg,IDC_EDIT1,buf,sizeof(buf)-1);
  877. buf[sizeof(buf)-1]=0;
  878. if (strcmp(buf,last_error_string))
  879. SetDlgItemText(hwndDlg,IDC_EDIT1,last_error_string);
  880. LeaveCriticalSection(&g_eval_cs);
  881. }
  882. {
  883. char buf[512];
  884. int *g_evallib_stats=NSEEL_getstats();
  885. wsprintf(buf,WASABI_API_LNGSTRING(IDS_EVAL_CODE_STATS_ETC),
  886. g_evallib_stats[4],g_evallib_stats[0],g_evallib_stats[1],g_evallib_stats[2],g_evallib_stats[3]);
  887. SetDlgItemText(hwndDlg,IDC_EDIT2,buf);
  888. }
  889. }
  890. return 0;
  891. case WM_COMMAND:
  892. switch (LOWORD(wParam))
  893. {
  894. case IDC_CHECK1:
  895. g_log_errors = !!IsDlgButtonChecked(hwndDlg,IDC_CHECK1);
  896. return 0;
  897. case IDC_CHECK2:
  898. g_reset_vars_on_recompile = !!IsDlgButtonChecked(hwndDlg,IDC_CHECK2);
  899. return 0;
  900. case IDC_CHECK3:
  901. g_config_seh = !IsDlgButtonChecked(hwndDlg,IDC_CHECK3);
  902. return 0;
  903. case IDC_BUTTON1:
  904. EnterCriticalSection(&g_eval_cs);
  905. last_error_string[0]=0;
  906. SetDlgItemText(hwndDlg,IDC_EDIT1,"");
  907. LeaveCriticalSection(&g_eval_cs);
  908. return 0;
  909. case IDOK:
  910. case IDCANCEL:
  911. DestroyWindow(hwndDlg);
  912. return 0;
  913. default:
  914. if (HIWORD(wParam) == EN_CHANGE && LOWORD(wParam) >= IDC_DEBUGREG_1 && LOWORD(wParam) <= IDC_DEBUGREG_16)
  915. {
  916. int x=LOWORD(wParam)-IDC_DEBUGREG_1;
  917. if (!(x&1))
  918. {
  919. x/=2;
  920. if (x > 7) x= 7;
  921. BOOL t;
  922. int v=GetDlgItemInt(hwndDlg,IDC_DEBUGREG_1+x*2,&t,FALSE);
  923. if (t) debug_reg[x]=v;
  924. }
  925. }
  926. break;
  927. }
  928. return 0;
  929. case WM_DESTROY:
  930. g_debugwnd=0;
  931. return 0;
  932. }
  933. return 0;
  934. }
  935. static BOOL CALLBACK dlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam,LPARAM lParam)
  936. {
  937. static HMENU presetTreeMenu;
  938. static int presetTreeCount;
  939. extern int need_redock;
  940. extern int inWharf;
  941. extern void toggleWharfAmpDock(HWND hwnd);
  942. switch (uMsg)
  943. {
  944. case WM_INITMENU:
  945. EnableMenuItem((HMENU)wParam,IDM_UNDO,MF_BYCOMMAND|(C_UndoStack::can_undo()?MF_ENABLED:MF_GRAYED));
  946. EnableMenuItem((HMENU)wParam,IDM_REDO,MF_BYCOMMAND|(C_UndoStack::can_redo()?MF_ENABLED:MF_GRAYED));
  947. return 0;
  948. case WM_INITMENUPOPUP:
  949. if (!HIWORD(lParam) && presetTreeMenu && !GetMenuItemCount((HMENU)wParam))
  950. {
  951. char buf[2048];
  952. buf[0]=0;
  953. if (findInMenu(presetTreeMenu,(HMENU)wParam,0,buf,2048))
  954. {
  955. HANDLE h;
  956. WIN32_FIND_DATA d;
  957. char dirmask[4096];
  958. wsprintf(dirmask,"%s%s\\*.*",g_path,buf);
  959. int directory_pos=0, insert_pos=0;
  960. // build menu
  961. h = FindFirstFile(dirmask,&d);
  962. if (h != INVALID_HANDLE_VALUE)
  963. {
  964. do
  965. {
  966. if (d.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY && d.cFileName[0] != '.')
  967. {
  968. MENUITEMINFO mi={sizeof(mi),MIIM_SUBMENU|MIIM_TYPE,MFT_STRING,MFS_DEFAULT };
  969. mi.hSubMenu=CreatePopupMenu();
  970. mi.dwTypeData=d.cFileName;
  971. mi.cch = strlen(d.cFileName);
  972. InsertMenuItem((HMENU)wParam,directory_pos++,TRUE,&mi);
  973. insert_pos++;
  974. }
  975. else if (!stricmp(extension(d.cFileName),"avs"))
  976. {
  977. extension(d.cFileName)[-1]=0;
  978. MENUITEMINFO i={sizeof(i),MIIM_TYPE|MIIM_DATA|MIIM_ID,MFT_STRING,MFS_DEFAULT };
  979. i.dwTypeData = d.cFileName;
  980. i.cch = strlen(d.cFileName);
  981. i.dwItemData=0xFFFFFFFF;//preset
  982. i.wID=presetTreeCount++;
  983. InsertMenuItem((HMENU)wParam,insert_pos++,TRUE,&i);
  984. }
  985. } while (FindNextFile(h,&d));
  986. FindClose(h);
  987. }
  988. }
  989. }
  990. return 0;
  991. case WM_USER+20:
  992. CfgWnd_Unpopulate();
  993. CfgWnd_Populate();
  994. return 0;
  995. case WM_CLOSE:
  996. if (inWharf)
  997. {
  998. #ifdef WA2_EMBED
  999. toggleWharfAmpDock(g_hwnd);
  1000. }
  1001. #else
  1002. PostMessage(g_hwnd,WM_CLOSE,0,0);
  1003. }
  1004. else
  1005. #endif
  1006. {
  1007. cfg_cfgwnd_open=0;
  1008. ShowWindow(hwndDlg,SW_HIDE);
  1009. }
  1010. return 0;
  1011. case WM_DESTROY:
  1012. return 0;
  1013. case WM_INITDIALOG:
  1014. {
  1015. #ifdef LASER
  1016. HMENU m=GetMenu(hwndDlg);
  1017. m=GetSubMenu(m,1);
  1018. DeleteMenu(m,IDM_TRANSITIONS,MF_BYCOMMAND);
  1019. #endif
  1020. g_hwndDlg=hwndDlg;
  1021. //SetDlgItemText(hwndDlg,IDC_AVS_VER,verstr);
  1022. WASABI_API_LNGSTRING_BUF(IDS_NO_EFFECT_SETTING_SELECTED,g_noeffectstr,48);
  1023. TreeView_SetIndent(GetDlgItem(hwndDlg,IDC_TREE1),8);
  1024. SetTimer(hwndDlg,1,250,NULL);
  1025. if (cfg_cfgwnd_open)
  1026. ShowWindow(hwndDlg,SW_SHOWNA);
  1027. CfgWnd_Populate();
  1028. SetWindowPos(hwndDlg,NULL,cfg_cfgwnd_x,cfg_cfgwnd_y,0,0,SWP_NOSIZE|SWP_NOACTIVATE|SWP_NOZORDER);
  1029. if (need_redock)
  1030. {
  1031. need_redock=0;
  1032. toggleWharfAmpDock(g_hwnd);
  1033. }
  1034. else
  1035. {
  1036. RECT r,r2;
  1037. // hide IDC_RRECT, resize IDC_TREE1 up
  1038. GetWindowRect(GetDlgItem(g_hwndDlg,IDC_RRECT),&r);
  1039. GetWindowRect(GetDlgItem(g_hwndDlg,IDC_TREE1),&r2);
  1040. ShowWindow(GetDlgItem(g_hwndDlg,IDC_RRECT),SW_HIDE);
  1041. SetWindowPos(GetDlgItem(g_hwndDlg,IDC_TREE1),NULL,0,0,r2.right-r2.left,r.bottom - r2.top - 2,SWP_NOMOVE|SWP_NOZORDER|SWP_NOACTIVATE);
  1042. }
  1043. }
  1044. return TRUE;
  1045. case WM_TIMER:
  1046. if (wParam == 1)
  1047. {
  1048. char s[1024];
  1049. char *tp=last_preset;
  1050. while (*tp) tp++;
  1051. while (tp >= last_preset && *tp != '\\')
  1052. tp--;
  1053. tp++;
  1054. wsprintf(s,"%d.%d FPS @ %dx%d%s%s",g_dlg_fps/10,g_dlg_fps%10,g_dlg_w,g_dlg_h,*tp?" - ":".",tp);
  1055. tp=s;
  1056. while (*tp) tp++;
  1057. while (tp > s && *tp != '.' && *tp != '-') tp--;
  1058. if (*tp == '.') *tp=0;
  1059. SetDlgItemText(hwndDlg,IDC_FPS,s);
  1060. }
  1061. if (wParam == 69)
  1062. {
  1063. KillTimer(hwndDlg,69);
  1064. C_UndoStack::saveundo();
  1065. }
  1066. return FALSE;
  1067. case WM_MOUSEMOVE:
  1068. if (g_dragsource_item)
  1069. {
  1070. TVHITTESTINFO hti={0,};
  1071. HWND hwnd=GetDlgItem(hwndDlg,IDC_TREE1);
  1072. hti.pt.x=(int)LOWORD(lParam);
  1073. hti.pt.y=(int)HIWORD(lParam);
  1074. ClientToScreen(hwndDlg,&hti.pt);
  1075. ScreenToClient(hwnd,&hti.pt);
  1076. HTREEITEM h=TreeView_HitTest(hwnd,&hti);
  1077. if (hti.flags&TVHT_ABOVE)
  1078. {
  1079. SendMessage(hwnd,WM_VSCROLL,SB_LINEUP,NULL);
  1080. }
  1081. if (hti.flags&TVHT_BELOW)
  1082. {
  1083. SendMessage(hwnd,WM_VSCROLL,SB_LINEDOWN,NULL);
  1084. }
  1085. if (hti.flags&TVHT_NOWHERE)
  1086. {
  1087. h=g_hroot;
  1088. }
  1089. if ((hti.flags&(TVHT_NOWHERE|TVHT_ONITEMINDENT|TVHT_ONITEMRIGHT|TVHT_ONITEM|TVHT_ONITEMBUTTON))&&h)
  1090. {
  1091. HTREEITEM temp=h;
  1092. while (temp && temp != TVI_ROOT)
  1093. {
  1094. if (temp==g_dragsource_item)
  1095. {
  1096. h=g_dragsource_item;
  1097. break;
  1098. }
  1099. temp=TreeView_GetParent(hwnd,temp);
  1100. }
  1101. if (h == g_dragsource_item)
  1102. {
  1103. SetCursor(LoadCursor(NULL, MAKEINTRESOURCE(IDC_NO)));
  1104. if (g_dragplace) TreeView_DeleteItem(hwnd,g_dragplace);
  1105. g_dragplace=0;
  1106. }
  1107. else
  1108. {
  1109. SetCursor(LoadCursor(NULL, MAKEINTRESOURCE(IDC_ARROW)));
  1110. TV_ITEM i={TVIF_HANDLE|TVIF_PARAM,h,0,0,0,0,0};
  1111. TreeView_GetItem(hwnd,&i);
  1112. if(i.lParam)
  1113. {
  1114. RECT r;
  1115. TreeView_GetItemRect(hwnd,h,&r,FALSE);
  1116. if (hti.pt.y > r.bottom-(r.bottom-r.top)/2) g_dragplaceisbelow=1;
  1117. else g_dragplaceisbelow=0;
  1118. HTREEITEM parenth;
  1119. g_draglastdest=h;
  1120. C_RenderListClass::T_RenderListType *it=(C_RenderListClass::T_RenderListType *)i.lParam;
  1121. if (it->effect_index==LIST_ID && (hti.flags&(TVHT_ONITEMINDENT|TVHT_ONITEMBUTTON)||h==g_hroot))
  1122. {
  1123. if (g_dragplace && (TreeView_GetParent(hwnd,g_dragplace)!=h ||
  1124. TreeView_GetNextSibling(hwnd,g_dragplace)))
  1125. {
  1126. TreeView_DeleteItem(hwnd,g_dragplace);
  1127. g_dragplace=0;
  1128. }
  1129. g_dragplaceisbelow=2;
  1130. parenth=h;
  1131. h=TVI_LAST;
  1132. }
  1133. else
  1134. {
  1135. parenth=TreeView_GetParent(hwnd,h);
  1136. if (g_dragplace && ((g_dragplaceisbelow&1)?
  1137. TreeView_GetNextSibling(hwnd,h)!=g_dragplace:
  1138. TreeView_GetPrevSibling(hwnd,h)!=g_dragplace))
  1139. {
  1140. TreeView_DeleteItem(hwnd,g_dragplace);
  1141. g_dragplace=0;
  1142. }
  1143. if (!g_dragplaceisbelow)
  1144. {
  1145. h=TreeView_GetPrevSibling(hwnd,h);
  1146. if (!h) h=TVI_FIRST;
  1147. }
  1148. }
  1149. if (!g_dragplace)
  1150. {
  1151. TV_INSERTSTRUCT is={parenth,h,{TVIF_PARAM|TVIF_TEXT|TVIF_CHILDREN,0,0,0,
  1152. WASABI_API_LNGSTRING(IDS_MOVE_HERE),0,0,0,0,(int)0}};
  1153. g_dragplace=TreeView_InsertItem(hwnd,&is);
  1154. if (g_dragplaceisbelow==2)
  1155. SendMessage(hwnd,TVM_EXPAND,TVE_EXPAND,(long)parenth);
  1156. }
  1157. }
  1158. }
  1159. }
  1160. return 0;
  1161. }
  1162. break;
  1163. case WM_LBUTTONUP:
  1164. if (g_dragsource_item)
  1165. {
  1166. HWND hwnd=GetDlgItem(hwndDlg,IDC_TREE1);
  1167. SetCursor(LoadCursor(NULL, MAKEINTRESOURCE(IDC_ARROW)));
  1168. if (g_dragplace)
  1169. {
  1170. TreeView_DeleteItem(hwnd,g_dragplace);
  1171. g_dragplace=0;
  1172. }
  1173. HTREEITEM h=g_draglastdest;
  1174. if (h)
  1175. {
  1176. C_RenderListClass::T_RenderListType *source, *source_parent;
  1177. C_RenderListClass::T_RenderListType *dest, // handle of item to insert above. NULL if end.
  1178. *dest_parent=NULL; // handle of parent to insert into
  1179. HTREEITEM dest_handle=h, // handle of item to insert above. NULL if folder.
  1180. dest_parent_handle=TreeView_GetParent(hwnd,h); // handle of parent
  1181. {
  1182. TV_ITEM i={TVIF_HANDLE|TVIF_PARAM,dest_handle,0,0,0,0,0};
  1183. TreeView_GetItem(hwnd,&i);
  1184. dest=(C_RenderListClass::T_RenderListType *)i.lParam;
  1185. }
  1186. if (dest_parent_handle)
  1187. {
  1188. TV_ITEM i={TVIF_HANDLE|TVIF_PARAM,dest_parent_handle,0,0,0,0,0};
  1189. TreeView_GetItem(hwnd,&i);
  1190. dest_parent=(C_RenderListClass::T_RenderListType *)i.lParam;
  1191. }
  1192. if (dest->effect_index==LIST_ID && (!dest_parent_handle||g_dragplaceisbelow==2))
  1193. {
  1194. dest_parent_handle=dest_handle;
  1195. dest_handle=NULL;
  1196. dest_parent=dest;
  1197. dest=NULL;
  1198. }
  1199. TV_ITEM i={TVIF_HANDLE|TVIF_PARAM|TVIF_STATE,g_dragsource_item,0,TVIS_EXPANDED,0,0,0};
  1200. TreeView_GetItem(hwnd,&i);
  1201. int expand=i.state&TVIS_EXPANDED;
  1202. source=(C_RenderListClass::T_RenderListType *)i.lParam;
  1203. TV_ITEM i2={TVIF_HANDLE|TVIF_PARAM,g_dragsource_parent,0,0,0,0,0};
  1204. TreeView_GetItem(hwnd,&i2);
  1205. source_parent=(C_RenderListClass::T_RenderListType *)i2.lParam;
  1206. int recurse_okay=1;
  1207. {
  1208. HTREEITEM temp=dest_parent_handle;
  1209. while (temp && temp != TVI_ROOT)
  1210. {
  1211. if (temp==g_dragsource_item) recurse_okay=0;
  1212. temp=TreeView_GetParent(hwnd,temp);
  1213. }
  1214. }
  1215. if (dest_handle != g_dragsource_item && recurse_okay)
  1216. {
  1217. C_RenderListClass *s=(C_RenderListClass *)source_parent->render;
  1218. C_RenderListClass *d=(C_RenderListClass *)dest_parent->render;
  1219. int os=0;
  1220. int a=s->findRender(source);
  1221. int b=d->findRender(dest);
  1222. int err=1;
  1223. if (a >= 0)
  1224. {
  1225. EnterCriticalSection(&g_render_cs);
  1226. err=s->removeRender(a,0);
  1227. if (!err)
  1228. {
  1229. d->insertRender(source,b+(g_dragplaceisbelow&1));
  1230. }
  1231. LeaveCriticalSection(&g_render_cs);
  1232. }
  1233. if (err)
  1234. {
  1235. char title[48];
  1236. MessageBox(NULL,WASABI_API_LNGSTRING(IDS_ERROR_TREE_INCONSISTANCY),
  1237. WASABI_API_LNGSTRING_BUF(IDS_CRITICAL_ERROR_OCCURRED,title,48),MB_OK);
  1238. }
  1239. treeview_hack=1;
  1240. TreeView_DeleteItem(hwnd,g_dragsource_item);
  1241. TV_INSERTSTRUCT is={dest_parent_handle,0,{TVIF_PARAM|TVIF_TEXT|TVIF_CHILDREN,0,0,0,source->render->get_desc(),0,0,0,source->effect_index==LIST_ID?1:0,(int)source}};
  1242. if (dest_handle)
  1243. {
  1244. if (g_dragplaceisbelow&1) is.hInsertAfter=dest_handle;
  1245. else
  1246. {
  1247. is.hInsertAfter=TreeView_GetPrevSibling(hwnd,dest_handle);
  1248. if (!is.hInsertAfter) is.hInsertAfter=TVI_FIRST;
  1249. }
  1250. }
  1251. else is.hInsertAfter=TVI_LAST;
  1252. HTREEITEM newi=TreeView_InsertItem(hwnd,&is);
  1253. if (source->effect_index == LIST_ID)
  1254. {
  1255. _do_add(hwnd,newi,(C_RenderListClass *)source->render);
  1256. if (expand) SendMessage(hwnd,TVM_EXPAND,TVE_EXPAND,(long)newi);
  1257. }
  1258. TreeView_Select(hwnd,newi,TVGN_CARET);
  1259. treeview_hack=0;
  1260. // After everything is changed, then save the undo and set the dirty bit.
  1261. KillTimer(hwndDlg,69);
  1262. SetTimer(hwndDlg,69,UNDO_TIMER_INTERVAL,NULL);
  1263. // g_preset_dirty=1;
  1264. }
  1265. }
  1266. TreeView_Select(hwnd,NULL,TVGN_DROPHILITE);
  1267. ReleaseCapture();
  1268. g_dragsource_item=0;
  1269. return 0;
  1270. }
  1271. break;
  1272. case WM_NOTIFY:
  1273. {
  1274. NM_TREEVIEW* p = (NM_TREEVIEW*)lParam;
  1275. if (p->hdr.hwndFrom == GetDlgItem(hwndDlg, IDC_TREE1))
  1276. {
  1277. // Element is being dragged
  1278. if (p->hdr.code==TVN_BEGINDRAG)
  1279. {
  1280. if (p->itemNew.hItem != g_hroot)
  1281. {
  1282. g_draglastdest=0;
  1283. g_dragsource_parent=TreeView_GetParent(p->hdr.hwndFrom,p->itemNew.hItem);
  1284. if (g_dragsource_parent)
  1285. {
  1286. SetCapture(hwndDlg);
  1287. g_dragsource_item=p->itemNew.hItem;
  1288. g_dragplace=0;
  1289. TreeView_Select(p->hdr.hwndFrom,g_dragsource_item,TVGN_CARET);
  1290. SetCursor(LoadCursor(NULL, MAKEINTRESOURCE(IDC_APPSTARTING)));
  1291. }
  1292. else
  1293. g_dragsource_item=NULL;
  1294. }
  1295. else
  1296. g_dragsource_item=NULL;
  1297. }
  1298. // new element is selected selectis
  1299. if ((p->hdr.code== TVN_SELCHANGEDW || p->hdr.code == TVN_SELCHANGEDA) && !treeview_hack)
  1300. {
  1301. HTREEITEM hTreeItem = TreeView_GetSelection(p->hdr.hwndFrom);
  1302. if (hTreeItem)
  1303. {
  1304. TV_ITEM i={TVIF_HANDLE|TVIF_PARAM,hTreeItem,0,0,0,0,0};
  1305. TreeView_GetItem(p->hdr.hwndFrom,&i);
  1306. C_RenderListClass::T_RenderListType *tp=(C_RenderListClass::T_RenderListType *)i.lParam;
  1307. is_aux_wnd=0;
  1308. if (tp&&tp->render)
  1309. {
  1310. SetDlgItemText(hwndDlg,IDC_EFNAME,tp->render->get_desc());
  1311. if (cur_hwnd)
  1312. DestroyWindow(cur_hwnd);
  1313. cur_hwnd=tp->render->conf(g_render_library->GetRendererInstance(tp->effect_index,g_hInstance),hwndDlg);
  1314. if (cur_hwnd)
  1315. sniffConfigWindow_oldProc=(WNDPROC)SetWindowLong(cur_hwnd, GWLP_WNDPROC,(LONG)sniffConfigWindow_newProc);
  1316. }
  1317. if (cur_hwnd)
  1318. {
  1319. RECT r;
  1320. GetWindowRect(GetDlgItem(hwndDlg,IDC_EFFECTRECT),&r);
  1321. ScreenToClient(hwndDlg,(LPPOINT)&r);
  1322. SetWindowPos(cur_hwnd,0,r.left,r.top,0,0,SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOZORDER);
  1323. ShowWindow(cur_hwnd,SW_SHOWNA);
  1324. } else
  1325. SetDlgItemText(hwndDlg,IDC_EFNAME,g_noeffectstr);
  1326. }
  1327. }
  1328. // a tree view item has been clicked
  1329. }
  1330. }
  1331. break;
  1332. case WM_COMMAND:
  1333. switch (LOWORD(wParam))
  1334. {
  1335. case IDC_RRECT:
  1336. if (HIWORD(wParam)==1)
  1337. {
  1338. toggleWharfAmpDock(g_hwnd);
  1339. }
  1340. return 0;
  1341. case IDM_HELP_DEBUGWND:
  1342. if (!g_debugwnd) g_debugwnd=WASABI_API_CREATEDIALOG(IDD_DEBUG,g_hwnd,debugProc);
  1343. ShowWindow(g_debugwnd,SW_SHOW);
  1344. return 0;
  1345. case IDM_ABOUT:
  1346. // DialogBox(g_hInstance,MAKEINTRESOURCE(IDD_DIALOG2),hwndDlg,aboutProc);
  1347. about(hwndDlg);
  1348. return 0;
  1349. case IDM_DISPLAY:
  1350. case IDM_FULLSCREEN:
  1351. case IDM_PRESETS:
  1352. case IDM_BPM:
  1353. case IDM_TRANSITIONS:
  1354. {
  1355. int name_ids[5]={IDS_DISPLAY,IDS_FULLSCREEN_SETTINGS,IDS_PRESET_HOTKEYS,IDS_BEAT_DETECTION,IDS_TRANSITIONS};
  1356. int x=0;
  1357. if (LOWORD(wParam) == IDM_DISPLAY) x=1;
  1358. if (LOWORD(wParam) == IDM_FULLSCREEN) x=2;
  1359. if (LOWORD(wParam) == IDM_PRESETS) x=3;
  1360. if (LOWORD(wParam) == IDM_BPM) x=4;
  1361. if (LOWORD(wParam) == IDM_TRANSITIONS) x=5;
  1362. if (x >= 1 && x <= 5)
  1363. {
  1364. SetDlgItemText(hwndDlg,IDC_EFNAME,WASABI_API_LNGSTRING(name_ids[x-1]));
  1365. TreeView_Select(GetDlgItem(hwndDlg,IDC_TREE1),NULL,TVGN_CARET);
  1366. if (cur_hwnd) DestroyWindow(cur_hwnd);
  1367. if (x==1)
  1368. cur_hwnd=WASABI_API_CREATEDIALOG(IDD_GCFG_DISP,hwndDlg,DlgProc_Disp);
  1369. if (x==2)
  1370. cur_hwnd=WASABI_API_CREATEDIALOG(IDD_GCFG_FS,hwndDlg,DlgProc_FS);
  1371. if (x==3)
  1372. cur_hwnd=WASABI_API_CREATEDIALOG(IDD_GCFG_PRESET,hwndDlg,DlgProc_Preset);
  1373. if (x==4)
  1374. cur_hwnd=WASABI_API_CREATEDIALOG(IDD_GCFG_BPM,hwndDlg,DlgProc_Bpm);
  1375. if (x==5)
  1376. cur_hwnd=g_render_transition->conf(g_hInstance,hwndDlg);
  1377. if (cur_hwnd)
  1378. {
  1379. RECT r;
  1380. is_aux_wnd=1;
  1381. GetWindowRect(GetDlgItem(hwndDlg,IDC_EFFECTRECT),&r);
  1382. ScreenToClient(hwndDlg,(LPPOINT)&r);
  1383. SetWindowPos(cur_hwnd,0,r.left,r.top,0,0,SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOZORDER);
  1384. ShowWindow(cur_hwnd,SW_SHOWNA);
  1385. }
  1386. else
  1387. SetDlgItemText(hwndDlg,IDC_EFNAME,g_noeffectstr);
  1388. }
  1389. }
  1390. return 0;
  1391. case IDC_ADD:
  1392. {
  1393. C_RenderListClass::T_RenderListType ren={0};
  1394. RECT r;
  1395. presetTreeMenu=CreatePopupMenu();
  1396. HMENU hAddMenu=CreatePopupMenu();
  1397. // int insert_pos=0;
  1398. int p=64;
  1399. int x=0;
  1400. while (1)
  1401. {
  1402. char str[1024];
  1403. if (!g_render_library->GetRendererDesc(x,str))
  1404. break;
  1405. if (str[0])
  1406. _insertintomenu(hAddMenu,p++,x,str);
  1407. x++;
  1408. }
  1409. x=DLLRENDERBASE;
  1410. while (1)
  1411. {
  1412. char str[1024];
  1413. int id=g_render_library->GetRendererDesc(x++, str);
  1414. if (!id) break;
  1415. if (str[0]) _insertintomenu(hAddMenu,p++,id,str);
  1416. }
  1417. _insertintomenu(hAddMenu,p++,LIST_ID,WASABI_API_LNGSTRING(IDS_EFFECT_LIST));
  1418. int preset_base=presetTreeCount=p;
  1419. // add presets
  1420. {
  1421. MENUITEMINFO i={sizeof(i),};
  1422. i.hSubMenu=presetTreeMenu;
  1423. i.fMask=MIIM_SUBMENU|MIIM_TYPE|MIIM_ID;
  1424. i.fType=MFT_STRING;
  1425. i.dwTypeData = WASABI_API_LNGSTRING(IDS_PRESETS);
  1426. i.cch = strlen((char*)i.dwTypeData);
  1427. InsertMenuItem(hAddMenu,0,TRUE,&i);
  1428. i.hSubMenu=0;
  1429. i.fMask=MIIM_TYPE|MIIM_ID;
  1430. i.fType=MFT_SEPARATOR;
  1431. InsertMenuItem(hAddMenu,1,TRUE,&i);
  1432. HANDLE h;
  1433. WIN32_FIND_DATA d;
  1434. char dirmask[1024];
  1435. wsprintf(dirmask,"%s\\*.*",g_path);
  1436. int directory_pos=0,insert_pos=0;
  1437. h = FindFirstFile(dirmask,&d);
  1438. if (h != INVALID_HANDLE_VALUE)
  1439. {
  1440. do
  1441. {
  1442. if (d.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY && d.cFileName[0] != '.')
  1443. {
  1444. MENUITEMINFO mi={sizeof(mi),MIIM_SUBMENU|MIIM_TYPE,MFT_STRING,MFS_DEFAULT};
  1445. mi.hSubMenu=CreatePopupMenu();
  1446. mi.dwTypeData=d.cFileName;
  1447. mi.cch = strlen(d.cFileName);
  1448. InsertMenuItem(presetTreeMenu,directory_pos++,TRUE,&mi);
  1449. insert_pos++;
  1450. }
  1451. else if (!stricmp(extension(d.cFileName),"avs"))
  1452. {
  1453. extension(d.cFileName)[-1]=0;
  1454. MENUITEMINFO i={sizeof(i),MIIM_DATA|MIIM_TYPE|MIIM_ID,MFT_STRING,MFS_DEFAULT };
  1455. i.dwTypeData = d.cFileName;
  1456. i.cch = strlen(d.cFileName);
  1457. i.dwItemData=0xffffffff;
  1458. i.wID=presetTreeCount++;
  1459. InsertMenuItem(presetTreeMenu,insert_pos++,TRUE,&i);
  1460. }
  1461. } while (FindNextFile(h,&d));
  1462. FindClose(h);
  1463. }
  1464. }
  1465. GetWindowRect(GetDlgItem(hwndDlg,IDC_ADD),&r);
  1466. int t=TrackPopupMenu(hAddMenu,TPM_LEFTALIGN|TPM_TOPALIGN|TPM_RETURNCMD|TPM_RIGHTBUTTON|TPM_LEFTBUTTON,r.right,r.top,0,hwndDlg,NULL);
  1467. if (t)
  1468. {
  1469. char buf[2048];
  1470. buf[0]=0;
  1471. if (t >= preset_base)
  1472. {
  1473. if (findInMenu(presetTreeMenu,0,t,buf,2048))
  1474. {
  1475. //preset
  1476. C_RenderListClass *r;
  1477. char temp[4096];
  1478. ren.effect_index=LIST_ID;
  1479. wsprintf(temp,"%s%s.avs",g_path,buf);
  1480. r=new C_RenderListClass();
  1481. if (!r->__LoadPreset(temp,1))
  1482. {
  1483. ren.render=(C_RBASE*)r;
  1484. }
  1485. else
  1486. {
  1487. delete r;
  1488. ren.render=NULL;
  1489. }
  1490. }
  1491. }
  1492. else
  1493. {
  1494. MENUITEMINFO mi={sizeof(mi),MIIM_DATA,};
  1495. GetMenuItemInfo(hAddMenu,t,FALSE,&mi);
  1496. if (mi.dwItemData != 0xffffffff) // effect
  1497. {
  1498. ren.effect_index=mi.dwItemData;
  1499. ren.render=g_render_library->CreateRenderer(&ren.effect_index,&ren.has_rbase2);
  1500. }
  1501. }
  1502. if (ren.render)
  1503. {
  1504. int insert_pos=0;
  1505. HTREEITEM hTreeItem = TreeView_GetSelection(GetDlgItem(hwndDlg,IDC_TREE1));
  1506. C_RenderListClass *parentrender=g_render_effects;
  1507. HTREEITEM parenthandle=g_hroot;
  1508. if (hTreeItem)
  1509. {
  1510. TV_ITEM i={TVIF_HANDLE|TVIF_PARAM,hTreeItem,0,0,0,0,0};
  1511. TreeView_GetItem(GetDlgItem(hwndDlg,IDC_TREE1),&i);
  1512. C_RenderListClass::T_RenderListType *tp=(C_RenderListClass::T_RenderListType *)i.lParam;
  1513. if (tp->effect_index == LIST_ID)
  1514. {
  1515. parentrender=(C_RenderListClass *)tp->render;
  1516. parenthandle=hTreeItem;
  1517. }
  1518. else
  1519. {
  1520. HTREEITEM hParent=TreeView_GetParent(GetDlgItem(hwndDlg,IDC_TREE1),hTreeItem);
  1521. if (hParent && hParent != TVI_ROOT)
  1522. {
  1523. TV_ITEM i2={TVIF_HANDLE|TVIF_PARAM,hParent,0,0,0,0,0};
  1524. TreeView_GetItem(GetDlgItem(hwndDlg,IDC_TREE1),&i2);
  1525. C_RenderListClass::T_RenderListType *tparent=(C_RenderListClass::T_RenderListType *)i2.lParam;
  1526. parentrender=(C_RenderListClass *)tparent->render;
  1527. parenthandle=hParent;
  1528. }
  1529. for (insert_pos=0; insert_pos<parentrender->getNumRenders()
  1530. && parentrender->getRender(insert_pos)->render != tp->render; insert_pos++);
  1531. }
  1532. }
  1533. EnterCriticalSection(&g_render_cs);
  1534. parentrender->insertRender(&ren,insert_pos);
  1535. LeaveCriticalSection(&g_render_cs);
  1536. C_RenderListClass::T_RenderListType *newt=(C_RenderListClass::T_RenderListType *)GlobalAlloc(GMEM_FIXED,sizeof(C_RenderListClass::T_RenderListType));
  1537. *newt=ren;
  1538. TV_INSERTSTRUCT is={parenthandle,0,{TVIF_PARAM|TVIF_TEXT|TVIF_CHILDREN,0,0,0,ren.render->get_desc(),0,0,0,newt->effect_index==LIST_ID?1:0,(int)newt}};
  1539. if (!hTreeItem || parenthandle==hTreeItem)
  1540. {
  1541. is.hInsertAfter=TVI_FIRST;
  1542. }
  1543. else
  1544. {
  1545. is.hInsertAfter=TreeView_GetPrevSibling(GetDlgItem(hwndDlg,IDC_TREE1),hTreeItem);
  1546. if (!is.hInsertAfter) is.hInsertAfter=TVI_FIRST;
  1547. }
  1548. HTREEITEM newh=TreeView_InsertItem(GetDlgItem(hwndDlg,IDC_TREE1),&is);
  1549. TreeView_Select(GetDlgItem(hwndDlg,IDC_TREE1),newh,TVGN_CARET);
  1550. if (ren.effect_index == LIST_ID)
  1551. _do_add(GetDlgItem(hwndDlg,IDC_TREE1),newh,(C_RenderListClass *)ren.render);
  1552. // Always do undo last.
  1553. KillTimer(hwndDlg,69);
  1554. SetTimer(hwndDlg,69,UNDO_TIMER_INTERVAL,NULL);
  1555. // g_preset_dirty=1;
  1556. }
  1557. }
  1558. DestroyMenu(hAddMenu);
  1559. presetTreeMenu=0;
  1560. } // end of IDC_ADD
  1561. return 0;
  1562. case IDC_CLEAR:
  1563. if (readyToLoadPreset(hwndDlg,1))
  1564. {
  1565. if (g_render_transition->LoadPreset("",0) != 2)
  1566. last_preset[0]=0;
  1567. }
  1568. return 0;
  1569. case IDC_REMSEL:
  1570. {
  1571. HTREEITEM hTreeItem = TreeView_GetSelection(GetDlgItem(hwndDlg,IDC_TREE1));
  1572. if (hTreeItem == g_hroot)
  1573. {
  1574. CfgWnd_Unpopulate();
  1575. EnterCriticalSection(&g_render_cs);
  1576. g_render_effects->clearRenders();
  1577. LeaveCriticalSection(&g_render_cs);
  1578. CfgWnd_Populate();
  1579. }
  1580. else if (hTreeItem)
  1581. {
  1582. C_RenderListClass *parentrender;
  1583. TV_ITEM i={TVIF_HANDLE|TVIF_PARAM,hTreeItem,0,0,0,0,0};
  1584. if (TreeView_GetItem(GetDlgItem(hwndDlg,IDC_TREE1),&i))
  1585. {
  1586. C_RenderListClass::T_RenderListType *tp=(C_RenderListClass::T_RenderListType *)i.lParam;
  1587. HTREEITEM hParent=TreeView_GetParent(GetDlgItem(hwndDlg,IDC_TREE1),hTreeItem);
  1588. if (hParent != NULL)
  1589. {
  1590. TV_ITEM i2={TVIF_HANDLE|TVIF_PARAM,hParent,0,0,0,0,0};
  1591. TreeView_GetItem(GetDlgItem(hwndDlg,IDC_TREE1),&i2);
  1592. C_RenderListClass::T_RenderListType *tparent=(C_RenderListClass::T_RenderListType *)i2.lParam;
  1593. parentrender=(C_RenderListClass*)tparent->render;
  1594. EnterCriticalSection(&g_render_cs);
  1595. if (!parentrender->removeRenderFrom(tp,1))
  1596. {
  1597. TreeView_DeleteItem(GetDlgItem(hwndDlg,IDC_TREE1),hTreeItem);
  1598. if (tp)
  1599. GlobalFree((HGLOBAL)tp);
  1600. }
  1601. LeaveCriticalSection(&g_render_cs);
  1602. }
  1603. }
  1604. }
  1605. // Always save undo last.
  1606. KillTimer(hwndDlg,69);
  1607. SetTimer(hwndDlg,69,UNDO_TIMER_INTERVAL,NULL);
  1608. // g_preset_dirty=1;
  1609. }
  1610. return 0;
  1611. case IDC_CLONESEL:
  1612. {
  1613. C_RenderListClass::T_RenderListType ren={0,};
  1614. int insert_pos=-1;
  1615. HTREEITEM hTreeItem = TreeView_GetSelection(GetDlgItem(hwndDlg,IDC_TREE1));
  1616. if (hTreeItem && hTreeItem != g_hroot)
  1617. {
  1618. TV_ITEM i={TVIF_HANDLE|TVIF_PARAM,hTreeItem,0,0,0,0,0};
  1619. TreeView_GetItem(GetDlgItem(hwndDlg,IDC_TREE1),&i);
  1620. C_RenderListClass::T_RenderListType *tp=(C_RenderListClass::T_RenderListType *)i.lParam;
  1621. ren.effect_index=tp->effect_index;
  1622. ren.render=g_render_library->CreateRenderer(&ren.effect_index,&ren.has_rbase2);
  1623. if (ren.render)
  1624. {
  1625. HTREEITEM hParent=TreeView_GetParent(GetDlgItem(hwndDlg,IDC_TREE1),hTreeItem);
  1626. if (hParent && hParent != TVI_ROOT)
  1627. {
  1628. TV_ITEM i2={TVIF_HANDLE|TVIF_PARAM,hParent,0,0,0,0,0};
  1629. TreeView_GetItem(GetDlgItem(hwndDlg,IDC_TREE1),&i2);
  1630. C_RenderListClass::T_RenderListType *tparent=(C_RenderListClass::T_RenderListType *)i2.lParam;
  1631. C_RenderListClass *parentrender=(C_RenderListClass *)tparent->render;
  1632. for (insert_pos=0; insert_pos<parentrender->getNumRenders()
  1633. && parentrender->getRender(insert_pos)->render != tp->render; insert_pos++);
  1634. insert_pos++;
  1635. unsigned char *buf = (unsigned char *) GlobalAlloc(GPTR,1024*1024);
  1636. if (buf)
  1637. {
  1638. int len=tp->render->save_config(buf);
  1639. ren.render->load_config(buf,len);
  1640. GlobalFree((HGLOBAL)buf);
  1641. }
  1642. EnterCriticalSection(&g_render_cs);
  1643. parentrender->insertRender(&ren,insert_pos);
  1644. LeaveCriticalSection(&g_render_cs);
  1645. C_RenderListClass::T_RenderListType *newt=(C_RenderListClass::T_RenderListType *)GlobalAlloc(GMEM_FIXED,sizeof(C_RenderListClass::T_RenderListType));
  1646. *newt=ren;
  1647. TV_INSERTSTRUCT is={hParent,0,{TVIF_PARAM|TVIF_TEXT|TVIF_CHILDREN,0,0,0,ren.render->get_desc(),0,0,0,newt->effect_index==LIST_ID?1:0,(int)newt}};
  1648. is.hInsertAfter=hTreeItem;
  1649. HTREEITEM newh=TreeView_InsertItem(GetDlgItem(hwndDlg,IDC_TREE1),&is);
  1650. TreeView_Select(GetDlgItem(hwndDlg,IDC_TREE1),newh,TVGN_CARET);
  1651. if (ren.effect_index == LIST_ID)
  1652. _do_add(GetDlgItem(hwndDlg,IDC_TREE1),newh,(C_RenderListClass *)ren.render);
  1653. }
  1654. }
  1655. // Always save undo last.
  1656. KillTimer(hwndDlg,69);
  1657. SetTimer(hwndDlg,69,UNDO_TIMER_INTERVAL,NULL);
  1658. // g_preset_dirty=1;
  1659. }
  1660. }
  1661. return 0;
  1662. case IDC_LOAD:
  1663. {
  1664. char temp[2048];
  1665. OPENFILENAME l={sizeof(l),0};
  1666. char buf1[2048],buf2[2048];
  1667. char filter[128], *ptr = filter;
  1668. char loadPreset[64];
  1669. WASABI_API_LNGSTRING_BUF(IDS_AVS_FILTER_STRING,filter,128);
  1670. while(*ptr)
  1671. {
  1672. if (*ptr=='|') *ptr=0;
  1673. ptr++;
  1674. }
  1675. GetCurrentDirectory(sizeof(buf2),buf2);
  1676. strcpy(buf1,g_path); // this was changed from: lstrcpyn(buf1,g_path,sizeof(buf1));
  1677. temp[0]=0;
  1678. l.lpstrInitialDir = buf1;
  1679. l.hwndOwner = hwndDlg;
  1680. l.lpstrFilter = filter;
  1681. l.lpstrFile = temp;
  1682. l.nMaxFile = 2048-1;
  1683. l.lpstrTitle = WASABI_API_LNGSTRING_BUF(IDS_LOAD_PRESET,loadPreset,48);
  1684. l.lpstrDefExt = "AVS";
  1685. l.Flags = OFN_HIDEREADONLY|OFN_EXPLORER;
  1686. if (readyToLoadPreset(hwndDlg,0) && GetOpenFileName(&l))
  1687. {
  1688. int x=g_render_transition->LoadPreset(temp,0);
  1689. if (x == 2)
  1690. MessageBox(hwndDlg,WASABI_API_LNGSTRING(IDS_STILL_INITIALIZING_PREVIOUS_PRESET),loadPreset,MB_OK);
  1691. else
  1692. lstrcpyn(last_preset,temp,sizeof(last_preset));
  1693. }
  1694. SetCurrentDirectory(buf2);
  1695. }
  1696. return 0;
  1697. case IDC_SAVE:
  1698. dosavePreset(hwndDlg);
  1699. return 0;
  1700. case IDM_UNDO:
  1701. C_UndoStack::undo();
  1702. return 0;
  1703. case IDM_REDO:
  1704. C_UndoStack::redo();
  1705. return 0;
  1706. } // end of switch(LOWORD(Param))
  1707. return 0;
  1708. }// end of switch(uMsg)
  1709. return 0;
  1710. }
  1711. static void _do_add(HWND hwnd, HTREEITEM h, C_RenderListClass *list)
  1712. {
  1713. int x,l;
  1714. l=list->getNumRenders();
  1715. for (x = 0; x < l; x ++)
  1716. {
  1717. C_RenderListClass::T_RenderListType *t=list->getRender(x);
  1718. if (t)
  1719. {
  1720. C_RenderListClass::T_RenderListType *newt=(C_RenderListClass::T_RenderListType *)GlobalAlloc(GMEM_FIXED,sizeof(C_RenderListClass::T_RenderListType));
  1721. memcpy(newt,t,sizeof(C_RenderListClass::T_RenderListType));
  1722. TV_INSERTSTRUCT is;
  1723. memset(&is,0,sizeof(is));
  1724. is.hParent=h;
  1725. is.hInsertAfter=TVI_LAST;
  1726. is.item.mask=TVIF_PARAM|TVIF_TEXT|TVIF_CHILDREN;
  1727. is.item.pszText=t->render->get_desc();
  1728. is.item.cChildren=t->effect_index==LIST_ID?1:0;
  1729. is.item.lParam=(int)newt;
  1730. HTREEITEM h2=TreeView_InsertItem(hwnd,&is);
  1731. if (t->effect_index==LIST_ID)
  1732. {
  1733. _do_add(hwnd,h2,(C_RenderListClass *)t->render);
  1734. }
  1735. }
  1736. }
  1737. SendMessage(hwnd,TVM_EXPAND,TVE_EXPAND,(long)h);
  1738. }
  1739. static void _do_free(HWND hwnd, HTREEITEM h)
  1740. {
  1741. while (h)
  1742. {
  1743. TV_ITEM i={TVIF_HANDLE|TVIF_PARAM,h,0,0,0,0,0};
  1744. TreeView_GetItem(hwnd,&i);
  1745. if (i.lParam) GlobalFree((HGLOBAL)(void*)i.lParam);
  1746. HTREEITEM h2=TreeView_GetChild(hwnd,h);
  1747. if (h2) _do_free(hwnd,h2);
  1748. h=TreeView_GetNextSibling(hwnd,h);
  1749. }
  1750. }
  1751. int need_repop;
  1752. void CfgWnd_RePopIfNeeded(void)
  1753. {
  1754. if (need_repop)
  1755. {
  1756. CfgWnd_Unpopulate(1);
  1757. CfgWnd_Populate(1);
  1758. need_repop=0;
  1759. }
  1760. }
  1761. void CfgWnd_Unpopulate(int force)
  1762. {
  1763. if (force || (IsWindowVisible(g_hwndDlg)&&!DDraw_IsFullScreen()))
  1764. {
  1765. HWND hwnd=GetDlgItem(g_hwndDlg,IDC_TREE1);
  1766. if (!is_aux_wnd)
  1767. {
  1768. if (cur_hwnd) DestroyWindow(cur_hwnd);
  1769. cur_hwnd=0;
  1770. SetDlgItemText(g_hwndDlg,IDC_EFNAME,g_noeffectstr);
  1771. }
  1772. treeview_hack=1;
  1773. _do_free(hwnd,TreeView_GetChild(hwnd,TVI_ROOT));
  1774. TreeView_DeleteAllItems(hwnd);
  1775. treeview_hack=0;
  1776. }
  1777. else need_repop=1;
  1778. }
  1779. void CfgWnd_Populate(int force)
  1780. {
  1781. if (force || (IsWindowVisible(g_hwndDlg)&&!DDraw_IsFullScreen()))
  1782. {
  1783. treeview_hack=1;
  1784. HWND hwnd=GetDlgItem(g_hwndDlg,IDC_TREE1);
  1785. C_RenderListClass::T_RenderListType *newt=(C_RenderListClass::T_RenderListType *)GlobalAlloc(GMEM_FIXED,sizeof(C_RenderListClass::T_RenderListType));
  1786. newt->render=g_render_effects;
  1787. newt->effect_index=LIST_ID;
  1788. TV_INSERTSTRUCT is;
  1789. memset(&is,0,sizeof(is));
  1790. is.hParent=TVI_ROOT;
  1791. is.hInsertAfter=TVI_LAST;
  1792. is.item.mask=TVIF_PARAM|TVIF_TEXT|TVIF_CHILDREN;
  1793. is.item.pszText=WASABI_API_LNGSTRING(IDS_MAIN);
  1794. is.item.cChildren=1;
  1795. is.item.lParam=(int)newt;
  1796. g_hroot=TreeView_InsertItem(hwnd,&is);
  1797. if (g_hroot)
  1798. {
  1799. _do_add(hwnd,g_hroot,g_render_effects);
  1800. SendMessage(hwnd,TVM_EXPAND,TVE_EXPAND,(long)g_hroot);
  1801. }
  1802. treeview_hack=0;
  1803. }
  1804. else need_repop=1;
  1805. }