/* ======================================================================================================================= ======================================================================================================================= */ void ProjectDialog(void) { /* Obtain the system directory name and store it in szDirName. */ strcpy(szDirName, ValueForKey(g_qeglobals.d_project_entity, "basepath")); /* Place the terminating null character in the szFile. */ szFile[0] = '\0'; /* Set the members of the OPENFILENAME structure. */ ofn.lStructSize = sizeof(OPENFILENAME); ofn.hwndOwner = g_pParentWnd->GetSafeHwnd(); ofn.lpstrFilter = szProjectFilter; ofn.nFilterIndex = 1; ofn.lpstrFile = szFile; ofn.nMaxFile = sizeof(szFile); ofn.lpstrFileTitle = szFileTitle; ofn.nMaxFileTitle = sizeof(szFileTitle); ofn.lpstrInitialDir = szDirName; ofn.Flags = OFN_SHOWHELP | OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST; /* Display the Open dialog box. */ if (!GetOpenFileName(&ofn)) { return; // canceled } // Refresh the File menu. PlaceMenuMRUItem(g_qeglobals.d_lpMruMenu, GetSubMenu(GetMenu(g_pParentWnd->GetSafeHwnd()), 0), ID_FILE_EXIT); /* Open the file. */ if (!QE_LoadProject(ofn.lpstrFile)) { Error("Couldn't load project file"); } }
BOOL DoMru(HWND hWnd,WORD wId) { char szFileName[128]; OFSTRUCT of; BOOL fExist; GetMenuItem(g_qeglobals.d_lpMruMenu, wId, TRUE, szFileName, sizeof(szFileName)); // Test if the file exists. fExist = OpenFile(szFileName ,&of,OF_EXIST) != HFILE_ERROR; if (fExist) { // Place the file on the top of MRU. AddNewItem(g_qeglobals.d_lpMruMenu,(LPSTR)szFileName); // Now perform opening this file !!! Map_LoadFile (szFileName); } else // Remove the file on MRU. DelMenuItem(g_qeglobals.d_lpMruMenu,wId,TRUE); // Refresh the File menu. PlaceMenuMRUItem(g_qeglobals.d_lpMruMenu,GetSubMenu(GetMenu(hWnd),0), ID_FILE_EXIT); return fExist; }
void OpenDialog( void ) { /* * Obtain the system directory name and * store it in szDirName. */ strcpy( szDirName, ValueForKey( g_qeglobals.d_project_entity, "mapspath" ) ); if ( strlen( szDirName ) == 0 ) { strcpy( szDirName, ValueForKey( g_qeglobals.d_project_entity, "basepath" ) ); strcat( szDirName, "\\maps" ); } /* Place the terminating null character in the szFile. */ szFile[0] = '\0'; /* Set the members of the OPENFILENAME structure. */ ofn.lStructSize = sizeof( OPENFILENAME ); ofn.hwndOwner = g_qeglobals.d_hwndCamera; ofn.lpstrFilter = szFilter; ofn.nFilterIndex = 1; ofn.lpstrFile = szFile; ofn.nMaxFile = sizeof( szFile ); ofn.lpstrFileTitle = szFileTitle; ofn.nMaxFileTitle = sizeof( szFileTitle ); ofn.lpstrInitialDir = szDirName; ofn.Flags = OFN_SHOWHELP | OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST; /* Display the Open dialog box. */ if ( !GetOpenFileName( &ofn ) ) return; // canceled // Add the file in MRU. //FIXME AddNewItem( g_qeglobals.d_lpMruMenu, ofn.lpstrFile ); // Refresh the File menu. //FIXME PlaceMenuMRUItem( g_qeglobals.d_lpMruMenu, GetSubMenu( GetMenu( g_qeglobals.d_hwndMain ), 0 ), ID_FILE_EXIT ); /* Open the file. */ Map_LoadFile( ofn.lpstrFile ); }
/* ======================================================================================================================= ======================================================================================================================= */ void SaveAsDialog(bool bRegion) { strcpy(szDirName, ValueForKey(g_qeglobals.d_project_entity, "basepath")); CString strPath = szDirName; AddSlash(strPath); strPath += "maps"; if (g_PrefsDlg.m_strMaps.GetLength() > 0) { strPath += va("\\%s", g_PrefsDlg.m_strMaps); } /* Place the terminating null character in the szFile. */ szFile[0] = '\0'; /* Set the members of the OPENFILENAME structure. */ ofn.lStructSize = sizeof(OPENFILENAME); ofn.hwndOwner = g_pParentWnd->GetSafeHwnd(); ofn.lpstrFilter = szFilter; ofn.nFilterIndex = 1; ofn.lpstrFile = szFile; ofn.nMaxFile = sizeof(szFile); ofn.lpstrFileTitle = szFileTitle; ofn.nMaxFileTitle = sizeof(szFileTitle); ofn.lpstrInitialDir = strPath; ofn.Flags = OFN_SHOWHELP | OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST | OFN_OVERWRITEPROMPT; /* Display the Open dialog box. */ if (!GetSaveFileName(&ofn)) { return; // canceled } if (bRegion) { DefaultExtension(ofn.lpstrFile, ".reg"); } else { DefaultExtension(ofn.lpstrFile, ".map"); } if (!bRegion) { strcpy(currentmap, ofn.lpstrFile); AddNewItem(g_qeglobals.d_lpMruMenu, ofn.lpstrFile); PlaceMenuMRUItem(g_qeglobals.d_lpMruMenu, GetSubMenu(GetMenu(g_pParentWnd->GetSafeHwnd()), 0), ID_FILE_EXIT); } Map_SaveFile(ofn.lpstrFile, bRegion); // ignore region }
void SaveAsDialog (void) { strcpy (szDirName, ValueForKey (g_qeglobals.d_project_entity, "basepath") ); strcat (szDirName, "\\maps"); /* Place the terminating null character in the szFile. */ szFile[0] = '\0'; /* Set the members of the OPENFILENAME structure. */ ofn.lStructSize = sizeof(OPENFILENAME); ofn.hwndOwner = g_qeglobals.d_hwndCamera; ofn.lpstrFilter = szFilter; ofn.nFilterIndex = 1; ofn.lpstrFile = szFile; ofn.nMaxFile = sizeof(szFile); ofn.lpstrFileTitle = szFileTitle; ofn.nMaxFileTitle = sizeof(szFileTitle); ofn.lpstrInitialDir = szDirName; ofn.Flags = OFN_SHOWHELP | OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST | OFN_OVERWRITEPROMPT; /* Display the Open dialog box. */ if (!GetSaveFileName(&ofn)) return; // canceled DefaultExtension (ofn.lpstrFile, ".map"); strcpy (currentmap, ofn.lpstrFile); // Add the file in MRU. AddNewItem(g_qeglobals.d_lpMruMenu, ofn.lpstrFile); // Refresh the File menu. PlaceMenuMRUItem(g_qeglobals.d_lpMruMenu,GetSubMenu(GetMenu(g_qeglobals.d_hwndMain),0), ID_FILE_EXIT); Map_SaveFile (ofn.lpstrFile, false); // ignore region }
/* ============ WMAIN_WndProc ============ */ LONG WINAPI WMAIN_WndProc ( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { LONG lRet = 1; RECT rect; HDC maindc; GetClientRect(hWnd, &rect); switch (uMsg) { case WM_TIMER: QE_CountBrushesAndUpdateStatusBar(); QE_CheckAutoSave(); return 0; case WM_DESTROY: SaveMruInReg(g_qeglobals.d_lpMruMenu,"Software\\id\\QuakeEd4\\MRU"); DeleteMruMenu(g_qeglobals.d_lpMruMenu); PostQuitMessage(0); KillTimer( hWnd, QE_TIMER0 ); return 0; case WM_CREATE: maindc = GetDC(hWnd); // QEW_SetupPixelFormat(maindc, false); g_qeglobals.d_lpMruMenu = CreateMruMenuDefault(); LoadMruInReg(g_qeglobals.d_lpMruMenu,"Software\\id\\QuakeEd4\\MRU"); // Refresh the File menu. PlaceMenuMRUItem(g_qeglobals.d_lpMruMenu,GetSubMenu(GetMenu(hWnd),0), ID_FILE_EXIT); return 0; case WM_SIZE: // resize the status window MoveWindow( g_qeglobals.d_hwndStatus, -100, 100, 10, 10, true); return 0; case WM_KEYDOWN: return QE_KeyDown (wParam); case WM_CLOSE: /* call destroy window to cleanup and go away */ SaveWindowState(g_qeglobals.d_hwndXY, "xywindow"); SaveWindowState(g_qeglobals.d_hwndCamera, "camerawindow"); SaveWindowState(g_qeglobals.d_hwndZ, "zwindow"); SaveWindowState(g_qeglobals.d_hwndEntity, "EntityWindow"); SaveWindowState(g_qeglobals.d_hwndMain, "mainwindow"); // FIXME: is this right? SaveRegistryInfo("SavedInfo", &g_qeglobals.d_savedinfo, sizeof(g_qeglobals.d_savedinfo)); DestroyWindow (hWnd); return 0; case WM_COMMAND: return CommandHandler (hWnd, wParam, lParam); return 0; } return DefWindowProc (hWnd, uMsg, wParam, lParam); }