| 1083 | } |
| 1084 | |
| 1085 | bool FileDialog(CWnd *wnd, BOOL open, LPCTSTR filter, char *pathname, char *initialdir, int dirlen) { |
| 1086 | CFileDialog *dlg; |
| 1087 | char saved_path[_MAX_PATH]; |
| 1088 | char search_path[_MAX_PATH]; |
| 1089 | |
| 1090 | theApp.pause(); |
| 1091 | |
| 1092 | if (open) |
| 1093 | dlg = new CFileDialog(TRUE, 0, 0, OFN_FILEMUSTEXIST, filter, wnd); |
| 1094 | else |
| 1095 | dlg = new CFileDialog(FALSE, 0, 0, OFN_OVERWRITEPROMPT, filter, wnd); |
| 1096 | |
| 1097 | // save current directory and set new directory. |
| 1098 | if (initialdir) { |
| 1099 | ASSERT(dirlen > 0); |
| 1100 | ddio_GetWorkingDir(saved_path, _MAX_PATH); |
| 1101 | if (initialdir[0]) { |
| 1102 | lstrcpy(search_path, initialdir); |
| 1103 | dlg->m_ofn.lpstrInitialDir = search_path; |
| 1104 | } |
| 1105 | } |
| 1106 | |
| 1107 | if (dlg->DoModal() == IDCANCEL) { |
| 1108 | if (initialdir) |
| 1109 | ddio_SetWorkingDir(saved_path); |
| 1110 | theApp.resume(); |
| 1111 | delete dlg; |
| 1112 | return false; |
| 1113 | } |
| 1114 | |
| 1115 | // we have a filename now. |
| 1116 | lstrcpy(pathname, dlg->GetPathName()); |
| 1117 | |
| 1118 | // restore old current directory and save current directory into initialdir. |
| 1119 | if (initialdir) { |
| 1120 | ddio_GetWorkingDir(initialdir, dirlen); |
| 1121 | ddio_SetWorkingDir(saved_path); |
| 1122 | } |
| 1123 | |
| 1124 | theApp.resume(); |
| 1125 | |
| 1126 | delete dlg; |
| 1127 | return true; |
| 1128 | } |
| 1129 | |
| 1130 | int CALC_PIXELS_WITH_ASPECTX(int pixels) { |
| 1131 | float scr_aspect_x = ((float)GetSystemMetrics(SM_CXSCREEN)) / ((float)EDITOR_RESOLUTION_X); |
no test coverage detected