2006-03-20 16:43:15 +00:00
|
|
|
/*
|
2014-06-01 17:55:23 +00:00
|
|
|
* Portions of this file are copyright Rebirth contributors and licensed as
|
|
|
|
* described in COPYING.txt.
|
|
|
|
* Portions of this file are copyright Parallax Software and licensed
|
|
|
|
* according to the Parallax license below.
|
|
|
|
* See COPYING.txt for license details.
|
|
|
|
|
2006-03-20 16:43:15 +00:00
|
|
|
THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
|
|
|
|
SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO
|
|
|
|
END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
|
|
|
|
ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
|
|
|
|
IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
|
|
|
|
SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
|
|
|
|
FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
|
|
|
|
CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS
|
2010-12-24 04:26:24 +00:00
|
|
|
AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.
|
|
|
|
COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
|
2006-03-20 16:43:15 +00:00
|
|
|
*/
|
2008-04-06 20:23:28 +00:00
|
|
|
|
2006-03-20 16:43:15 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
2010-12-24 04:26:24 +00:00
|
|
|
|
2011-01-13 04:36:19 +00:00
|
|
|
#include "event.h"
|
2012-07-01 02:54:33 +00:00
|
|
|
#include "maths.h"
|
2008-01-02 03:37:13 +00:00
|
|
|
#include "pstypes.h"
|
2006-03-20 16:43:15 +00:00
|
|
|
#include "gr.h"
|
|
|
|
#include "key.h"
|
2012-03-18 10:04:16 +00:00
|
|
|
#include "mouse.h"
|
2010-12-24 04:26:24 +00:00
|
|
|
#include "strutil.h"
|
2006-03-20 16:43:15 +00:00
|
|
|
#include "ui.h"
|
2012-01-02 07:49:08 +00:00
|
|
|
#include "window.h"
|
2006-03-20 16:43:15 +00:00
|
|
|
#include "u_mem.h"
|
2015-01-17 18:31:42 +00:00
|
|
|
#include "physfsx.h"
|
2015-04-26 20:15:50 +00:00
|
|
|
#include "physfs_list.h"
|
2006-03-20 16:43:15 +00:00
|
|
|
|
2019-05-04 18:27:36 +00:00
|
|
|
#include "compiler-range_for.h"
|
|
|
|
#include "d_range.h"
|
2020-05-02 21:18:43 +00:00
|
|
|
#include <memory>
|
2014-12-20 04:36:08 +00:00
|
|
|
|
2015-12-13 18:00:49 +00:00
|
|
|
namespace dcx {
|
2015-12-05 22:57:24 +00:00
|
|
|
|
2020-10-12 03:28:25 +00:00
|
|
|
namespace {
|
|
|
|
|
2020-10-12 03:28:25 +00:00
|
|
|
#if DXX_USE_EDITOR
|
2015-05-09 17:38:57 +00:00
|
|
|
static PHYSFSX_counted_list file_getdirlist(const char *dir)
|
2006-03-20 16:43:15 +00:00
|
|
|
{
|
2015-03-22 18:49:21 +00:00
|
|
|
ntstring<PATH_MAX - 1> path;
|
|
|
|
auto dlen = path.copy_if(dir);
|
2016-11-13 04:49:08 +00:00
|
|
|
if ((!dlen && dir[0] != '\0') || !path.copy_if(dlen, "/"))
|
2015-03-22 18:49:21 +00:00
|
|
|
return nullptr;
|
|
|
|
++ dlen;
|
2015-05-09 17:38:57 +00:00
|
|
|
PHYSFSX_counted_list list{PHYSFS_enumerateFiles(dir)};
|
2010-12-24 04:26:24 +00:00
|
|
|
if (!list)
|
2015-05-05 03:20:42 +00:00
|
|
|
return nullptr;
|
2015-04-26 20:15:50 +00:00
|
|
|
const auto predicate = [&](char *i) -> bool {
|
|
|
|
if (path.copy_if(dlen, i) && PHYSFS_isDirectory(path))
|
|
|
|
return false;
|
|
|
|
free(i);
|
|
|
|
return true;
|
|
|
|
};
|
2015-04-26 20:15:51 +00:00
|
|
|
auto j = std::remove_if(list.begin(), list.end(), predicate);
|
2010-12-24 04:26:24 +00:00
|
|
|
*j = NULL;
|
2015-05-09 17:38:57 +00:00
|
|
|
auto NumDirs = j.get() - list.get();
|
2016-09-04 19:10:43 +00:00
|
|
|
qsort(list.get(), NumDirs, sizeof(char *), string_array_sort_func);
|
2010-12-24 04:26:24 +00:00
|
|
|
if (*dir)
|
|
|
|
{
|
|
|
|
// Put the 'go to parent directory' sequence '..' first
|
2015-05-09 17:38:57 +00:00
|
|
|
++NumDirs;
|
|
|
|
auto r = reinterpret_cast<char **>(realloc(list.get(), sizeof(char *)*(NumDirs + 1)));
|
2015-04-26 20:15:50 +00:00
|
|
|
if (!r)
|
|
|
|
return list;
|
2015-04-26 20:15:50 +00:00
|
|
|
list.release();
|
|
|
|
list.reset(r);
|
2015-05-09 17:38:57 +00:00
|
|
|
std::move_backward(r, r + NumDirs, r + NumDirs + 1);
|
2013-07-07 17:28:13 +00:00
|
|
|
list[0] = d_strdup("..");
|
2010-12-24 04:26:24 +00:00
|
|
|
}
|
2015-05-09 17:38:57 +00:00
|
|
|
list.set_count(NumDirs);
|
2010-12-24 04:26:24 +00:00
|
|
|
return list;
|
2006-03-20 16:43:15 +00:00
|
|
|
}
|
2020-10-12 03:28:25 +00:00
|
|
|
#endif
|
2006-03-20 16:43:15 +00:00
|
|
|
|
2015-05-09 17:38:57 +00:00
|
|
|
static PHYSFSX_counted_list file_getfilelist(const char *filespec, const char *dir)
|
2006-03-20 16:43:15 +00:00
|
|
|
{
|
2015-05-09 17:38:57 +00:00
|
|
|
PHYSFSX_counted_list list{PHYSFS_enumerateFiles(dir)};
|
2010-12-24 04:26:24 +00:00
|
|
|
if (!list)
|
2015-05-05 03:20:42 +00:00
|
|
|
return nullptr;
|
2006-03-20 16:43:15 +00:00
|
|
|
|
2010-12-24 04:26:24 +00:00
|
|
|
if (*filespec == '*')
|
|
|
|
filespec++;
|
2006-03-20 16:43:15 +00:00
|
|
|
|
2015-04-26 20:15:50 +00:00
|
|
|
const auto predicate = [&](char *i) -> bool {
|
|
|
|
auto ext = strrchr(i, '.');
|
2012-06-01 11:05:44 +00:00
|
|
|
if (ext && (!d_stricmp(ext, filespec)))
|
2015-04-26 20:15:50 +00:00
|
|
|
return false;
|
|
|
|
free(i);
|
|
|
|
return true;
|
|
|
|
};
|
2015-04-26 20:15:51 +00:00
|
|
|
auto j = std::remove_if(list.begin(), list.end(), predicate);
|
2010-12-24 04:26:24 +00:00
|
|
|
*j = NULL;
|
2015-05-09 17:38:57 +00:00
|
|
|
auto NumFiles = j.get() - list.get();
|
|
|
|
list.set_count(NumFiles);
|
2016-09-04 19:10:43 +00:00
|
|
|
qsort(list.get(), NumFiles, sizeof(char *), string_array_sort_func);
|
2010-12-24 04:26:24 +00:00
|
|
|
return list;
|
2006-03-20 16:43:15 +00:00
|
|
|
}
|
|
|
|
|
2020-10-12 03:28:25 +00:00
|
|
|
#if DXX_USE_EDITOR
|
|
|
|
struct ui_file_browser : UI_DIALOG
|
2006-03-20 16:43:15 +00:00
|
|
|
{
|
2012-01-02 07:49:08 +00:00
|
|
|
char *filename;
|
2013-06-08 22:24:17 +00:00
|
|
|
const char *filespec;
|
|
|
|
const char *message;
|
2020-10-12 03:28:25 +00:00
|
|
|
PHYSFSX_counted_list &filename_list;
|
|
|
|
PHYSFSX_counted_list directory_list;
|
2014-12-20 04:36:10 +00:00
|
|
|
std::unique_ptr<UI_GADGET_BUTTON> button1, button2, help_button;
|
2014-12-20 04:36:10 +00:00
|
|
|
std::unique_ptr<UI_GADGET_LISTBOX> listbox1, listbox2;
|
2014-12-20 04:36:09 +00:00
|
|
|
std::unique_ptr<UI_GADGET_INPUTBOX> user_file;
|
2020-05-02 21:18:42 +00:00
|
|
|
std::array<char, 35> spaces;
|
2020-10-12 03:28:25 +00:00
|
|
|
std::array<char, PATH_MAX> view_dir;
|
2020-10-12 03:28:25 +00:00
|
|
|
explicit ui_file_browser(short x, short y, short w, short h, enum dialog_flags flags, const std::array<char, PATH_MAX> &view_dir, PHYSFSX_counted_list &filename, PHYSFSX_counted_list &&directory) :
|
2020-12-19 16:13:26 +00:00
|
|
|
UI_DIALOG(x, y, w, h, flags),
|
2020-10-12 03:28:25 +00:00
|
|
|
filename_list(filename),
|
|
|
|
directory_list(std::move(directory)),
|
|
|
|
view_dir(view_dir)
|
2020-10-12 03:28:25 +00:00
|
|
|
{
|
|
|
|
std::fill(spaces.begin(), std::prev(spaces.end()), ' ');
|
|
|
|
spaces.back() = 0;
|
|
|
|
}
|
2020-10-12 03:28:25 +00:00
|
|
|
virtual window_event_result callback_handler(const d_event &) override;
|
2013-12-22 22:03:07 +00:00
|
|
|
};
|
2012-01-02 07:49:08 +00:00
|
|
|
|
2020-10-12 03:28:25 +00:00
|
|
|
window_event_result ui_file_browser::callback_handler(const d_event &event)
|
2012-01-02 07:49:08 +00:00
|
|
|
{
|
2016-10-04 07:58:20 +00:00
|
|
|
window_event_result rval = window_event_result::ignored;
|
2012-01-02 07:49:08 +00:00
|
|
|
|
2014-10-04 21:47:13 +00:00
|
|
|
if (event.type == EVENT_UI_DIALOG_DRAW)
|
2012-04-11 02:52:19 +00:00
|
|
|
{
|
2020-10-12 03:28:25 +00:00
|
|
|
ui_dputs_at(this, 10, 5, message);
|
2012-04-11 02:52:19 +00:00
|
|
|
|
2020-10-12 03:28:25 +00:00
|
|
|
ui_dprintf_at(this, 20, 32, "N&ame");
|
|
|
|
ui_dprintf_at(this, 20, 86, "&Files");
|
|
|
|
ui_dprintf_at(this, 210, 86, "&Dirs");
|
2012-04-11 02:52:19 +00:00
|
|
|
|
2020-10-12 03:28:25 +00:00
|
|
|
ui_dputs_at(this, 20, 60, spaces.data());
|
|
|
|
ui_dputs_at(this, 20, 60, view_dir.data());
|
2012-04-11 02:52:19 +00:00
|
|
|
|
2016-10-04 07:58:20 +00:00
|
|
|
return window_event_result::handled;
|
2012-04-11 02:52:19 +00:00
|
|
|
}
|
|
|
|
|
2020-10-12 03:28:25 +00:00
|
|
|
if (GADGET_PRESSED(button2.get()))
|
2012-01-02 07:49:08 +00:00
|
|
|
{
|
2020-10-12 03:28:25 +00:00
|
|
|
filename_list.reset();
|
2016-10-27 09:38:20 +00:00
|
|
|
return window_event_result::close;
|
2012-01-02 07:49:08 +00:00
|
|
|
}
|
|
|
|
|
2020-10-12 03:28:25 +00:00
|
|
|
if (GADGET_PRESSED(help_button.get()))
|
2012-01-02 07:49:08 +00:00
|
|
|
{
|
2012-04-17 08:02:32 +00:00
|
|
|
ui_messagebox( -1, -1, 1, "Sorry, no help is available!", "Ok" );
|
2016-10-04 07:58:20 +00:00
|
|
|
rval = window_event_result::handled;
|
2012-01-02 07:49:08 +00:00
|
|
|
}
|
|
|
|
|
2014-10-04 21:47:13 +00:00
|
|
|
if (event.type == EVENT_UI_LISTBOX_MOVED)
|
2012-01-02 07:49:08 +00:00
|
|
|
{
|
2020-10-12 03:28:25 +00:00
|
|
|
if (&ui_event_get_gadget(event) == listbox1.get() && listbox1->current_item >= 0 && filename_list[listbox1->current_item])
|
2020-10-12 03:28:25 +00:00
|
|
|
ui_inputbox_set_text(user_file.get(), filename_list[listbox1->current_item]);
|
2012-03-05 11:07:57 +00:00
|
|
|
|
2020-10-12 03:28:25 +00:00
|
|
|
if (&ui_event_get_gadget(event) == listbox2.get() && listbox2->current_item >= 0 && directory_list[listbox2->current_item])
|
2020-10-12 03:28:25 +00:00
|
|
|
ui_inputbox_set_text(user_file.get(), directory_list[listbox2->current_item]);
|
2012-03-05 11:07:57 +00:00
|
|
|
|
2016-10-04 07:58:20 +00:00
|
|
|
rval = window_event_result::handled;
|
2012-01-02 07:49:08 +00:00
|
|
|
}
|
|
|
|
|
2020-10-12 03:28:25 +00:00
|
|
|
if (GADGET_PRESSED(button1.get()) || GADGET_PRESSED(user_file.get()) || event.type == EVENT_UI_LISTBOX_SELECTED)
|
2012-01-02 07:49:08 +00:00
|
|
|
{
|
|
|
|
char *p;
|
|
|
|
|
2020-10-12 03:28:25 +00:00
|
|
|
if (&ui_event_get_gadget(event) == listbox2.get())
|
2020-10-12 03:28:25 +00:00
|
|
|
strcpy(user_file->text.get(), directory_list[listbox2->current_item]);
|
2012-01-02 07:49:08 +00:00
|
|
|
|
2020-10-12 03:28:25 +00:00
|
|
|
strncpy(filename, view_dir.data(), PATH_MAX);
|
2012-01-02 07:49:08 +00:00
|
|
|
|
2020-10-12 03:28:25 +00:00
|
|
|
p = user_file->text.get();
|
2012-01-02 07:49:08 +00:00
|
|
|
while (!strncmp(p, "..", 2)) // shorten the path manually
|
|
|
|
{
|
2020-10-12 03:28:25 +00:00
|
|
|
char *sep = strrchr(filename, '/');
|
2012-01-02 07:49:08 +00:00
|
|
|
if (sep)
|
|
|
|
*sep = 0;
|
|
|
|
else
|
2020-10-12 03:28:25 +00:00
|
|
|
*filename = 0; // look directly in search paths
|
2012-01-02 07:49:08 +00:00
|
|
|
|
|
|
|
p += 2;
|
|
|
|
if (*p == '/')
|
|
|
|
p++;
|
|
|
|
}
|
|
|
|
|
2020-10-12 03:28:25 +00:00
|
|
|
if (*filename && *p)
|
|
|
|
strncat(filename, "/", PATH_MAX - strlen(filename));
|
|
|
|
strncat(filename, p, PATH_MAX - strlen(filename));
|
2012-01-02 07:49:08 +00:00
|
|
|
|
2020-10-12 03:28:25 +00:00
|
|
|
if (!PHYSFS_isDirectory(filename))
|
2012-01-02 07:49:08 +00:00
|
|
|
{
|
2020-10-12 03:28:25 +00:00
|
|
|
if (RAIIPHYSFS_File{PHYSFS_openRead(filename)})
|
2012-01-02 07:49:08 +00:00
|
|
|
{
|
|
|
|
// Looks like a valid filename that already exists!
|
2016-10-27 09:38:20 +00:00
|
|
|
return window_event_result::close;
|
2012-01-02 07:49:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// File doesn't exist, but can we create it?
|
2020-10-12 03:28:25 +00:00
|
|
|
if (RAIIPHYSFS_File TempFile{PHYSFS_openWrite(filename)})
|
2012-01-02 07:49:08 +00:00
|
|
|
{
|
2015-01-17 18:31:42 +00:00
|
|
|
TempFile.reset();
|
2012-01-02 07:49:08 +00:00
|
|
|
// Looks like a valid filename!
|
2020-10-12 03:28:25 +00:00
|
|
|
PHYSFS_delete(filename);
|
2016-10-27 09:38:20 +00:00
|
|
|
return window_event_result::close;
|
2012-01-02 07:49:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-10-12 03:28:25 +00:00
|
|
|
if (auto &last = filename[strlen(filename) - 1]; last == '/') // user typed a separator on the end
|
2020-10-12 03:28:25 +00:00
|
|
|
last = 0;
|
2012-01-02 07:49:08 +00:00
|
|
|
|
2020-10-12 03:28:25 +00:00
|
|
|
strcpy(view_dir.data(), filename);
|
|
|
|
filename_list = file_getfilelist(filespec, view_dir.data());
|
|
|
|
if (!filename_list)
|
2012-01-02 07:49:08 +00:00
|
|
|
{
|
2016-10-27 09:38:20 +00:00
|
|
|
return window_event_result::close;
|
2012-01-02 07:49:08 +00:00
|
|
|
}
|
|
|
|
|
2020-10-12 03:28:25 +00:00
|
|
|
ui_inputbox_set_text(user_file.get(), filespec);
|
|
|
|
directory_list = file_getdirlist(view_dir.data());
|
|
|
|
if (!directory_list)
|
2012-01-02 07:49:08 +00:00
|
|
|
{
|
2020-10-12 03:28:25 +00:00
|
|
|
filename_list.reset();
|
2016-10-27 09:38:20 +00:00
|
|
|
return window_event_result::close;
|
2012-01-02 07:49:08 +00:00
|
|
|
}
|
|
|
|
|
2020-10-12 03:28:25 +00:00
|
|
|
ui_listbox_change(this, listbox1.get(), filename_list.get_count(), filename_list.get());
|
|
|
|
ui_listbox_change(this, listbox2.get(), directory_list.get_count(), directory_list.get());
|
2012-01-02 07:49:08 +00:00
|
|
|
}
|
|
|
|
|
2016-10-04 07:58:20 +00:00
|
|
|
rval = window_event_result::handled;
|
2012-01-02 07:49:08 +00:00
|
|
|
}
|
|
|
|
return rval;
|
|
|
|
}
|
2020-10-12 03:28:25 +00:00
|
|
|
#endif
|
2010-12-24 04:26:24 +00:00
|
|
|
|
2020-10-12 03:28:25 +00:00
|
|
|
}
|
|
|
|
|
2020-10-12 03:28:25 +00:00
|
|
|
#if DXX_USE_EDITOR
|
2020-10-12 03:28:25 +00:00
|
|
|
int ui_get_filename(std::array<char, PATH_MAX> &filename, const char *const filespec, const char *const message)
|
2012-01-02 07:49:08 +00:00
|
|
|
{
|
2020-10-12 03:28:25 +00:00
|
|
|
std::array<char, PATH_MAX>::iterator InputText;
|
|
|
|
std::size_t InputLength;
|
2012-01-02 07:49:08 +00:00
|
|
|
int rval = 0;
|
2020-10-12 03:28:25 +00:00
|
|
|
std::array<char, PATH_MAX> view_dir;
|
2020-10-12 03:28:25 +00:00
|
|
|
if (const auto p = strrchr(filename.data(), '/'))
|
2006-03-20 16:43:15 +00:00
|
|
|
{
|
2020-10-12 03:28:25 +00:00
|
|
|
const auto count = std::distance(filename.begin(), p);
|
2020-10-12 03:28:25 +00:00
|
|
|
if (count >= view_dir.size())
|
2020-10-12 03:28:25 +00:00
|
|
|
/* This should never happen. */
|
|
|
|
return 0;
|
2020-10-12 03:28:25 +00:00
|
|
|
std::copy(std::begin(filename), p, std::begin(view_dir));
|
2020-10-12 03:28:25 +00:00
|
|
|
InputText = std::next(p);
|
|
|
|
InputLength = std::distance(InputText, filename.end());
|
2006-03-20 16:43:15 +00:00
|
|
|
}
|
2010-12-24 04:26:24 +00:00
|
|
|
else
|
2006-03-20 16:43:15 +00:00
|
|
|
{
|
2020-10-12 03:28:25 +00:00
|
|
|
view_dir.front() = 0;
|
2020-10-12 03:28:25 +00:00
|
|
|
InputText = filename.begin();
|
|
|
|
InputLength = filename.size();
|
2006-03-20 16:43:15 +00:00
|
|
|
}
|
|
|
|
|
2020-10-12 03:28:25 +00:00
|
|
|
PHYSFSX_counted_list filename_list = file_getfilelist(filespec, view_dir.data());
|
|
|
|
if (!filename_list)
|
2006-03-20 16:43:15 +00:00
|
|
|
{
|
2010-12-24 04:26:24 +00:00
|
|
|
return 0;
|
2006-03-20 16:43:15 +00:00
|
|
|
}
|
2012-01-02 07:49:08 +00:00
|
|
|
|
2020-10-12 03:28:25 +00:00
|
|
|
PHYSFSX_counted_list &&directory_list = file_getdirlist(view_dir.data());
|
|
|
|
if (!directory_list)
|
2006-03-20 16:43:15 +00:00
|
|
|
{
|
2010-12-24 04:26:24 +00:00
|
|
|
return 0;
|
2006-03-20 16:43:15 +00:00
|
|
|
}
|
|
|
|
|
2012-04-17 08:02:32 +00:00
|
|
|
//ui_messagebox( -2,-2, 1,"DEBUG:0", "Ok" );
|
2006-03-20 16:43:15 +00:00
|
|
|
|
2020-12-19 16:13:26 +00:00
|
|
|
auto dlg = window_create<ui_file_browser>(200, 100, 400, 370, static_cast<dialog_flags>(DF_DIALOG | DF_MODAL), view_dir, filename_list, std::move(directory_list));
|
2006-03-20 16:43:15 +00:00
|
|
|
|
2020-10-12 03:28:26 +00:00
|
|
|
dlg->user_file = ui_add_gadget_inputbox(*dlg, 60, 30, InputLength, 40, InputText);
|
2006-03-20 16:43:15 +00:00
|
|
|
|
2020-10-12 03:28:25 +00:00
|
|
|
dlg->listbox1 = ui_add_gadget_listbox(*dlg, 20, 110, 125, 200, filename_list.get_count(), filename_list.get());
|
|
|
|
dlg->listbox2 = ui_add_gadget_listbox(*dlg, 210, 110, 100, 200, dlg->directory_list.get_count(), dlg->directory_list.get());
|
2006-03-20 16:43:15 +00:00
|
|
|
|
2020-10-12 03:28:26 +00:00
|
|
|
dlg->button1 = ui_add_gadget_button(*dlg, 20, 330, 60, 25, "Ok", nullptr);
|
|
|
|
dlg->button2 = ui_add_gadget_button(*dlg, 100, 330, 60, 25, "Cancel", nullptr);
|
|
|
|
dlg->help_button = ui_add_gadget_button(*dlg, 180, 330, 60, 25, "Help", nullptr);
|
2006-03-20 16:43:15 +00:00
|
|
|
|
2020-10-12 03:28:25 +00:00
|
|
|
dlg->keyboard_focus_gadget = dlg->user_file.get();
|
2006-03-20 16:43:15 +00:00
|
|
|
|
2020-10-12 03:28:25 +00:00
|
|
|
dlg->button1->hotkey = KEY_CTRLED + KEY_ENTER;
|
|
|
|
dlg->button2->hotkey = KEY_ESC;
|
|
|
|
dlg->help_button->hotkey = KEY_F1;
|
|
|
|
dlg->listbox1->hotkey = KEY_ALTED + KEY_F;
|
|
|
|
dlg->listbox2->hotkey = KEY_ALTED + KEY_D;
|
|
|
|
dlg->user_file->hotkey = KEY_ALTED + KEY_A;
|
2006-03-20 16:43:15 +00:00
|
|
|
|
2020-10-12 03:28:26 +00:00
|
|
|
ui_gadget_calc_keys(*dlg);
|
2006-03-20 16:43:15 +00:00
|
|
|
|
2020-10-12 03:28:25 +00:00
|
|
|
dlg->filename = filename.data();
|
|
|
|
dlg->filespec = filespec;
|
|
|
|
dlg->message = message;
|
2010-12-24 04:26:24 +00:00
|
|
|
|
2016-10-29 12:06:01 +00:00
|
|
|
event_process_all();
|
2020-10-12 03:28:25 +00:00
|
|
|
rval = static_cast<bool>(filename_list);
|
2006-03-20 16:43:15 +00:00
|
|
|
|
|
|
|
//key_flush();
|
2012-01-02 07:49:08 +00:00
|
|
|
return rval;
|
2006-03-20 16:43:15 +00:00
|
|
|
}
|
2020-10-12 03:28:25 +00:00
|
|
|
#endif
|
2006-03-20 16:43:15 +00:00
|
|
|
|
2013-06-08 22:24:17 +00:00
|
|
|
int ui_get_file( char * filename, const char * Filespec )
|
2006-03-20 16:43:15 +00:00
|
|
|
{
|
2015-05-09 17:38:57 +00:00
|
|
|
int x;
|
|
|
|
auto list = file_getfilelist(Filespec, "");
|
2010-12-24 04:26:24 +00:00
|
|
|
if (!list) return 0;
|
2015-05-09 17:38:57 +00:00
|
|
|
x = MenuX(-1, -1, list.get_count(), list.get());
|
2010-12-24 04:26:24 +00:00
|
|
|
if (x > 0)
|
|
|
|
strcpy(filename, list[x - 1]);
|
|
|
|
return (x > 0);
|
2006-03-20 16:43:15 +00:00
|
|
|
}
|
2015-12-05 22:57:24 +00:00
|
|
|
|
|
|
|
}
|