diff options
author | Linnea Gräf <roman.graef@gmail.com> | 2023-11-25 14:13:33 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-26 00:13:33 +1100 |
commit | f61507f7bd948d3fde697a3c8e0561f88c452a5a (patch) | |
tree | 214ba23edd9a9af1ac72492b387e55a5c696c714 /src/main/kotlin | |
parent | c202b3d7a7d5fdcaac6ed466d16b04928a5d6bdf (diff) | |
download | NotEnoughUpdates-f61507f7bd948d3fde697a3c8e0561f88c452a5a.tar.gz NotEnoughUpdates-f61507f7bd948d3fde697a3c8e0561f88c452a5a.tar.bz2 NotEnoughUpdates-f61507f7bd948d3fde697a3c8e0561f88c452a5a.zip |
Fix doubletyping in custom todos on bad operating systems (#937)
Diffstat (limited to 'src/main/kotlin')
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() |