From f61507f7bd948d3fde697a3c8e0561f88c452a5a Mon Sep 17 00:00:00 2001 From: Linnea Gräf Date: Sat, 25 Nov 2023 14:13:33 +0100 Subject: Fix doubletyping in custom todos on bad operating systems (#937) --- build.gradle.kts | 2 ++ gradle/MoulConfig.xsd | 1 - gradle/libs.versions.toml | 2 +- .../miscgui/customtodos/CustomTodoEditor.kt | 16 ++++++++-------- .../miscgui/customtodos/CustomTodoList.kt | 5 +++++ .../assets/notenoughupdates/gui/customtodos/edit.xml | 6 ++++-- .../assets/notenoughupdates/gui/customtodos/overview.xml | 1 + 7 files changed, 21 insertions(+), 12 deletions(-) delete mode 100644 gradle/MoulConfig.xsd diff --git a/build.gradle.kts b/build.gradle.kts index 96867283..3ed5d4e4 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -260,6 +260,8 @@ tasks.shadowJar { dependsOn(kotlinDependencyCollectionJar) fun relocate(name: String) = relocate(name, "io.github.moulberry.notenoughupdates.deps.$name") relocate("com.mojang.brigadier") + relocate("io.github.moulberry.moulconfig") + mergeServiceFiles() } tasks.assemble.get().dependsOn(remapJar) diff --git a/gradle/MoulConfig.xsd b/gradle/MoulConfig.xsd deleted file mode 100644 index 6826f5fc..00000000 --- a/gradle/MoulConfig.xsd +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index f66463d6..fb8236d4 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,5 +1,5 @@ [versions] -moulconfig = "2.2.0" +moulconfig = "2.4.3" [libraries] moulconfig = { module = "org.notenoughupdates.moulconfig:legacy", version.ref = "moulconfig" } 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() diff --git a/src/main/resources/assets/notenoughupdates/gui/customtodos/edit.xml b/src/main/resources/assets/notenoughupdates/gui/customtodos/edit.xml index 9ccf71c2..83457a60 100644 --- a/src/main/resources/assets/notenoughupdates/gui/customtodos/edit.xml +++ b/src/main/resources/assets/notenoughupdates/gui/customtodos/edit.xml @@ -18,10 +18,12 @@ ~ along with NotEnoughUpdates. If not, see . --> - + - +