diff --git a/mirai-console-graphical/src/main/kotlin/net/mamoe/mirai/console/graphical/MiraiConsoleGraphicalLoader.kt b/mirai-console-graphical/src/main/kotlin/net/mamoe/mirai/console/graphical/MiraiConsoleGraphicalLoader.kt new file mode 100644 index 000000000..06c3fc167 --- /dev/null +++ b/mirai-console-graphical/src/main/kotlin/net/mamoe/mirai/console/graphical/MiraiConsoleGraphicalLoader.kt @@ -0,0 +1,35 @@ +/* + * Copyright 2020 Mamoe Technologies and contributors. + * + * 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证. + * Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link. + * + * https://github.com/mamoe/mirai/blob/master/LICENSE + */ +package net.mamoe.mirai.console.graphical + +import net.mamoe.mirai.console.pure.MiraiConsoleUIPure + +import net.mamoe.mirai.console.MiraiConsole +import tornadofx.launch +import kotlin.concurrent.thread + +class MiraiConsoleGraphicalLoader { + companion object { + internal lateinit var coreVersion :String + internal lateinit var consoleVersion: String + @JvmStatic + fun load( + coreVersion: String, + consoleVersion: String + ) { + this.coreVersion = coreVersion + this.consoleVersion = consoleVersion + Runtime.getRuntime().addShutdownHook(thread(start = false) { + MiraiConsole.stop() + }) + launch() + } + + } +} \ No newline at end of file diff --git a/mirai-console-graphical/src/main/kotlin/net/mamoe/mirai/console/graphical/MiraiGraphical.kt b/mirai-console-graphical/src/main/kotlin/net/mamoe/mirai/console/graphical/MiraiGraphical.kt index 4c8ba7351..5c2f48555 100644 --- a/mirai-console-graphical/src/main/kotlin/net/mamoe/mirai/console/graphical/MiraiGraphical.kt +++ b/mirai-console-graphical/src/main/kotlin/net/mamoe/mirai/console/graphical/MiraiGraphical.kt @@ -27,8 +27,7 @@ class MiraiGraphicalUI : App(Decorator::class, PrimaryStyleSheet::class) { override fun init() { super.init() - - MiraiConsole.start(find()) + MiraiConsole.start(find(),MiraiConsoleGraphicalLoader.coreVersion,MiraiConsoleGraphicalLoader.consoleVersion) } override fun stop() {