diff --git a/UnityLauncherPro/App.xaml b/UnityLauncherPro/App.xaml index 1d882de..adfad5f 100644 --- a/UnityLauncherPro/App.xaml +++ b/UnityLauncherPro/App.xaml @@ -136,7 +136,7 @@ - + @@ -530,9 +530,6 @@ - - - diff --git a/UnityLauncherPro/Converters/ThumbnailConverter.cs b/UnityLauncherPro/Converters/ThumbnailConverter.cs new file mode 100644 index 0000000..d389489 --- /dev/null +++ b/UnityLauncherPro/Converters/ThumbnailConverter.cs @@ -0,0 +1,58 @@ +using System; +using System.Globalization; +using System.IO; +using System.Windows.Data; +using System.Windows.Media.Imaging; + +namespace UnityLauncherPro.Converters +{ + public class ThumbnailConverter : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + if (value is Project project) + { + if (!string.IsNullOrEmpty(project.Path)) + { + string thumbnailPath = Path.Combine(project.Path, "ProjectSettings", "icon.png"); + + if (File.Exists(thumbnailPath)) + { + try + { + var bitmap = new BitmapImage(); + bitmap.BeginInit(); + bitmap.CacheOption = BitmapCacheOption.OnLoad; + bitmap.CreateOptions = BitmapCreateOptions.IgnoreImageCache; + bitmap.UriSource = new Uri(thumbnailPath, UriKind.Absolute); + bitmap.DecodePixelWidth = 64; // Match your display size + bitmap.DecodePixelHeight = 64; + + bitmap.EndInit(); + + // Freeze for cross-thread access + if (bitmap.CanFreeze) + { + bitmap.Freeze(); + } + + return bitmap; + } + catch + { + // Ignore and fall back to null + } + } + } + return null; + } + + return null; + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + throw new NotImplementedException(); + } + } +} \ No newline at end of file diff --git a/UnityLauncherPro/Data/OnlineTemplateItem.cs b/UnityLauncherPro/Data/OnlineTemplateItem.cs new file mode 100644 index 0000000..a5ff4e6 --- /dev/null +++ b/UnityLauncherPro/Data/OnlineTemplateItem.cs @@ -0,0 +1,12 @@ +namespace UnityLauncherPro.Data +{ + public class OnlineTemplateItem + { + public string Name { get; set; } + public string Description { get; set; } + public string RenderPipeline { get; set; } + public string Type { get; set; } // Core, Learning, Sample, + public string PreviewImageURL { get; set; } + public string TarBallURL { get; set; } + } +} \ No newline at end of file diff --git a/UnityLauncherPro/Data/TemplateGraphQLResponse.cs b/UnityLauncherPro/Data/TemplateGraphQLResponse.cs new file mode 100644 index 0000000..32bdd91 --- /dev/null +++ b/UnityLauncherPro/Data/TemplateGraphQLResponse.cs @@ -0,0 +1,49 @@ +namespace UnityLauncherPro.Data +{ + public class TemplateGraphQLResponse + { + public TemplateData data { get; set; } + } + + public class TemplateData + { + public GetTemplates getTemplates { get; set; } + } + + public class GetTemplates + { + public TemplateEdge[] edges { get; set; } + } + + public class TemplateEdge + { + public TemplateNode node { get; set; } + } + + public class TemplateNode + { + public string name { get; set; } + public string packageName { get; set; } + public string description { get; set; } + public string type { get; set; } + public string renderPipeline { get; set; } + public PreviewImage previewImage { get; set; } + public TemplateVersion[] versions { get; set; } + } + + public class PreviewImage + { + public string url { get; set; } + } + + public class TemplateVersion + { + public string name { get; set; } + public Tarball tarball { get; set; } + } + + public class Tarball + { + public string url { get; set; } + } +} \ No newline at end of file diff --git a/UnityLauncherPro/MainWindow.xaml b/UnityLauncherPro/MainWindow.xaml index 1e19791..9441c30 100644 --- a/UnityLauncherPro/MainWindow.xaml +++ b/UnityLauncherPro/MainWindow.xaml @@ -12,6 +12,7 @@ + @@ -258,6 +259,21 @@ + + + + + + + + + + + + diff --git a/UnityLauncherPro/MainWindow.xaml.cs b/UnityLauncherPro/MainWindow.xaml.cs index e965383..d2dde14 100644 --- a/UnityLauncherPro/MainWindow.xaml.cs +++ b/UnityLauncherPro/MainWindow.xaml.cs @@ -333,7 +333,17 @@ void HandleCommandLineLaunch() { bool useInitScript = (bool)chkUseInitScript.IsChecked; - Tools.DisplayUpgradeDialog(proj, null, useInitScript); + // if not editors found, then dont open commandline? + if (unityInstallationsSource.Count > 0) + { + Tools.DisplayUpgradeDialog(proj, null, useInitScript); + } + else + { + MessageBox.Show("No Unity installations found. Please setup Unity Editor root folders first by running UnityLauncherPro.", "No Unity Installations found", MessageBoxButton.OK, MessageBoxImage.Warning); + // TODO display setup tab + } + } else // no Assets folder here OR Assets folder is empty, then its new project { @@ -737,14 +747,16 @@ void LoadSettings() { string filename = ((ConfigurationErrorsException)ex.InnerException).Filename; - if (MessageBox.Show("This may be due to a Windows crash/BSOD.\n" + + var res = MessageBox.Show("This may be due to a Windows crash/BSOD.\n" + "Click 'Yes' to use automatic backup (if exists, otherwise settings are reset), then start application again.\n\n" + - "Click 'No' to exit now (and delete user.config manually)\n\nCorrupted file: " + filename, + "Click 'No' to reset config file (you'll need to setup settings again)\n\n" + + "Click 'Cancel' to exit now (and delete user.config manually)\n\nCorrupted file: " + filename, appName + " - Corrupt user settings", - MessageBoxButton.YesNo, - MessageBoxImage.Error) == MessageBoxResult.Yes) - { + MessageBoxButton.YesNoCancel, + MessageBoxImage.Error); + if (res == MessageBoxResult.Yes) + { // try to use backup string backupFilename = filename + ".bak"; if (File.Exists(backupFilename)) @@ -756,6 +768,15 @@ void LoadSettings() File.Delete(filename); } } + else if (res == MessageBoxResult.No) + { + File.Delete(filename); + } + else if (res == MessageBoxResult.Cancel) + { + Tools.ExploreFolder(Path.GetDirectoryName(filename)); + } + // need to restart, otherwise settings not loaded Process.GetCurrentProcess().Kill(); } @@ -880,11 +901,18 @@ void AddUnityInstallationRootFolder() var result = dialog.ShowDialog(); var newRoot = dialog.SelectedPath; + + if (lstRootFolders.Items.Contains(newRoot) == true) + { + SetStatus("Folder already exists in the list!", MessageType.Error); + return; + } + if (String.IsNullOrWhiteSpace(newRoot) == false && Directory.Exists(newRoot) == true) { - Properties.Settings.Default.rootFolders.Add(newRoot); + Settings.Default.rootFolders.Add(newRoot); lstRootFolders.Items.Refresh(); - Properties.Settings.Default.Save(); + Settings.Default.Save(); UpdateUnityInstallationsList(); RefreshRecentProjects(); } @@ -4183,6 +4211,14 @@ private void gridRecent_SelectionChanged(object sender, SelectionChangedEventArg } + private void Image_MouseDown(object sender, MouseButtonEventArgs e) + { + var proj = GetSelectedProject(); + if (proj == null) return; + var thumbnailPath = Path.Combine(proj.Path, "ProjectSettings", "icon.png"); + Tools.LaunchExe(thumbnailPath); + } + //private void menuProjectProperties_Click(object sender, RoutedEventArgs e) //{ // var proj = GetSelectedProject(); diff --git a/UnityLauncherPro/NewProject.xaml b/UnityLauncherPro/NewProject.xaml index c1986db..b756f3f 100644 --- a/UnityLauncherPro/NewProject.xaml +++ b/UnityLauncherPro/NewProject.xaml @@ -4,10 +4,16 @@ xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:local="clr-namespace:UnityLauncherPro" + xmlns:data="clr-namespace:UnityLauncherPro.Data" + d:DataContext="{d:DesignInstance Type=local:NewProject}" mc:Ignorable="d" - Title="Create New Project" Height="480" Width="500" Background="{DynamicResource ThemeDarkestBackground}" PreviewKeyDown="Window_PreviewKeyDown" ResizeMode="NoResize" WindowStartupLocation="CenterOwner" ShowInTaskbar="True"> + Title="Create New Project" Height="480" Width="640" Background="{DynamicResource ThemeDarkestBackground}" PreviewKeyDown="Window_PreviewKeyDown" ResizeMode="NoResize" WindowStartupLocation="CenterOwner" ShowInTaskbar="True"> + + + + @@ -41,7 +47,7 @@ - +