Skip to content

Commit ea9a02a

Browse files
committed
adding Platform selection dropdown (disable for now), rename ParseTargetPlatform to GetTargetPlatform
1 parent 4b2a38a commit ea9a02a

File tree

7 files changed

+65
-21
lines changed

7 files changed

+65
-21
lines changed

UnityLauncherPro/Data/Platform.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
namespace UnityLauncherPro
2+
{
3+
// TODO should display only valid platforms for projects Unity version
4+
public enum Platform
5+
{
6+
Unknown,
7+
Win32, Win64, OSX, Linux, Linux64, iOS, Android, Web, WebStreamed, WebGL, Xboxone, OS4, PSP2, WSAPlayer, Tizen, SamsungTV,
8+
Standalone, Win, OSXuniversal, LinuxUniversal, WindowsStoreApps, @Switch, Wiiu, N3DS, tVoS, PSM,
9+
// manually added
10+
StandaloneWindows, StandaloneWindows64
11+
}
12+
}

UnityLauncherPro/Data/Project.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ public class Project : IValueConverter
1212
public DateTime? Modified { set; get; }
1313
public string Arguments { set; get; }
1414
public string GITBranch { set; get; }
15-
public string TargetPlatform { set; get; }
15+
//public string TargetPlatform { set; get; }
16+
public Platform TargetPlatform { set; get; }
1617
public bool folderExists { set; get; }
1718
public Process Process; // launched unity exe
1819

UnityLauncherPro/GetProjects.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,10 +116,12 @@ public static List<Project> Scan(bool getGitBranch = false, bool getArguments =
116116
}
117117

118118
// TODO add option to disable check
119-
string targetPlatform = "";
119+
//string targetPlatform = "";
120+
Platform targetPlatform = Platform.Unknown;
120121
if (showTargetPlatform == true)
121122
{
122-
targetPlatform = folderExists ? Tools.ParseTargetPlatform(projectPath) : null;
123+
//targetPlatform = folderExists ? Tools.GetTargetPlatform(projectPath) : null;
124+
targetPlatform = folderExists ? Tools.GetTargetPlatform(projectPath) : Platform.Unknown;
123125
}
124126

125127
var p = new Project();
@@ -129,6 +131,7 @@ public static List<Project> Scan(bool getGitBranch = false, bool getArguments =
129131
p.Modified = lastUpdated;
130132
p.Arguments = customArgs;
131133
p.GITBranch = gitBranch;
134+
//p.TargetPlatform = targetPlatform;
132135
p.TargetPlatform = targetPlatform;
133136
p.folderExists = folderExists;
134137

UnityLauncherPro/MainWindow.xaml

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,13 @@
99
Title="UnityLauncherPro" Height="650" Width="600" WindowStartupLocation="CenterScreen" Background="{DynamicResource ThemeDarkestBackground}" MinWidth="600" MinHeight="650" AllowsTransparency="True" WindowStyle="None" Margin="0" KeyDown="OnWindowKeyDown" Closing="Window_Closing" SizeChanged="Window_SizeChanged" Icon="Images/icon.ico" Activated="Window_Activated">
1010
<Window.Resources>
1111

12+
<!-- platform dropdown menu -->
13+
<ObjectDataProvider x:Key="platformEnum" MethodName="GetValues" ObjectType="{x:Type System:Enum}">
14+
<ObjectDataProvider.MethodParameters>
15+
<x:Type Type="local:Platform"/>
16+
</ObjectDataProvider.MethodParameters>
17+
</ObjectDataProvider>
18+
1219
<!-- colors for unity missing installatios -->
1320
<local:UnityInstallation x:Key="VersionInstalledConverter"/>
1421
<local:Project x:Key="ProjectExistsConverter"/>
@@ -337,9 +344,10 @@
337344
<DataGridTextColumn CellStyle="{StaticResource NoFocusCellStyle}" Binding="{Binding Arguments}" ClipboardContentBinding="{x:Null}" Header="Arguments" IsReadOnly="False" Width="100"/>
338345
<DataGridTextColumn CellStyle="{StaticResource NoFocusCellStyle}" Binding="{Binding GITBranch}" ClipboardContentBinding="{x:Null}" Header="Branch" IsReadOnly="True" Width="100"/>
339346
<!--TODO platform as dropdown?-->
340-
<DataGridTextColumn CellStyle="{StaticResource NoFocusCellStyle}" Binding="{Binding TargetPlatform}" ClipboardContentBinding="{x:Null}" Header="Platform" IsReadOnly="True" Width="100"/>
347+
<!--<DataGridTextColumn CellStyle="{StaticResource NoFocusCellStyle}" Binding="{Binding TargetPlatform}" ClipboardContentBinding="{x:Null}" Header="Platform" IsReadOnly="True" Width="100"/>-->
341348
<!--<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"/>-->
342-
<DataGridComboBoxColumn x:Name="cmbPlatform" CellStyle="{StaticResource NoFocusCellStyle}" ClipboardContentBinding="{x:Null}" Header="Platform" IsReadOnly="True" Width="100"/>
349+
<!--<DataGridComboBoxColumn x:Name="cmbPlatform" CellStyle="{StaticResource NoFocusCellStyle}" ClipboardContentBinding="{x:Null}" Header="Platform" IsReadOnly="True" Width="100"/>-->
350+
<DataGridComboBoxColumn Header="Platform" IsReadOnly="True" SelectedItemBinding="{Binding TargetPlatform}" ItemsSource="{Binding Source={StaticResource platformEnum}}" />
343351
</DataGrid.Columns>
344352

345353
<!-- right click context menu -->
@@ -357,7 +365,7 @@
357365
</DataGrid.ContextMenu>
358366

359367
<!-- sample data for testing -->
360-
<local:Project TargetPlatform="C64" GITBranch="Best" Modified="" Title="M dfgh dfghMO" Path="A:/temp" Version="2099.1.2.3" />
368+
<local:Project TargetPlatform="win64" GITBranch="Best" Modified="" Title="M dfgh dfghMO" Path="A:/temp" Version="2099.1.2.3" />
361369
<local:Project GITBranch="" Modified="" Title="asdgdfg" Path="A:/temp" Version="5.6.7f1"/>
362370
<local:Project GITBranch="" Modified="" Title="Mghdfghdf dfghdfgMO" Path="A:/temp" Version="2018.3.13f1"/>
363371
<local:Project GITBranch="" Modified="" Title="MMO" Path="A:/temp" Version="2099.1.2.3"/>

UnityLauncherPro/MainWindow.xaml.cs

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,7 @@ private void BtnAddProjectFolder_Click(object sender, RoutedEventArgs e)
476476
p.Title = Path.GetFileName(folder);
477477
p.Version = Tools.GetProjectVersion(folder);
478478
p.Arguments = Tools.ReadCustomLaunchArguments(folder, MainWindow.launcherArgumentsFile);
479-
if ((bool)chkShowPlatform.IsChecked == true) p.TargetPlatform = Tools.ParseTargetPlatform(folder);
479+
if ((bool)chkShowPlatform.IsChecked == true) p.TargetPlatform = Tools.GetTargetPlatform(folder);
480480
if ((bool)chkShowGitBranchColumn.IsChecked == true) p.GITBranch = Tools.ReadGitBranchInfo(folder);
481481

482482
// add to list
@@ -1112,7 +1112,7 @@ private void BtnOpenGithub_Click(object sender, RoutedEventArgs e)
11121112
Process.Start(githubURL);
11131113
}
11141114

1115-
// finished editing project name cell or launcher argument cell
1115+
// finished editing project name cell or launcher argument cell or platform cells
11161116
private void GridRecent_CellEditEnding(object sender, DataGridCellEditEndingEventArgs e)
11171117
{
11181118
// avoid ending event running twice
@@ -1124,16 +1124,22 @@ private void GridRecent_CellEditEnding(object sender, DataGridCellEditEndingEven
11241124

11251125
// check that folder exists
11261126
string path = proj.Path;
1127-
if (string.IsNullOrEmpty(path)) return;
1128-
1129-
// get current arguments, after editing
1130-
TextBox t = e.EditingElement as TextBox;
1131-
string newcellValue = t.Text.ToString();
1127+
Console.WriteLine(e.Column.DisplayIndex);
1128+
Console.WriteLine(path);
1129+
Console.WriteLine(string.IsNullOrEmpty(path));
1130+
if (string.IsNullOrEmpty(path))
1131+
{
11321132

1133+
//return;
1134+
}
11331135

11341136
// check if we edited project name, or launcher arguments
11351137
if (e.Column.DisplayIndex == 0)
11361138
{
1139+
// get current arguments, after editing
1140+
TextBox t = e.EditingElement as TextBox;
1141+
string newcellValue = t.Text.ToString();
1142+
11371143
// restore read only
11381144
e.Column.IsReadOnly = true;
11391145

@@ -1191,8 +1197,11 @@ private void GridRecent_CellEditEnding(object sender, DataGridCellEditEndingEven
11911197
}
11921198

11931199
}
1194-
else // edit launcher arguments
1200+
else if (e.Column.DisplayIndex == 4) // edit launcher arguments
11951201
{
1202+
// get current arguments, after editing
1203+
TextBox t = e.EditingElement as TextBox;
1204+
string newcellValue = t.Text.ToString();
11961205

11971206
string projSettingsFolder = "ProjectSettings";
11981207

@@ -1217,6 +1226,14 @@ private void GridRecent_CellEditEnding(object sender, DataGridCellEditEndingEven
12171226
Console.WriteLine("Error saving launcher arguments: " + ex);
12181227
}
12191228
}
1229+
else if (e.Column.DisplayIndex == 6) // platform dropdown
1230+
{
1231+
// get current arguments, after editing
1232+
var t = e.EditingElement as ComboBox;
1233+
string newcellValue = t.SelectedItem.ToString();
1234+
1235+
Console.WriteLine("Modified platform target: " + newcellValue);
1236+
}
12201237

12211238
// TODO select the same row again
12221239
}
@@ -1233,12 +1250,12 @@ private void TxtSearchBoxUnity_TextChanged(object sender, TextChangedEventArgs e
12331250

12341251
private void GridRecent_PreviewMouseDoubleClick(object sender, MouseButtonEventArgs e)
12351252
{
1236-
// cancel if editing cell, because often try to double click to edit
1253+
// cancel if editing cell, because often try to double click to edit instead
12371254
if (IsEditingCell(gridRecent)) return;
12381255

1239-
// cancel run if double click arguments editable field
1256+
// cancel run if double clicked Arguments or Platform editable field
12401257
var currentColumnCell = gridRecent.CurrentCell.Column.DisplayIndex;
1241-
if (currentColumnCell == 4) return;
1258+
if (currentColumnCell == 4 || currentColumnCell == 6) return;
12421259

12431260
var proj = GetSelectedProject();
12441261
var proc = Tools.LaunchProject(proj);

UnityLauncherPro/Tools.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -734,9 +734,11 @@ public static string ReadGitBranchInfo(string projectPath)
734734
return results;
735735
}
736736

737-
public static string ParseTargetPlatform(string projectPath)
737+
public static Platform GetTargetPlatform(string projectPath)
738+
//public static string GetTargetPlatform(string projectPath)
738739
{
739-
string results = null;
740+
//string results = null;
741+
Platform results = Platform.Unknown;
740742

741743
// get buildtarget from .csproj
742744
// <UnityBuildTarget>StandaloneWindows64:19</UnityBuildTarget>
@@ -759,11 +761,11 @@ public static string ParseTargetPlatform(string projectPath)
759761
// 2018: standalone, Win, Win64, OSXUniversal, Linux, Linux64, LinuxUniversal, iOS, Android, Web, WebStreamed, WebGL, XboxOne, PS4, WindowsStoreApps, Switch, N3DS, tvOS
760762
// 2019: Standalone, Win, Win64, OSXUniversal, Linux64, iOS, Android, WebGL, XboxOne, PS4, WindowsStoreApps, Switch, tvOS
761763
// 2020: Standalone, Win, Win64, OSXUniversal, Linux64, iOS, Android, WebGL, XboxOne, PS4, WindowsStoreApps, Switch, tvOS
762-
results = csprojsplit[1].Substring(0, endrow);
764+
//results = csprojsplit[1].Substring(0, endrow);
765+
results = (Platform)Enum.Parse(typeof(Platform), csprojsplit[1].Substring(0, endrow));
763766
}
764767
}
765768
}
766-
767769
return results;
768770
}
769771

UnityLauncherPro/UnityLauncherPro.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@
7676
<SubType>Designer</SubType>
7777
</ApplicationDefinition>
7878
<Compile Include="Data\BuildReport.cs" />
79+
<Compile Include="Data\Platform.cs" />
7980
<Compile Include="Data\Tabs.cs" />
8081
<Compile Include="GetProjects.cs" />
8182
<Compile Include="GetUnityInstallations.cs" />

0 commit comments

Comments
 (0)