Skip to content

Commit 96697e6

Browse files
committed
fix nullref on missing project platform selection dropdown, fix project list sorting (missing project had wrong platform), fix sorting null modified dates, update maxProjectCount value on checkbox setting, fix backslashes when adding projects
1 parent 83b744d commit 96697e6

File tree

4 files changed

+36
-11
lines changed

4 files changed

+36
-11
lines changed

UnityLauncherPro/GetProjects.cs

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ public static List<Project> Scan(bool getGitBranch = false, bool getPlasticBranc
5454
}
5555

5656
var p = GetProjectInfo(projectPath, getGitBranch, getPlasticBranch, getArguments, showMissingFolders, showTargetPlatform);
57+
//Console.WriteLine(projectPath+" "+p.TargetPlatform);
5758

5859
// if want to hide project and folder path for screenshot
5960
//p.Title = "Example Project ";
@@ -91,7 +92,7 @@ public static List<Project> Scan(bool getGitBranch = false, bool getPlasticBranc
9192
}
9293
}
9394

94-
// if not found, add
95+
// if not found from full history list, add
9596
if (found == false)
9697
{
9798
var p = GetProjectInfo(projectPath, getGitBranch, getPlasticBranch, getArguments, showMissingFolders, showTargetPlatform);
@@ -102,12 +103,21 @@ public static List<Project> Scan(bool getGitBranch = false, bool getPlasticBranc
102103

103104
// NOTE sometimes projects are in wrong order, seems to be related to messing up your unity registry, the keys are received in created order (so if you had removed/modified them manually, it might return wrong order instead of 0 - 40)
104105
// thats why need to sort projects list by modified date
105-
projectsFound.Sort((x, y) => y.Modified.Value.CompareTo(x.Modified.Value));
106+
// sort by modified date, projects without modified date are put to last, NOTE: this would remove projects without modified date (if they become last items, before trimming list on next step)
107+
projectsFound.Sort((x, y) =>
108+
{
109+
if (x.Modified == null && y.Modified == null) return -1; // was 0
110+
if (x.Modified == null) return 1;
111+
if (y.Modified == null) return -1;
112+
return y.Modified.Value.CompareTo(x.Modified.Value);
113+
//return x.Modified.Value.CompareTo(y.Modified.Value); // BUG this breaks something, so that last item platform is wrong (for project that is missing from disk) ?
114+
});
115+
//projectsFound.Sort((x, y) => y.Modified.Value.CompareTo(x.Modified.Value));
106116

107117
// trim list to max amount TODO only if enabled in settings
108118
if (projectsFound.Count > MainWindow.maxProjectCount)
109119
{
110-
Console.WriteLine("Trimming projects list to " + MainWindow.maxProjectCount + " projects");
120+
//Console.WriteLine("Trimming projects list to " + MainWindow.maxProjectCount + " projects");
111121
projectsFound.RemoveRange(MainWindow.maxProjectCount, projectsFound.Count - MainWindow.maxProjectCount);
112122
}
113123

@@ -116,8 +126,9 @@ public static List<Project> Scan(bool getGitBranch = false, bool getPlasticBranc
116126

117127
static Project GetProjectInfo(string projectPath, bool getGitBranch = false, bool getPlasticBranch = false, bool getArguments = false, bool showMissingFolders = false, bool showTargetPlatform = false)
118128
{
119-
// first check if whole folder exists, if not, skip
120129
bool folderExists = Directory.Exists(projectPath);
130+
131+
// if displaying missing folders are disabled, and folder doesnt exists, skip this project
121132
if (showMissingFolders == false && folderExists == false) return null;
122133

123134
string projectName = "";
@@ -163,10 +174,11 @@ static Project GetProjectInfo(string projectPath, bool getGitBranch = false, boo
163174
}
164175
}
165176

166-
string targetPlatform = "";
177+
string targetPlatform = null;
167178
if (showTargetPlatform == true)
168179
{
169180
targetPlatform = folderExists ? Tools.GetTargetPlatform(projectPath) : null;
181+
//if (projectPath.Contains("Shader")) Console.WriteLine(projectPath + " targetPlatform=" + targetPlatform);
170182
}
171183

172184
var p = new Project();
@@ -197,7 +209,6 @@ static Project GetProjectInfo(string projectPath, bool getGitBranch = false, boo
197209

198210
// bubblegum(TM) solution, fill available platforms for this unity version, for this project
199211
p.TargetPlatforms = Tools.GetPlatformsForUnityVersion(projectVersion);
200-
201212
p.folderExists = folderExists;
202213
return p;
203214
}

UnityLauncherPro/MainWindow.xaml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -668,9 +668,12 @@
668668
<Button Style="{StaticResource CustomButton}" ToolTip="Explore Scripts folder" x:Name="btnExploreScriptsFolder" Content="..." Height="22" Width="22" HorizontalAlignment="Right" VerticalAlignment="Top" FontSize="16" Padding="1,-2,1,1" BorderBrush="{x:Null}" Click="btnExploreScriptsFolder_Click" Margin="5,0,0,0"/>
669669
</StackPanel>
670670

671-
<Button x:Name="btnPatchHubConfig" ToolTip="Modifies json file to set 'manual:true' values into 'false', so that can add modules using Hub. NOTE: This cannot be reversed (not keeping track which values were already 'false')" Style="{StaticResource CustomButton}" BorderBrush="{x:Null}" HorizontalAlignment="Left" VerticalAlignment="Top" Click="btnPatchHubConfig_Click">
672-
<Label Content="Patch Hub editors.json" Foreground="{Binding Path=Foreground, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Control}}}" />
673-
</Button>
671+
<StackPanel Grid.Row="3" Orientation="Horizontal" Margin="0,6,0,0">
672+
<Button x:Name="btnPatchHubConfig" ToolTip="Modifies json file to set 'manual:true' values into 'false', so that can add modules using Hub. NOTE: This cannot be reversed (not keeping track which values were already 'false')" Style="{StaticResource CustomButton}" BorderBrush="{x:Null}" HorizontalAlignment="Left" VerticalAlignment="Top" Click="btnPatchHubConfig_Click">
673+
<Label Content="Patch Hub editors.json" Foreground="{Binding Path=Foreground, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Control}}}" />
674+
</Button>
675+
<Label Content="*If want to install modeules from Hub" Foreground="{DynamicResource ThemeButtonForeground}" />
676+
</StackPanel>
674677

675678
<StackPanel Grid.Row="3" Orientation="Horizontal" Margin="0,6,0,0">
676679
<TextBox x:Name="txtWebglPort" BorderBrush="Transparent" CaretBrush="{DynamicResource ThemeSearchCaret}" Background="{DynamicResource ThemeTextBoxBackground}" SelectionBrush="{DynamicResource ThemeSearchSelection}" Foreground="{DynamicResource ThemeSearchForeground}" MinWidth="80" ToolTip="Initial port for first local WebGL webserver process (next one will be +1)" Padding="0,3,0,0" TextChanged="txtWebglPort_TextChanged" HorizontalAlignment="Left" Text="50000" LostFocus="txtWebglPort_LostFocus" />

UnityLauncherPro/MainWindow.xaml.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2312,7 +2312,7 @@ private void CmbPlatformSelection_DropDownClosed(object sender, EventArgs e)
23122312
var cmb = (ComboBox)sender;
23132313
//Console.WriteLine(cmb.SelectedValue);
23142314
var p = GetSelectedProject();
2315-
if (p != null) p.TargetPlatform = cmb.SelectedValue.ToString();
2315+
if (p != null && p.TargetPlatform!=null) p.TargetPlatform = cmb.SelectedValue.ToString();
23162316
}
23172317
catch (Exception ex)
23182318
{
@@ -3024,6 +3024,14 @@ private void chkOverride40ProjectCount_Checked(object sender, RoutedEventArgs e)
30243024

30253025
Properties.Settings.Default.override40ProjectCount = (bool)((CheckBox)sender).IsChecked;
30263026
Properties.Settings.Default.Save();
3027+
if ((bool)chkOverride40ProjectCount.IsChecked)
3028+
{
3029+
maxProjectCount = Properties.Settings.Default.maxProjectCount;
3030+
}
3031+
else
3032+
{
3033+
maxProjectCount = 40;
3034+
}
30273035
}
30283036

30293037
private void txtMaxProjectCount_LostFocus(object sender, RoutedEventArgs e)
@@ -3046,7 +3054,7 @@ private void txtMaxProjectCount_TextChanged(object sender, TextChangedEventArgs
30463054
{
30473055
if (this.IsActive == false) return; // dont run code on window init
30483056

3049-
// TODO duplicate code
3057+
// TODO remove duplicate code
30503058
var ok = ValidateIntRange((TextBox)sender, 10, 1024);
30513059
maxProjectCount = 40;
30523060
if (ok)

UnityLauncherPro/Tools.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,9 @@ public static void ExploreFolder(string path)
189189
// this runs before unity editor starts, so the project is not yet in registry (unless it already was there)
190190
public static void AddProjectToHistory(string projectPath)
191191
{
192+
// fix backslashes
193+
projectPath = projectPath.Replace('\\', '/');
194+
192195
if (Properties.Settings.Default.projectPaths.Contains(projectPath) == false)
193196
{
194197
// TODO do we need to add as first?

0 commit comments

Comments
 (0)