Skip to content

Commit 28f79aa

Browse files
added options panel & added background blue options
1 parent d915586 commit 28f79aa

30 files changed

+268
-96
lines changed

.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
.vs/
2-
Counter/obj/
3-
Counter/bin/
2+
UnityHubNative.Net/obj/
3+
UnityHubNative.Net/bin/
44
Windows/obj/
55
Windows/bin/

Counter.sln

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00
33
# Visual Studio Version 17
44
VisualStudioVersion = 17.13.35716.79
55
MinimumVisualStudioVersion = 10.0.40219.1
6-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnityHubNative.Net", "Counter\UnityHubNative.Net.csproj", "{B7ECF9E1-6808-4F83-BC8E-C6B940D82304}"
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnityHubNative.Net", "UnityHubNative.Net\UnityHubNative.Net.csproj", "{B7ECF9E1-6808-4F83-BC8E-C6B940D82304}"
77
EndProject
88
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnityHubNative.Net.Windows", "Windows\UnityHubNative.Net.Windows.csproj", "{48DAB9C0-0C77-40C4-BF07-F12C0BDA2C43}"
99
EndProject

Counter/Properties/PublishProfiles/FolderProfile.pubxml.user

Lines changed: 0 additions & 4 deletions
This file was deleted.

Counter/UnityHubNativeNetApp.cs

Lines changed: 0 additions & 33 deletions
This file was deleted.

Counter/AboutDialogue.cs renamed to UnityHubNative.Net/AboutDialogue.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ public AboutDialogue()
2121
];
2222
CanResize = false;
2323
SizeToContent = SizeToContent.WidthAndHeight;
24+
#if Windows
2425
Background = Brushes.Transparent;
26+
#endif
2527
WindowStartupLocation = WindowStartupLocation.CenterOwner;
2628
Focusable = true;
2729
}

Counter/ControlsExtensions.cs renamed to UnityHubNative.Net/ControlsExtensions.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@ namespace UnityHubNative.Net;
77

88
public static class ControlsExtensions
99
{
10+
public static T OnCheckChanged<T>(this T checkbox, Action value) where T : CheckBox
11+
{
12+
checkbox.IsCheckedChanged += (_, _) => value();
13+
return checkbox;
14+
}
15+
1016
public static T OnKeyDown<T>(this T element, params Action<T, KeyEventArgs>[] callbacks) where T : InputElement
1117
{
1218
for (int i = 0; i < callbacks.Length; i++)
@@ -92,7 +98,7 @@ public static MenuItem OnClick(this MenuItem menuItem, Action callback)
9298
return menuItem;
9399
}
94100

95-
public static Panel AddChildren(this Panel control, params Control[] children)
101+
public static T AddChildren<T>(this T control, params Control[] children) where T : Panel
96102
{
97103
control.Children.AddRange(children);
98104
return control;
File renamed without changes.

Counter/MainWindow.cs renamed to UnityHubNative.Net/MainWindow.cs

Lines changed: 86 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
using Avalonia.Layout;
77
using Avalonia.Media;
88
using Avalonia.Platform.Storage;
9+
using FluentAvalonia.UI.Controls;
910
using MsBox.Avalonia;
10-
using UnityHubNative.Net;
1111

1212
namespace UnityHubNative.Net;
1313

@@ -30,6 +30,9 @@ class MainWindow : Window
3030
private static MenuItem s_removeFromListMenuItem;
3131
private static MenuItem s_revealInFileExplorerMenuItem;
3232
private static MenuItem s_openInDifferentVersionMenuItem;
33+
private static CheckBox s_transparentCheckbox;
34+
private static CheckBox s_acrylicCheckbox;
35+
private static DockPanel s_transparentPanel;
3336

3437
public MainWindow(object data)
3538
{
@@ -39,11 +42,9 @@ public MainWindow(object data)
3942
Content = CreateContent();
4043
ReloadEverything();
4144
SizeToContent = SizeToContent.WidthAndHeight;
42-
TransparencyLevelHint =
43-
[
44-
WindowTransparencyLevel.Mica,
45-
];
46-
Background = Brushes.Transparent;
45+
SetupBackground();
46+
ActualThemeVariantChanged += (_, _) => SetupBackground();
47+
4748
#if DEBUG
4849
this.AttachDevTools();
4950
#endif
@@ -57,8 +58,9 @@ protected override void OnKeyDown(KeyEventArgs e)
5758
{
5859
if (!s_projectSearchBoxAutoComplete.IsKeyboardFocusWithin)
5960
{
60-
s_projectSearchBoxAutoComplete.Text += e.KeyModifiers == KeyModifiers.Shift ? e.Key.ToString() : e.Key.ToString().ToLower();
6161
s_projectSearchBoxAutoComplete.Focus();
62+
s_projectSearchBoxAutoComplete.Text += e.KeyModifiers == KeyModifiers.Shift ? e.Key.ToString() : e.Key.ToString().ToLower();
63+
s_projectSearchBoxAutoComplete.CaretIndex = s_projectSearchBoxAutoComplete.Text.Length;
6264
e.Handled = true;
6365
}
6466
return;
@@ -84,6 +86,22 @@ protected override void OnOpened(EventArgs e)
8486
s_unityProjectsParent.ContainerFromIndex(0)!.Focus();
8587
}
8688

89+
void SetupBackground()
90+
{
91+
if (UnityHubNativeNetApp.Config.transparent)
92+
{
93+
TransparencyLevelHint =
94+
[
95+
UnityHubNativeNetApp.Config.acrylic ? WindowTransparencyLevel.AcrylicBlur : WindowTransparencyLevel.Mica,
96+
WindowTransparencyLevel.Blur,
97+
];
98+
#if Windows
99+
100+
Background = Brushes.Transparent;
101+
#endif
102+
}
103+
}
104+
87105
private static void ReloadEverything()
88106
{
89107
UnityHubUtils.LoadAll();
@@ -332,11 +350,72 @@ private static void ReloadEverything()
332350
},
333351
])
334352
])
353+
},
354+
new TabItem
355+
{
356+
Header = "Options",
357+
Content = new DockPanel
358+
{
359+
LastChildFill = false
360+
}.AddChildren
361+
([
362+
new SettingsExpander
363+
{
364+
Header = new DockPanel
365+
{
366+
LastChildFill = false
367+
}.AddChildren
368+
([
369+
new TextBlock
370+
{
371+
Text = "Transparent Window",
372+
VerticalAlignment = VerticalAlignment.Center,
373+
}.SetDock(Dock.Left),
374+
s_transparentCheckbox = new CheckBox
375+
{
376+
IsChecked = UnityHubNativeNetApp.Config.transparent,
377+
VerticalAlignment = VerticalAlignment.Center,
378+
}.OnCheckChanged(OnTransparencyCheckboxChanged).SetDock(Dock.Right),
379+
]).SetTooltip("Makes the window transparent. Uses Mica on Windows and the desktop's blur on Linux.\nNeeds restart to take effect."),
380+
}.SetDock(Dock.Top).AddItems
381+
([
382+
s_transparentPanel = new DockPanel
383+
{
384+
IsEnabled = UnityHubNativeNetApp.Config.transparent,
385+
LastChildFill = false,
386+
}.AddChildren
387+
([
388+
new TextBlock
389+
{
390+
Text = "Acrilyc",
391+
VerticalAlignment = VerticalAlignment.Center,
392+
}.SetTooltip("Use Acrylic blur. Only works on Windows.\nNeeds restart to take effect.").SetDock(Dock.Left),
393+
s_acrylicCheckbox = new CheckBox
394+
{
395+
IsChecked = UnityHubNativeNetApp.Config.transparent,
396+
VerticalAlignment = VerticalAlignment.Center,
397+
}.OnCheckChanged(OnAcrylicCheckboxChanged).SetDock(Dock.Right)
398+
])
399+
])
400+
])
335401
}
336402
])
337403
])
338404
]);
339405

406+
private static void OnAcrylicCheckboxChanged()
407+
{
408+
UnityHubNativeNetApp.Config.acrylic = !UnityHubNativeNetApp.Config.acrylic;
409+
UnityHubNativeNetApp.SaveConfig(UnityHubNativeNetApp.Config);
410+
}
411+
412+
private static void OnTransparencyCheckboxChanged()
413+
{
414+
UnityHubNativeNetApp.Config.transparent = !UnityHubNativeNetApp.Config.transparent;
415+
UnityHubNativeNetApp.SaveConfig(UnityHubNativeNetApp.Config);
416+
s_transparentPanel.IsEnabled = UnityHubNativeNetApp.Config.transparent;
417+
}
418+
340419
private static Task<IEnumerable<object>> PopulateUnityProjectSearchAutoCompletion(string? filter, CancellationToken _)
341420
{
342421
if (filter == null)
File renamed without changes.
File renamed without changes.

Counter/OpenWithDialogue.cs renamed to UnityHubNative.Net/OpenWithDialogue.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
using Avalonia.Controls;
22
using Avalonia.Input;
33
using Avalonia.Media;
4-
using UnityHubNative.Net;
54

65
namespace UnityHubNative.Net;
76

@@ -35,7 +34,9 @@ public OpenWithDialogue(UnityProject unityProject)
3534
_unityVersionListBox!.Focus();
3635
CanResize = false;
3736
SizeToContent = SizeToContent.WidthAndHeight;
37+
#if Windows
3838
Background = Brushes.Transparent;
39+
#endif
3940
WindowStartupLocation = WindowStartupLocation.CenterOwner;
4041
}
4142

File renamed without changes.

UnityHubNative.Net/Paths.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
using System.Diagnostics;
2+
3+
namespace UnityHubNative.Net;
4+
5+
static class Paths
6+
{
7+
public static readonly string Dir = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "UnityHubNative");
8+
public static readonly string SearchPathsPath = Path.Combine(Dir, "editorPaths.txt");
9+
public static readonly string ProjectPathsPath = Path.Combine(Dir, "projects.txt");
10+
public static readonly string ConfigPath = Path.Combine(Dir, "config.txt");
11+
12+
static Paths()
13+
{
14+
if (!Directory.Exists(Dir))
15+
{
16+
Directory.CreateDirectory(Dir);
17+
Debug.WriteLine("created local data directory \"{0}\"", Dir);
18+
}
19+
}
20+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!-- https://go.microsoft.com/fwlink/?LinkID=208121. -->
3+
<Project>
4+
<PropertyGroup>
5+
<Configuration>Release</Configuration>
6+
<Platform>Any CPU</Platform>
7+
<PublishDir>bin\Release\net9.0\publish\win-x64\</PublishDir>
8+
<PublishProtocol>FileSystem</PublishProtocol>
9+
<_TargetId>Folder</_TargetId>
10+
<TargetFramework>net9.0</TargetFramework>
11+
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
12+
<SelfContained>true</SelfContained>
13+
<PublishSingleFile>true</PublishSingleFile>
14+
<PublishReadyToRun>false</PublishReadyToRun>
15+
</PropertyGroup>
16+
</Project>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!-- https://go.microsoft.com/fwlink/?LinkID=208121. -->
3+
<Project>
4+
<PropertyGroup>
5+
<History>False|2025-03-06T17:49:53.5031938Z||;</History>
6+
<LastFailureDetails />
7+
</PropertyGroup>
8+
</Project>

Counter/UnityHubNative.Net.csproj renamed to UnityHubNative.Net/UnityHubNative.Net.csproj

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,20 @@
77
<PublishAot>true</PublishAot>
88
<AssemblyName>UnityNativeHub.Net</AssemblyName>
99
<PublishTrimmed>True</PublishTrimmed>
10+
11+
<IsWindows Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Windows)))' == 'true'">true</IsWindows>
12+
<IsOSX Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::OSX)))' == 'true'">true</IsOSX>
13+
<IsLinux Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Linux)))' == 'true'">true</IsLinux>
14+
</PropertyGroup>
15+
16+
<PropertyGroup Condition="'$(IsWindows)'=='true'">
17+
<DefineConstants>Windows</DefineConstants>
18+
</PropertyGroup>
19+
<PropertyGroup Condition="'$(IsOSX)'=='true'">
20+
<DefineConstants>OSX</DefineConstants>
21+
</PropertyGroup>
22+
<PropertyGroup Condition="'$(IsLinux)'=='true'">
23+
<DefineConstants>Linux</DefineConstants>
1024
</PropertyGroup>
1125

1226
<!--for optimization-->
@@ -24,12 +38,12 @@
2438
<PackageReference Include="Avalonia" Version="11.2.5" />
2539
<!--<PackageReference Include="Avalonia.Controls.DataGrid" Version="11.2.4" />-->
2640
<PackageReference Include="Avalonia.Desktop" Version="11.2.5" />
27-
<PackageReference Include="Avalonia.Themes.Fluent" Version="11.2.5" />
41+
<!--<PackageReference Include="Avalonia.Themes.Fluent" Version="11.2.5" />-->
2842
<!--<PackageReference Include="Avalonia.Fonts.Inter" Version="11.2.4" />-->
2943
<!--<PackageReference Include="Avalonia.Themes.Simple" Version="11.2.4" />-->
3044
<!--<PackageReference Include="Classic.Avalonia.Theme" Version="11.2.0.7" />-->
3145
<PackageReference Include="FluentAvaloniaUI" Version="2.2.0" />
32-
<PackageReference Include="FluentIcons.Avalonia" Version="1.1.271" />
46+
<!--<PackageReference Include="FluentIcons.Avalonia" Version="1.1.271" />-->
3347
<!--<PackageReference Include="GridExtra.Avalonia" Version="0.9.1" />-->
3448
<!--<PackageReference Include="Material.Avalonia" Version="3.9.2" />-->
3549
<PackageReference Include="MessageBox.Avalonia" Version="3.2.0" />
@@ -42,15 +56,6 @@
4256
<RuntimeIdentifiers>win-x64</RuntimeIdentifiers>
4357
</PropertyGroup>
4458

45-
<PropertyGroup Condition="$([MSBuild]::IsOSPlatform('Windows'))">
46-
<DefineConstants>$(DefineConstants);OS_WINDOWS</DefineConstants>
47-
</PropertyGroup>
48-
<PropertyGroup Condition="$([MSBuild]::IsOSPlatform('Linux'))">
49-
<DefineConstants>$(DefineConstants);OS_LINUX</DefineConstants>
50-
</PropertyGroup>
51-
<PropertyGroup Condition="$([MSBuild]::IsOSPlatform('OSX'))">
52-
<DefineConstants>$(DefineConstants);OS_MAC</DefineConstants>
53-
</PropertyGroup>
5459
<PropertyGroup Label="Avalonia">
5560
<AvaloniaUseCompiledBindingsByDefault>True</AvaloniaUseCompiledBindingsByDefault>
5661
<EnableAvaloniaXamlCompilation>False</EnableAvaloniaXamlCompilation>

0 commit comments

Comments
 (0)