Skip to content

Commit 1723065

Browse files
committed
fix overlapping access keys (release notes, run unity), add search for installed unitys and updates, cleanup
1 parent 21c92ae commit 1723065

File tree

6 files changed

+88
-62
lines changed

6 files changed

+88
-62
lines changed

Diff for: UnityLauncherPro/Data/UnityInstallation.cs

-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
using System;
2-
using System.Drawing;
3-
using System.Windows;
42
using System.Windows.Data;
53

64
namespace UnityLauncherPro

Diff for: UnityLauncherPro/GetUnityInstallations.cs

-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ public static UnityInstallation[] Scan()
1616
var rootFolders = Properties.Settings.Default.rootFolders;
1717

1818
// unityversion, exe_path
19-
//Dictionary<string, UnityInstallation> results = new ictionary<string, UnityInstallation>();
2019
List<UnityInstallation> results = new List<UnityInstallation>();
2120

2221
// iterate all root folders

Diff for: UnityLauncherPro/GetUnityUpdates.cs

+7-18
Original file line numberDiff line numberDiff line change
@@ -9,24 +9,23 @@ namespace UnityLauncherPro
99
public static class GetUnityUpdates
1010
{
1111
static bool isDownloadingUnityList = false;
12+
static readonly string unityVersionsURL = @"http://symbolserver.unity3d.com/000Admin/history.txt";
1213

13-
//public static async Task<List<Updates>> Scan()
1414
public static async Task<string> Scan()
1515
{
16-
/*
1716
if (isDownloadingUnityList == true)
1817
{
1918
//SetStatus("We are already downloading ...");
20-
return;
21-
}*/
19+
return null;
20+
}
2221

2322
isDownloadingUnityList = true;
2423
//SetStatus("Downloading list of Unity versions ...");
2524
string result;
2625
// download list of Unity versions
2726
using (WebClient webClient = new WebClient())
2827
{
29-
var unityVersionsURL = @"http://symbolserver.unity3d.com/000Admin/history.txt";
28+
3029
Task<string> downloadStringTask = webClient.DownloadStringTaskAsync(new Uri(unityVersionsURL));
3130
result = await downloadStringTask;
3231
}
@@ -36,27 +35,17 @@ public static async Task<string> Scan()
3635

3736
public static Updates[] Parse(string items)// object sender, DownloadStringCompletedEventArgs e)
3837
{
39-
// TODO check for error..
38+
isDownloadingUnityList = false;
4039
//SetStatus("Downloading list of Unity versions ... done");
41-
//isDownloadingUnityList = false;
42-
43-
// parse to list
4440
var receivedList = items.Split(new[] { Environment.NewLine }, StringSplitOptions.None);
41+
if (receivedList == null && receivedList.Length < 1) return null;
4542
Array.Reverse(receivedList);
46-
//gridUnityUpdates.Rows.Clear();
47-
// fill in, TODO: show only top 50 or so
48-
4943
var updates = new List<Updates>();
50-
44+
// parse into data
5145
for (int i = 0, len = receivedList.Length; i < len; i++)
5246
{
5347
var row = receivedList[i].Split(',');
5448
var versionTemp = row[6].Trim('"');
55-
//gridUnityUpdates.Rows.Add(row[3], versionTemp);
56-
57-
// set color if we already have it installed
58-
//gridUnityUpdates.Rows[i].Cells[1].Style.ForeColor = unityList.ContainsKey(versionTemp) ? Color.Green : Color.Black;
59-
6049
var u = new Updates();
6150
u.ReleaseDate = DateTime.ParseExact(row[3], "MM/dd/yyyy", CultureInfo.InvariantCulture); //DateTime ? lastUpdated = Tools.GetLastModifiedTime(csprojFile);
6251
u.Version = versionTemp;

Diff for: UnityLauncherPro/MainWindow.xaml

+6-6
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,7 @@
385385
<Label Content="_Run Unity" Foreground="{Binding Path=Foreground, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Control}}}" />
386386
</Button>
387387

388-
<Button Grid.Column="2" Style="{StaticResource CustomButton}" x:Name="btnLaunchProject" Background="{DynamicResource ButtonBackground}" Foreground="#FFC1C1C1" Margin="8,0,0,0" BorderBrush="{x:Null}" Click="BtnLaunchProject_Click" >
388+
<Button Grid.Column="2" Style="{StaticResource CustomButton}" x:Name="btnLaunchProject" Background="{DynamicResource ButtonBackground}" Foreground="#FFC1C1C1" Margin="8,0,0,0" BorderBrush="{x:Null}" Click="BtnLaunchProject_Click" AutomationProperties.AccessKey="o" >
389389
<Label Content="_Open Project" Foreground="{Binding Path=Foreground, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Control}}}" />
390390
</Button>
391391

@@ -402,7 +402,7 @@
402402
<!-- search box -->
403403
<Grid Background="{DynamicResource TextBoxBackground}" HorizontalAlignment="Left" VerticalAlignment="Top" Width="222" Margin="6,5,0,0" Height="20" >
404404
<TextBlock Margin="3,2" MinWidth="100" Text="Search" Foreground="#7F919191" Visibility="{Binding Text.IsEmpty, Converter={StaticResource MyBoolToVisibilityConverter}, ElementName=txtSearchBoxUnity}" Height="24" />
405-
<TextBox MinWidth="100" CaretBrush="#FFE2E2E2" x:Name="txtSearchBoxUnity" Background="Transparent" BorderBrush="{x:Null}" Foreground="#FFC7C7C7" SelectionBrush="#FF003966" BorderThickness="0" Margin="2,2,0,0" UndoLimit="64" PreviewKeyDown="TxtSearchBoxUnity_PreviewKeyDown" />
405+
<TextBox MinWidth="100" CaretBrush="#FFE2E2E2" x:Name="txtSearchBoxUnity" Background="Transparent" BorderBrush="{x:Null}" Foreground="#FFC7C7C7" SelectionBrush="#FF003966" BorderThickness="0" Margin="2,2,0,0" UndoLimit="64" PreviewKeyDown="TxtSearchBoxUnity_PreviewKeyDown" TextChanged="TxtSearchBoxUnity_TextChanged" />
406406
<Button x:Name="btnClearUnitySearch" Style="{StaticResource {x:Static ToolBar.ButtonStyleKey}}" BorderThickness="0" HorizontalAlignment="Right" VerticalAlignment="Top" Height="23" Width="23" Background="Transparent" Padding="0,2" Visibility="Visible" BorderBrush="{x:Null}" Click="OnClearUnitySearchClick">
407407
<TextBlock Text="" FontSize="8" Foreground="#FFC3C3C3" Padding="5,3,4,4" HorizontalAlignment="Center">
408408
<TextBlock.Style>
@@ -457,7 +457,7 @@
457457
<RowDefinition Height="32" />
458458
</Grid.RowDefinitions>
459459
<Button Grid.Column="0" Style="{StaticResource CustomButton}" x:Name="btnReleaseNotes" Background="{DynamicResource ButtonBackground}" Foreground="{DynamicResource ButtonForeground}" Margin="5,0,0,0" BorderBrush="{x:Null}" Click="BtnReleaseNotes_Click">
460-
<Label Content="Release Notes" Foreground="{Binding Path=Foreground, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Control}}}" />
460+
<Label Content="Release _Notes" Foreground="{Binding Path=Foreground, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Control}}}" />
461461
</Button>
462462
<Button Grid.Column="1" Style="{StaticResource CustomButton}" x:Name="btnUpdateUnity" Background="{DynamicResource ButtonBackground}" Foreground="{DynamicResource ButtonForeground}" Margin="8,0,0,0" BorderBrush="{x:Null}" Click="BtnUpdateUnity_Click">
463463
<Label Content="Update" Foreground="{Binding Path=Foreground, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Control}}}" />
@@ -479,7 +479,7 @@
479479
<!-- search box -->
480480
<Grid Background="{DynamicResource TextBoxBackground}" HorizontalAlignment="Left" VerticalAlignment="Top" Width="222" Margin="6,5,0,0" Height="20" >
481481
<TextBlock Margin="3,2" MinWidth="100" Text="Search" Foreground="#7F919191" Visibility="{Binding Text.IsEmpty, Converter={StaticResource MyBoolToVisibilityConverter}, ElementName=txtSearchBoxUpdates}" Height="24" />
482-
<TextBox MinWidth="100" CaretBrush="#FFE2E2E2" x:Name="txtSearchBoxUpdates" Background="Transparent" BorderBrush="{x:Null}" Foreground="#FFC7C7C7" SelectionBrush="#FF003966" BorderThickness="0" Margin="2,2,0,0" UndoLimit="64" PreviewKeyDown="TxtSearchBoxUpdates_PreviewKeyDown" />
482+
<TextBox MinWidth="100" CaretBrush="#FFE2E2E2" x:Name="txtSearchBoxUpdates" Background="Transparent" BorderBrush="{x:Null}" Foreground="#FFC7C7C7" SelectionBrush="#FF003966" BorderThickness="0" Margin="2,2,0,0" UndoLimit="64" PreviewKeyDown="TxtSearchBoxUpdates_PreviewKeyDown" TextChanged="TxtSearchBoxUpdates_TextChanged" />
483483
<Button x:Name="btnClearUpdatesSearch" Style="{StaticResource {x:Static ToolBar.ButtonStyleKey}}" BorderThickness="0" HorizontalAlignment="Right" VerticalAlignment="Top" Height="23" Width="23" Background="Transparent" Padding="0,2" Visibility="Visible" BorderBrush="{x:Null}" Click="OnClearUpdateSearchClick">
484484
<TextBlock Text="" FontSize="8" Foreground="#FFC3C3C3" Padding="5,3,4,4" HorizontalAlignment="Center">
485485
<TextBlock.Style>
@@ -504,7 +504,7 @@
504504
<DataGrid x:Name="dataGridUpdates" SelectionMode="Single" Margin="4,30,2,42" Background="{x:Null}" BorderBrush="{x:Null}" ColumnHeaderStyle="{StaticResource HeaderStyle}" Padding="0" HorizontalScrollBarVisibility="Disabled" HeadersVisibility="Column" Foreground="#FFD8D8D8" HorizontalGridLinesBrush="#4C000000" VerticalGridLinesBrush="#19000000" AutoGenerateColumns="False" PreviewKeyDown="DataGridUpdates_PreviewKeyDown">
505505

506506
<DataGrid.Columns>
507-
<DataGridTextColumn Binding="{Binding ReleaseDate, StringFormat=\{0:dd/MM/yyyy\}}" ClipboardContentBinding="{x:Null}" Header="ReleaseDate" IsReadOnly="True"/>
507+
<DataGridTextColumn Binding="{Binding ReleaseDate, StringFormat=\{0:dd/MM/yyyy\}}" ClipboardContentBinding="{x:Null}" MinWidth="100" Header="ReleaseDate" IsReadOnly="True"/>
508508
<DataGridTextColumn Binding="{Binding Version}" ClipboardContentBinding="{x:Null}" Header="Version" IsReadOnly="True" MinWidth="123">
509509
<DataGridTextColumn.CellStyle>
510510
<Style TargetType="{x:Type DataGridCell}">
@@ -542,7 +542,7 @@
542542
<Label Content="_Download in browser" Foreground="{Binding Path=Foreground, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Control}}}" />
543543
</Button>
544544
<Button Grid.Column="1" Style="{StaticResource CustomButton}" x:Name="btnOpenWebsite" Background="{DynamicResource ButtonBackground}" Foreground="{DynamicResource ButtonForeground}" Margin="8,0,0,0" BorderBrush="{x:Null}" Click="BtnOpenWebsite_Click" >
545-
<Label Content="_Release Notes" Foreground="{Binding Path=Foreground, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Control}}}" />
545+
<Label Content="Release _Notes" Foreground="{Binding Path=Foreground, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Control}}}" />
546546
</Button>
547547
</Grid>
548548
</Grid>

Diff for: UnityLauncherPro/MainWindow.xaml.cs

+65-11
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
using System;
1+
// Unity Project Launcher by https://unitycoder.com
2+
// Sources https://github.com/unitycoder/UnityLauncherPro
3+
4+
using System;
25
using System.Collections.Generic;
36
using System.ComponentModel;
47
using System.Diagnostics;
@@ -35,9 +38,11 @@ void Start()
3538
{
3639
LoadSettings();
3740

41+
// disable accesskeys without alt
42+
CoreCompatibilityPreferences.IsAltKeyRequiredInAccessKeyDefaultScope = true;
43+
3844
// make window resizable (this didnt work when used pure xaml to do this)
3945
WindowChrome Resizable_BorderLess_Chrome = new WindowChrome();
40-
//Resizable_BorderLess_Chrome.GlassFrameThickness = new Thickness(0);
4146
Resizable_BorderLess_Chrome.CornerRadius = new CornerRadius(0);
4247
Resizable_BorderLess_Chrome.CaptionHeight = 1.0;
4348
WindowChrome.SetWindowChrome(this, Resizable_BorderLess_Chrome);
@@ -131,20 +136,53 @@ void FilterRecentProjects()
131136
_filterString = txtSearchBox.Text;
132137
ICollectionView collection = CollectionViewSource.GetDefaultView(projectsSource);
133138
collection.Filter = ProjectFilter;
134-
135-
// set first row selected (good, especially if only one results)
139+
// set first row selected
136140
if (gridRecent.Items.Count > 0)
137141
{
138142
gridRecent.SelectedIndex = 0;
139143
}
140144
}
141145

146+
void FilterUpdates()
147+
{
148+
_filterString = txtSearchBoxUpdates.Text;
149+
ICollectionView collection = CollectionViewSource.GetDefaultView(dataGridUpdates.ItemsSource);
150+
collection.Filter = UpdatesFilter;
151+
if (dataGridUpdates.Items.Count > 0)
152+
{
153+
dataGridUpdates.SelectedIndex = 0;
154+
}
155+
}
156+
157+
void FilterUnitys()
158+
{
159+
_filterString = txtSearchBoxUnity.Text;
160+
ICollectionView collection = CollectionViewSource.GetDefaultView(dataGridUnitys.ItemsSource);
161+
collection.Filter = UnitysFilter;
162+
if (dataGridUnitys.Items.Count > 0)
163+
{
164+
dataGridUnitys.SelectedIndex = 0;
165+
}
166+
}
167+
142168
private bool ProjectFilter(object item)
143169
{
144170
Project proj = item as Project;
145171
return (proj.Title.IndexOf(_filterString, 0, StringComparison.CurrentCultureIgnoreCase) != -1);
146172
}
147173

174+
private bool UpdatesFilter(object item)
175+
{
176+
Updates unity = item as Updates;
177+
return (unity.Version.IndexOf(_filterString, 0, StringComparison.CurrentCultureIgnoreCase) != -1);
178+
}
179+
180+
private bool UnitysFilter(object item)
181+
{
182+
UnityInstallation unity = item as UnityInstallation;
183+
return (unity.Version.IndexOf(_filterString, 0, StringComparison.CurrentCultureIgnoreCase) != -1);
184+
}
185+
148186
void LoadSettings()
149187
{
150188
// form size
@@ -276,7 +314,6 @@ async void CallGetUnityUpdates()
276314
dataGridUpdates.ItemsSource = null;
277315
var task = GetUnityUpdates.Scan();
278316
var items = await task;
279-
// TODO handle errors?
280317
if (items == null) return;
281318
updatesSource = GetUnityUpdates.Parse(items);
282319
if (updatesSource == null) return;
@@ -334,7 +371,6 @@ private void OnRectangleMouseDown(object sender, MouseButtonEventArgs e)
334371

335372
private void OnSearchTextChanged(object sender, TextChangedEventArgs e)
336373
{
337-
TextBox textbox = (TextBox)sender;
338374
FilterRecentProjects();
339375
}
340376

@@ -383,7 +419,7 @@ private void BtnMinimize_Click(object sender, RoutedEventArgs e)
383419
}
384420
}
385421

386-
private async void OnGetUnityUpdatesClick(object sender, RoutedEventArgs e)
422+
private void OnGetUnityUpdatesClick(object sender, RoutedEventArgs e)
387423
{
388424
var button = (Button)sender;
389425
button.IsEnabled = false;
@@ -395,8 +431,12 @@ private async void OnGetUnityUpdatesClick(object sender, RoutedEventArgs e)
395431

396432
private void OnWindowKeyDown(object sender, KeyEventArgs e)
397433
{
398-
// TODO if editing cells, dont focus on search
399-
//if (gridRecent.IsCurrentCellInEditMode == true) return;
434+
// disable alt key?
435+
/*
436+
if (Keyboard.Modifiers == ModifierKeys.Alt)
437+
{
438+
e.Handled = true;
439+
}*/
400440

401441
switch (tabControl.SelectedIndex)
402442
{
@@ -418,6 +458,9 @@ private void OnWindowKeyDown(object sender, KeyEventArgs e)
418458
IEditableCollectionView itemsView = gridRecent.Items;
419459
if (itemsView.IsAddingNew || itemsView.IsEditingItem) return;
420460

461+
// skip these keys
462+
if (Keyboard.Modifiers == ModifierKeys.Alt) return;
463+
421464
// activate searchbar if not active and we are in tab#1
422465
if (txtSearchBox.IsFocused == false)
423466
{
@@ -537,8 +580,10 @@ private void MenuItemCopyVersion_Click(object sender, RoutedEventArgs e)
537580
}
538581
else if (tabControl.SelectedIndex == 2)
539582
{
540-
//var update = getselect
583+
var unity = GetSelectedUpdate();
584+
copy = unity?.Version;
541585
}
586+
542587
if (copy != null) Clipboard.SetText(copy);
543588
}
544589

@@ -927,8 +972,17 @@ private void GridRecent_CellEditEnding(object sender, DataGridCellEditEndingEven
927972
//SetStatus("File error: " + exception.Message);
928973
Console.WriteLine(ex);
929974
}
930-
931975
// TODO select the same row again
932976
}
977+
978+
private void TxtSearchBoxUpdates_TextChanged(object sender, TextChangedEventArgs e)
979+
{
980+
FilterUpdates();
981+
}
982+
983+
private void TxtSearchBoxUnity_TextChanged(object sender, TextChangedEventArgs e)
984+
{
985+
FilterUnitys();
986+
}
933987
} // class
934988
} //namespace

Diff for: UnityLauncherPro/Tools.cs

+10-24
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
using System.Text;
99
using System.Text.RegularExpressions;
1010
using System.Windows;
11-
using System.Windows.Controls;
1211
using System.Windows.Input;
1312

1413
namespace UnityLauncherPro
@@ -132,13 +131,14 @@ public static void ExploreProjectFolder(Project proj)
132131
}
133132
}
134133

134+
// NOTE holding alt key (when using alt+o) brings up unity project selector
135135
public static void LaunchProject(Project proj)
136136
{
137137
// validate
138138
if (proj == null) return;
139139
if (Directory.Exists(proj.Path) == false) return;
140140

141-
Console.WriteLine("launching " + proj.Title);
141+
Console.WriteLine("launch project " + proj.Title);
142142

143143
// there is no assets path, probably we want to create new project then
144144
var assetsFolder = Path.Combine(proj.Path, "Assets");
@@ -148,7 +148,6 @@ public static void LaunchProject(Project proj)
148148
Directory.CreateDirectory(assetsFolder);
149149
}
150150

151-
152151
// when opening project, check for crashed backup scene first
153152
var cancelLaunch = CheckCrashBackupScene(proj.Path);
154153
if (cancelLaunch == true)
@@ -164,37 +163,24 @@ public static void LaunchProject(Project proj)
164163
return;
165164
}
166165

167-
/*
168-
if (openProject == true)
169-
{
170-
SetStatus("Launching project in Unity " + version);
171-
}
172-
else
173-
{
174-
SetStatus("Launching Unity " + version);
175-
}*/
166+
// SetStatus("Launching project in Unity " + version);
176167

177168
try
178169
{
179170
Process myProcess = new Process();
180171
var cmd = "\"" + unityExePath + "\"";
181172
myProcess.StartInfo.FileName = cmd;
182173

183-
//if (openProject == true)
184-
{
185-
var pars = " -projectPath " + "\"" + proj.Path + "\"";
174+
var unitycommandlineparameters = " -projectPath " + "\"" + proj.Path + "\"";
186175

187-
// TODO check for custom launch parameters and append them
188-
//string customArguments = GetSelectedRowData("_launchArguments");
189-
//if (string.IsNullOrEmpty(customArguments) == false)
190-
//{
191-
// pars += " " + customArguments;
192-
//}
193-
194-
myProcess.StartInfo.Arguments = pars;// TODO args + commandLineArguments;
176+
string customArguments = proj.Arguments;
177+
if (string.IsNullOrEmpty(customArguments) == false)
178+
{
179+
unitycommandlineparameters += " " + customArguments;
195180
}
196-
myProcess.Start();
197181

182+
myProcess.StartInfo.Arguments = unitycommandlineparameters;
183+
myProcess.Start();
198184

199185
if (Properties.Settings.Default.closeAfterProject)
200186
{

0 commit comments

Comments
 (0)