Persist LogWidget "scroll to the end" checkbox value

This commit is contained in:
UnicornFreedom 2025-08-22 15:16:37 +02:00
parent 04bbf626a1
commit b03078ff27
No known key found for this signature in database
GPG Key ID: B4ED0DB6B940024F

View File

@ -7,7 +7,9 @@ import ocelot.desktop.ui.widget.LogWidget.{LogEntry, TextLogEntry}
import ocelot.desktop.ui.widget.window.PanelWindow
import ocelot.desktop.ui.widget.{Button, Checkbox, Filler, Label, LogWidget, PaddingBox, TextInput, Widget}
import ocelot.desktop.util.{OcelotInterfaceLogStorage, Orientation}
import ocelot.desktop.windows.OcelotInterfaceWindow.ScrollToEndTag
import org.lwjgl.input.Keyboard
import totoro.ocelot.brain.nbt.NBTTagCompound
class OcelotInterfaceWindow(storage: OcelotInterfaceLogStorage) extends PanelWindow {
override protected def title: String = s"${storage.name} ${storage.ocelotInterface.node.address}"
@ -127,4 +129,20 @@ class OcelotInterfaceWindow(storage: OcelotInterfaceLogStorage) extends PanelWin
def pushLine(line: String): Unit = {
storage.ocelotInterface.pushMessage(line)
}
override def save(nbt: NBTTagCompound): Unit = {
super.save(nbt)
nbt.setBoolean(ScrollToEndTag, logWidget.scrollToEnd)
}
override def load(nbt: NBTTagCompound): Unit = {
super.load(nbt)
if (nbt.hasKey(ScrollToEndTag)) {
logWidget.scrollToEnd = nbt.getBoolean(ScrollToEndTag)
}
}
}
object OcelotInterfaceWindow {
private val ScrollToEndTag = "scrollToEnd"
}