Skip to content

Commit d824a1f

Browse files
committed
move parsetargetplatform to tools, read git and platform for Add Project,
1 parent 2ad9bf0 commit d824a1f

File tree

4 files changed

+46
-25
lines changed

4 files changed

+46
-25
lines changed

Diff for: UnityLauncherPro/GetProjects.cs

+2-25
Original file line numberDiff line numberDiff line change
@@ -11,6 +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+
// TODO separate scan and folders
1415
public static List<Project> Scan(bool getGitBranch = false, bool getArguments = false, bool showMissingFolders = false, bool showTargetPlatform = false)
1516
{
1617
List<Project> projectsFound = new List<Project>();
@@ -116,31 +117,7 @@ public static List<Project> Scan(bool getGitBranch = false, bool getArguments =
116117
string targetPlatform = "";
117118
if (showTargetPlatform == true)
118119
{
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-
}
120+
targetPlatform = Tools.ParseTargetPlatform(projectPath);
144121
}
145122

146123
var p = new Project();

Diff for: UnityLauncherPro/MainWindow.xaml

+2
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,8 @@
325325
<DataGridTextColumn CellStyle="{StaticResource NoFocusCellStyle}" Binding="{Binding GITBranch}" ClipboardContentBinding="{x:Null}" Header="Branch" IsReadOnly="True" Width="100"/>
326326
<!--TODO platform as dropdown?-->
327327
<DataGridTextColumn CellStyle="{StaticResource NoFocusCellStyle}" Binding="{Binding TargetPlatform}" ClipboardContentBinding="{x:Null}" Header="Platform" IsReadOnly="True" Width="100"/>
328+
<!--<DataGridComboBoxColumn x:Name="cmbPlatform" CellStyle="{StaticResource NoFocusCellStyle}" SelectedItemBinding="{Binding TargetPlatform, NotifyOnSourceUpdated=True, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" ClipboardContentBinding="{x:Null}" Header="Platform" IsReadOnly="True" Width="100"/>-->
329+
<DataGridComboBoxColumn x:Name="cmbPlatform" CellStyle="{StaticResource NoFocusCellStyle}" ClipboardContentBinding="{x:Null}" Header="Platform" IsReadOnly="True" Width="100"/>
328330
</DataGrid.Columns>
329331

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

Diff for: UnityLauncherPro/MainWindow.xaml.cs

+9
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,10 @@ void Start()
8484
}
8585
}
8686

87+
// TEST platform combobox
88+
// var test = new string[] { "1", "2", "3" };
89+
// cmbPlatform.ItemsSource = test;
90+
8791
// update projects list
8892
projectsSource = GetProjects.Scan(getGitBranch: (bool)chkShowGitBranchColumn.IsChecked, getArguments: (bool)chkShowLauncherArgumentsColumn.IsChecked, showMissingFolders: (bool)chkShowMissingFolderProjects.IsChecked, showTargetPlatform: (bool)chkShowPlatform.IsChecked);
8993
gridRecent.Items.Clear();
@@ -454,6 +458,9 @@ private void BtnAddProjectFolder_Click(object sender, RoutedEventArgs e)
454458
p.Title = Path.GetFileName(folder);
455459
p.Version = Tools.GetProjectVersion(folder);
456460
p.Arguments = Tools.ReadCustomLaunchArguments(folder, MainWindow.launcherArgumentsFile);
461+
if ((bool)chkShowPlatform.IsChecked == true) p.TargetPlatform = Tools.ParseTargetPlatform(folder);
462+
if ((bool)chkShowGitBranchColumn.IsChecked == true) p.GITBranch = Tools.ReadGitBranchInfo(folder);
463+
457464
// add to list
458465
projectsSource.Insert(0, p);
459466
gridRecent.Items.Refresh();
@@ -1388,6 +1395,8 @@ private void ChkAskNameForQuickProject_Checked(object sender, RoutedEventArgs e)
13881395
bool isInitializing = true; // used to avoid doing things while still starting up
13891396
private void ChkStreamerMode_Checked(object sender, RoutedEventArgs e)
13901397
{
1398+
// TODO add "(streamer mode)" text in statusbar
1399+
13911400
var isChecked = (bool)((CheckBox)sender).IsChecked;
13921401

13931402
Properties.Settings.Default.streamerMode = isChecked;

Diff for: UnityLauncherPro/Tools.cs

+33
Original file line numberDiff line numberDiff line change
@@ -687,6 +687,39 @@ public static string ReadGitBranchInfo(string projectPath)
687687
return results;
688688
}
689689

690+
public static string ParseTargetPlatform(string projectPath)
691+
{
692+
string results = null;
693+
694+
// get buildtarget from .csproj
695+
// <UnityBuildTarget>StandaloneWindows64:19</UnityBuildTarget>
696+
// get main csproj file
697+
var csproj = Path.Combine(projectPath, "Assembly-CSharp.csproj");
698+
// TODO check projname also, if no assembly-.., NOTE already checked above
699+
//var csproj = Path.Combine(projectPath, projectName + ".csproj");
700+
if (File.Exists(csproj))
701+
{
702+
var csprojtxt = File.ReadAllText(csproj);
703+
var csprojsplit = csprojtxt.Split(new[] { "<UnityBuildTarget>" }, StringSplitOptions.None);
704+
if (csprojsplit != null && csprojsplit.Length > 1)
705+
{
706+
var endrow = csprojsplit[1].IndexOf(":");
707+
if (endrow > -1)
708+
{
709+
//Console.WriteLine("build target: " + csprojsplit[1].Substring(0, endrow));
710+
// 5.6 : win32, win64, osx, linux, linux64, ios, android, web, webstreamed, webgl, xboxone, ps4, psp2, wsaplayer, tizen, samsungtv
711+
// 2017: standalone, Win, Win64, OSXUniversal, Linux, Linux64, LinuxUniversal, iOS, Android, Web, WebStreamed, WebGL, XboxOne, PS4, PSP2, WindowsStoreApps, Switch, WiiU, N3DS, tvOS, PSM
712+
// 2018: standalone, Win, Win64, OSXUniversal, Linux, Linux64, LinuxUniversal, iOS, Android, Web, WebStreamed, WebGL, XboxOne, PS4, WindowsStoreApps, Switch, N3DS, tvOS
713+
// 2019: Standalone, Win, Win64, OSXUniversal, Linux64, iOS, Android, WebGL, XboxOne, PS4, WindowsStoreApps, Switch, tvOS
714+
// 2020: Standalone, Win, Win64, OSXUniversal, Linux64, iOS, Android, WebGL, XboxOne, PS4, WindowsStoreApps, Switch, tvOS
715+
results = csprojsplit[1].Substring(0, endrow);
716+
}
717+
}
718+
}
719+
720+
return results;
721+
}
722+
690723
/// <summary>
691724
/// Searches for a directory beginning with "startPath".
692725
/// If the directory is not found, then parent folders are searched until

0 commit comments

Comments
 (0)