Skip to content

Commit 7fccc4c

Browse files
committed
set missing folder color red, rename MyConverter, add project exists property value and converter, browse parent folder(s) if cannot Explore missing folder, #build
1 parent d824a1f commit 7fccc4c

File tree

4 files changed

+750
-705
lines changed

4 files changed

+750
-705
lines changed

Diff for: UnityLauncherPro/Data/Project.cs

+16-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
using System;
22
using System.Diagnostics;
3+
using System.Windows.Data;
34

45
namespace UnityLauncherPro
56
{
6-
public class Project
7+
public class Project : IValueConverter
78
{
89
public string Title { set; get; }
910
public string Version { set; get; }
@@ -12,12 +13,26 @@ public class Project
1213
public string Arguments { set; get; }
1314
public string GITBranch { set; get; }
1415
public string TargetPlatform { set; get; }
16+
public bool folderExists { set; get; }
1517
public Process Process; // launched unity exe
1618

1719
public override string ToString()
1820
{
1921
return $"{Title} {Version} {Path} {Modified} {Arguments} {GITBranch} {TargetPlatform}";
2022
}
2123

24+
// https://stackoverflow.com/a/5551986/5452781
25+
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
26+
{
27+
bool b = (bool)value;
28+
return b;
29+
//return string.IsNullOrEmpty(str);
30+
}
31+
32+
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
33+
{
34+
throw new NotSupportedException();
35+
}
36+
2237
}
2338
}

Diff for: UnityLauncherPro/GetProjects.cs

+12-9
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ public static List<Project> Scan(bool getGitBranch = false, bool getArguments =
3737
{
3838
if (valueName.IndexOf("RecentlyUsedProjectPaths-") == 0)
3939
{
40+
bool folderExists = false;
4041
string projectPath = "";
4142
// check if binary or not
4243
var valueKind = key.GetValueKind(valueName);
@@ -51,7 +52,8 @@ public static List<Project> Scan(bool getGitBranch = false, bool getArguments =
5152
}
5253

5354
// first check if whole folder exists, if not, skip
54-
if (showMissingFolders == false && Directory.Exists(projectPath) == false)
55+
folderExists = Directory.Exists(projectPath);
56+
if (showMissingFolders == false && folderExists == false)
5557
{
5658
//Console.WriteLine("Recent project directory not found, skipping: " + projectPath);
5759
continue;
@@ -76,48 +78,48 @@ public static List<Project> Scan(bool getGitBranch = false, bool getArguments =
7678
string csprojFile = Path.Combine(projectPath, projectName + ".csproj");
7779

7880
// solution only
79-
if (File.Exists(csprojFile) == false)
81+
if (folderExists == true && File.Exists(csprojFile) == false)
8082
{
8183
csprojFile = Path.Combine(projectPath, projectName + ".sln");
8284
}
8385

8486
// editor only project
85-
if (File.Exists(csprojFile) == false)
87+
if (folderExists == true && File.Exists(csprojFile) == false)
8688
{
8789
csprojFile = Path.Combine(projectPath, projectName + ".Editor.csproj");
8890
}
8991

9092
// maybe 4.x project, NOTE recent versions also have this as default
91-
if (File.Exists(csprojFile) == false)
93+
if (folderExists == true && File.Exists(csprojFile) == false)
9294
{
9395
csprojFile = Path.Combine(projectPath, "Assembly-CSharp.csproj");
9496
}
9597

9698
// get last modified date
97-
DateTime? lastUpdated = Tools.GetLastModifiedTime(csprojFile);
99+
DateTime? lastUpdated = folderExists ? Tools.GetLastModifiedTime(csprojFile) : null;
98100

99101
// get project version
100-
string projectVersion = Tools.GetProjectVersion(projectPath);
102+
string projectVersion = folderExists ? Tools.GetProjectVersion(projectPath) : null;
101103

102104
// get custom launch arguments, only if column in enabled
103105
string customArgs = "";
104106
if (getArguments == true)
105107
{
106-
customArgs = Tools.ReadCustomLaunchArguments(projectPath, MainWindow.launcherArgumentsFile);
108+
customArgs = folderExists ? Tools.ReadCustomLaunchArguments(projectPath, MainWindow.launcherArgumentsFile) : null;
107109
}
108110

109111
// get git branchinfo, only if column in enabled
110112
string gitBranch = "";
111113
if (getGitBranch == true)
112114
{
113-
gitBranch = Tools.ReadGitBranchInfo(projectPath);
115+
gitBranch = folderExists ? Tools.ReadGitBranchInfo(projectPath) : null;
114116
}
115117

116118
// TODO add option to disable check
117119
string targetPlatform = "";
118120
if (showTargetPlatform == true)
119121
{
120-
targetPlatform = Tools.ParseTargetPlatform(projectPath);
122+
targetPlatform = folderExists ? Tools.ParseTargetPlatform(projectPath) : null;
121123
}
122124

123125
var p = new Project();
@@ -128,6 +130,7 @@ public static List<Project> Scan(bool getGitBranch = false, bool getArguments =
128130
p.Arguments = customArgs;
129131
p.GITBranch = gitBranch;
130132
p.TargetPlatform = targetPlatform;
133+
p.folderExists = folderExists;
131134

132135
// if want to hide project and folder path for screenshot
133136
//p.Title = "Hidden Project";

0 commit comments

Comments
 (0)