Skip to content

Commit

Permalink
Fix typo on UseExternalBrowser
Browse files Browse the repository at this point in the history
Also move the function into the invoker instead
Still doesn't fix the crashing issue on OpenButtonLinkFromTag especially on CommunityTool :(
  • Loading branch information
bagusnl committed Jan 8, 2024
1 parent b1922e8 commit 41a7ece
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 26 deletions.
16 changes: 13 additions & 3 deletions CollapseLauncher/Classes/EventsManagement/EventsHandler.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
using Hi3Helper;
using Hi3Helper.Data;
using Hi3Helper.Http;
using Hi3Helper.Shared.ClassStruct;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Media.Animation;
using Squirrel;
using System;
using System.Collections.Generic;
using System.IO;
using System.Diagnostics;
using System.Threading.Tasks;
using Windows.Foundation;
using Windows.Networking.Connectivity;
Expand Down Expand Up @@ -329,7 +328,18 @@ internal BackgroundImgProperty(string ImgPath, bool IsCustom)
internal static class SpawnWebView2
{
static SpawnWebView2Invoker invoker = new SpawnWebView2Invoker();
public static void SpawnWebView2Window(string URL) => invoker.SpawnWebView2Window(URL);
public static void SpawnWebView2Window(string URL)
{
if (GetAppConfigValue("UseExternalBrowser").ToBool())
{
Process.Start(new ProcessStartInfo
{
FileName = URL,
UseShellExecute = true,
});
}
else invoker.SpawnWebView2Window(URL);
}
}

internal class SpawnWebView2Invoker
Expand Down
2 changes: 1 addition & 1 deletion CollapseLauncher/XAMLs/MainApp/Pages/SettingsPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -649,7 +649,7 @@ private bool IsLowerCollapsePriorityOnGameLaunch

private bool IsAlwaysUseExternalBrowser
{
get => GetAppConfigValue("UserExternalBrowser").ToBool();
get => GetAppConfigValue("UseExternalBrowser").ToBool();
set => SetAndSaveConfigValue("UseExternalBrowser", value);
}

Expand Down
31 changes: 9 additions & 22 deletions CollapseLauncher/XAMLs/MainApp/WebView2FramePage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,8 @@ public sealed partial class WebView2FramePage : Page

public WebView2FramePage()
{
if (WebView2URL == null) return;

if (GetAppConfigValue("UseExternalBrowser").ToBool())
{
Process.Start(new ProcessStartInfo
{
FileName = WebView2URL.ToString(),
UseShellExecute = true,
});
}
else
{
this.InitializeComponent();
SpawnWebView2Panel(WebView2URL);
}
this.InitializeComponent();
SpawnWebView2Panel(WebView2URL);
}

private async void SpawnWebView2Panel(Uri URL)
Expand All @@ -42,20 +29,20 @@ private async void SpawnWebView2Panel(Uri URL)
Environment.SetEnvironmentVariable("WEBVIEW2_USER_DATA_FOLDER", Path.Combine(AppGameFolder, "_webView2"));

WebView2Runtime = new WebView2()
{
HorizontalAlignment = HorizontalAlignment.Stretch,
VerticalAlignment = VerticalAlignment.Stretch
};
{
HorizontalAlignment = HorizontalAlignment.Stretch,
VerticalAlignment = VerticalAlignment.Stretch
};
WebViewWindowTitle.Text = string.Empty;

WebView2Runtime.CoreWebView2Initialized += WebView2Window_CoreWebView2Initialized;
WebView2Runtime.NavigationStarting += WebView2Window_PageLoading;
WebView2Runtime.NavigationCompleted += WebView2Window_PageLoaded;
WebView2Runtime.NavigationStarting += WebView2Window_PageLoading;
WebView2Runtime.NavigationCompleted += WebView2Window_PageLoaded;

WebView2WindowContainer.Children.Clear();
WebView2WindowContainer.Children.Add(WebView2Runtime);

WebView2Panel.Visibility = Visibility.Visible;
WebView2Panel.Visibility = Visibility.Visible;
WebView2Panel.Translation += Shadow32;
await WebView2Runtime.EnsureCoreWebView2Async();

Expand Down

0 comments on commit 41a7ece

Please sign in to comment.