Skip to content
This repository was archived by the owner on Dec 13, 2020. It is now read-only.

Commit 0c41bde

Browse files
author
Firestack
committed
I have no idea what I'm doing on the branch right now, pushing from remote
1 parent cb9c5a1 commit 0c41bde

File tree

13 files changed

+278
-40
lines changed

13 files changed

+278
-40
lines changed

UnityMultiLauncher/App.config

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
1-
<?xml version="1.0" encoding="utf-8" ?>
1+
<?xml version="1.0" encoding="utf-8"?>
22
<configuration>
33
<startup>
44
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
55
</startup>
6+
<runtime>
7+
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
8+
<dependentAssembly>
9+
<assemblyIdentity name="MahApps.Metro" publicKeyToken="f4fb5a3c4d1e5b4f" culture="neutral" />
10+
<bindingRedirect oldVersion="0.0.0.0-1.3.0.0" newVersion="1.3.0.0" />
11+
</dependentAssembly>
12+
</assemblyBinding>
13+
</runtime>
614
</configuration>

UnityMultiLauncher/App.xaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/Violet.xaml" />
2020
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/BaseLight.xaml" />
2121

22+
<!--Icons-->
23+
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro.IconPacks;component/Themes/IconPacks.xaml" />
2224
</ResourceDictionary.MergedDictionaries>
2325
</ResourceDictionary>
2426
</Application.Resources>
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<UserControl x:Class="UnityMultiLauncher.Controls.BaseFilesystemControl"
2+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
5+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
6+
mc:Ignorable="d"
7+
d:DesignHeight="300" d:DesignWidth="300">
8+
<Grid>
9+
<Grid.RowDefinitions>
10+
<RowDefinition/>
11+
<RowDefinition/>
12+
<RowDefinition/>
13+
</Grid.RowDefinitions>
14+
<Grid.ColumnDefinitions>
15+
<ColumnDefinition/>
16+
<ColumnDefinition/>
17+
</Grid.ColumnDefinitions>
18+
19+
<!--Grid Content-->
20+
<!--PWD-->
21+
<ItemsControl Grid.ColumnSpan="2">
22+
<ItemsControl.ItemsPanel>
23+
<ItemsPanelTemplate>
24+
<StackPanel Orientation="Horizontal"></StackPanel>
25+
</ItemsPanelTemplate>
26+
</ItemsControl.ItemsPanel>
27+
28+
</ItemsControl>
29+
30+
<!--Favorites Bar-->
31+
32+
<!--File Browser-->
33+
34+
<!--Button Bar-->
35+
<ItemsControl >
36+
37+
</ItemsControl>
38+
39+
40+
41+
</Grid>
42+
</UserControl>
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Collections.ObjectModel;
4+
using System.Linq;
5+
using System.Text;
6+
using System.Threading.Tasks;
7+
using System.Windows;
8+
using System.Windows.Controls;
9+
using System.Windows.Data;
10+
using System.Windows.Documents;
11+
using System.Windows.Input;
12+
using System.Windows.Media;
13+
using System.Windows.Media.Imaging;
14+
using System.Windows.Navigation;
15+
using System.Windows.Shapes;
16+
17+
namespace UnityMultiLauncher.Controls
18+
{
19+
/// <summary>
20+
/// Interaction logic for BaseFilesystemControl.xaml
21+
/// </summary>
22+
public partial class BaseFilesystemControl : UserControl
23+
{
24+
public static readonly DependencyProperty ButtonArray = ButtonArrayPropertyKey.DependencyProperty;
25+
26+
private static readonly DependencyPropertyKey ButtonArrayPropertyKey =
27+
DependencyProperty.RegisterReadOnly(
28+
"Buttons",
29+
typeof(ObservableCollection<string>),
30+
typeof(BaseFilesystemControl),
31+
new FrameworkPropertyMetadata(new ObservableCollection<string>())
32+
);
33+
34+
public ObservableCollection<string> Buttons { get { return (ObservableCollection<string>)GetValue(ButtonArray); } set { SetValue(ButtonArray, value); } }
35+
36+
public static readonly DependencyProperty DirectoryRoot = DependencyProperty.Register("dirRoot", typeof(Uri), typeof(BaseFilesystemControl), new PropertyMetadata(new Uri(@"C:\")));
37+
38+
public Uri dirRoot
39+
{
40+
get
41+
{
42+
return (Uri)GetValue(DirectoryRoot);
43+
}
44+
set
45+
{
46+
SetValue(DirectoryRoot, value);
47+
}
48+
}
49+
50+
public BaseFilesystemControl()
51+
{
52+
InitializeComponent();
53+
}
54+
}
55+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<UserControl x:Class="UnityMultiLauncher.Controls.FavoritesPanel"
2+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
5+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
6+
xmlns:local="clr-namespace:UnityMultiLauncher.Controls"
7+
mc:Ignorable="d"
8+
d:DesignHeight="300" d:DesignWidth="300">
9+
<ItemsControl>
10+
<ItemsControl.ItemsPanel>
11+
<ItemsPanelTemplate>
12+
<StackPanel>
13+
14+
</StackPanel>
15+
</ItemsPanelTemplate>
16+
</ItemsControl.ItemsPanel>
17+
</ItemsControl>
18+
</UserControl>
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
using System.Windows;
7+
using System.Windows.Controls;
8+
using System.Windows.Data;
9+
using System.Windows.Documents;
10+
using System.Windows.Input;
11+
using System.Windows.Media;
12+
using System.Windows.Media.Imaging;
13+
using System.Windows.Navigation;
14+
using System.Windows.Shapes;
15+
16+
namespace UnityMultiLauncher.Controls
17+
{
18+
/// <summary>
19+
/// Interaction logic for FavoritesPanel.xaml
20+
/// </summary>
21+
public partial class FavoritesPanel : UserControl
22+
{
23+
public FavoritesPanel()
24+
{
25+
InitializeComponent();
26+
27+
}
28+
}
29+
}

UnityMultiLauncher/Models/Utility.cs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,14 @@ public static string UnityProjectSettings(Uri project, string key)
3737
public static Tuple<int, int, int, int> UnityProjectVersion(Uri project)
3838
{
3939
var filename = System.IO.Path.Combine(project.LocalPath, @"ProjectSettings /ProjectVersion.txt");
40-
var data = System.IO.File.ReadAllText(filename, Encoding.UTF8);
41-
var match = versionExp.Match(data);
42-
40+
if (System.IO.File.Exists(filename))
41+
{
42+
var data = System.IO.File.ReadAllText(filename, Encoding.UTF8);
43+
var match = versionExp.Match(data);
4344

44-
return Tuple.Create(Convert.ToInt32(match.Groups[1].Value), Convert.ToInt32(match.Groups[2].Value), Convert.ToInt32(match.Groups[3].Value), Convert.ToInt32(match.Groups[4].Value));
45+
return Tuple.Create(Convert.ToInt32(match.Groups[1].Value), Convert.ToInt32(match.Groups[2].Value), Convert.ToInt32(match.Groups[3].Value), Convert.ToInt32(match.Groups[4].Value));
46+
}
47+
return null;
4548
}
4649

4750
public static Uri GetUnityExecutableFromVersion(Tuple<int, int, int, int> version)

UnityMultiLauncher/UnityMultiLauncher.csproj

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,16 +68,17 @@
6868
<HintPath>..\packages\MahApps.Metro.1.3.0\lib\net45\MahApps.Metro.dll</HintPath>
6969
<Private>True</Private>
7070
</Reference>
71+
<Reference Include="MahApps.Metro.IconPacks, Version=1.1.0.0, Culture=neutral, processorArchitecture=MSIL">
72+
<HintPath>..\packages\MahApps.Metro.IconPacks.1.1.0\lib\net45\MahApps.Metro.IconPacks.dll</HintPath>
73+
<Private>True</Private>
74+
</Reference>
7175
<Reference Include="Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
7276
<HintPath>..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
7377
<Private>True</Private>
7478
</Reference>
7579
<Reference Include="System" />
7680
<Reference Include="System.Data" />
77-
<Reference Include="System.Windows.Interactivity, Version=4.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
78-
<HintPath>..\packages\MahApps.Metro.1.3.0\lib\net45\System.Windows.Interactivity.dll</HintPath>
79-
<Private>True</Private>
80-
</Reference>
81+
<Reference Include="System.Windows.Forms" />
8182
<Reference Include="System.Xml" />
8283
<Reference Include="Microsoft.CSharp" />
8384
<Reference Include="System.Core" />
@@ -102,13 +103,25 @@
102103
<Compile Include="Controls\Converters\UnityProjectToUnityVersion.cs" />
103104
<Compile Include="Controls\Converters\UnityUriToUnityVersion.cs" />
104105
<Compile Include="Controls\AlignableWrapPanel.cs" />
106+
<Compile Include="Controls\FavoritesPanel.xaml.cs">
107+
<DependentUpon>FavoritesPanel.xaml</DependentUpon>
108+
</Compile>
105109
<Compile Include="Models\ConfigLoader.cs" />
106110
<Compile Include="Models\ProgramConfig.cs" />
107111
<Compile Include="Models\Utility.cs" />
112+
<Compile Include="Util\ExtentionMethods.cs" />
108113
<Compile Include="ViewModels\StyleViewModel.cs" />
109114
<Compile Include="ViewModels\UnityViewModel.cs" />
110115
<Compile Include="ViewModels\Utils\ViewCommand.cs" />
111116
<Compile Include="ViewModels\Utils\ViewModel.cs" />
117+
<Page Include="Controls\FavoritesPanel.xaml">
118+
<SubType>Designer</SubType>
119+
<Generator>MSBuild:Compile</Generator>
120+
</Page>
121+
<Page Include="Controls\BaseFilesystemControl.xaml">
122+
<SubType>Designer</SubType>
123+
<Generator>MSBuild:Compile</Generator>
124+
</Page>
112125
<Page Include="Views\MainWindow.xaml">
113126
<Generator>MSBuild:Compile</Generator>
114127
<SubType>Designer</SubType>
@@ -118,6 +131,9 @@
118131
<SubType>Code</SubType>
119132
</Compile>
120133
<Compile Include="ViewModels\UtilViewModel.cs" />
134+
<Compile Include="Controls\BaseFilesystemControl.xaml.cs">
135+
<DependentUpon>BaseFilesystemControl.xaml</DependentUpon>
136+
</Compile>
121137
<Compile Include="Views\MainWindow.xaml.cs">
122138
<DependentUpon>MainWindow.xaml</DependentUpon>
123139
<SubType>Code</SubType>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
7+
namespace UnityMultiLauncher
8+
{
9+
public static class ExtentionMethods
10+
{
11+
public static string GetLocation(this System.Environment.SpecialFolder folder)
12+
{
13+
return Environment.GetFolderPath(folder);
14+
}
15+
}
16+
}

UnityMultiLauncher/ViewModels/UnityViewModel.cs

Lines changed: 44 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using System.Windows;
66
using UnityMultiLauncher.ViewModels.Utils;
77
using Microsoft.Win32;
8+
using System.Windows.Forms;
89
using MahApps.Metro.Controls;
910
using MahApps.Metro.Controls.Dialogs;
1011
using System.Windows.Controls;
@@ -14,6 +15,8 @@ namespace UnityMultiLauncher.ViewModels
1415
{
1516
public class UnityViewModel : ViewModel
1617
{
18+
protected List<Uri> extraProjectLoctions = new List<Uri>();
19+
1720
protected void LaunchUnityVersion(Uri unityExe)
1821
{
1922

@@ -23,11 +26,10 @@ protected void LaunchUnityVersion(Uri unityExe)
2326

2427
protected void AddUnityVersion(object param)
2528
{
26-
27-
var a = new OpenFileDialog();
28-
a.Filter = "Executable Files (.exe)|*.exe|All Files (*.*)|*.*";
29+
var a = new System.Windows.Forms.OpenFileDialog();
30+
a.Filter = "Programs (.exe)|*.exe|All Files (*.*)|*.*";
2931
//a.Filter = "exe";
30-
if ((bool)a.ShowDialog())
32+
if (a.ShowDialog() == DialogResult.OK)
3133
{
3234
ProgramConfig.conf.unityExeLocations.Add(new Uri(a.FileName));
3335
unityLocations.Add(new Uri(a.FileName));
@@ -64,8 +66,8 @@ protected void LaunchProject(Uri projectLocation, Uri unityExe = null)
6466
MessageDialogStyle.Affirmative,
6567
dialogSettings
6668
).ContinueWith(
67-
// This makes the screen oddly flash (This could either be the thread switch or the animate show affecting it oddly
68-
(a) => Application.Current.Dispatcher.Invoke(() => SelectUnityVersionDialog(projectLocation, new MetroDialogSettings { AnimateShow = false}))
69+
// HACK: This makes the screen oddly flash (This could either be the thread switch or the animate show affecting it oddly
70+
(a) => System.Windows.Application.Current.Dispatcher.Invoke(() => SelectUnityVersionDialog(projectLocation, new MetroDialogSettings { AnimateShow = false}))
6971
);
7072
}
7173
if (unityExe == null)
@@ -75,6 +77,17 @@ protected void LaunchProject(Uri projectLocation, Uri unityExe = null)
7577
}
7678
}
7779

80+
protected void AddUnityProject()
81+
{
82+
var a = new FolderBrowserDialog();
83+
84+
if (a.ShowDialog() == DialogResult.OK)
85+
{
86+
extraProjectLoctions.Add(new Uri(a.SelectedPath));
87+
UpdateProperty(nameof(unityProjectLocations));
88+
}
89+
}
90+
7891
protected void DuplicateUnityProject(Uri param)
7992
{
8093
ProgramConfig.conf.unityExeLocations.Remove(param);
@@ -103,7 +116,6 @@ public IEnumerable<Tuple<Uri, string, string>> unityProjectLocations
103116
{
104117
get
105118
{
106-
107119
#if EXAMPLE_VIEW
108120
var rng = new Random();
109121
foreach(var idx in Enumerable.Range(0,10))
@@ -115,14 +127,27 @@ public IEnumerable<Tuple<Uri, string, string>> unityProjectLocations
115127
yield return Tuple.Create(testUri, testUri.LocalPath.Substring(testUri.LocalPath.LastIndexOf('\\') + 1), string.Format("{0}.{1}.{2}f{3}", rngExeVersion.Item1, rngExeVersion.Item2, rngExeVersion.Item3, rngExeVersion.Item4));
116128
}
117129
#else
118-
119130
var unityKeys = Registry.CurrentUser.OpenSubKey(@"SOFTWARE\Unity Technologies\Unity Editor 5.x\", false);
120131
var matchingKeys = unityKeys.GetValueNames().Where(key => key.Contains("RecentlyUsedProjectPaths"));
132+
121133
var pos = matchingKeys.Select(key => new Uri(Encoding.UTF8.GetString(unityKeys.GetValue(key) as byte[]).TrimEnd((char)0)));
122-
foreach (var project in pos)
134+
foreach (var project in extraProjectLoctions.Concat(pos) )
123135
{
124-
var a = Util.UnityProjectVersion(project);
125-
yield return Tuple.Create(project, project.LocalPath.Substring(project.LocalPath.LastIndexOf('\\') + 1), string.Format("{0}.{1}.{2}f{3}", a.Item1, a.Item2, a.Item3, a.Item4));
136+
if (System.IO.Directory.Exists(project.LocalPath) && System.IO.Directory.Exists(System.IO.Path.Combine(project.LocalPath, "Assets")))
137+
{
138+
var projectVersion = Util.UnityProjectVersion(project);
139+
if(projectVersion != null)
140+
yield return Tuple.Create(
141+
project,
142+
project.LocalPath.Substring(project.LocalPath.LastIndexOf('\\') + 1),
143+
string.Format("{0}.{1}.{2}f{3}",
144+
projectVersion.Item1,
145+
projectVersion.Item2,
146+
projectVersion.Item3,
147+
projectVersion.Item4
148+
)
149+
);
150+
}
126151
}
127152
#endif
128153

@@ -169,6 +194,14 @@ public ViewCommand launchUnityProject
169194
}
170195
}
171196

197+
public ViewCommand addUnityProject
198+
{
199+
get
200+
{
201+
return GetProperty() as ViewCommand ?? SetProperty(new ViewCommand(param => AddUnityProject()));
202+
}
203+
}
204+
172205
public ViewCommand launchUnityProjectWithVersion
173206
{
174207
get

0 commit comments

Comments
 (0)