mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-12 15:14:35 +00:00
Adds the ability to force the path returned by the file dialog to be relative.
This commit is contained in:
parent
a6038d1801
commit
490c05ffd4
2 changed files with 15 additions and 3 deletions
|
|
@ -122,6 +122,7 @@ FileDialog::FileDialog() : mData()
|
||||||
// Default to File Must Exist Open Dialog style
|
// Default to File Must Exist Open Dialog style
|
||||||
mData.mStyle = FileDialogData::FDS_OPEN | FileDialogData::FDS_MUSTEXIST;
|
mData.mStyle = FileDialogData::FDS_OPEN | FileDialogData::FDS_MUSTEXIST;
|
||||||
mChangePath = false;
|
mChangePath = false;
|
||||||
|
mForceRelativePath = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
FileDialog::~FileDialog()
|
FileDialog::~FileDialog()
|
||||||
|
|
@ -151,6 +152,8 @@ void FileDialog::initPersistFields()
|
||||||
addProtectedField("changePath", TypeBool, Offset(mChangePath, FileDialog), &setChangePath, &getChangePath,
|
addProtectedField("changePath", TypeBool, Offset(mChangePath, FileDialog), &setChangePath, &getChangePath,
|
||||||
"True/False whether to set the working directory to the directory returned by the dialog.");
|
"True/False whether to set the working directory to the directory returned by the dialog.");
|
||||||
|
|
||||||
|
addField("forceRelativePath", TypeBool, Offset(mForceRelativePath, FileDialog), "True/False whether to the path returned is always made to be relative.");
|
||||||
|
|
||||||
Parent::initPersistFields();
|
Parent::initPersistFields();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -267,7 +270,8 @@ bool FileDialog::Execute()
|
||||||
}
|
}
|
||||||
|
|
||||||
String resultPath = String(outPath).replace(rootDir, String(""));
|
String resultPath = String(outPath).replace(rootDir, String(""));
|
||||||
resultPath = resultPath.replace(0, 1, String("")).c_str(); //kill '\\' prefix
|
if(resultPath[0] == '\\')
|
||||||
|
resultPath = resultPath.replace(0, 1, String("")).c_str(); //kill '\\' prefix
|
||||||
resultPath = resultPath.replace(String("\\"), String("/"));
|
resultPath = resultPath.replace(String("\\"), String("/"));
|
||||||
|
|
||||||
// Did we select a file?
|
// Did we select a file?
|
||||||
|
|
@ -280,7 +284,10 @@ bool FileDialog::Execute()
|
||||||
if (mData.mStyle & FileDialogData::FDS_OPEN || mData.mStyle & FileDialogData::FDS_SAVE)
|
if (mData.mStyle & FileDialogData::FDS_OPEN || mData.mStyle & FileDialogData::FDS_SAVE)
|
||||||
{
|
{
|
||||||
// Single file selection, do it the easy way
|
// Single file selection, do it the easy way
|
||||||
mData.mFile = Platform::makeRelativePathName(resultPath.c_str(), NULL);
|
if(mForceRelativePath)
|
||||||
|
mData.mFile = Platform::makeRelativePathName(resultPath.c_str(), NULL);
|
||||||
|
else
|
||||||
|
mData.mFile = resultPath.c_str();
|
||||||
}
|
}
|
||||||
else if (mData.mStyle & FileDialogData::FDS_MULTIPLEFILES)
|
else if (mData.mStyle & FileDialogData::FDS_MULTIPLEFILES)
|
||||||
{
|
{
|
||||||
|
|
@ -300,7 +307,11 @@ bool FileDialog::Execute()
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//nope, just one file, so set it as normal
|
//nope, just one file, so set it as normal
|
||||||
setDataField(StringTable->insert("files"), "0", Platform::makeRelativePathName(resultPath.c_str(), NULL));
|
if (mForceRelativePath)
|
||||||
|
setDataField(StringTable->insert("files"), "0", Platform::makeRelativePathName(resultPath.c_str(), NULL));
|
||||||
|
else
|
||||||
|
setDataField(StringTable->insert("files"), "0", resultPath.c_str());
|
||||||
|
|
||||||
setDataField(StringTable->insert("fileCount"), NULL, "1");
|
setDataField(StringTable->insert("fileCount"), NULL, "1");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -106,6 +106,7 @@ protected:
|
||||||
FileDialogData mData; ///< Stores platform agnostic information about the dialogs properties
|
FileDialogData mData; ///< Stores platform agnostic information about the dialogs properties
|
||||||
bool mChangePath; ///< Exposed ChangePath Property
|
bool mChangePath; ///< Exposed ChangePath Property
|
||||||
bool mBoolTranslator; ///< Internally used to translate boolean values into their respective bits of dialog style
|
bool mBoolTranslator; ///< Internally used to translate boolean values into their respective bits of dialog style
|
||||||
|
bool mForceRelativePath;
|
||||||
public:
|
public:
|
||||||
|
|
||||||
FileDialog();
|
FileDialog();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue