Skip to content

Commit ee58811

Browse files
committed
Merge branch 'dev'
* dev: refresh projects after adding Unity editors, started adding project properties window (not used yet), new project: add warning if projectname starts or ends with Space character change/optimize GetElapsedTime #54 simplified Project.ToString() override (its not needed anywhere, but WPF keeps calling it) #54 remove unnecessary FindDir/DirectoryInfo scan #54 avoid calling checkbox checked setting save code at startup (#54) after sorting columns: scroll view to selected row
2 parents 4a1226e + 45d981a commit ee58811

9 files changed

+322
-76
lines changed

UnityLauncherPro/Data/Project.cs

+8-1
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,18 @@ public class Project : IValueConverter
1717
public string[] TargetPlatforms { set; get; }
1818
public bool folderExists { set; get; }
1919

20+
// WPF keeps calling this method from AppendFormatHelper, GetNameCore..? not sure if need to return something else or default would be faster?
2021
public override string ToString()
2122
{
22-
return $"{Title} {Version} {Path} {Modified} {Arguments} {GITBranch} {TargetPlatform}";
23+
return Path;
2324
}
2425

26+
// for debugging
27+
//public override string ToString()
28+
//{
29+
// return $"{Title} {Version} {Path} {Modified} {Arguments} {GITBranch} {TargetPlatform}";
30+
//}
31+
2532
// change datagrid colors based on value using converter https://stackoverflow.com/a/5551986/5452781
2633
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
2734
{

UnityLauncherPro/MainWindow.xaml

+1
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,7 @@
201201
</MenuItem>
202202
<Separator/>
203203
<MenuItem x:Name="menuRemoveProject" Header="Remove from recent list" Click="MenuRemoveProject_Click" />
204+
<!--<MenuItem x:Name="menuProjectProperties" Header="Properties..." Click="menuProjectProperties_Click" />-->
204205
</ContextMenu>
205206
</DataGrid.ContextMenu>
206207

UnityLauncherPro/MainWindow.xaml.cs

+57-14
Original file line numberDiff line numberDiff line change
@@ -670,13 +670,13 @@ private void SaveSettingsOnExit()
670670

671671
void UpdateUnityInstallationsList()
672672
{
673-
// reset preferred string, if user changed it
673+
// Reset preferred string, if user changed it
674674
//preferredVersion = "none";
675675

676676
unityInstallationsSource = GetUnityInstallations.Scan();
677677
dataGridUnitys.ItemsSource = unityInstallationsSource;
678678

679-
// also make dictionary of installed unitys, to search faster
679+
// Also make dictionary of installed unitys, to search faster
680680
unityInstalledVersions.Clear();
681681

682682
for (int i = 0, len = unityInstallationsSource.Count; i < len; i++)
@@ -725,6 +725,7 @@ void AddUnityInstallationRootFolder()
725725
lstRootFolders.Items.Refresh();
726726
Properties.Settings.Default.Save();
727727
UpdateUnityInstallationsList();
728+
RefreshRecentProjects();
728729
}
729730
}
730731

@@ -1526,12 +1527,16 @@ private void BtnOpenWebsite_Click(object sender, RoutedEventArgs e)
15261527

15271528
private void ChkMinimizeToTaskbar_CheckedChanged(object sender, RoutedEventArgs e)
15281529
{
1530+
if (this.IsActive == false) return; // dont run code on window init
1531+
15291532
Settings.Default.minimizeToTaskbar = (bool)chkMinimizeToTaskbar.IsChecked;
15301533
Settings.Default.Save();
15311534
}
15321535

15331536
private void ChkRegisterExplorerMenu_CheckedChanged(object sender, RoutedEventArgs e)
15341537
{
1538+
if (this.IsActive == false) return; // dont run code on window init
1539+
15351540
if ((bool)chkRegisterExplorerMenu.IsChecked)
15361541
{
15371542
Tools.AddContextMenuRegistry(contextRegRoot);
@@ -1548,6 +1553,7 @@ private void ChkRegisterExplorerMenu_CheckedChanged(object sender, RoutedEventAr
15481553
private void ChkShowLauncherArgumentsColumn_CheckedChanged(object sender, RoutedEventArgs e)
15491554
{
15501555
if (this.IsActive == false) return; // dont run code on window init
1556+
15511557
Settings.Default.showArgumentsColumn = (bool)chkShowLauncherArgumentsColumn.IsChecked;
15521558
Settings.Default.Save();
15531559
gridRecent.Columns[4].Visibility = (bool)chkShowLauncherArgumentsColumn.IsChecked ? Visibility.Visible : Visibility.Collapsed;
@@ -1557,6 +1563,7 @@ private void ChkShowLauncherArgumentsColumn_CheckedChanged(object sender, Routed
15571563
private void ChkShowGitBranchColumn_CheckedChanged(object sender, RoutedEventArgs e)
15581564
{
15591565
if (this.IsActive == false) return; // dont run code on window init
1566+
15601567
Settings.Default.showGitBranchColumn = (bool)chkShowGitBranchColumn.IsChecked;
15611568
Settings.Default.Save();
15621569
gridRecent.Columns[5].Visibility = (bool)chkShowGitBranchColumn.IsChecked ? Visibility.Visible : Visibility.Collapsed;
@@ -1565,12 +1572,16 @@ private void ChkShowGitBranchColumn_CheckedChanged(object sender, RoutedEventArg
15651572

15661573
private void ChkQuitAfterOpen_CheckedChanged(object sender, RoutedEventArgs e)
15671574
{
1575+
if (this.IsActive == false) return; // dont run code on window init
1576+
15681577
Settings.Default.closeAfterProject = (bool)chkQuitAfterOpen.IsChecked;
15691578
Settings.Default.Save();
15701579
}
15711580

15721581
private void ChkQuitAfterCommandline_CheckedChanged(object sender, RoutedEventArgs e)
15731582
{
1583+
if (this.IsActive == false) return; // dont run code on window init
1584+
15741585
Settings.Default.closeAfterExplorer = (bool)chkQuitAfterCommandline.IsChecked;
15751586
Settings.Default.Save();
15761587
}
@@ -1793,12 +1804,16 @@ private void DataGridUpdates_PreviewMouseDoubleClick(object sender, MouseButtonE
17931804

17941805
private void ChkShowMissingFolderProjects_CheckedChanged(object sender, RoutedEventArgs e)
17951806
{
1807+
if (this.IsActive == false) return; // dont run code on window init
1808+
17961809
Settings.Default.showProjectsMissingFolder = (bool)chkShowMissingFolderProjects.IsChecked;
17971810
Settings.Default.Save();
17981811
}
17991812

18001813
private void ChkAllowSingleInstanceOnly_CheckedChanged(object sender, RoutedEventArgs e)
18011814
{
1815+
if (this.IsActive == false) return; // dont run code on window init
1816+
18021817
Settings.Default.AllowSingleInstanceOnly = (bool)chkAllowSingleInstanceOnly.IsChecked;
18031818
Settings.Default.Save();
18041819
}
@@ -1966,17 +1981,21 @@ void CreateNewEmptyProject(string targetFolder = null)
19661981

19671982
private void ChkAskNameForQuickProject_Checked(object sender, RoutedEventArgs e)
19681983
{
1969-
Properties.Settings.Default.askNameForQuickProject = (bool)chkAskNameForQuickProject.IsChecked;
1970-
Properties.Settings.Default.Save();
1984+
if (this.IsActive == false) return; // dont run code on window init
1985+
1986+
Settings.Default.askNameForQuickProject = (bool)chkAskNameForQuickProject.IsChecked;
1987+
Settings.Default.Save();
19711988
}
19721989

19731990
bool isInitializing = true; // used to avoid doing things while still starting up
19741991
private void ChkStreamerMode_Checked(object sender, RoutedEventArgs e)
19751992
{
1993+
if (this.IsActive == false) return; // dont run code on window init
1994+
19761995
var isChecked = (bool)((CheckBox)sender).IsChecked;
19771996

1978-
Properties.Settings.Default.streamerMode = isChecked;
1979-
Properties.Settings.Default.Save();
1997+
Settings.Default.streamerMode = isChecked;
1998+
Settings.Default.Save();
19801999

19812000
// Create cellstyle and assign if streamermode is enabled
19822001
Style cellStyle = new Style(typeof(DataGridCell));
@@ -1999,6 +2018,8 @@ private void ChkStreamerMode_Checked(object sender, RoutedEventArgs e)
19992018

20002019
private void ChkShowPlatform_Checked(object sender, RoutedEventArgs e)
20012020
{
2021+
if (this.IsActive == false) return; // dont run code on window init
2022+
20022023
var isChecked = (bool)((CheckBox)sender).IsChecked;
20032024

20042025
Settings.Default.showTargetPlatform = isChecked;
@@ -2072,6 +2093,8 @@ public void MoveRecentGridItem(int to)
20722093

20732094
private void ChkEnableProjectRename_Checked(object sender, RoutedEventArgs e)
20742095
{
2096+
if (this.IsActive == false) return; // dont run code on window init
2097+
20752098
Properties.Settings.Default.enableProjectRename = (bool)chkEnableProjectRename.IsChecked;
20762099
Properties.Settings.Default.Save();
20772100
}
@@ -2565,8 +2588,8 @@ private void ChkUseCustomTheme_Checked(object sender, RoutedEventArgs e)
25652588
if (this.IsActive == false) return; // dont run code on window init
25662589

25672590
var isChecked = (bool)((CheckBox)sender).IsChecked;
2568-
Properties.Settings.Default.useCustomTheme = isChecked;
2569-
Properties.Settings.Default.Save();
2591+
Settings.Default.useCustomTheme = isChecked;
2592+
Settings.Default.Save();
25702593

25712594
btnReloadTheme.IsEnabled = isChecked;
25722595

@@ -2616,9 +2639,11 @@ private void BtnExploreFolder_Click(object sender, RoutedEventArgs e)
26162639

26172640
private void ChkEnablePlatformSelection_Checked(object sender, RoutedEventArgs e)
26182641
{
2642+
if (this.IsActive == false) return; // dont run code on window init
2643+
26192644
var isChecked = (bool)((CheckBox)sender).IsChecked;
2620-
Properties.Settings.Default.enablePlatformSelection = isChecked;
2621-
Properties.Settings.Default.Save();
2645+
Settings.Default.enablePlatformSelection = isChecked;
2646+
Settings.Default.Save();
26222647
chkEnablePlatformSelection.IsChecked = isChecked;
26232648
}
26242649

@@ -2642,9 +2667,10 @@ private void CmbPlatformSelection_DropDownClosed(object sender, EventArgs e)
26422667
private void ChkRunAutomatically_Checked(object sender, RoutedEventArgs e)
26432668
{
26442669
if (this.IsActive == false) return; // dont run code on window init
2670+
26452671
var isChecked = (bool)((CheckBox)sender).IsChecked;
2646-
Properties.Settings.Default.runAutomatically = isChecked;
2647-
Properties.Settings.Default.Save();
2672+
Settings.Default.runAutomatically = isChecked;
2673+
Settings.Default.Save();
26482674
chkRunAutomatically.IsChecked = isChecked;
26492675
// set or unset registry, NOTE should not do this on debug build.. (otherwise 2 builds try to run?)
26502676
Tools.SetStartupRegistry(isChecked);
@@ -2741,6 +2767,7 @@ bool ValidateIntRange(TextBox textBox, int min, int max)
27412767
private void ChkHumanFriendlyDateTime_Checked(object sender, RoutedEventArgs e)
27422768
{
27432769
if (this.IsActive == false) return; // dont run code on window init
2770+
27442771
var isChecked = (bool)((CheckBox)sender).IsChecked;
27452772

27462773
// cannot have both date formats
@@ -2796,6 +2823,7 @@ void OpenSelectedBuildReportFile()
27962823
private void ChkRunAutomaticallyMinimized_Checked(object sender, RoutedEventArgs e)
27972824
{
27982825
if (this.IsActive == false) return; // dont run code on window init
2826+
27992827
var isChecked = (bool)((CheckBox)sender).IsChecked;
28002828

28012829
Settings.Default.runAutomaticallyMinimized = isChecked;
@@ -2974,6 +3002,7 @@ private void Window_SourceInitialized(object sender, EventArgs e)
29743002
private void ChkSearchProjectPath_Checked(object sender, RoutedEventArgs e)
29753003
{
29763004
if (this.IsActive == false) return; // dont run code on window init
3005+
29773006
var isChecked = (bool)((CheckBox)sender).IsChecked;
29783007

29793008
searchProjectPathAlso = isChecked;
@@ -3011,6 +3040,7 @@ private void MenuBatchBuildIOS_Click(object sender, RoutedEventArgs e)
30113040
private void ChkCheckPlasticBranch_Checked(object sender, RoutedEventArgs e)
30123041
{
30133042
if (this.IsActive == false) return; // dont run code on window init
3043+
30143044
Settings.Default.checkPlasticBranch = (bool)chkCheckPlasticBranch.IsChecked;
30153045
Settings.Default.Save();
30163046
RefreshRecentProjects();
@@ -3087,7 +3117,6 @@ void SortHandlerUpdates(object sender, DataGridSortingEventArgs e)
30873117
{
30883118
DataGridColumn column = e.Column;
30893119

3090-
30913120
IComparer comparer = null;
30923121

30933122
// prevent the built-in sort from sorting
@@ -3179,6 +3208,14 @@ void SortHandlerRecentProjects(object sender, DataGridSortingEventArgs e)
31793208

31803209
//apply the sort
31813210
lcv.CustomSort = comparer;
3211+
3212+
if (gridRecent.SelectedItem != null)
3213+
{
3214+
// scroll view to selected, after sort
3215+
gridRecent.ScrollIntoView(gridRecent.SelectedItem);
3216+
// needed for keyboard to work in grid
3217+
gridRecent.Focus();
3218+
}
31823219
}
31833220

31843221
public class CustomProjectSort : IComparer
@@ -3308,7 +3345,7 @@ private void btnPatchHubConfig_Click(object sender, RoutedEventArgs e)
33083345
// replace the manual:true with manual:false using regex
33093346
json = json.Replace("\"manual\":true", "\"manual\":false");
33103347

3311-
Console.WriteLine(json);
3348+
//Console.WriteLine(json);
33123349

33133350
// write the config file
33143351
File.WriteAllText(configFile, json);
@@ -3556,6 +3593,12 @@ private void btnHubLogs_Click(object sender, RoutedEventArgs e)
35563593
Tools.OpenAppdataSpecialFolder("../Roaming/UnityHub/logs/");
35573594
}
35583595

3596+
//private void menuProjectProperties_Click(object sender, RoutedEventArgs e)
3597+
//{
3598+
// var proj = GetSelectedProject();
3599+
// if (proj == null) return;
3600+
// Tools.DisplayProjectProperties(proj, this);
3601+
//}
35593602
} // class
35603603
} //namespace
35613604

UnityLauncherPro/NewProject.xaml

+11-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
66
xmlns:local="clr-namespace:UnityLauncherPro"
77
mc:Ignorable="d"
8-
Title="Create New Project" Height="460" Width="450" Background="{DynamicResource ThemeDarkestBackground}" PreviewKeyDown="Window_PreviewKeyDown" ResizeMode="NoResize" WindowStartupLocation="CenterOwner" ShowInTaskbar="True">
8+
Title="Create New Project" Height="480" Width="450" Background="{DynamicResource ThemeDarkestBackground}" PreviewKeyDown="Window_PreviewKeyDown" ResizeMode="NoResize" WindowStartupLocation="CenterOwner" ShowInTaskbar="True">
99

1010
<Grid>
1111
<StackPanel Margin="10,3">
@@ -24,7 +24,7 @@
2424
<ColumnDefinition Width="20*"/>
2525
<ColumnDefinition Width="40*"/>
2626
</Grid.ColumnDefinitions>
27-
<Label Grid.Column="0" Content="Project Name:" Foreground="{DynamicResource ThemeButtonForeground}" Margin="0" Padding="0,5,5,0" />
27+
<Label x:Name="lblNewProjectNameLabel" Grid.Column="0" Content="Project Name:" Foreground="{DynamicResource ThemeButtonForeground}" Margin="0" Padding="0,5,5,0" />
2828
<Label Grid.Column="1" Content="Platform:" Foreground="{DynamicResource ThemeButtonForeground}" Margin="0" Padding="0,5,0,0" />
2929
<Label x:Name="lblTemplateTitleAndCount" Grid.Column="2" Content="Templates:" Foreground="{DynamicResource ThemeButtonForeground}" Margin="0" Padding="5,5,5,0" />
3030
</Grid>
@@ -53,6 +53,15 @@
5353
<Label Content="_Create" Foreground="{Binding RelativeSource={RelativeSource AncestorType=Button}, Path=Foreground}"/>
5454
</Button>
5555
</Grid>
56+
57+
<Grid Grid.Row="2" UseLayoutRounding="False">
58+
<StatusBar VerticalAlignment="Center" Background="{x:Null}" Foreground="{DynamicResource ThemeStatusText}">
59+
<StatusBarItem>
60+
<TextBlock x:Name="txtNewProjectStatus" VerticalAlignment="Center" Text=""/>
61+
</StatusBarItem>
62+
</StatusBar>
63+
</Grid>
64+
5665
</StackPanel>
5766
</Grid>
5867
</Window>

UnityLauncherPro/NewProject.xaml.cs

+18-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using System.Collections.Generic;
1+
using System;
2+
using System.Collections.Generic;
23
using System.IO;
34
using System.Windows;
45
using System.Windows.Controls;
@@ -217,6 +218,22 @@ private void TxtNewProjectName_TextChanged(object sender, TextChangedEventArgs e
217218
{
218219
if (isInitializing == true) return;
219220

221+
// warning yellow if contains space at start or end
222+
if (txtNewProjectName.Text.StartsWith(" ") || txtNewProjectName.Text.EndsWith(" "))
223+
{
224+
// NOTE txtbox outline didnt work
225+
txtNewProjectName.Background = Brushes.Yellow;
226+
txtNewProjectStatus.Text = "Warning: Project name starts or ends with SPACE character";
227+
txtNewProjectStatus.Foreground = Brushes.Orange;
228+
}
229+
else
230+
{
231+
// NOTE this element is not using themes yet, so can set white
232+
txtNewProjectName.Background = Brushes.White;
233+
txtNewProjectStatus.Foreground = Brushes.White;
234+
txtNewProjectStatus.Text = "";
235+
}
236+
220237
// validate new projectname that it doesnt exists already
221238
var targetPath = Path.Combine(targetFolder, txtNewProjectName.Text);
222239
if (Directory.Exists(targetPath) == true)
+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<Window x:Class="UnityLauncherPro.ProjectProperties"
2+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
5+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
6+
xmlns:local="clr-namespace:UnityLauncherPro"
7+
mc:Ignorable="d"
8+
Title="Project Properties" Height="480" Width="450" Background="{DynamicResource ThemeDarkestBackground}" ResizeMode="NoResize" WindowStartupLocation="CenterOwner" ShowInTaskbar="True" PreviewKeyDown="Window_PreviewKeyDown">
9+
10+
<Grid>
11+
<StackPanel Margin="10,3">
12+
<Label Content="Custom environment variables:" Foreground="{DynamicResource ThemeButtonForeground}" Margin="0,0,0,3" Padding="5,5,5,3" />
13+
<TextBox x:Name="txtCustomEnvVariables" IsUndoEnabled="True" TextChanged="txtCustomEnvVariables_TextChanged" PreviewKeyDown="txtCustomEnvVariables_PreviewKeyDown" TabIndex="0" Width="320" Text="JAVA_HOME=C:\Program Files\Java\jdk1.8.0_202" />
14+
15+
<Grid HorizontalAlignment="Stretch" Margin="0,8,0,0">
16+
<Grid.ColumnDefinitions>
17+
<ColumnDefinition Width="*"/>
18+
<ColumnDefinition Width="*"/>
19+
</Grid.ColumnDefinitions>
20+
<Button Grid.Column="0" Style="{StaticResource CustomButton}" x:Name="btnCloseProperties" Margin="0,0,3,3" BorderBrush="{x:Null}" VerticalAlignment="Top" Height="35" TabIndex="4" Click="btnCloseProperties_Click" >
21+
<Label Content="Cancel" Foreground="{Binding RelativeSource={RelativeSource AncestorType=Button}, Path=Foreground}"/>
22+
</Button>
23+
<Button Grid.Column="1" Style="{StaticResource CustomButton}" x:Name="btnApplyProperties" Margin="0,0,3,3" BorderBrush="{x:Null}" VerticalAlignment="Top" Height="35" TabIndex="4" Click="btnApplyProperties_Click" >
24+
<Label Content="Apply" Foreground="{Binding RelativeSource={RelativeSource AncestorType=Button}, Path=Foreground}"/>
25+
</Button>
26+
</Grid>
27+
28+
<!--<DataGrid x:Name="gridEnvVariables" SelectionMode="Single" Height="88" Margin="10,121,10,0" VerticalAlignment="Top" HeadersVisibility="None" AutoGenerateColumns="False" IsSynchronizedWithCurrentItem="True" Foreground="{DynamicResource ThemeButtonForeground}" Background="{DynamicResource ThemeMainBackgroundColor}" PreviewKeyDown="GridAvailableVersions_PreviewKeyDown" Loaded="GridAvailableVersions_Loaded" PreviewMouseDoubleClick="GridAvailableVersions_PreviewMouseDoubleClick" VerticalScrollBarVisibility="Visible" HorizontalScrollBarVisibility="Disabled" ScrollViewer.VerticalScrollBarVisibility="Visible" CanUserAddRows="False" CanUserDeleteRows="False" CanUserResizeRows="False" CanUserSortColumns="False" CanUserResizeColumns="False" CanUserReorderColumns="False">
29+
<DataGrid.Columns>
30+
<DataGridTextColumn Header="Variable" Binding="{Binding Version}" IsReadOnly="True" CanUserResize="False" MinWidth="80" />
31+
<DataGridTextColumn Header="Value" Binding="{Binding PlatformsCombined}" IsReadOnly="True" CanUserResize="False" MinWidth="270" />
32+
</DataGrid.Columns>
33+
</DataGrid>-->
34+
35+
36+
</StackPanel>
37+
</Grid>
38+
</Window>

0 commit comments

Comments
 (0)