Skip to content

Commit b750b13

Browse files
committed
still adding combobox for platform selection (wpf is so much fun..)
1 parent d57345b commit b750b13

File tree

7 files changed

+89
-49
lines changed

7 files changed

+89
-49
lines changed

UnityLauncherPro/Data/Project.cs

+5-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,11 @@ public class Project : IValueConverter
1313
public string Arguments { set; get; }
1414
public string GITBranch { set; get; }
1515
//public string TargetPlatform { set; get; }
16-
public Platform TargetPlatform { set; get; }
16+
public string TargetPlatform { set; get; }
17+
18+
public string[] TargetPlatforms { set; get; }
19+
20+
1721
public bool folderExists { set; get; }
1822
public Process Process; // launched unity exe
1923

UnityLauncherPro/Data/UnityInstallation.cs

+4-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@ public class UnityInstallation : IValueConverter
88
public string Version { set; get; }
99
public string Path { set; get; }
1010
public DateTime? Installed { set; get; }
11-
public string Platforms { set; get; }
11+
12+
public string PlatformsCombined { set; get; }
13+
public string[] Platforms { set; get; }
14+
1215
public bool IsPreferred { set; get; }
1316

1417
// https://stackoverflow.com/a/5551986/5452781

UnityLauncherPro/GetProjects.cs

+21-5
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ 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+
static Dictionary<string, string> remapPlatformNames = new Dictionary<string, string> { { "StandaloneWindows64", "Windows" }, { "StandaloneWindows", "Windows" }, { "Android", "Android" }, { "WebGL", "WebGL" } };
15+
16+
1417
// TODO separate scan and folders
1518
public static List<Project> Scan(bool getGitBranch = false, bool getArguments = false, bool showMissingFolders = false, bool showTargetPlatform = false)
1619
{
@@ -116,12 +119,12 @@ public static List<Project> Scan(bool getGitBranch = false, bool getArguments =
116119
}
117120

118121
// TODO add option to disable check
119-
//string targetPlatform = "";
120-
Platform targetPlatform = Platform.Unknown;
122+
string targetPlatform = "";
123+
//Platform targetPlatform = Platform.Unknown;
121124
if (showTargetPlatform == true)
122125
{
123-
//targetPlatform = folderExists ? Tools.GetTargetPlatform(projectPath) : null;
124-
targetPlatform = folderExists ? Tools.GetTargetPlatform(projectPath) : Platform.Unknown;
126+
targetPlatform = folderExists ? Tools.GetTargetPlatform(projectPath) : null;
127+
//targetPlatform = folderExists ? Tools.GetTargetPlatform(projectPath) : Platform.Unknown;
125128
}
126129

127130
var p = new Project();
@@ -131,8 +134,21 @@ public static List<Project> Scan(bool getGitBranch = false, bool getArguments =
131134
p.Modified = lastUpdated;
132135
p.Arguments = customArgs;
133136
p.GITBranch = gitBranch;
137+
// TODO this one should pick best match from available platforms (since they look different: StandaloneWindows64 should be remapped as Windows)
134138
//p.TargetPlatform = targetPlatform;
135-
p.TargetPlatform = targetPlatform;
139+
if (string.IsNullOrEmpty(targetPlatform) == false && remapPlatformNames.ContainsKey(targetPlatform))
140+
{
141+
p.TargetPlatform = remapPlatformNames[targetPlatform];
142+
}
143+
else
144+
{
145+
p.TargetPlatform = null;
146+
}
147+
148+
// bubblegum(TM) solution, fill available platforms for this unity version, for this project
149+
p.TargetPlatforms = Tools.GetPlatformsForUnityVersion(projectVersion);
150+
151+
136152
p.folderExists = folderExists;
137153

138154
// if want to hide project and folder path for screenshot

UnityLauncherPro/GetUnityInstallations.cs

+5-2
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,10 @@ public static UnityInstallation[] Scan()
5252

5353
// get platforms, NOTE if this is slow, do it later, or skip for commandline
5454
var platforms = GetPlatforms(dataFolder);
55-
if (platforms != null) unity.Platforms = string.Join(", ", platforms);
55+
// this is for editor tab, show list of all platforms in cell
56+
if (platforms != null) unity.PlatformsCombined = string.Join(", ", platforms);
57+
// this is for keeping array of platforms for platform combobox
58+
if (platforms != null) unity.Platforms = platforms;
5659

5760
// add to list, if not there yet NOTE should notify that there are 2 same versions..? this might happen with preview builds..
5861
if (results.Contains(unity) == true)
@@ -70,6 +73,7 @@ public static UnityInstallation[] Scan()
7073
return results.ToArray();
7174
} // scan()
7275

76+
// scans unity installation folder for installed platforms
7377
static string[] GetPlatforms(string dataFolder)
7478
{
7579
// get all folders inside
@@ -92,6 +96,5 @@ static string[] GetPlatforms(string dataFolder)
9296

9397
return directories;
9498
}
95-
9699
} // class
97100
} // namespace

UnityLauncherPro/MainWindow.xaml

+23-33
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,14 @@
7474
<Setter Property="ScrollViewer.CanContentScroll" Value="true" />
7575
<Setter Property="MinWidth" Value="120" />
7676
<Setter Property="MinHeight" Value="20" />
77+
78+
<!--test fix for System.Windows.Data Error: 4-->
79+
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
80+
<Setter Property="VerticalContentAlignment" Value="Center" />
81+
<Setter Property="HorizontalAlignment" Value="Stretch" />
82+
<Setter Property="VerticalAlignment" Value="Center" />
83+
<Setter Property="OverridesDefaultStyle" Value="True"/>
84+
7785
<Setter Property="Template">
7886
<Setter.Value>
7987
<ControlTemplate TargetType="{x:Type ComboBox}">
@@ -146,46 +154,27 @@
146154
</Setter>
147155
</Style>
148156

157+
<!-- error 4 comes from this whole part? -->
149158
<Style x:Key="{x:Type ComboBoxItem}" TargetType="{x:Type ComboBoxItem}">
150159
<Setter Property="SnapsToDevicePixels" Value="true" />
151160
<Setter Property="OverridesDefaultStyle" Value="true" />
161+
<!-- test fix for error 4 https://gist.github.com/TobiasSekan/73a93c2dfea4a051ff72abb5218d6f8f--><!--
162+
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
163+
<Setter Property="VerticalContentAlignment" Value="Center" />
164+
<Setter Property="HorizontalAlignment" Value="Stretch" />
165+
<Setter Property="VerticalAlignment" Value="Center" />-->
166+
152167
<Setter Property="Template">
153168
<Setter.Value>
154169
<ControlTemplate TargetType="{x:Type ComboBoxItem}">
155170
<Border x:Name="Border" Padding="0" SnapsToDevicePixels="true" Background="Transparent">
156-
<!--<VisualStateManager.VisualStateGroups>
157-
<VisualStateGroup x:Name="SelectionStates">
158-
<VisualState x:Name="Unselected" />
159-
<VisualState x:Name="Selected">
160-
<Storyboard>
161-
-->
162-
<!--combobox selected item color in dropdown -->
163-
<!--
164-
<ColorAnimationUsingKeyFrames Storyboard.TargetName="Border" Storyboard.TargetProperty="(Panel.Background).(SolidColorBrush.Color)">
165-
<EasingColorKeyFrame KeyTime="0" Value="Black" />
166-
</ColorAnimationUsingKeyFrames>
167-
</Storyboard>
168-
</VisualState>
169-
<VisualState x:Name="SelectedUnfocused"/>
170-
-->
171-
<!--<VisualState x:Name="SelectedUnfocused">
172-
<Storyboard>
173-
<ColorAnimationUsingKeyFrames Storyboard.TargetName="Border" Storyboard.TargetProperty="(Panel.Background).(SolidColorBrush.Color)">
174-
<EasingColorKeyFrame KeyTime="0" Value="Yellow" />
175-
</ColorAnimationUsingKeyFrames>
176-
</Storyboard>
177-
</VisualState>-->
178-
<!--
179-
</VisualStateGroup>
180-
</VisualStateManager.VisualStateGroups>-->
181171
<ContentPresenter />
182172
</Border>
183173

184174
<!--mouseover colors for dropdown combobox https://stackoverflow.com/a/39228553/5452781 -->
185175
<ControlTemplate.Triggers>
186176
<Trigger Property="ComboBoxItem.IsMouseOver" Value="True">
187177
<Setter TargetName="Border" Property="Background" Value="DarkBlue"></Setter>
188-
<!--<Setter TargetName="Border" Property="TextElement.Foreground" Value="White"></Setter>-->
189178
</Trigger>
190179
<Trigger Property="ComboBoxItem.IsSelected" Value="True">
191180
<Setter TargetName="Border" Property="Background" Value="{StaticResource ThemeDataGridRowSelectedBackground}"></Setter>
@@ -329,9 +318,9 @@
329318
<Setter.Value>
330319
<ControlTemplate TargetType="{x:Type RepeatButton}">
331320
<!-- button background -->
332-
<Border x:Name="Border" Margin="1" CornerRadius="0" BorderThickness="0" Background="{DynamicResource ButtonBackground}" BorderBrush="{x:Null}">
321+
<Border x:Name="Border" Margin="1" CornerRadius="0" BorderThickness="0" Background="{DynamicResource ThemeButtonBackground}" BorderBrush="{x:Null}">
333322
<!-- arrow sign -->
334-
<Path HorizontalAlignment="Center" VerticalAlignment="Center" Fill="{DynamicResource ScrollArrowForeground}" Data="{Binding Content, RelativeSource={RelativeSource TemplatedParent}}" />
323+
<Path HorizontalAlignment="Center" VerticalAlignment="Center" Fill="{DynamicResource ThemeScrollArrowForeground}" Data="{Binding Content, RelativeSource={RelativeSource TemplatedParent}}" />
335324
</Border>
336325
<ControlTemplate.Triggers>
337326
<!-- NOTE order matters, if pressed is before mouseover, then it gets overwritten -->
@@ -392,7 +381,7 @@
392381
<RowDefinition MaxHeight="18"/>
393382
</Grid.RowDefinitions>
394383
<!-- scrollbar background -->
395-
<Border Grid.RowSpan="3" CornerRadius="0" Background="{DynamicResource ScrollBarBackground}" />
384+
<Border Grid.RowSpan="3" CornerRadius="0" Background="{DynamicResource ThemeScrollBarBackground}" />
396385
<!-- scrollbar top button -->
397386
<RepeatButton Grid.Row="0" Style="{StaticResource ScrollBarLineButton}" Height="18" Command="ScrollBar.LineUpCommand" Content="M 0 4 L 8 4 L 4 0 Z" />
398387
<Track x:Name="PART_Track" Grid.Row="1" IsDirectionReversed="true">
@@ -401,7 +390,7 @@
401390
</Track.DecreaseRepeatButton>
402391
<Track.Thumb>
403392
<!-- scrollbar foreground -->
404-
<Thumb Style="{StaticResource ScrollBarThumb}" Margin="1,0,1,0" Background="{DynamicResource ScrollBarFill}" BorderBrush="{x:Null}"/>
393+
<Thumb Style="{StaticResource ScrollBarThumb}" Margin="1,0,1,0" Background="{DynamicResource ThemeScrollBarFill}" BorderBrush="{x:Null}"/>
405394
</Track.Thumb>
406395
<Track.IncreaseRepeatButton>
407396
<RepeatButton Style="{StaticResource ScrollBarPageButton}" Command="ScrollBar.PageDownCommand" />
@@ -484,7 +473,8 @@
484473
<Button Style="{StaticResource CustomButton}" ToolTip="Add existing project" x:Name="btnAddProjectFolder" Content="Add Project.." Height="22" Width="78" HorizontalAlignment="Right" VerticalAlignment="Top" Margin="0,4,34,0" Click="BtnAddProjectFolder_Click" BorderBrush="{x:Null}" TabIndex="10" />
485474
<Button Style="{StaticResource CustomButton}" ToolTip="Refresh list (F5)" x:Name="btnRefreshProjectList" Content="" Height="22" Width="22" HorizontalAlignment="Right" VerticalAlignment="Top" FontSize="16" Margin="0,4,3,0" Padding="1,-2,1,1" BorderBrush="{x:Null}" Click="BtnRefreshProjectList_Click" TabIndex="11"/>
486475

487-
<DataGrid x:Name="gridRecent" SelectionMode="Single" Margin="4,30,2,42" CanUserAddRows="False" Background="{x:Null}" BorderBrush="{x:Null}" ColumnHeaderStyle="{StaticResource HeaderStyle}" Padding="0" HorizontalScrollBarVisibility="Disabled" HeadersVisibility="Column" Foreground="{DynamicResource ThemeGridForeground}" HorizontalGridLinesBrush="{DynamicResource ThemeGridHorizontalGridLines}" VerticalGridLinesBrush="{DynamicResource ThemeGridVerticalGridLines}" AutoGenerateColumns="False" PreviewKeyDown="GridRecent_PreviewKeyDown" Loaded="GridRecent_Loaded" TabIndex="2" CellEditEnding="GridRecent_CellEditEnding" PreviewMouseDoubleClick="GridRecent_PreviewMouseDoubleClick" BeginningEdit="GridRecent_BeginningEdit" ContextMenuOpening="GridRecent_ContextMenuOpening" >
476+
<DataGrid x:Name="gridRecent" HorizontalAlignment="Left" HorizontalContentAlignment="Left" VerticalAlignment="Center" VerticalContentAlignment="Center" SelectionMode="Single" Margin="4,30,2,42" CanUserAddRows="False" Background="{x:Null}" BorderBrush="{x:Null}" ColumnHeaderStyle="{StaticResource HeaderStyle}" Padding="0" HorizontalScrollBarVisibility="Disabled" HeadersVisibility="Column" Foreground="{DynamicResource ThemeGridForeground}" HorizontalGridLinesBrush="{DynamicResource ThemeGridHorizontalGridLines}" VerticalGridLinesBrush="{DynamicResource ThemeGridVerticalGridLines}" AutoGenerateColumns="False" PreviewKeyDown="GridRecent_PreviewKeyDown" Loaded="GridRecent_Loaded" TabIndex="2" CellEditEnding="GridRecent_CellEditEnding" PreviewMouseDoubleClick="GridRecent_PreviewMouseDoubleClick" ContextMenuOpening="GridRecent_ContextMenuOpening" BeginningEdit="GridRecent_BeginningEdit" >
477+
488478
<DataGrid.CommandBindings>
489479
<CommandBinding Command="ApplicationCommands.Copy" Executed="CopyRowFolderToClipBoard" CanExecute="CanExecute_Copy"/>
490480
<CommandBinding Command="{x:Static local:MainWindow.KillProcessCommand}" Executed="KillSelectedProcess"/>
@@ -529,7 +519,7 @@
529519
<DataGridTemplateColumn Header="Platform">
530520
<DataGridTemplateColumn.CellTemplate >
531521
<DataTemplate >
532-
<ComboBox x:Name="cmbPlatformSelection" IsEnabled="{Binding ElementName=chkEnablePlatformSelection, Path=IsChecked}" ItemsSource="{Binding Source={StaticResource platformEnum}}" SelectedValue="{Binding TargetPlatform}" Height="18" Foreground="{DynamicResource ThemeButtonForeground}"/>
522+
<ComboBox x:Name="cmbPlatformSelection" OverridesDefaultStyle="True" VerticalAlignment="Center" HorizontalAlignment="Stretch" VerticalContentAlignment="Center" HorizontalContentAlignment="Stretch" IsEnabled="{Binding ElementName=chkEnablePlatformSelection, Path=IsChecked}" ItemsSource="{Binding TargetPlatforms}" SelectedValue="{Binding TargetPlatform}" Height="18" Foreground="{DynamicResource ThemeButtonForeground}"/>
533523
</DataTemplate>
534524
</DataGridTemplateColumn.CellTemplate>
535525
</DataGridTemplateColumn>
@@ -664,7 +654,7 @@
664654
<DataGridTextColumn Binding="{Binding Version}" ClipboardContentBinding="{x:Null}" Header="Version" IsReadOnly="True" MinWidth="123"/>
665655
<DataGridTextColumn Binding="{Binding Path}" ClipboardContentBinding="{x:Null}" Header="Path" IsReadOnly="True"/>
666656
<DataGridTextColumn Binding="{Binding Installed, StringFormat=\{0:dd/MM/yyyy HH:mm:ss\}}" ClipboardContentBinding="{x:Null}" Header="Installed" IsReadOnly="True"/>
667-
<DataGridTextColumn Binding="{Binding Platforms}" ClipboardContentBinding="{x:Null}" Header="Platforms" IsReadOnly="True"/>
657+
<DataGridTextColumn Binding="{Binding PlatformsCombined}" ClipboardContentBinding="{x:Null}" Header="Platforms" IsReadOnly="True"/>
668658
</DataGrid.Columns>
669659

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

UnityLauncherPro/MainWindow.xaml.cs

+11-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public partial class MainWindow : Window
3838
// datagrid sources
3939
List<Project> projectsSource;
4040
Updates[] updatesSource;
41-
UnityInstallation[] unityInstallationsSource;
41+
public static UnityInstallation[] unityInstallationsSource;
4242

4343
public static Dictionary<string, string> unityInstalledVersions = new Dictionary<string, string>(); // versionID and installation folder
4444
const string contextRegRoot = "Software\\Classes\\Directory\\Background\\shell";
@@ -1853,5 +1853,15 @@ private void ChkEnablePlatformSelection_Checked(object sender, RoutedEventArgs e
18531853
chkEnablePlatformSelection.IsChecked = isChecked;
18541854
}
18551855

1856+
1857+
//private void CmbPlatformSelection_ManipulationInertiaStarting(object sender, ManipulationInertiaStartingEventArgs e)
1858+
//{
1859+
// var comb = (ComboBox)sender;
1860+
// Console.WriteLine(comb.Name);
1861+
// comb.HorizontalContentAlignment = HorizontalAlignment.Stretch;
1862+
// comb.VerticalContentAlignment = VerticalAlignment.Center;
1863+
// comb.HorizontalAlignment = HorizontalAlignment.Stretch;
1864+
// comb.VerticalAlignment = VerticalAlignment.Center;
1865+
//}
18561866
} // class
18571867
} //namespace

0 commit comments

Comments
 (0)