Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
* dev:
  add SRP column sorting
  add RenderPipeline Column & settings for it, #139
  • Loading branch information
unitycoder committed Nov 29, 2024
2 parents 5a1d062 + b658376 commit 104fd99
Show file tree
Hide file tree
Showing 8 changed files with 91 additions and 20 deletions.
1 change: 1 addition & 0 deletions UnityLauncherPro/Data/Project.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
3 changes: 0 additions & 3 deletions UnityLauncherPro/Data/UnityInstallation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 7 additions & 4 deletions UnityLauncherPro/GetProjects.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, string> remapPlatformNames = new Dictionary<string, string> { { "StandaloneWindows64", "Win64" }, { "StandaloneWindows", "Win" }, { "Android", "Android" }, { "WebGL", "WebGL" } };

public static List<Project> 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<Project> 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<Project> projectsFound = new List<Project>();

Expand Down Expand Up @@ -53,7 +53,7 @@ public static List<Project> 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
Expand Down Expand Up @@ -94,7 +94,7 @@ public static List<Project> 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);
}
}
Expand All @@ -121,7 +121,7 @@ public static List<Project> 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);

Expand Down Expand Up @@ -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;
}

Expand Down
8 changes: 8 additions & 0 deletions UnityLauncherPro/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,13 @@
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>

<DataGridTextColumn Header="SRP" x:Name="txtColumnRenderPipeline" Binding="{Binding SRP}" CellStyle="{StaticResource NoFocusCellStyle}" ClipboardContentBinding="{x:Null}" IsReadOnly="True" Width="50">
<DataGridTextColumn.HeaderTemplate>
<DataTemplate>
<TextBlock Text="SRP" IsHitTestVisible="False" />
</DataTemplate>
</DataGridTextColumn.HeaderTemplate>
</DataGridTextColumn>
</DataGrid.Columns>

<!-- right click context menu -->
Expand Down Expand Up @@ -739,6 +746,7 @@
<CheckBox x:Name="chkCheckPlasticBranch" Content="Check Plastic branch" ToolTip="Checks for plastic branch, if .git doesnt exists" HorizontalAlignment="Left" Margin="14,0,0,3" Checked="ChkCheckPlasticBranch_Checked" Unchecked="ChkCheckPlasticBranch_Checked"/>
</StackPanel>
<CheckBox x:Name="chkAskNameForQuickProject" Content="Ask name for New Project" Checked="ChkAskNameForQuickProject_Checked" Unchecked="ChkAskNameForQuickProject_Checked" ToolTip="If disabled, uses automatic quick project naming (Should be enabled, unless you want instant project creation)" HorizontalAlignment="Left"/>
<CheckBox x:Name="chkCheckSRP" Content="Show SRP column" ToolTip="If disabled, uses automatic quick project naming (Should be enabled, unless you want instant project creation)" HorizontalAlignment="Left" Checked="chkCheckSRP_Checked" Unchecked="chkCheckSRP_Checked"/>
<CheckBox x:Name="chkShowMissingFolderProjects" Content="Show projects that don't exist on disk" Checked="ChkShowMissingFolderProjects_CheckedChanged" Unchecked="ChkShowMissingFolderProjects_CheckedChanged" ToolTip="List in recent projects, even if the project folder is missing" HorizontalAlignment="Left"/>
<CheckBox x:Name="chkShowLauncherArgumentsColumn" Content="Show commandline arguments column" Unchecked="ChkShowLauncherArgumentsColumn_CheckedChanged" Checked="ChkShowLauncherArgumentsColumn_CheckedChanged" ToolTip="Shows column for custom project commandline params" HorizontalAlignment="Left"/>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Left">
Expand Down
45 changes: 32 additions & 13 deletions UnityLauncherPro/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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;
Expand All @@ -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();
Expand Down Expand Up @@ -654,9 +656,9 @@ private void SaveSettingsOnExit()
List<int> gridWidths;

// if we dont have any settings yet
if (Properties.Settings.Default.gridColumnWidths != null)
if (Settings.Default.gridColumnWidths != null)
{
gridWidths = new List<int>(Properties.Settings.Default.gridColumnWidths);
gridWidths = new List<int>(Settings.Default.gridColumnWidths);
}
else
{
Expand All @@ -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;
}
Expand All @@ -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<int>(Properties.Settings.Default.gridColumnWidthsBuildReport);
gridWidths = new List<int>(Settings.Default.gridColumnWidthsBuildReport);
}
else
{
Expand All @@ -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;
}
Expand All @@ -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);
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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();
Expand Down
12 changes: 12 additions & 0 deletions UnityLauncherPro/Properties/Settings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions UnityLauncherPro/Properties/Settings.settings
Original file line number Diff line number Diff line change
Expand Up @@ -145,5 +145,8 @@
<Setting Name="useAlphaReleaseNotes" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">True</Value>
</Setting>
<Setting Name="checkSRP" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">False</Value>
</Setting>
</Settings>
</SettingsFile>
28 changes: 28 additions & 0 deletions UnityLauncherPro/Tools.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2287,6 +2287,34 @@ private static async Task<bool> 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

0 comments on commit 104fd99

Please sign in to comment.