mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-12 17:07:55 -04:00
pre load eros
This commit is contained in:
parent
d5a91e703a
commit
9f253a386a
@ -112,11 +112,7 @@ object Minosoft {
|
||||
taskWorker += WorkerTask(identifier = BootTasks.LAN_SERVERS, dependencies = arrayOf(BootTasks.PROFILES), executor = LANServerListener::listen)
|
||||
|
||||
if (!RunConfiguration.DISABLE_EROS) {
|
||||
taskWorker += WorkerTask(identifier = BootTasks.JAVAFX, executor = { JavaFXInitializer.start(); async(ThreadPool.HIGHER) { javafx.scene.text.Font.getDefault() } })
|
||||
|
||||
taskWorker += WorkerTask(identifier = BootTasks.STARTUP_PROGRESS, executor = { StartingDialog(BOOT_LATCH).show() }, dependencies = arrayOf(BootTasks.LANGUAGE_FILES, BootTasks.JAVAFX))
|
||||
|
||||
Eros::class.java.forceInit()
|
||||
javafx(taskWorker)
|
||||
}
|
||||
if (RunConfiguration.DISABLE_EROS && !RunConfiguration.DISABLE_RENDERING) {
|
||||
// eros is disabled, but rendering not, force initialize the desktop, otherwise eros will do so
|
||||
@ -148,6 +144,15 @@ object Minosoft {
|
||||
RunConfiguration.AUTO_CONNECT_TO?.let { AutoConnect.autoConnect(it) }
|
||||
}
|
||||
|
||||
private fun javafx(taskWorker: TaskWorker) {
|
||||
taskWorker += WorkerTask(identifier = BootTasks.JAVAFX, executor = { JavaFXInitializer.start(); async(ThreadPool.HIGHER) { javafx.scene.text.Font.getDefault() } })
|
||||
|
||||
taskWorker += WorkerTask(identifier = BootTasks.STARTUP_PROGRESS, executor = { StartingDialog(BOOT_LATCH).show() }, dependencies = arrayOf(BootTasks.LANGUAGE_FILES, BootTasks.JAVAFX))
|
||||
taskWorker += WorkerTask(identifier = BootTasks.EROS, dependencies = arrayOf(BootTasks.JAVAFX, BootTasks.PROFILES, BootTasks.MODS, BootTasks.VERSIONS, BootTasks.LANGUAGE_FILES), executor = { DefaultThreadPool += { Eros.preload() } })
|
||||
|
||||
Eros::class.java.forceInit()
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun main(args: Array<String>) {
|
||||
val start = nanos()
|
||||
|
@ -124,7 +124,8 @@ object GlobalProfileManager {
|
||||
}
|
||||
Log.log(LogMessageType.PROFILES, LogLevels.VERBOSE) { "Loading profiles..." }
|
||||
loadSelectedProfiles()
|
||||
val innerLatch = latch.child(DEFAULT_MANAGERS.size)
|
||||
val innerLatch = latch.child(0)
|
||||
innerLatch.plus(DEFAULT_MANAGERS.size)
|
||||
for ((namespace, manager) in DEFAULT_MANAGERS) {
|
||||
DefaultThreadPool += { manager.load(selectedProfiles[namespace]); innerLatch.dec() }
|
||||
}
|
||||
|
@ -14,21 +14,31 @@
|
||||
package de.bixilon.minosoft.gui.eros
|
||||
|
||||
import de.bixilon.kutil.collections.CollectionUtil.toSynchronizedSet
|
||||
import de.bixilon.kutil.exception.ExceptionUtil.catchAll
|
||||
import de.bixilon.kutil.latch.SimpleLatch
|
||||
import de.bixilon.minosoft.Minosoft
|
||||
import de.bixilon.minosoft.config.profile.profiles.eros.ErosProfileSelectEvent
|
||||
import de.bixilon.minosoft.gui.eros.main.MainErosController
|
||||
import de.bixilon.minosoft.gui.eros.util.JavaFXUtil
|
||||
import de.bixilon.minosoft.gui.eros.util.JavaFXUtil.forceInit
|
||||
import de.bixilon.minosoft.modding.event.events.FinishBootEvent
|
||||
import de.bixilon.minosoft.modding.event.listener.CallbackEventListener.Companion.listen
|
||||
import de.bixilon.minosoft.modding.event.master.GlobalEventMaster
|
||||
import de.bixilon.minosoft.util.KUtil.toResourceLocation
|
||||
import de.bixilon.minosoft.util.logging.Log
|
||||
import de.bixilon.minosoft.util.logging.LogLevels
|
||||
import de.bixilon.minosoft.util.logging.LogMessageType
|
||||
import javafx.stage.Window
|
||||
|
||||
object Eros {
|
||||
private val TITLE = "minosoft:eros_window_title".toResourceLocation()
|
||||
private val LAYOUT = "minosoft:eros/main/main.fxml".toResourceLocation()
|
||||
|
||||
private val latch = SimpleLatch(2)
|
||||
|
||||
lateinit var mainErosController: MainErosController
|
||||
|
||||
|
||||
var skipErosStartup = false
|
||||
|
||||
var initialized = false
|
||||
@ -75,11 +85,23 @@ object Eros {
|
||||
}
|
||||
|
||||
fun start() {
|
||||
if (latch.count >= 1) return
|
||||
latch.await()
|
||||
mainErosController.stage.show()
|
||||
initialized = true
|
||||
visible = true
|
||||
Log.log(LogMessageType.JAVAFX, LogLevels.VERBOSE) { "Eros up!" }
|
||||
}
|
||||
|
||||
fun preload() {
|
||||
latch.dec()
|
||||
JavaFXUtil.openModalAsync<MainErosController>(TITLE, LAYOUT) {
|
||||
mainErosController = it
|
||||
it.stage.show()
|
||||
initialized = true
|
||||
visible = true
|
||||
catchAll { it.stage.forceInit() }
|
||||
latch.dec()
|
||||
if (Minosoft.BOOT_LATCH.count == 0) {
|
||||
start()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -29,6 +29,7 @@ import de.bixilon.minosoft.util.crash.freeze.FreezeDumpUtil
|
||||
import de.bixilon.minosoft.util.delegate.JavaFXDelegate.observeFX
|
||||
import javafx.application.HostServices
|
||||
import javafx.application.Platform
|
||||
import javafx.beans.property.BooleanPropertyBase
|
||||
import javafx.css.StyleableProperty
|
||||
import javafx.fxml.FXMLLoader
|
||||
import javafx.scene.*
|
||||
@ -44,11 +45,14 @@ import javafx.scene.text.Text
|
||||
import javafx.scene.text.TextFlow
|
||||
import javafx.stage.Modality
|
||||
import javafx.stage.Stage
|
||||
import javafx.stage.Window
|
||||
import java.io.File
|
||||
import kotlin.reflect.jvm.javaField
|
||||
|
||||
object JavaFXUtil {
|
||||
private const val DEFAULT_STYLE = "resource:minosoft:eros/style.css"
|
||||
private val SHOWING_FIELD = Window::class.java.getDeclaredField("showing").apply { isAccessible = true }
|
||||
private val MARK_INVALID_METHOD = BooleanPropertyBase::class.java.getDeclaredMethod("markInvalid").apply { isAccessible = true }
|
||||
private val stages = StageList()
|
||||
lateinit var JAVA_FX_THREAD: Thread
|
||||
lateinit var MINOSOFT_LOGO: Image
|
||||
@ -236,4 +240,9 @@ object JavaFXUtil {
|
||||
|
||||
return loader
|
||||
}
|
||||
|
||||
fun Window.forceInit() {
|
||||
val showing = SHOWING_FIELD.get(this)
|
||||
MARK_INVALID_METHOD.invoke(showing)
|
||||
}
|
||||
}
|
||||
|
@ -20,7 +20,6 @@ enum class BootTasks {
|
||||
ASSETS_PROPERTIES,
|
||||
DEFAULT_REGISTRIES,
|
||||
LAN_SERVERS,
|
||||
JAVAFX,
|
||||
FILE_WATCHER,
|
||||
YGGDRASIL,
|
||||
STARTUP_PROGRESS,
|
||||
@ -29,5 +28,8 @@ enum class BootTasks {
|
||||
MODS,
|
||||
|
||||
DATA_FIXER,
|
||||
|
||||
JAVAFX,
|
||||
EROS,
|
||||
;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user