From f18b83288869613c2119ed3c51fd1b94c6a313ef Mon Sep 17 00:00:00 2001 From: Kyren223 Date: Tue, 14 May 2024 19:10:19 +0300 Subject: Version 2.1.2 Reverted back to the old settings panel due to the new one not saving properly after a restart. --- .../kotlin/me/kyren223/trident/data/Settings.kt | 25 +++++++++++++--------- 1 file changed, 15 insertions(+), 10 deletions(-) (limited to 'src/main/kotlin/me/kyren223/trident/data/Settings.kt') diff --git a/src/main/kotlin/me/kyren223/trident/data/Settings.kt b/src/main/kotlin/me/kyren223/trident/data/Settings.kt index a1a400b..e97737c 100644 --- a/src/main/kotlin/me/kyren223/trident/data/Settings.kt +++ b/src/main/kotlin/me/kyren223/trident/data/Settings.kt @@ -2,20 +2,12 @@ package me.kyren223.trident.data import com.intellij.openapi.application.ApplicationManager import com.intellij.openapi.components.* +import com.intellij.util.xmlb.XmlSerializerUtil // Copyright 2000-2022 JetBrains s.r.o. and other contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. @Service @State(name = "me.kyren223.trident.data.SettingsState", storages = [Storage("SdkSettingsPlugin.xml")]) -class Settings : SimplePersistentStateComponent(SettingsState()) { - companion object { - private val instance: Settings - get() = ApplicationManager.getApplication().getService(Settings::class.java) - val state: SettingsState - get() = instance.state - } -} - -class SettingsState : BaseState() { +class SettingsState : PersistentStateComponent { var width = 800 var height = 400 var fontSize = 20 @@ -25,4 +17,17 @@ class SettingsState : BaseState() { var recursiveMapping = false var rememberLine = false var indexCycling = false + + override fun getState(): SettingsState { + return this + } + + override fun loadState(state: SettingsState) { + XmlSerializerUtil.copyBean(state, this) + } + + companion object { + val instance: SettingsState + get() = ApplicationManager.getApplication().getService(SettingsState::class.java) + } } -- cgit v1.3.1