diff --git a/serverpackcreator-gui/src/main/kotlin/de/griefed/serverpackcreator/gui/GuiProps.kt b/serverpackcreator-gui/src/main/kotlin/de/griefed/serverpackcreator/gui/GuiProps.kt index b986eba90..8c32801eb 100644 --- a/serverpackcreator-gui/src/main/kotlin/de/griefed/serverpackcreator/gui/GuiProps.kt +++ b/serverpackcreator-gui/src/main/kotlin/de/griefed/serverpackcreator/gui/GuiProps.kt @@ -49,6 +49,7 @@ import javax.swing.plaf.FontUIResource */ @Suppress("unused", "RedundantSuppression") class GuiProps(private val apiProperties: ApiProperties) { + @Suppress("MemberVisibilityCanBePrivate") val smallSize = 18 @@ -387,35 +388,42 @@ class GuiProps(private val apiProperties: ApiProperties) { FlatAnimatedLafChange.hideSnapshotWithAnimation() storeGuiProperty("theme", field.javaClass.name) } - var startFocusEnabled: Boolean + var startFocusEnabled: Boolean = getGuiProperty("focus.start", "false").toBoolean() get() { val prop = getGuiProperty("focus.start", "false") - return prop == "true" + field = prop == "true" + return field } set(value) { + field = value storeGuiProperty("focus.start",value.toString()) } - var generationFocusEnabled: Boolean + var generationFocusEnabled: Boolean = getGuiProperty("focus.generation", "false").toBoolean() get() { val prop = getGuiProperty("focus.generation", "false") - return prop == "true" + field = prop == "true" + return field } set(value) { + field = value storeGuiProperty("focus.generation",value.toString()) } - var fontSize: Int + var fontSize: Int = getGuiProperty("font.size","12")!!.toInt() get() { val prop = getGuiProperty("font.size","12") - return if (prop != null) { + field = if (prop != null) { return prop.toInt() } else { 12 } + return field } set(value) { + field = value storeGuiProperty("font.size",value.toString()) val currentFont = UIManager.get("defaultFont") as Font UIManager.put("defaultFont",FontUIResource(currentFont.fontName, currentFont.style, value)) + FlatLaf.updateUI() } /** @@ -452,4 +460,11 @@ class GuiProps(private val apiProperties: ApiProperties) { fun storeGuiProperty(key: String, value: String) { apiProperties.storeCustomProperty("$guiPropertyPrefix$key", value) } + + fun initFont() { + val value = getGuiProperty("font.size","12")!!.toInt() + val currentFont = UIManager.get("defaultFont") as Font + UIManager.put("defaultFont",FontUIResource(currentFont.fontName, currentFont.style, value)) + FlatLaf.updateUI() + } } \ No newline at end of file diff --git a/serverpackcreator-gui/src/main/kotlin/de/griefed/serverpackcreator/gui/MainWindow.kt b/serverpackcreator-gui/src/main/kotlin/de/griefed/serverpackcreator/gui/MainWindow.kt index 0e0f2cc62..ecf4b4672 100644 --- a/serverpackcreator-gui/src/main/kotlin/de/griefed/serverpackcreator/gui/MainWindow.kt +++ b/serverpackcreator-gui/src/main/kotlin/de/griefed/serverpackcreator/gui/MainWindow.kt @@ -67,16 +67,13 @@ class MainWindow( UIManager.setLookAndFeel(instance) FlatLaf.updateUI() - val frame = MainFrame( + MainFrame( guiProps, apiWrapper, updateChecker, migrationManager ) splashScreen.close() - if (guiProps.startFocusEnabled) { - frame.toFront() - } } } } \ No newline at end of file diff --git a/serverpackcreator-gui/src/main/kotlin/de/griefed/serverpackcreator/gui/window/MainFrame.kt b/serverpackcreator-gui/src/main/kotlin/de/griefed/serverpackcreator/gui/window/MainFrame.kt index 642653d6f..2b1919143 100644 --- a/serverpackcreator-gui/src/main/kotlin/de/griefed/serverpackcreator/gui/window/MainFrame.kt +++ b/serverpackcreator-gui/src/main/kotlin/de/griefed/serverpackcreator/gui/window/MainFrame.kt @@ -68,33 +68,14 @@ class MainFrame( frame.isAutoRequestFocus = true frame.preferredSize = Dimension(1100, 860) frame.pack() + guiProps.initFont() frame.isVisible = true guiProps.larsonScanner.loadConfig(guiProps.idleConfig) guiProps.larsonScanner.play() KeyComboManager(guiProps,apiWrapper,updateChecker,updateDialogs,migrationManager,frame,mainPanel,menu) - /*Toolkit.getDefaultToolkit().addAWTEventListener({ e: AWTEvent -> - val event = e as KeyEvent - if (event.id == KeyEvent.KEY_RELEASED) { - val currentFont = UIManager.get("defaultFont") as Font - when { - event.keyCode == KeyEvent.VK_UP && event.isControlDown && event.isShiftDown -> { - UIManager.put( - "defaultFont", - FontUIResource(currentFont.fontName, currentFont.style, currentFont.size + 1) - ) - FlatLaf.updateUI() - } - - event.keyCode == KeyEvent.VK_DOWN && event.isControlDown && event.isShiftDown -> { - UIManager.put( - "defaultFont", - FontUIResource(currentFont.fontName, currentFont.style, currentFont.size - 1) - ) - FlatLaf.updateUI() - } - } - } - }, AWTEvent.KEY_EVENT_MASK)*/ + if (guiProps.startFocusEnabled) { + toFront() + } } fun toFront() {