Merge branch 'lastproject' of https://github.com/GoaLitiuM/FlaxEngine into GoaLitiuM-lastproject
This commit is contained in:
@@ -526,6 +526,23 @@ int32 Editor::LoadProduct()
|
||||
return 12;
|
||||
}
|
||||
|
||||
// Get the last opened project path
|
||||
String localCachePath;
|
||||
FileSystem::GetSpecialFolderPath(SpecialFolder::AppData, localCachePath);
|
||||
String editorConfigPath = localCachePath / TEXT("Flax");
|
||||
String lastProjectSettingPath = editorConfigPath / TEXT("LastProject.txt");
|
||||
if (!FileSystem::DirectoryExists(editorConfigPath))
|
||||
FileSystem::CreateDirectory(editorConfigPath);
|
||||
String lastProjectPath;
|
||||
if (FileSystem::FileExists(lastProjectSettingPath))
|
||||
File::ReadAllText(lastProjectSettingPath, lastProjectPath);
|
||||
if (!FileSystem::DirectoryExists(lastProjectPath))
|
||||
lastProjectPath = String::Empty;
|
||||
|
||||
// Try to open the last project when requested
|
||||
if (projectPath.IsEmpty() && CommandLine::Options.LastProject.IsTrue() && !lastProjectPath.IsEmpty())
|
||||
projectPath = lastProjectPath;
|
||||
|
||||
// Missing project case
|
||||
if (projectPath.IsEmpty())
|
||||
{
|
||||
@@ -541,7 +558,7 @@ int32 Editor::LoadProduct()
|
||||
Array<String> files;
|
||||
if (FileSystem::ShowOpenFileDialog(
|
||||
nullptr,
|
||||
StringView::Empty,
|
||||
lastProjectPath,
|
||||
TEXT("Project files (*.flaxproj)\0*.flaxproj\0All files (*.*)\0*.*\0"),
|
||||
false,
|
||||
TEXT("Select project to open in Editor"),
|
||||
@@ -625,6 +642,10 @@ int32 Editor::LoadProduct()
|
||||
}
|
||||
}
|
||||
|
||||
// Update the last opened project path
|
||||
if (lastProjectPath.Compare(Project->ProjectFolderPath) != 0)
|
||||
File::WriteAllText(lastProjectSettingPath, Project->ProjectFolderPath, Encoding::UTF8);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -149,6 +149,7 @@ bool CommandLine::Parse(const Char* cmdLine)
|
||||
PARSE_BOOL_SWITCH("-clearcache ", ClearCache);
|
||||
PARSE_BOOL_SWITCH("-clearcooker ", ClearCookerCache);
|
||||
PARSE_ARG_SWITCH("-project ", Project);
|
||||
PARSE_BOOL_SWITCH("-lastproject ", LastProject);
|
||||
PARSE_BOOL_SWITCH("-new ", NewProject);
|
||||
PARSE_BOOL_SWITCH("-genprojectfiles ", GenProjectFiles);
|
||||
PARSE_ARG_SWITCH("-build ", Build);
|
||||
|
||||
@@ -133,6 +133,11 @@ public:
|
||||
/// </summary>
|
||||
String Project;
|
||||
|
||||
/// <summary>
|
||||
/// -lastproject (Opens the last project)
|
||||
/// </summary>
|
||||
Nullable<bool> LastProject;
|
||||
|
||||
/// <summary>
|
||||
/// -new (generates the project files inside the specified project folder or uses current workspace folder)
|
||||
/// </summary>
|
||||
|
||||
@@ -83,17 +83,19 @@ void AppleFileSystem::GetSpecialFolderPath(const SpecialFolder type, String& res
|
||||
switch (type)
|
||||
{
|
||||
case SpecialFolder::Desktop:
|
||||
result = home / TEXT("/Desktop");
|
||||
result = home / TEXT("/Desktop"); // TODO: should be NSDesktopDirectory
|
||||
break;
|
||||
case SpecialFolder::Documents:
|
||||
result = home / TEXT("/Documents");
|
||||
result = home / TEXT("/Documents"); // TODO: should be NSDocumentDirectory
|
||||
break;
|
||||
case SpecialFolder::Pictures:
|
||||
result = home / TEXT("/Pictures");
|
||||
result = home / TEXT("/Pictures"); // TODO: should be NSPicturesDirectory
|
||||
break;
|
||||
case SpecialFolder::AppData:
|
||||
result = home / TEXT("/Library/Application Support"); // TODO: should be NSApplicationSupportDirectory
|
||||
break;
|
||||
case SpecialFolder::LocalAppData:
|
||||
result = home / TEXT("/Library/Caches");
|
||||
result = home / TEXT("/Library/Caches"); // TODO: should be NSApplicationSupportDirectory
|
||||
break;
|
||||
case SpecialFolder::ProgramData:
|
||||
result = home / TEXT("/Library/Application Support");
|
||||
|
||||
@@ -338,17 +338,35 @@ void LinuxFileSystem::GetSpecialFolderPath(const SpecialFolder type, String& res
|
||||
switch (type)
|
||||
{
|
||||
case SpecialFolder::Desktop:
|
||||
result = home / TEXT("Desktop");
|
||||
{
|
||||
String desktopDir;
|
||||
if (!Platform::GetEnvironmentVariable(TEXT("XDG_DESKTOP_DIR"), desktopDir))
|
||||
result = desktopDir;
|
||||
else
|
||||
result = home / TEXT("Desktop");
|
||||
break;
|
||||
}
|
||||
case SpecialFolder::Documents:
|
||||
result = String::Empty;
|
||||
break;
|
||||
case SpecialFolder::Pictures:
|
||||
result = home / TEXT("Pictures");
|
||||
{
|
||||
String picturesDir;
|
||||
if (!Platform::GetEnvironmentVariable(TEXT("XDG_PICTURES_DIR"), picturesDir))
|
||||
result = picturesDir;
|
||||
else
|
||||
result = home / TEXT("Pictures");
|
||||
break;
|
||||
}
|
||||
case SpecialFolder::AppData:
|
||||
result = TEXT("/usr/share");
|
||||
{
|
||||
String configHome;
|
||||
if (!Platform::GetEnvironmentVariable(TEXT("XDG_CONFIG_HOME"), configHome))
|
||||
result = configHome;
|
||||
else
|
||||
result = home / TEXT(".config");
|
||||
break;
|
||||
}
|
||||
case SpecialFolder::LocalAppData:
|
||||
{
|
||||
String dataHome;
|
||||
|
||||
Reference in New Issue
Block a user