Skip to content

Commit 91eb43d

Browse files
Merge pull request #128 from PhantomGamers/dev
2 parents 7e28aca + 910d81d commit 91eb43d

File tree

6 files changed

+53
-58
lines changed

6 files changed

+53
-58
lines changed

Directory.Packages.props

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,6 @@
3232
<PackageVersion Include="FileWatcherEx" Version="2.5.0" />
3333
<PackageVersion Include="FluentAvaloniaUI" Version="2.0.0-rc1" />
3434
<PackageVersion Include="WindowsShortcutFactory" Version="1.1.0" />
35-
<PackageVersion Include="WmiLight" Version="3.1.0" />
35+
<PackageVersion Include="WmiLight" Version="4.0.0" />
3636
</ItemGroup>
3737
</Project>

SFP/Models/Injection/Injector.cs

+15-15
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ private static async Task ProcessFrame(Frame frame)
218218
{
219219
try
220220
{
221-
if (await frame.QuerySelectorAsync(patch.MatchRegexString) == null)
221+
if (await frame.QuerySelectorAsync(regex) == null)
222222
{
223223
continue;
224224
}
@@ -345,20 +345,20 @@ private static async Task InjectResourceAsync(Frame frame, string fileRelativePa
345345

346346
var injectString =
347347
$@"function inject() {{
348-
if (document.getElementById('{frame.Id}{resourceType}') !== null) return;
349-
const element = document.createElement('{(resourceType == "css" ? "link" : "script")}');
350-
element.id = '{frame.Id}{resourceType}';
351-
{(resourceType == "css" ? "element.rel = 'stylesheet';" : "")}
352-
element.type = '{(resourceType == "css" ? "text/css" : "module")}';
353-
element.{(resourceType == "css" ? "href" : "src")} = 'https://steamloopback.host/{fileRelativePath}';
354-
document.head.append(element);
355-
}}
356-
if ((document.readyState === 'loading') && '{IsFrameWebkit(frame)}' === 'True') {{
357-
addEventListener('DOMContentLoaded', inject);
358-
}} else {{
359-
inject();
360-
}}
361-
";
348+
if (document.getElementById('{frame.Id}{resourceType}') !== null) return;
349+
const element = document.createElement('{(resourceType == "css" ? "link" : "script")}');
350+
element.id = '{frame.Id}{resourceType}';
351+
{(resourceType == "css" ? "element.rel = 'stylesheet';" : "")}
352+
element.type = '{(resourceType == "css" ? "text/css" : "module")}';
353+
element.{(resourceType == "css" ? "href" : "src")} = 'https://steamloopback.host/{fileRelativePath}';
354+
document.head.append(element);
355+
}}
356+
if ((document.readyState === 'loading') && '{IsFrameWebkit(frame)}' === 'True') {{
357+
addEventListener('DOMContentLoaded', inject);
358+
}} else {{
359+
inject();
360+
}}
361+
";
362362
try
363363
{
364364
if (!IsFrameWebkit(frame) && resourceType == "js")

SFP/Models/Steam.cs

+12-4
Original file line numberDiff line numberDiff line change
@@ -194,19 +194,19 @@ public static Task StartSteam(string? args = null)
194194
return Task.CompletedTask;
195195
}
196196

197-
args ??= Settings.Default.SteamLaunchArgs;
197+
args ??= Settings.Default.SteamLaunchArgs.Trim();
198198
const string DebuggingString = @"-cef-enable-debugging";
199199
if (!args.Contains(DebuggingString))
200200
{
201-
args = args.Trim();
202201
args += $" {DebuggingString}";
202+
args = args.Trim();
203203
}
204204

205205
const string BootstrapString = @"-skipinitialbootstrap";
206206
if (OperatingSystem.IsMacOS() && !args.Contains(BootstrapString))
207207
{
208-
args = args.Trim();
209208
args += $" {BootstrapString}";
209+
args = args.Trim();
210210
}
211211

212212
if (OperatingSystem.IsWindows() && File.Exists(MillenniumPath))
@@ -381,7 +381,15 @@ private static async Task<bool> CheckForMissingArgumentsAsync()
381381
return false;
382382
}
383383

384-
var argumentMissing = Settings.Default.SteamLaunchArgs.Trim().ToLower().Split(' ', StringSplitOptions.TrimEntries | StringSplitOptions.RemoveEmptyEntries)
384+
var args = Settings.Default.SteamLaunchArgs.Trim().ToLower();
385+
const string DebuggingString = @"-cef-enable-debugging";
386+
if (!args.Contains(DebuggingString))
387+
{
388+
args += $" {DebuggingString}";
389+
args = args.Trim();
390+
}
391+
392+
var argumentMissing = args.Split(' ', StringSplitOptions.TrimEntries | StringSplitOptions.RemoveEmptyEntries)
385393
.Any(arg => !cmdLine.Contains(arg));
386394

387395
if (!argumentMissing)

SFP/packages.lock.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,9 @@
8989
},
9090
"WmiLight": {
9191
"type": "Direct",
92-
"requested": "[3.1.0, )",
93-
"resolved": "3.1.0",
94-
"contentHash": "VioqRImznVNEe1ye062++9kg/v/bBIXeh6Q7YXyhRtX2snGCqrL6YlKvSkfmJzuTKNmHIcUGPc8xK+p1ZxM1DA==",
92+
"requested": "[4.0.0, )",
93+
"resolved": "4.0.0",
94+
"contentHash": "tRYc62pG2ds4NXtEO+PAWSqnKejyFD8xLOCAO1kl2HzsnEvdZFQ1ZeTcCgx2BUJAW/SUWQADcftbPqaXpRxhEA==",
9595
"dependencies": {
9696
"Microsoft.Win32.Registry": "5.0.0"
9797
}

SFP_UI/Views/MainWindow.axaml.cs

+18-31
Original file line numberDiff line numberDiff line change
@@ -36,34 +36,36 @@ public MainWindow()
3636
}
3737
};
3838

39-
Application.Current!.ActualThemeVariantChanged += ApplicationActualThemeVariantChanged;
39+
Application.Current!.ActualThemeVariantChanged += OnActualThemeVariantChanged;
4040

4141
App.SetApplicationTheme(Settings.Default.AppTheme);
4242
}
4343

4444
public static MainWindow? Instance { get; private set; }
4545

46-
private void ApplicationActualThemeVariantChanged(object? sender, EventArgs e)
46+
private void OnActualThemeVariantChanged(object? sender, EventArgs e)
4747
{
48-
if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
48+
if (!IsWindows11)
4949
{
5050
return;
5151
}
5252

53-
// TODO: add Windows version to CoreWindow
54-
if (IsWindows11 && ActualThemeVariant != FluentAvaloniaTheme.HighContrastTheme)
53+
if (ActualThemeVariant != FluentAvaloniaTheme.HighContrastTheme)
5554
{
5655
TryEnableMicaEffect();
5756
}
58-
else if (ActualThemeVariant != FluentAvaloniaTheme.HighContrastTheme)
57+
else
5958
{
60-
// Clear the local value here, and let the normal styles take over for HighContrast theme
61-
SetValue(BackgroundProperty, AvaloniaProperty.UnsetValue);
59+
ClearValue(BackgroundProperty);
60+
ClearValue(TransparencyBackgroundFallbackProperty);
6261
}
6362
}
6463

6564
private void TryEnableMicaEffect()
6665
{
66+
TransparencyBackgroundFallback = Brushes.Transparent;
67+
TransparencyLevelHint = new[] { WindowTransparencyLevel.Mica, WindowTransparencyLevel.None };
68+
6769
// The background colors for the Mica brush are still based around SolidBackgroundFillColorBase resource
6870
// BUT since we can't control the actual Mica brush color, we have to use the window background to create
6971
// the same effect. However, we can't use SolidBackgroundFillColorBase directly since its opaque, and if
@@ -73,22 +75,18 @@ private void TryEnableMicaEffect()
7375
// CompositionBrush to properly change the color but I don't know if we can do that or not
7476
if (ActualThemeVariant == ThemeVariant.Dark)
7577
{
76-
Color2 color = this.TryFindResource("SolidBackgroundFillColorBase",
77-
ThemeVariant.Dark, out var value)
78-
? (Color)value!
79-
: new Color2(32, 32, 32);
78+
var color = this.TryFindResource("SolidBackgroundFillColorBase",
79+
ThemeVariant.Dark, out var value) ? (Color2)(Color)value! : new Color2(32, 32, 32);
8080

8181
color = color.LightenPercent(-0.8f);
8282

83-
Background = new ImmutableSolidColorBrush(color, 0.78);
83+
Background = new ImmutableSolidColorBrush(color, 0.9);
8484
}
8585
else if (ActualThemeVariant == ThemeVariant.Light)
8686
{
8787
// Similar effect here
88-
Color2 color = this.TryFindResource("SolidBackgroundFillColorBase",
89-
ThemeVariant.Light, out var value)
90-
? (Color)value!
91-
: new Color2(243, 243, 243);
88+
var color = this.TryFindResource("SolidBackgroundFillColorBase",
89+
ThemeVariant.Light, out var value) ? (Color2)(Color)value! : new Color2(243, 243, 243);
9290

9391
color = color.LightenPercent(0.5f);
9492

@@ -100,22 +98,11 @@ protected override void OnOpened(EventArgs e)
10098
{
10199
base.OnOpened(e);
102100

103-
// Enable Mica on Windows 11
104-
if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
105-
{
106-
return;
107-
}
108-
109-
// TODO: add Windows version to CoreWindow
110-
if (!IsWindows11 || ActualThemeVariant == FluentAvaloniaTheme.HighContrastTheme)
101+
var thm = ActualThemeVariant;
102+
if (IsWindows11 && thm != FluentAvaloniaTheme.HighContrastTheme)
111103
{
112-
return;
104+
TryEnableMicaEffect();
113105
}
114-
115-
TransparencyBackgroundFallback = Brushes.Transparent;
116-
TransparencyLevelHint = new[] { WindowTransparencyLevel.Mica, WindowTransparencyLevel.None };
117-
118-
TryEnableMicaEffect();
119106
}
120107

121108
protected override async void OnClosing(WindowClosingEventArgs e)

SFP_UI/packages.lock.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -1527,7 +1527,7 @@
15271527
"PortableJsonSettingsProvider": "[0.2.1, )",
15281528
"PuppeteerSharp": "[6.2.0, )",
15291529
"WindowsShortcutFactory": "[1.1.0, )",
1530-
"WmiLight": "[3.1.0, )"
1530+
"WmiLight": "[4.0.0, )"
15311531
}
15321532
},
15331533
"FileWatcherEx": {
@@ -1587,9 +1587,9 @@
15871587
},
15881588
"WmiLight": {
15891589
"type": "CentralTransitive",
1590-
"requested": "[3.1.0, )",
1591-
"resolved": "3.1.0",
1592-
"contentHash": "VioqRImznVNEe1ye062++9kg/v/bBIXeh6Q7YXyhRtX2snGCqrL6YlKvSkfmJzuTKNmHIcUGPc8xK+p1ZxM1DA==",
1590+
"requested": "[4.0.0, )",
1591+
"resolved": "4.0.0",
1592+
"contentHash": "tRYc62pG2ds4NXtEO+PAWSqnKejyFD8xLOCAO1kl2HzsnEvdZFQ1ZeTcCgx2BUJAW/SUWQADcftbPqaXpRxhEA==",
15931593
"dependencies": {
15941594
"Microsoft.Win32.Registry": "5.0.0"
15951595
}

0 commit comments

Comments
 (0)