gmtldlg.cpp 53 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235
  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. /* $Header: /Commando/Code/Tools/max2w3d/gmtldlg.cpp 18 5/27/98 8:34a Greg_h $ */
  19. /***********************************************************************************************
  20. *** Confidential - Westwood Studios ***
  21. ***********************************************************************************************
  22. * *
  23. * Project Name : Commando / G 3D engine *
  24. * *
  25. * File Name : GMTLDLG.CPP *
  26. * *
  27. * Programmer : Greg Hjelstrom *
  28. * *
  29. * Start Date : 06/26/97 *
  30. * *
  31. * Last Update : June 26, 1997 [GH] *
  32. * *
  33. *---------------------------------------------------------------------------------------------*
  34. * Functions: *
  35. * GameMtlDlg::GameMtlDlg -- constructor *
  36. * GameMtlDlg::~GameMtlDlg -- destructor! *
  37. * GameMtlDlg::ClassID -- Returns the ClassID of GameMtl *
  38. * GameMtlDlg::Invalidate -- causes the dialog to be redrawn *
  39. * GameMtlDlg::ReloadDialog -- Updates the values in all of the dialog's controls *
  40. * GameMtlDlg::SetTime -- Sets the time value, updates the material and the dialog *
  41. * GameMtlDlg::PanelProc -- Windows Message handler *
  42. * PanelDlgProc -- Windows Proc which thunks into GameMtlDlg::PanelProc *
  43. * GameMtlDlg::LoadDialog -- Sets the state of all of the dialog's controls *
  44. * GameMtlDlg::UpdateMtlDisplay -- Informs MAX that the material parameters have changed *
  45. * GameMtlDlg::ActivateDlg -- Activates and deactivates the dialog *
  46. * GameMtlDlg::SetThing -- Sets the material to be edited *
  47. * GameMtlDlg::BuildDialog -- Adds the dialog to the material editor *
  48. * GameMtlDlg::UpdateTexmapDisplay -- Updates the texture map buttons *
  49. * NotesDlgProc -- Dialog Proc which thunks to GameMtlDlg::NotesProc *
  50. * GameMtlDlg::NotesProc -- Dialog Proc for the Notes panel *
  51. * HintsDlgProc -- Dialog proc which thunks to GameMtlDlg::HintsProc *
  52. * GameMtlDlg::HintsProc -- Dialog Proc for the hints panel *
  53. * GameMtlDlg::PsxProc -- Dialog proc for the PSX options panel *
  54. * PsxDlgProc -- Dialog proc which thunks into GameMtlDlg::PsxProc *
  55. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  56. #include <Max.h>
  57. #include <gport.h>
  58. #include <hsv.h>
  59. #include <bmmlib.h>
  60. #include "gmtldlg.h"
  61. #include "gamemtl.h"
  62. #include "gamemaps.h"
  63. #include "dllmain.h"
  64. #include "resource.h"
  65. #include "w3d_file.h"
  66. static inline float PcToFrac(int pc)
  67. {
  68. return (float)pc/100.0f;
  69. }
  70. static inline int FracToPc(float f)
  71. {
  72. if (f<0.0) return (int)(100.0f*f - .5f);
  73. else return (int) (100.0f*f + .5f);
  74. }
  75. /***********************************************************************************************
  76. * GameMtlDlg::GameMtlDlg -- constructor *
  77. * *
  78. * INPUT: *
  79. * hwMtlEdit - windows handle of the MAX material editor *
  80. * imp - Interface object for MAX materials and textures *
  81. * m - pointer to a GameMtl to be edited *
  82. * *
  83. * OUTPUT: *
  84. * *
  85. * WARNINGS: *
  86. * *
  87. * HISTORY: *
  88. * 06/26/1997 GH : Created. *
  89. *=============================================================================================*/
  90. GameMtlDlg::GameMtlDlg(HWND hwMtlEdit, IMtlParams *imp, GameMtl *m)
  91. {
  92. HwndEdit = hwMtlEdit;
  93. HwndPanel = NULL;
  94. HwndHints = NULL;
  95. HwndPsx = NULL;
  96. HwndNotes = NULL;
  97. HpalOld = NULL;
  98. TheMtl = m;
  99. IParams = imp;
  100. Valid = FALSE;
  101. IsActive = 0;
  102. InstCopy = FALSE;
  103. DiffuseSwatch = NULL;
  104. SpecularSwatch = NULL;
  105. AmbientCoeffSwatch = NULL;
  106. DiffuseCoeffSwatch = NULL;
  107. SpecularCoeffSwatch = NULL;
  108. EmissiveCoeffSwatch = NULL;
  109. DCTFramesSpin = NULL;
  110. DITFramesSpin = NULL;
  111. SCTFramesSpin = NULL;
  112. SITFramesSpin = NULL;
  113. DCTRateSpin = NULL;
  114. DITRateSpin = NULL;
  115. SCTRateSpin = NULL;
  116. SITRateSpin = NULL;
  117. OpacitySpin = NULL;
  118. TranslucencySpin = NULL;
  119. ShininessSpin = NULL;
  120. FogSpin = NULL;
  121. }
  122. /***********************************************************************************************
  123. * GameMtlDlg::~GameMtlDlg -- destructor! *
  124. * *
  125. * INPUT: *
  126. * *
  127. * OUTPUT: *
  128. * *
  129. * WARNINGS: *
  130. * *
  131. * HISTORY: *
  132. * 06/26/1997 GH : Created. *
  133. *=============================================================================================*/
  134. GameMtlDlg::~GameMtlDlg()
  135. {
  136. if (DiffuseSwatch) {
  137. ReleaseIColorSwatch(DiffuseSwatch);
  138. DiffuseSwatch = NULL;
  139. }
  140. if (SpecularSwatch) {
  141. ReleaseIColorSwatch(SpecularSwatch);
  142. SpecularSwatch = NULL;
  143. }
  144. if (AmbientCoeffSwatch) {
  145. ReleaseIColorSwatch(AmbientCoeffSwatch);
  146. AmbientCoeffSwatch = NULL;
  147. }
  148. if (DiffuseCoeffSwatch) {
  149. ReleaseIColorSwatch(DiffuseCoeffSwatch);
  150. DiffuseCoeffSwatch = NULL;
  151. }
  152. if (SpecularCoeffSwatch) {
  153. ReleaseIColorSwatch(SpecularCoeffSwatch);
  154. SpecularCoeffSwatch = NULL;
  155. }
  156. if (EmissiveCoeffSwatch) {
  157. ReleaseIColorSwatch(EmissiveCoeffSwatch);
  158. EmissiveCoeffSwatch = NULL;
  159. }
  160. if (HwndPanel) {
  161. HDC hdc = GetDC(HwndPanel);
  162. GetGPort()->RestorePalette(hdc, HpalOld);
  163. ReleaseDC(HwndPanel,hdc);
  164. }
  165. TheMtl->SetFlag(GAMEMTL_ROLLUP1_OPEN,IParams->IsRollupPanelOpen(HwndPanel));
  166. TheMtl->SetFlag(GAMEMTL_ROLLUP2_OPEN,IParams->IsRollupPanelOpen(HwndPsx));
  167. TheMtl->SetFlag(GAMEMTL_ROLLUP3_OPEN,IParams->IsRollupPanelOpen(HwndHints));
  168. TheMtl->SetFlag(GAMEMTL_ROLLUP4_OPEN,IParams->IsRollupPanelOpen(HwndNotes));
  169. TheMtl->RollScroll = IParams->GetRollupScrollPos();
  170. TheMtl->SetParamDlg(NULL);
  171. IParams->UnRegisterDlgWnd(HwndPanel);
  172. IParams->DeleteRollupPage(HwndPanel);
  173. HwndPanel = NULL;
  174. IParams->UnRegisterDlgWnd(HwndPsx);
  175. IParams->DeleteRollupPage(HwndPsx);
  176. HwndPsx = NULL;
  177. IParams->UnRegisterDlgWnd(HwndHints);
  178. IParams->DeleteRollupPage(HwndHints);
  179. HwndHints = NULL;
  180. IParams->UnRegisterDlgWnd(HwndNotes);
  181. IParams->DeleteRollupPage(HwndNotes);
  182. HwndNotes = NULL;
  183. }
  184. /***********************************************************************************************
  185. * GameMtlDlg::ClassID -- Returns the ClassID of GameMtl *
  186. * *
  187. * INPUT: *
  188. * *
  189. * OUTPUT: *
  190. * *
  191. * WARNINGS: *
  192. * *
  193. * HISTORY: *
  194. * 06/26/1997 GH : Created. *
  195. *=============================================================================================*/
  196. Class_ID GameMtlDlg::ClassID()
  197. {
  198. return GameMaterialClassID;
  199. }
  200. /***********************************************************************************************
  201. * GameMtlDlg::Invalidate -- causes the dialog to be redrawn *
  202. * *
  203. * INPUT: *
  204. * *
  205. * OUTPUT: *
  206. * *
  207. * WARNINGS: *
  208. * *
  209. * HISTORY: *
  210. * 06/26/1997 GH : Created. *
  211. *=============================================================================================*/
  212. void GameMtlDlg::Invalidate()
  213. {
  214. Valid = FALSE;
  215. InvalidateRect(HwndPanel,NULL,0);
  216. InvalidateRect(HwndPsx,NULL,0);
  217. InvalidateRect(HwndHints,NULL,0);
  218. InvalidateRect(HwndNotes,NULL,0);
  219. }
  220. /***********************************************************************************************
  221. * GameMtlDlg::ReloadDialog -- Updates the values in all of the dialog's controls *
  222. * *
  223. * INPUT: *
  224. * *
  225. * OUTPUT: *
  226. * *
  227. * WARNINGS: *
  228. * *
  229. * HISTORY: *
  230. * 06/26/1997 GH : Created. *
  231. *=============================================================================================*/
  232. void GameMtlDlg::ReloadDialog()
  233. {
  234. Interval v;
  235. TheMtl->Update(IParams->GetTime(),v);
  236. LoadDialog(FALSE);
  237. }
  238. /***********************************************************************************************
  239. * GameMtlDlg::SetTime -- Sets the time value, updates the material and the dialog *
  240. * *
  241. * INPUT: *
  242. * *
  243. * OUTPUT: *
  244. * *
  245. * WARNINGS: *
  246. * *
  247. * HISTORY: *
  248. * 06/26/1997 GH : Created. *
  249. *=============================================================================================*/
  250. void GameMtlDlg::SetTime(TimeValue t)
  251. {
  252. if (t!=CurTime) {
  253. CurTime = t;
  254. Interval v;
  255. TheMtl->Update(IParams->GetTime(),v);
  256. LoadDialog(TRUE);
  257. }
  258. }
  259. /***********************************************************************************************
  260. * GameMtlDlg::PanelProc -- Windows Message handler *
  261. * *
  262. * INPUT: *
  263. * *
  264. * OUTPUT: *
  265. * *
  266. * WARNINGS: *
  267. * *
  268. * HISTORY: *
  269. * 06/26/1997 GH : Created. *
  270. *=============================================================================================*/
  271. BOOL GameMtlDlg::PanelProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam )
  272. {
  273. int id = LOWORD(wParam);
  274. int code = HIWORD(wParam);
  275. int mtype;
  276. switch (msg) {
  277. case WM_INITDIALOG:
  278. {
  279. HDC theHDC = GetDC(hwndDlg);
  280. HpalOld = GetGPort()->PlugPalette(theHDC);
  281. ReleaseDC(hwndDlg,theHDC);
  282. DiffuseSwatch = GetIColorSwatch(GetDlgItem(hwndDlg, IDC_DIFFUSE_COLOR),TheMtl->GetDiffuse(),Get_String(IDS_DIFFUSE_COLOR));
  283. SpecularSwatch = GetIColorSwatch(GetDlgItem(hwndDlg, IDC_SPECULAR_COLOR),TheMtl->GetSpecular(),Get_String(IDS_SPECULAR_COLOR));
  284. AmbientCoeffSwatch = GetIColorSwatch(GetDlgItem(hwndDlg, IDC_AMBIENT_COEFF),TheMtl->GetAmbientCoeff(),Get_String(IDS_AMBIENT_COEFF));
  285. DiffuseCoeffSwatch = GetIColorSwatch(GetDlgItem(hwndDlg, IDC_DIFFUSE_COEFF),TheMtl->GetDiffuseCoeff(),Get_String(IDS_DIFFUSE_COEFF));
  286. SpecularCoeffSwatch = GetIColorSwatch(GetDlgItem(hwndDlg, IDC_SPECULAR_COEFF),TheMtl->GetSpecularCoeff(),Get_String(IDS_SPECULAR_COEFF));
  287. EmissiveCoeffSwatch = GetIColorSwatch(GetDlgItem(hwndDlg, IDC_EMISSIVE_COEFF),TheMtl->GetEmissiveCoeff(),Get_String(IDS_EMISSIVE_COEFF));
  288. DCTFramesSpin = SetupIntSpinner(hwndDlg,IDC_DCT_FRAMES_SPIN,IDC_DCT_FRAMES_EDIT,1,999,TheMtl->DCTFrames);
  289. DITFramesSpin = SetupIntSpinner(hwndDlg,IDC_DIT_FRAMES_SPIN,IDC_DIT_FRAMES_EDIT,1,999,TheMtl->DITFrames);
  290. SCTFramesSpin = SetupIntSpinner(hwndDlg,IDC_SCT_FRAMES_SPIN,IDC_SCT_FRAMES_EDIT,1,999,TheMtl->SCTFrames);
  291. SITFramesSpin = SetupIntSpinner(hwndDlg,IDC_SIT_FRAMES_SPIN,IDC_SIT_FRAMES_EDIT,1,999,TheMtl->SITFrames);
  292. DCTRateSpin = SetupFloatSpinner(hwndDlg,IDC_DCT_RATE_SPIN,IDC_DCT_RATE_EDIT,0.0f,60.0f,TheMtl->DCTFrameRate,5.0f);
  293. DITRateSpin = SetupFloatSpinner(hwndDlg,IDC_DIT_RATE_SPIN,IDC_DIT_RATE_EDIT,0.0f,60.0f,TheMtl->DITFrameRate,5.0f);
  294. SCTRateSpin = SetupFloatSpinner(hwndDlg,IDC_SCT_RATE_SPIN,IDC_SCT_RATE_EDIT,0.0f,60.0f,TheMtl->SCTFrameRate,5.0f);
  295. SITRateSpin = SetupFloatSpinner(hwndDlg,IDC_SIT_RATE_SPIN,IDC_SIT_RATE_EDIT,0.0f,60.0f,TheMtl->SITFrameRate,5.0f);
  296. OpacitySpin = SetupFloatSpinner(hwndDlg,IDC_OPACITY_SPIN,IDC_OPACITY_EDIT,0.0f,1.0f,TheMtl->GetOpacity(),0.01f);
  297. TranslucencySpin = SetupFloatSpinner(hwndDlg,IDC_TRANSLUCENCY_SPIN,IDC_TRANSULCENCY_EDIT,0.0f,1.0f,TheMtl->GetTranslucency(),0.01f);
  298. ShininessSpin = SetupFloatSpinner(hwndDlg,IDC_SHININESS_SPIN,IDC_SHININESS_EDIT,1.0f,1000.0f,TheMtl->GetShininess(),1.0f);
  299. FogSpin = SetupFloatSpinner(hwndDlg,IDC_FOG_SPIN,IDC_FOG_EDIT,0.0f,1.0f,TheMtl->FogCoeff,0.01f);
  300. SendDlgItemMessage( hwndDlg, IDC_DCT_MAPPING_COMBO, CB_ADDSTRING, 0, (LPARAM) (LPCTSTR) Get_String(IDS_UV_MAPPING));
  301. SendDlgItemMessage( hwndDlg, IDC_DCT_MAPPING_COMBO, CB_ADDSTRING, 0, (LPARAM) (LPCTSTR) Get_String(IDS_ENVIRONMENT_MAPPING) );
  302. SendDlgItemMessage( hwndDlg, IDC_DIT_MAPPING_COMBO, CB_ADDSTRING, 0, (LPARAM) (LPCTSTR) Get_String(IDS_UV_MAPPING));
  303. SendDlgItemMessage( hwndDlg, IDC_DIT_MAPPING_COMBO, CB_ADDSTRING, 0, (LPARAM) (LPCTSTR) Get_String(IDS_ENVIRONMENT_MAPPING) );
  304. SendDlgItemMessage( hwndDlg, IDC_SCT_MAPPING_COMBO, CB_ADDSTRING, 0, (LPARAM) (LPCTSTR) Get_String(IDS_UV_MAPPING));
  305. SendDlgItemMessage( hwndDlg, IDC_SCT_MAPPING_COMBO, CB_ADDSTRING, 0, (LPARAM) (LPCTSTR) Get_String(IDS_ENVIRONMENT_MAPPING) );
  306. SendDlgItemMessage( hwndDlg, IDC_SIT_MAPPING_COMBO, CB_ADDSTRING, 0, (LPARAM) (LPCTSTR) Get_String(IDS_UV_MAPPING));
  307. SendDlgItemMessage( hwndDlg, IDC_SIT_MAPPING_COMBO, CB_ADDSTRING, 0, (LPARAM) (LPCTSTR) Get_String(IDS_ENVIRONMENT_MAPPING) );
  308. /* Installing a windproc for texmap buttons which will handle drag-n-drop
  309. HWND hw = GetDlgItem(hwndDlg, texMapID[i]);
  310. WNDPROC oldp = (WNDPROC)GetWindowLong(hw, GWL_WNDPROC);
  311. SetWindowLong( hw, GWL_WNDPROC, (LONG)TexSlotWndProc);
  312. SetWindowLong( hw, GWL_USERDATA, (LONG)oldp);
  313. */
  314. return TRUE;
  315. }
  316. break;
  317. case WM_COMMAND:
  318. {
  319. switch (id) {
  320. case IDC_DCT_BUTTON:
  321. {
  322. BitmapInfo bmi;
  323. BitmapTex * texture;
  324. if (TheManager->SelectFileInput(&bmi, HwndEdit)) {
  325. texture = NewDefaultBitmapTex();
  326. if (texture) {
  327. texture->SetMapName((char *)bmi.Name());
  328. TheMtl->SetSubTexmap(ID_DI,texture);
  329. UpdateMtlDisplay();
  330. TheMtl->NotifyChanged();
  331. }
  332. }
  333. }
  334. break;
  335. case IDC_DIT_BUTTON:
  336. {
  337. BitmapInfo bmi;
  338. BitmapTex * texture;
  339. if (TheManager->SelectFileInput(&bmi, HwndEdit)) {
  340. texture = NewDefaultBitmapTex();
  341. if (texture) {
  342. texture->SetMapName((char *)bmi.Name());
  343. TheMtl->SetSubTexmap(ID_SI,texture);
  344. UpdateMtlDisplay();
  345. TheMtl->NotifyChanged();
  346. }
  347. }
  348. }
  349. break;
  350. case IDC_SCT_BUTTON:
  351. {
  352. BitmapInfo bmi;
  353. BitmapTex * texture;
  354. if (TheManager->SelectFileInput(&bmi, HwndEdit)) {
  355. texture = NewDefaultBitmapTex();
  356. if (texture) {
  357. texture->SetMapName((char *)bmi.Name());
  358. TheMtl->SetSubTexmap(ID_SP,texture);
  359. UpdateMtlDisplay();
  360. TheMtl->NotifyChanged();
  361. }
  362. }
  363. }
  364. break;
  365. case IDC_SIT_BUTTON:
  366. {
  367. BitmapInfo bmi;
  368. BitmapTex * texture;
  369. if (TheManager->SelectFileInput(&bmi, HwndEdit)) {
  370. texture = NewDefaultBitmapTex();
  371. if (texture) {
  372. texture->SetMapName((char *)bmi.Name());
  373. TheMtl->SetSubTexmap(ID_RL,texture);
  374. UpdateMtlDisplay();
  375. TheMtl->NotifyChanged();
  376. }
  377. }
  378. }
  379. break;
  380. case IDC_MAPON_DCT:
  381. TheMtl->EnableMap(ID_DI,GetCheckBox(hwndDlg, id));
  382. if (!GetCheckBox(hwndDlg,id)) TheMtl->SetSubTexmap(ID_DI,NULL);
  383. UpdateTexmapDisplay(ID_DI);
  384. UpdateMtlDisplay();
  385. TheMtl->NotifyChanged();
  386. break;
  387. case IDC_MAPON_DIT:
  388. TheMtl->EnableMap(ID_SI,GetCheckBox(hwndDlg, id));
  389. if (!GetCheckBox(hwndDlg,id)) TheMtl->SetSubTexmap(ID_SI,NULL);
  390. UpdateTexmapDisplay(ID_SI);
  391. UpdateMtlDisplay();
  392. TheMtl->NotifyChanged();
  393. break;
  394. case IDC_MAPON_SCT:
  395. TheMtl->EnableMap(ID_SP,GetCheckBox(hwndDlg, id));
  396. if (!GetCheckBox(hwndDlg,id)) TheMtl->SetSubTexmap(ID_SP,NULL);
  397. UpdateTexmapDisplay(ID_SP);
  398. UpdateMtlDisplay();
  399. TheMtl->NotifyChanged();
  400. break;
  401. case IDC_MAPON_SIT:
  402. TheMtl->EnableMap(ID_RL,GetCheckBox(hwndDlg, id));
  403. if (!GetCheckBox(hwndDlg,id)) TheMtl->SetSubTexmap(ID_RL,NULL);
  404. UpdateTexmapDisplay(ID_RL);
  405. UpdateMtlDisplay();
  406. TheMtl->NotifyChanged();
  407. break;
  408. case IDC_USE_ALPHA_CHECK:
  409. TheMtl->SetAttribute(GAMEMTL_USE_ALPHA,GetCheckBox(hwndDlg,IDC_USE_ALPHA_CHECK));
  410. UpdateMtlDisplay();
  411. TheMtl->NotifyChanged();
  412. break;
  413. case IDC_USE_SORTING_CHECK:
  414. TheMtl->SetAttribute(GAMEMTL_USE_SORTING,GetCheckBox(hwndDlg,IDC_USE_SORTING_CHECK));
  415. break;
  416. case IDC_DCT_MAPPING_COMBO:
  417. mtype = SendDlgItemMessage(hwndDlg,IDC_DCT_MAPPING_COMBO,CB_GETCURSEL,0,0);
  418. TheMtl->DCTMappingType = mtype;
  419. break;
  420. case IDC_DIT_MAPPING_COMBO:
  421. mtype = SendDlgItemMessage(hwndDlg,IDC_DIT_MAPPING_COMBO,CB_GETCURSEL,0,0);
  422. TheMtl->DITMappingType = mtype;
  423. break;
  424. case IDC_SCT_MAPPING_COMBO:
  425. mtype = SendDlgItemMessage(hwndDlg,IDC_SCT_MAPPING_COMBO,CB_GETCURSEL,0,0);
  426. TheMtl->SCTMappingType = mtype;
  427. break;
  428. case IDC_SIT_MAPPING_COMBO:
  429. mtype = SendDlgItemMessage(hwndDlg,IDC_SIT_MAPPING_COMBO,CB_GETCURSEL,0,0);
  430. TheMtl->SITMappingType = mtype;
  431. break;
  432. case IDC_VIEWPORT_DISPLAY_CHECK:
  433. TheMtl->Set_Viewport_Display_Status(GetCheckBox(hwndDlg,IDC_VIEWPORT_DISPLAY_CHECK));
  434. TheMtl->NotifyChanged();
  435. UpdateMtlDisplay();
  436. break;
  437. }
  438. }
  439. break;
  440. case CC_COLOR_CHANGE:
  441. {
  442. // just update all of the colors
  443. TheMtl->Diffuse = DiffuseSwatch->GetColor();
  444. TheMtl->Specular = SpecularSwatch->GetColor();
  445. TheMtl->AmbientCoeff = AmbientCoeffSwatch->GetColor();
  446. TheMtl->DiffuseCoeff = DiffuseCoeffSwatch->GetColor();
  447. TheMtl->SpecularCoeff = SpecularCoeffSwatch->GetColor();
  448. TheMtl->EmissiveCoeff = EmissiveCoeffSwatch->GetColor();
  449. TheMtl->NotifyChanged();
  450. UpdateMtlDisplay();
  451. }
  452. break;
  453. case WM_LBUTTONDOWN:
  454. case WM_LBUTTONUP:
  455. case WM_MOUSEMOVE:
  456. {
  457. IParams->RollupMouseMessage(hwndDlg,msg,wParam,lParam);
  458. }
  459. return FALSE;
  460. case CC_SPINNER_CHANGE:
  461. {
  462. TheMtl->DCTFrames = DCTFramesSpin->GetIVal();
  463. TheMtl->DITFrames = DITFramesSpin->GetIVal();
  464. TheMtl->SCTFrames = SCTFramesSpin->GetIVal();
  465. TheMtl->SITFrames = SITFramesSpin->GetIVal();
  466. TheMtl->DCTFrameRate = DCTRateSpin->GetFVal();
  467. TheMtl->DITFrameRate = DITRateSpin->GetFVal();
  468. TheMtl->SCTFrameRate = SCTRateSpin->GetFVal();
  469. TheMtl->SITFrameRate = SITRateSpin->GetFVal();
  470. TheMtl->SetOpacity(OpacitySpin->GetFVal());
  471. TheMtl->SetTranslucency(TranslucencySpin->GetFVal());
  472. TheMtl->SetShininess(ShininessSpin->GetFVal());
  473. TheMtl->FogCoeff = FogSpin->GetFVal();
  474. TheMtl->NotifyChanged();
  475. UpdateMtlDisplay();
  476. }
  477. break;
  478. case CC_SPINNER_BUTTONUP:
  479. {
  480. #if 0
  481. UpdateMtlDisplay();
  482. #endif
  483. }
  484. break;
  485. case WM_PAINT:
  486. {
  487. if (!Valid) {
  488. Valid = TRUE;
  489. ReloadDialog();
  490. }
  491. }
  492. return FALSE;
  493. case WM_CLOSE:
  494. break;
  495. case WM_DESTROY:
  496. TheMtl->DCTFrames = DCTFramesSpin->GetIVal();
  497. TheMtl->DITFrames = DITFramesSpin->GetIVal();
  498. TheMtl->SCTFrames = SCTFramesSpin->GetIVal();
  499. TheMtl->SITFrames = SITFramesSpin->GetIVal();
  500. TheMtl->DCTFrameRate = DCTRateSpin->GetFVal();
  501. TheMtl->DITFrameRate = DITRateSpin->GetFVal();
  502. TheMtl->SCTFrameRate = SCTRateSpin->GetFVal();
  503. TheMtl->SITFrameRate = SITRateSpin->GetFVal();
  504. TheMtl->SetOpacity(OpacitySpin->GetFVal());
  505. TheMtl->SetTranslucency(TranslucencySpin->GetFVal());
  506. TheMtl->SetShininess(ShininessSpin->GetFVal());
  507. TheMtl->FogCoeff = FogSpin->GetFVal();
  508. ReleaseISpinner(DCTFramesSpin);
  509. ReleaseISpinner(DITFramesSpin);
  510. ReleaseISpinner(SCTFramesSpin);
  511. ReleaseISpinner(SITFramesSpin);
  512. ReleaseISpinner(DCTRateSpin);
  513. ReleaseISpinner(DITRateSpin);
  514. ReleaseISpinner(SCTRateSpin);
  515. ReleaseISpinner(SITRateSpin);
  516. ReleaseISpinner(OpacitySpin);
  517. ReleaseISpinner(TranslucencySpin);
  518. ReleaseISpinner(ShininessSpin);
  519. ReleaseISpinner(FogSpin);
  520. DCTFramesSpin = DITFramesSpin = SCTFramesSpin = SITFramesSpin = NULL;
  521. DCTRateSpin = DITRateSpin = SCTRateSpin = SITRateSpin = NULL;
  522. OpacitySpin = TranslucencySpin = ShininessSpin = FogSpin = NULL;
  523. break;
  524. }
  525. return FALSE;
  526. }
  527. /***********************************************************************************************
  528. * PanelDlgProc -- Windows Proc which thunks into GameMtlDlg::PanelProc *
  529. * *
  530. * INPUT: *
  531. * *
  532. * OUTPUT: *
  533. * *
  534. * WARNINGS: *
  535. * *
  536. * HISTORY: *
  537. * 06/26/1997 GH : Created. *
  538. *=============================================================================================*/
  539. static BOOL CALLBACK PanelDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
  540. {
  541. GameMtlDlg *theDlg;
  542. if (msg==WM_INITDIALOG) {
  543. theDlg = (GameMtlDlg*)lParam;
  544. theDlg->HwndPanel = hwndDlg;
  545. SetWindowLong(hwndDlg, GWL_USERDATA,lParam);
  546. } else {
  547. if ((theDlg = (GameMtlDlg *)GetWindowLong(hwndDlg, GWL_USERDATA) ) == NULL) {
  548. return FALSE;
  549. }
  550. }
  551. BOOL res;
  552. theDlg->IsActive = 1;
  553. res = theDlg->PanelProc(hwndDlg,msg,wParam,lParam);
  554. theDlg->IsActive = 0;
  555. return res;
  556. }
  557. /***********************************************************************************************
  558. * GameMtlDlg::NotesProc -- Dialog Proc for the Notes panel *
  559. * *
  560. * INPUT: *
  561. * *
  562. * OUTPUT: *
  563. * *
  564. * WARNINGS: *
  565. * *
  566. * HISTORY: *
  567. * 06/26/1997 GH : Created. *
  568. *=============================================================================================*/
  569. BOOL GameMtlDlg::NotesProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
  570. {
  571. int id = LOWORD(wParam);
  572. int code = HIWORD(wParam);
  573. switch (msg) {
  574. case WM_LBUTTONDOWN:
  575. case WM_LBUTTONUP:
  576. case WM_MOUSEMOVE:
  577. {
  578. IParams->RollupMouseMessage(hwndDlg,msg,wParam,lParam);
  579. return FALSE;
  580. }
  581. case WM_COMMAND:
  582. {
  583. int i = lParam;
  584. }
  585. break;
  586. }
  587. return FALSE;
  588. }
  589. /***********************************************************************************************
  590. * NotesDlgProc -- Dialog Proc which thunks to GameMtlDlg::NotesProc *
  591. * *
  592. * INPUT: *
  593. * *
  594. * OUTPUT: *
  595. * *
  596. * WARNINGS: *
  597. * *
  598. * HISTORY: *
  599. * 06/26/1997 GH : Created. *
  600. *=============================================================================================*/
  601. static BOOL CALLBACK NotesDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
  602. {
  603. GameMtlDlg *theDlg;
  604. if (msg==WM_INITDIALOG) {
  605. theDlg = (GameMtlDlg*)lParam;
  606. theDlg->HwndNotes = hwndDlg;
  607. SetWindowLong(hwndDlg, GWL_USERDATA,lParam);
  608. } else {
  609. if ((theDlg = (GameMtlDlg *)GetWindowLong(hwndDlg, GWL_USERDATA) ) == NULL) {
  610. return FALSE;
  611. }
  612. }
  613. BOOL res;
  614. theDlg->IsActive = 1;
  615. res = theDlg->NotesProc(hwndDlg,msg,wParam,lParam);
  616. theDlg->IsActive = 0;
  617. return res;
  618. }
  619. /***********************************************************************************************
  620. * GameMtlDlg::HintsProc -- Dialog Proc for the hints panel *
  621. * *
  622. * INPUT: *
  623. * *
  624. * OUTPUT: *
  625. * *
  626. * WARNINGS: *
  627. * *
  628. * HISTORY: *
  629. * 3/30/98 GTH : Created. *
  630. *=============================================================================================*/
  631. BOOL GameMtlDlg::HintsProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
  632. {
  633. int id = LOWORD(wParam);
  634. int code = HIWORD(wParam);
  635. switch (msg) {
  636. case WM_LBUTTONDOWN:
  637. case WM_LBUTTONUP:
  638. case WM_MOUSEMOVE:
  639. {
  640. IParams->RollupMouseMessage(hwndDlg,msg,wParam,lParam);
  641. return FALSE;
  642. }
  643. case WM_COMMAND:
  644. {
  645. switch(id)
  646. {
  647. case IDC_DIT_OVER_DCT_CHECK:
  648. TheMtl->SetAttribute(GAMEMTL_DIT_OVER_DCT, GetCheckBox(hwndDlg, IDC_DIT_OVER_DCT_CHECK));
  649. break;
  650. case IDC_SIT_OVER_SCT_CHECK:
  651. TheMtl->SetAttribute(GAMEMTL_SIT_OVER_SCT, GetCheckBox(hwndDlg, IDC_SIT_OVER_SCT_CHECK));
  652. break;
  653. case IDC_DIT_OVER_DIG_CHECK:
  654. TheMtl->SetAttribute(GAMEMTL_DIT_OVER_DIG, GetCheckBox(hwndDlg, IDC_DIT_OVER_DIG_CHECK));
  655. break;
  656. case IDC_SIT_OVER_SIG_CHECK:
  657. TheMtl->SetAttribute(GAMEMTL_SIT_OVER_SIG, GetCheckBox(hwndDlg, IDC_SIT_OVER_SIG_CHECK));
  658. break;
  659. case IDC_FAST_SPECULAR_AFTER_ALPHA_CHECK:
  660. TheMtl->SetAttribute(GAMEMTL_FAST_SPECULAR_AFTER_ALPHA, GetCheckBox(hwndDlg, IDC_FAST_SPECULAR_AFTER_ALPHA_CHECK));
  661. break;
  662. }
  663. }
  664. break;
  665. }
  666. return FALSE;
  667. }
  668. /***********************************************************************************************
  669. * HintsDlgProc -- Dialog proc which thunks to GameMtlDlg::HintsProc *
  670. * *
  671. * INPUT: *
  672. * *
  673. * OUTPUT: *
  674. * *
  675. * WARNINGS: *
  676. * *
  677. * HISTORY: *
  678. * 3/30/98 GTH : Created. *
  679. *=============================================================================================*/
  680. static BOOL CALLBACK HintsDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
  681. {
  682. GameMtlDlg *theDlg;
  683. if (msg==WM_INITDIALOG) {
  684. theDlg = (GameMtlDlg*)lParam;
  685. theDlg->HwndHints = hwndDlg;
  686. SetWindowLong(hwndDlg, GWL_USERDATA,lParam);
  687. } else {
  688. if ((theDlg = (GameMtlDlg *)GetWindowLong(hwndDlg, GWL_USERDATA) ) == NULL) {
  689. return FALSE;
  690. }
  691. }
  692. BOOL res;
  693. theDlg->IsActive = 1;
  694. res = theDlg->HintsProc(hwndDlg,msg,wParam,lParam);
  695. theDlg->IsActive = 0;
  696. return res;
  697. }
  698. /***********************************************************************************************
  699. * GameMtlDlg::PsxProc -- Dialog proc for the PSX options panel *
  700. * *
  701. * INPUT: *
  702. * *
  703. * OUTPUT: *
  704. * *
  705. * WARNINGS: *
  706. * *
  707. * HISTORY: *
  708. * 3/31/98 GTH : Created. *
  709. *=============================================================================================*/
  710. BOOL GameMtlDlg::PsxProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
  711. {
  712. int id = LOWORD(wParam);
  713. int code = HIWORD(wParam);
  714. switch (msg) {
  715. case WM_LBUTTONDOWN:
  716. case WM_LBUTTONUP:
  717. case WM_MOUSEMOVE:
  718. {
  719. IParams->RollupMouseMessage(hwndDlg,msg,wParam,lParam);
  720. return FALSE;
  721. }
  722. case WM_COMMAND:
  723. {
  724. switch(id)
  725. {
  726. case IDC_NO_TRANS:
  727. TheMtl->SetMaskedAttribute(GAMEMTL_PSX_TRANS_MASK,0);
  728. break;
  729. case IDC_100_TRANS:
  730. TheMtl->SetMaskedAttribute(GAMEMTL_PSX_TRANS_MASK,GAMEMTL_PSX_100_TRANS);
  731. break;
  732. case IDC_50_TRANS:
  733. TheMtl->SetMaskedAttribute(GAMEMTL_PSX_TRANS_MASK,GAMEMTL_PSX_50_TRANS);
  734. break;
  735. case IDC_25_TRANS:
  736. TheMtl->SetMaskedAttribute(GAMEMTL_PSX_TRANS_MASK,GAMEMTL_PSX_25_TRANS);
  737. break;
  738. case IDC_MINUS_100_TRANS:
  739. TheMtl->SetMaskedAttribute(GAMEMTL_PSX_TRANS_MASK,GAMEMTL_PSX_MINUS_100_TRANS);
  740. break;
  741. case IDC_NO_RT_LIGHTING:
  742. TheMtl->SetAttribute(GAMEMTL_PSX_NO_RT_LIGHTING, GetCheckBox(hwndDlg, IDC_NO_RT_LIGHTING));
  743. break;
  744. }
  745. }
  746. break;
  747. }
  748. return FALSE;
  749. }
  750. /***********************************************************************************************
  751. * PsxDlgProc -- Dialog proc which thunks into GameMtlDlg::PsxProc *
  752. * *
  753. * INPUT: *
  754. * *
  755. * OUTPUT: *
  756. * *
  757. * WARNINGS: *
  758. * *
  759. * HISTORY: *
  760. * 3/31/98 GTH : Created. *
  761. *=============================================================================================*/
  762. static BOOL CALLBACK PsxDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
  763. {
  764. GameMtlDlg *theDlg;
  765. if (msg==WM_INITDIALOG) {
  766. theDlg = (GameMtlDlg*)lParam;
  767. theDlg->HwndPsx = hwndDlg;
  768. SetWindowLong(hwndDlg, GWL_USERDATA,lParam);
  769. } else {
  770. if ((theDlg = (GameMtlDlg *)GetWindowLong(hwndDlg, GWL_USERDATA) ) == NULL) {
  771. return FALSE;
  772. }
  773. }
  774. BOOL res;
  775. theDlg->IsActive = 1;
  776. res = theDlg->PsxProc(hwndDlg,msg,wParam,lParam);
  777. theDlg->IsActive = 0;
  778. return res;
  779. }
  780. /***********************************************************************************************
  781. * GameMtlDlg::LoadDialog -- Sets the state of all of the dialog's controls *
  782. * *
  783. * INPUT: *
  784. * *
  785. * OUTPUT: *
  786. * *
  787. * WARNINGS: *
  788. * *
  789. * HISTORY: *
  790. * 06/26/1997 GH : Created. *
  791. *=============================================================================================*/
  792. void GameMtlDlg::LoadDialog(BOOL draw)
  793. {
  794. /*
  795. ** Set the state of the entire panel based on the current material.
  796. */
  797. if (TheMtl && HwndPanel) {
  798. /*
  799. ** Init all of the color swatches
  800. */
  801. if (DiffuseSwatch) {
  802. DiffuseSwatch->InitColor(TheMtl->GetDiffuse());
  803. }
  804. if (SpecularSwatch) {
  805. SpecularSwatch->InitColor(TheMtl->GetSpecular());
  806. }
  807. if (AmbientCoeffSwatch) {
  808. AmbientCoeffSwatch->InitColor(TheMtl->GetAmbientCoeff());
  809. }
  810. if (DiffuseCoeffSwatch) {
  811. DiffuseCoeffSwatch->InitColor(TheMtl->GetDiffuseCoeff());
  812. }
  813. if (SpecularCoeffSwatch) {
  814. SpecularCoeffSwatch->InitColor(TheMtl->GetSpecularCoeff());
  815. }
  816. if (EmissiveCoeffSwatch) {
  817. EmissiveCoeffSwatch->InitColor(TheMtl->GetEmissiveCoeff());
  818. }
  819. /*
  820. ** Checkboxes
  821. */
  822. SetCheckBox(HwndPanel,IDC_USE_ALPHA_CHECK, TheMtl->GetAttribute(GAMEMTL_USE_ALPHA));
  823. SetCheckBox(HwndPanel,IDC_USE_SORTING_CHECK, TheMtl->GetAttribute(GAMEMTL_USE_SORTING));
  824. SetCheckBox(HwndPanel,IDC_VIEWPORT_DISPLAY_CHECK,TheMtl->Get_Viewport_Display_Status());
  825. /*
  826. ** Texture maps enable checks.
  827. */
  828. SetCheckBox(HwndPanel,IDC_MAPON_DCT, TheMtl->SubTexmapOn(ID_DI));
  829. SetCheckBox(HwndPanel,IDC_MAPON_DIT, TheMtl->SubTexmapOn(ID_SI));
  830. SetCheckBox(HwndPanel,IDC_MAPON_SCT, TheMtl->SubTexmapOn(ID_SP));
  831. SetCheckBox(HwndPanel,IDC_MAPON_SIT, TheMtl->SubTexmapOn(ID_RL));
  832. /*
  833. ** Mapping types
  834. */
  835. SendDlgItemMessage( HwndPanel, IDC_DCT_MAPPING_COMBO, CB_SETCURSEL, TheMtl->DCTMappingType, 0 );
  836. SendDlgItemMessage( HwndPanel, IDC_DIT_MAPPING_COMBO, CB_SETCURSEL, TheMtl->DITMappingType, 0 );
  837. SendDlgItemMessage( HwndPanel, IDC_SCT_MAPPING_COMBO, CB_SETCURSEL, TheMtl->SCTMappingType, 0 );
  838. SendDlgItemMessage( HwndPanel, IDC_SIT_MAPPING_COMBO, CB_SETCURSEL, TheMtl->SITMappingType, 0 );
  839. /*
  840. ** Texture animation parameters
  841. */
  842. DCTFramesSpin->SetValue(TheMtl->DCTFrames,FALSE);
  843. DITFramesSpin->SetValue(TheMtl->DITFrames,FALSE);
  844. SCTFramesSpin->SetValue(TheMtl->SCTFrames,FALSE);
  845. SITFramesSpin->SetValue(TheMtl->SITFrames,FALSE);
  846. DCTRateSpin->SetValue(TheMtl->DCTFrameRate,FALSE);
  847. DITRateSpin->SetValue(TheMtl->DITFrameRate,FALSE);
  848. SCTRateSpin->SetValue(TheMtl->SCTFrameRate,FALSE);
  849. SITRateSpin->SetValue(TheMtl->SITFrameRate,FALSE);
  850. /*
  851. ** Opacity, translucency, etc
  852. */
  853. OpacitySpin->SetValue(TheMtl->Opacity,FALSE);
  854. TranslucencySpin->SetValue(TheMtl->Translucency,FALSE);
  855. ShininessSpin->SetValue(TheMtl->Shininess,FALSE);
  856. FogSpin->SetValue(TheMtl->FogCoeff,FALSE);
  857. /*
  858. ** Init the Psx flags state
  859. */
  860. SetCheckBox(HwndPsx,IDC_NO_RT_LIGHTING, TheMtl->GetAttribute(GAMEMTL_PSX_NO_RT_LIGHTING));
  861. SetCheckBox(HwndPsx,IDC_NO_TRANS, false);
  862. SetCheckBox(HwndPsx,IDC_100_TRANS, false);
  863. SetCheckBox(HwndPsx,IDC_50_TRANS, false);
  864. SetCheckBox(HwndPsx,IDC_25_TRANS, false);
  865. SetCheckBox(HwndPsx,IDC_MINUS_100_TRANS, false);
  866. switch (TheMtl->GetMaskedAttribute(GAMEMTL_PSX_TRANS_MASK)) {
  867. case 0:
  868. SetCheckBox(HwndPsx,IDC_NO_TRANS,true);
  869. break;
  870. case GAMEMTL_PSX_100_TRANS:
  871. SetCheckBox(HwndPsx,IDC_100_TRANS,true);
  872. break;
  873. case GAMEMTL_PSX_50_TRANS:
  874. SetCheckBox(HwndPsx,IDC_50_TRANS,true);
  875. break;
  876. case GAMEMTL_PSX_25_TRANS:
  877. SetCheckBox(HwndPsx,IDC_25_TRANS,true);
  878. break;
  879. case GAMEMTL_PSX_MINUS_100_TRANS:
  880. SetCheckBox(HwndPsx,IDC_MINUS_100_TRANS,true);
  881. break;
  882. }
  883. /*
  884. ** Init the Hints state
  885. */
  886. SetCheckBox(HwndHints,IDC_DIT_OVER_DCT_CHECK, TheMtl->GetAttribute(GAMEMTL_DIT_OVER_DCT));
  887. SetCheckBox(HwndHints,IDC_SIT_OVER_SCT_CHECK, TheMtl->GetAttribute(GAMEMTL_SIT_OVER_SCT));
  888. SetCheckBox(HwndHints,IDC_DIT_OVER_DIG_CHECK, TheMtl->GetAttribute(GAMEMTL_DIT_OVER_DIG));
  889. SetCheckBox(HwndHints,IDC_SIT_OVER_SIG_CHECK, TheMtl->GetAttribute(GAMEMTL_SIT_OVER_SIG));
  890. SetCheckBox(HwndHints,IDC_FAST_SPECULAR_AFTER_ALPHA_CHECK, TheMtl->GetAttribute(GAMEMTL_FAST_SPECULAR_AFTER_ALPHA));
  891. /*
  892. ** Init the texmaps state
  893. */
  894. for (int i=0; i<NTEXMAPS; i++) {
  895. UpdateTexmapDisplay(i);
  896. }
  897. }
  898. }
  899. /***********************************************************************************************
  900. * GameMtlDlg::UpdateMtlDisplay -- Informs MAX that the material parameters have changed *
  901. * *
  902. * INPUT: *
  903. * *
  904. * OUTPUT: *
  905. * *
  906. * WARNINGS: *
  907. * *
  908. * HISTORY: *
  909. * 06/26/1997 GH : Created. *
  910. *=============================================================================================*/
  911. void GameMtlDlg::UpdateMtlDisplay()
  912. {
  913. IParams->MtlChanged();
  914. }
  915. /***********************************************************************************************
  916. * GameMtlDlg::ActivateDlg -- Activates and deactivates the dialog *
  917. * *
  918. * INPUT: *
  919. * *
  920. * OUTPUT: *
  921. * *
  922. * WARNINGS: *
  923. * *
  924. * HISTORY: *
  925. * 06/26/1997 GH : Created. *
  926. *=============================================================================================*/
  927. void GameMtlDlg::ActivateDlg(BOOL onOff)
  928. {
  929. if (DiffuseSwatch) {
  930. DiffuseSwatch->Activate(onOff);
  931. }
  932. if (SpecularSwatch) {
  933. SpecularSwatch->Activate(onOff);
  934. }
  935. if (AmbientCoeffSwatch) {
  936. AmbientCoeffSwatch->Activate(onOff);
  937. }
  938. if (DiffuseCoeffSwatch) {
  939. DiffuseCoeffSwatch->Activate(onOff);
  940. }
  941. if (SpecularCoeffSwatch) {
  942. SpecularCoeffSwatch->Activate(onOff);
  943. }
  944. if (EmissiveCoeffSwatch) {
  945. EmissiveCoeffSwatch->Activate(onOff);
  946. }
  947. }
  948. /***********************************************************************************************
  949. * GameMtlDlg::SetThing -- Sets the material to be edited *
  950. * *
  951. * INPUT: *
  952. * *
  953. * OUTPUT: *
  954. * *
  955. * WARNINGS: *
  956. * *
  957. * HISTORY: *
  958. * 06/26/1997 GH : Created. *
  959. *=============================================================================================*/
  960. void GameMtlDlg::SetThing(ReferenceTarget *m)
  961. {
  962. assert (m->SuperClassID()==MATERIAL_CLASS_ID);
  963. assert (m->ClassID()==GameMaterialClassID);
  964. if (TheMtl) {
  965. TheMtl->ParamPanel = NULL;
  966. }
  967. TheMtl = (GameMtl *)m;
  968. if (TheMtl) {
  969. TheMtl->ParamPanel = this;
  970. }
  971. LoadDialog(TRUE);
  972. if (HwndPanel && DiffuseSwatch) {
  973. DiffuseSwatch->InitColor(TheMtl->GetDiffuse());
  974. }
  975. if (HwndPanel && SpecularSwatch) {
  976. SpecularSwatch->InitColor(TheMtl->GetSpecular());
  977. }
  978. if (HwndPanel && AmbientCoeffSwatch) {
  979. AmbientCoeffSwatch->InitColor(TheMtl->GetAmbientCoeff());
  980. }
  981. if (HwndPanel && DiffuseCoeffSwatch) {
  982. DiffuseCoeffSwatch->InitColor(TheMtl->GetDiffuseCoeff());
  983. }
  984. if (HwndPanel && SpecularCoeffSwatch) {
  985. SpecularCoeffSwatch->InitColor(TheMtl->GetSpecularCoeff());
  986. }
  987. if (HwndPanel && EmissiveCoeffSwatch) {
  988. EmissiveCoeffSwatch->InitColor(TheMtl->GetEmissiveCoeff());
  989. }
  990. }
  991. /***********************************************************************************************
  992. * GameMtlDlg::BuildDialog -- Adds the dialog to the material editor *
  993. * *
  994. * INPUT: *
  995. * *
  996. * OUTPUT: *
  997. * *
  998. * WARNINGS: *
  999. * *
  1000. * HISTORY: *
  1001. * 06/26/1997 GH : Created. *
  1002. *=============================================================================================*/
  1003. void GameMtlDlg::BuildDialog()
  1004. {
  1005. if ((TheMtl->Flags&(GAMEMTL_ROLLUP_FLAGS))==0) {
  1006. TheMtl->SetFlag(GAMEMTL_ROLLUP1_OPEN,TRUE);
  1007. }
  1008. HwndPanel = IParams->AddRollupPage(
  1009. AppInstance,
  1010. MAKEINTRESOURCE(IDD_GAMEMTL_PANEL),
  1011. PanelDlgProc,
  1012. Get_String(IDS_PARAMETERS),
  1013. (LPARAM)this,
  1014. (TheMtl->GetFlag(GAMEMTL_ROLLUP1_OPEN) ? 0:APPENDROLL_CLOSED)
  1015. );
  1016. HwndPsx = IParams->AddRollupPage(
  1017. AppInstance,
  1018. MAKEINTRESOURCE(IDD_GAMEMTL_PSX_PANEL),
  1019. PsxDlgProc,
  1020. Get_String(IDS_PSX_OPTIONS),
  1021. (LPARAM)this,
  1022. (TheMtl->GetFlag(GAMEMTL_ROLLUP2_OPEN) ? 0:APPENDROLL_CLOSED)
  1023. );
  1024. HwndHints = IParams->AddRollupPage(
  1025. AppInstance,
  1026. MAKEINTRESOURCE(IDD_GAMEMTL_HINTS_PANEL),
  1027. HintsDlgProc,
  1028. Get_String(IDS_MATERIAL_HINTS),
  1029. (LPARAM)this,
  1030. (TheMtl->GetFlag(GAMEMTL_ROLLUP3_OPEN) ? 0:APPENDROLL_CLOSED)
  1031. );
  1032. HwndNotes = IParams->AddRollupPage(
  1033. AppInstance,
  1034. MAKEINTRESOURCE(IDD_MATERIAL_NOTES_PANEL),
  1035. NotesDlgProc,
  1036. Get_String(IDS_NOTES),
  1037. (LPARAM)this,
  1038. (TheMtl->GetFlag(GAMEMTL_ROLLUP4_OPEN) ? 0:APPENDROLL_CLOSED)
  1039. );
  1040. IParams->SetRollupScrollPos(TheMtl->RollScroll);
  1041. }
  1042. /***********************************************************************************************
  1043. * GameMtlDlg::UpdateTexmapDisplay -- Updates the texture map buttons *
  1044. * *
  1045. * INPUT: *
  1046. * *
  1047. * OUTPUT: *
  1048. * *
  1049. * WARNINGS: *
  1050. * *
  1051. * HISTORY: *
  1052. * 06/26/1997 GH : Created. *
  1053. *=============================================================================================*/
  1054. void GameMtlDlg::UpdateTexmapDisplay(int i)
  1055. {
  1056. TSTR nm = Get_String(IDS_NONE);
  1057. Texmap *texmap = (*TheMtl->Maps)[i].Map;
  1058. if (texmap) nm = texmap->GetFullName();
  1059. // Diffuse Map -> Surrender Diffuse Color Channel
  1060. if (i == ID_DI) {
  1061. SetCheckBox(HwndPanel, IDC_MAPON_DCT, TheMtl->IsMapEnabled(i));
  1062. SetDlgItemText(HwndPanel, IDC_DCT_BUTTON, nm.data());
  1063. }
  1064. // Self Illumination Map -> Surrender Diffuse Illumination Channel
  1065. if (i == ID_SI) {
  1066. SetCheckBox(HwndPanel, IDC_MAPON_DIT, TheMtl->IsMapEnabled(i));
  1067. SetDlgItemText(HwndPanel, IDC_DIT_BUTTON, nm.data());
  1068. }
  1069. // Specular Map -> Surrender Specular Color Channel
  1070. if (i == ID_SP) {
  1071. SetCheckBox(HwndPanel, IDC_MAPON_SCT, TheMtl->IsMapEnabled(i));
  1072. SetDlgItemText(HwndPanel, IDC_SCT_BUTTON, nm.data());
  1073. }
  1074. // Reflection Map -> Surrender Specular Illumination Channel
  1075. if (i == ID_RL) {
  1076. SetCheckBox(HwndPanel, IDC_MAPON_SIT, TheMtl->IsMapEnabled(i));
  1077. SetDlgItemText(HwndPanel, IDC_SIT_BUTTON, nm.data());
  1078. }
  1079. }