Remove Overwolf Support
This commit is contained in:
parent
0ccd38359a
commit
b6181e174b
@ -1,6 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$USER_HOME$/MiNET.LevelDB" vcs="Git" />
|
||||
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
||||
@ -31,9 +31,4 @@
|
||||
<PackageReference Include="Avalonia.ReactiveUI" Version="11.0.6"/>
|
||||
<PackageReference Include="FluentAvalonia.ProgressRing" Version="1.69.2" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\MiNET.LevelDB\MiNET.LevelDB\MiNET.LevelDB.csproj" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
||||
@ -2,8 +2,6 @@
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VaultSmpInstaller", "VaultSmpInstaller.csproj", "{5111A3E1-248F-43AF-A70B-51248B418BE9}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MiNET.LevelDB", "..\..\MiNET.LevelDB\MiNET.LevelDB\MiNET.LevelDB.csproj", "{7CD1B124-DEEE-4745-820F-C499E7AE3A6B}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
@ -14,9 +12,5 @@ Global
|
||||
{5111A3E1-248F-43AF-A70B-51248B418BE9}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{5111A3E1-248F-43AF-A70B-51248B418BE9}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{5111A3E1-248F-43AF-A70B-51248B418BE9}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{7CD1B124-DEEE-4745-820F-C499E7AE3A6B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{7CD1B124-DEEE-4745-820F-C499E7AE3A6B}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{7CD1B124-DEEE-4745-820F-C499E7AE3A6B}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{7CD1B124-DEEE-4745-820F-C499E7AE3A6B}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
|
||||
@ -2,10 +2,9 @@
|
||||
using System.IO;
|
||||
using System.Reactive;
|
||||
using System.Reactive.Linq;
|
||||
using System.Text;
|
||||
using System.Text.Json.Nodes;
|
||||
using Avalonia.Media;
|
||||
using MiNET.LevelDB;
|
||||
using Microsoft.Win32;
|
||||
using ReactiveUI;
|
||||
|
||||
namespace VaultSmpInstaller.ViewModels;
|
||||
@ -16,13 +15,11 @@ public class ProfileWindow1ViewModel : ViewModelBase
|
||||
|
||||
public ReactiveCommand<Unit, ProfileWindow2ViewModel.InstanceInfo?> UseCurseforgeCommand { get; }
|
||||
public ReactiveCommand<Unit, ProfileWindow2ViewModel.InstanceInfo?> UsePrismCommand { get; }
|
||||
public ReactiveCommand<Unit, ProfileWindow2ViewModel.InstanceInfo?> UseOverwolfCommand { get; }
|
||||
|
||||
public ProfileWindow1ViewModel()
|
||||
{
|
||||
var curseforgeDir = CurseforgeInstanceDir;
|
||||
var prismDir = PrismInstanceDir;
|
||||
var overwolfDir = OverwolfInstanceDir;
|
||||
|
||||
ShowProfileSelectionDialog = new Interaction<ProfileWindow2ViewModel, ProfileWindow2ViewModel.InstanceInfo?>();
|
||||
|
||||
@ -37,13 +34,6 @@ public class ProfileWindow1ViewModel : ViewModelBase
|
||||
var profileWindowModel = new ProfileWindow2ViewModel(ProfileWindow2ViewModel.InstanceType.Prism, prismDir);
|
||||
return await ShowProfileSelectionDialog.Handle(profileWindowModel);
|
||||
});
|
||||
|
||||
UseOverwolfCommand = ReactiveCommand.CreateFromTask(async () =>
|
||||
{
|
||||
var profileWindowModel = new ProfileWindow2ViewModel(ProfileWindow2ViewModel.InstanceType.Overwolf, overwolfDir);
|
||||
return await ShowProfileSelectionDialog.Handle(profileWindowModel);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public static Brush Background => SolidColorBrush.Parse("#282A36");
|
||||
@ -91,25 +81,7 @@ public class ProfileWindow1ViewModel : ViewModelBase
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsOverwolfInstalled { get; set; } = false;
|
||||
|
||||
private string? _overwolfInstanceDir = null;
|
||||
public string OverwolfButtonText => IsOverwolfInstalled ? "Curseforge (Overwolf)" : "Curseforge (Overwolf) Not Detected";
|
||||
|
||||
public string? OverwolfInstanceDir
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_overwolfInstanceDir == null && TryGetOverwolfMinecraftRoot(out _overwolfInstanceDir))
|
||||
{
|
||||
IsOverwolfInstalled = true;
|
||||
this.RaisePropertyChanged(nameof(IsOverwolfInstalled));
|
||||
this.RaisePropertyChanged(nameof(OverwolfButtonText));
|
||||
this.RaisePropertyChanged();
|
||||
}
|
||||
return _overwolfInstanceDir;
|
||||
}
|
||||
}
|
||||
public bool IsOverwolfInstalled { get; set; } = Registry.GetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Overwolf", "UninstallString", null) != null;
|
||||
|
||||
public bool TryGetCurseforgeMinecraftRoot(out string? minecraftRoot)
|
||||
{
|
||||
@ -161,60 +133,60 @@ public class ProfileWindow1ViewModel : ViewModelBase
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool TryGetOverwolfMinecraftRoot(out string? minecraftRoot)
|
||||
{
|
||||
minecraftRoot = null;
|
||||
|
||||
var localAppData = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
|
||||
var overwolfDbDirectory = Path.Combine(localAppData, "Overwolf", "BrowserCache", "Local Storage", "leveldb");
|
||||
|
||||
if (!Directory.Exists(overwolfDbDirectory)) return false;
|
||||
|
||||
var overwolfDb = new Database(new(overwolfDbDirectory), false, new Options() { ReadOnly = true });
|
||||
byte[] databaseKey = new byte[]
|
||||
{
|
||||
0x5F, 0x6F,
|
||||
0x76, 0x65, 0x72, 0x77, 0x6F, 0x6C, 0x66, 0x2D,
|
||||
0x65, 0x78, 0x74, 0x65, 0x6E, 0x73, 0x69, 0x6F,
|
||||
0x6E, 0x3A, 0x2F, 0x2F, 0x63, 0x63, 0x68, 0x68,
|
||||
0x63, 0x61, 0x69, 0x61, 0x70, 0x65, 0x69, 0x6B,
|
||||
0x6A, 0x62, 0x64, 0x62, 0x70, 0x66, 0x70, 0x6C,
|
||||
0x67, 0x6D, 0x70, 0x6F, 0x62, 0x62, 0x63, 0x64,
|
||||
0x6B, 0x64, 0x61, 0x70, 0x68, 0x63, 0x6C, 0x62,
|
||||
0x6D, 0x6B, 0x62, 0x6A, 0x00, 0x01, 0x6D, 0x69,
|
||||
0x6E, 0x65, 0x63, 0x72, 0x61, 0x66, 0x74, 0x2D,
|
||||
0x73, 0x65, 0x74, 0x74, 0x69, 0x6E, 0x67, 0x73
|
||||
};
|
||||
String? curseforgeMinecraftSettings = "";
|
||||
try
|
||||
{
|
||||
overwolfDb.Open();
|
||||
curseforgeMinecraftSettings = Encoding.ASCII.GetString(overwolfDb.Get(databaseKey))[1..];
|
||||
}
|
||||
catch (NullReferenceException e)
|
||||
{
|
||||
minecraftRoot = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), "curseforge", "minecraft", "Instances");
|
||||
return true;
|
||||
}
|
||||
finally
|
||||
{
|
||||
overwolfDb.Close();
|
||||
overwolfDb.Dispose();
|
||||
}
|
||||
if(String.IsNullOrEmpty(curseforgeMinecraftSettings))
|
||||
{
|
||||
minecraftRoot = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), "curseforge", "minecraft", "Instances");
|
||||
return true;
|
||||
}
|
||||
|
||||
var minecraftSettings = JsonNode.Parse(curseforgeMinecraftSettings);
|
||||
if (!minecraftSettings!.AsObject().TryGetPropertyValue("minecraftRoot", out var minecraftRootNode)) {
|
||||
minecraftRoot = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), "curseforge", "minecraft", "Instances");
|
||||
return true;
|
||||
}
|
||||
if (!minecraftRootNode!.AsValue().TryGetValue(out minecraftRoot)) return false;
|
||||
|
||||
minecraftRoot = Path.Combine(minecraftRoot, "Instances");
|
||||
return true;
|
||||
}
|
||||
// public bool TryGetOverwolfMinecraftRoot(out string? minecraftRoot)
|
||||
// {
|
||||
// minecraftRoot = null;
|
||||
//
|
||||
// var localAppData = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
|
||||
// var overwolfDbDirectory = Path.Combine(localAppData, "Overwolf", "BrowserCache", "Local Storage", "leveldb");
|
||||
//
|
||||
// if (!Directory.Exists(overwolfDbDirectory)) return false;
|
||||
//
|
||||
// var overwolfDb = new Database(new(overwolfDbDirectory), false, new Options() { ReadOnly = true});
|
||||
// byte[] databaseKey = new byte[]
|
||||
// {
|
||||
// 0x5F, 0x6F,
|
||||
// 0x76, 0x65, 0x72, 0x77, 0x6F, 0x6C, 0x66, 0x2D,
|
||||
// 0x65, 0x78, 0x74, 0x65, 0x6E, 0x73, 0x69, 0x6F,
|
||||
// 0x6E, 0x3A, 0x2F, 0x2F, 0x63, 0x63, 0x68, 0x68,
|
||||
// 0x63, 0x61, 0x69, 0x61, 0x70, 0x65, 0x69, 0x6B,
|
||||
// 0x6A, 0x62, 0x64, 0x62, 0x70, 0x66, 0x70, 0x6C,
|
||||
// 0x67, 0x6D, 0x70, 0x6F, 0x62, 0x62, 0x63, 0x64,
|
||||
// 0x6B, 0x64, 0x61, 0x70, 0x68, 0x63, 0x6C, 0x62,
|
||||
// 0x6D, 0x6B, 0x62, 0x6A, 0x00, 0x01, 0x6D, 0x69,
|
||||
// 0x6E, 0x65, 0x63, 0x72, 0x61, 0x66, 0x74, 0x2D,
|
||||
// 0x73, 0x65, 0x74, 0x74, 0x69, 0x6E, 0x67, 0x73
|
||||
// };
|
||||
// String? curseforgeMinecraftSettings = "";
|
||||
// try
|
||||
// {
|
||||
// overwolfDb.Open();
|
||||
// curseforgeMinecraftSettings = Encoding.ASCII.GetString(overwolfDb.Get(databaseKey))[1..];
|
||||
// }
|
||||
// catch (NullReferenceException e)
|
||||
// {
|
||||
// minecraftRoot = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), "curseforge", "minecraft", "Instances");
|
||||
// return true;
|
||||
// }
|
||||
// finally
|
||||
// {
|
||||
// overwolfDb.Close();
|
||||
// overwolfDb.Dispose();
|
||||
// }
|
||||
// if(String.IsNullOrEmpty(curseforgeMinecraftSettings))
|
||||
// {
|
||||
// minecraftRoot = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), "curseforge", "minecraft", "Instances");
|
||||
// return true;
|
||||
// }
|
||||
//
|
||||
// var minecraftSettings = JsonNode.Parse(curseforgeMinecraftSettings);
|
||||
// if (!minecraftSettings!.AsObject().TryGetPropertyValue("minecraftRoot", out var minecraftRootNode)) {
|
||||
// minecraftRoot = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), "curseforge", "minecraft", "Instances");
|
||||
// return true;
|
||||
// }
|
||||
// if (!minecraftRootNode!.AsValue().TryGetValue(out minecraftRoot)) return false;
|
||||
//
|
||||
// minecraftRoot = Path.Combine(minecraftRoot, "Instances");
|
||||
// return true;
|
||||
// }
|
||||
}
|
||||
@ -11,10 +11,9 @@
|
||||
Width="400" Height="175"
|
||||
WindowStartupLocation="CenterOwner"
|
||||
CanResize="False">
|
||||
<Grid Background="{Binding Background}" RowDefinitions="Auto, *, *, *">
|
||||
<Grid Background="{Binding Background}" RowDefinitions="Auto, *, *">
|
||||
<TextBlock Grid.Row="0" FontSize="18" Margin="0, 10">Please Select Prism Launcher or Curseforge</TextBlock>
|
||||
<Button Grid.Row="1" Command="{Binding UsePrismCommand}" FontSize="18" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" VerticalContentAlignment="Center" HorizontalContentAlignment="Center" Margin="25, 5" Content="{Binding PrismButtonText}" IsEnabled="{Binding IsPrismInstalled}"/>
|
||||
<Button Grid.Row="2" Command="{Binding UseCurseforgeCommand}" FontSize="18" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" VerticalContentAlignment="Center" HorizontalContentAlignment="Center" Margin="25, 5" Content="{Binding CurseforgeButtonText}" IsEnabled="{Binding IsCurseforgeInstalled}"/>
|
||||
<Button Grid.Row="3" Command="{Binding UseOverwolfCommand}" FontSize="18" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" VerticalContentAlignment="Center" HorizontalContentAlignment="Center" Margin="25, 5" Content="{Binding OverwolfButtonText}" IsEnabled="{Binding IsOverwolfInstalled}"/>
|
||||
</Grid>
|
||||
</Window>
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Avalonia.ReactiveUI;
|
||||
using Avalonia.Threading;
|
||||
using ReactiveUI;
|
||||
using VaultSmpInstaller.ViewModels;
|
||||
|
||||
@ -14,10 +15,22 @@ public partial class ProfileWindow1 : ReactiveWindow<ProfileWindow1ViewModel>
|
||||
|
||||
this.WhenActivated(d => d(ViewModel!.UseCurseforgeCommand.Subscribe(Close)));
|
||||
this.WhenActivated(d => d(ViewModel!.UsePrismCommand.Subscribe(Close)));
|
||||
this.WhenActivated(d => d(ViewModel!.UseOverwolfCommand.Subscribe(Close)));
|
||||
|
||||
this.WhenActivated(action =>
|
||||
action(ViewModel!.ShowProfileSelectionDialog.RegisterHandler(DoShowDialogAsync)));
|
||||
this.WhenActivated(action => action(ViewModel!.ShowProfileSelectionDialog.RegisterHandler(DoShowDialogAsync)));
|
||||
|
||||
this.WhenActivated(_ =>
|
||||
{
|
||||
if (ViewModel!.IsOverwolfInstalled)
|
||||
{
|
||||
var removeOverwolfWindow = new RemoveOverwolfWindow();
|
||||
removeOverwolfWindow.DataContext = new ThemeViewModel();
|
||||
|
||||
Dispatcher.UIThread.Invoke( () =>
|
||||
{
|
||||
removeOverwolfWindow.ShowDialog(this);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
private async Task DoShowDialogAsync(InteractionContext<ProfileWindow2ViewModel, ProfileWindow2ViewModel.InstanceInfo?> interaction)
|
||||
{
|
||||
@ -27,5 +40,4 @@ public partial class ProfileWindow1 : ReactiveWindow<ProfileWindow1ViewModel>
|
||||
var result = await dialog.ShowDialog<ProfileWindow2ViewModel.InstanceInfo?>(this);
|
||||
interaction.SetOutput(result);
|
||||
}
|
||||
|
||||
}
|
||||
36
Views/RemoveOverwolfWindow.axaml
Normal file
36
Views/RemoveOverwolfWindow.axaml
Normal file
@ -0,0 +1,36 @@
|
||||
<Window xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:vm="using:VaultSmpInstaller.ViewModels"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:controls="clr-namespace:FluentAvalonia.UI.Controls;assembly=FluentAvalonia"
|
||||
mc:Ignorable="d" d:DesignWidth="600" d:DesignHeight="400"
|
||||
x:Class="VaultSmpInstaller.Views.RemoveOverwolfWindow"
|
||||
x:DataType="vm:ThemeViewModel"
|
||||
Icon="/Assets/icon.ico"
|
||||
Title="Overwolf Detected"
|
||||
Width="600" Height="400"
|
||||
WindowStartupLocation="CenterOwner"
|
||||
CanResize="False">
|
||||
<Design.DataContext>
|
||||
<vm:ThemeViewModel/>
|
||||
</Design.DataContext>
|
||||
<Grid Margin="15" Background="{Binding Background}" RowDefinitions="Auto, *, Auto">
|
||||
<StackPanel>
|
||||
<TextBlock FontSize="18" Margin="15">Curseforge with Overwolf Detected</TextBlock>
|
||||
<TextBlock>Please note: Curseforge installed with Overwolf is not</TextBlock>
|
||||
<TextBlock Margin="0, 0, 0, 10">and will never be supported by this installer.</TextBlock>
|
||||
<TextBlock>A standalone Curseforge launcher exists and is created by Curseforge, use it instead.</TextBlock>
|
||||
<TextBlock>It uses the same default instance folder as the Overwolf launcher.</TextBlock>
|
||||
<TextBlock>If you didn't change the instance folder, it will keep your instances.</TextBlock>
|
||||
</StackPanel>
|
||||
<Grid Grid.Row="1" ColumnDefinitions="*, *">
|
||||
<Button Click="DownloadNewLaucher">Download New Launcher</Button>
|
||||
<Button Grid.Column="1" Margin="0, 0, 0, 10" Click="UninstallOldVersion">Uninstall Old Launcher</Button>
|
||||
</Grid>
|
||||
<Grid Grid.Row="2" ColumnDefinitions="*">
|
||||
<Button Margin="5, 10, 10, 10" Click="Continue">Continue</Button>
|
||||
</Grid>
|
||||
</Grid>
|
||||
|
||||
</Window>
|
||||
77
Views/RemoveOverwolfWindow.axaml.cs
Normal file
77
Views/RemoveOverwolfWindow.axaml.cs
Normal file
@ -0,0 +1,77 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Runtime.InteropServices;
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Interactivity;
|
||||
using Avalonia.Markup.Xaml;
|
||||
using Avalonia.Threading;
|
||||
using FluentAvalonia.UI.Controls;
|
||||
using Microsoft.Win32;
|
||||
|
||||
namespace VaultSmpInstaller.Views;
|
||||
|
||||
public partial class RemoveOverwolfWindow : Window
|
||||
{
|
||||
public RemoveOverwolfWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void Continue(object? sender, RoutedEventArgs e)
|
||||
{
|
||||
Dispatcher.UIThread.Invoke(Close);
|
||||
}
|
||||
|
||||
private void UninstallOldVersion(object? sender, RoutedEventArgs e)
|
||||
{
|
||||
string keyPath = @"HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Overwolf";
|
||||
string valueName = "UninstallString";
|
||||
String? uninstallPath = (string?)Registry.GetValue(keyPath, valueName, null);
|
||||
|
||||
|
||||
if (uninstallPath != null)
|
||||
{
|
||||
Process proc = new Process();
|
||||
proc.StartInfo.FileName = uninstallPath[..uninstallPath.LastIndexOf('/')].Replace('"', ' ').Trim();
|
||||
proc.StartInfo.UseShellExecute = true;
|
||||
proc.StartInfo.Verb = "runas";
|
||||
proc.Start();
|
||||
}
|
||||
}
|
||||
|
||||
private void DownloadNewLaucher(object? sender, RoutedEventArgs e)
|
||||
{
|
||||
OpenUrl("https://download.overwolf.com/install/Download?ExtensionId=cfiahnpaolfnlgaihhmobmnjdafknjnjdpdabpcm");
|
||||
}
|
||||
|
||||
private void OpenUrl(string url)
|
||||
{
|
||||
try
|
||||
{
|
||||
Process.Start(url);
|
||||
}
|
||||
catch
|
||||
{
|
||||
// hack because of this: https://github.com/dotnet/corefx/issues/10361
|
||||
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
||||
{
|
||||
url = url.Replace("&", "^&");
|
||||
Process.Start(new ProcessStartInfo(url) { UseShellExecute = true });
|
||||
}
|
||||
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
|
||||
{
|
||||
Process.Start("xdg-open", url);
|
||||
}
|
||||
else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
|
||||
{
|
||||
Process.Start("open", url);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user