| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392 |
- /*
- ** Command & Conquer Generals(tm)
- ** Copyright 2025 Electronic Arts Inc.
- **
- ** This program is free software: you can redistribute it and/or modify
- ** it under the terms of the GNU General Public License as published by
- ** the Free Software Foundation, either version 3 of the License, or
- ** (at your option) any later version.
- **
- ** This program is distributed in the hope that it will be useful,
- ** but WITHOUT ANY WARRANTY; without even the implied warranty of
- ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- ** GNU General Public License for more details.
- **
- ** You should have received a copy of the GNU General Public License
- ** along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
- /***********************************************************************************************
- *** 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 ***
- ***********************************************************************************************
- * *
- * Project Name : Max2W3d *
- * *
- * $Archive:: /Commando/Code/Tools/max2w3d/GameMtlVertexMaterialDlg.cpp $*
- * *
- * Author:: Greg Hjelstrom *
- * *
- * $Modtime:: 7/10/00 3:37p $*
- * *
- * $Revision:: 12 $*
- * *
- *---------------------------------------------------------------------------------------------*
- * Functions: *
- * GameMtlVertexMaterialDlg::GameMtlVertexMaterialDlg -- constructor *
- * GameMtlVertexMaterialDlg::~GameMtlVertexMaterialDlg -- destructor *
- * GameMtlVertexMaterialDlg::Dialog_Proc -- windows message handler *
- * GameMtlVertexMaterialDlg::ReloadDialog -- reload the contents of the controls *
- * GameMtlVertexMaterialDlg::ActivateDlg -- activate / deactivate this dialog *
- * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
- #include "GameMtlVertexMaterialDlg.h"
- #include "GameMtl.h"
- #include "dllmain.h"
- #include "resource.h"
- /***********************************************************************************************
- * GameMtlVertexMaterialDlg::GameMtlVertexMaterialDlg -- constructor *
- * *
- * INPUT: *
- * *
- * OUTPUT: *
- * *
- * WARNINGS: *
- * *
- * HISTORY: *
- * 11/23/98 GTH : Created. *
- *=============================================================================================*/
- GameMtlVertexMaterialDlg::GameMtlVertexMaterialDlg
- (
- HWND parent,
- IMtlParams * imp,
- GameMtl * mtl,
- int pass
- ) :
- GameMtlFormClass(imp,mtl,pass)
- {
- AmbientSwatch = NULL;
- DiffuseSwatch = NULL;
- SpecularSwatch = NULL;
- EmissiveSwatch = NULL;
- OpacitySpin = NULL;
- TranslucencySpin = NULL;
- ShininessSpin = NULL;
- for (int i=0; i<MAX_STAGES; i++) {
- UVChannelSpin[i] = NULL;
- }
- Create_Form(parent,IDD_GAMEMTL_VERTEX_MATERIAL);
- }
- /***********************************************************************************************
- * GameMtlVertexMaterialDlg::~GameMtlVertexMaterialDlg -- destructor *
- * *
- * INPUT: *
- * *
- * OUTPUT: *
- * *
- * WARNINGS: *
- * *
- * HISTORY: *
- * 11/23/98 GTH : Created. *
- *=============================================================================================*/
- GameMtlVertexMaterialDlg::~GameMtlVertexMaterialDlg()
- {
- if (AmbientSwatch) {
- ReleaseIColorSwatch(AmbientSwatch);
- }
- if (DiffuseSwatch) {
- ReleaseIColorSwatch(DiffuseSwatch);
- }
- if (SpecularSwatch) {
- ReleaseIColorSwatch(SpecularSwatch);
- }
- if (EmissiveSwatch) {
- ReleaseIColorSwatch(EmissiveSwatch);
- }
- if (OpacitySpin) {
- ReleaseISpinner(OpacitySpin);
- }
- if (TranslucencySpin) {
- ReleaseISpinner(TranslucencySpin);
- }
- if (ShininessSpin) {
- ReleaseISpinner(ShininessSpin);
- }
- for (int i=0; i<MAX_STAGES; i++) {
- if (UVChannelSpin[i] != NULL) {
- ReleaseISpinner(UVChannelSpin[i]);
- }
- }
- }
- /***********************************************************************************************
- * GameMtlVertexMaterialDlg::Dialog_Proc -- windows message handler *
- * *
- * INPUT: *
- * *
- * OUTPUT: *
- * *
- * WARNINGS: *
- * *
- * HISTORY: *
- * 11/23/98 GTH : Created. *
- *=============================================================================================*/
- BOOL GameMtlVertexMaterialDlg::Dialog_Proc(HWND dlg_wnd, UINT message, WPARAM wparam, LPARAM lparam)
- {
- int val;
- int id = LOWORD(wparam);
- int code = HIWORD(wparam);
- switch (message)
- {
- case WM_INITDIALOG:
- {
- AmbientSwatch = GetIColorSwatch(GetDlgItem(dlg_wnd, IDC_AMBIENT_COLOR),TheMtl->Get_Ambient(PassIndex,IParams->GetTime()),Get_String(IDS_AMBIENT_COLOR));
- DiffuseSwatch = GetIColorSwatch(GetDlgItem(dlg_wnd, IDC_DIFFUSE_COLOR),TheMtl->Get_Diffuse(PassIndex,IParams->GetTime()),Get_String(IDS_DIFFUSE_COLOR));
- SpecularSwatch = GetIColorSwatch(GetDlgItem(dlg_wnd, IDC_SPECULAR_COLOR),TheMtl->Get_Specular(PassIndex,IParams->GetTime()),Get_String(IDS_SPECULAR_COLOR));
- EmissiveSwatch = GetIColorSwatch(GetDlgItem(dlg_wnd, IDC_EMISSIVE_COLOR),TheMtl->Get_Emissive(PassIndex,IParams->GetTime()),Get_String(IDS_EMISSIVE_COLOR));
- OpacitySpin = SetupFloatSpinner(dlg_wnd,IDC_OPACITY_SPIN,IDC_OPACITY_EDIT,0.0f,1.0f,TheMtl->Get_Opacity(PassIndex,IParams->GetTime()),0.01f);
- TranslucencySpin = SetupFloatSpinner(dlg_wnd,IDC_TRANSLUCENCY_SPIN,IDC_TRANSULCENCY_EDIT,0.0f,1.0f,TheMtl->Get_Translucency(PassIndex,IParams->GetTime()),0.01f);
- ShininessSpin = SetupFloatSpinner(dlg_wnd,IDC_SHININESS_SPIN,IDC_SHININESS_EDIT,1.0f,1000.0f,TheMtl->Get_Shininess(PassIndex,IParams->GetTime()),1.0f);
- UVChannelSpin[0] = SetupIntSpinner(dlg_wnd,IDC_STAGE0UVCHAN_SPIN,IDC_STAGE0UVCHAN_EDIT,1,99,1);
- UVChannelSpin[1] = SetupIntSpinner(dlg_wnd,IDC_STAGE1UVCHAN_SPIN,IDC_STAGE1UVCHAN_EDIT,1,99,1);
- break;
- }
-
- case WM_LBUTTONDOWN:
- case WM_LBUTTONUP:
- case WM_MOUSEMOVE:
- {
- IParams->RollupMouseMessage(dlg_wnd,message,wparam,lparam);
- return FALSE;
- }
- case WM_COMMAND:
- {
- switch (id)
- {
- case IDC_COPY_SPECULAR_DIFFUSE:
- TheMtl->Set_Copy_Specular_To_Diffuse(PassIndex,GetCheckBox(dlg_wnd, IDC_COPY_SPECULAR_DIFFUSE) == TRUE);
- break;
-
- case IDC_MAPPING0_COMBO:
- if (code == CBN_SELCHANGE) {
- val = SendDlgItemMessage(dlg_wnd,IDC_MAPPING0_COMBO,CB_GETCURSEL,0,0);
- TheMtl->Set_Mapping_Type(PassIndex,0,val);
- }
- break;
- case IDC_MAPPING1_COMBO:
- if (code == CBN_SELCHANGE) {
- val = SendDlgItemMessage(dlg_wnd,IDC_MAPPING1_COMBO,CB_GETCURSEL,0,0);
- TheMtl->Set_Mapping_Type(PassIndex,1,val);
- }
- break;
- case IDC_MAPPING0_ARGS_EDIT:
- switch (code) {
- case EN_SETFOCUS:
- DisableAccelerators();
- break;
- case EN_KILLFOCUS:
- EnableAccelerators();
- break;
- case EN_CHANGE:
- int len = GetWindowTextLength(GetDlgItem(dlg_wnd, IDC_MAPPING0_ARGS_EDIT));
- char *buffer = TheMtl->Get_Mapping_Arg_Buffer(PassIndex, 0, len);
- GetWindowText(GetDlgItem(dlg_wnd, IDC_MAPPING0_ARGS_EDIT), buffer, len + 1);
- break;
- }
- break;
- case IDC_MAPPING1_ARGS_EDIT:
- switch (code) {
- case EN_SETFOCUS:
- DisableAccelerators();
- break;
- case EN_KILLFOCUS:
- EnableAccelerators();
- break;
- case EN_CHANGE:
- int len = GetWindowTextLength(GetDlgItem(dlg_wnd, IDC_MAPPING1_ARGS_EDIT));
- char *buffer = TheMtl->Get_Mapping_Arg_Buffer(PassIndex, 1, len);
- GetWindowText(GetDlgItem(dlg_wnd, IDC_MAPPING1_ARGS_EDIT), buffer, len + 1);
- break;
- }
- break;
- case IDC_NO_TRANS:
- TheMtl->Set_PSX_Translucency(PassIndex,GAMEMTL_PSX_TRANS_NONE);
- break;
- case IDC_100_TRANS:
- TheMtl->Set_PSX_Translucency(PassIndex,GAMEMTL_PSX_TRANS_100);
- break;
-
- case IDC_50_TRANS:
- TheMtl->Set_PSX_Translucency(PassIndex,GAMEMTL_PSX_TRANS_50);
- break;
-
- case IDC_25_TRANS:
- TheMtl->Set_PSX_Translucency(PassIndex,GAMEMTL_PSX_TRANS_25);
- break;
- case IDC_MINUS_100_TRANS:
- TheMtl->Set_PSX_Translucency(PassIndex,GAMEMTL_PSX_TRANS_MINUS_100);
- break;
-
- case IDC_NO_RT_LIGHTING:
- TheMtl->Set_PSX_Lighting(PassIndex,!GetCheckBox(dlg_wnd, IDC_NO_RT_LIGHTING));
- break;
- }
- break;
- }
- case CC_COLOR_CHANGE:
- {
- // just update all of the colors
- TheMtl->Set_Ambient(PassIndex,IParams->GetTime(),AmbientSwatch->GetColor());
- TheMtl->Set_Diffuse(PassIndex,IParams->GetTime(),DiffuseSwatch->GetColor());
- TheMtl->Set_Specular(PassIndex,IParams->GetTime(),SpecularSwatch->GetColor());
- TheMtl->Set_Emissive(PassIndex,IParams->GetTime(),EmissiveSwatch->GetColor());
- TheMtl->Notify_Changed();
- break;
- }
- case CC_SPINNER_CHANGE:
- {
- TheMtl->Set_Shininess(PassIndex,IParams->GetTime(),ShininessSpin->GetFVal());
- TheMtl->Set_Opacity(PassIndex,IParams->GetTime(),OpacitySpin->GetFVal());
- TheMtl->Set_Translucency(PassIndex,IParams->GetTime(),TranslucencySpin->GetFVal());
- for (int i=0; i<MAX_STAGES; i++) {
- TheMtl->Set_Map_Channel(PassIndex,i,UVChannelSpin[i]->GetIVal());
- }
- break;
- }
- case CC_SPINNER_BUTTONUP:
- {
- TheMtl->Notify_Changed();
- break;
- }
-
- }
- return FALSE;
- }
- /***********************************************************************************************
- * GameMtlVertexMaterialDlg::ReloadDialog -- reload the contents of the controls *
- * *
- * INPUT: *
- * *
- * OUTPUT: *
- * *
- * WARNINGS: *
- * *
- * HISTORY: *
- * 11/23/98 GTH : Created. *
- *=============================================================================================*/
- void GameMtlVertexMaterialDlg::ReloadDialog(void)
- {
- // Vertex Material Controls
- DebugPrint("GameMtlVertexMaterialDlg::ReloadDialog\n");
- assert(AmbientSwatch && DiffuseSwatch && SpecularSwatch && EmissiveSwatch);
- assert(ShininessSpin && OpacitySpin && TranslucencySpin);
- AmbientSwatch->InitColor(TheMtl->Get_Ambient(PassIndex,IParams->GetTime()));
- DiffuseSwatch->InitColor(TheMtl->Get_Diffuse(PassIndex,IParams->GetTime()));
- SpecularSwatch->InitColor(TheMtl->Get_Specular(PassIndex,IParams->GetTime()));
- EmissiveSwatch->InitColor(TheMtl->Get_Emissive(PassIndex,IParams->GetTime()));
-
- ShininessSpin->SetValue(TheMtl->Get_Shininess(PassIndex,IParams->GetTime()),FALSE);
- OpacitySpin->SetValue(TheMtl->Get_Opacity(PassIndex,IParams->GetTime()),FALSE);
- TranslucencySpin->SetValue(TheMtl->Get_Translucency(PassIndex,IParams->GetTime()),FALSE);
- for (int i=0; i<MAX_STAGES; i++) {
- UVChannelSpin[i]->SetValue(TheMtl->Get_Map_Channel(PassIndex,i),FALSE);
- }
- SetCheckBox(m_hWnd,IDC_COPY_SPECULAR_DIFFUSE, TheMtl->Get_Copy_Specular_To_Diffuse(PassIndex));
- SendDlgItemMessage( m_hWnd,
- IDC_MAPPING0_COMBO,
- CB_SETCURSEL,
- TheMtl->Get_Mapping_Type(PassIndex, 0),
- 0 );
- SendDlgItemMessage( m_hWnd,
- IDC_MAPPING1_COMBO,
- CB_SETCURSEL,
- TheMtl->Get_Mapping_Type(PassIndex, 1),
- 0 );
- // PSX Controls
- SetCheckBox(m_hWnd,IDC_NO_RT_LIGHTING, !TheMtl->Get_PSX_Lighting(PassIndex));
- SetCheckBox(m_hWnd,IDC_NO_TRANS, false);
- SetCheckBox(m_hWnd,IDC_100_TRANS, false);
- SetCheckBox(m_hWnd,IDC_50_TRANS, false);
- SetCheckBox(m_hWnd,IDC_25_TRANS, false);
- SetCheckBox(m_hWnd,IDC_MINUS_100_TRANS, false);
- switch (TheMtl->Get_PSX_Translucency(PassIndex)) {
- case 0:
- SetCheckBox(m_hWnd,IDC_NO_TRANS,true);
- break;
- case GAMEMTL_PSX_TRANS_100:
- SetCheckBox(m_hWnd,IDC_100_TRANS,true);
- break;
- case GAMEMTL_PSX_TRANS_50:
- SetCheckBox(m_hWnd,IDC_50_TRANS,true);
- break;
- case GAMEMTL_PSX_TRANS_25:
- SetCheckBox(m_hWnd,IDC_25_TRANS,true);
- break;
- case GAMEMTL_PSX_TRANS_MINUS_100:
- SetCheckBox(m_hWnd,IDC_MINUS_100_TRANS,true);
- break;
- }
- // Reload contents of mapper args edit box:
- char *buffer = TheMtl->Get_Mapping_Arg_Buffer(PassIndex, 0);
- SetWindowText(GetDlgItem(m_hWnd, IDC_MAPPING0_ARGS_EDIT), buffer);
- buffer = TheMtl->Get_Mapping_Arg_Buffer(PassIndex, 1);
- SetWindowText(GetDlgItem(m_hWnd, IDC_MAPPING1_ARGS_EDIT), buffer);
- }
- /***********************************************************************************************
- * GameMtlVertexMaterialDlg::ActivateDlg -- activate / deactivate this dialog *
- * *
- * INPUT: *
- * *
- * OUTPUT: *
- * *
- * WARNINGS: *
- * *
- * HISTORY: *
- * 11/23/98 GTH : Created. *
- *=============================================================================================*/
- void GameMtlVertexMaterialDlg::ActivateDlg(BOOL onoff)
- {
- if (AmbientSwatch) {
- AmbientSwatch->Activate(onoff);
- }
- if (DiffuseSwatch) {
- DiffuseSwatch->Activate(onoff);
- }
- if (SpecularSwatch) {
- SpecularSwatch->Activate(onoff);
- }
- if (EmissiveSwatch) {
- EmissiveSwatch->Activate(onoff);
- }
- }
|