Give ui_get_filename a callback for its dialog. Happy new year
This commit is contained in:
parent
16b5d1b101
commit
ead5b43319
|
@ -1,5 +1,9 @@
|
||||||
D2X-Rebirth Changelog
|
D2X-Rebirth Changelog
|
||||||
|
|
||||||
|
20120102
|
||||||
|
--------
|
||||||
|
ui/dialog.c, ui/file.c: Give ui_get_filename a callback for its dialog. Happy new year!
|
||||||
|
|
||||||
20111231
|
20111231
|
||||||
--------
|
--------
|
||||||
editor/med.c, include/ui.h, ui/menu.c, ui/menubar.c, ui/popup.c: Make editor menubar and associated menus into windows; either remove or make event-based all the B1_* macros
|
editor/med.c, include/ui.h, ui/menu.c, ui/menubar.c, ui/popup.c: Make editor menubar and associated menus into windows; either remove or make event-based all the B1_* macros
|
||||||
|
|
21
ui/dialog.c
21
ui/dialog.c
|
@ -145,6 +145,8 @@ int ui_dialog_draw(UI_DIALOG *dlg)
|
||||||
// The dialog handler borrows heavily from the newmenu_handler
|
// The dialog handler borrows heavily from the newmenu_handler
|
||||||
int ui_dialog_handler(window *wind, d_event *event, UI_DIALOG *dlg)
|
int ui_dialog_handler(window *wind, d_event *event, UI_DIALOG *dlg)
|
||||||
{
|
{
|
||||||
|
int rval = 0;
|
||||||
|
|
||||||
if (event->type == EVENT_WINDOW_CLOSED)
|
if (event->type == EVENT_WINDOW_CLOSED)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
@ -152,33 +154,38 @@ int ui_dialog_handler(window *wind, d_event *event, UI_DIALOG *dlg)
|
||||||
if (wind == window_get_front())
|
if (wind == window_get_front())
|
||||||
ui_event_handler(event);
|
ui_event_handler(event);
|
||||||
|
|
||||||
|
#if 0 // must only call this once, after the gadget actions are determined
|
||||||
|
// until all the gadgets send events instead
|
||||||
if (dlg->callback)
|
if (dlg->callback)
|
||||||
if ((*dlg->callback)(dlg, event, dlg->userdata))
|
if ((*dlg->callback)(dlg, event, dlg->userdata))
|
||||||
return 1; // event handled
|
return 1; // event handled
|
||||||
|
#endif
|
||||||
|
|
||||||
switch (event->type)
|
switch (event->type)
|
||||||
{
|
{
|
||||||
case EVENT_WINDOW_ACTIVATED:
|
case EVENT_WINDOW_ACTIVATED:
|
||||||
|
return 0;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EVENT_WINDOW_DEACTIVATED:
|
case EVENT_WINDOW_DEACTIVATED:
|
||||||
|
return 0;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EVENT_MOUSE_BUTTON_DOWN:
|
case EVENT_MOUSE_BUTTON_DOWN:
|
||||||
case EVENT_MOUSE_BUTTON_UP:
|
case EVENT_MOUSE_BUTTON_UP:
|
||||||
case EVENT_MOUSE_MOVED:
|
case EVENT_MOUSE_MOVED:
|
||||||
/*return*/ ui_dialog_do_gadgets(dlg, event);
|
/*return*/ ui_dialog_do_gadgets(dlg, event);
|
||||||
return mouse_in_window(dlg->wind);
|
rval = mouse_in_window(dlg->wind);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EVENT_KEY_COMMAND:
|
case EVENT_KEY_COMMAND:
|
||||||
case EVENT_KEY_RELEASE:
|
case EVENT_KEY_RELEASE:
|
||||||
return ui_dialog_do_gadgets(dlg, event);
|
rval = ui_dialog_do_gadgets(dlg, event);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EVENT_IDLE:
|
case EVENT_IDLE:
|
||||||
timer_delay2(50);
|
timer_delay2(50);
|
||||||
return ui_dialog_do_gadgets(dlg, event);
|
rval = ui_dialog_do_gadgets(dlg, event);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EVENT_WINDOW_DRAW:
|
case EVENT_WINDOW_DRAW:
|
||||||
|
@ -187,13 +194,19 @@ int ui_dialog_handler(window *wind, d_event *event, UI_DIALOG *dlg)
|
||||||
|
|
||||||
case EVENT_WINDOW_CLOSE:
|
case EVENT_WINDOW_CLOSE:
|
||||||
//ui_close_dialog(dlg); // need to hide this function and make it not call window_close first
|
//ui_close_dialog(dlg); // need to hide this function and make it not call window_close first
|
||||||
|
return 0;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
return 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
if (dlg->callback)
|
||||||
|
if ((*dlg->callback)(dlg, event, dlg->userdata))
|
||||||
|
return 1; // event handled
|
||||||
|
|
||||||
|
return rval;
|
||||||
}
|
}
|
||||||
|
|
||||||
UI_DIALOG * ui_create_dialog( short x, short y, short w, short h, enum dialog_flags flags, int (*callback)(UI_DIALOG *, d_event *, void *), void *userdata )
|
UI_DIALOG * ui_create_dialog( short x, short y, short w, short h, enum dialog_flags flags, int (*callback)(UI_DIALOG *, d_event *, void *), void *userdata )
|
||||||
|
|
374
ui/file.c
374
ui/file.c
|
@ -22,6 +22,7 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
|
||||||
#include "key.h"
|
#include "key.h"
|
||||||
#include "strutil.h"
|
#include "strutil.h"
|
||||||
#include "ui.h"
|
#include "ui.h"
|
||||||
|
#include "window.h"
|
||||||
#include "u_mem.h"
|
#include "u_mem.h"
|
||||||
|
|
||||||
int file_sort_func(char **e0, char **e1)
|
int file_sort_func(char **e0, char **e1)
|
||||||
|
@ -106,219 +107,254 @@ char **file_getfilelist(int *NumFiles, char *filespec, char *dir)
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ui_get_filename( char * filename, char * Filespec, char * message )
|
typedef struct browser
|
||||||
{
|
{
|
||||||
char ViewDir[PATH_MAX];
|
char view_dir[PATH_MAX];
|
||||||
char InputText[PATH_MAX];
|
char *filename;
|
||||||
char *p;
|
char *filespec;
|
||||||
PHYSFS_file *TempFile;
|
char *message;
|
||||||
int NumFiles, NumDirs,i;
|
|
||||||
char **filename_list;
|
char **filename_list;
|
||||||
char **directory_list;
|
char **directory_list;
|
||||||
char Spaces[35];
|
UI_GADGET_BUTTON *button1, *button2, *help_button;
|
||||||
UI_DIALOG *dlg;
|
UI_GADGET_LISTBOX *listbox1;
|
||||||
UI_GADGET_BUTTON *Button1, *Button2, *HelpButton;
|
UI_GADGET_LISTBOX *listbox2;
|
||||||
UI_GADGET_LISTBOX *ListBox1;
|
UI_GADGET_INPUTBOX *user_file;
|
||||||
UI_GADGET_LISTBOX *ListBox2;
|
int num_files, num_dirs;
|
||||||
UI_GADGET_INPUTBOX *UserFile;
|
int new_listboxes;
|
||||||
int new_listboxes;
|
char spaces[35];
|
||||||
|
} browser;
|
||||||
|
|
||||||
|
static int browser_handler(UI_DIALOG *dlg, d_event *event, browser *b)
|
||||||
|
{
|
||||||
|
int rval = 0;
|
||||||
|
|
||||||
|
if ( b->button2->pressed )
|
||||||
|
{
|
||||||
|
PHYSFS_freeList(b->filename_list); b->filename_list = NULL;
|
||||||
|
PHYSFS_freeList(b->directory_list); b->directory_list = NULL;
|
||||||
|
ui_close_dialog(dlg);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( b->help_button->pressed )
|
||||||
|
{
|
||||||
|
MessageBox( -1, -1, 1, "Sorry, no help is available!", "Ok" );
|
||||||
|
rval = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (b->listbox1->moved || b->new_listboxes)
|
||||||
|
{
|
||||||
|
if (b->listbox1->current_item >= 0 )
|
||||||
|
ui_inputbox_set_text(b->user_file, b->filename_list[b->listbox1->current_item]);
|
||||||
|
rval = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (b->listbox2->moved || b->new_listboxes)
|
||||||
|
{
|
||||||
|
if (b->listbox2->current_item >= 0 )
|
||||||
|
ui_inputbox_set_text(b->user_file, b->directory_list[b->listbox2->current_item]);
|
||||||
|
rval = 1;
|
||||||
|
}
|
||||||
|
b->new_listboxes = 0;
|
||||||
|
|
||||||
|
if (b->button1->pressed || b->user_file->pressed || (b->listbox1->selected_item > -1 ) || (b->listbox2->selected_item > -1 ))
|
||||||
|
{
|
||||||
|
char *p;
|
||||||
|
|
||||||
|
ui_mouse_hide();
|
||||||
|
|
||||||
|
if (b->listbox2->selected_item > -1 )
|
||||||
|
strcpy(b->user_file->text, b->directory_list[b->listbox2->selected_item]);
|
||||||
|
|
||||||
|
strncpy(b->filename, b->view_dir, PATH_MAX);
|
||||||
|
|
||||||
|
p = b->user_file->text;
|
||||||
|
while (!strncmp(p, "..", 2)) // shorten the path manually
|
||||||
|
{
|
||||||
|
char *sep = strrchr(b->filename, '/');
|
||||||
|
if (sep)
|
||||||
|
*sep = 0;
|
||||||
|
else
|
||||||
|
*b->filename = 0; // look directly in search paths
|
||||||
|
|
||||||
|
p += 2;
|
||||||
|
if (*p == '/')
|
||||||
|
p++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (*b->filename && *p)
|
||||||
|
strncat(b->filename, "/", PATH_MAX - strlen(b->filename));
|
||||||
|
strncat(b->filename, p, PATH_MAX - strlen(b->filename));
|
||||||
|
|
||||||
|
if (!PHYSFS_isDirectory(b->filename))
|
||||||
|
{
|
||||||
|
PHYSFS_file *TempFile;
|
||||||
|
|
||||||
|
TempFile = PHYSFS_openRead(b->filename);
|
||||||
|
if (TempFile)
|
||||||
|
{
|
||||||
|
// Looks like a valid filename that already exists!
|
||||||
|
PHYSFS_close(TempFile);
|
||||||
|
ui_close_dialog(dlg);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// File doesn't exist, but can we create it?
|
||||||
|
TempFile = PHYSFS_openWrite(b->filename);
|
||||||
|
if (TempFile)
|
||||||
|
{
|
||||||
|
// Looks like a valid filename!
|
||||||
|
PHYSFS_close(TempFile);
|
||||||
|
PHYSFS_delete(b->filename);
|
||||||
|
ui_close_dialog(dlg);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (b->filename[strlen(b->filename) - 1] == '/') // user typed a separator on the end
|
||||||
|
b->filename[strlen(b->filename) - 1] = 0;
|
||||||
|
|
||||||
|
strcpy(b->view_dir, b->filename);
|
||||||
|
|
||||||
|
|
||||||
|
PHYSFS_freeList(b->filename_list);
|
||||||
|
b->filename_list = file_getfilelist(&b->num_files, b->filespec, b->view_dir);
|
||||||
|
if (!b->filename_list)
|
||||||
|
{
|
||||||
|
PHYSFS_freeList(b->directory_list); b->directory_list = NULL;
|
||||||
|
ui_close_dialog(dlg);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
ui_inputbox_set_text(b->user_file, b->filespec);
|
||||||
|
|
||||||
|
PHYSFS_freeList(b->directory_list);
|
||||||
|
b->directory_list = file_getdirlist(&b->num_dirs, b->view_dir);
|
||||||
|
if (!b->directory_list)
|
||||||
|
{
|
||||||
|
PHYSFS_freeList(b->filename_list); b->filename_list = NULL;
|
||||||
|
ui_close_dialog(dlg);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
ui_listbox_change(dlg, b->listbox1, b->num_files, b->filename_list);
|
||||||
|
ui_listbox_change(dlg, b->listbox2, b->num_dirs, b->directory_list);
|
||||||
|
b->new_listboxes = 1;
|
||||||
|
|
||||||
|
ui_dprintf_at( dlg, 20, 60, "%s", b->spaces );
|
||||||
|
ui_dprintf_at( dlg, 20, 60, "%s", b->view_dir );
|
||||||
|
|
||||||
|
//i = TICKER;
|
||||||
|
//while ( TICKER < i+2 );
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
ui_mouse_show();
|
||||||
|
rval = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return rval;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ui_get_filename( char * filename, char * filespec, char * message )
|
||||||
|
{
|
||||||
|
char InputText[PATH_MAX];
|
||||||
|
char *p;
|
||||||
|
int i;
|
||||||
|
browser *b;
|
||||||
|
UI_DIALOG *dlg;
|
||||||
|
window *wind;
|
||||||
|
int rval = 0;
|
||||||
|
|
||||||
|
MALLOC(b, browser, 1);
|
||||||
|
if (!b)
|
||||||
|
return 0;
|
||||||
|
|
||||||
if ((p = strrchr(filename, '/')))
|
if ((p = strrchr(filename, '/')))
|
||||||
{
|
{
|
||||||
*p++ = 0;
|
*p++ = 0;
|
||||||
strcpy(ViewDir, filename);
|
strcpy(b->view_dir, filename);
|
||||||
strcpy(InputText, p);
|
strcpy(InputText, p);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
strcpy(ViewDir, "");
|
strcpy(b->view_dir, "");
|
||||||
strcpy(InputText, filename);
|
strcpy(InputText, filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
filename_list = file_getfilelist(&NumFiles, Filespec, ViewDir);
|
b->filename_list = file_getfilelist(&b->num_files, filespec, b->view_dir);
|
||||||
directory_list = file_getdirlist(&NumDirs, ViewDir);
|
if (!b->filename_list)
|
||||||
|
|
||||||
// Running out of memory may become likely in the future
|
|
||||||
if (!filename_list && !directory_list)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
if (!filename_list)
|
|
||||||
{
|
{
|
||||||
PHYSFS_freeList(directory_list);
|
d_free(b);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!directory_list)
|
b->directory_list = file_getdirlist(&b->num_dirs, b->view_dir);
|
||||||
|
if (!b->directory_list)
|
||||||
{
|
{
|
||||||
PHYSFS_freeList(filename_list);
|
PHYSFS_freeList(b->filename_list);
|
||||||
|
d_free(b);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
//MessageBox( -2,-2, 1,"DEBUG:0", "Ok" );
|
//MessageBox( -2,-2, 1,"DEBUG:0", "Ok" );
|
||||||
for (i=0; i<35; i++)
|
for (i=0; i<35; i++)
|
||||||
Spaces[i] = ' ';
|
b->spaces[i] = ' ';
|
||||||
Spaces[34] = 0;
|
b->spaces[34] = 0;
|
||||||
|
|
||||||
dlg = ui_create_dialog( 200, 100, 400, 370, DF_DIALOG | DF_MODAL, NULL, NULL );
|
dlg = ui_create_dialog( 200, 100, 400, 370, DF_DIALOG | DF_MODAL, (int (*)(UI_DIALOG *, d_event *, void *))browser_handler, b );
|
||||||
|
|
||||||
ui_dprintf_at( dlg, 10, 5, message );
|
ui_dprintf_at( dlg, 10, 5, message );
|
||||||
|
|
||||||
ui_dprintf_at( dlg, 20, 32,"N&ame" );
|
ui_dprintf_at( dlg, 20, 32,"N&ame" );
|
||||||
UserFile = ui_add_gadget_inputbox( dlg, 60, 30, PATH_MAX, 40, InputText );
|
b->user_file = ui_add_gadget_inputbox( dlg, 60, 30, PATH_MAX, 40, InputText );
|
||||||
|
|
||||||
ui_dprintf_at( dlg, 20, 86,"&Files" );
|
ui_dprintf_at( dlg, 20, 86,"&Files" );
|
||||||
ui_dprintf_at( dlg, 210, 86,"&Dirs" );
|
ui_dprintf_at( dlg, 210, 86,"&Dirs" );
|
||||||
|
|
||||||
ListBox1 = ui_add_gadget_listbox(dlg, 20, 110, 125, 200, NumFiles, filename_list);
|
b->listbox1 = ui_add_gadget_listbox(dlg, 20, 110, 125, 200, b->num_files, b->filename_list);
|
||||||
ListBox2 = ui_add_gadget_listbox(dlg, 210, 110, 100, 200, NumDirs, directory_list);
|
b->listbox2 = ui_add_gadget_listbox(dlg, 210, 110, 100, 200, b->num_dirs, b->directory_list);
|
||||||
|
|
||||||
Button1 = ui_add_gadget_button( dlg, 20, 330, 60, 25, "Ok", NULL );
|
b->button1 = ui_add_gadget_button( dlg, 20, 330, 60, 25, "Ok", NULL );
|
||||||
Button2 = ui_add_gadget_button( dlg, 100, 330, 60, 25, "Cancel", NULL );
|
b->button2 = ui_add_gadget_button( dlg, 100, 330, 60, 25, "Cancel", NULL );
|
||||||
HelpButton = ui_add_gadget_button( dlg, 180, 330, 60, 25, "Help", NULL );
|
b->help_button = ui_add_gadget_button( dlg, 180, 330, 60, 25, "Help", NULL );
|
||||||
|
|
||||||
dlg->keyboard_focus_gadget = (UI_GADGET *)UserFile;
|
dlg->keyboard_focus_gadget = (UI_GADGET *)b->user_file;
|
||||||
|
|
||||||
Button1->hotkey = KEY_CTRLED + KEY_ENTER;
|
b->button1->hotkey = KEY_CTRLED + KEY_ENTER;
|
||||||
Button2->hotkey = KEY_ESC;
|
b->button2->hotkey = KEY_ESC;
|
||||||
HelpButton->hotkey = KEY_F1;
|
b->help_button->hotkey = KEY_F1;
|
||||||
ListBox1->hotkey = KEY_ALTED + KEY_F;
|
b->listbox1->hotkey = KEY_ALTED + KEY_F;
|
||||||
ListBox2->hotkey = KEY_ALTED + KEY_D;
|
b->listbox2->hotkey = KEY_ALTED + KEY_D;
|
||||||
UserFile->hotkey = KEY_ALTED + KEY_A;
|
b->user_file->hotkey = KEY_ALTED + KEY_A;
|
||||||
|
|
||||||
ui_gadget_calc_keys(dlg);
|
ui_gadget_calc_keys(dlg);
|
||||||
|
|
||||||
ui_dprintf_at( dlg, 20, 60, "%s", Spaces );
|
ui_dprintf_at( dlg, 20, 60, "%s", b->spaces );
|
||||||
ui_dprintf_at( dlg, 20, 60, "%s", ViewDir );
|
ui_dprintf_at( dlg, 20, 60, "%s", b->view_dir );
|
||||||
|
|
||||||
new_listboxes = 0;
|
b->filename = filename;
|
||||||
|
b->filespec = filespec;
|
||||||
while( 1 )
|
b->message = message;
|
||||||
{
|
b->new_listboxes = 0;
|
||||||
|
|
||||||
|
wind = ui_dialog_get_window(dlg);
|
||||||
|
|
||||||
|
while (window_exists(wind))
|
||||||
event_process();
|
event_process();
|
||||||
|
|
||||||
if ( Button2->pressed )
|
|
||||||
{
|
|
||||||
PHYSFS_freeList(filename_list);
|
|
||||||
PHYSFS_freeList(directory_list);
|
|
||||||
ui_close_dialog(dlg);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( HelpButton->pressed )
|
|
||||||
MessageBox( -1, -1, 1, "Sorry, no help is available!", "Ok" );
|
|
||||||
|
|
||||||
if (ListBox1->moved || new_listboxes)
|
|
||||||
{
|
|
||||||
if (ListBox1->current_item >= 0 )
|
|
||||||
ui_inputbox_set_text(UserFile, filename_list[ListBox1->current_item]);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ListBox2->moved || new_listboxes)
|
|
||||||
{
|
|
||||||
if (ListBox2->current_item >= 0 )
|
|
||||||
ui_inputbox_set_text(UserFile, directory_list[ListBox2->current_item]);
|
|
||||||
}
|
|
||||||
new_listboxes = 0;
|
|
||||||
|
|
||||||
if (Button1->pressed || UserFile->pressed || (ListBox1->selected_item > -1 ) || (ListBox2->selected_item > -1 ))
|
|
||||||
{
|
|
||||||
ui_mouse_hide();
|
|
||||||
|
|
||||||
if (ListBox2->selected_item > -1 )
|
|
||||||
strcpy(UserFile->text, directory_list[ListBox2->selected_item]);
|
|
||||||
|
|
||||||
strncpy(filename, ViewDir, PATH_MAX);
|
|
||||||
|
|
||||||
p = UserFile->text;
|
|
||||||
while (!strncmp(p, "..", 2)) // shorten the path manually
|
|
||||||
{
|
|
||||||
char *sep = strrchr(filename, '/');
|
|
||||||
if (sep)
|
|
||||||
*sep = 0;
|
|
||||||
else
|
|
||||||
*filename = 0; // look directly in search paths
|
|
||||||
|
|
||||||
p += 2;
|
|
||||||
if (*p == '/')
|
|
||||||
p++;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (*filename && *p)
|
|
||||||
strncat(filename, "/", PATH_MAX - strlen(filename));
|
|
||||||
strncat(filename, p, PATH_MAX - strlen(filename));
|
|
||||||
|
|
||||||
if (!PHYSFS_isDirectory(filename))
|
|
||||||
{
|
|
||||||
TempFile = PHYSFS_openRead(filename);
|
|
||||||
if (TempFile)
|
|
||||||
{
|
|
||||||
// Looks like a valid filename that already exists!
|
|
||||||
PHYSFS_close(TempFile);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// File doesn't exist, but can we create it?
|
|
||||||
TempFile = PHYSFS_openWrite(filename);
|
|
||||||
if (TempFile)
|
|
||||||
{
|
|
||||||
// Looks like a valid filename!
|
|
||||||
PHYSFS_close(TempFile);
|
|
||||||
PHYSFS_delete(filename);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (filename[strlen(filename) - 1] == '/') // user typed a separator on the end
|
|
||||||
filename[strlen(filename) - 1] = 0;
|
|
||||||
|
|
||||||
strcpy(ViewDir, filename);
|
|
||||||
|
|
||||||
|
|
||||||
PHYSFS_freeList(filename_list);
|
|
||||||
filename_list = file_getfilelist(&NumFiles, Filespec, ViewDir);
|
|
||||||
if (!filename_list)
|
|
||||||
{
|
|
||||||
PHYSFS_freeList(directory_list);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
ui_inputbox_set_text(UserFile, Filespec);
|
|
||||||
|
|
||||||
PHYSFS_freeList(directory_list);
|
|
||||||
directory_list = file_getdirlist(&NumDirs, ViewDir);
|
|
||||||
if (!directory_list)
|
|
||||||
{
|
|
||||||
PHYSFS_freeList(filename_list);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
ui_listbox_change(dlg, ListBox1, NumFiles, filename_list);
|
|
||||||
ui_listbox_change(dlg, ListBox2, NumDirs, directory_list);
|
|
||||||
new_listboxes = 0;
|
|
||||||
|
|
||||||
ui_dprintf_at( dlg, 20, 60, "%s", Spaces );
|
|
||||||
ui_dprintf_at( dlg, 20, 60, "%s", ViewDir );
|
|
||||||
|
|
||||||
//i = TICKER;
|
|
||||||
//while ( TICKER < i+2 );
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
ui_mouse_show();
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//key_flush();
|
//key_flush();
|
||||||
|
|
||||||
ui_close_dialog(dlg);
|
if (b->filename_list)
|
||||||
if (filename_list)
|
PHYSFS_freeList(b->filename_list);
|
||||||
PHYSFS_freeList(filename_list);
|
if (b->directory_list)
|
||||||
if (directory_list)
|
PHYSFS_freeList(b->directory_list);
|
||||||
PHYSFS_freeList(directory_list);
|
|
||||||
|
rval = b->filename_list != NULL;
|
||||||
|
d_free(b);
|
||||||
|
|
||||||
return 1;
|
return rval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue