aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLinnea Gräf <nea@nea.moe>2023-11-18 10:01:22 +0100
committerLinnea Gräf <nea@nea.moe>2023-11-18 10:01:22 +0100
commit9b5de0e3e459bf521acf98a2608ee27c764b4414 (patch)
treeaf3c4dfcac882b69bfb2d2b3028ca02d1863bd45
parentbc501f4eae427ce4ad07b6d78ac9f1f7764ccdb6 (diff)
downloadNotEnoughUpdates-9b5de0e3e459bf521acf98a2608ee27c764b4414.tar.gz
NotEnoughUpdates-9b5de0e3e459bf521acf98a2608ee27c764b4414.tar.bz2
NotEnoughUpdates-9b5de0e3e459bf521acf98a2608ee27c764b4414.zip
Fix doubletyping in custom todos on bad operating systemsfixdoubletyping
-rw-r--r--build.gradle.kts2
-rw-r--r--gradle/MoulConfig.xsd1
-rw-r--r--gradle/libs.versions.toml2
-rw-r--r--src/main/kotlin/io/github/moulberry/notenoughupdates/miscgui/customtodos/CustomTodoEditor.kt16
-rw-r--r--src/main/kotlin/io/github/moulberry/notenoughupdates/miscgui/customtodos/CustomTodoList.kt5
-rw-r--r--src/main/resources/assets/notenoughupdates/gui/customtodos/edit.xml6
-rw-r--r--src/main/resources/assets/notenoughupdates/gui/customtodos/overview.xml1
7 files changed, 21 insertions, 12 deletions
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 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?><xs:schema xmlns="http://notenoughupdates.org/moulconfig" elementFormDefault="qualified" targetNamespace="http://notenoughupdates.org/moulconfig" xmlns:xs="http://www.w3.org/2001/XMLSchema"><xs:complexType name="Widgetless"/><xs:complexType name="SingleWidget"><xs:group ref="AnyWidget"/></xs:complexType><xs:complexType name="MultiWidget"><xs:group maxOccurs="unbounded" minOccurs="0" ref="AnyWidget"/></xs:complexType><xs:group name="AnyWidget"><xs:choice><xs:element name="Text" type="Text"/><xs:element name="Scale" type="Scale"/><xs:element name="Center" type="Center"/><xs:element name="Slider" type="Slider"/><xs:element name="Row" type="Row"/><xs:element name="Gui" type="Gui"/><xs:element name="TextField" type="TextField"/><xs:element name="ScrollPanel" type="ScrollPanel"/><xs:element name="ItemStack" type="ItemStack"/><xs:element name="Array" type="Array"/><xs:element name="Hover" type="Hover"/><xs:element name="Spacer" type="Spacer"/><xs:element name="Column" type="Column"/><xs:element name="Button" type="Button"/><xs:element name="Switch" type="Switch"/></xs:choice></xs:group><xs:element name="Root" type="Root"/><xs:complexType name="Text"><xs:complexContent><xs:extension base="Widgetless"><xs:attribute name="split"/><xs:attribute name="shadow"/><xs:attribute name="textAlign"/><xs:attribute name="width"/><xs:attribute name="text" use="required"/></xs:extension></xs:complexContent></xs:complexType><xs:complexType name="Scale"><xs:complexContent><xs:extension base="SingleWidget"><xs:attribute name="scale" use="required"/></xs:extension></xs:complexContent></xs:complexType><xs:complexType name="Center"><xs:complexContent><xs:extension base="SingleWidget"/></xs:complexContent></xs:complexType><xs:complexType name="Root"><xs:complexContent><xs:extension base="SingleWidget"/></xs:complexContent></xs:complexType><xs:complexType name="Slider"><xs:complexContent><xs:extension base="Widgetless"><xs:attribute name="minValue" use="required"/><xs:attribute name="maxValue" use="required"/><xs:attribute name="minStep"/><xs:attribute name="width"/><xs:attribute name="value" use="required"/></xs:extension></xs:complexContent></xs:complexType><xs:complexType name="Row"><xs:complexContent><xs:extension base="MultiWidget"/></xs:complexContent></xs:complexType><xs:complexType name="Gui"><xs:complexContent><xs:extension base="SingleWidget"/></xs:complexContent></xs:complexType><xs:complexType name="TextField"><xs:complexContent><xs:extension base="Widgetless"><xs:attribute name="value" use="required"/><xs:attribute name="width"/><xs:attribute name="editable"/><xs:attribute name="suggestion"/></xs:extension></xs:complexContent></xs:complexType><xs:complexType name="ScrollPanel"><xs:complexContent><xs:extension base="SingleWidget"><xs:attribute name="width" use="required"/><xs:attribute name="height" use="required"/></xs:extension></xs:complexContent></xs:complexType><xs:complexType name="ItemStack"><xs:complexContent><xs:extension base="Widgetless"><xs:attribute name="value" use="required"/></xs:extension></xs:complexContent></xs:complexType><xs:complexType name="Array"><xs:complexContent><xs:extension base="SingleWidget"><xs:attribute name="data" use="required"/></xs:extension></xs:complexContent></xs:complexType><xs:complexType name="Hover"><xs:complexContent><xs:extension base="SingleWidget"><xs:attribute name="lines" use="required"/></xs:extension></xs:complexContent></xs:complexType><xs:complexType name="Spacer"><xs:complexContent><xs:extension base="Widgetless"><xs:attribute name="width"/><xs:attribute name="height"/></xs:extension></xs:complexContent></xs:complexType><xs:complexType name="Column"><xs:complexContent><xs:extension base="MultiWidget"/></xs:complexContent></xs:complexType><xs:complexType name="Button"><xs:complexContent><xs:extension base="SingleWidget"><xs:attribute name="margin"/><xs:attribute name="onClick" use="required"/></xs:extension></xs:complexContent></xs:complexType><xs:complexType name="Switch"><xs:complexContent><xs:extension base="Widgetless"><xs:attribute name="animationSpeed"/><xs:attribute name="value" use="required"/></xs:extension></xs:complexContent></xs:complexType></xs:schema> \ 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 <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"/>