| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393 |
- /*
- ** Command & Conquer Generals Zero Hour(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:: /Bay/Tools/max2w3d/GameMtlPassDlg.cpp $*
- * *
- * Author:: Greg Hjelstrom *
- * *
- * $Modtime:: 10/22/99 9:54a $*
- * *
- * $Revision:: 9 $*
- * *
- *---------------------------------------------------------------------------------------------*
- * Functions: *
- * PassDlgProc -- dialog proc which thunks into a GameMtlPassDlg *
- * GameMtlPassDlg::GameMtlPassDlg -- constructor *
- * GameMtlPassDlg::~GameMtlPassDlg -- destructor *
- * GameMtlPassDlg::DialogProc -- windows message handler *
- * GameMtlPassDlg::Invalidate -- invalidate the dialog *
- * GameMtlPassDlg::ReloadDialog -- update the contents of all of the controls *
- * GameMtlPassDlg::ClassID -- returns classID of the object being edited *
- * GameMtlPassDlg::SetThing -- set the material being edited *
- * GameMtlPassDlg::ActivateDlg -- activate or deactivate the dialog *
- * GameMtlPassDlg::SetTime -- set the current time *
- * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
- #include "GameMtlPassDlg.h"
- #include "dllmain.h"
- #include "resource.h"
- #include "GameMtl.h"
- #include "GameMtlDlg.h"
- #include "GameMtlShaderDlg.h"
- #include "PS2GameMtlShaderDlg.h"
- #include "GameMtlTextureDlg.h"
- #include "GameMtlVertexMaterialDlg.h"
- #include "w3d_file.h"
- static int _Pass_Index_To_Flag[] =
- {
- GAMEMTL_PASS0_ROLLUP_OPEN,
- GAMEMTL_PASS1_ROLLUP_OPEN,
- GAMEMTL_PASS2_ROLLUP_OPEN,
- GAMEMTL_PASS3_ROLLUP_OPEN,
- };
- /***********************************************************************************************
- * PassDlgProc -- dialog proc which thunks into a GameMtlPassDlg *
- * *
- * INPUT: *
- * *
- * OUTPUT: *
- * *
- * WARNINGS: *
- * *
- * HISTORY: *
- * 11/23/98 GTH : Created. *
- *=============================================================================================*/
- static BOOL CALLBACK PassDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
- {
- GameMtlPassDlg *theDlg;
- if (msg==WM_INITDIALOG) {
- theDlg = (GameMtlPassDlg*)lParam;
- theDlg->HwndPanel = hwndDlg;
- SetWindowLong(hwndDlg, GWL_USERDATA,lParam);
- } else {
- if ((theDlg = (GameMtlPassDlg *)GetWindowLong(hwndDlg, GWL_USERDATA) ) == NULL) {
- return FALSE;
- }
- }
- return theDlg->DialogProc(hwndDlg,msg,wParam,lParam);
- }
- /***********************************************************************************************
- * GameMtlPassDlg::GameMtlPassDlg -- constructor *
- * *
- * INPUT: *
- * *
- * OUTPUT: *
- * *
- * WARNINGS: *
- * *
- * HISTORY: *
- * 11/23/98 GTH : Created. *
- *=============================================================================================*/
- GameMtlPassDlg::GameMtlPassDlg(HWND hwMtlEdit, IMtlParams *imp, GameMtl *m,int pass)
- {
- HwndEdit = hwMtlEdit;
- TheMtl = m;
- IParams = imp;
- PassIndex = pass;
- char title[200];
- sprintf(title, "Pass %d", pass + 1);
- HwndPanel = IParams->AddRollupPage(
- AppInstance,
- MAKEINTRESOURCE(IDD_GAMEMTL_PASS),
- PassDlgProc,
- title,
- (LPARAM)this,
- TheMtl->Get_Flag(_Pass_Index_To_Flag[PassIndex]) ? 0 : APPENDROLL_CLOSED
- );
- }
- /***********************************************************************************************
- * GameMtlPassDlg::~GameMtlPassDlg -- destructor *
- * *
- * INPUT: *
- * *
- * OUTPUT: *
- * *
- * WARNINGS: *
- * *
- * HISTORY: *
- * 11/23/98 GTH : Created. *
- *=============================================================================================*/
- GameMtlPassDlg::~GameMtlPassDlg()
- {
- TheMtl->Set_Flag(_Pass_Index_To_Flag[PassIndex],IParams->IsRollupPanelOpen(HwndPanel));
- IParams->DeleteRollupPage(HwndPanel);
- SetWindowLong(HwndPanel, GWL_USERDATA, NULL);
- }
- /***********************************************************************************************
- * GameMtlPassDlg::DialogProc -- windows message handler *
- * *
- * INPUT: *
- * *
- * OUTPUT: *
- * *
- * WARNINGS: *
- * *
- * HISTORY: *
- * 11/23/98 GTH : Created. *
- *=============================================================================================*/
- BOOL GameMtlPassDlg::DialogProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
- {
- int i=0;
- int id = LOWORD(wParam);
- int code = HIWORD(wParam);
- switch (message) {
- case WM_INITDIALOG:
- {
- Page[0] = new GameMtlVertexMaterialDlg(HwndPanel,IParams,TheMtl,PassIndex);
- if (TheMtl->Get_Shader_Type() == GameMtl::STE_PC_SHADER) {
- Page[1] = new GameMtlShaderDlg(HwndPanel,IParams,TheMtl,PassIndex);
- } else {
- // The PS2 shader is different.
- Page[1] = new PS2GameMtlShaderDlg(HwndPanel,IParams,TheMtl,PassIndex);
- }
- Page[2] = new GameMtlTextureDlg(HwndPanel,IParams,TheMtl,PassIndex);
- for (i=0; i<PAGE_COUNT; i++) {
- HWND hwnd = Page[i]->Get_Hwnd();
-
- // set the tab names
- char name[64];
- ::GetWindowText(hwnd,name,sizeof(name));
- TC_ITEM tcitem = { TCIF_TEXT,0,0,name,0 };
- TabCtrl_InsertItem(GetDlgItem(HwndPanel,IDC_GAMEMTL_TAB),i,&tcitem);
- }
- // Get the display rectangle of the tab control
- RECT rect;
- ::GetWindowRect(GetDlgItem(HwndPanel,IDC_GAMEMTL_TAB),&rect);
- TabCtrl_AdjustRect(GetDlgItem(HwndPanel,IDC_GAMEMTL_TAB),FALSE, &rect);
-
- // Convert the display rectangle from screen to client coords
- ScreenToClient(HwndPanel,(POINT *)(&rect));
- ScreenToClient(HwndPanel, ((LPPOINT)&rect) + 1);
- for (i=0; i<PAGE_COUNT; i++) {
- HWND hwnd = Page[i]->Get_Hwnd();
- // Loop through all the tabs in the property sheet
- // Get a pointer to this tab
- SetWindowPos( hwnd,
- NULL,
- rect.left, rect.top,
- rect.right - rect.left, rect.bottom - rect.top,
- SWP_NOZORDER);
- }
-
- CurPage = 0;
- TabCtrl_SetCurSel(GetDlgItem(HwndPanel,IDC_GAMEMTL_TAB),CurPage);
- Page[CurPage]->Show();
- break;
- }
-
- case WM_PAINT:
- {
- if (!Valid) {
- Valid = TRUE;
- ReloadDialog();
- }
- return FALSE;
- }
-
- case WM_NOTIFY:
- {
- NMHDR * header = (NMHDR *)lParam;
-
- switch(header->code) {
- case TCN_SELCHANGE:
- {
- int sel = TabCtrl_GetCurSel(GetDlgItem(HwndPanel,IDC_GAMEMTL_TAB));
- Page[sel]->Show();
- for (int i=0; i < PAGE_COUNT; i++) {
- if (i != sel) Page[i]->Show(false);
- }
- CurPage = sel;
- TheMtl->Set_Current_Page(PassIndex,CurPage);
- }
- };
- break;
- }
- }
- return FALSE;
- }
- /***********************************************************************************************
- * GameMtlPassDlg::Invalidate -- invalidate the dialog *
- * *
- * INPUT: *
- * *
- * OUTPUT: *
- * *
- * WARNINGS: *
- * *
- * HISTORY: *
- * 11/23/98 GTH : Created. *
- *=============================================================================================*/
- void GameMtlPassDlg::Invalidate()
- {
- Valid = FALSE;
- InvalidateRect(HwndPanel,NULL,0);
- }
- /***********************************************************************************************
- * GameMtlPassDlg::ReloadDialog -- update the contents of all of the controls *
- * *
- * INPUT: *
- * *
- * OUTPUT: *
- * *
- * WARNINGS: *
- * *
- * HISTORY: *
- * 11/23/98 GTH : Created. *
- *=============================================================================================*/
- void GameMtlPassDlg::ReloadDialog()
- {
- int i;
- DebugPrint("GameMtlPassDlg::ReloadDialog\n");
- Interval v;
- TheMtl->Update(IParams->GetTime(),v);
-
- for (i=0; i<PAGE_COUNT; i++) {
- Page[i]->ReloadDialog();
- }
- CurPage = TheMtl->Get_Current_Page(PassIndex);
- TabCtrl_SetCurSel(GetDlgItem(HwndPanel,IDC_GAMEMTL_TAB),CurPage);
- Page[CurPage]->Show();
- for (i=0; i < PAGE_COUNT; i++) {
- if (i != CurPage) Page[i]->Show(false);
- }
- }
- /***********************************************************************************************
- * GameMtlPassDlg::ClassID -- returns classID of the object being edited *
- * *
- * INPUT: *
- * *
- * OUTPUT: *
- * *
- * WARNINGS: *
- * *
- * HISTORY: *
- * 11/23/98 GTH : Created. *
- *=============================================================================================*/
- Class_ID GameMtlPassDlg::ClassID()
- {
- return GameMaterialClassID;
- }
- /***********************************************************************************************
- * GameMtlPassDlg::SetThing -- set the material being edited *
- * *
- * INPUT: *
- * *
- * OUTPUT: *
- * *
- * WARNINGS: *
- * *
- * HISTORY: *
- * 11/23/98 GTH : Created. *
- *=============================================================================================*/
- void GameMtlPassDlg::SetThing(ReferenceTarget* target)
- {
- // Note, parent will "reload" when our "thing" changes :-)
- assert (target->SuperClassID()==MATERIAL_CLASS_ID);
- assert (target->ClassID()==GameMaterialClassID);
- TheMtl = (GameMtl *)target;
-
- for (int i=0; i<PAGE_COUNT; i++) {
- Page[i]->SetThing(target);
- }
- }
- /***********************************************************************************************
- * GameMtlPassDlg::ActivateDlg -- activate or deactivate the dialog *
- * *
- * some of the custom max controls need to be activated and deactivated *
- * *
- * INPUT: *
- * *
- * OUTPUT: *
- * *
- * WARNINGS: *
- * *
- * HISTORY: *
- * 11/23/98 GTH : Created. *
- *=============================================================================================*/
- void GameMtlPassDlg::ActivateDlg(BOOL onoff)
- {
- for (int i=0; i<PAGE_COUNT; i++) {
- Page[i]->ActivateDlg(onoff);
- }
- }
- /***********************************************************************************************
- * GameMtlPassDlg::SetTime -- set the current time *
- * *
- * INPUT: *
- * *
- * OUTPUT: *
- * *
- * WARNINGS: *
- * *
- * HISTORY: *
- * 11/23/98 GTH : Created. *
- *=============================================================================================*/
- void GameMtlPassDlg::SetTime(TimeValue t)
- {
- // parent dialog class keeps track of the validty and we
- // don't have to do anything in this function (it will never
- // be called in fact)
- }
|