GameMtlDlg.cpp 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685
  1. /*
  2. ** Command & Conquer Generals Zero Hour(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:: 12/07/00 5:52p $*
  29. * *
  30. * $Revision:: 12 $*
  31. * *
  32. *---------------------------------------------------------------------------------------------*
  33. * Functions: *
  34. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  35. #include <Max.h>
  36. #include <gport.h>
  37. #include <hsv.h>
  38. #include <bmmlib.h>
  39. #include "GameMtlDlg.h"
  40. #include "GameMtl.h"
  41. #include "GameMtlPassDlg.h"
  42. #include "dllmain.h"
  43. #include "resource.h"
  44. #include "w3d_file.h"
  45. static BOOL CALLBACK DisplacementMapDlgProc(HWND hwndDlg, UINT msg, WPARAM wPara,LPARAM lParam);
  46. static BOOL CALLBACK SurfaceTypePanelDlgProc(HWND hwndDlg, UINT msg, WPARAM wPara,LPARAM lParam);
  47. static BOOL CALLBACK PassCountPanelDlgProc(HWND hwndDlg, UINT msg, WPARAM wPara,LPARAM lParam);
  48. static BOOL CALLBACK PassCountDialogDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam,LPARAM lParam);
  49. static int _Pass_Index_To_Flag[] =
  50. {
  51. GAMEMTL_PASS0_ROLLUP_OPEN,
  52. GAMEMTL_PASS1_ROLLUP_OPEN,
  53. GAMEMTL_PASS2_ROLLUP_OPEN,
  54. GAMEMTL_PASS3_ROLLUP_OPEN,
  55. };
  56. /***********************************************************************************************
  57. * GameMtlDlg::GameMtlDlg -- constructor *
  58. * *
  59. * INPUT: *
  60. * hwMtlEdit - windows handle of the MAX material editor *
  61. * imp - Interface object for MAX materials and textures *
  62. * m - pointer to a GameMtl to be edited *
  63. * *
  64. * OUTPUT: *
  65. * *
  66. * WARNINGS: *
  67. * *
  68. * HISTORY: *
  69. * 06/26/1997 GH : Created. *
  70. *=============================================================================================*/
  71. GameMtlDlg::GameMtlDlg(HWND hwMtlEdit, IMtlParams *imp, GameMtl *m)
  72. {
  73. HwndEdit = hwMtlEdit;
  74. HwndPassCount = NULL;
  75. HwndSurfaceType = NULL;
  76. HwndDisplacementMap = NULL;
  77. HpalOld = NULL;
  78. for (int i=0; i<MAX_PASSES; i++) {
  79. PassDialog[i] = NULL;
  80. }
  81. TheMtl = m;
  82. IParams = imp;
  83. IsActive = 0;
  84. Build_Dialog();
  85. }
  86. /***********************************************************************************************
  87. * GameMtlDlg::~GameMtlDlg -- destructor! *
  88. * *
  89. * INPUT: *
  90. * *
  91. * OUTPUT: *
  92. * *
  93. * WARNINGS: *
  94. * *
  95. * HISTORY: *
  96. * 06/26/1997 GH : Created. *
  97. *=============================================================================================*/
  98. GameMtlDlg::~GameMtlDlg()
  99. {
  100. if (HwndPassCount) {
  101. HDC hdc = GetDC(HwndPassCount);
  102. GetGPort()->RestorePalette(hdc, HpalOld);
  103. ReleaseDC(HwndPassCount,hdc);
  104. }
  105. #ifdef WANT_DISPLACEMENT_MAPS
  106. TheMtl->Set_Flag(GAMEMTL_DISPLACEMENT_ROLLUP_OPEN,IParams->IsRollupPanelOpen(HwndDisplacementMap));
  107. #endif //WANT_DISPLACEMENT_MAPS
  108. TheMtl->Set_Flag(GAMEMTL_SURFACE_ROLLUP_OPEN,IParams->IsRollupPanelOpen(HwndSurfaceType));
  109. TheMtl->Set_Flag(GAMEMTL_PASSCOUNT_ROLLUP_OPEN,IParams->IsRollupPanelOpen(HwndPassCount));
  110. TheMtl->RollScroll = IParams->GetRollupScrollPos();
  111. IParams->UnRegisterDlgWnd(HwndSurfaceType);
  112. IParams->DeleteRollupPage(HwndSurfaceType);
  113. HwndSurfaceType = NULL;
  114. #ifdef WANT_DISPLACEMENT_MAPS
  115. IParams->UnRegisterDlgWnd(HwndDisplacementMap);
  116. IParams->DeleteRollupPage(HwndDisplacementMap);
  117. HwndDisplacementMap = NULL;
  118. #endif //#ifdef WANT_DISPLACEMENT_MAPS
  119. IParams->UnRegisterDlgWnd(HwndPassCount);
  120. IParams->DeleteRollupPage(HwndPassCount);
  121. HwndPassCount = NULL;
  122. for (int i=0; i<MAX_PASSES; i++) {
  123. if (PassDialog[i]) {
  124. delete PassDialog[i];
  125. }
  126. }
  127. TheMtl->SetParamDlg(NULL);
  128. }
  129. /***********************************************************************************************
  130. * GameMtlDlg::ClassID -- Returns the ClassID of GameMtl *
  131. * *
  132. * INPUT: *
  133. * *
  134. * OUTPUT: *
  135. * *
  136. * WARNINGS: *
  137. * *
  138. * HISTORY: *
  139. * 06/26/1997 GH : Created. *
  140. *=============================================================================================*/
  141. Class_ID GameMtlDlg::ClassID()
  142. {
  143. return GameMaterialClassID;
  144. }
  145. /***********************************************************************************************
  146. * GameMtlDlg::SetThing -- Sets the material to be edited *
  147. * *
  148. * INPUT: *
  149. * *
  150. * OUTPUT: *
  151. * *
  152. * WARNINGS: *
  153. * *
  154. * HISTORY: *
  155. * 06/26/1997 GH : Created. *
  156. *=============================================================================================*/
  157. void GameMtlDlg::SetThing(ReferenceTarget *m)
  158. {
  159. assert (m);
  160. assert (m->SuperClassID()==MATERIAL_CLASS_ID);
  161. assert ((m->ClassID()==GameMaterialClassID) || (m->ClassID()==PS2GameMaterialClassID));
  162. assert (TheMtl);
  163. int pass;
  164. // destroy our old pass dialogs
  165. for (pass=0; pass<TheMtl->Get_Pass_Count();pass++) {
  166. delete PassDialog[pass];
  167. PassDialog[pass] = NULL;
  168. }
  169. // install the new material
  170. TheMtl->SetParamDlg(NULL);
  171. TheMtl = (GameMtl *)m;
  172. TheMtl->SetParamDlg(this);
  173. // build a new set of pass dialogs
  174. for (pass=0; pass<TheMtl->Get_Pass_Count(); pass++) {
  175. PassDialog[pass] = new GameMtlPassDlg(HwndEdit, IParams, TheMtl, pass);
  176. }
  177. // refresh the contents of the dialogs
  178. ReloadDialog();
  179. }
  180. /***********************************************************************************************
  181. * GameMtlDlg::SetTime -- Sets the time value, updates the material and the dialog *
  182. * *
  183. * INPUT: *
  184. * *
  185. * OUTPUT: *
  186. * *
  187. * WARNINGS: *
  188. * *
  189. * HISTORY: *
  190. * 06/26/1997 GH : Created. *
  191. *=============================================================================================*/
  192. void GameMtlDlg::SetTime(TimeValue t)
  193. {
  194. if (t!=CurTime) {
  195. CurTime = t;
  196. // TheMtl->Update(IParams->GetTime(),Valid);
  197. ReloadDialog();
  198. }
  199. }
  200. /***********************************************************************************************
  201. * GameMtlDlg::ReloadDialog -- Updates the values in all of the dialog's controls *
  202. * *
  203. * INPUT: *
  204. * *
  205. * OUTPUT: *
  206. * *
  207. * WARNINGS: *
  208. * *
  209. * HISTORY: *
  210. * 06/26/1997 GH : Created. *
  211. *=============================================================================================*/
  212. void GameMtlDlg::ReloadDialog()
  213. {
  214. /*
  215. ** Init the pass count panel
  216. */
  217. assert(TheMtl && HwndPassCount && HwndSurfaceType);
  218. /*
  219. ** Init the surface count panel
  220. */
  221. ::SendMessage (HwndSurfaceType, WM_USER+101, 0, 0L);
  222. #ifdef WANT_DISPLACEMENT_MAPS
  223. ::SendMessage (HwndDisplacementMap, WM_USER+101, 0, 0L);
  224. #endif //WANT_DISPLACEMENT_MAPS
  225. /*
  226. ** Init the pass count panel
  227. */
  228. char a[10];
  229. sprintf(a, "%d", TheMtl->Get_Pass_Count());
  230. SetWindowText(GetDlgItem(HwndPassCount, IDC_GAMEMTL_PASSCOUNT_STATIC), a);
  231. /*
  232. ** Init each pass panel
  233. */
  234. for(int i = 0; i < TheMtl->Get_Pass_Count(); i++)
  235. {
  236. PassDialog[i]->ReloadDialog();
  237. }
  238. }
  239. /***********************************************************************************************
  240. * GameMtlDlg::ActivateDlg -- Activates and deactivates the dialog *
  241. * *
  242. * INPUT: *
  243. * *
  244. * OUTPUT: *
  245. * *
  246. * WARNINGS: *
  247. * *
  248. * HISTORY: *
  249. * 06/26/1997 GH : Created. *
  250. *=============================================================================================*/
  251. void GameMtlDlg::ActivateDlg(BOOL onoff)
  252. {
  253. for(int i = 0; i < TheMtl->Get_Pass_Count(); i++)
  254. {
  255. assert(PassDialog[i]);
  256. PassDialog[i]->ActivateDlg(onoff);
  257. }
  258. }
  259. /***********************************************************************************************
  260. * GameMtlDlg::Invalidate -- causes the dialog to be redrawn *
  261. * *
  262. * INPUT: *
  263. * *
  264. * OUTPUT: *
  265. * *
  266. * WARNINGS: *
  267. * *
  268. * HISTORY: *
  269. * 06/26/1997 GH : Created. *
  270. *=============================================================================================*/
  271. void GameMtlDlg::Invalidate()
  272. {
  273. InvalidateRect(HwndSurfaceType,NULL,0);
  274. #ifdef WANT_DISPLACEMENT_MAPS
  275. InvalidateRect(HwndDisplacementMap,NULL,0);
  276. #endif //WANT_DISPLACEMENT_MAPS
  277. InvalidateRect(HwndPassCount,NULL,0);
  278. }
  279. BOOL GameMtlDlg::DisplacementMapProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
  280. {
  281. switch (message)
  282. {
  283. case WM_INITDIALOG:
  284. //SetupIntSpinner(hDlg, IDC_AMOUNT_SPIN, IDC_AMOUNT_EDIT, -999, 999, 0);
  285. /* no break */
  286. case WM_USER + 101:
  287. {
  288. SetDlgItemInt (hDlg, IDC_AMOUNT_EDIT, TheMtl->Get_Displacement_Amount () * 100, TRUE);
  289. SetupIntSpinner(hDlg, IDC_AMOUNT_SPIN, IDC_AMOUNT_EDIT, -999, 999, TheMtl->Get_Displacement_Amount () * 100);
  290. Texmap *map = TheMtl->Get_Displacement_Map ();
  291. if (map != NULL) {
  292. SetDlgItemText (hDlg, IDC_TEXTURE_BUTTON, map->GetFullName ());
  293. }
  294. }
  295. break;
  296. case CC_SPINNER_CHANGE:
  297. {
  298. ISpinnerControl *control = (ISpinnerControl *)lParam;
  299. TheMtl->Set_Displacement_Amount (((float)control->GetIVal ()) / 100.0F);
  300. }
  301. break;
  302. case WM_COMMAND:
  303. switch(LOWORD(wParam))
  304. {
  305. case IDC_TEXTURE_BUTTON:
  306. if(HIWORD(wParam) == BN_CLICKED)
  307. {
  308. PostMessage(HwndEdit, WM_TEXMAP_BUTTON, TheMtl->Get_Displacement_Map_Index (), (LPARAM)TheMtl);
  309. }
  310. }
  311. break;
  312. }
  313. return FALSE;
  314. }
  315. BOOL GameMtlDlg::SurfaceTypeProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
  316. {
  317. switch (message)
  318. {
  319. case WM_INITDIALOG:
  320. {
  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. //
  343. // Select the current surface type
  344. //
  345. ::SendDlgItemMessage ( hDlg,
  346. IDC_SURFACE_TYPE_COMBO,
  347. CB_SETCURSEL,
  348. (WPARAM)TheMtl->Get_Surface_Type (),
  349. 0L);
  350. //
  351. // Set the correct sort level
  352. //
  353. int sort_level = TheMtl->Get_Sort_Level();
  354. ISpinnerControl *spinner = GetISpinner(::GetDlgItem(hDlg, IDC_SORT_LEVEL_SPIN));
  355. assert(spinner);
  356. spinner->SetValue(sort_level, FALSE);
  357. ::SendDlgItemMessage(hDlg, IDC_ENABLE_SORT_LEVEL, BM_SETCHECK,
  358. sort_level == SORT_LEVEL_NONE ? BST_UNCHECKED : BST_CHECKED, 0);
  359. break;
  360. }
  361. case WM_COMMAND:
  362. {
  363. switch(LOWORD(wParam))
  364. {
  365. case IDC_SURFACE_TYPE_COMBO:
  366. if(HIWORD(wParam) == CBN_SELCHANGE)
  367. {
  368. unsigned int type = ::SendDlgItemMessage (hDlg, IDC_SURFACE_TYPE_COMBO, CB_GETCURSEL, 0, 0L);
  369. TheMtl->Set_Surface_Type (type);
  370. }
  371. break;
  372. case IDC_ENABLE_SORT_LEVEL:
  373. if (HIWORD(wParam) == BN_CLICKED)
  374. {
  375. // If the 'enable' checkbox was unchecked, set the sort level to NONE.
  376. int state = ::IsDlgButtonChecked(hDlg, IDC_ENABLE_SORT_LEVEL);
  377. ISpinnerControl *spinner = GetISpinner(::GetDlgItem(hDlg, IDC_SORT_LEVEL_SPIN));
  378. assert(spinner);
  379. if (state == BST_UNCHECKED)
  380. {
  381. spinner->SetValue(SORT_LEVEL_NONE, FALSE);
  382. TheMtl->Set_Sort_Level(SORT_LEVEL_NONE);
  383. }
  384. else if (state == BST_CHECKED)
  385. {
  386. // Sort level was enabled, so set it's level to 1 if it was NONE before.
  387. if (spinner->GetIVal() == SORT_LEVEL_NONE)
  388. {
  389. spinner->SetValue(1, FALSE);
  390. TheMtl->Set_Sort_Level(1);
  391. }
  392. }
  393. }
  394. }
  395. break;
  396. }
  397. case CC_SPINNER_CHANGE:
  398. {
  399. ISpinnerControl *spinner = (ISpinnerControl*)lParam;
  400. switch(LOWORD(wParam))
  401. {
  402. case IDC_SORT_LEVEL_SPIN:
  403. // Check the 'enabled' checkbox if sort level != SORT_LEVEL_NONE, uncheck it otherwise.
  404. ::SendDlgItemMessage(hDlg, IDC_ENABLE_SORT_LEVEL, BM_SETCHECK,
  405. spinner->GetIVal() == SORT_LEVEL_NONE ? BST_UNCHECKED : BST_CHECKED, 0);
  406. TheMtl->Set_Sort_Level(spinner->GetIVal());
  407. break;
  408. }
  409. break;
  410. }
  411. }
  412. return FALSE;
  413. }
  414. BOOL GameMtlDlg::PassCountProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
  415. {
  416. switch (message)
  417. {
  418. case WM_INITDIALOG:
  419. break;
  420. case WM_COMMAND:
  421. switch(LOWORD(wParam))
  422. {
  423. case IDC_SETPASSCOUNT:
  424. if(HIWORD(wParam) == BN_CLICKED)
  425. {
  426. Set_Pass_Count_Dialog();
  427. }
  428. }
  429. break;
  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);
  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);
  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;
  470. if (msg == WM_INITDIALOG) {
  471. theDlg = (GameMtlDlg*)lParam;
  472. theDlg->HwndPassCount = hwndDlg;
  473. SetWindowLong(hwndDlg, GWL_USERDATA,lParam);
  474. } else {
  475. if ((theDlg = (GameMtlDlg *)GetWindowLong(hwndDlg, GWL_USERDATA) ) == NULL) {
  476. return FALSE;
  477. }
  478. }
  479. theDlg->IsActive = 1;
  480. BOOL res = theDlg->PassCountProc(hwndDlg,msg,wParam,lParam);
  481. theDlg->IsActive = 0;
  482. return res;
  483. }
  484. void GameMtlDlg::Set_Pass_Count_Dialog(void)
  485. {
  486. int res = DialogBoxParam(
  487. AppInstance,
  488. MAKEINTRESOURCE(IDD_GAMEMTL_PASS_COUNT_DIALOG),
  489. HwndPassCount,
  490. PassCountDialogDlgProc,
  491. (LPARAM)TheMtl->Get_Pass_Count());
  492. if (res>=0)
  493. {
  494. if (res<=0) res = 1;
  495. if (res>4) res = 4;
  496. char a[10];
  497. sprintf(a, "%d", res);
  498. SetWindowText(GetDlgItem(HwndPassCount, IDC_GAMEMTL_PASSCOUNT_STATIC), a);
  499. if(TheMtl->Get_Pass_Count() != res)
  500. {
  501. for(int i = 0; i < TheMtl->Get_Pass_Count(); i++)
  502. {
  503. delete PassDialog[i];
  504. PassDialog[i] = NULL;
  505. }
  506. TheMtl->Set_Pass_Count(res);
  507. for(i = 0; i < TheMtl->Get_Pass_Count(); i++)
  508. {
  509. PassDialog[i] = new GameMtlPassDlg(HwndEdit, IParams, TheMtl, i);
  510. }
  511. ReloadDialog();
  512. }
  513. }
  514. }
  515. static BOOL CALLBACK PassCountDialogDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam,LPARAM lParam)
  516. {
  517. switch (msg)
  518. {
  519. case WM_INITDIALOG:
  520. {
  521. ISpinnerControl *spin = SetupIntSpinner(
  522. hwndDlg,IDC_PASSCOUNT_SPIN, IDC_PASSCOUNT_EDIT,
  523. 1,4,(int)lParam);
  524. ReleaseISpinner(spin);
  525. CenterWindow(hwndDlg,GetParent(hwndDlg));
  526. break;
  527. }
  528. case WM_COMMAND:
  529. switch (LOWORD(wParam))
  530. {
  531. case IDOK:
  532. {
  533. ISpinnerControl *spin = GetISpinner(GetDlgItem(hwndDlg,IDC_PASSCOUNT_SPIN));
  534. EndDialog(hwndDlg,spin->GetIVal());
  535. ReleaseISpinner(spin);
  536. break;
  537. }
  538. case IDCANCEL:
  539. EndDialog(hwndDlg,-1);
  540. break;
  541. }
  542. break;
  543. default:
  544. return FALSE;
  545. }
  546. return TRUE;
  547. }
  548. /***********************************************************************************************
  549. * GameMtlDlg::Build_Dialog -- Adds the dialog to the material editor *
  550. * *
  551. * INPUT: *
  552. * *
  553. * OUTPUT: *
  554. * *
  555. * WARNINGS: *
  556. * *
  557. * HISTORY: *
  558. * 06/26/1997 GH : Created. *
  559. *=============================================================================================*/
  560. void GameMtlDlg::Build_Dialog()
  561. {
  562. if ((TheMtl->Flags&(GAMEMTL_ROLLUP_FLAGS))==0) {
  563. TheMtl->Set_Flag(GAMEMTL_PASS0_ROLLUP_OPEN,TRUE);
  564. }
  565. HwndSurfaceType = IParams->AddRollupPage(
  566. AppInstance,
  567. MAKEINTRESOURCE(IDD_GAMEMTL_SURFACE_TYPE),
  568. SurfaceTypePanelDlgProc,
  569. Get_String(IDS_SURFACE_TYPE),
  570. (LPARAM)this,
  571. TheMtl->Get_Flag(GAMEMTL_SURFACE_ROLLUP_OPEN) ? 0:APPENDROLL_CLOSED
  572. );
  573. #ifdef WANT_DISPLACEMENT_MAPS
  574. HwndDisplacementMap = IParams->AddRollupPage(
  575. AppInstance,
  576. MAKEINTRESOURCE(IDD_GAMEMTL_DISPLACEMENT_MAP),
  577. DisplacementMapDlgProc,
  578. Get_String(IDS_DISPLACEMENT_MAP),
  579. (LPARAM)this,
  580. TheMtl->Get_Flag(GAMEMTL_DISPLACEMENT_ROLLUP_OPEN) ? 0:APPENDROLL_CLOSED
  581. );
  582. #endif //WANT_DISPLACEMENT_MAPS
  583. HwndPassCount = IParams->AddRollupPage(
  584. AppInstance,
  585. MAKEINTRESOURCE(IDD_GAMEMTL_PASS_COUNT),
  586. PassCountPanelDlgProc,
  587. Get_String(IDS_PASS_COUNT),
  588. (LPARAM)this,
  589. TheMtl->Get_Flag(GAMEMTL_PASSCOUNT_ROLLUP_OPEN) ? 0:APPENDROLL_CLOSED
  590. );
  591. for (int i=0; i<TheMtl->Get_Pass_Count(); i++) {
  592. PassDialog[i] = new GameMtlPassDlg(HwndEdit, IParams, TheMtl, i);
  593. }
  594. IParams->SetRollupScrollPos(TheMtl->RollScroll);
  595. ReloadDialog();
  596. }