GameMtlDlg.cpp 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670
  1. /*
  2. ** Command & Conquer Renegade(tm)
  3. ** Copyright 2025 Electronic Arts Inc.
  4. **
  5. ** This program is free software: you can redistribute it and/or modify
  6. ** it under the terms of the GNU General Public License as published by
  7. ** the Free Software Foundation, either version 3 of the License, or
  8. ** (at your option) any later version.
  9. **
  10. ** This program is distributed in the hope that it will be useful,
  11. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. ** GNU General Public License for more details.
  14. **
  15. ** You should have received a copy of the GNU General Public License
  16. ** along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. /***********************************************************************************************
  19. *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S ***
  20. ***********************************************************************************************
  21. * *
  22. * Project Name : Max2W3d *
  23. * *
  24. * $Archive:: /Commando/Code/Tools/max2w3d/GameMtlDlg.cpp $*
  25. * *
  26. * Author:: Greg Hjelstrom *
  27. * *
  28. * $Modtime:: 2/08/02 11:07a $*
  29. * *
  30. * $Revision:: 22 $*
  31. * *
  32. *---------------------------------------------------------------------------------------------*
  33. * Functions: *
  34. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  35. #if !defined W3D_GMAXDEV
  36. #include <Max.h>
  37. #include <gport.h>
  38. #include <hsv.h>
  39. #include <bmmlib.h>
  40. #include "GameMtlDlg.h"
  41. #include "GameMtl.h"
  42. #include "GameMtlPassDlg.h"
  43. #include "dllmain.h"
  44. #include "resource.h"
  45. #include "w3d_file.h"
  46. static BOOL CALLBACK DisplacementMapDlgProc(HWND hwndDlg, UINT msg, WPARAM wPara,LPARAM lParam);
  47. static BOOL CALLBACK SurfaceTypePanelDlgProc(HWND hwndDlg, UINT msg, WPARAM wPara,LPARAM lParam);
  48. static BOOL CALLBACK PassCountPanelDlgProc(HWND hwndDlg, UINT msg, WPARAM wPara,LPARAM lParam);
  49. static BOOL CALLBACK PassCountDialogDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam,LPARAM lParam);
  50. static int _Pass_Index_To_Flag[] =
  51. {
  52. GAMEMTL_PASS0_ROLLUP_OPEN,
  53. GAMEMTL_PASS1_ROLLUP_OPEN,
  54. GAMEMTL_PASS2_ROLLUP_OPEN,
  55. GAMEMTL_PASS3_ROLLUP_OPEN,
  56. };
  57. /***********************************************************************************************
  58. * GameMtlDlg::GameMtlDlg -- constructor *
  59. * *
  60. * INPUT: *
  61. * hwMtlEdit - windows handle of the MAX material editor *
  62. * imp - Interface object for MAX materials and textures *
  63. * m - pointer to a GameMtl to be edited *
  64. * *
  65. * OUTPUT: *
  66. * *
  67. * WARNINGS: *
  68. * *
  69. * HISTORY: *
  70. * 06/26/1997 GH : Created. *
  71. *=============================================================================================*/
  72. GameMtlDlg::GameMtlDlg(HWND hwMtlEdit, IMtlParams *imp, GameMtl *m)
  73. {
  74. Ip = GetCOREInterface();
  75. HwndEdit = hwMtlEdit;
  76. HwndPassCount = NULL;
  77. HwndSurfaceType = NULL;
  78. HwndDisplacementMap = NULL;
  79. HpalOld = NULL;
  80. for (int i=0; i<MAX_PASSES; i++) {
  81. PassDialog[i] = NULL;
  82. }
  83. TheMtl = m;
  84. IParams = imp;
  85. IsActive = 0;
  86. Build_Dialog(hwMtlEdit);
  87. }
  88. /***********************************************************************************************
  89. * GameMtlDlg::~GameMtlDlg -- destructor! *
  90. * *
  91. * INPUT: *
  92. * *
  93. * OUTPUT: *
  94. * *
  95. * WARNINGS: *
  96. * *
  97. * HISTORY: *
  98. * 06/26/1997 GH : Created. *
  99. *=============================================================================================*/
  100. GameMtlDlg::~GameMtlDlg()
  101. {
  102. if (HwndPassCount) {
  103. HDC hdc = GetDC(HwndPassCount);
  104. GetGPort()->RestorePalette(hdc, HpalOld);
  105. ReleaseDC(HwndPassCount,hdc);
  106. }
  107. #ifdef WANT_DISPLACEMENT_MAPS
  108. TheMtl->Set_Flag(GAMEMTL_DISPLACEMENT_ROLLUP_OPEN,IParams->IsRollupPanelOpen(HwndDisplacementMap));
  109. #endif //WANT_DISPLACEMENT_MAPS
  110. TheMtl->Set_Flag(GAMEMTL_SURFACE_ROLLUP_OPEN,IParams->IsRollupPanelOpen(HwndSurfaceType));
  111. TheMtl->Set_Flag(GAMEMTL_PASSCOUNT_ROLLUP_OPEN,IParams->IsRollupPanelOpen(HwndPassCount));
  112. TheMtl->RollScroll = IParams->GetRollupScrollPos();
  113. IParams->UnRegisterDlgWnd(HwndSurfaceType);
  114. IParams->DeleteRollupPage(HwndSurfaceType);
  115. HwndSurfaceType = NULL;
  116. #ifdef WANT_DISPLACEMENT_MAPS
  117. IParams->UnRegisterDlgWnd(HwndDisplacementMap);
  118. IParams->DeleteRollupPage(HwndDisplacementMap);
  119. HwndDisplacementMap = NULL;
  120. #endif //#ifdef WANT_DISPLACEMENT_MAPS
  121. IParams->UnRegisterDlgWnd(HwndPassCount);
  122. IParams->DeleteRollupPage(HwndPassCount);
  123. HwndPassCount = NULL;
  124. for (int i=0; i<MAX_PASSES; i++) {
  125. if (PassDialog[i]) {
  126. delete PassDialog[i];
  127. }
  128. }
  129. TheMtl->SetParamDlg(NULL);
  130. }
  131. /***********************************************************************************************
  132. * GameMtlDlg::ClassID -- Returns the ClassID of GameMtl *
  133. * *
  134. * INPUT: *
  135. * *
  136. * OUTPUT: *
  137. * *
  138. * WARNINGS: *
  139. * *
  140. * HISTORY: *
  141. * 06/26/1997 GH : Created. *
  142. *=============================================================================================*/
  143. Class_ID GameMtlDlg::ClassID()
  144. {
  145. return GameMaterialClassID;
  146. }
  147. /***********************************************************************************************
  148. * GameMtlDlg::SetThing -- Sets the material to be edited *
  149. * *
  150. * INPUT: *
  151. * *
  152. * OUTPUT: *
  153. * *
  154. * WARNINGS: *
  155. * *
  156. * HISTORY: *
  157. * 06/26/1997 GH : Created. *
  158. *=============================================================================================*/
  159. void GameMtlDlg::SetThing(ReferenceTarget *m)
  160. {
  161. assert (m);
  162. assert (m->SuperClassID()==MATERIAL_CLASS_ID);
  163. assert ((m->ClassID()==GameMaterialClassID) || (m->ClassID()==PS2GameMaterialClassID));
  164. assert (TheMtl);
  165. int pass;
  166. // destroy our old pass dialogs
  167. for (pass=0; pass<TheMtl->Get_Pass_Count();pass++) {
  168. delete PassDialog[pass];
  169. PassDialog[pass] = NULL;
  170. }
  171. // install the new material
  172. TheMtl->SetParamDlg(NULL);
  173. TheMtl = (GameMtl *)m;
  174. TheMtl->SetParamDlg(this);
  175. // build a new set of pass dialogs
  176. for (pass=0; pass<TheMtl->Get_Pass_Count(); pass++) {
  177. PassDialog[pass] = new GameMtlPassDlg(HwndEdit, IParams, TheMtl, pass);
  178. }
  179. // refresh the contents of the dialogs
  180. ReloadDialog();
  181. }
  182. /***********************************************************************************************
  183. * GameMtlDlg::SetTime -- Sets the time value, updates the material and the dialog *
  184. * *
  185. * INPUT: *
  186. * *
  187. * OUTPUT: *
  188. * *
  189. * WARNINGS: *
  190. * *
  191. * HISTORY: *
  192. * 06/26/1997 GH : Created. *
  193. *=============================================================================================*/
  194. void GameMtlDlg::SetTime(TimeValue t)
  195. {
  196. if (t!=CurTime) {
  197. CurTime = t;
  198. // TheMtl->Update(IParams->GetTime(),Valid);
  199. ReloadDialog();
  200. }
  201. }
  202. /***********************************************************************************************
  203. * GameMtlDlg::ReloadDialog -- Updates the values in all of the dialog's controls *
  204. * *
  205. * INPUT: *
  206. * *
  207. * OUTPUT: *
  208. * *
  209. * WARNINGS: *
  210. * *
  211. * HISTORY: *
  212. * 06/26/1997 GH : Created. *
  213. *=============================================================================================*/
  214. void GameMtlDlg::ReloadDialog()
  215. {
  216. /*
  217. ** Init the pass count panel
  218. */
  219. assert(TheMtl && HwndPassCount && HwndSurfaceType);
  220. /*
  221. ** Init the surface count panel
  222. */
  223. ::SendMessage (HwndSurfaceType, WM_USER+101, 0, 0L);
  224. #ifdef WANT_DISPLACEMENT_MAPS
  225. ::SendMessage (HwndDisplacementMap, WM_USER+101, 0, 0L);
  226. #endif //WANT_DISPLACEMENT_MAPS
  227. /*
  228. ** Init the pass count panel
  229. */
  230. char a[10];
  231. sprintf(a, "%d", TheMtl->Get_Pass_Count());
  232. SetWindowText(GetDlgItem(HwndPassCount, IDC_GAMEMTL_PASSCOUNT_STATIC), a);
  233. /*
  234. ** Init each pass panel
  235. */
  236. for(int i = 0; i < TheMtl->Get_Pass_Count(); i++)
  237. {
  238. PassDialog[i]->ReloadDialog();
  239. }
  240. }
  241. /***********************************************************************************************
  242. * GameMtlDlg::ActivateDlg -- Activates and deactivates the dialog *
  243. * *
  244. * INPUT: *
  245. * *
  246. * OUTPUT: *
  247. * *
  248. * WARNINGS: *
  249. * *
  250. * HISTORY: *
  251. * 06/26/1997 GH : Created. *
  252. *=============================================================================================*/
  253. void GameMtlDlg::ActivateDlg(BOOL onoff)
  254. {
  255. for(int i = 0; i < TheMtl->Get_Pass_Count(); i++)
  256. {
  257. assert(PassDialog[i]);
  258. PassDialog[i]->ActivateDlg(onoff);
  259. }
  260. }
  261. /***********************************************************************************************
  262. * GameMtlDlg::Invalidate -- causes the dialog to be redrawn *
  263. * *
  264. * INPUT: *
  265. * *
  266. * OUTPUT: *
  267. * *
  268. * WARNINGS: *
  269. * *
  270. * HISTORY: *
  271. * 06/26/1997 GH : Created. *
  272. *=============================================================================================*/
  273. void GameMtlDlg::Invalidate()
  274. {
  275. InvalidateRect(HwndSurfaceType,NULL,0);
  276. #ifdef WANT_DISPLACEMENT_MAPS
  277. InvalidateRect(HwndDisplacementMap,NULL,0);
  278. #endif //WANT_DISPLACEMENT_MAPS
  279. InvalidateRect(HwndPassCount,NULL,0);
  280. }
  281. BOOL GameMtlDlg::DisplacementMapProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
  282. {
  283. switch (message)
  284. {
  285. case WM_INITDIALOG:
  286. //SetupIntSpinner(hDlg, IDC_AMOUNT_SPIN, IDC_AMOUNT_EDIT, -999, 999, 0);
  287. /* no break */
  288. case WM_USER + 101:
  289. {
  290. SetDlgItemInt (hDlg, IDC_AMOUNT_EDIT, TheMtl->Get_Displacement_Amount () * 100, TRUE);
  291. SetupIntSpinner(hDlg, IDC_AMOUNT_SPIN, IDC_AMOUNT_EDIT, -999, 999, TheMtl->Get_Displacement_Amount () * 100);
  292. Texmap *map = TheMtl->Get_Displacement_Map ();
  293. if (map != NULL) {
  294. SetDlgItemText (hDlg, IDC_TEXTURE_BUTTON, map->GetFullName ());
  295. }
  296. }
  297. break;
  298. case CC_SPINNER_CHANGE:
  299. {
  300. ISpinnerControl *control = (ISpinnerControl *)lParam;
  301. TheMtl->Set_Displacement_Amount (((float)control->GetIVal ()) / 100.0F);
  302. }
  303. break;
  304. case WM_COMMAND:
  305. switch(LOWORD(wParam))
  306. {
  307. case IDC_TEXTURE_BUTTON:
  308. if(HIWORD(wParam) == BN_CLICKED)
  309. {
  310. PostMessage(HwndEdit, WM_TEXMAP_BUTTON, TheMtl->Get_Displacement_Map_Index (), (LPARAM)TheMtl);
  311. }
  312. }
  313. break;
  314. }
  315. return FALSE;
  316. }
  317. BOOL GameMtlDlg::SurfaceTypeProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
  318. {
  319. switch (message){
  320. case WM_INITDIALOG:{
  321. //
  322. // Fill the combobox with the names of the different surface types
  323. //
  324. for (int index = 0; index < SURFACE_TYPE_MAX; index ++) {
  325. ::SendDlgItemMessage ( hDlg,
  326. IDC_SURFACE_TYPE_COMBO,
  327. CB_ADDSTRING,
  328. 0,
  329. (LPARAM)SURFACE_TYPE_STRINGS[index]);
  330. }
  331. //
  332. // Limit the range of the static sort level spinner to 0 - MAX_SORT_LEVEL.
  333. //
  334. int sort_level = TheMtl->Get_Sort_Level();
  335. SetupIntSpinner(hDlg, IDC_SORT_LEVEL_SPIN, IDC_SORT_LEVEL, 0, MAX_SORT_LEVEL, sort_level);
  336. // Check the checkbox if sort_level is not SORT_LEVEL_NONE.
  337. ::SendDlgItemMessage(hDlg, IDC_ENABLE_SORT_LEVEL, BM_SETCHECK,
  338. sort_level == SORT_LEVEL_NONE ? BST_UNCHECKED : BST_CHECKED, 0);
  339. }
  340. case WM_USER + 101:{
  341. //
  342. // Select the current surface type
  343. //
  344. ::SendDlgItemMessage ( hDlg,
  345. IDC_SURFACE_TYPE_COMBO,
  346. CB_SETCURSEL,
  347. (WPARAM)TheMtl->Get_Surface_Type (),
  348. 0L);
  349. //
  350. // Set the correct sort level
  351. //
  352. int sort_level = TheMtl->Get_Sort_Level();
  353. ISpinnerControl *spinner = GetISpinner(::GetDlgItem(hDlg, IDC_SORT_LEVEL_SPIN));
  354. assert(spinner);
  355. spinner->SetValue(sort_level, FALSE);
  356. ::SendDlgItemMessage(hDlg, IDC_ENABLE_SORT_LEVEL, BM_SETCHECK,
  357. sort_level == SORT_LEVEL_NONE ? BST_UNCHECKED : BST_CHECKED, 0);
  358. break;
  359. }
  360. case WM_COMMAND:
  361. {
  362. switch(LOWORD(wParam)){
  363. case IDC_SURFACE_TYPE_COMBO:
  364. if(HIWORD(wParam) == CBN_SELCHANGE)
  365. {
  366. unsigned int type = ::SendDlgItemMessage (hDlg, IDC_SURFACE_TYPE_COMBO, CB_GETCURSEL, 0, 0L);
  367. TheMtl->Set_Surface_Type (type);
  368. }
  369. break;
  370. case IDC_ENABLE_SORT_LEVEL:
  371. if (HIWORD(wParam) == BN_CLICKED)
  372. {
  373. // If the 'enable' checkbox was unchecked, set the sort level to NONE.
  374. int state = ::IsDlgButtonChecked(hDlg, IDC_ENABLE_SORT_LEVEL);
  375. ISpinnerControl *spinner = GetISpinner(::GetDlgItem(hDlg, IDC_SORT_LEVEL_SPIN));
  376. assert(spinner);
  377. if (state == BST_UNCHECKED)
  378. {
  379. spinner->SetValue(SORT_LEVEL_NONE, FALSE);
  380. TheMtl->Set_Sort_Level(SORT_LEVEL_NONE);
  381. }
  382. else if (state == BST_CHECKED)
  383. {
  384. // Sort level was enabled, so set it's level to 1 if it was NONE before.
  385. if (spinner->GetIVal() == SORT_LEVEL_NONE)
  386. {
  387. spinner->SetValue(1, FALSE);
  388. TheMtl->Set_Sort_Level(1);
  389. }
  390. }
  391. break;
  392. }
  393. }
  394. break;
  395. }
  396. case CC_SPINNER_CHANGE:
  397. {
  398. ISpinnerControl *spinner = (ISpinnerControl*)lParam;
  399. switch(LOWORD(wParam))
  400. {
  401. case IDC_SORT_LEVEL_SPIN:
  402. // Check the 'enabled' checkbox if sort level != SORT_LEVEL_NONE, uncheck it otherwise.
  403. ::SendDlgItemMessage(hDlg, IDC_ENABLE_SORT_LEVEL, BM_SETCHECK,
  404. spinner->GetIVal() == SORT_LEVEL_NONE ? BST_UNCHECKED : BST_CHECKED, 0);
  405. TheMtl->Set_Sort_Level(spinner->GetIVal());
  406. break;
  407. }
  408. break;
  409. }
  410. }
  411. return FALSE;
  412. }
  413. BOOL GameMtlDlg::PassCountProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
  414. {
  415. switch (message)
  416. {
  417. case WM_INITDIALOG:
  418. break;
  419. case WM_COMMAND:{
  420. switch(LOWORD(wParam)){
  421. case IDC_SETPASSCOUNT:{
  422. if(HIWORD(wParam) == BN_CLICKED){
  423. Set_Pass_Count_Dialog();
  424. }
  425. break;
  426. }
  427. }
  428. break;
  429. }
  430. }
  431. return FALSE;
  432. }
  433. static BOOL CALLBACK DisplacementMapDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam,LPARAM lParam)
  434. {
  435. GameMtlDlg * theDlg;
  436. if (msg == WM_INITDIALOG) {
  437. theDlg = (GameMtlDlg*)lParam;
  438. theDlg->HwndDisplacementMap = hwndDlg;
  439. SetWindowLong(hwndDlg, GWL_USERDATA,(LPARAM)theDlg);
  440. } else {
  441. if ((theDlg = (GameMtlDlg *)GetWindowLong(hwndDlg, GWL_USERDATA) ) == NULL) {
  442. return FALSE;
  443. }
  444. }
  445. theDlg->IsActive = 1;
  446. BOOL res = theDlg->DisplacementMapProc(hwndDlg,msg,wParam,lParam);
  447. theDlg->IsActive = 0;
  448. return res;
  449. }
  450. static BOOL CALLBACK SurfaceTypePanelDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam,LPARAM lParam)
  451. {
  452. GameMtlDlg * theDlg;
  453. if (msg == WM_INITDIALOG) {
  454. theDlg = (GameMtlDlg*)lParam;
  455. theDlg->HwndSurfaceType = hwndDlg;
  456. SetWindowLong(hwndDlg, GWL_USERDATA,(LPARAM)theDlg);
  457. } else {
  458. if ((theDlg = (GameMtlDlg *)GetWindowLong(hwndDlg, GWL_USERDATA) ) == NULL) {
  459. return FALSE;
  460. }
  461. }
  462. theDlg->IsActive = 1;
  463. BOOL res = theDlg->SurfaceTypeProc(hwndDlg,msg,wParam,lParam);
  464. theDlg->IsActive = 0;
  465. return res;
  466. }
  467. static BOOL CALLBACK PassCountPanelDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam,LPARAM lParam)
  468. {
  469. GameMtlDlg * theDlg = (GameMtlDlg *)GetWindowLong(hwndDlg, GWL_USERDATA);
  470. switch(msg){
  471. case WM_INITDIALOG: {
  472. theDlg = (GameMtlDlg*)lParam;
  473. theDlg->HwndPassCount = hwndDlg;
  474. SetWindowLong(hwndDlg, GWL_USERDATA,(LPARAM)theDlg);
  475. return FALSE;
  476. }
  477. }
  478. if ((theDlg = (GameMtlDlg *)GetWindowLong(hwndDlg, GWL_USERDATA) ) == NULL) {
  479. return FALSE;
  480. }
  481. theDlg->IsActive = 1;
  482. BOOL res = theDlg->PassCountProc(hwndDlg,msg,wParam,lParam);
  483. theDlg->IsActive = 0;
  484. return res;
  485. }
  486. ///////////////////////////////////////////////////////////////////////////////////////////////
  487. void GameMtlDlg::Set_Pass_Count_Dialog(void)
  488. {
  489. int res = DialogBoxParam(
  490. AppInstance,
  491. MAKEINTRESOURCE(IDD_GAMEMTL_PASS_COUNT_DIALOG),
  492. HwndPassCount,
  493. PassCountDialogDlgProc,
  494. (LPARAM)TheMtl->Get_Pass_Count());
  495. if (res>=0)
  496. {
  497. if (res<=0) res = 1;
  498. if (res>4) res = 4;
  499. char a[10];
  500. sprintf(a, "%d", res);
  501. SetWindowText(GetDlgItem(HwndPassCount, IDC_GAMEMTL_PASSCOUNT_STATIC), a);
  502. if(TheMtl->Get_Pass_Count() != res)
  503. {
  504. for(int i = 0; i < TheMtl->Get_Pass_Count(); i++)
  505. {
  506. delete PassDialog[i];
  507. PassDialog[i] = NULL;
  508. }
  509. TheMtl->Set_Pass_Count(res);
  510. for(i = 0; i < TheMtl->Get_Pass_Count(); i++)
  511. {
  512. PassDialog[i] = new GameMtlPassDlg(HwndEdit, IParams, TheMtl, i);
  513. }
  514. ReloadDialog();
  515. }
  516. }
  517. }
  518. static BOOL CALLBACK PassCountDialogDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam,LPARAM lParam)
  519. {
  520. switch (msg)
  521. {
  522. case WM_INITDIALOG:
  523. {
  524. ISpinnerControl *spin = SetupIntSpinner(
  525. hwndDlg,IDC_PASSCOUNT_SPIN, IDC_PASSCOUNT_EDIT,
  526. 1,4,(int)lParam);
  527. ReleaseISpinner(spin);
  528. CenterWindow(hwndDlg,GetParent(hwndDlg));
  529. break;
  530. }
  531. case WM_COMMAND:
  532. switch (LOWORD(wParam))
  533. {
  534. case IDOK:
  535. {
  536. ISpinnerControl *spin = GetISpinner(GetDlgItem(hwndDlg,IDC_PASSCOUNT_SPIN));
  537. EndDialog(hwndDlg,spin->GetIVal());
  538. ReleaseISpinner(spin);
  539. break;
  540. }
  541. case IDCANCEL:
  542. EndDialog(hwndDlg,-1);
  543. break;
  544. }
  545. break;
  546. default:
  547. return FALSE;
  548. }
  549. return TRUE;
  550. }
  551. /***********************************************************************************************
  552. * GameMtlDlg::Build_Dialog -- Adds the dialog to the material editor *
  553. * *
  554. * INPUT: *
  555. * *
  556. * OUTPUT: *
  557. * *
  558. * WARNINGS: *
  559. * *
  560. * HISTORY: *
  561. * 06/26/1997 GH : Created. *
  562. *=============================================================================================*/
  563. void GameMtlDlg::Build_Dialog(HWND hParent)// = NULL
  564. {
  565. if ((TheMtl->Flags&(GAMEMTL_ROLLUP_FLAGS))==0) {
  566. TheMtl->Set_Flag(GAMEMTL_PASS0_ROLLUP_OPEN,TRUE);
  567. }
  568. HwndSurfaceType = IParams->AddRollupPage(
  569. AppInstance,
  570. MAKEINTRESOURCE(IDD_GAMEMTL_SURFACE_TYPE),
  571. SurfaceTypePanelDlgProc,
  572. Get_String(IDS_SURFACE_TYPE),
  573. (LPARAM)this,
  574. TheMtl->Get_Flag(GAMEMTL_SURFACE_ROLLUP_OPEN) ? 0:APPENDROLL_CLOSED
  575. );
  576. #ifdef WANT_DISPLACEMENT_MAPS
  577. HwndDisplacementMap = IParams->AddRollupPage(
  578. AppInstance,
  579. MAKEINTRESOURCE(IDD_GAMEMTL_DISPLACEMENT_MAP),
  580. DisplacementMapDlgProc,
  581. Get_String(IDS_DISPLACEMENT_MAP),
  582. (LPARAM)this,
  583. TheMtl->Get_Flag(GAMEMTL_DISPLACEMENT_ROLLUP_OPEN) ? 0:APPENDROLL_CLOSED
  584. );
  585. #endif //WANT_DISPLACEMENT_MAPS
  586. HwndPassCount = IParams->AddRollupPage(
  587. AppInstance,
  588. MAKEINTRESOURCE(IDD_GAMEMTL_PASS_COUNT),
  589. PassCountPanelDlgProc,
  590. Get_String(IDS_PASS_COUNT),
  591. (LPARAM)this,
  592. TheMtl->Get_Flag(GAMEMTL_PASSCOUNT_ROLLUP_OPEN) ? 0:APPENDROLL_CLOSED
  593. );
  594. for (int i=0; i<TheMtl->Get_Pass_Count(); i++) {
  595. PassDialog[i] = new GameMtlPassDlg(HwndEdit, IParams, TheMtl, i);
  596. }
  597. IParams->SetRollupScrollPos(TheMtl->RollScroll);
  598. ReloadDialog();
  599. }
  600. #endif