initial fixes for settings instantiation issue

This commit is contained in:
2024-06-17 20:52:31 -05:00
parent 371cfc41c8
commit b12f3b07c4
2 changed files with 14 additions and 9 deletions

View File

@@ -12,10 +12,11 @@ public class Settings
{
public Settings()
{}
{
WebhookSettingsList = new[] { new WebhookSettings() }.ToList();
}
public Settings(
WebhookSettings webhookSettings,
public Settings(
List<WebhookSettings> webhookSettingsList,
bool handBrakeAndAirTagModifiers
)
@@ -29,7 +30,11 @@ public class Settings
internal void AddAnotherRow()
{
//if (!string.IsNullOrEmpty(WebhookSettingsList.Last().WebhookUrl)) WebhookSettingsList.Add(new());
if (!string.IsNullOrEmpty(WebhookSettingsList.Last().WebhookUrl))
{
WebhookSettingsList.Add(new());
Log.Information($"Adding another {nameof(WebhookSettings)} list entry, last one was filled in");
}
}
}

View File

@@ -1,16 +1,11 @@
using GalaSoft.MvvmLight.Messaging;
using Game.Messages;
using Game.State;
using HarmonyLib;
using Newtonsoft.Json.Linq;
using Railloader;
using Serilog;
using Serilog.Debugging;
using System.Linq;
using System.Net.Http;
using TweaksAndThings.Commands;
using UI.Builder;
using UI.CarInspector;
namespace TweaksAndThings
{
@@ -48,6 +43,11 @@ namespace TweaksAndThings
//moddingContext.RegisterConsoleCommand(new EchoCommand());
settings = moddingContext.LoadSettingsData<Settings>(self.Id);
if (settings.WebhookSettingsList?.Any() ?? false)
{
settings.WebhookSettingsList = new[] { new WebhookSettings() }.ToList();
this.moddingContext.SaveSettingsData(this.modDefinition.Id, settings ?? new());
}
}
public override void OnEnable()