mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-03-30 17:45:21 +00:00
Improved file open dialogue
Added some extra parameters to open file dialogue and added a check to findConstructor so it doesn't throw errors.
This commit is contained in:
parent
014b566014
commit
40999be7c1
2 changed files with 36 additions and 14 deletions
|
|
@ -20,27 +20,38 @@
|
|||
// IN THE SOFTWARE.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
function getLoadFilename(%filespec, %callback, %currentFile)
|
||||
{
|
||||
function getLoadFilename(%filespec, %callback, %currentFile, %getRelative, %defaultPath)
|
||||
{
|
||||
//If no default path passed in then try to get one from the file
|
||||
if(%defaultPath $= "")
|
||||
{
|
||||
if ( filePath( %currentFile ) !$= "" )
|
||||
%defaultPath = filePath(%currentFile);
|
||||
}
|
||||
|
||||
%dlg = new OpenFileDialog()
|
||||
{
|
||||
Filters = %filespec;
|
||||
DefaultFile = %currentFile;
|
||||
DefaultPath = %defaultPath;
|
||||
ChangePath = false;
|
||||
MustExist = true;
|
||||
MultipleFiles = false;
|
||||
};
|
||||
|
||||
if ( filePath( %currentFile ) !$= "" )
|
||||
%dlg.DefaultPath = filePath(%currentFile);
|
||||
|
||||
if ( %dlg.Execute() )
|
||||
%ok = %dlg.Execute();
|
||||
if ( %ok )
|
||||
{
|
||||
eval(%callback @ "(\"" @ %dlg.FileName @ "\");");
|
||||
%file = %dlg.FileName;
|
||||
if(%getRelative)
|
||||
%file = strreplace(%file,getWorkingDirectory() @ "/", "");
|
||||
eval(%callback @ "(\"" @ %file @ "\");");
|
||||
$Tools::FileDialogs::LastFilePath = filePath( %dlg.FileName );
|
||||
}
|
||||
|
||||
%dlg.delete();
|
||||
|
||||
return %ok;
|
||||
}
|
||||
|
||||
// Opens a choose file dialog with format filters already loaded
|
||||
|
|
|
|||
|
|
@ -20,27 +20,38 @@
|
|||
// IN THE SOFTWARE.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
function getLoadFilename(%filespec, %callback, %currentFile)
|
||||
{
|
||||
function getLoadFilename(%filespec, %callback, %currentFile, %getRelative, %defaultPath)
|
||||
{
|
||||
//If no default path passed in then try to get one from the file
|
||||
if(%defaultPath $= "")
|
||||
{
|
||||
if ( filePath( %currentFile ) !$= "" )
|
||||
%defaultPath = filePath(%currentFile);
|
||||
}
|
||||
|
||||
%dlg = new OpenFileDialog()
|
||||
{
|
||||
Filters = %filespec;
|
||||
DefaultFile = %currentFile;
|
||||
DefaultPath = %defaultPath;
|
||||
ChangePath = false;
|
||||
MustExist = true;
|
||||
MultipleFiles = false;
|
||||
};
|
||||
|
||||
if ( filePath( %currentFile ) !$= "" )
|
||||
%dlg.DefaultPath = filePath(%currentFile);
|
||||
|
||||
if ( %dlg.Execute() )
|
||||
%ok = %dlg.Execute();
|
||||
if ( %ok )
|
||||
{
|
||||
eval(%callback @ "(\"" @ %dlg.FileName @ "\");");
|
||||
%file = %dlg.FileName;
|
||||
if(%getRelative)
|
||||
%file = strreplace(%file,getWorkingDirectory() @ "/", "");
|
||||
eval(%callback @ "(\"" @ %file @ "\");");
|
||||
$Tools::FileDialogs::LastFilePath = filePath( %dlg.FileName );
|
||||
}
|
||||
|
||||
%dlg.delete();
|
||||
|
||||
return %ok;
|
||||
}
|
||||
|
||||
// Opens a choose file dialog with format filters already loaded
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue