Skip to content

Commit 6a33b3b

Browse files
committed
upgrade project to vs2022, use create new project dialog when opening empty folder project from context menu
1 parent d0d72ee commit 6a33b3b

File tree

5 files changed

+64
-47
lines changed

5 files changed

+64
-47
lines changed

UnityLauncherPro/App.config

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,6 @@
1616
<setting name="windowHeight" serializeAs="String">
1717
<value>650</value>
1818
</setting>
19-
<setting name="rootFolders" serializeAs="Xml">
20-
<value>
21-
<ArrayOfString xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
22-
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
23-
<string>C:\Program Files\</string>
24-
</ArrayOfString>
25-
</value>
26-
</setting>
2719
<setting name="minimizeToTaskbar" serializeAs="String">
2820
<value>True</value>
2921
</setting>
@@ -114,6 +106,13 @@
114106
<setting name="shortcutBatchFileFolder" serializeAs="String">
115107
<value />
116108
</setting>
109+
<setting name="rootFolders" serializeAs="Xml">
110+
<value>
111+
<ArrayOfString xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
112+
<string>C:\Program Files\</string>
113+
</ArrayOfString>
114+
</value>
115+
</setting>
117116
</UnityLauncherPro.Properties.Settings>
118117
</userSettings>
119118
</configuration>

UnityLauncherPro/MainWindow.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1012,7 +1012,7 @@
10121012
<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"/>
10131013
<CheckBox x:Name="chkAllowSingleInstanceOnly" Content="Allow single instance only" Checked="ChkAllowSingleInstanceOnly_CheckedChanged" Unchecked="ChkAllowSingleInstanceOnly_CheckedChanged" ToolTip="Activates already running instance, instead of starting new exe (not working if app is minized to taskbar)" HorizontalAlignment="Left"/>
10141014
<CheckBox x:Name="chkEnableProjectRename" Content="Enable Project title rename (F2)" ToolTip="Renames project title only, DOES NOT rename project folder! New name is saved into ProjectSettings/ProjectName.txt" Checked="ChkEnableProjectRename_Checked" Unchecked="ChkEnableProjectRename_Checked" HorizontalAlignment="Left"/>
1015-
<CheckBox x:Name="chkAskNameForQuickProject" Content="Ask name for New Project" Checked="ChkAskNameForQuickProject_Checked" Unchecked="ChkAskNameForQuickProject_Checked" ToolTip="If disabled, uses automatic quick project naming" HorizontalAlignment="Left"/>
1015+
<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"/>
10161016
<CheckBox x:Name="chkStreamerMode" Content="Streamer Mode (hide project names and folders)" ToolTip="Hide project names and folders in main view" Checked="ChkStreamerMode_Checked" Unchecked="ChkStreamerMode_Checked" HorizontalAlignment="Left"/>
10171017
<CheckBox x:Name="chkShowPlatform" Content="Show current target platform (if exists in .csproj)" ToolTip="Shows target platform column" Checked="ChkShowPlatform_Checked" Unchecked="ChkShowPlatform_Checked" HorizontalAlignment="Left"/>
10181018
<StackPanel Grid.Row="3" Orientation="Horizontal" Margin="0,0,0,4">

UnityLauncherPro/MainWindow.xaml.cs

Lines changed: 35 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -196,11 +196,19 @@ void HandleCommandLineLaunch()
196196
proj.Path = projectPathArgument;
197197
proj.Arguments = commandLineArguments;
198198

199-
// check if force-update button is down
199+
// no version info or check if force-update button is down
200200
// NOTE if keydown, window doesnt become active and focused
201201
if (string.IsNullOrEmpty(version) || (Keyboard.Modifiers & ModifierKeys.Shift) != 0)
202202
{
203-
Tools.DisplayUpgradeDialog(proj, null);
203+
if (Directory.Exists(Path.Combine(proj.Path, "Assets")) == true)
204+
{
205+
Tools.DisplayUpgradeDialog(proj, null);
206+
}
207+
else // no assets folder here, then its new project
208+
{
209+
//Tools.DisplayUpgradeDialog(proj, null);
210+
CreateNewEmptyProject(proj.Path);
211+
}
204212
}
205213
else
206214
{
@@ -1591,18 +1599,29 @@ private void BtnCreateEmptyProjectUnity_Click(object sender, RoutedEventArgs e)
15911599
CreateNewEmptyProject();
15921600
}
15931601

1594-
void CreateNewEmptyProject()
1602+
void CreateNewEmptyProject(string targetFolder = null)
15951603
{
1596-
// first check if quick project path is assigned, if not, need to set it
1597-
if (Directory.Exists(txtRootFolderForNewProjects.Text) == false)
1604+
string rootFolder = txtRootFolderForNewProjects.Text;
1605+
1606+
// if have targetfolder, then use that instead of quick folder
1607+
if (targetFolder != null && Directory.Exists(targetFolder))
15981608
{
1599-
tabControl.SelectedIndex = 4;
1600-
this.UpdateLayout();
1601-
txtRootFolderForNewProjects.Focus();
1602-
return;
1609+
rootFolder = targetFolder;
1610+
}
1611+
else
1612+
{
1613+
// check if quick root folder is set correctly
1614+
if (Directory.Exists(rootFolder) == false)
1615+
{
1616+
tabControl.SelectedIndex = 4;
1617+
this.UpdateLayout();
1618+
txtRootFolderForNewProjects.Focus();
1619+
return;
1620+
}
16031621
}
16041622

1605-
if (chkAskNameForQuickProject.IsChecked == true)
1623+
// for new projects created from explorer, always ask for name
1624+
if (chkAskNameForQuickProject.IsChecked == true || targetFolder != null)
16061625
{
16071626
// ask name
16081627
string newVersion = null;
@@ -1623,7 +1642,7 @@ void CreateNewEmptyProject()
16231642
return;
16241643
}
16251644

1626-
NewProject modalWindow = new NewProject(newVersion, Tools.GetSuggestedProjectName(newVersion, txtRootFolderForNewProjects.Text), txtRootFolderForNewProjects.Text);
1645+
NewProject modalWindow = new NewProject(newVersion, Tools.GetSuggestedProjectName(newVersion, rootFolder), rootFolder);
16271646
modalWindow.ShowInTaskbar = this == null;
16281647
modalWindow.WindowStartupLocation = this == null ? WindowStartupLocation.CenterScreen : WindowStartupLocation.CenterOwner;
16291648
modalWindow.Topmost = this == null;
@@ -1634,11 +1653,10 @@ void CreateNewEmptyProject()
16341653

16351654
if (results == true)
16361655
{
1637-
var projectPath = txtRootFolderForNewProjects.Text;
1638-
Console.WriteLine("Create project " + NewProject.newVersion + " : " + projectPath);
1639-
if (string.IsNullOrEmpty(projectPath)) return;
1656+
Console.WriteLine("Create project " + NewProject.newVersion + " : " + rootFolder);
1657+
if (string.IsNullOrEmpty(rootFolder)) return;
16401658

1641-
var p = Tools.FastCreateProject(NewProject.newVersion, projectPath, NewProject.newProjectName, NewProject.templateZipPath, NewProject.platformsForThisUnity, NewProject.selectedPlatform);
1659+
var p = Tools.FastCreateProject(NewProject.newVersion, rootFolder, NewProject.newProjectName, NewProject.templateZipPath, NewProject.platformsForThisUnity, NewProject.selectedPlatform);
16421660

16431661
// add to list (just in case new project fails to start, then folder is already generated..)
16441662
if (p != null) AddNewProjectToList(p);
@@ -1649,7 +1667,7 @@ void CreateNewEmptyProject()
16491667
}
16501668

16511669
}
1652-
else // use automatic name
1670+
else // use automatic name (project is instantly created, without asking anything)
16531671
{
16541672
string newVersion = null;
16551673
// if in maintab
@@ -1661,7 +1679,7 @@ void CreateNewEmptyProject()
16611679
{
16621680
newVersion = GetSelectedUnity().Version == null ? preferredVersion : GetSelectedUnity().Version;
16631681
}
1664-
var p = Tools.FastCreateProject(newVersion, txtRootFolderForNewProjects.Text);
1682+
var p = Tools.FastCreateProject(newVersion, rootFolder);
16651683
if (p != null) AddNewProjectToList(p);
16661684
}
16671685

UnityLauncherPro/Properties/Settings.Designer.cs

Lines changed: 15 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

UnityLauncherPro/Properties/Settings.settings

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,6 @@
88
<Setting Name="windowHeight" Type="System.Int32" Scope="User">
99
<Value Profile="(Default)">650</Value>
1010
</Setting>
11-
<Setting Name="rootFolders" Type="System.Collections.Specialized.StringCollection" Scope="User">
12-
<Value Profile="(Default)">&lt;?xml version="1.0" encoding="utf-16"?&gt;
13-
&lt;ArrayOfString xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"&gt;
14-
&lt;string&gt;C:\Program Files\&lt;/string&gt;
15-
&lt;/ArrayOfString&gt;</Value>
16-
</Setting>
1711
<Setting Name="minimizeToTaskbar" Type="System.Boolean" Scope="User">
1812
<Value Profile="(Default)">True</Value>
1913
</Setting>
@@ -113,5 +107,11 @@
113107
<Setting Name="shortcutBatchFileFolder" Type="System.String" Scope="User">
114108
<Value Profile="(Default)" />
115109
</Setting>
110+
<Setting Name="rootFolders" Type="System.Collections.Specialized.StringCollection" Scope="User">
111+
<Value Profile="(Default)">&lt;?xml version="1.0" encoding="utf-16"?&gt;
112+
&lt;ArrayOfString xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"&gt;
113+
&lt;string&gt;C:\Program Files\&lt;/string&gt;
114+
&lt;/ArrayOfString&gt;</Value>
115+
</Setting>
116116
</Settings>
117117
</SettingsFile>

0 commit comments

Comments
 (0)