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 6f5725da3..e8727b9da 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 @@ -73,7 +73,7 @@ class MainWindow( UIManager.setLookAndFeel(instance) FlatLaf.updateUI() - MainFrame( + val main = MainFrame( guiProps, apiWrapper, updateChecker, @@ -81,6 +81,17 @@ class MainWindow( ) splashScreen.close() guiProps.font = guiProps.font + if (guiProps.startFocusEnabled) { + main.toFront() + } else { + main.show() + } + if (!apiWrapper.apiProperties.preRelease) { + main.displayMigrationMessages() + } + if (guiProps.showTipOnStartup) { + main.showTip() + } } } } \ No newline at end of file diff --git a/serverpackcreator-gui/src/main/kotlin/de/griefed/serverpackcreator/gui/window/tips/CustomTip.kt b/serverpackcreator-gui/src/main/kotlin/de/griefed/serverpackcreator/gui/tips/CustomTip.kt similarity index 95% rename from serverpackcreator-gui/src/main/kotlin/de/griefed/serverpackcreator/gui/window/tips/CustomTip.kt rename to serverpackcreator-gui/src/main/kotlin/de/griefed/serverpackcreator/gui/tips/CustomTip.kt index bbe00fbbb..160041fe3 100644 --- a/serverpackcreator-gui/src/main/kotlin/de/griefed/serverpackcreator/gui/window/tips/CustomTip.kt +++ b/serverpackcreator-gui/src/main/kotlin/de/griefed/serverpackcreator/gui/tips/CustomTip.kt @@ -17,7 +17,7 @@ * * The full license can be found at https:github.com/Griefed/ServerPackCreator/blob/main/LICENSE */ -package de.griefed.serverpackcreator.gui.window.tips +package de.griefed.serverpackcreator.gui.tips import tokyo.northside.swing.tips.DefaultTip import javax.swing.ImageIcon diff --git a/serverpackcreator-gui/src/main/kotlin/de/griefed/serverpackcreator/gui/window/tips/CustomTipOfTheDayUI.kt b/serverpackcreator-gui/src/main/kotlin/de/griefed/serverpackcreator/gui/tips/CustomTipOfTheDayUI.kt similarity index 99% rename from serverpackcreator-gui/src/main/kotlin/de/griefed/serverpackcreator/gui/window/tips/CustomTipOfTheDayUI.kt rename to serverpackcreator-gui/src/main/kotlin/de/griefed/serverpackcreator/gui/tips/CustomTipOfTheDayUI.kt index 522cc6159..f1ef36781 100644 --- a/serverpackcreator-gui/src/main/kotlin/de/griefed/serverpackcreator/gui/window/tips/CustomTipOfTheDayUI.kt +++ b/serverpackcreator-gui/src/main/kotlin/de/griefed/serverpackcreator/gui/tips/CustomTipOfTheDayUI.kt @@ -17,7 +17,7 @@ * * The full license can be found at https:github.com/Griefed/ServerPackCreator/blob/main/LICENSE */ -package de.griefed.serverpackcreator.gui.window.tips +package de.griefed.serverpackcreator.gui.tips import Gui import de.griefed.serverpackcreator.gui.GuiProps diff --git a/serverpackcreator-gui/src/main/kotlin/de/griefed/serverpackcreator/gui/window/tips/TipOfTheDayManager.kt b/serverpackcreator-gui/src/main/kotlin/de/griefed/serverpackcreator/gui/tips/TipOfTheDayManager.kt similarity index 98% rename from serverpackcreator-gui/src/main/kotlin/de/griefed/serverpackcreator/gui/window/tips/TipOfTheDayManager.kt rename to serverpackcreator-gui/src/main/kotlin/de/griefed/serverpackcreator/gui/tips/TipOfTheDayManager.kt index 24058b8a8..09816e5a5 100644 --- a/serverpackcreator-gui/src/main/kotlin/de/griefed/serverpackcreator/gui/window/tips/TipOfTheDayManager.kt +++ b/serverpackcreator-gui/src/main/kotlin/de/griefed/serverpackcreator/gui/tips/TipOfTheDayManager.kt @@ -17,7 +17,7 @@ * * The full license can be found at https:github.com/Griefed/ServerPackCreator/blob/main/LICENSE */ -package de.griefed.serverpackcreator.gui.window.tips +package de.griefed.serverpackcreator.gui.tips import Gui import de.griefed.serverpackcreator.gui.GuiProps 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 168cc720b..10bd8c956 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 @@ -23,7 +23,6 @@ import Gui import de.griefed.serverpackcreator.api.ApiWrapper import de.griefed.serverpackcreator.gui.GuiProps import de.griefed.serverpackcreator.gui.window.menu.MainMenuBar -import de.griefed.serverpackcreator.gui.window.tips.TipOfTheDayManager import de.griefed.serverpackcreator.updater.MigrationManager import de.griefed.serverpackcreator.updater.UpdateChecker import java.awt.Dimension @@ -31,8 +30,6 @@ import java.awt.event.WindowAdapter import java.awt.event.WindowEvent import javax.swing.JFrame import javax.swing.WindowConstants -import javax.swing.event.HyperlinkEvent -import javax.swing.event.HyperlinkListener /** * Main Frame of ServerPackCreator, housing [MainPanel], [MainMenuBar]. @@ -47,50 +44,63 @@ class MainFrame( ) { val frame: JFrame = JFrame(Gui.createserverpack_gui_createandshowgui.toString()) val mainPanel = MainPanel(guiProps, apiWrapper, guiProps.larsonScanner,this) + private val updateDialogs : UpdateDialogs + private val menuBar: MainMenuBar init { - val closeAndExit = object : WindowAdapter() { - override fun windowClosing(event: WindowEvent) { - mainPanel.closeAndExit() - } - } - val updateDialogs = UpdateDialogs( + updateDialogs = UpdateDialogs( guiProps, apiWrapper.utilities!!.webUtilities, apiWrapper.apiProperties, updateChecker, frame ) - val menu = MainMenuBar( + menuBar = MainMenuBar( guiProps, apiWrapper, updateDialogs, this, migrationManager ) - frame.jMenuBar = menu.menuBar + frame.jMenuBar = menuBar.menuBar frame.defaultCloseOperation = WindowConstants.EXIT_ON_CLOSE - frame.addWindowListener(closeAndExit) + frame.addWindowListener(object : WindowAdapter() { + override fun windowClosing(event: WindowEvent) { + mainPanel.closeAndExit() + } + }) frame.iconImage = guiProps.appIcon frame.contentPane = mainPanel.panel frame.isLocationByPlatform = true - 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) - if (guiProps.startFocusEnabled) { - toFront() - } - if (!apiWrapper.apiProperties.preRelease) { - menu.displayMigrationMessages() - } - if (guiProps.showTipOnStartup) { - menu.showTip() - } + KeyComboManager(guiProps,apiWrapper,updateChecker,updateDialogs,migrationManager,frame,mainPanel,menuBar) + } + + /** + * @author Griefed + */ + fun show() { + frame.isVisible = true + } + + /** + * @author Griefed + */ + fun displayMigrationMessages() { + menuBar.displayMigrationMessages() + } + + /** + * @author Griefed + */ + fun showTip() { + menuBar.showTip() } /** * @author Griefed */ fun toFront() { + frame.isAutoRequestFocus = true + show() frame.toFront() frame.requestFocus() } diff --git a/serverpackcreator-gui/src/main/kotlin/de/griefed/serverpackcreator/gui/window/menu/about/TipOfTheDayItem.kt b/serverpackcreator-gui/src/main/kotlin/de/griefed/serverpackcreator/gui/window/menu/about/TipOfTheDayItem.kt index c61a88c5f..3173bc1a0 100644 --- a/serverpackcreator-gui/src/main/kotlin/de/griefed/serverpackcreator/gui/window/menu/about/TipOfTheDayItem.kt +++ b/serverpackcreator-gui/src/main/kotlin/de/griefed/serverpackcreator/gui/window/menu/about/TipOfTheDayItem.kt @@ -21,7 +21,7 @@ package de.griefed.serverpackcreator.gui.window.menu.about import de.griefed.serverpackcreator.gui.GuiProps import de.griefed.serverpackcreator.gui.window.MainFrame -import de.griefed.serverpackcreator.gui.window.tips.TipOfTheDayManager +import de.griefed.serverpackcreator.gui.tips.TipOfTheDayManager import javax.swing.JMenuItem /**