mirror of
https://github.com/wabbajack-tools/wabbajack.git
synced 2024-08-30 18:42:17 +00:00
Merge pull request #488 from wabbajack-tools/launcher-first-spike
Launcher first spike
This commit is contained in:
commit
6703b4090e
@ -100,5 +100,7 @@ namespace Wabbajack.Common
|
||||
public static int WabbajackCachePort = 80;
|
||||
public static int MaxHTTPRetries = 4;
|
||||
public const string MO2ModFolderName = "mods";
|
||||
|
||||
public static string PatchCacheFolder => Path.Combine(LocalAppDataPath, "patch_cache");
|
||||
}
|
||||
}
|
||||
|
@ -824,9 +824,9 @@ namespace Wabbajack.Common
|
||||
{
|
||||
var dataA = a.xxHash().FromBase64().ToHex();
|
||||
var dataB = b.xxHash().FromBase64().ToHex();
|
||||
var cacheFile = Path.Combine("patch_cache", $"{dataA}_{dataB}.patch");
|
||||
if (!Directory.Exists("patch_cache"))
|
||||
Directory.CreateDirectory("patch_cache");
|
||||
var cacheFile = Path.Combine(Consts.PatchCacheFolder, $"{dataA}_{dataB}.patch");
|
||||
if (!Directory.Exists(Consts.PatchCacheFolder))
|
||||
Directory.CreateDirectory(Consts.PatchCacheFolder);
|
||||
|
||||
while (true)
|
||||
{
|
||||
@ -837,7 +837,7 @@ namespace Wabbajack.Common
|
||||
}
|
||||
else
|
||||
{
|
||||
var tmpName = Path.Combine("patch_cache", Guid.NewGuid() + ".tmp");
|
||||
var tmpName = Path.Combine(Consts.PatchCacheFolder, Guid.NewGuid() + ".tmp");
|
||||
|
||||
await using (var f = File.Open(tmpName, System.IO.FileMode.Create))
|
||||
{
|
||||
@ -867,7 +867,7 @@ namespace Wabbajack.Common
|
||||
|
||||
public static bool TryGetPatch(string foundHash, string fileHash, out byte[] ePatch)
|
||||
{
|
||||
var patchName = Path.Combine("patch_cache",
|
||||
var patchName = Path.Combine(Consts.PatchCacheFolder,
|
||||
$"{foundHash.FromBase64().ToHex()}_{fileHash.FromBase64().ToHex()}.patch");
|
||||
if (File.Exists(patchName))
|
||||
{
|
||||
|
1163
Wabbajack.Launcher/Annotations.cs
Normal file
1163
Wabbajack.Launcher/Annotations.cs
Normal file
File diff suppressed because it is too large
Load Diff
9
Wabbajack.Launcher/App.xaml
Normal file
9
Wabbajack.Launcher/App.xaml
Normal file
@ -0,0 +1,9 @@
|
||||
<Application x:Class="Wabbajack.Launcher.App"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:local="clr-namespace:Wabbajack.Launcher"
|
||||
StartupUri="MainWindow.xaml">
|
||||
<Application.Resources>
|
||||
|
||||
</Application.Resources>
|
||||
</Application>
|
17
Wabbajack.Launcher/App.xaml.cs
Normal file
17
Wabbajack.Launcher/App.xaml.cs
Normal file
@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Configuration;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
|
||||
namespace Wabbajack.Launcher
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for App.xaml
|
||||
/// </summary>
|
||||
public partial class App : Application
|
||||
{
|
||||
}
|
||||
}
|
10
Wabbajack.Launcher/AssemblyInfo.cs
Normal file
10
Wabbajack.Launcher/AssemblyInfo.cs
Normal file
@ -0,0 +1,10 @@
|
||||
using System.Windows;
|
||||
|
||||
[assembly: ThemeInfo(
|
||||
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
|
||||
//(used if a resource is not found in the page,
|
||||
// or application resource dictionaries)
|
||||
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
|
||||
//(used if a resource is not found in the page,
|
||||
// app, or any theme specific resource dictionaries)
|
||||
)]
|
23
Wabbajack.Launcher/MainWindow.xaml
Normal file
23
Wabbajack.Launcher/MainWindow.xaml
Normal file
@ -0,0 +1,23 @@
|
||||
<Window x:Class="Wabbajack.Launcher.MainWindow"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:local="clr-namespace:Wabbajack.Launcher"
|
||||
mc:Ignorable="d"
|
||||
Title="Wabbajack Launcher" Height="320" Width="600"
|
||||
WindowStyle="None"
|
||||
Background="#121212"
|
||||
BorderThickness="0"
|
||||
AllowsTransparency="False"
|
||||
ResizeMode="NoResize"
|
||||
WindowStartupLocation="CenterScreen">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="275"></RowDefinition>
|
||||
<RowDefinition Height="45"></RowDefinition>
|
||||
</Grid.RowDefinitions>
|
||||
<Image Grid.Row="0" Source="Wabba_Mouth_Small.png"></Image>
|
||||
<Label Grid.Row="1" Foreground="White" FontSize="20" Content="{Binding Status}"></Label>
|
||||
</Grid>
|
||||
</Window>
|
29
Wabbajack.Launcher/MainWindow.xaml.cs
Normal file
29
Wabbajack.Launcher/MainWindow.xaml.cs
Normal file
@ -0,0 +1,29 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace Wabbajack.Launcher
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for MainWindow.xaml
|
||||
/// </summary>
|
||||
public partial class MainWindow : Window
|
||||
{
|
||||
public MainWindow()
|
||||
{
|
||||
DataContext = new MainWindowVM();
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
155
Wabbajack.Launcher/MainWindowVM.cs
Normal file
155
Wabbajack.Launcher/MainWindowVM.cs
Normal file
@ -0,0 +1,155 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.IO.Compression;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Threading.Tasks;
|
||||
using Newtonsoft.Json;
|
||||
using Wabbajack.Launcher.Annotations;
|
||||
|
||||
namespace Wabbajack.Launcher
|
||||
{
|
||||
public class MainWindowVM : INotifyPropertyChanged
|
||||
{
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
private WebClient _client = new WebClient();
|
||||
public Uri GITHUB_REPO = new Uri("https://api.github.com/repos/wabbajack-tools/temp-releases/releases");
|
||||
|
||||
|
||||
[NotifyPropertyChangedInvocator]
|
||||
protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
|
||||
{
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
|
||||
private string _status = "Checking for Updates";
|
||||
private Release _version;
|
||||
|
||||
public string Status
|
||||
{
|
||||
set
|
||||
{
|
||||
_status = value;
|
||||
OnPropertyChanged("Status");
|
||||
}
|
||||
get
|
||||
{
|
||||
return _status;
|
||||
}
|
||||
}
|
||||
|
||||
public MainWindowVM()
|
||||
{
|
||||
Task.Run(CheckForUpdates);
|
||||
}
|
||||
|
||||
private async Task CheckForUpdates()
|
||||
{
|
||||
_client.Headers.Add ("user-agent", "Wabbajack Launcher");
|
||||
Status = "Selecting Release";
|
||||
|
||||
try
|
||||
{
|
||||
var releases = await GetReleases();
|
||||
_version = releases.OrderByDescending(r =>
|
||||
{
|
||||
if (Version.TryParse(r.Tag, out var v))
|
||||
return v;
|
||||
return new Version(0, 0, 0, 0);
|
||||
}).FirstOrDefault();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
FinishAndExit();
|
||||
}
|
||||
|
||||
if (_version == null)
|
||||
FinishAndExit();
|
||||
|
||||
Status = "Looking for Updates";
|
||||
|
||||
var base_folder = Path.Combine(Directory.GetCurrentDirectory(), _version.Tag);
|
||||
|
||||
if (File.Exists(Path.Combine(base_folder, "Wabbajack.exe")))
|
||||
FinishAndExit();
|
||||
|
||||
var asset = _version.Assets.FirstOrDefault(a => a.Name == _version.Tag + ".zip");
|
||||
if (asset == null)
|
||||
FinishAndExit();
|
||||
|
||||
var wc = new WebClient();
|
||||
wc.DownloadProgressChanged += UpdateProgress;
|
||||
Status = $"Downloading {_version.Tag} ...";
|
||||
var data = await wc.DownloadDataTaskAsync(asset.BrowserDownloadUrl);
|
||||
|
||||
using (var zip = new ZipArchive(new MemoryStream(data), ZipArchiveMode.Read))
|
||||
{
|
||||
foreach (var entry in zip.Entries)
|
||||
{
|
||||
Status = $"Extracting: {entry.Name}";
|
||||
var outPath = Path.Combine(base_folder, entry.FullName);
|
||||
if (!Directory.Exists(Path.GetDirectoryName(outPath)))
|
||||
Directory.CreateDirectory(Path.GetDirectoryName(outPath));
|
||||
|
||||
if (entry.FullName.EndsWith("/") || entry.FullName.EndsWith("\\"))
|
||||
continue;
|
||||
await using var o = entry.Open();
|
||||
await using var of = File.Create(outPath);
|
||||
await o.CopyToAsync(of);
|
||||
}
|
||||
}
|
||||
FinishAndExit();
|
||||
}
|
||||
|
||||
private void FinishAndExit()
|
||||
{
|
||||
Status = "Launching...";
|
||||
var wjFolder = Directory.EnumerateDirectories(Directory.GetCurrentDirectory())
|
||||
.OrderByDescending(v =>
|
||||
Version.TryParse(Path.GetFileName(v), out var ver) ? ver : new Version(0, 0, 0, 0))
|
||||
.FirstOrDefault();
|
||||
var info = new ProcessStartInfo
|
||||
{
|
||||
FileName = Path.Combine(wjFolder, "Wabbajack.exe"),
|
||||
WorkingDirectory = wjFolder,
|
||||
};
|
||||
Process.Start(info);
|
||||
Environment.Exit(0);
|
||||
}
|
||||
|
||||
private void UpdateProgress(object sender, DownloadProgressChangedEventArgs e)
|
||||
{
|
||||
Status = $"Downloading {_version.Tag} ({e.ProgressPercentage}%)...";
|
||||
}
|
||||
|
||||
private async Task<Release[]> GetReleases()
|
||||
{
|
||||
Status = "Checking GitHub Repository";
|
||||
var data = await _client.DownloadStringTaskAsync(GITHUB_REPO);
|
||||
Status = "Parsing Response";
|
||||
return JsonConvert.DeserializeObject<Release[]>(data);
|
||||
}
|
||||
|
||||
|
||||
class Release
|
||||
{
|
||||
[JsonProperty("tag_name")]
|
||||
public string Tag { get; set; }
|
||||
|
||||
[JsonProperty("assets")]
|
||||
public Asset[] Assets { get; set; }
|
||||
}
|
||||
|
||||
class Asset
|
||||
{
|
||||
[JsonProperty("browser_download_url")]
|
||||
public Uri BrowserDownloadUrl { get; set; }
|
||||
|
||||
[JsonProperty("name")]
|
||||
public string Name { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
BIN
Wabbajack.Launcher/Resources/Icons/wabbajack.ico
Normal file
BIN
Wabbajack.Launcher/Resources/Icons/wabbajack.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 139 KiB |
BIN
Wabbajack.Launcher/Wabba_Mouth_Small.png
Normal file
BIN
Wabbajack.Launcher/Wabba_Mouth_Small.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 58 KiB |
27
Wabbajack.Launcher/Wabbajack.Launcher.csproj
Normal file
27
Wabbajack.Launcher/Wabbajack.Launcher.csproj
Normal file
@ -0,0 +1,27 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||
<UseWPF>true</UseWPF>
|
||||
|
||||
<PublishSingleFile>true</PublishSingleFile>
|
||||
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
|
||||
<AssemblyName>Wabbajack</AssemblyName>
|
||||
<RootNamespace>Wabbajack</RootNamespace>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<ApplicationIcon>Resources\Icons\wabbajack.ico</ApplicationIcon>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Remove="Wabba_Mouth_Small.png" />
|
||||
<Resource Include="Wabba_Mouth_Small.png" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Newtonsoft.Json" Version="9.0.1" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
@ -22,7 +22,7 @@ namespace Wabbajack.Lib
|
||||
public bool ReadmeIsWebsite;
|
||||
public string WabbajackVersion;
|
||||
|
||||
protected static string _vfsCacheName = "vfs_compile_cache.bin";
|
||||
protected static string _vfsCacheName => Path.Combine(Consts.LocalAppDataPath, "vfs_compile_cache.bin");
|
||||
/// <summary>
|
||||
/// A stream of tuples of ("Update Title", 0.25) which represent the name of the current task
|
||||
/// and the current progress.
|
||||
|
@ -88,7 +88,7 @@ namespace Wabbajack.Lib.LibCefHelpers
|
||||
if (Inited) return;
|
||||
Inited = true;
|
||||
CefSettings settings = new CefSettings();
|
||||
settings.CachePath = Path.Combine(Directory.GetCurrentDirectory() + @"\CEF");
|
||||
settings.CachePath = Path.Combine(Consts.LocalAppDataPath + @"\CEF");
|
||||
Cef.Initialize(settings);
|
||||
}
|
||||
|
||||
|
@ -38,6 +38,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Wabbajack.Test", "Wabbajack
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Wabbajack.CLI", "Wabbajack.CLI\Wabbajack.CLI.csproj", "{685D8BB1-D178-4D2C-85C7-C54A36FB7454}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Wabbajack.Launcher", "Wabbajack.Launcher\Wabbajack.Launcher.csproj", "{D6856DBF-C959-4867-A8A8-343DA2D2715E}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
@ -118,6 +120,14 @@ Global
|
||||
{685D8BB1-D178-4D2C-85C7-C54A36FB7454}.Release|Any CPU.ActiveCfg = Release|x64
|
||||
{685D8BB1-D178-4D2C-85C7-C54A36FB7454}.Release|x64.ActiveCfg = Release|x64
|
||||
{685D8BB1-D178-4D2C-85C7-C54A36FB7454}.Release|x64.Build.0 = Release|x64
|
||||
{D6856DBF-C959-4867-A8A8-343DA2D2715E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{D6856DBF-C959-4867-A8A8-343DA2D2715E}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{D6856DBF-C959-4867-A8A8-343DA2D2715E}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{D6856DBF-C959-4867-A8A8-343DA2D2715E}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{D6856DBF-C959-4867-A8A8-343DA2D2715E}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{D6856DBF-C959-4867-A8A8-343DA2D2715E}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{D6856DBF-C959-4867-A8A8-343DA2D2715E}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{D6856DBF-C959-4867-A8A8-343DA2D2715E}.Release|x64.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
2
Wabbajack.sln.DotSettings
Normal file
2
Wabbajack.sln.DotSettings
Normal file
@ -0,0 +1,2 @@
|
||||
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
|
||||
<s:Boolean x:Key="/Default/CodeInspection/CodeAnnotations/NamespacesWithAnnotations/=Wabbajack_002ELauncher_002EAnnotations/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
|
@ -14,9 +14,9 @@
|
||||
<StartupObject></StartupObject>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<ApplicationIcon>Resources\Icons\wabbajack.ico</ApplicationIcon>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<ApplicationIcon>Resources\Icons\wabbajack.ico</ApplicationIcon>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
|
Loading…
Reference in New Issue
Block a user