/*=========================================================================== * * Arch3DObjDlg.CPP - Dave Humphrey (uesp@m0use.net), 1 November 2000 * *=========================================================================*/ /* Includes */ #include "stdafx.h" #include "Arch3DObjDlg.H" #include "Resource.h" CDFArchD3D* pArch3DObject = NULL; /* The main arch3d object */ int LastRecord = 0; #undef __FUNC__ #define __FUNC__ "Arch3DObjectDialogProc()" /*=========================================================================== * * Function - BOOL Arch3DObjectDialogProc (hWindow, Message, wParam, lParam); * *=========================================================================*/ BOOL FAR PASCAL Arch3DObjectDialogProc (HWND hWindow, UINT Message, WPARAM wParam, LPARAM lParam) { int Result; int wNotifyCode; int wID; switch (Message) { /* Initialize the object list */ case WM_INITDIALOG: Arch3DObjDlgInit(hWindow); return TRUE; case WM_COMMAND: wNotifyCode = HIWORD(wParam); wID = LOWORD(wParam); /* Return the currently selected item in the list and close dialog */ if (wID == IDOK || wNotifyCode == LBN_DBLCLK) { Result = SendDlgItemMessage(hWindow, IDC_OBJECT_LIST, LB_GETCURSEL, 0, 0); LastRecord = Result; if (Result >= 0) Result = SendDlgItemMessage(hWindow, IDC_OBJECT_LIST, LB_GETITEMDATA, (WPARAM) Result, 0); else Result = -1; EndDialog(hWindow, Result); return TRUE; } /* Close dialog returning an invalid index */ else if (wID == IDCANCEL) { EndDialog(hWindow, -1); return (TRUE); } else if (wID == ID_OBJECT_IDLOAD) { char Buffer[256]; long ObjectID; Result = SendDlgItemMessage(hWindow, IDC_OBJECT_IDTEXT, WM_GETTEXT, (WPARAM) 255, (LPARAM) &Buffer[0]); if (Result >= 0) { ObjectID = (long) strtoul(Buffer, NULL, 0); Result = pArch3DObject->FindRecordIndex(ObjectID); if (Result >= 0) { LastRecord = Result; EndDialog(hWindow, Result); } else MessageBox(hWindow, "Do not find the specified 3D object ID in Arch3D.BSA file!", "Arch3D Error", MB_OK | MB_APPLMODAL); } else Result = -1; return TRUE; } break; } return (FALSE); } /*=========================================================================== * End of Function Arch3DObjectDialogProc() *=========================================================================*/ #undef __FUNC__ #define __FUNC__ "Arch3DObjDlgInit()" /*=========================================================================== * * Function - void Arch3DObjDlgInit (HWND hWindow); * *=========================================================================*/ void Arch3DObjDlgInit (HWND hWindow) { dfbsa_dir_record_t* pDirRecord; int LoopCounter; int Result; char Buffer[128]; /* Ensure a valid data object has been set */ if (pArch3DObject == NULL) return; /* Delete the list box and text box contents */ SendDlgItemMessage(hWindow, IDC_OBJECT_LIST, LB_RESETCONTENT, 0, 0); SendDlgItemMessage(hWindow, IDC_OBJECT_IDTEXT, WM_SETTEXT, 0, (WPARAM) ""); /* Add all records to the list box */ for (LoopCounter = 0; LoopCounter < pArch3DObject->GetNumRecords(); LoopCounter++) { /* Get the record data */ pDirRecord = pArch3DObject->GetRecord(LoopCounter); if (pDirRecord == NULL) continue; /* Create and add list string */ sprintf (Buffer, "%d (0x%06lX), 0x%lX bytes at 0x%08lX", LoopCounter+1, pDirRecord->Value, pDirRecord->RecordSize, pDirRecord->RecordOffset); Result = SendDlgItemMessage(hWindow, IDC_OBJECT_LIST, LB_ADDSTRING, 0, (LPARAM) (LPCTSTR) Buffer); /* Set the record index if valid */ if (Result >= 0) SendDlgItemMessage(hWindow, IDC_OBJECT_LIST, LB_SETITEMDATA, (WPARAM) Result, (LPARAM) LoopCounter); } /* Set the selected item in the list */ SendDlgItemMessage(hWindow, IDC_OBJECT_LIST, LB_SETCURSEL, (WPARAM) LastRecord, 0); } /*=========================================================================== * End of Function Arch3DObjDlgInit() *=========================================================================*/ #undef __FUNC__ #define __FUNC__ "DisplayArch3DObjectDialog()" /*=========================================================================== * * Function - void DisplayArch3DObjectDialog (hWindow, hInstance, pArch3D); * *=========================================================================*/ int DisplayArch3DObjectDialog (HWND hWindow, HINSTANCE hInstance, CDFArchD3D* pArch3D) { int Result; /* Set the data objects */ pArch3DObject = pArch3D; /* Display the modal dialog box */ Result = DialogBoxParam (hInstance, "ARCH3D_OBJECT_DIALOG", hWindow, (DLGPROC) Arch3DObjectDialogProc, 0); return (Result); } /*=========================================================================== * End of Function DisplayArch3DObjectDialog() *=========================================================================*/