diff --git a/UnityLauncherPro/Data/Project.cs b/UnityLauncherPro/Data/Project.cs index 6bf8621..5f422d3 100644 --- a/UnityLauncherPro/Data/Project.cs +++ b/UnityLauncherPro/Data/Project.cs @@ -16,6 +16,7 @@ public class Project : IValueConverter public string TargetPlatform { set; get; } // TODO rename to Platform public string[] TargetPlatforms { set; get; } public bool folderExists { set; get; } + public string SRP { set; get; } // Scriptable Render Pipeline, TODO add version info? // WPF keeps calling this method from AppendFormatHelper, GetNameCore..? not sure if need to return something else or default would be faster? public override string ToString() diff --git a/UnityLauncherPro/Data/UnityInstallation.cs b/UnityLauncherPro/Data/UnityInstallation.cs index 3647bf6..c43d7f8 100644 --- a/UnityLauncherPro/Data/UnityInstallation.cs +++ b/UnityLauncherPro/Data/UnityInstallation.cs @@ -9,13 +9,10 @@ public class UnityInstallation : IValueConverter public long VersionCode { set; get; } // version as number, cached for sorting public string Path { set; get; } // exe path public DateTime? Installed { set; get; } - public string PlatformsCombined { set; get; } public string[] Platforms { set; get; } public int ProjectCount { set; get; } - public bool IsPreferred { set; get; } - public string ReleaseType { set; get; } // Alpha, Beta, LTS.. TODO could be enum // https://stackoverflow.com/a/5551986/5452781 diff --git a/UnityLauncherPro/GetProjects.cs b/UnityLauncherPro/GetProjects.cs index caa05a9..19f1a17 100644 --- a/UnityLauncherPro/GetProjects.cs +++ b/UnityLauncherPro/GetProjects.cs @@ -15,7 +15,7 @@ public static class GetProjects // convert target platform name into valid buildtarget platform name, NOTE this depends on unity version, now only 2019 and later are supported public static Dictionary remapPlatformNames = new Dictionary { { "StandaloneWindows64", "Win64" }, { "StandaloneWindows", "Win" }, { "Android", "Android" }, { "WebGL", "WebGL" } }; - public static List Scan(bool getGitBranch = false, bool getPlasticBranch = false, bool getArguments = false, bool showMissingFolders = false, bool showTargetPlatform = false, StringCollection AllProjectPaths = null, bool searchGitbranchRecursivly = false) + public static List Scan(bool getGitBranch = false, bool getPlasticBranch = false, bool getArguments = false, bool showMissingFolders = false, bool showTargetPlatform = false, StringCollection AllProjectPaths = null, bool searchGitbranchRecursivly = false, bool showSRP = false) { List projectsFound = new List(); @@ -53,7 +53,7 @@ public static List Scan(bool getGitBranch = false, bool getPlasticBranc projectPath = (string)key.GetValue(valueName); } - var p = GetProjectInfo(projectPath, getGitBranch, getPlasticBranch, getArguments, showMissingFolders, showTargetPlatform, searchGitbranchRecursivly); + var p = GetProjectInfo(projectPath, getGitBranch, getPlasticBranch, getArguments, showMissingFolders, showTargetPlatform, searchGitbranchRecursivly, showSRP); //Console.WriteLine(projectPath+" "+p.TargetPlatform); // if want to hide project and folder path for screenshot @@ -94,7 +94,7 @@ public static List Scan(bool getGitBranch = false, bool getPlasticBranc // if not found from registry, add to recent projects list if (found == false) { - var p = GetProjectInfo(projectPath, getGitBranch, getPlasticBranch, getArguments, showMissingFolders, showTargetPlatform, searchGitbranchRecursivly); + var p = GetProjectInfo(projectPath, getGitBranch, getPlasticBranch, getArguments, showMissingFolders, showTargetPlatform, searchGitbranchRecursivly, showSRP); if (p != null) projectsFound.Add(p); } } @@ -121,7 +121,7 @@ public static List Scan(bool getGitBranch = false, bool getPlasticBranc return projectsFound; } // Scan() - static Project GetProjectInfo(string projectPath, bool getGitBranch = false, bool getPlasticBranch = false, bool getArguments = false, bool showMissingFolders = false, bool showTargetPlatform = false, bool searchGitbranchRecursivly = false) + static Project GetProjectInfo(string projectPath, bool getGitBranch = false, bool getPlasticBranch = false, bool getArguments = false, bool showMissingFolders = false, bool showTargetPlatform = false, bool searchGitbranchRecursivly = false, bool showSRP = false) { bool folderExists = Directory.Exists(projectPath); @@ -209,6 +209,9 @@ static Project GetProjectInfo(string projectPath, bool getGitBranch = false, boo // bubblegum(TM) solution, fill available platforms for this unity version, for this project p.TargetPlatforms = Tools.GetPlatformsForUnityVersion(projectVersion); p.folderExists = folderExists; + + if (showSRP == true) p.SRP = Tools.GetSRP(projectPath); + return p; } diff --git a/UnityLauncherPro/MainWindow.xaml b/UnityLauncherPro/MainWindow.xaml index 142a045..594a42d 100644 --- a/UnityLauncherPro/MainWindow.xaml +++ b/UnityLauncherPro/MainWindow.xaml @@ -183,6 +183,13 @@ + + + + + + + @@ -739,6 +746,7 @@ + diff --git a/UnityLauncherPro/MainWindow.xaml.cs b/UnityLauncherPro/MainWindow.xaml.cs index 705abe1..91b892f 100644 --- a/UnityLauncherPro/MainWindow.xaml.cs +++ b/UnityLauncherPro/MainWindow.xaml.cs @@ -148,7 +148,7 @@ void Start() //Properties.Settings.Default.projectPaths = null; //Properties.Settings.Default.Save(); - projectsSource = GetProjects.Scan(getGitBranch: (bool)chkShowGitBranchColumn.IsChecked, getPlasticBranch: (bool)chkCheckPlasticBranch.IsChecked, getArguments: (bool)chkShowLauncherArgumentsColumn.IsChecked, showMissingFolders: (bool)chkShowMissingFolderProjects.IsChecked, showTargetPlatform: (bool)chkShowPlatform.IsChecked, AllProjectPaths: Properties.Settings.Default.projectPaths, searchGitbranchRecursivly: (bool)chkGetGitBranchRecursively.IsChecked); + projectsSource = GetProjects.Scan(getGitBranch: (bool)chkShowGitBranchColumn.IsChecked, getPlasticBranch: (bool)chkCheckPlasticBranch.IsChecked, getArguments: (bool)chkShowLauncherArgumentsColumn.IsChecked, showMissingFolders: (bool)chkShowMissingFolderProjects.IsChecked, showTargetPlatform: (bool)chkShowPlatform.IsChecked, AllProjectPaths: Properties.Settings.Default.projectPaths, searchGitbranchRecursivly: (bool)chkGetGitBranchRecursively.IsChecked, showSRP: (bool)chkCheckSRP.IsChecked); //Console.WriteLine("projectsSource.Count: " + projectsSource.Count); @@ -453,6 +453,7 @@ void LoadSettings() chkEnableProjectRename.IsChecked = Settings.Default.enableProjectRename; chkStreamerMode.IsChecked = Settings.Default.streamerMode; chkShowPlatform.IsChecked = Settings.Default.showTargetPlatform; + chkCheckSRP.IsChecked = Settings.Default.checkSRP; chkUseCustomTheme.IsChecked = Settings.Default.useCustomTheme; txtRootFolderForNewProjects.Text = Settings.Default.newProjectsRoot; txtWebglRelativePath.Text = Settings.Default.webglBuildPath; @@ -467,6 +468,7 @@ void LoadSettings() gridRecent.Columns[4].Visibility = (bool)chkShowLauncherArgumentsColumn.IsChecked ? Visibility.Visible : Visibility.Collapsed; gridRecent.Columns[5].Visibility = (bool)chkShowGitBranchColumn.IsChecked ? Visibility.Visible : Visibility.Collapsed; gridRecent.Columns[6].Visibility = (bool)chkShowPlatform.IsChecked ? Visibility.Visible : Visibility.Collapsed; + gridRecent.Columns[7].Visibility = (bool)chkCheckSRP.IsChecked ? Visibility.Visible : Visibility.Collapsed; // update installations folder listbox lstRootFolders.Items.Clear(); @@ -654,9 +656,9 @@ private void SaveSettingsOnExit() List gridWidths; // if we dont have any settings yet - if (Properties.Settings.Default.gridColumnWidths != null) + if (Settings.Default.gridColumnWidths != null) { - gridWidths = new List(Properties.Settings.Default.gridColumnWidths); + gridWidths = new List(Settings.Default.gridColumnWidths); } else { @@ -667,7 +669,7 @@ private void SaveSettingsOnExit() var column = gridRecent.Columns[0]; for (int i = 0; i < gridRecent.Columns.Count; ++i) { - if (Properties.Settings.Default.gridColumnWidths != null && Properties.Settings.Default.gridColumnWidths.Length > i) + if (Settings.Default.gridColumnWidths != null && Settings.Default.gridColumnWidths.Length > i) { gridWidths[i] = (int)gridRecent.Columns[i].Width.Value; } @@ -676,17 +678,17 @@ private void SaveSettingsOnExit() gridWidths.Add((int)gridRecent.Columns[i].Width.Value); } } - Properties.Settings.Default.gridColumnWidths = gridWidths.ToArray(); - Properties.Settings.Default.Save(); + Settings.Default.gridColumnWidths = gridWidths.ToArray(); + Settings.Default.Save(); // save buildrepot column widths gridWidths.Clear(); // if we dont have any settings yet - if (Properties.Settings.Default.gridColumnWidthsBuildReport != null) + if (Settings.Default.gridColumnWidthsBuildReport != null) { - gridWidths = new List(Properties.Settings.Default.gridColumnWidthsBuildReport); + gridWidths = new List(Settings.Default.gridColumnWidthsBuildReport); } else { @@ -697,7 +699,7 @@ private void SaveSettingsOnExit() column = gridBuildReport.Columns[0]; for (int i = 0; i < gridBuildReport.Columns.Count; ++i) { - if (Properties.Settings.Default.gridColumnWidthsBuildReport != null && Properties.Settings.Default.gridColumnWidthsBuildReport.Length > i) + if (Settings.Default.gridColumnWidthsBuildReport != null && Settings.Default.gridColumnWidthsBuildReport.Length > i) { gridWidths[i] = (int)gridBuildReport.Columns[i].Width.Value; } @@ -706,9 +708,9 @@ private void SaveSettingsOnExit() gridWidths.Add((int)gridBuildReport.Columns[i].Width.Value); } } - Properties.Settings.Default.gridColumnWidthsBuildReport = gridWidths.ToArray(); - Properties.Settings.Default.projectName = projectNameSetting; - Properties.Settings.Default.Save(); + Settings.Default.gridColumnWidthsBuildReport = gridWidths.ToArray(); + Settings.Default.projectName = projectNameSetting; + Settings.Default.Save(); // make backup var config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoamingAndLocal); @@ -813,7 +815,7 @@ public void RefreshRecentProjects() // take currently selected project row lastSelectedProjectIndex = gridRecent.SelectedIndex; // rescan recent projects - projectsSource = GetProjects.Scan(getGitBranch: (bool)chkShowGitBranchColumn.IsChecked, getPlasticBranch: (bool)chkCheckPlasticBranch.IsChecked, getArguments: (bool)chkShowLauncherArgumentsColumn.IsChecked, showMissingFolders: (bool)chkShowMissingFolderProjects.IsChecked, showTargetPlatform: (bool)chkShowPlatform.IsChecked, AllProjectPaths: Settings.Default.projectPaths, searchGitbranchRecursivly: (bool)chkGetGitBranchRecursively.IsChecked); + projectsSource = GetProjects.Scan(getGitBranch: (bool)chkShowGitBranchColumn.IsChecked, getPlasticBranch: (bool)chkCheckPlasticBranch.IsChecked, getArguments: (bool)chkShowLauncherArgumentsColumn.IsChecked, showMissingFolders: (bool)chkShowMissingFolderProjects.IsChecked, showTargetPlatform: (bool)chkShowPlatform.IsChecked, AllProjectPaths: Settings.Default.projectPaths, searchGitbranchRecursivly: (bool)chkGetGitBranchRecursively.IsChecked, showSRP: (bool)chkCheckSRP.IsChecked); gridRecent.ItemsSource = projectsSource; // fix sorting on refresh @@ -3332,6 +3334,12 @@ public int Compare(Object a, Object b) if (((Project)a).TargetPlatform == null) return direction == ListSortDirection.Ascending ? -1 : 1; if (((Project)b).TargetPlatform == null) return direction == ListSortDirection.Ascending ? 1 : -1; return direction == ListSortDirection.Ascending ? ((Project)a).TargetPlatform.CompareTo(((Project)b).TargetPlatform) : ((Project)b).TargetPlatform.CompareTo(((Project)a).TargetPlatform); + case "SRP": + // handle null values + if (((Project)a).SRP == null && ((Project)b).SRP == null) return 0; + if (((Project)a).SRP == null) return direction == ListSortDirection.Ascending ? -1 : 1; + if (((Project)b).SRP == null) return direction == ListSortDirection.Ascending ? 1 : -1; + return direction == ListSortDirection.Ascending ? ((Project)a).SRP.CompareTo(((Project)b).SRP) : ((Project)b).SRP.CompareTo(((Project)a).SRP); default: return 0; } @@ -3798,6 +3806,17 @@ private void CheckCustomIcon() //Debug.WriteLine("Custom icon not found. Using default."); } } + + private void chkCheckSRP_Checked(object sender, RoutedEventArgs e) + { + if (this.IsActive == false) return; // dont run code on window init + + gridRecent.Columns[7].Visibility = (bool)chkCheckSRP.IsChecked ? Visibility.Visible : Visibility.Collapsed; + + Settings.Default.checkSRP = (bool)chkCheckSRP.IsChecked; + Settings.Default.Save(); + RefreshRecentProjects(); + } //private void menuProjectProperties_Click(object sender, RoutedEventArgs e) //{ // var proj = GetSelectedProject(); diff --git a/UnityLauncherPro/Properties/Settings.Designer.cs b/UnityLauncherPro/Properties/Settings.Designer.cs index 080c44a..64fffe5 100644 --- a/UnityLauncherPro/Properties/Settings.Designer.cs +++ b/UnityLauncherPro/Properties/Settings.Designer.cs @@ -577,5 +577,17 @@ public bool useAlphaReleaseNotes { this["useAlphaReleaseNotes"] = value; } } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("False")] + public bool checkSRP { + get { + return ((bool)(this["checkSRP"])); + } + set { + this["checkSRP"] = value; + } + } } } diff --git a/UnityLauncherPro/Properties/Settings.settings b/UnityLauncherPro/Properties/Settings.settings index 1d7323b..b6c2402 100644 --- a/UnityLauncherPro/Properties/Settings.settings +++ b/UnityLauncherPro/Properties/Settings.settings @@ -145,5 +145,8 @@ True + + False + \ No newline at end of file diff --git a/UnityLauncherPro/Tools.cs b/UnityLauncherPro/Tools.cs index 9350ae7..f54b4fe 100644 --- a/UnityLauncherPro/Tools.cs +++ b/UnityLauncherPro/Tools.cs @@ -2287,6 +2287,34 @@ private static async Task DownloadFileAsync(string fileUrl, string destina } return result; } + + internal static string GetSRP(string projectPath) + { + // read projectsettings/graphicsettings file, look for m_SRPDefaultSettings: value + var settingsFile = Path.Combine(projectPath, "ProjectSettings", "GraphicsSettings.asset"); + if (File.Exists(settingsFile) == false) return null; + + var allText = File.ReadAllText(settingsFile); + var srpIndex = allText.IndexOf("m_SRPDefaultSettings:"); + if (srpIndex == -1) return null; // BIRP + + // urp = UnityEngine.Rendering.Universal.UniversalRenderPipeline + // hdrp = UnityEngine.Rendering.HighDefinition.HDRenderPipeline + + if (allText.IndexOf("UnityEngine.Rendering.Universal.UniversalRenderPipeline", srpIndex) > -1) + { + return "URP"; + } + else if (allText.IndexOf("UnityEngine.Rendering.HighDefinition.HDRenderPipeline", srpIndex) > -1) + { + return "HDRP"; + } + else + { + return null; // BIRP + } + + } } // class } // namespace