mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-16 10:55:01 -04:00
eros: theming
This commit is contained in:
parent
3368ae4a72
commit
32e45bd017
@ -7,6 +7,7 @@ import de.bixilon.minosoft.config.profile.profiles.eros.ErosProfileManager.lates
|
||||
import de.bixilon.minosoft.config.profile.profiles.eros.general.GeneralC
|
||||
import de.bixilon.minosoft.config.profile.profiles.eros.server.ServerC
|
||||
import de.bixilon.minosoft.config.profile.profiles.eros.text.TextC
|
||||
import de.bixilon.minosoft.config.profile.profiles.eros.theme.ThemeC
|
||||
import de.bixilon.minosoft.util.KUtil.unsafeCast
|
||||
|
||||
/**
|
||||
@ -26,6 +27,7 @@ class ErosProfile(
|
||||
|
||||
|
||||
val general = GeneralC()
|
||||
val theme = ThemeC()
|
||||
val server = ServerC()
|
||||
val text = TextC()
|
||||
|
||||
|
@ -0,0 +1,12 @@
|
||||
package de.bixilon.minosoft.config.profile.profiles.eros.theme
|
||||
|
||||
import de.bixilon.minosoft.config.profile.profiles.eros.ErosProfileManager.delegate
|
||||
|
||||
class ThemeC {
|
||||
|
||||
/**
|
||||
* Name of the theme css file
|
||||
* Located in minosoft:eros/themes/<name>.css
|
||||
*/
|
||||
var theme by delegate("default")
|
||||
}
|
@ -13,7 +13,10 @@
|
||||
|
||||
package de.bixilon.minosoft.gui.eros.util
|
||||
|
||||
import com.sun.javafx.util.WeakReferenceQueue
|
||||
import de.bixilon.minosoft.Minosoft
|
||||
import de.bixilon.minosoft.config.profile.delegate.watcher.SimpleProfileDelegateWatcher.Companion.profileWatchFX
|
||||
import de.bixilon.minosoft.config.profile.profiles.eros.ErosProfileManager
|
||||
import de.bixilon.minosoft.data.registries.ResourceLocation
|
||||
import de.bixilon.minosoft.gui.eros.controller.EmbeddedJavaFXController
|
||||
import de.bixilon.minosoft.gui.eros.controller.JavaFXController
|
||||
@ -39,11 +42,33 @@ import java.net.CookieManager
|
||||
import kotlin.reflect.jvm.javaField
|
||||
|
||||
object JavaFXUtil {
|
||||
private const val DEFAULT_STYLE = "resource:minosoft:eros/style.css"
|
||||
private val stages: WeakReferenceQueue<Stage> = WeakReferenceQueue()
|
||||
lateinit var JAVA_FX_THREAD: Thread
|
||||
lateinit var MINOSOFT_LOGO: Image
|
||||
lateinit var HOST_SERVICES: HostServices
|
||||
private var watchingTheme = false
|
||||
|
||||
private fun startThemeWatcher() {
|
||||
if (watchingTheme) {
|
||||
return
|
||||
}
|
||||
|
||||
ErosProfileManager.selected.theme::theme.profileWatchFX(this) {
|
||||
stages.cleanup()
|
||||
for (stage in stages.iterator() as Iterator<Stage?>) {
|
||||
stage ?: continue
|
||||
stage.scene.stylesheets.clear()
|
||||
stage.scene.stylesheets.add(DEFAULT_STYLE)
|
||||
val theme = ErosProfileManager.selected.theme.theme
|
||||
stage.scene.stylesheets.add("resource:minosoft:eros/themes/$theme.css")
|
||||
}
|
||||
}
|
||||
watchingTheme = true
|
||||
}
|
||||
|
||||
fun <T : JavaFXController> openModal(title: Any, layout: ResourceLocation, controller: T? = null, modality: Modality = Modality.WINDOW_MODAL): T {
|
||||
startThemeWatcher()
|
||||
val fxmlLoader = FXMLLoader()
|
||||
controller?.let { fxmlLoader.setController(it) }
|
||||
val parent: Parent = fxmlLoader.load(Minosoft.MINOSOFT_ASSETS_MANAGER.readAssetAsStream(layout))
|
||||
@ -54,7 +79,12 @@ object JavaFXUtil {
|
||||
stage.scene = Scene(parent)
|
||||
stage.icons.setAll(MINOSOFT_LOGO)
|
||||
|
||||
stage.scene.stylesheets.add("resource:minosoft:eros/style.css")
|
||||
stage.scene.stylesheets.add(DEFAULT_STYLE)
|
||||
val theme = ErosProfileManager.selected.theme.theme
|
||||
stage.scene.stylesheets.add("resource:minosoft:eros/themes/$theme.css")
|
||||
|
||||
stages.cleanup()
|
||||
stages.add(stage)
|
||||
|
||||
val controller: T = fxmlLoader.getController()
|
||||
|
||||
|
8
src/main/resources/assets/minosoft/eros/themes/green.css
Normal file
8
src/main/resources/assets/minosoft/eros/themes/green.css
Normal file
@ -0,0 +1,8 @@
|
||||
|
||||
* {
|
||||
-primary-color: #13d349;
|
||||
-primary-light-color: #66ff7a;
|
||||
-primary-dark-color: #00a012;
|
||||
-primary-text-color: #000000;
|
||||
}
|
||||
|
8
src/main/resources/assets/minosoft/eros/themes/red.css
Normal file
8
src/main/resources/assets/minosoft/eros/themes/red.css
Normal file
@ -0,0 +1,8 @@
|
||||
|
||||
* {
|
||||
-primary-color: #d33324;
|
||||
-primary-light-color: #ff684e;
|
||||
-primary-dark-color: #9a0000;
|
||||
-primary-text-color: #000000;
|
||||
}
|
||||
|
@ -0,0 +1,8 @@
|
||||
|
||||
* {
|
||||
-primary-color: #e8da1a;
|
||||
-primary-light-color: #ffff5a;
|
||||
-primary-dark-color: #b2a900;
|
||||
-primary-text-color: #000000;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user