mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-02-01 18:41:00 +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
|
|
@ -122,6 +122,7 @@ FileDialog::FileDialog() : mData()
|
|||
// Default to File Must Exist Open Dialog style
|
||||
mData.mStyle = FileDialogData::FDS_OPEN | FileDialogData::FDS_MUSTEXIST;
|
||||
mChangePath = false;
|
||||
mForceRelativePath = true;
|
||||
}
|
||||
|
||||
FileDialog::~FileDialog()
|
||||
|
|
@ -151,6 +152,8 @@ void FileDialog::initPersistFields()
|
|||
addProtectedField("changePath", TypeBool, Offset(mChangePath, FileDialog), &setChangePath, &getChangePath,
|
||||
"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();
|
||||
}
|
||||
|
||||
|
|
@ -267,7 +270,8 @@ bool FileDialog::Execute()
|
|||
}
|
||||
|
||||
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("/"));
|
||||
|
||||
// Did we select a file?
|
||||
|
|
@ -280,7 +284,10 @@ bool FileDialog::Execute()
|
|||
if (mData.mStyle & FileDialogData::FDS_OPEN || mData.mStyle & FileDialogData::FDS_SAVE)
|
||||
{
|
||||
// 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)
|
||||
{
|
||||
|
|
@ -300,7 +307,11 @@ bool FileDialog::Execute()
|
|||
else
|
||||
{
|
||||
//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");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -106,6 +106,7 @@ protected:
|
|||
FileDialogData mData; ///< Stores platform agnostic information about the dialogs properties
|
||||
bool mChangePath; ///< Exposed ChangePath Property
|
||||
bool mBoolTranslator; ///< Internally used to translate boolean values into their respective bits of dialog style
|
||||
bool mForceRelativePath;
|
||||
public:
|
||||
|
||||
FileDialog();
|
||||
|
|
|
|||
Loading…
Reference in a new issue