MCPcopy Create free account
hub / github.com/DescentDevelopers/Descent3 / DoPathFileDialog

Function DoPathFileDialog

Descent3/newui_filedlg.cpp:224–473  ·  view source on GitHub ↗

Displays a file/directory dialog box path - Initial path, will contain the chosen file/path on exit with true, must be at least _MAX_PATH in size title - Title of the dialog wildc - semicolon (;) seperated list of wildcards to be shown flags - see header PFDF_ for flags

Source from the content-addressed store, hash-verified

222// in size title - Title of the dialog wildc - semicolon (;) seperated list of wildcards to
223// be shown flags - see header PFDF_ for flags
224bool DoPathFileDialog(bool save_dialog, char *path, const char *title, const char *wildc, int flags) {
225#define HS_CANCEL 0
226#define HS_OK 1
227#define HS_UPDIR 0
228#define ED_WILDCARD 0
229#define ED_FILENAME 1
230#define ID_LISTBOX 25
231#define ID_UPDIR 26
232#define ID_WILDCARD 27
233#define ID_FILENAME 28
234#define ID_CANCEL UID_CANCEL
235#define ID_OK UID_OK
236 newuiTiledWindow window;
237 newuiSheet *sheet;
238 newuiListBox *listbox;
239 char *edits[2];
240
241 char wildcards[256];
242 char working_path[_MAX_PATH];
243 char working_file[_MAX_FNAME];
244
245 if (!path)
246 return false;
247 if (!title)
248 return false;
249 if (!wildc)
250 return false;
251
252 strcpy(wildcards, wildc);
253 strcpy(working_file, "");
254
255 // figure out the correct path
256 char oldpath[_MAX_PATH];
257 ddio_GetWorkingDir(oldpath, _MAX_PATH);
258 if (!ddio_SetWorkingDir(path)) {
259 // try to use last good path
260 if (!ddio_SetWorkingDir(NewuiFileDlg_lastpath)) {
261 strcpy(path, LocalD3Dir);
262 } else {
263 strcpy(path, NewuiFileDlg_lastpath);
264 }
265 }
266 ddio_SetWorkingDir(oldpath);
267
268 // Create all the UI Items
269 window.Create(title, 0, 0, 384, 288);
270 fdlg_working_sheet = sheet = window.GetSheet();
271
272 sheet->NewGroup(NULL, 10, 0);
273 listbox = sheet->AddListBox(268, 100, ID_LISTBOX);
274
275 sheet->NewGroup(NULL, 0, 145);
276 edits[ED_FILENAME] = sheet->AddEditBox(NULL, _MAX_PATH, 300, ID_FILENAME);
277 edits[ED_WILDCARD] = sheet->AddEditBox(NULL, 256, 150, ID_WILDCARD);
278 sheet->AddLongButton(TXT_UPTOPARENTDIR, ID_UPDIR);
279
280 sheet->NewGroup(NULL, 200, 160);
281 sheet->AddButton((save_dialog) ? TXT_SAVE : TXT_OPEN, ID_OK);

Callers 5

PltSelectShipFunction · 0.85
MultiDoConfigSaveFunction · 0.85
MultiDoConfigLoadFunction · 0.85
LoadDemoDialogFunction · 0.85
MenuLoadLevelFunction · 0.85

Calls 15

UpdateFileListFunction · 0.85
DoMessageBoxFunction · 0.85
cfexistFunction · 0.85
IsDirectoryItemFunction · 0.85
FileSelectCallbackFunction · 0.85
GetSheetMethod · 0.80
NewGroupMethod · 0.80
AddListBoxMethod · 0.80
AddEditBoxMethod · 0.80
AddLongButtonMethod · 0.80
AddButtonMethod · 0.80

Tested by

no test coverage detected