eros: css loading, wip styling

This commit is contained in:
Bixilon 2021-08-01 13:33:45 +02:00
parent aa50a62b0e
commit 9aed7e9e03
No known key found for this signature in database
GPG Key ID: 5CAD791931B09AC4
6 changed files with 165 additions and 14 deletions

View File

@ -123,7 +123,6 @@ open class TextComponent(
override fun getJavaFXText(nodes: ObservableList<Node>): ObservableList<Node> {
val text = Text(this.message)
this.color?.let {
text.fill = Color.WHITE
if (Minosoft.config.config.chat.colored) {
text.fill = Color.rgb(it.red, it.green, it.blue)
}

View File

@ -49,6 +49,8 @@ object JavaFXUtil {
stage.scene = Scene(parent)
stage.icons.setAll(MINOSOFT_LOGO)
stage.scene.stylesheets.add("resource:minosoft:eros/style.css")
val controller: T = fxmlLoader.getController()
if (controller is JavaFXWindowController) {

View File

@ -0,0 +1,57 @@
/*
* Minosoft
* Copyright (C) 2021 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.util
import de.bixilon.minosoft.Minosoft
import de.bixilon.minosoft.data.registries.ResourceLocation
import java.io.InputStream
import java.net.URL
import java.net.URLConnection
import java.net.URLStreamHandler
import java.net.URLStreamHandlerFactory
object ResourceURLHandler {
init {
URL.setURLStreamHandlerFactory(ResourceURLStreamHandlerFactory)
}
private object ResourceStreamHandler : URLStreamHandler() {
override fun openConnection(url: URL?): URLConnection {
return ResourceURLConnection(url)
}
}
private object ResourceURLStreamHandlerFactory : URLStreamHandlerFactory {
override fun createURLStreamHandler(protocol: String): URLStreamHandler? {
if (protocol == "resource") {
return ResourceStreamHandler
}
return null
}
}
private class ResourceURLConnection(url: URL?) : URLConnection(url) {
override fun connect() {
}
override fun getInputStream(): InputStream {
return Minosoft.MINOSOFT_ASSETS_MANAGER.readAssetAsStream(ResourceLocation(url.path))
}
}
}

View File

@ -288,6 +288,7 @@ public final class Util {
public static void initUtilClasses() {
forceClassInit(Log.class);
forceClassInit(ResourceURLHandler.class);
forceClassInit(MicrosoftOAuthUtils.class);
forceClassInit(TimeWorker.class);
}

View File

@ -20,9 +20,7 @@ import de.bixilon.minosoft.terminal.RunConfiguration
import de.bixilon.minosoft.util.HTTP
import de.bixilon.minosoft.util.Util
import de.bixilon.minosoft.util.logging.Log
import java.net.URL
import java.net.URLConnection
import java.net.URLStreamHandler
object MicrosoftOAuthUtils {
val NULL_URL_CONNECTION: URLConnection = object : URLConnection(null) {
@ -166,16 +164,17 @@ object MicrosoftOAuthUtils {
}
init {
URL.setURLStreamHandlerFactory {
if (it == "ms-xal-" + ProtocolDefinition.MICROSOFT_ACCOUNT_APPLICATION_ID) {
return@setURLStreamHandlerFactory object : URLStreamHandler() {
override fun openConnection(url: URL): URLConnection {
loginToMicrosoftAccount(Util.urlQueryToMap(url.query)["code"]!!)
return NULL_URL_CONNECTION
}
}
}
return@setURLStreamHandlerFactory null
}
// ToDo
// URL.setURLStreamHandlerFactory {
// if (it == "ms-xal-" + ProtocolDefinition.MICROSOFT_ACCOUNT_APPLICATION_ID) {
// return@setURLStreamHandlerFactory object : URLStreamHandler() {
// override fun openConnection(url: URL): URLConnection {
// loginToMicrosoftAccount(Util.urlQueryToMap(url.query)["code"]!!)
// return NULL_URL_CONNECTION
// }
// }
// }
// return@setURLStreamHandlerFactory null
// }
}
}

View File

@ -0,0 +1,93 @@
/*
* Minosoft
* Copyright (C) 2021 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.
*/
* {
-primary-color: #448aff;
-primary-light-color: #83b9ff;
-primary-dark-color: #005ecb;
-secondary-color: #2c3746;
-secondary-light-color: #566171;
-secondary-dark-color: #03111f;
-primary-text-color: #000000;
-secondary-text-color: #ffffff;
-secondary-light-light-color: #868191;
}
.root {
-fx-background-color: -secondary-color;
-fx-text-fill: -secondary-text-color;
}
.label {
-fx-text-fill: -secondary-text-color;
}
.combo-box .list-cell {
-fx-background: -secondary-color;
-fx-background-color: transparent;
-fx-text-fill: -secondary-text-color;
}
.combo-box-popup .list-view {
-fx-background-color: -secondary-color;
}
.combo-box-popup .list-view .list-cell:filled:selected, .combo-box-popup .list-view .list-cell:filled:selected:hover {
-fx-background: -primary-light-color;
-fx-background-color: -secondary-dark-color;
-fx-text-fill: -secondary-text-color;
}
.combo-box-popup .list-view .list-cell:filled:hover {
-fx-background-color: -secondary-light-color;
-fx-text-fill: -secondary-text-color;
}
.combo-box-base {
-fx-background-color: -secondary-color;
}
.list-cell {
-fx-border-width: 3px;
-fx-background-color: -secondary-color;
}
.list-cell:selected {
-fx-background-color: -secondary-color;
}
.list-cell:filled:hover {
-fx-background-color: -secondary-light-color;
}
.list-view {
-fx-background-color: -secondary-color;
}
.obfuscated {
-fx-font-family: "Hack";
}
.button {
-fx-background-color: -primary-color;
-fx-text-fill: -secondary-text-color;
}
.check-box {
-fx-text-fill: -secondary-text-color;
}
.ikonli-font-icon {
-fx-icon-color: -primary-light-color;
}