Skip to content

Commit 26bf0d8

Browse files
committed
add Purge button (for project paths with missing folder, those are hanging in Settings string list), add status messages for new project creation failures
1 parent 25f2947 commit 26bf0d8

File tree

4 files changed

+54
-9
lines changed

4 files changed

+54
-9
lines changed

UnityLauncherPro/MainWindow.xaml

+9-2
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,8 @@
238238
</DataGrid.ContextMenu>
239239

240240
<!-- TODO cannot have this enabled, otherwise needs additional .Clear() at start before setting itemsource data -->
241-
<!-- sample data for testing --><!--
241+
<!-- sample data for testing -->
242+
<!--
242243
<local:Project TargetPlatform="win64" GITBranch="Best" Modified="" Title="M dfgh dfghMO" Path="A:/temp" Version="2099.1.2.3" />
243244
<local:Project GITBranch="" Modified="" Title="asdgdfg" Path="A:/temp" Version="5.6.7f1"/>
244245
<local:Project GITBranch="" Modified="" Title="Mghdfghdf dfghdfgMO" Path="A:/temp" Version="2018.3.13f1"/>
@@ -772,7 +773,13 @@
772773
</StackPanel>
773774
<CheckBox x:Name="chkAskNameForQuickProject" Content="Ask name for New Project" Checked="ChkAskNameForQuickProject_Checked" Unchecked="ChkAskNameForQuickProject_Checked" ToolTip="If disabled, uses automatic quick project naming (Should be enabled, unless you want instant project creation)" HorizontalAlignment="Left"/>
774775
<CheckBox x:Name="chkCheckSRP" Content="Show SRP column" ToolTip="Display Scriptable Render Pipeline column" HorizontalAlignment="Left" Checked="chkCheckSRP_Checked" Unchecked="chkCheckSRP_Checked"/>
775-
<CheckBox x:Name="chkShowMissingFolderProjects" Content="Show projects that don't exist on disk" Checked="ChkShowMissingFolderProjects_CheckedChanged" Unchecked="ChkShowMissingFolderProjects_CheckedChanged" ToolTip="List in recent projects, even if the project folder is missing" HorizontalAlignment="Left"/>
776+
<StackPanel Orientation="Horizontal" HorizontalAlignment="Left">
777+
<CheckBox x:Name="chkShowMissingFolderProjects" Content="Show projects that don't exist on disk" Checked="ChkShowMissingFolderProjects_CheckedChanged" Unchecked="ChkShowMissingFolderProjects_CheckedChanged" ToolTip="List in recent projects, even if the project folder is missing" HorizontalAlignment="Left"/>
778+
<Button Style="{StaticResource CustomButton}" x:Name="btnPurgeMissingFolders" Margin="12,0,0,0" BorderBrush="{x:Null}" HorizontalAlignment="Left" VerticalAlignment="Top" ToolTip="Cleanup projects with missing project folder from the recent list (in settings data)" Click="btnPurgeMissingFolders_Click">
779+
<Label Content="Purge list" Foreground="{Binding Path=Foreground, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Control}}}" />
780+
</Button>
781+
782+
</StackPanel>
776783
<CheckBox x:Name="chkShowLauncherArgumentsColumn" Content="Show commandline arguments column" Unchecked="ChkShowLauncherArgumentsColumn_CheckedChanged" Checked="ChkShowLauncherArgumentsColumn_CheckedChanged" ToolTip="Shows column for custom project commandline params" HorizontalAlignment="Left"/>
777784
<StackPanel Orientation="Horizontal" HorizontalAlignment="Left">
778785
<Label Foreground="{DynamicResource ThemeButtonForeground}" Padding="0,5,5,0" HorizontalAlignment="Left">Project name:</Label>

UnityLauncherPro/MainWindow.xaml.cs

+36
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using System;
55
using System.Collections;
66
using System.Collections.Generic;
7+
using System.Collections.Specialized;
78
using System.ComponentModel;
89
using System.Configuration;
910
using System.Diagnostics;
@@ -151,6 +152,9 @@ void Start()
151152
//Properties.Settings.Default.projectPaths = null;
152153
//Properties.Settings.Default.Save();
153154

155+
156+
157+
154158
projectsSource = GetProjects.Scan(getGitBranch: (bool)chkShowGitBranchColumn.IsChecked, getPlasticBranch: (bool)chkCheckPlasticBranch.IsChecked, getArguments: (bool)chkShowLauncherArgumentsColumn.IsChecked, showMissingFolders: (bool)chkShowMissingFolderProjects.IsChecked, showTargetPlatform: (bool)chkShowPlatform.IsChecked, AllProjectPaths: Properties.Settings.Default.projectPaths, searchGitbranchRecursively: (bool)chkGetGitBranchRecursively.IsChecked, showSRP: (bool)chkCheckSRP.IsChecked);
155159

156160
//Console.WriteLine("projectsSource.Count: " + projectsSource.Count);
@@ -1183,6 +1187,7 @@ private void RemoveProjectFromList(bool confirm = false)
11831187
gridRecent.SelectedIndex = 0;
11841188
}
11851189

1190+
// NOTE this doesnt remove from settings list?
11861191
}
11871192

11881193
private async void OnTabSelectionChanged(object sender, SelectionChangedEventArgs e)
@@ -4077,6 +4082,37 @@ private void menuExcludeFromDefender_Click(object sender, RoutedEventArgs e)
40774082
}
40784083
}
40794084

4085+
private void btnPurgeMissingFolders_Click(object sender, RoutedEventArgs e)
4086+
{
4087+
var validPaths = new List<string>();
4088+
int removedCount = 0;
4089+
foreach (string path in Settings.Default.projectPaths)
4090+
{
4091+
if (!string.IsNullOrEmpty(path) && Directory.Exists(path))
4092+
{
4093+
validPaths.Add(path);
4094+
}
4095+
else
4096+
{
4097+
Console.WriteLine("Path not found: " + path);
4098+
removedCount++;
4099+
}
4100+
}
4101+
4102+
// Replace the old collection with the filtered one
4103+
var newCollection = new StringCollection();
4104+
foreach (string path in validPaths)
4105+
{
4106+
newCollection.Add(path);
4107+
}
4108+
4109+
Settings.Default.projectPaths = newCollection;
4110+
Settings.Default.Save();
4111+
4112+
SetStatus("Purged " + removedCount + " items", MessageType.Info);
4113+
}
4114+
4115+
40804116
//private void menuProjectProperties_Click(object sender, RoutedEventArgs e)
40814117
//{
40824118
// var proj = GetSelectedProject();

UnityLauncherPro/NewProject.xaml.cs

+3-4
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,12 @@ public NewProject(string unityVersion, string suggestedName, string targetFolder
4040
txtNewProjectName.Text = newName;
4141
lblNewProjectFolder.Content = targetFolder;
4242

43-
//// fill available versions
43+
// fill available versions
4444
if (gridAvailableVersions.ItemsSource == null)
4545
{
4646
gridAvailableVersions.ItemsSource = MainWindow.unityInstallationsSource;
4747
}
48-
48+
4949
// we have that version installed
5050
if (MainWindow.unityInstalledVersions.ContainsKey(unityVersion) == true)
5151
{
@@ -131,11 +131,10 @@ private void BtnCreateNewProject_Click(object sender, RoutedEventArgs e)
131131
var targetPath = Path.Combine(targetFolder, txtNewProjectName.Text);
132132
if (txtNewProjectName.IsEnabled == true && Directory.Exists(targetPath) == true)
133133
{
134-
System.Console.WriteLine("Project already exists");
134+
Tools.SetStatus("Project already exists: " + txtNewProjectName.Text);
135135
return;
136136
}
137137

138-
139138
templateZipPath = ((KeyValuePair<string, string>)cmbNewProjectTemplate.SelectedValue).Value;
140139
selectedPlatform = cmbNewProjectPlatform.SelectedValue.ToString();
141140
UpdateSelectedVersion();

UnityLauncherPro/Tools.cs

+6-3
Original file line numberDiff line numberDiff line change
@@ -1673,21 +1673,22 @@ public static Project FastCreateProject(string version, string baseFolder, strin
16731673
// check for base folders in settings tab
16741674
if (string.IsNullOrEmpty(baseFolder) == true)
16751675
{
1676-
Console.WriteLine("Missing baseFolder value");
1676+
SetStatus("Missing baseFolder value");
16771677
return null;
16781678
}
16791679

16801680
// check if base folder exists
16811681
if (Directory.Exists(baseFolder) == false)
16821682
{
1683-
Console.WriteLine("Missing baseFolder: " + baseFolder);
1683+
// TODO add streaming filter
1684+
SetStatus("Missing baseFolder: " + baseFolder);
16841685
return null;
16851686
}
16861687

16871688
// check selected unity version
16881689
if (string.IsNullOrEmpty(version) == true)
16891690
{
1690-
Console.WriteLine("Missing unity version string");
1691+
SetStatus("Missing unity version string");
16911692
return null;
16921693
}
16931694

@@ -1773,6 +1774,8 @@ public static string GetSuggestedProjectName(string version, string baseFolder)
17731774
static void CreateEmptyProjectFolder(string path, string version)
17741775
{
17751776
Console.WriteLine("Create new project folder: " + path);
1777+
// TODO add streaming filter
1778+
SetStatus("Creating new project folder: " + path);
17761779
Directory.CreateDirectory(path);
17771780

17781781
// create project version file, to avoid wrong version warning

0 commit comments

Comments
 (0)