diff options
author | Linnea Gräf <nea@nea.moe> | 2023-11-18 10:01:22 +0100 |
---|---|---|
committer | Linnea Gräf <nea@nea.moe> | 2023-11-18 10:01:22 +0100 |
commit | 9b5de0e3e459bf521acf98a2608ee27c764b4414 (patch) | |
tree | af3c4dfcac882b69bfb2d2b3028ca02d1863bd45 /src/main/kotlin/io | |
parent | bc501f4eae427ce4ad07b6d78ac9f1f7764ccdb6 (diff) | |
download | NotEnoughUpdates-fixdoubletyping.tar.gz NotEnoughUpdates-fixdoubletyping.tar.bz2 NotEnoughUpdates-fixdoubletyping.zip |
Fix doubletyping in custom todos on bad operating systemsfixdoubletyping
Diffstat (limited to 'src/main/kotlin/io')
2 files changed, 13 insertions, 8 deletions
diff --git a/src/main/kotlin/io/github/moulberry/notenoughupdates/miscgui/customtodos/CustomTodoEditor.kt b/src/main/kotlin/io/github/moulberry/notenoughupdates/miscgui/customtodos/CustomTodoEditor.kt index 1c5c16ed..b0dab0f6 100644 --- a/src/main/kotlin/io/github/moulberry/notenoughupdates/miscgui/customtodos/CustomTodoEditor.kt +++ b/src/main/kotlin/io/github/moulberry/notenoughupdates/miscgui/customtodos/CustomTodoEditor.kt @@ -21,6 +21,7 @@ package io.github.moulberry.notenoughupdates.miscgui.customtodos import io.github.moulberry.moulconfig.common.IItemStack import io.github.moulberry.moulconfig.forge.ForgeItemStack +import io.github.moulberry.moulconfig.gui.CloseEventListener import io.github.moulberry.moulconfig.internal.ClipboardUtils import io.github.moulberry.moulconfig.observer.ObservableList import io.github.moulberry.moulconfig.xml.Bind @@ -59,10 +60,9 @@ class CustomTodoEditor( var target = from.triggerTarget var matchMode = from.triggerMatcher - var lastCustomTodo: CustomTodo? = null fun into(): CustomTodo { - val nextCustomTodo = CustomTodo( + return CustomTodo( label, timer.toIntOrNull() ?: 0, trigger, @@ -72,11 +72,6 @@ class CustomTodoEditor( from.readyAt, from.enabled.toMutableMap().also { it[SBInfo.getInstance().currentProfile ?: return@also] = enabled } ) - if (nextCustomTodo != lastCustomTodo) { - lastCustomTodo = nextCustomTodo - CustomTodoList(todos, xmlUniverse).save() - } - return nextCustomTodo } @Bind @@ -236,7 +231,12 @@ class CustomTodoEditor( @Bind fun getTitle(): String { - return "Editing ${into().label}" + return "Editing $label" + } + + @Bind + fun afterClose() { + CustomTodoList(todos, xmlUniverse).save() } @Bind diff --git a/src/main/kotlin/io/github/moulberry/notenoughupdates/miscgui/customtodos/CustomTodoList.kt b/src/main/kotlin/io/github/moulberry/notenoughupdates/miscgui/customtodos/CustomTodoList.kt index 1b278990..d351b475 100644 --- a/src/main/kotlin/io/github/moulberry/notenoughupdates/miscgui/customtodos/CustomTodoList.kt +++ b/src/main/kotlin/io/github/moulberry/notenoughupdates/miscgui/customtodos/CustomTodoList.kt @@ -74,6 +74,11 @@ class CustomTodoList( save() } + @Bind + fun afterClose() { + save() + } + fun save() { NotEnoughUpdates.INSTANCE.config.hidden.customTodos = todos.map { it.into() }.toMutableList() NotEnoughUpdates.INSTANCE.saveConfig() |