Skip to content

Commit f1bb731

Browse files
committed
new project: added platform selection, load/save last used platform selection,
1 parent 5be4882 commit f1bb731

File tree

6 files changed

+50
-13
lines changed

6 files changed

+50
-13
lines changed

UnityLauncherPro/App.config

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,9 @@
102102
<setting name="templatePackagesFolder" serializeAs="String">
103103
<value />
104104
</setting>
105+
<setting name="newProjectPlatform" serializeAs="String">
106+
<value />
107+
</setting>
105108
</UnityLauncherPro.Properties.Settings>
106109
</userSettings>
107110
</configuration>

UnityLauncherPro/MainWindow.xaml.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -559,7 +559,7 @@ async Task CallGetUnityUpdates()
559559
dataGridUpdates.ItemsSource = null;
560560
var task = GetUnityUpdates.Scan();
561561
var items = await task;
562-
Console.WriteLine(items == null);
562+
Console.WriteLine("CallGetUnityUpdates=" + items == null);
563563
if (items == null) return;
564564
updatesSource = GetUnityUpdates.Parse(items);
565565
if (updatesSource == null) return;
@@ -1642,7 +1642,7 @@ void CreateNewEmptyProject()
16421642
Console.WriteLine("Create project " + NewProject.newVersion + " : " + projectPath);
16431643
if (string.IsNullOrEmpty(projectPath)) return;
16441644

1645-
var p = Tools.FastCreateProject(NewProject.newVersion, projectPath, NewProject.newProjectName, NewProject.templateZipPath);
1645+
var p = Tools.FastCreateProject(NewProject.newVersion, projectPath, NewProject.newProjectName, NewProject.templateZipPath, NewProject.selectedPlatform);
16461646

16471647
// add to list (just in case new project fails to start, then folder is already generated..)
16481648
if (p != null) AddNewProjectToList(p);
@@ -1732,7 +1732,7 @@ public void CopyRowFolderToClipBoard(object sender, ExecutedRoutedEventArgs e)
17321732
{
17331733
path = GetSelectedUpdate()?.Version; // TODO copy url instead
17341734
}
1735-
Console.WriteLine(path);
1735+
Console.WriteLine("CopyRowFolderToClipBoard=" + path);
17361736

17371737
if (string.IsNullOrEmpty(path) == false) Clipboard.SetText(path);
17381738
}

UnityLauncherPro/NewProject.xaml.cs

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ public partial class NewProject : Window
1212
public static string newVersion = null;
1313
public static string newName = null;
1414
public static string templateZipPath = null;
15+
public static string selectedPlatform = null;
1516

1617
bool isInitializing = true; // to keep OnChangeEvent from firing too early
1718
int previousSelectedTemplateIndex = -1;
@@ -77,11 +78,22 @@ void UpdateTemplatesDropDown(string unityPath)
7778
void UpdateModulesDropdown(string version)
7879
{
7980
// get modules and stick into combobox
80-
cmbNewProjectPlatform.ItemsSource = Tools.GetPlatformsForUnityVersion(version);
81-
System.Console.WriteLine(Tools.GetPlatformsForUnityVersion(version).Length);
81+
var platformsForThisUnity = Tools.GetPlatformsForUnityVersion(version);
82+
cmbNewProjectPlatform.ItemsSource = platformsForThisUnity;
83+
//System.Console.WriteLine(Tools.GetPlatformsForUnityVersion(version).Length);
84+
85+
var lastUsedPlatform = Properties.Settings.Default.newProjectPlatform;
86+
87+
for (int i = 0; i < platformsForThisUnity.Length; i++)
88+
{
89+
// set default platform (now win64) if never used this before
90+
if (platformsForThisUnity[i].ToLower() == "win64" || platformsForThisUnity[i] == lastUsedPlatform)
91+
{
92+
cmbNewProjectPlatform.SelectedIndex = i;
93+
break;
94+
}
95+
}
8296

83-
// TODO remember this selection next time
84-
cmbNewProjectPlatform.SelectedIndex = 0;
8597
//lblTemplateTitleAndCount.Content = "Templates: (" + (cmbNewProjectTemplate.Items.Count - 1) + ")";
8698
}
8799

@@ -90,7 +102,13 @@ void UpdateModulesDropdown(string version)
90102
private void BtnCreateNewProject_Click(object sender, RoutedEventArgs e)
91103
{
92104
templateZipPath = ((KeyValuePair<string, string>)cmbNewProjectTemplate.SelectedValue).Value;
105+
selectedPlatform = cmbNewProjectPlatform.SelectedValue.ToString();
93106
UpdateSelectedVersion();
107+
108+
// save last used value for platform
109+
Properties.Settings.Default.newProjectPlatform = cmbNewProjectPlatform.SelectedValue.ToString();
110+
Properties.Settings.Default.Save();
111+
94112
DialogResult = true;
95113
}
96114

@@ -123,7 +141,7 @@ private void Window_PreviewKeyDown(object sender, KeyEventArgs e)
123141
e.Handled = true;
124142
break;
125143
case Key.Escape: // esc cancel
126-
// if pressed esc while combobox is open, close that one instead of closing window
144+
// if pressed esc while combobox is open, close that one instead of closing window
127145
if (cmbNewProjectTemplate.IsDropDownOpen)
128146
{
129147
cmbNewProjectTemplate.IsDropDownOpen = false;

UnityLauncherPro/Properties/Settings.Designer.cs

Lines changed: 12 additions & 0 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: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,5 +101,8 @@
101101
<Setting Name="templatePackagesFolder" Type="System.String" Scope="User">
102102
<Value Profile="(Default)" />
103103
</Setting>
104+
<Setting Name="newProjectPlatform" Type="System.String" Scope="User">
105+
<Value Profile="(Default)" />
106+
</Setting>
104107
</Settings>
105108
</SettingsFile>

UnityLauncherPro/Tools.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ public static bool LaunchExe(string path, string param = null)
383383
{
384384
if (string.IsNullOrEmpty(param) == true)
385385
{
386-
Console.WriteLine(path);
386+
Console.WriteLine("LaunchExe=" + path);
387387
Process.Start(path);
388388
}
389389
else
@@ -1016,7 +1016,7 @@ public static string BrowseForOutputFolder(string title)
10161016
return null;
10171017
}
10181018

1019-
public static Project FastCreateProject(string version, string baseFolder, string projectName = null, string templateZipPath = null)
1019+
public static Project FastCreateProject(string version, string baseFolder, string projectName = null, string templateZipPath = null, string platform = null)
10201020
{
10211021
// check for base folders in settings tab
10221022
if (string.IsNullOrEmpty(baseFolder) == true)
@@ -1035,16 +1035,16 @@ public static Project FastCreateProject(string version, string baseFolder, strin
10351035
// check selected unity version
10361036
if (string.IsNullOrEmpty(version) == true)
10371037
{
1038-
Console.WriteLine("Missing unity version");
1038+
Console.WriteLine("Missing unity version string");
10391039
return null;
10401040
}
10411041

10421042
string newPath = null;
10431043
// if we didnt have name yet
10441044
if (string.IsNullOrEmpty(projectName) == true)
10451045
{
1046-
Console.WriteLine(version);
1047-
Console.WriteLine(baseFolder);
1046+
//Console.WriteLine("version=" + version);
1047+
//Console.WriteLine("baseFolder=" + baseFolder);
10481048
projectName = GetSuggestedProjectName(version, baseFolder);
10491049
// failed getting new path a-z
10501050
if (projectName == null) return null;
@@ -1065,6 +1065,7 @@ public static Project FastCreateProject(string version, string baseFolder, strin
10651065
proj.Title = projectName;
10661066
proj.Path = Path.Combine(baseFolder, newPath);
10671067
proj.Version = version;
1068+
proj.TargetPlatform = platform;
10681069
var proc = LaunchProject(proj);
10691070
ProcessHandler.Add(proj, proc);
10701071
return proj;

0 commit comments

Comments
 (0)