Skip to content

Commit 545e010

Browse files
committed
adding editor project count column (now only updates if press refresh button in editors tab)
1 parent b0c2bee commit 545e010

File tree

5 files changed

+35
-22
lines changed

5 files changed

+35
-22
lines changed

UnityLauncherPro/Data/UnityInstallation.cs

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ public class UnityInstallation : IValueConverter
1111

1212
public string PlatformsCombined { set; get; }
1313
public string[] Platforms { set; get; }
14+
public int ProjectCount { set; get; }
1415

1516
public bool IsPreferred { set; get; }
1617

UnityLauncherPro/GetProjects.cs

+15-15
Original file line numberDiff line numberDiff line change
@@ -78,21 +78,21 @@ public static List<Project> Scan(bool getGitBranch = false, bool getArguments =
7878
projectName = projectPath;
7979
}
8080

81-
string csprojFile = Path.Combine(projectPath, projectName + ".csproj");
82-
83-
// maybe 4.x or 2019 or later project
84-
if (folderExists == true && File.Exists(csprojFile) == false)
85-
{
86-
csprojFile = Path.Combine(projectPath, "Assembly-CSharp.csproj");
87-
}
88-
else if (folderExists == true && File.Exists(csprojFile) == false) // editor only project
89-
{
90-
csprojFile = Path.Combine(projectPath, projectName + ".Editor.csproj");
91-
}
92-
else if (folderExists == true && File.Exists(csprojFile) == false) // solution only
93-
{
94-
csprojFile = Path.Combine(projectPath, projectName + ".sln");
95-
}
81+
//string csprojFile = Path.Combine(projectPath, projectName + ".csproj");
82+
83+
//// maybe 4.x or 2019 or later project
84+
//if (folderExists == true && File.Exists(csprojFile) == false)
85+
//{
86+
// csprojFile = Path.Combine(projectPath, "Assembly-CSharp.csproj");
87+
//}
88+
//else if (folderExists == true && File.Exists(csprojFile) == false) // editor only project
89+
//{
90+
// csprojFile = Path.Combine(projectPath, projectName + ".Editor.csproj");
91+
//}
92+
//else if (folderExists == true && File.Exists(csprojFile) == false) // solution only
93+
//{
94+
// csprojFile = Path.Combine(projectPath, projectName + ".sln");
95+
//}
9696

9797
// get last modified date from folder
9898
DateTime? lastUpdated = folderExists ? Tools.GetLastModifiedTime(projectPath) : null;

UnityLauncherPro/GetUnityInstallations.cs

+15
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ public static UnityInstallation[] Scan()
5151
unity.Path = exePath;
5252
unity.Installed = installDate;
5353
unity.IsPreferred = (version == MainWindow.preferredVersion);
54+
unity.ProjectCount = GetProjectCountForUnityVersion(version);
5455

5556
// get platforms, NOTE if this is slow, do it later, or skip for commandline
5657
var platforms = GetPlatforms(dataFolder);
@@ -98,5 +99,19 @@ static string[] GetPlatforms(string dataFolder)
9899

99100
return directories;
100101
}
102+
103+
static int GetProjectCountForUnityVersion(string version)
104+
{
105+
if (MainWindow.projectsSource == null) return 0;
106+
//Console.WriteLine("xxx "+(MainWindow.projectsSource==null));
107+
int count = 0;
108+
// count projects using this exact version
109+
for (int i = 0, len = MainWindow.projectsSource.Count; i < len; i++)
110+
{
111+
if (MainWindow.projectsSource[i].Version == version) count++;
112+
}
113+
return count;
114+
}
115+
101116
} // class
102117
} // namespace

UnityLauncherPro/MainWindow.xaml

+1
Original file line numberDiff line numberDiff line change
@@ -620,6 +620,7 @@
620620
<DataGridTextColumn Binding="{Binding Path}" ClipboardContentBinding="{x:Null}" Header="Path" IsReadOnly="True"/>
621621
<DataGridTextColumn Binding="{Binding Installed, StringFormat=\{0:dd/MM/yyyy HH:mm:ss\}}" ClipboardContentBinding="{x:Null}" Header="Installed" IsReadOnly="True"/>
622622
<DataGridTextColumn Binding="{Binding PlatformsCombined}" ClipboardContentBinding="{x:Null}" Header="Platforms" IsReadOnly="True"/>
623+
<DataGridTextColumn Binding="{Binding ProjectCount}" ClipboardContentBinding="{x:Null}" Header="Projects" IsReadOnly="True"/>
623624
</DataGrid.Columns>
624625

625626
<!-- right click context menu -->

UnityLauncherPro/MainWindow.xaml.cs

+3-7
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public partial class MainWindow : Window
3636
static extern bool OpenIcon(IntPtr hWnd);
3737

3838
// datagrid sources
39-
List<Project> projectsSource;
39+
public static List<Project> projectsSource;
4040
Updates[] updatesSource;
4141
public static UnityInstallation[] unityInstallationsSource;
4242

@@ -78,7 +78,6 @@ void Start()
7878
// get unity installations
7979
dataGridUnitys.Items.Clear();
8080
UpdateUnityInstallationsList();
81-
8281
HandleCommandLineLaunch();
8382

8483
// check for duplicate instance, and activate that instead
@@ -93,10 +92,6 @@ void Start()
9392
}
9493
}
9594

96-
// TEST platform combobox
97-
// var test = new string[] { "1", "2", "3" };
98-
// cmbPlatform.ItemsSource = test;
99-
10095
// update projects list
10196
projectsSource = GetProjects.Scan(getGitBranch: (bool)chkShowGitBranchColumn.IsChecked, getArguments: (bool)chkShowLauncherArgumentsColumn.IsChecked, showMissingFolders: (bool)chkShowMissingFolderProjects.IsChecked, showTargetPlatform: (bool)chkShowPlatform.IsChecked);
10297
gridRecent.Items.Clear();
@@ -393,11 +388,12 @@ void UpdateUnityInstallationsList()
393388
unityInstallationsSource = GetUnityInstallations.Scan();
394389
dataGridUnitys.ItemsSource = unityInstallationsSource;
395390

396-
// make dictionary of installed unitys, to search faster
391+
// also make dictionary of installed unitys, to search faster
397392
unityInstalledVersions.Clear();
398393
for (int i = 0, len = unityInstallationsSource.Length; i < len; i++)
399394
{
400395
var version = unityInstallationsSource[i].Version;
396+
// NOTE cannot have same version id in 2 places with this
401397
if (string.IsNullOrEmpty(version) == false && unityInstalledVersions.ContainsKey(version) == false)
402398
{
403399
unityInstalledVersions.Add(version, unityInstallationsSource[i].Path);

0 commit comments

Comments
 (0)