mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-13 15:44:36 +00:00
Merge pull request #1185 from MusicMonkey5555/script-improvements
Improved file open dialogue
This commit is contained in:
commit
a34cf9e3f9
2 changed files with 36 additions and 14 deletions
|
|
@ -20,27 +20,38 @@
|
||||||
// IN THE SOFTWARE.
|
// 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()
|
%dlg = new OpenFileDialog()
|
||||||
{
|
{
|
||||||
Filters = %filespec;
|
Filters = %filespec;
|
||||||
DefaultFile = %currentFile;
|
DefaultFile = %currentFile;
|
||||||
|
DefaultPath = %defaultPath;
|
||||||
ChangePath = false;
|
ChangePath = false;
|
||||||
MustExist = true;
|
MustExist = true;
|
||||||
MultipleFiles = false;
|
MultipleFiles = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
if ( filePath( %currentFile ) !$= "" )
|
%ok = %dlg.Execute();
|
||||||
%dlg.DefaultPath = filePath(%currentFile);
|
if ( %ok )
|
||||||
|
|
||||||
if ( %dlg.Execute() )
|
|
||||||
{
|
{
|
||||||
eval(%callback @ "(\"" @ %dlg.FileName @ "\");");
|
%file = %dlg.FileName;
|
||||||
|
if(%getRelative)
|
||||||
|
%file = strreplace(%file,getWorkingDirectory() @ "/", "");
|
||||||
|
eval(%callback @ "(\"" @ %file @ "\");");
|
||||||
$Tools::FileDialogs::LastFilePath = filePath( %dlg.FileName );
|
$Tools::FileDialogs::LastFilePath = filePath( %dlg.FileName );
|
||||||
}
|
}
|
||||||
|
|
||||||
%dlg.delete();
|
%dlg.delete();
|
||||||
|
|
||||||
|
return %ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Opens a choose file dialog with format filters already loaded
|
// Opens a choose file dialog with format filters already loaded
|
||||||
|
|
|
||||||
|
|
@ -20,27 +20,38 @@
|
||||||
// IN THE SOFTWARE.
|
// 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()
|
%dlg = new OpenFileDialog()
|
||||||
{
|
{
|
||||||
Filters = %filespec;
|
Filters = %filespec;
|
||||||
DefaultFile = %currentFile;
|
DefaultFile = %currentFile;
|
||||||
|
DefaultPath = %defaultPath;
|
||||||
ChangePath = false;
|
ChangePath = false;
|
||||||
MustExist = true;
|
MustExist = true;
|
||||||
MultipleFiles = false;
|
MultipleFiles = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
if ( filePath( %currentFile ) !$= "" )
|
%ok = %dlg.Execute();
|
||||||
%dlg.DefaultPath = filePath(%currentFile);
|
if ( %ok )
|
||||||
|
|
||||||
if ( %dlg.Execute() )
|
|
||||||
{
|
{
|
||||||
eval(%callback @ "(\"" @ %dlg.FileName @ "\");");
|
%file = %dlg.FileName;
|
||||||
|
if(%getRelative)
|
||||||
|
%file = strreplace(%file,getWorkingDirectory() @ "/", "");
|
||||||
|
eval(%callback @ "(\"" @ %file @ "\");");
|
||||||
$Tools::FileDialogs::LastFilePath = filePath( %dlg.FileName );
|
$Tools::FileDialogs::LastFilePath = filePath( %dlg.FileName );
|
||||||
}
|
}
|
||||||
|
|
||||||
%dlg.delete();
|
%dlg.delete();
|
||||||
|
|
||||||
|
return %ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Opens a choose file dialog with format filters already loaded
|
// Opens a choose file dialog with format filters already loaded
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue