mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-14 18:05:51 -04:00
outsource minosoft boot process from main class to external class
That will make it much easier to use a custom main class, maybe useful on android
This commit is contained in:
parent
a2cb6b6258
commit
56f26dbae4
@ -20,7 +20,6 @@ import de.bixilon.kutil.concurrent.pool.runnable.ForcePooledRunnable
|
||||
import de.bixilon.kutil.concurrent.worker.task.TaskWorker
|
||||
import de.bixilon.kutil.concurrent.worker.task.WorkerTask
|
||||
import de.bixilon.kutil.latch.AbstractLatch
|
||||
import de.bixilon.kutil.latch.CallbackLatch
|
||||
import de.bixilon.kutil.latch.SimpleLatch
|
||||
import de.bixilon.kutil.observer.DataObserver.Companion.observe
|
||||
import de.bixilon.kutil.os.OSTypes
|
||||
@ -31,50 +30,35 @@ import de.bixilon.kutil.shutdown.ShutdownManager
|
||||
import de.bixilon.kutil.time.TimeUtil.nanos
|
||||
import de.bixilon.kutil.unit.UnitFormatter.formatNanos
|
||||
import de.bixilon.minosoft.assets.IntegratedAssets
|
||||
import de.bixilon.minosoft.assets.meta.MinosoftMeta
|
||||
import de.bixilon.minosoft.assets.properties.version.AssetsVersionProperties
|
||||
import de.bixilon.minosoft.config.StaticConfiguration
|
||||
import de.bixilon.minosoft.config.profile.manager.ProfileManagers
|
||||
import de.bixilon.minosoft.config.profile.profiles.eros.ErosProfileManager
|
||||
import de.bixilon.minosoft.data.entities.event.EntityEvents
|
||||
import de.bixilon.minosoft.data.language.LanguageUtil
|
||||
import de.bixilon.minosoft.data.language.manager.MultiLanguageManager
|
||||
import de.bixilon.minosoft.data.registries.fallback.FallbackRegistries
|
||||
import de.bixilon.minosoft.data.registries.fallback.tags.FallbackTags
|
||||
import de.bixilon.minosoft.data.registries.identified.Namespaces
|
||||
import de.bixilon.minosoft.data.registries.identified.Namespaces.minosoft
|
||||
import de.bixilon.minosoft.data.language.IntegratedLanguage
|
||||
import de.bixilon.minosoft.data.text.formatting.FormattingCodes
|
||||
import de.bixilon.minosoft.data.text.formatting.color.ChatColors
|
||||
import de.bixilon.minosoft.datafixer.DataFixer
|
||||
import de.bixilon.minosoft.gui.eros.Eros
|
||||
import de.bixilon.minosoft.gui.eros.crash.ErosCrashReport
|
||||
import de.bixilon.minosoft.gui.eros.crash.ErosCrashReport.Companion.crash
|
||||
import de.bixilon.minosoft.gui.eros.dialog.StartingDialog
|
||||
import de.bixilon.minosoft.gui.eros.util.JavaFXInitializer
|
||||
import de.bixilon.minosoft.main.BootTasks
|
||||
import de.bixilon.minosoft.main.MinosoftBoot
|
||||
import de.bixilon.minosoft.modding.event.events.FinishBootEvent
|
||||
import de.bixilon.minosoft.modding.event.master.GlobalEventMaster
|
||||
import de.bixilon.minosoft.modding.loader.LoadingPhases
|
||||
import de.bixilon.minosoft.modding.loader.ModLoader
|
||||
import de.bixilon.minosoft.properties.MinosoftPropertiesLoader
|
||||
import de.bixilon.minosoft.protocol.protocol.LANServerListener
|
||||
import de.bixilon.minosoft.protocol.versions.VersionLoader
|
||||
import de.bixilon.minosoft.terminal.AutoConnect
|
||||
import de.bixilon.minosoft.terminal.CommandLineArguments
|
||||
import de.bixilon.minosoft.terminal.RunConfiguration
|
||||
import de.bixilon.minosoft.terminal.cli.CLI
|
||||
import de.bixilon.minosoft.util.DesktopUtil
|
||||
import de.bixilon.minosoft.util.KUtil
|
||||
import de.bixilon.minosoft.util.json.Jackson
|
||||
import de.bixilon.minosoft.util.logging.Log
|
||||
import de.bixilon.minosoft.util.logging.LogLevels
|
||||
import de.bixilon.minosoft.util.logging.LogMessageType
|
||||
import de.bixilon.minosoft.util.yggdrasil.YggdrasilUtil
|
||||
|
||||
|
||||
object Minosoft {
|
||||
val LANGUAGE_MANAGER = MultiLanguageManager()
|
||||
val BOOT_LATCH = CallbackLatch(1)
|
||||
|
||||
|
||||
private fun preBoot(args: Array<String>) {
|
||||
@ -104,15 +88,8 @@ object Minosoft {
|
||||
private fun boot() {
|
||||
val taskWorker = TaskWorker(errorHandler = { _, error -> error.printStackTrace(); error.crash() }, forcePool = true)
|
||||
|
||||
taskWorker += WorkerTask(identifier = BootTasks.VERSIONS, priority = ThreadPool.HIGHER, executor = VersionLoader::load)
|
||||
taskWorker += WorkerTask(identifier = BootTasks.PROFILES, priority = ThreadPool.HIGHEST, executor = ProfileManagers::load)
|
||||
|
||||
MinosoftBoot.register(taskWorker)
|
||||
taskWorker += WorkerTask(identifier = BootTasks.LANGUAGE_FILES, dependencies = arrayOf(BootTasks.PROFILES), executor = this::loadLanguageFiles)
|
||||
taskWorker += WorkerTask(identifier = BootTasks.ASSETS_PROPERTIES, dependencies = arrayOf(BootTasks.VERSIONS), executor = AssetsVersionProperties::load)
|
||||
taskWorker += WorkerTask(identifier = BootTasks.DEFAULT_REGISTRIES, dependencies = arrayOf(BootTasks.VERSIONS), executor = { MinosoftMeta.load(); FallbackTags.load(); FallbackRegistries.load(); EntityEvents.load() })
|
||||
|
||||
|
||||
taskWorker += WorkerTask(identifier = BootTasks.LAN_SERVERS, dependencies = arrayOf(BootTasks.PROFILES), executor = LANServerListener::listen)
|
||||
|
||||
if (!RunConfiguration.DISABLE_EROS) {
|
||||
javafx(taskWorker)
|
||||
@ -121,17 +98,10 @@ object Minosoft {
|
||||
// eros is disabled, but rendering not, force initialize the desktop, otherwise eros will do so
|
||||
DefaultThreadPool += { DesktopUtil.initialize() }
|
||||
}
|
||||
taskWorker += WorkerTask(identifier = BootTasks.YGGDRASIL, executor = { YggdrasilUtil.load() })
|
||||
|
||||
taskWorker += WorkerTask(identifier = BootTasks.ASSETS_OVERRIDE, executor = { IntegratedAssets.OVERRIDE.load(it) })
|
||||
taskWorker += WorkerTask(identifier = BootTasks.MODS, executor = { ModLoader.load(LoadingPhases.BOOT, it) })
|
||||
taskWorker += WorkerTask(identifier = BootTasks.DATA_FIXER, executor = { DataFixer.load() })
|
||||
taskWorker += WorkerTask(identifier = BootTasks.CLI, priority = ThreadPool.LOW, executor = CLI::startThread)
|
||||
|
||||
|
||||
taskWorker.work(BOOT_LATCH)
|
||||
BOOT_LATCH.dec() // initial count
|
||||
BOOT_LATCH.await()
|
||||
taskWorker.work(MinosoftBoot.LATCH)
|
||||
MinosoftBoot.LATCH.dec() // initial count
|
||||
MinosoftBoot.LATCH.await()
|
||||
}
|
||||
|
||||
private fun postBoot() {
|
||||
@ -150,7 +120,7 @@ object Minosoft {
|
||||
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.STARTUP_PROGRESS, executor = { StartingDialog(MinosoftBoot.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() } })
|
||||
|
||||
DefaultThreadPool += ForcePooledRunnable { Eros::class.java.forceInit() }
|
||||
@ -185,12 +155,7 @@ object Minosoft {
|
||||
}
|
||||
|
||||
private fun loadLanguageFiles(latch: AbstractLatch?) {
|
||||
val language = ErosProfileManager.selected.general.language
|
||||
ErosProfileManager.selected.general::language.observe(this, true) {
|
||||
Log.log(LogMessageType.OTHER, LogLevels.VERBOSE) { "Loading language files (${language})" }
|
||||
LANGUAGE_MANAGER.translators[Namespaces.MINOSOFT] = LanguageUtil.load(it, null, IntegratedAssets.DEFAULT, minosoft("language/"))
|
||||
Log.log(LogMessageType.OTHER, LogLevels.VERBOSE) { "Language files loaded!" }
|
||||
}
|
||||
ErosProfileManager.selected.general::language.observe(this, true) { IntegratedLanguage.load(it) }
|
||||
}
|
||||
|
||||
private fun checkMacOS() {
|
||||
|
@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Minosoft
|
||||
* Copyright (C) 2020-2023 Moritz Zwerger
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
|
||||
*/
|
||||
|
||||
package de.bixilon.minosoft.data.language
|
||||
|
||||
import de.bixilon.minosoft.assets.IntegratedAssets
|
||||
import de.bixilon.minosoft.data.language.manager.MultiLanguageManager
|
||||
import de.bixilon.minosoft.data.registries.identified.Namespaces
|
||||
import de.bixilon.minosoft.data.registries.identified.Namespaces.minosoft
|
||||
import de.bixilon.minosoft.util.logging.Log
|
||||
import de.bixilon.minosoft.util.logging.LogLevels
|
||||
import de.bixilon.minosoft.util.logging.LogMessageType
|
||||
|
||||
object IntegratedLanguage {
|
||||
val LANGUAGE = MultiLanguageManager()
|
||||
|
||||
|
||||
fun load(name: String) {
|
||||
Log.log(LogMessageType.LOADING, LogLevels.VERBOSE) { "Loading language files (${name})" }
|
||||
val language = LanguageUtil.load(name, null, IntegratedAssets.DEFAULT, minosoft("language/"))
|
||||
LANGUAGE.translators[Namespaces.MINOSOFT] = language
|
||||
}
|
||||
}
|
@ -14,7 +14,7 @@ package de.bixilon.minosoft.data.text
|
||||
|
||||
import com.fasterxml.jackson.core.JacksonException
|
||||
import de.bixilon.kutil.cast.CastUtil.unsafeCast
|
||||
import de.bixilon.minosoft.Minosoft
|
||||
import de.bixilon.minosoft.data.language.IntegratedLanguage
|
||||
import de.bixilon.minosoft.data.language.translate.Translatable
|
||||
import de.bixilon.minosoft.data.language.translate.Translator
|
||||
import de.bixilon.minosoft.data.registries.identified.ResourceLocation
|
||||
@ -103,7 +103,7 @@ interface ChatComponent {
|
||||
return raw
|
||||
}
|
||||
if (raw is Translatable && raw !is ResourceLocation) {
|
||||
return (translator ?: Minosoft.LANGUAGE_MANAGER).forceTranslate(raw.translationKey, parent, restricted = restricted)
|
||||
return (translator ?: IntegratedLanguage.LANGUAGE).forceTranslate(raw.translationKey, parent, restricted = restricted)
|
||||
}
|
||||
|
||||
when (raw) {
|
||||
|
@ -13,9 +13,9 @@
|
||||
|
||||
package de.bixilon.minosoft.data.text
|
||||
|
||||
import de.bixilon.minosoft.Minosoft
|
||||
import de.bixilon.minosoft.config.profile.profiles.eros.server.entries.AbstractServer
|
||||
import de.bixilon.minosoft.data.accounts.Account
|
||||
import de.bixilon.minosoft.data.language.IntegratedLanguage
|
||||
import de.bixilon.minosoft.util.KUtil.toResourceLocation
|
||||
|
||||
object TranslatableComponents {
|
||||
@ -27,8 +27,15 @@ object TranslatableComponents {
|
||||
val GENERAL_EXIT = "minosoft:general.exit".toResourceLocation()
|
||||
val GENERAL_REFRESH = "minosoft:general.refresh".toResourceLocation()
|
||||
|
||||
val EROS_DELETE_SERVER_CONFIRM_DESCRIPTION = { name: ChatComponent, address: String -> Minosoft.LANGUAGE_MANAGER.forceTranslate("minosoft:server_info.delete.dialog.description".toResourceLocation(), name, address) }
|
||||
val ACCOUNT_CARD_CONNECTION_COUNT = { count: Int -> Minosoft.LANGUAGE_MANAGER.forceTranslate("minosoft:main.account.card.connection_count".toResourceLocation(), count) }
|
||||
val CONNECTION_KICK_DESCRIPTION = { server: AbstractServer, account: Account -> Minosoft.LANGUAGE_MANAGER.forceTranslate("minosoft:connection.kick.description".toResourceLocation(), server.name, account.username) }
|
||||
val CONNECTION_LOGIN_KICK_DESCRIPTION = { server: AbstractServer, account: Account -> Minosoft.LANGUAGE_MANAGER.forceTranslate("minosoft:connection.login_kick.description".toResourceLocation(), server.name, account.username) }
|
||||
@Deprecated("yah")
|
||||
val EROS_DELETE_SERVER_CONFIRM_DESCRIPTION = { name: ChatComponent, address: String -> IntegratedLanguage.LANGUAGE.forceTranslate("minosoft:server_info.delete.dialog.description".toResourceLocation(), name, address) }
|
||||
|
||||
@Deprecated("yah")
|
||||
val ACCOUNT_CARD_CONNECTION_COUNT = { count: Int -> IntegratedLanguage.LANGUAGE.forceTranslate("minosoft:main.account.card.connection_count".toResourceLocation(), count) }
|
||||
|
||||
@Deprecated("yah")
|
||||
val CONNECTION_KICK_DESCRIPTION = { server: AbstractServer, account: Account -> IntegratedLanguage.LANGUAGE.forceTranslate("minosoft:connection.kick.description".toResourceLocation(), server.name, account.username) }
|
||||
|
||||
@Deprecated("yah")
|
||||
val CONNECTION_LOGIN_KICK_DESCRIPTION = { server: AbstractServer, account: Account -> IntegratedLanguage.LANGUAGE.forceTranslate("minosoft:connection.login_kick.description".toResourceLocation(), server.name, account.username) }
|
||||
}
|
||||
|
@ -17,11 +17,11 @@ import de.bixilon.kutil.collections.CollectionUtil.toSynchronizedSet
|
||||
import de.bixilon.kutil.exception.ExceptionUtil.catchAll
|
||||
import de.bixilon.kutil.latch.SimpleLatch
|
||||
import de.bixilon.kutil.observer.DataObserver.Companion.observe
|
||||
import de.bixilon.minosoft.Minosoft
|
||||
import de.bixilon.minosoft.config.profile.profiles.eros.ErosProfileManager
|
||||
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.main.MinosoftBoot
|
||||
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
|
||||
@ -100,7 +100,7 @@ object Eros {
|
||||
mainErosController = it
|
||||
catchAll { it.stage.forceInit() }
|
||||
latch.dec()
|
||||
if (Minosoft.BOOT_LATCH.count == 0) {
|
||||
if (MinosoftBoot.LATCH.count == 0) {
|
||||
start()
|
||||
}
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ package de.bixilon.minosoft.gui.eros.dialog
|
||||
|
||||
import de.bixilon.kutil.exception.ExceptionUtil.toStackTrace
|
||||
import de.bixilon.kutil.reflection.ReflectionUtil.realName
|
||||
import de.bixilon.minosoft.Minosoft
|
||||
import de.bixilon.minosoft.data.language.IntegratedLanguage
|
||||
import de.bixilon.minosoft.data.text.TranslatableComponents.GENERAL_IGNORE
|
||||
import de.bixilon.minosoft.gui.eros.controller.DialogController
|
||||
import de.bixilon.minosoft.gui.eros.crash.ErosCrashReport.Companion.crash
|
||||
@ -66,7 +66,7 @@ class ErosErrorReport : DialogController() {
|
||||
|
||||
companion object {
|
||||
private val LAYOUT = "minosoft:eros/dialog/error.fxml".toResourceLocation()
|
||||
private val TITLE = { exception: Throwable? -> Minosoft.LANGUAGE_MANAGER.forceTranslate("minosoft:error.title".toResourceLocation(), exception?.let { it::class.java.realName }) }
|
||||
private val TITLE = { exception: Throwable? -> IntegratedLanguage.LANGUAGE.forceTranslate("minosoft:error.title".toResourceLocation(), exception?.let { it::class.java.realName }) }
|
||||
private val HEADER = "minosoft:error.header".toResourceLocation()
|
||||
private val DESCRIPTION = "minosoft:error.description".toResourceLocation()
|
||||
private val FATAL_CRASH = "minosoft:error.fatal_crash".toResourceLocation()
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Minosoft
|
||||
* Copyright (C) 2020-2022 Moritz Zwerger
|
||||
* Copyright (C) 2020-2023 Moritz Zwerger
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
@ -14,7 +14,7 @@
|
||||
package de.bixilon.minosoft.gui.eros.dialog
|
||||
|
||||
import de.bixilon.kutil.concurrent.pool.DefaultThreadPool
|
||||
import de.bixilon.minosoft.Minosoft
|
||||
import de.bixilon.minosoft.data.language.IntegratedLanguage
|
||||
import de.bixilon.minosoft.data.text.ChatComponent
|
||||
import de.bixilon.minosoft.data.text.TranslatableComponents
|
||||
import de.bixilon.minosoft.gui.eros.controller.DialogController
|
||||
@ -49,10 +49,10 @@ class SimpleErosConfirmationDialog(
|
||||
}
|
||||
|
||||
override fun init() {
|
||||
headerFX.text = Minosoft.LANGUAGE_MANAGER.translate(header)
|
||||
descriptionFX.text = description?.let { Minosoft.LANGUAGE_MANAGER.translate(it) } ?: ChatComponent.EMPTY
|
||||
cancelButtonFX.text = Minosoft.LANGUAGE_MANAGER.translate(cancelButtonText).message
|
||||
confirmButtonFX.text = Minosoft.LANGUAGE_MANAGER.translate(confirmButtonText).message
|
||||
headerFX.text = IntegratedLanguage.LANGUAGE.translate(header)
|
||||
descriptionFX.text = description?.let { IntegratedLanguage.LANGUAGE.translate(it) } ?: ChatComponent.EMPTY
|
||||
cancelButtonFX.text = IntegratedLanguage.LANGUAGE.translate(cancelButtonText).message
|
||||
confirmButtonFX.text = IntegratedLanguage.LANGUAGE.translate(confirmButtonText).message
|
||||
}
|
||||
|
||||
override fun postInit() {
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Minosoft
|
||||
* Copyright (C) 2020-2022 Moritz Zwerger
|
||||
* Copyright (C) 2020-2023 Moritz Zwerger
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
@ -14,7 +14,7 @@
|
||||
package de.bixilon.minosoft.gui.eros.dialog
|
||||
|
||||
import de.bixilon.kutil.concurrent.pool.DefaultThreadPool
|
||||
import de.bixilon.minosoft.Minosoft
|
||||
import de.bixilon.minosoft.data.language.IntegratedLanguage
|
||||
import de.bixilon.minosoft.data.text.ChatComponent
|
||||
import de.bixilon.minosoft.gui.eros.controller.DialogController
|
||||
import de.bixilon.minosoft.gui.eros.util.JavaFXUtil
|
||||
@ -47,9 +47,9 @@ class SimpleErosWarningDialog(
|
||||
}
|
||||
|
||||
override fun init() {
|
||||
headerFX.text = Minosoft.LANGUAGE_MANAGER.translate(header)
|
||||
descriptionFX.text = description?.let { Minosoft.LANGUAGE_MANAGER.translate(it) } ?: ChatComponent.EMPTY
|
||||
ignoreButtonFX.text = Minosoft.LANGUAGE_MANAGER.translate(ignoreButtonText).message
|
||||
headerFX.text = IntegratedLanguage.LANGUAGE.translate(header)
|
||||
descriptionFX.text = description?.let { IntegratedLanguage.LANGUAGE.translate(it) } ?: ChatComponent.EMPTY
|
||||
ignoreButtonFX.text = IntegratedLanguage.LANGUAGE.translate(ignoreButtonText).message
|
||||
}
|
||||
|
||||
override fun postInit() {
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Minosoft
|
||||
* Copyright (C) 2020-2022 Moritz Zwerger
|
||||
* Copyright (C) 2020-2023 Moritz Zwerger
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
@ -13,7 +13,7 @@
|
||||
|
||||
package de.bixilon.minosoft.gui.eros.dialog.connection
|
||||
|
||||
import de.bixilon.minosoft.Minosoft
|
||||
import de.bixilon.minosoft.data.language.IntegratedLanguage
|
||||
import de.bixilon.minosoft.data.text.ChatComponent
|
||||
import de.bixilon.minosoft.gui.eros.controller.DialogController
|
||||
import de.bixilon.minosoft.gui.eros.util.JavaFXUtil
|
||||
@ -44,8 +44,8 @@ class KickDialog(
|
||||
|
||||
|
||||
override fun init() {
|
||||
headerFX.text = Minosoft.LANGUAGE_MANAGER.translate(header)
|
||||
descriptionFX.text = description?.let { Minosoft.LANGUAGE_MANAGER.translate(it) } ?: ChatComponent.EMPTY
|
||||
headerFX.text = IntegratedLanguage.LANGUAGE.translate(header)
|
||||
descriptionFX.text = description?.let { IntegratedLanguage.LANGUAGE.translate(it) } ?: ChatComponent.EMPTY
|
||||
reasonFX.text = reason
|
||||
|
||||
reconnectButtonFX.isDisable = true // ToDo
|
||||
|
@ -15,9 +15,9 @@ package de.bixilon.minosoft.gui.eros.dialog.profiles
|
||||
|
||||
import de.bixilon.kutil.cast.CastUtil.nullCast
|
||||
import de.bixilon.kutil.cast.CastUtil.unsafeCast
|
||||
import de.bixilon.minosoft.Minosoft
|
||||
import de.bixilon.minosoft.config.profile.ProfileType
|
||||
import de.bixilon.minosoft.config.profile.manager.ProfileManagers
|
||||
import de.bixilon.minosoft.data.language.IntegratedLanguage
|
||||
import de.bixilon.minosoft.data.language.translate.Translatable
|
||||
import de.bixilon.minosoft.data.registries.identified.Identified
|
||||
import de.bixilon.minosoft.data.registries.identified.Namespaces.i18n
|
||||
@ -57,7 +57,7 @@ class ProfileSelectDialog(
|
||||
}
|
||||
|
||||
override fun init() {
|
||||
headerFX.text = Minosoft.LANGUAGE_MANAGER.forceTranslate(HEADER)
|
||||
headerFX.text = IntegratedLanguage.LANGUAGE.forceTranslate(HEADER)
|
||||
|
||||
typeColumnFX.ctext = TYPE_COLUMN_TITLE
|
||||
profileColumnFX.ctext = PROFILE_COLUMN_TITLE
|
||||
|
@ -13,7 +13,7 @@
|
||||
|
||||
package de.bixilon.minosoft.gui.eros.main
|
||||
|
||||
import de.bixilon.minosoft.Minosoft
|
||||
import de.bixilon.minosoft.data.language.IntegratedLanguage
|
||||
import de.bixilon.minosoft.data.registries.identified.ResourceLocation
|
||||
import de.bixilon.minosoft.util.KUtil.format
|
||||
import javafx.geometry.HPos
|
||||
@ -41,7 +41,7 @@ class InfoPane<T>(vararg children: Node) : AnchorPane(*children) {
|
||||
for ((key, property) in properties) {
|
||||
val propertyValue = property(item) ?: continue
|
||||
|
||||
propertiesPane.add(Minosoft.LANGUAGE_MANAGER.forceTranslate(key).textFlow, 0, row)
|
||||
propertiesPane.add(IntegratedLanguage.LANGUAGE.forceTranslate(key).textFlow, 0, row)
|
||||
propertiesPane.add(propertyValue.format().textFlow, 1, row++)
|
||||
}
|
||||
}
|
||||
|
@ -20,13 +20,13 @@ import de.bixilon.kutil.concurrent.pool.runnable.ForcePooledRunnable
|
||||
import de.bixilon.kutil.latch.CallbackLatch
|
||||
import de.bixilon.kutil.observer.map.MapChange.Companion.values
|
||||
import de.bixilon.kutil.primitive.BooleanUtil.decide
|
||||
import de.bixilon.minosoft.Minosoft
|
||||
import de.bixilon.minosoft.config.profile.profiles.eros.ErosProfileManager
|
||||
import de.bixilon.minosoft.data.accounts.Account
|
||||
import de.bixilon.minosoft.data.accounts.AccountStates
|
||||
import de.bixilon.minosoft.data.accounts.types.microsoft.MicrosoftAccount
|
||||
import de.bixilon.minosoft.data.accounts.types.mojang.MojangAccount
|
||||
import de.bixilon.minosoft.data.accounts.types.offline.OfflineAccount
|
||||
import de.bixilon.minosoft.data.language.IntegratedLanguage
|
||||
import de.bixilon.minosoft.data.registries.identified.ResourceLocation
|
||||
import de.bixilon.minosoft.data.text.ChatComponent
|
||||
import de.bixilon.minosoft.data.text.TranslatableComponents
|
||||
@ -184,7 +184,7 @@ class AccountController : EmbeddedJavaFXController<Pane>() {
|
||||
for ((key, property) in ACCOUNT_INFO_PROPERTIES.extend(accountTypeListViewFX.selectionModel.selectedItem.additionalDetails)) { // ToDo
|
||||
val propertyValue = property(account) ?: continue
|
||||
|
||||
it.add(Minosoft.LANGUAGE_MANAGER.forceTranslate(key).textFlow, 0, row)
|
||||
it.add(IntegratedLanguage.LANGUAGE.forceTranslate(key).textFlow, 0, row)
|
||||
it.add(ChatComponent.of(propertyValue).textFlow, 1, row++)
|
||||
}
|
||||
|
||||
|
@ -13,8 +13,8 @@
|
||||
|
||||
package de.bixilon.minosoft.gui.eros.main.account
|
||||
|
||||
import de.bixilon.minosoft.Minosoft
|
||||
import de.bixilon.minosoft.config.profile.profiles.eros.ErosProfileManager
|
||||
import de.bixilon.minosoft.data.language.IntegratedLanguage
|
||||
import de.bixilon.minosoft.gui.eros.card.AbstractCardController
|
||||
import de.bixilon.minosoft.gui.eros.card.CardFactory
|
||||
import de.bixilon.minosoft.gui.eros.util.JavaFXUtil.text
|
||||
@ -41,7 +41,7 @@ class AccountTypeCardController : AbstractCardController<ErosAccountType<*>>() {
|
||||
iconFX.isVisible = true
|
||||
|
||||
iconFX.iconCode = item.icon
|
||||
headerFX.text = Minosoft.LANGUAGE_MANAGER.translate(item)
|
||||
headerFX.text = IntegratedLanguage.LANGUAGE.translate(item)
|
||||
|
||||
recalculate(item)
|
||||
ErosProfileManager.selected.general.accountProfile::entries.observeMapFX(this) { recalculate(item) }
|
||||
|
@ -14,9 +14,9 @@
|
||||
package de.bixilon.minosoft.gui.eros.main.account.add
|
||||
|
||||
import de.bixilon.kutil.latch.CallbackLatch
|
||||
import de.bixilon.minosoft.Minosoft
|
||||
import de.bixilon.minosoft.config.profile.profiles.eros.ErosProfileManager
|
||||
import de.bixilon.minosoft.data.accounts.types.microsoft.MicrosoftAccount
|
||||
import de.bixilon.minosoft.data.language.IntegratedLanguage
|
||||
import de.bixilon.minosoft.gui.eros.controller.JavaFXWindowController
|
||||
import de.bixilon.minosoft.gui.eros.dialog.ErosErrorReport.Companion.report
|
||||
import de.bixilon.minosoft.gui.eros.dialog.PleaseWaitDialog
|
||||
@ -109,7 +109,7 @@ class MicrosoftAddController(
|
||||
companion object {
|
||||
private val LAYOUT = "minosoft:eros/main/account/add/microsoft.fxml".toResourceLocation()
|
||||
private val TITLE = "minosoft:main.account.add.microsoft.title".toResourceLocation()
|
||||
private val HEADER = { link: URL -> Minosoft.LANGUAGE_MANAGER.forceTranslate("minosoft:main.account.add.microsoft.header".toResourceLocation(), link) }
|
||||
private val HEADER = { link: URL -> IntegratedLanguage.LANGUAGE.forceTranslate("minosoft:main.account.add.microsoft.header".toResourceLocation(), link) }
|
||||
private val CANCEL = "minosoft:main.account.add.microsoft.cancel".toResourceLocation()
|
||||
}
|
||||
}
|
||||
|
@ -16,7 +16,7 @@ package de.bixilon.minosoft.gui.eros.main.play.server.card
|
||||
import de.bixilon.kutil.concurrent.pool.DefaultThreadPool
|
||||
import de.bixilon.kutil.primitive.IntUtil.thousands
|
||||
import de.bixilon.kutil.unit.UnitFormatter.formatNanos
|
||||
import de.bixilon.minosoft.Minosoft
|
||||
import de.bixilon.minosoft.data.language.IntegratedLanguage
|
||||
import de.bixilon.minosoft.data.registries.identified.ResourceLocation
|
||||
import de.bixilon.minosoft.data.text.ChatComponent
|
||||
import de.bixilon.minosoft.gui.eros.card.AbstractCardController
|
||||
@ -111,7 +111,7 @@ class ServerCardController : AbstractCardController<ServerCard>() {
|
||||
return@observeFX
|
||||
}
|
||||
|
||||
motdFX.text = ChatComponent.of(Minosoft.LANGUAGE_MANAGER.translate(it))
|
||||
motdFX.text = ChatComponent.of(IntegratedLanguage.LANGUAGE.translate(it))
|
||||
serverList?.onPingUpdate(item)
|
||||
resetPing()
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Minosoft
|
||||
* Copyright (C) 2021 Moritz Zwerger
|
||||
* Copyright (C) 2020-2023 Moritz Zwerger
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
@ -13,7 +13,7 @@
|
||||
|
||||
package de.bixilon.minosoft.gui.eros.main.play.server.type
|
||||
|
||||
import de.bixilon.minosoft.Minosoft
|
||||
import de.bixilon.minosoft.data.language.IntegratedLanguage
|
||||
import de.bixilon.minosoft.gui.eros.card.AbstractCardController
|
||||
import de.bixilon.minosoft.gui.eros.card.CardFactory
|
||||
import de.bixilon.minosoft.gui.eros.main.play.server.type.types.ServerType
|
||||
@ -41,7 +41,7 @@ class ServerTypeCardController : AbstractCardController<ServerType>() {
|
||||
|
||||
|
||||
iconFX.iconCode = item.icon
|
||||
headerFX.text = Minosoft.LANGUAGE_MANAGER.translate(item)
|
||||
headerFX.text = IntegratedLanguage.LANGUAGE.translate(item)
|
||||
|
||||
recalculate(item)
|
||||
item::servers.observeListFX(this) { recalculate(item) }
|
||||
|
@ -17,9 +17,9 @@ import de.bixilon.kutil.cast.CastUtil.unsafeCast
|
||||
import de.bixilon.kutil.collections.map.bi.AbstractMutableBiMap
|
||||
import de.bixilon.kutil.observer.map.MapChange
|
||||
import de.bixilon.kutil.observer.map.bi.BiMapObserver.Companion.observeBiMap
|
||||
import de.bixilon.minosoft.Minosoft
|
||||
import de.bixilon.minosoft.config.profile.profiles.Profile
|
||||
import de.bixilon.minosoft.config.profile.storage.StorageProfileManager
|
||||
import de.bixilon.minosoft.data.language.IntegratedLanguage
|
||||
import de.bixilon.minosoft.gui.eros.card.AbstractCardController
|
||||
import de.bixilon.minosoft.gui.eros.card.CardFactory
|
||||
import de.bixilon.minosoft.gui.eros.util.JavaFXUtil
|
||||
@ -47,7 +47,7 @@ class ProfilesTypeCardController : AbstractCardController<StorageProfileManager<
|
||||
iconFX.isVisible = true
|
||||
|
||||
iconFX.iconCode = item.type.icon
|
||||
headerFX.text = Minosoft.LANGUAGE_MANAGER.forceTranslate(item.type.identifier)
|
||||
headerFX.text = IntegratedLanguage.LANGUAGE.forceTranslate(item.type.identifier)
|
||||
|
||||
recalculate(item)
|
||||
item::profiles.observeBiMapFX(this) { recalculate(item) }
|
||||
|
@ -20,9 +20,9 @@ import de.bixilon.kutil.exception.ExceptionUtil.catchAll
|
||||
import de.bixilon.kutil.reflection.ReflectionUtil.forceSet
|
||||
import de.bixilon.kutil.reflection.ReflectionUtil.jvmField
|
||||
import de.bixilon.kutil.url.URLUtil.toURL
|
||||
import de.bixilon.minosoft.Minosoft
|
||||
import de.bixilon.minosoft.assets.IntegratedAssets
|
||||
import de.bixilon.minosoft.config.profile.profiles.eros.ErosProfileManager
|
||||
import de.bixilon.minosoft.data.language.IntegratedLanguage
|
||||
import de.bixilon.minosoft.data.registries.identified.Namespaces.minosoft
|
||||
import de.bixilon.minosoft.data.registries.identified.ResourceLocation
|
||||
import de.bixilon.minosoft.gui.eros.controller.EmbeddedJavaFXController
|
||||
@ -86,7 +86,7 @@ object JavaFXUtil {
|
||||
private fun <T : JavaFXController> loadController(title: Any, fxmlLoader: FXMLLoader, parent: Parent, modality: Modality = Modality.WINDOW_MODAL): T {
|
||||
val stage = Stage()
|
||||
stage.initModality(modality)
|
||||
stage.title = Minosoft.LANGUAGE_MANAGER.translate(title).message
|
||||
stage.title = IntegratedLanguage.LANGUAGE.translate(title).message
|
||||
stage.scene = Scene(parent)
|
||||
stage.icons.setAll(MINOSOFT_LOGO)
|
||||
|
||||
@ -148,31 +148,31 @@ object JavaFXUtil {
|
||||
var TextFlow.text: Any?
|
||||
get() = TODO("Can not get the text of a TextFlow (yet)")
|
||||
set(value) {
|
||||
this.children.setAll(Minosoft.LANGUAGE_MANAGER.translate(value).javaFXText)
|
||||
this.children.setAll(IntegratedLanguage.LANGUAGE.translate(value).javaFXText)
|
||||
}
|
||||
|
||||
var TextField.placeholder: Any?
|
||||
get() = this.promptText
|
||||
set(value) {
|
||||
this.promptText = Minosoft.LANGUAGE_MANAGER.translate(value).message
|
||||
this.promptText = IntegratedLanguage.LANGUAGE.translate(value).message
|
||||
}
|
||||
|
||||
var Labeled.ctext: Any?
|
||||
get() = this.text
|
||||
set(value) {
|
||||
this.text = Minosoft.LANGUAGE_MANAGER.translate(value).message
|
||||
this.text = IntegratedLanguage.LANGUAGE.translate(value).message
|
||||
}
|
||||
|
||||
var TableColumnBase<*, *>.ctext: Any?
|
||||
get() = this.text
|
||||
set(value) {
|
||||
this.text = Minosoft.LANGUAGE_MANAGER.translate(value).message
|
||||
this.text = IntegratedLanguage.LANGUAGE.translate(value).message
|
||||
}
|
||||
|
||||
var Text.ctext: Any?
|
||||
get() = this.text
|
||||
set(value) {
|
||||
this.text = Minosoft.LANGUAGE_MANAGER.translate(value).message
|
||||
this.text = IntegratedLanguage.LANGUAGE.translate(value).message
|
||||
}
|
||||
|
||||
fun Text.hyperlink(link: String) {
|
||||
|
@ -13,14 +13,14 @@
|
||||
|
||||
package de.bixilon.minosoft.gui.eros.util.cell
|
||||
|
||||
import de.bixilon.minosoft.Minosoft
|
||||
import de.bixilon.minosoft.data.language.IntegratedLanguage
|
||||
import de.bixilon.minosoft.data.registries.identified.Namespaces.i18n
|
||||
import de.bixilon.minosoft.protocol.versions.Version
|
||||
import de.bixilon.minosoft.protocol.versions.Versions
|
||||
|
||||
class VersionListCell : LabeledListCell<Version>({
|
||||
if (it == Versions.AUTOMATIC) {
|
||||
Minosoft.LANGUAGE_MANAGER.forceTranslate(AUTOMATIC)
|
||||
IntegratedLanguage.LANGUAGE.forceTranslate(AUTOMATIC)
|
||||
} else {
|
||||
"${it.name} (${it.type.name.lowercase()})"
|
||||
}
|
||||
|
@ -16,7 +16,7 @@ package de.bixilon.minosoft.gui.rendering.gui.elements.text
|
||||
import de.bixilon.kotlinglm.vec2.Vec2
|
||||
import de.bixilon.kutil.cast.CastUtil.unsafeNull
|
||||
import de.bixilon.kutil.exception.Broken
|
||||
import de.bixilon.minosoft.Minosoft
|
||||
import de.bixilon.minosoft.data.language.IntegratedLanguage
|
||||
import de.bixilon.minosoft.data.text.ChatComponent
|
||||
import de.bixilon.minosoft.data.text.EmptyComponent
|
||||
import de.bixilon.minosoft.data.text.TextComponent
|
||||
@ -81,7 +81,7 @@ open class TextElement(
|
||||
|
||||
override var text: Any = text
|
||||
set(value) {
|
||||
chatComponent = ChatComponent.of(value, translator = Minosoft.LANGUAGE_MANAGER /*guiRenderer.connection.language*/) // Should the server be allowed to send minosoft namespaced translation keys?
|
||||
chatComponent = ChatComponent.of(value, translator = IntegratedLanguage.LANGUAGE /*guiRenderer.connection.language*/) // Should the server be allowed to send minosoft namespaced translation keys?
|
||||
field = value
|
||||
}
|
||||
|
||||
|
55
src/main/java/de/bixilon/minosoft/main/MinosoftBoot.kt
Normal file
55
src/main/java/de/bixilon/minosoft/main/MinosoftBoot.kt
Normal file
@ -0,0 +1,55 @@
|
||||
/*
|
||||
* Minosoft
|
||||
* Copyright (C) 2020-2023 Moritz Zwerger
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
|
||||
*/
|
||||
|
||||
package de.bixilon.minosoft.main
|
||||
|
||||
import de.bixilon.kutil.concurrent.pool.ThreadPool
|
||||
import de.bixilon.kutil.concurrent.worker.task.TaskWorker
|
||||
import de.bixilon.kutil.concurrent.worker.task.WorkerTask
|
||||
import de.bixilon.kutil.latch.CallbackLatch
|
||||
import de.bixilon.minosoft.assets.IntegratedAssets
|
||||
import de.bixilon.minosoft.assets.meta.MinosoftMeta
|
||||
import de.bixilon.minosoft.assets.properties.version.AssetsVersionProperties
|
||||
import de.bixilon.minosoft.config.profile.manager.ProfileManagers
|
||||
import de.bixilon.minosoft.data.entities.event.EntityEvents
|
||||
import de.bixilon.minosoft.data.registries.fallback.FallbackRegistries
|
||||
import de.bixilon.minosoft.data.registries.fallback.tags.FallbackTags
|
||||
import de.bixilon.minosoft.datafixer.DataFixer
|
||||
import de.bixilon.minosoft.modding.loader.LoadingPhases
|
||||
import de.bixilon.minosoft.modding.loader.ModLoader
|
||||
import de.bixilon.minosoft.protocol.protocol.LANServerListener
|
||||
import de.bixilon.minosoft.protocol.versions.VersionLoader
|
||||
import de.bixilon.minosoft.terminal.cli.CLI
|
||||
import de.bixilon.minosoft.util.yggdrasil.YggdrasilUtil
|
||||
|
||||
object MinosoftBoot {
|
||||
val LATCH = CallbackLatch(1)
|
||||
|
||||
fun register(worker: TaskWorker) {
|
||||
worker += WorkerTask(identifier = BootTasks.VERSIONS, priority = ThreadPool.HIGHER, executor = VersionLoader::load)
|
||||
worker += WorkerTask(identifier = BootTasks.PROFILES, priority = ThreadPool.HIGHEST, executor = ProfileManagers::load)
|
||||
|
||||
worker += WorkerTask(identifier = BootTasks.ASSETS_PROPERTIES, dependencies = arrayOf(BootTasks.VERSIONS), executor = AssetsVersionProperties::load)
|
||||
worker += WorkerTask(identifier = BootTasks.DEFAULT_REGISTRIES, dependencies = arrayOf(BootTasks.VERSIONS), executor = { MinosoftMeta.load(); FallbackTags.load(); FallbackRegistries.load(); EntityEvents.load() })
|
||||
|
||||
|
||||
worker += WorkerTask(identifier = BootTasks.LAN_SERVERS, dependencies = arrayOf(BootTasks.PROFILES), executor = LANServerListener::listen)
|
||||
|
||||
worker += WorkerTask(identifier = BootTasks.YGGDRASIL, executor = { YggdrasilUtil.load() })
|
||||
|
||||
worker += WorkerTask(identifier = BootTasks.ASSETS_OVERRIDE, executor = { IntegratedAssets.OVERRIDE.load(it) })
|
||||
worker += WorkerTask(identifier = BootTasks.MODS, executor = { ModLoader.load(LoadingPhases.BOOT, it) })
|
||||
worker += WorkerTask(identifier = BootTasks.DATA_FIXER, executor = { DataFixer.load() })
|
||||
worker += WorkerTask(identifier = BootTasks.CLI, priority = ThreadPool.LOW, executor = CLI::startThread)
|
||||
}
|
||||
}
|
@ -20,9 +20,9 @@ import de.bixilon.kutil.observer.DataObserver.Companion.observed
|
||||
import de.bixilon.kutil.shutdown.AbstractShutdownReason
|
||||
import de.bixilon.kutil.shutdown.ShutdownManager
|
||||
import de.bixilon.kutil.string.WhitespaceUtil.trimWhitespaces
|
||||
import de.bixilon.minosoft.Minosoft
|
||||
import de.bixilon.minosoft.commands.errors.ReaderError
|
||||
import de.bixilon.minosoft.commands.nodes.RootNode
|
||||
import de.bixilon.minosoft.main.MinosoftBoot
|
||||
import de.bixilon.minosoft.protocol.network.connection.play.PlayConnection
|
||||
import de.bixilon.minosoft.terminal.commands.Commands
|
||||
import de.bixilon.minosoft.terminal.commands.connection.ConnectionCommand
|
||||
@ -70,7 +70,7 @@ object CLI {
|
||||
|
||||
this::connection.observe(this) { register() }
|
||||
|
||||
Minosoft.BOOT_LATCH.await()
|
||||
MinosoftBoot.LATCH.await()
|
||||
|
||||
Log.log(LogMessageType.OTHER, LogLevels.INFO) { "§aA headless input system is available, §epress tab§a or type §ehelp§a to see all available commands!" }
|
||||
reader.pollLines()
|
||||
|
Loading…
x
Reference in New Issue
Block a user