mirror of
https://github.com/wabbajack-tools/wabbajack.git
synced 2024-08-30 18:42:17 +00:00
Merge pull request #129 from wabbajack-tools/pr-128
Wabbajack File association
This commit is contained in:
commit
3c12ce4680
@ -4,6 +4,8 @@
|
||||
* Nothing yet...
|
||||
* Slideshow more responsive on pressing next
|
||||
* Slideshow timer resets when next is pressed
|
||||
* Changed modlist extension to `.wabbajack`
|
||||
* You can now open modlists directly (after initial launch)
|
||||
|
||||
#### Version 1.0 alpha 2 - 10/15/2019
|
||||
* Fix installer running in wrong mode
|
||||
|
@ -9,7 +9,6 @@ namespace Wabbajack.Common
|
||||
{
|
||||
public static bool TestMode { get; set; } = false;
|
||||
|
||||
public static string ModlistExtension = ".modlist_v2";
|
||||
public static string GameFolderFilesDir = "Game Folder Files";
|
||||
public static string LOOTFolderFilesDir = "LOOT Config Files";
|
||||
public static string BSACreationDir = "TEMP_BSA_FILES";
|
||||
|
73
Wabbajack.Common/ExtensionManager.cs
Normal file
73
Wabbajack.Common/ExtensionManager.cs
Normal file
@ -0,0 +1,73 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.InteropServices;
|
||||
using Microsoft.Win32;
|
||||
|
||||
namespace Wabbajack.Common
|
||||
{
|
||||
public class ExtensionManager
|
||||
{
|
||||
[DllImport("Shell32.dll", CharSet = CharSet.Auto, SetLastError = true)]
|
||||
public static extern void SHChangeNotify(uint wEventId, uint uFlags, IntPtr dwItem1, IntPtr dwItem2);
|
||||
|
||||
public static string Extension = ".wabbajack";
|
||||
|
||||
private static readonly string ProgIDPath = "Software\\Classes\\Wabbajack";
|
||||
private static readonly string ExtPath = $"Software\\Classes\\{Extension}";
|
||||
|
||||
private static readonly Dictionary<string, string> ProgIDList = new Dictionary<string, string>
|
||||
{
|
||||
{"", "Wabbajack"},
|
||||
{"FriendlyTypeName", "Wabbajack"},
|
||||
{"shell\\open\\command", "\"{appPath}\" -i \"%1\""},
|
||||
};
|
||||
|
||||
private static readonly Dictionary<string, string> ExtList = new Dictionary<string, string>
|
||||
{
|
||||
{"", "Wabbajack"},
|
||||
{"PerceivedType", "Compressed"}
|
||||
};
|
||||
|
||||
public static bool NeedsUpdating(string appPath)
|
||||
{
|
||||
var progIDKey = Registry.CurrentUser.OpenSubKey(ProgIDPath);
|
||||
var tempKey = progIDKey?.OpenSubKey("shell\\open\\command");
|
||||
if (progIDKey == null || tempKey == null) return true;
|
||||
return tempKey.GetValue("").ToString().Equals($"\"{appPath}\" -i \"%1\"");
|
||||
}
|
||||
|
||||
public static bool IsAssociated(string appPath)
|
||||
{
|
||||
var progIDKey = Registry.CurrentUser.OpenSubKey(ProgIDPath);
|
||||
var extKey = Registry.CurrentUser.OpenSubKey(ExtPath);
|
||||
return (progIDKey != null && extKey != null);
|
||||
}
|
||||
|
||||
public static void Associate(string appPath)
|
||||
{
|
||||
var progIDKey = Registry.CurrentUser.CreateSubKey(ProgIDPath, RegistryKeyPermissionCheck.ReadWriteSubTree);
|
||||
foreach (KeyValuePair<string, string> entry in ProgIDList)
|
||||
{
|
||||
if (entry.Key.Contains("\\"))
|
||||
{
|
||||
var tempKey = progIDKey.CreateSubKey(entry.Key);
|
||||
tempKey.SetValue("", entry.Value.Replace("{appPath}", appPath));
|
||||
}
|
||||
else
|
||||
{
|
||||
progIDKey?.SetValue(entry.Key, entry.Value.Replace("{appPath}", appPath));
|
||||
}
|
||||
}
|
||||
|
||||
var extKey = Registry.CurrentUser.CreateSubKey(ExtPath, RegistryKeyPermissionCheck.ReadWriteSubTree);
|
||||
foreach (KeyValuePair<string, string> entry in ExtList)
|
||||
{
|
||||
extKey?.SetValue(entry.Key, entry.Value);
|
||||
}
|
||||
|
||||
progIDKey?.Close();
|
||||
extKey?.Close();
|
||||
SHChangeNotify(0x000000, 0x0000, IntPtr.Zero, IntPtr.Zero);
|
||||
}
|
||||
}
|
||||
}
|
@ -108,6 +108,7 @@
|
||||
<Compile Include="ChildProcessTracker.cs" />
|
||||
<Compile Include="Consts.cs" />
|
||||
<Compile Include="DynamicIniData.cs" />
|
||||
<Compile Include="ExtensionManager.cs" />
|
||||
<Compile Include="FileExtractor.cs" />
|
||||
<Compile Include="GameMetaData.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
|
@ -67,7 +67,7 @@ namespace Wabbajack.Lib
|
||||
public string MO2ProfileDir => Path.Combine(MO2Folder, "profiles", MO2Profile);
|
||||
|
||||
public string ModListOutputFolder => "output_folder";
|
||||
public string ModListOutputFile => MO2Profile + Consts.ModlistExtension;
|
||||
public string ModListOutputFile => MO2Profile + ExtensionManager.Extension;
|
||||
|
||||
public List<Directive> InstallDirectives { get; private set; }
|
||||
internal UserStatus User { get; private set; }
|
||||
|
@ -2,7 +2,6 @@
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:local="clr-namespace:Wabbajack"
|
||||
StartupUri="UI\ModeSelectionWindow.xaml"
|
||||
ShutdownMode="OnExplicitShutdown">
|
||||
<Application.Resources>
|
||||
<ResourceDictionary>
|
||||
|
@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Reflection;
|
||||
using System.Windows;
|
||||
using Wabbajack.Common;
|
||||
using Wabbajack.Lib.Updater;
|
||||
@ -29,6 +30,18 @@ namespace Wabbajack
|
||||
Environment.Exit(1);
|
||||
}*/
|
||||
|
||||
var appPath = Assembly.GetExecutingAssembly().Location;
|
||||
if (!ExtensionManager.IsAssociated(appPath) || ExtensionManager.NeedsUpdating(appPath))
|
||||
{
|
||||
ExtensionManager.Associate(appPath);
|
||||
}
|
||||
|
||||
string[] args = Environment.GetCommandLineArgs();
|
||||
StartupUri = new Uri("UI/ModeSelectionWindow.xaml", UriKind.Relative);
|
||||
if (args.Length != 3) return;
|
||||
if (!args[1].Contains("-i")) return;
|
||||
// modlists gets loaded using a shell command
|
||||
StartupUri = new Uri("UI/MainWindow.xaml", UriKind.Relative);
|
||||
}
|
||||
|
||||
private void SetupHandlers()
|
||||
|
@ -17,10 +17,19 @@ namespace Wabbajack
|
||||
{
|
||||
private AppState _state;
|
||||
|
||||
public MainWindow()
|
||||
{
|
||||
string[] args = Environment.GetCommandLineArgs();
|
||||
|
||||
if (args.Length != 3) return;
|
||||
var modlistPath = args[2];
|
||||
var mainWindow = new MainWindow(RunMode.Install, modlistPath);
|
||||
mainWindow.Show();
|
||||
Close();
|
||||
}
|
||||
|
||||
public MainWindow(RunMode mode, string source)
|
||||
{
|
||||
var args = Environment.GetCommandLineArgs();
|
||||
|
||||
InitializeComponent();
|
||||
|
||||
var context = new AppState(mode);
|
||||
|
@ -90,7 +90,7 @@ namespace Wabbajack
|
||||
private void InstallFromList_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
OpenMainWindow(RunMode.Install,
|
||||
UIUtils.OpenFileDialog($"*{Consts.ModlistExtension}|*{Consts.ModlistExtension}"));
|
||||
UIUtils.OpenFileDialog($"*{ExtensionManager.Extension}|*{ExtensionManager.Extension}"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -52,7 +52,7 @@ namespace Wabbajack.UI
|
||||
if (!Directory.Exists(Consts.ModListDownloadFolder))
|
||||
Directory.CreateDirectory(Consts.ModListDownloadFolder);
|
||||
|
||||
string dest = Path.Combine(Consts.ModListDownloadFolder, SelectedModList.Links.MachineURL + Consts.ModlistExtension);
|
||||
string dest = Path.Combine(Consts.ModListDownloadFolder, SelectedModList.Links.MachineURL + ExtensionManager.Extension);
|
||||
|
||||
var window = new DownloadWindow(SelectedModList.Links.Download, SelectedModList.Title, dest);
|
||||
window.ShowDialog();
|
||||
|
@ -17,6 +17,7 @@
|
||||
<Deterministic>true</Deterministic>
|
||||
<NuGetPackageImportStamp>
|
||||
</NuGetPackageImportStamp>
|
||||
<IsWebBootstrapper>false</IsWebBootstrapper>
|
||||
<PublishUrl>publish\</PublishUrl>
|
||||
<Install>true</Install>
|
||||
<InstallFrom>Disk</InstallFrom>
|
||||
@ -29,7 +30,6 @@
|
||||
<MapFileExtensions>true</MapFileExtensions>
|
||||
<ApplicationRevision>0</ApplicationRevision>
|
||||
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
|
||||
<IsWebBootstrapper>false</IsWebBootstrapper>
|
||||
<UseApplicationTrust>false</UseApplicationTrust>
|
||||
<BootstrapperEnabled>true</BootstrapperEnabled>
|
||||
</PropertyGroup>
|
||||
|
Loading…
Reference in New Issue
Block a user