From c0cc18b0a034271d024a5d7219907f44775c5110 Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Thu, 27 Jun 2024 20:54:03 +0200 Subject: [PATCH] only save the options to disk when they get removed from the ui --- ExampleMod.cs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/ExampleMod.cs b/ExampleMod.cs index f0efe25..89efec4 100644 --- a/ExampleMod.cs +++ b/ExampleMod.cs @@ -152,11 +152,9 @@ public class ExampleMod : Mod { group.AddChild(new Paragraph(Anchor.AutoLeft, 1, _ => $"{Localization.Get(LnCategory.Ui, "ExampleMod.DarkShirtSpeedOption")}: {ExampleMod.Options.DarkShirtSpeedIncrease}")); group.AddChild(new Slider(Anchor.AutoLeft, new Vector2(1, 10), 5, 5) { CurrentValue = ExampleMod.Options.DarkShirtSpeedIncrease, - OnValueChanged = (_, v) => { - ExampleMod.Options.DarkShirtSpeedIncrease = v; - info.SaveOptions(ExampleMod.Options); - } + OnValueChanged = (_, v) => ExampleMod.Options.DarkShirtSpeedIncrease = v }); + group.OnRemovedFromUi += _ => info.SaveOptions(ExampleMod.Options); } }