Skip to content

Commit 2ad9bf0

Browse files
committed
add target platform column (checked from Assembly-CSharp.csproj) and setting, rename GITBranch column header to Branch
1 parent fdb5bf4 commit 2ad9bf0

File tree

7 files changed

+83
-8
lines changed

7 files changed

+83
-8
lines changed

UnityLauncherPro/App.config

+3
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@
6363
<setting name="streamerMode" serializeAs="String">
6464
<value>False</value>
6565
</setting>
66+
<setting name="showTargetPlatform" serializeAs="String">
67+
<value>False</value>
68+
</setting>
6669
</UnityLauncherPro.Properties.Settings>
6770
</userSettings>
6871
</configuration>

UnityLauncherPro/Data/Project.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,12 @@ public class Project
1111
public DateTime? Modified { set; get; }
1212
public string Arguments { set; get; }
1313
public string GITBranch { set; get; }
14+
public string TargetPlatform { set; get; }
1415
public Process Process; // launched unity exe
1516

1617
public override string ToString()
1718
{
18-
return $"{Title} {Version} {Path} {Modified} {Arguments} {GITBranch} ";
19+
return $"{Title} {Version} {Path} {Modified} {Arguments} {GITBranch} {TargetPlatform}";
1920
}
2021

2122
}

UnityLauncherPro/GetProjects.cs

+34-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public static class GetProjects
1111
// which registries we want to scan for projects
1212
static readonly string[] registryPathsToCheck = new string[] { @"SOFTWARE\Unity Technologies\Unity Editor 5.x", @"SOFTWARE\Unity Technologies\Unity Editor 4.x" };
1313

14-
public static List<Project> Scan(bool getGitBranch = false, bool getArguments = false, bool showMissingFolders = false)
14+
public static List<Project> Scan(bool getGitBranch = false, bool getArguments = false, bool showMissingFolders = false, bool showTargetPlatform = false)
1515
{
1616
List<Project> projectsFound = new List<Project>();
1717

@@ -86,7 +86,7 @@ public static List<Project> Scan(bool getGitBranch = false, bool getArguments =
8686
csprojFile = Path.Combine(projectPath, projectName + ".Editor.csproj");
8787
}
8888

89-
// maybe 4.x project
89+
// maybe 4.x project, NOTE recent versions also have this as default
9090
if (File.Exists(csprojFile) == false)
9191
{
9292
csprojFile = Path.Combine(projectPath, "Assembly-CSharp.csproj");
@@ -112,13 +112,45 @@ public static List<Project> Scan(bool getGitBranch = false, bool getArguments =
112112
gitBranch = Tools.ReadGitBranchInfo(projectPath);
113113
}
114114

115+
// TODO add option to disable check
116+
string targetPlatform = "";
117+
if (showTargetPlatform == true)
118+
{
119+
// get buildtarget from .csproj
120+
// <UnityBuildTarget>StandaloneWindows64:19</UnityBuildTarget>
121+
// get main csproj file
122+
var csproj = Path.Combine(projectPath, "Assembly-CSharp.csproj");
123+
// TODO check projname also, if no assembly-.., NOTE already checked above
124+
//var csproj = Path.Combine(projectPath, projectName + ".csproj");
125+
if (File.Exists(csproj))
126+
{
127+
var csprojtxt = File.ReadAllText(csproj);
128+
var csprojsplit = csprojtxt.Split(new[] { "<UnityBuildTarget>" }, StringSplitOptions.None);
129+
if (csprojsplit != null && csprojsplit.Length > 1)
130+
{
131+
var endrow = csprojsplit[1].IndexOf(":");
132+
if (endrow > -1)
133+
{
134+
Console.WriteLine("build target: " + csprojsplit[1].Substring(0, endrow));
135+
// 5.6 : win32, win64, osx, linux, linux64, ios, android, web, webstreamed, webgl, xboxone, ps4, psp2, wsaplayer, tizen, samsungtv
136+
// 2017: standalone, Win, Win64, OSXUniversal, Linux, Linux64, LinuxUniversal, iOS, Android, Web, WebStreamed, WebGL, XboxOne, PS4, PSP2, WindowsStoreApps, Switch, WiiU, N3DS, tvOS, PSM
137+
// 2018: standalone, Win, Win64, OSXUniversal, Linux, Linux64, LinuxUniversal, iOS, Android, Web, WebStreamed, WebGL, XboxOne, PS4, WindowsStoreApps, Switch, N3DS, tvOS
138+
// 2019: Standalone, Win, Win64, OSXUniversal, Linux64, iOS, Android, WebGL, XboxOne, PS4, WindowsStoreApps, Switch, tvOS
139+
// 2020: Standalone, Win, Win64, OSXUniversal, Linux64, iOS, Android, WebGL, XboxOne, PS4, WindowsStoreApps, Switch, tvOS
140+
targetPlatform = csprojsplit[1].Substring(0, endrow);
141+
}
142+
}
143+
}
144+
}
145+
115146
var p = new Project();
116147
p.Title = projectName;
117148
p.Version = projectVersion;
118149
p.Path = projectPath;
119150
p.Modified = lastUpdated;
120151
p.Arguments = customArgs;
121152
p.GITBranch = gitBranch;
153+
p.TargetPlatform = targetPlatform;
122154

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

UnityLauncherPro/MainWindow.xaml

+4-1
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,9 @@
322322
<DataGridTextColumn x:Name="txtColumnName" CellStyle="{StaticResource NoFocusCellStyle}" Binding="{Binding Path}" ClipboardContentBinding="{x:Null}" Header="Path" IsReadOnly="True" Width="185"/>
323323
<DataGridTextColumn CellStyle="{StaticResource NoFocusCellStyle}" Binding="{Binding Modified, StringFormat=\{0:dd/MM/yyyy HH:mm:ss\}}" ClipboardContentBinding="{x:Null}" Header="Modified" IsReadOnly="True" Width="120"/>
324324
<DataGridTextColumn CellStyle="{StaticResource NoFocusCellStyle}" Binding="{Binding Arguments}" ClipboardContentBinding="{x:Null}" Header="Arguments" IsReadOnly="False" Width="100"/>
325-
<DataGridTextColumn CellStyle="{StaticResource NoFocusCellStyle}" Binding="{Binding GITBranch}" ClipboardContentBinding="{x:Null}" Header="GITBranch" IsReadOnly="True" Width="100"/>
325+
<DataGridTextColumn CellStyle="{StaticResource NoFocusCellStyle}" Binding="{Binding GITBranch}" ClipboardContentBinding="{x:Null}" Header="Branch" IsReadOnly="True" Width="100"/>
326+
<!--TODO platform as dropdown?-->
327+
<DataGridTextColumn CellStyle="{StaticResource NoFocusCellStyle}" Binding="{Binding TargetPlatform}" ClipboardContentBinding="{x:Null}" Header="Platform" IsReadOnly="True" Width="100"/>
326328
</DataGrid.Columns>
327329

328330
<!-- right click context menu -->
@@ -686,6 +688,7 @@
686688
<CheckBox x:Name="chkEnableProjectRename" Content="Enable Project Renaming (Not recommended for beginners)" Foreground="{DynamicResource ButtonForeground}" Margin="0,0,0,3" ToolTip="Can use F2 to rename project folders, Note that project will disappears from list on refresh, unless you open it (since its new path, not in unity recent projects registry)" Checked="ChkEnableProjectRename_Checked" Unchecked="ChkEnableProjectRename_Checked"/>
687689
<CheckBox x:Name="chkAskNameForQuickProject" Content="Ask name for New Project" Foreground="{DynamicResource ButtonForeground}" Checked="ChkAskNameForQuickProject_Checked" Unchecked="ChkAskNameForQuickProject_Checked" Margin="0,0,0,3" ToolTip="If disabled, uses automatic quick project naming"/>
688690
<CheckBox x:Name="chkStreamerMode" Content="Streamer Mode (hide project names and folders)" Foreground="{DynamicResource ButtonForeground}" Margin="0,0,0,3" ToolTip="" Checked="ChkStreamerMode_Checked" Unchecked="ChkStreamerMode_Checked"/>
691+
<CheckBox x:Name="chkShowPlatform" Content="Show current target platform (if exists in .csproj)" Foreground="{DynamicResource ButtonForeground}" Margin="0,0,0,3" ToolTip="" Checked="ChkShowPlatform_Checked" Unchecked="ChkShowPlatform_Checked"/>
689692

690693
<StackPanel Grid.Row="3" Orientation="Horizontal">
691694
<Label Content="Root Folder for New Projects" Foreground="{DynamicResource ButtonForeground}" />

UnityLauncherPro/MainWindow.xaml.cs

+25-4
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ void Start()
8585
}
8686

8787
// update projects list
88-
projectsSource = GetProjects.Scan(getGitBranch: (bool)chkShowGitBranchColumn.IsChecked, getArguments: (bool)chkShowLauncherArgumentsColumn.IsChecked, showMissingFolders: (bool)chkShowMissingFolderProjects.IsChecked);
88+
projectsSource = GetProjects.Scan(getGitBranch: (bool)chkShowGitBranchColumn.IsChecked, getArguments: (bool)chkShowLauncherArgumentsColumn.IsChecked, showMissingFolders: (bool)chkShowMissingFolderProjects.IsChecked, showTargetPlatform: (bool)chkShowPlatform.IsChecked);
8989
gridRecent.Items.Clear();
9090
gridRecent.ItemsSource = projectsSource;
9191

@@ -251,10 +251,12 @@ void LoadSettings()
251251
chkAskNameForQuickProject.IsChecked = Properties.Settings.Default.askNameForQuickProject;
252252
chkEnableProjectRename.IsChecked = Properties.Settings.Default.enableProjectRename;
253253
chkStreamerMode.IsChecked = Properties.Settings.Default.streamerMode;
254+
chkShowPlatform.IsChecked = Properties.Settings.Default.showTargetPlatform;
254255

255256
// update optional grid columns, hidden or visible
256257
gridRecent.Columns[4].Visibility = (bool)chkShowLauncherArgumentsColumn.IsChecked ? Visibility.Visible : Visibility.Collapsed;
257258
gridRecent.Columns[5].Visibility = (bool)chkShowGitBranchColumn.IsChecked ? Visibility.Visible : Visibility.Collapsed;
259+
gridRecent.Columns[6].Visibility = (bool)chkShowPlatform.IsChecked ? Visibility.Visible : Visibility.Collapsed;
258260

259261
// update installations folder listbox
260262
lstRootFolders.Items.Clear();
@@ -409,7 +411,7 @@ void RefreshRecentProjects()
409411
// take currently selected project row
410412
lastSelectedProjectIndex = gridRecent.SelectedIndex;
411413
// rescan recent projects
412-
projectsSource = GetProjects.Scan(getGitBranch: (bool)chkShowGitBranchColumn.IsChecked, getArguments: (bool)chkShowLauncherArgumentsColumn.IsChecked, showMissingFolders: (bool)chkShowMissingFolderProjects.IsChecked);
414+
projectsSource = GetProjects.Scan(getGitBranch: (bool)chkShowGitBranchColumn.IsChecked, getArguments: (bool)chkShowLauncherArgumentsColumn.IsChecked, showMissingFolders: (bool)chkShowMissingFolderProjects.IsChecked, showTargetPlatform: (bool)chkShowPlatform.IsChecked);
413415
gridRecent.ItemsSource = projectsSource;
414416
// focus back
415417
Tools.SetFocusToGrid(gridRecent, lastSelectedProjectIndex);
@@ -1050,6 +1052,7 @@ private void ChkShowGitBranchColumn_CheckedChanged(object sender, RoutedEventArg
10501052
gridRecent.Columns[5].Visibility = (bool)chkShowGitBranchColumn.IsChecked ? Visibility.Visible : Visibility.Collapsed;
10511053
}
10521054

1055+
10531056
private void ChkQuitAfterOpen_CheckedChanged(object sender, RoutedEventArgs e)
10541057
{
10551058
Properties.Settings.Default.closeAfterProject = (bool)chkQuitAfterOpen.IsChecked;
@@ -1385,7 +1388,7 @@ private void ChkAskNameForQuickProject_Checked(object sender, RoutedEventArgs e)
13851388
bool isInitializing = true; // used to avoid doing things while still starting up
13861389
private void ChkStreamerMode_Checked(object sender, RoutedEventArgs e)
13871390
{
1388-
var isChecked = (bool)chkStreamerMode.IsChecked;
1391+
var isChecked = (bool)((CheckBox)sender).IsChecked;
13891392

13901393
Properties.Settings.Default.streamerMode = isChecked;
13911394
Properties.Settings.Default.Save();
@@ -1396,7 +1399,23 @@ private void ChkStreamerMode_Checked(object sender, RoutedEventArgs e)
13961399
txtColumnTitle.CellStyle = isChecked ? cellStyle : null;
13971400
txtColumnName.CellStyle = isChecked ? cellStyle : null;
13981401

1399-
// need to reload list if user clicked
1402+
// need to reload list if user changed setting
1403+
if (isInitializing == false)
1404+
{
1405+
RefreshRecentProjects();
1406+
}
1407+
}
1408+
1409+
private void ChkShowPlatform_Checked(object sender, RoutedEventArgs e)
1410+
{
1411+
var isChecked = (bool)((CheckBox)sender).IsChecked;
1412+
1413+
Properties.Settings.Default.showTargetPlatform = isChecked;
1414+
Properties.Settings.Default.Save();
1415+
1416+
gridRecent.Columns[6].Visibility = (bool)chkShowPlatform.IsChecked ? Visibility.Visible : Visibility.Collapsed;
1417+
1418+
// need to reload list if user changed setting
14001419
if (isInitializing == false)
14011420
{
14021421
RefreshRecentProjects();
@@ -1606,6 +1625,8 @@ private void BtnClearBuildReport_Click(object sender, RoutedEventArgs e)
16061625
{
16071626
gridBuildReport.ItemsSource = null;
16081627
}
1628+
1629+
16091630
} // class
16101631
} //namespace
16111632

UnityLauncherPro/Properties/Settings.Designer.cs

+12
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

UnityLauncherPro/Properties/Settings.settings

+3
Original file line numberDiff line numberDiff line change
@@ -56,5 +56,8 @@
5656
<Setting Name="streamerMode" Type="System.Boolean" Scope="User">
5757
<Value Profile="(Default)">False</Value>
5858
</Setting>
59+
<Setting Name="showTargetPlatform" Type="System.Boolean" Scope="User">
60+
<Value Profile="(Default)">False</Value>
61+
</Setting>
5962
</Settings>
6063
</SettingsFile>

0 commit comments

Comments
 (0)