diff options
Diffstat (limited to 'src')
4 files changed, 18 insertions, 10 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() 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 <https://www.gnu.org/licenses/>. --> -<Root xmlns="http://notenoughupdates.org/moulconfig"> +<Root xmlns="http://notenoughupdates.org/moulconfig" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://notenoughupdates.org/moulconfig https://raw.githubusercontent.com/NotEnoughUpdates/MoulConfig/master/MoulConfig.xsd"> <Gui> <Column> - + <Meta afterClose="@afterClose"/> <Row> <Button onClick="@close"> <Text text="←"/> diff --git a/src/main/resources/assets/notenoughupdates/gui/customtodos/overview.xml b/src/main/resources/assets/notenoughupdates/gui/customtodos/overview.xml index b1cb1521..1aa09f2a 100644 --- a/src/main/resources/assets/notenoughupdates/gui/customtodos/overview.xml +++ b/src/main/resources/assets/notenoughupdates/gui/customtodos/overview.xml @@ -21,6 +21,7 @@ <Root xmlns="http://notenoughupdates.org/moulconfig"> <Gui> <Column> + <Meta afterClose="@afterClose"/> <Center> <Scale scale="2"> <Text text="Custom TODOs"/> |