mirror of
https://github.com/ZuneDev/ZuneModdingHelper.git
synced 2026-07-27 13:12:21 -07:00
Remove built-in Init method
This commit is contained in:
@@ -1,12 +1,14 @@
|
||||
using OwlCore.AbstractUI.Models;
|
||||
using OwlCore.ComponentModel;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using ZuneModCore.Win32;
|
||||
|
||||
namespace ZuneModCore.Mods;
|
||||
|
||||
public class FeaturesOverrideMod : Mod
|
||||
public class FeaturesOverrideMod : Mod, IAsyncInit
|
||||
{
|
||||
private const string ZUNE_FEATURESOVERRIDE_REGKEY = RegEdit.ZUNE_REG_PATH + "FeaturesOverride";
|
||||
|
||||
@@ -57,8 +59,12 @@ public class FeaturesOverrideMod : Mod
|
||||
|
||||
public override IReadOnlyList<Type>? DependentMods => null;
|
||||
|
||||
public override Task Init()
|
||||
public bool IsInitialized { get; private set; }
|
||||
|
||||
public Task InitAsync(CancellationToken token = default)
|
||||
{
|
||||
if (IsInitialized) return Task.CompletedTask;
|
||||
|
||||
foreach (AbstractUIElement uiElem in OptionsUI!)
|
||||
{
|
||||
if (uiElem is AbstractBoolean boolElem)
|
||||
@@ -68,6 +74,7 @@ public class FeaturesOverrideMod : Mod
|
||||
}
|
||||
}
|
||||
|
||||
IsInitialized = true;
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using OwlCore.AbstractUI.Models;
|
||||
using OwlCore.ComponentModel;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
@@ -9,7 +10,7 @@ using static ZuneModCore.Mods.FeaturesOverrideMod;
|
||||
|
||||
namespace ZuneModCore.Mods;
|
||||
|
||||
public class WebservicesMod : Mod
|
||||
public class WebservicesMod : Mod, IAsyncInit
|
||||
{
|
||||
private const int ZUNESERVICES_ENDPOINTS_BLOCK_OFFSET = 0x14D60;
|
||||
private const int ZUNESERVICES_ENDPOINTS_BLOCK_LENGTH = 0x884;
|
||||
@@ -86,8 +87,13 @@ public class WebservicesMod : Mod
|
||||
|
||||
public override IReadOnlyList<Type>? DependentMods => null;
|
||||
|
||||
public override Task Init()
|
||||
public bool IsInitialized { get; private set; }
|
||||
|
||||
public Task InitAsync(CancellationToken token = default)
|
||||
{
|
||||
if (IsInitialized)
|
||||
return Task.CompletedTask;
|
||||
|
||||
_client = new()
|
||||
{
|
||||
Timeout = TimeSpan.FromSeconds(3)
|
||||
@@ -97,6 +103,7 @@ public class WebservicesMod : Mod
|
||||
newHostBox.ValueChanged += OnHostChanged;
|
||||
newHostBox.Value = "zunes.me";
|
||||
|
||||
IsInitialized = true;
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user