mirror of
https://github.com/ZuneDev/ZuneModdingHelper.git
synced 2026-07-27 13:12:21 -07:00
Remove ZuneInstallDir property from base Mod
This commit is contained in:
@@ -8,12 +8,8 @@ namespace ZuneModCore;
|
|||||||
|
|
||||||
public abstract class Mod(ModMetadata metadata)
|
public abstract class Mod(ModMetadata metadata)
|
||||||
{
|
{
|
||||||
public static string DefaultZuneInstallDir { get; } = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles), "Zune");
|
|
||||||
|
|
||||||
public ModMetadata Metadata { get; } = metadata;
|
public ModMetadata Metadata { get; } = metadata;
|
||||||
|
|
||||||
public string ZuneInstallDir { get; set; } = DefaultZuneInstallDir;
|
|
||||||
|
|
||||||
public virtual AbstractUICollection? GetDefaultOptionsUI() => null;
|
public virtual AbstractUICollection? GetDefaultOptionsUI() => null;
|
||||||
|
|
||||||
public abstract Task<string?> Apply();
|
public abstract Task<string?> Apply();
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ using System.Diagnostics;
|
|||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Vestris.ResourceLib;
|
using Vestris.ResourceLib;
|
||||||
|
using ZuneModCore.Services;
|
||||||
using ZuneModCore.Win32;
|
using ZuneModCore.Win32;
|
||||||
|
|
||||||
namespace ZuneModCore.Mods;
|
namespace ZuneModCore.Mods;
|
||||||
@@ -19,8 +20,10 @@ public class BackgroundImageModFactory : DIModFactoryBase<BackgroundImageMod>
|
|||||||
Description, Author, new(1, 0));
|
Description, Author, new(1, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
public class BackgroundImageMod(ModMetadata metadata) : Mod(metadata)
|
public class BackgroundImageMod(ModMetadata metadata, IModCoreConfig modConfig) : Mod(metadata)
|
||||||
{
|
{
|
||||||
|
public string ZuneInstallDir => modConfig.ZuneInstallDir;
|
||||||
|
|
||||||
public override AbstractUICollection? GetDefaultOptionsUI()
|
public override AbstractUICollection? GetDefaultOptionsUI()
|
||||||
{
|
{
|
||||||
AbstractUICollection optionsUi = new(nameof(BackgroundImageMod))
|
AbstractUICollection optionsUi = new(nameof(BackgroundImageMod))
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ using System.Collections.Generic;
|
|||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using ZuneModCore.Services;
|
||||||
|
|
||||||
namespace ZuneModCore.Mods;
|
namespace ZuneModCore.Mods;
|
||||||
|
|
||||||
@@ -17,8 +18,10 @@ public class VideoSyncModFactory : DIModFactoryBase<VideoSyncMod>
|
|||||||
Description, Author, new(2, 0));
|
Description, Author, new(2, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
public class VideoSyncMod(ModMetadata metadata) : Mod(metadata)
|
public class VideoSyncMod(ModMetadata metadata, IModCoreConfig modConfig) : Mod(metadata)
|
||||||
{
|
{
|
||||||
|
public string ZuneInstallDir => modConfig.ZuneInstallDir;
|
||||||
|
|
||||||
private const int ZUNEENCENG_WMVCORA_OFFSET = 0x161E;
|
private const int ZUNEENCENG_WMVCORA_OFFSET = 0x161E;
|
||||||
|
|
||||||
public override async Task<string?> Apply()
|
public override async Task<string?> Apply()
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ public class WebservicesModFactory : DIModFactoryBase<WebservicesMod>
|
|||||||
Description, Author, new(1, 1));
|
Description, Author, new(1, 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
public partial class WebservicesMod(ModMetadata metadata) : Mod(metadata), IAsyncInit
|
public partial class WebservicesMod(ModMetadata metadata, IModCoreConfig modConfig) : Mod(metadata), IAsyncInit
|
||||||
{
|
{
|
||||||
private const int ZUNESERVICES_ENDPOINTS_BLOCK_OFFSET = 0x14D60;
|
private const int ZUNESERVICES_ENDPOINTS_BLOCK_OFFSET = 0x14D60;
|
||||||
private const int ZUNESERVICES_ENDPOINTS_BLOCK_LENGTH = 0x884;
|
private const int ZUNESERVICES_ENDPOINTS_BLOCK_LENGTH = 0x884;
|
||||||
@@ -68,6 +68,8 @@ public partial class WebservicesMod(ModMetadata metadata) : Mod(metadata), IAsyn
|
|||||||
private CancellationTokenSource _cts = new();
|
private CancellationTokenSource _cts = new();
|
||||||
private string _methodFile;
|
private string _methodFile;
|
||||||
|
|
||||||
|
public string ZuneInstallDir => modConfig.ZuneInstallDir;
|
||||||
|
|
||||||
public override AbstractUICollection? GetDefaultOptionsUI()
|
public override AbstractUICollection? GetDefaultOptionsUI()
|
||||||
{
|
{
|
||||||
AbstractUICollection optionsUi = new(nameof(FeaturesOverrideMod))
|
AbstractUICollection optionsUi = new(nameof(FeaturesOverrideMod))
|
||||||
|
|||||||
@@ -21,12 +21,10 @@ namespace ZuneModdingHelper.Pages
|
|||||||
{
|
{
|
||||||
private const string MOD_MANAGER_TITLE = "MOD MANAGER";
|
private const string MOD_MANAGER_TITLE = "MOD MANAGER";
|
||||||
|
|
||||||
private readonly IModCoreConfig _modConfig;
|
|
||||||
private readonly Settings _settings;
|
private readonly Settings _settings;
|
||||||
|
|
||||||
public ModsPage(IModCoreConfig modConfig, Settings settings)
|
public ModsPage(Settings settings)
|
||||||
{
|
{
|
||||||
_modConfig = modConfig;
|
|
||||||
_settings = settings;
|
_settings = settings;
|
||||||
|
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
@@ -50,10 +48,7 @@ namespace ZuneModdingHelper.Pages
|
|||||||
WeakReferenceMessenger.Default.Send(new ShowDialogMessage(progDialog));
|
WeakReferenceMessenger.Default.Send(new ShowDialogMessage(progDialog));
|
||||||
|
|
||||||
// Stage 0: Initialize mod
|
// Stage 0: Initialize mod
|
||||||
var mod = modFactory.Create(Ioc.Default);
|
var mod = await CreateModInstance(modFactory);
|
||||||
mod.ZuneInstallDir = _modConfig.ZuneInstallDir;
|
|
||||||
if (mod is IAsyncInit initMod)
|
|
||||||
await initMod.InitAsync();
|
|
||||||
++progDialog.Progress;
|
++progDialog.Progress;
|
||||||
|
|
||||||
// Stage 1: Display AbstractUI for options
|
// Stage 1: Display AbstractUI for options
|
||||||
@@ -115,10 +110,7 @@ namespace ZuneModdingHelper.Pages
|
|||||||
};
|
};
|
||||||
WeakReferenceMessenger.Default.Send(new ShowDialogMessage(progDialog));
|
WeakReferenceMessenger.Default.Send(new ShowDialogMessage(progDialog));
|
||||||
|
|
||||||
var mod = modFactory.Create(Ioc.Default);
|
var mod = await CreateModInstance(modFactory);
|
||||||
mod.ZuneInstallDir = _modConfig.ZuneInstallDir;
|
|
||||||
if (mod is IAsyncInit initMod)
|
|
||||||
await initMod.InitAsync();
|
|
||||||
++progDialog.Progress;
|
++progDialog.Progress;
|
||||||
|
|
||||||
// TODO: Implement AbstractUI display for reset options
|
// TODO: Implement AbstractUI display for reset options
|
||||||
@@ -161,6 +153,16 @@ namespace ZuneModdingHelper.Pages
|
|||||||
return modFactory is not null;
|
return modFactory is not null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static async Task<Mod> CreateModInstance(IModFactory<Mod> modFactory)
|
||||||
|
{
|
||||||
|
var mod = modFactory.Create(Ioc.Default);
|
||||||
|
|
||||||
|
if (mod is IAsyncInit initMod)
|
||||||
|
await initMod.InitAsync();
|
||||||
|
|
||||||
|
return mod;
|
||||||
|
}
|
||||||
|
|
||||||
private async Task ShowDonationRequestDialog(bool _)
|
private async Task ShowDonationRequestDialog(bool _)
|
||||||
{
|
{
|
||||||
// Close success dialog
|
// Close success dialog
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ using System.IO;
|
|||||||
using System;
|
using System;
|
||||||
using ZuneModCore;
|
using ZuneModCore;
|
||||||
using ZuneModCore.Services;
|
using ZuneModCore.Services;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace ZuneModdingHelper.Services;
|
namespace ZuneModdingHelper.Services;
|
||||||
|
|
||||||
@@ -22,7 +23,7 @@ public class Settings(IModifiableFolder folder) : SettingsBase(folder, SystemTex
|
|||||||
|
|
||||||
public string ZuneInstallDir
|
public string ZuneInstallDir
|
||||||
{
|
{
|
||||||
get => GetSetting(() => Mod.DefaultZuneInstallDir);
|
get => GetSetting(GetDefaultZuneInstallDir);
|
||||||
set => SetSetting(value);
|
set => SetSetting(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -37,6 +38,22 @@ public class Settings(IModifiableFolder folder) : SettingsBase(folder, SystemTex
|
|||||||
get => GetSetting(() => DonationRequestInterval.OneMonth);
|
get => GetSetting(() => DonationRequestInterval.OneMonth);
|
||||||
set => SetSetting(value);
|
set => SetSetting(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static string GetDefaultZuneInstallDir()
|
||||||
|
{
|
||||||
|
// Check common install locations for Zune
|
||||||
|
string[] commonPaths = [
|
||||||
|
Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles), "Zune"),
|
||||||
|
@"C:\Program Files\Zune",
|
||||||
|
@"C:\Program Files (x86)\Zune",
|
||||||
|
];
|
||||||
|
|
||||||
|
foreach (var path in commonPaths)
|
||||||
|
if (Directory.Exists(path))
|
||||||
|
return path;
|
||||||
|
|
||||||
|
return commonPaths[0];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum DonationRequestInterval
|
public enum DonationRequestInterval
|
||||||
|
|||||||
Reference in New Issue
Block a user