Skip to content

Commit aac1c6b

Browse files
committed
add option to show new project dialog and set project name (for Quick Project), fix empty row in recent project grid, #build
1 parent 9ffa897 commit aac1c6b

10 files changed

+270
-35
lines changed

Diff for: UnityLauncherPro/App.config

+3
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@
5454
<setting name="newProjectsRoot" serializeAs="String">
5555
<value />
5656
</setting>
57+
<setting name="askNameForQuickProject" serializeAs="String">
58+
<value>True</value>
59+
</setting>
5760
</UnityLauncherPro.Properties.Settings>
5861
</userSettings>
5962
</configuration>

Diff for: UnityLauncherPro/GetProjects.cs

+1
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ public static List<Project> Scan(bool getGitBranch = false, bool getArguments =
112112
gitBranch = Tools.ReadGitBranchInfo(projectPath);
113113
}
114114

115+
115116
var p = new Project();
116117
p.Title = projectName;
117118
p.Version = projectVersion;

Diff for: UnityLauncherPro/MainWindow.xaml

+5-4
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@
302302
<Button Style="{StaticResource CustomButton}" ToolTip="Add existing project" x:Name="btnAddProjectFolder" Content="Add Project.." Height="22" Width="78" HorizontalAlignment="Right" VerticalAlignment="Top" Background="#FF3F3F46" Foreground="#FFC1C1C1" Margin="0,4,34,0" Click="BtnAddProjectFolder_Click" BorderBrush="{x:Null}" TabIndex="10" />
303303
<Button Style="{StaticResource CustomButton}" ToolTip="Refresh list (F5)" x:Name="btnRefreshProjectList" Content="" Height="22" Width="22" HorizontalAlignment="Right" VerticalAlignment="Top" FontSize="16" Background="#FF3F3F46" Foreground="#FFC1C1C1" Margin="0,4,3,0" Padding="1,-2,1,1" BorderBrush="{x:Null}" Click="BtnRefreshProjectList_Click" TabIndex="11"/>
304304

305-
<DataGrid x:Name="gridRecent" 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="GridRecent_PreviewKeyDown" Loaded="GridRecent_Loaded" TabIndex="2" CellEditEnding="GridRecent_CellEditEnding" PreviewMouseDoubleClick="GridRecent_PreviewMouseDoubleClick" >
305+
<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="#FFD8D8D8" HorizontalGridLinesBrush="#4C000000" VerticalGridLinesBrush="#19000000" AutoGenerateColumns="False" PreviewKeyDown="GridRecent_PreviewKeyDown" Loaded="GridRecent_Loaded" TabIndex="2" CellEditEnding="GridRecent_CellEditEnding" PreviewMouseDoubleClick="GridRecent_PreviewMouseDoubleClick" >
306306
<DataGrid.Columns>
307307
<DataGridTextColumn CellStyle="{StaticResource NoFocusCellStyle}" Binding="{Binding Title}" ClipboardContentBinding="{x:Null}" Header="Project" IsReadOnly="True" Width="150"/>
308308
<DataGridTextColumn Binding="{Binding Version}" ClipboardContentBinding="{x:Null}" Header="Version" IsReadOnly="True" Width="72">
@@ -372,10 +372,10 @@
372372
<Grid VerticalAlignment="Bottom" Margin="4,0,8,5">
373373
<Grid.ColumnDefinitions>
374374
<ColumnDefinition Width="12*" />
375-
<ColumnDefinition Width="20*" />
375+
<ColumnDefinition Width="18*" />
376376
<ColumnDefinition Width="15*" />
377377
<ColumnDefinition Width="50*" />
378-
<ColumnDefinition Width="12*" />
378+
<ColumnDefinition Width="14*" />
379379
</Grid.ColumnDefinitions>
380380
<Grid.RowDefinitions>
381381
<RowDefinition Height="32" />
@@ -646,10 +646,11 @@
646646
<CheckBox x:Name="chkShowGitBranchColumn" Content="Show Git Branch Column" Foreground="{DynamicResource ButtonForeground}" Checked="ChkShowGitBranchColumn_CheckedChanged" Unchecked="ChkShowGitBranchColumn_CheckedChanged" Margin="0,0,0,3"/>
647647
<CheckBox x:Name="chkShowMissingFolderProjects" Content="Show projects that dont exist on disk" Foreground="{DynamicResource ButtonForeground}" Checked="ChkShowMissingFolderProjects_CheckedChanged" Unchecked="ChkShowMissingFolderProjects_CheckedChanged" Margin="0,0,0,3" ToolTip="List recent projects, even if the project folder is missing"/>
648648
<CheckBox x:Name="chkAllowSingleInstanceOnly" Content="Allow single instance only" Foreground="{DynamicResource ButtonForeground}" Checked="ChkAllowSingleInstanceOnly_CheckedChanged" Unchecked="ChkAllowSingleInstanceOnly_CheckedChanged" Margin="0,0,0,3" ToolTip="Activates already running instance, instead of starting new exe"/>
649+
<CheckBox x:Name="chkAskNameForQuickProject" Content="Ask name for Quick Project" Foreground="{DynamicResource ButtonForeground}" Checked="ChkAskNameForQuickProject_Checked" Unchecked="ChkAskNameForQuickProject_Checked" Margin="0,0,0,3" ToolTip="If disabled, uses automatic quick project naming"/>
649650

650651
<StackPanel Grid.Row="3" Orientation="Horizontal">
651652
<Label Content="Root Folder for New Projects" Foreground="{DynamicResource ButtonForeground}" />
652-
<TextBox x:Name="txtRootFolderForNewProjects" MinWidth="250" ToolTip="When you click &quot;Create Project&quot; in main page, new project is generated under this path+UnityVersion (eg. /2017a/)" Padding="0,3,0,0" TextChanged="TxtRootFolderForNewProjects_TextChanged" />
653+
<TextBox x:Name="txtRootFolderForNewProjects" MinWidth="300" ToolTip="When you click &quot;Create Project&quot; in main page, new project is generated under this path+UnityVersion (eg. /2017a/)" Padding="0,3,0,0" TextChanged="TxtRootFolderForNewProjects_TextChanged" />
653654
<Button x:Name="btnBrowseProjectRootFolder" Content="..." Margin="6,0,0,0" MinWidth="32" Click="BtnBrowseProjectRootFolder_Click" />
654655
</StackPanel>
655656
</StackPanel>

Diff for: UnityLauncherPro/MainWindow.xaml.cs

+73-3
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ void Start()
8989
gridRecent.Items.Clear();
9090
gridRecent.ItemsSource = projectsSource;
9191

92-
// updates grid
92+
// clear updates grid
9393
dataGridUpdates.Items.Clear();
9494

9595
// build notifyicon (using windows.forms)
@@ -243,6 +243,7 @@ void LoadSettings()
243243
chkShowMissingFolderProjects.IsChecked = Properties.Settings.Default.showProjectsMissingFolder;
244244
chkAllowSingleInstanceOnly.IsChecked = Properties.Settings.Default.AllowSingleInstanceOnly;
245245
txtRootFolderForNewProjects.Text = Properties.Settings.Default.newProjectsRoot;
246+
chkAskNameForQuickProject.IsChecked = Properties.Settings.Default.askNameForQuickProject;
246247

247248
// update optional grid columns, hidden or visible
248249
gridRecent.Columns[4].Visibility = (bool)chkShowLauncherArgumentsColumn.IsChecked ? Visibility.Visible : Visibility.Collapsed;
@@ -1157,7 +1158,7 @@ private void MenuItemCopyPath_Click(object sender, RoutedEventArgs e)
11571158
// creates empty project into default project root with selected unity version
11581159
private void BtnCreateEmptyProject_Click(object sender, RoutedEventArgs e)
11591160
{
1160-
Tools.FastCreateProject(GetSelectedProject().Version, txtRootFolderForNewProjects.Text);
1161+
CreateNewEmptyProject();
11611162
}
11621163

11631164
private void BtnBrowseProjectRootFolder_Click(object sender, RoutedEventArgs e)
@@ -1181,7 +1182,76 @@ private void TxtRootFolderForNewProjects_TextChanged(object sender, TextChangedE
11811182

11821183
private void BtnCreateEmptyProjectUnity_Click(object sender, RoutedEventArgs e)
11831184
{
1184-
Tools.FastCreateProject(GetSelectedUnity().Version, txtRootFolderForNewProjects.Text);
1185+
CreateNewEmptyProject();
1186+
}
1187+
1188+
void CreateNewEmptyProject()
1189+
{
1190+
if (chkAskNameForQuickProject.IsChecked == true)
1191+
{
1192+
// ask name
1193+
string newVersion = null;
1194+
1195+
// if in maintab
1196+
if (tabControl.SelectedIndex == 0)
1197+
{
1198+
newVersion = GetSelectedProject().Version == null ? preferredVersion : GetSelectedProject().Version;
1199+
}
1200+
else // unity tab
1201+
{
1202+
newVersion = GetSelectedUnity().Version == null ? preferredVersion : GetSelectedUnity().Version;
1203+
}
1204+
1205+
if (string.IsNullOrEmpty(newVersion))
1206+
{
1207+
Console.WriteLine("Missing selected unity version");
1208+
return;
1209+
}
1210+
1211+
NewProject modalWindow = new NewProject(newVersion, Tools.GetSuggestedProjectName(newVersion, txtRootFolderForNewProjects.Text));
1212+
modalWindow.ShowInTaskbar = this == null;
1213+
modalWindow.WindowStartupLocation = this == null ? WindowStartupLocation.CenterScreen : WindowStartupLocation.CenterOwner;
1214+
modalWindow.Topmost = this == null;
1215+
modalWindow.ShowActivated = true;
1216+
modalWindow.Owner = this;
1217+
modalWindow.ShowDialog();
1218+
var results = modalWindow.DialogResult.HasValue && modalWindow.DialogResult.Value;
1219+
1220+
if (results == true)
1221+
{
1222+
var projectPath = txtRootFolderForNewProjects.Text;
1223+
Console.WriteLine("create project " + projectPath);
1224+
if (string.IsNullOrEmpty(projectPath)) return;
1225+
1226+
Tools.FastCreateProject(newVersion, projectPath, NewProject.newProjectName);
1227+
}
1228+
else // false, cancel
1229+
{
1230+
Console.WriteLine("Cancellled project creation..");
1231+
}
1232+
1233+
}
1234+
else // use automatic name
1235+
{
1236+
string newVersion = null;
1237+
// if in maintab
1238+
if (tabControl.SelectedIndex == 0)
1239+
{
1240+
newVersion = GetSelectedProject().Version == null ? preferredVersion : GetSelectedProject().Version;
1241+
}
1242+
else // unity tab
1243+
{
1244+
newVersion = GetSelectedUnity().Version == null ? preferredVersion : GetSelectedUnity().Version;
1245+
}
1246+
Tools.FastCreateProject(newVersion, txtRootFolderForNewProjects.Text);
1247+
}
1248+
1249+
}
1250+
1251+
private void ChkAskNameForQuickProject_Checked(object sender, RoutedEventArgs e)
1252+
{
1253+
Properties.Settings.Default.askNameForQuickProject = (bool)chkAskNameForQuickProject.IsChecked;
1254+
Properties.Settings.Default.Save();
11851255
}
11861256
} // class
11871257
} //namespace

Diff for: UnityLauncherPro/NewProject.xaml

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
<Window x:Class="UnityLauncherPro.NewProject"
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="Create New Project" Height="200" Width="300" Background="{DynamicResource DarkestBackground}" PreviewKeyDown="Window_PreviewKeyDown">
9+
<Window.Resources>
10+
<!-- custom buttons -->
11+
<Style x:Key="CustomButton" TargetType="{x:Type Button}">
12+
<Setter Property="SnapsToDevicePixels" Value="true"/>
13+
<Setter Property="OverridesDefaultStyle" Value="true"/>
14+
<Setter Property="Template">
15+
<Setter.Value>
16+
<ControlTemplate TargetType="{x:Type Button}">
17+
<Border x:Name="shortcutbutton" BorderThickness="0" BorderBrush="Black" Background="{TemplateBinding Background}">
18+
<ContentPresenter Margin="0" HorizontalAlignment="Center" VerticalAlignment="Center" RecognizesAccessKey="True"/>
19+
</Border>
20+
<ControlTemplate.Triggers>
21+
<Trigger Property="IsMouseOver" Value="true">
22+
<Setter TargetName="shortcutbutton" Property="Background" Value="#FF494949" />
23+
</Trigger>
24+
<Trigger Property="IsPressed" Value="true">
25+
<Setter TargetName="shortcutbutton" Property="Background" Value="#FF0F0F0F" />
26+
</Trigger>
27+
</ControlTemplate.Triggers>
28+
</ControlTemplate>
29+
</Setter.Value>
30+
</Setter>
31+
</Style>
32+
</Window.Resources>
33+
34+
<Grid>
35+
<StackPanel Margin="10,3">
36+
<Label Content="Unity Version " Foreground="{DynamicResource ButtonForeground}" Margin="0,0,0,3" />
37+
<TextBox x:Name="txtNewProjectVersion" VerticalAlignment="Center" Margin="0,0,0,3" IsEnabled="False" IsReadOnly="True" IsUndoEnabled="False" />
38+
<Label Content="Project Name:" Foreground="{DynamicResource ButtonForeground}" Margin="0,0,0,3" />
39+
<TextBox x:Name="txtNewProjectName" VerticalAlignment="Center" Margin="0,0,0,3" IsUndoEnabled="True" TextChanged="TxtNewProjectName_TextChanged" />
40+
<Grid HorizontalAlignment="Stretch" Margin="0,15,0,0">
41+
<Grid.ColumnDefinitions>
42+
<ColumnDefinition Width="*"/>
43+
<ColumnDefinition Width="*"/>
44+
</Grid.ColumnDefinitions>
45+
<Button Grid.Column="0" Style="{StaticResource CustomButton}" x:Name="btnCancelNewProject" Background="{DynamicResource ButtonBackground}" Foreground="#FFC1C1C1" Margin="3,0,3,3" BorderBrush="{x:Null}" VerticalAlignment="Top" Height="35" Click="BtnCancelNewProject_Click" >
46+
<Label Foreground="{DynamicResource ButtonForeground}" Content="Cancel"/>
47+
</Button>
48+
<Button Grid.Column="1" Style="{StaticResource CustomButton}" x:Name="btnCreateNewProject" Background="{DynamicResource ButtonBackground}" Foreground="#FFC1C1C1" Margin="3,0,3,3" BorderBrush="{x:Null}" VerticalAlignment="Top" Height="35" Click="BtnCreateNewProject_Click">
49+
<Label Foreground="{DynamicResource ButtonForeground}" Content="_Create"/>
50+
</Button>
51+
</Grid>
52+
</StackPanel>
53+
</Grid>
54+
</Window>

Diff for: UnityLauncherPro/NewProject.xaml.cs

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
using System.Windows;
2+
using System.Windows.Input;
3+
4+
namespace UnityLauncherPro
5+
{
6+
public partial class NewProject : Window
7+
{
8+
public static string newProjectName = null;
9+
10+
public NewProject(string unityVersion, string suggestedName)
11+
{
12+
InitializeComponent();
13+
14+
// get version
15+
txtNewProjectVersion.Text = unityVersion;
16+
txtNewProjectName.Text = suggestedName;
17+
18+
// select projectname text so can overwrite if needed
19+
txtNewProjectName.Focus();
20+
txtNewProjectName.SelectAll();
21+
newProjectName = txtNewProjectName.Text;
22+
}
23+
24+
private void BtnCreateNewProject_Click(object sender, RoutedEventArgs e)
25+
{
26+
DialogResult = true;
27+
}
28+
29+
private void BtnCancelNewProject_Click(object sender, RoutedEventArgs e)
30+
{
31+
DialogResult = false;
32+
}
33+
34+
private void Window_PreviewKeyDown(object sender, KeyEventArgs e)
35+
{
36+
switch (e.Key)
37+
{
38+
// TODO allow typing anywhere
39+
40+
case Key.Enter: // enter accept
41+
DialogResult = true;
42+
e.Handled = true;
43+
break;
44+
case Key.Escape: // esc cancel
45+
DialogResult = false;
46+
e.Handled = true;
47+
break;
48+
default:
49+
break;
50+
}
51+
}
52+
53+
private void TxtNewProjectName_TextChanged(object sender, System.Windows.Controls.TextChangedEventArgs e)
54+
{
55+
newProjectName = txtNewProjectName.Text;
56+
}
57+
}
58+
}

Diff for: UnityLauncherPro/Properties/Settings.Designer.cs

+12
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: UnityLauncherPro/Properties/Settings.settings

+3
Original file line numberDiff line numberDiff line change
@@ -47,5 +47,8 @@
4747
<Setting Name="newProjectsRoot" Type="System.String" Scope="User">
4848
<Value Profile="(Default)" />
4949
</Setting>
50+
<Setting Name="askNameForQuickProject" Type="System.Boolean" Scope="User">
51+
<Value Profile="(Default)">True</Value>
52+
</Setting>
5053
</Settings>
5154
</SettingsFile>

0 commit comments

Comments
 (0)