mirror of
https://github.com/mamoe/mirai.git
synced 2025-03-12 22:10:14 +08:00
background
This commit is contained in:
parent
182078679f
commit
bd69e22854
@ -1,14 +1,14 @@
|
||||
package net.mamoe.mirai.console.graphical.styleSheet
|
||||
|
||||
import javafx.scene.layout.BackgroundPosition
|
||||
import javafx.scene.layout.BackgroundRepeat
|
||||
import javafx.scene.layout.BackgroundSize
|
||||
import javafx.scene.paint.Color
|
||||
import net.mamoe.mirai.console.MiraiConsole
|
||||
import tornadofx.*
|
||||
import tornadofx.Stylesheet
|
||||
import tornadofx.cssclass
|
||||
import tornadofx.csselement
|
||||
import java.io.File
|
||||
import kotlin.random.Random
|
||||
|
||||
@OptIn(ExperimentalStdlibApi::class)
|
||||
open class BaseStyleSheet : Stylesheet() {
|
||||
|
||||
companion object {
|
||||
@ -23,7 +23,7 @@ open class BaseStyleSheet : Stylesheet() {
|
||||
val jfxTabPane by cssclass("jfx-tab-pane")
|
||||
val myButtonBar by cssclass("my-button-bar")
|
||||
|
||||
val vbox by csselement("VBox")
|
||||
val vBox by csselement("VBox")
|
||||
}
|
||||
|
||||
init {
|
||||
@ -35,8 +35,10 @@ open class BaseStyleSheet : Stylesheet() {
|
||||
|
||||
jfxTabPane {
|
||||
val bg = File(MiraiConsole.path, "background")
|
||||
if (bg.exists() && bg.isDirectory) {
|
||||
bg.listFiles()!!.randomOrNull()?.also {
|
||||
if (!bg.exists()) bg.mkdir()
|
||||
if (bg.isDirectory) {
|
||||
bg.listFiles()!!.filter { file -> file.extension in listOf("jpg", "jpeg", "png", "gif") }
|
||||
.randomElement()?.also {
|
||||
backgroundImage += it.toURI()
|
||||
backgroundRepeat += BackgroundRepeat.REPEAT to BackgroundRepeat.REPEAT
|
||||
}
|
||||
@ -53,3 +55,9 @@ open class BaseStyleSheet : Stylesheet() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun <T> Collection<T>.randomElement(): T? {
|
||||
if (isEmpty())
|
||||
return null
|
||||
return elementAt(Random.nextInt(size))
|
||||
}
|
@ -1,9 +1,6 @@
|
||||
package net.mamoe.mirai.console.graphical.styleSheet
|
||||
|
||||
import javafx.scene.Cursor
|
||||
import javafx.scene.effect.BlurType
|
||||
import javafx.scene.effect.DropShadow
|
||||
import javafx.scene.paint.Color
|
||||
import javafx.scene.text.FontWeight
|
||||
import tornadofx.*
|
||||
|
||||
@ -40,7 +37,7 @@ class PrimaryStyleSheet : BaseStyleSheet() {
|
||||
* bot list
|
||||
*/
|
||||
rootPane {
|
||||
child(vbox) {
|
||||
child(vBox) {
|
||||
|
||||
backgroundColor += c(primaryColor)
|
||||
// 这个padding有bug,十分神奇
|
||||
@ -75,7 +72,7 @@ class PrimaryStyleSheet : BaseStyleSheet() {
|
||||
jfxTabPane {
|
||||
|
||||
// 日志列表样式
|
||||
vbox {
|
||||
vBox {
|
||||
padding = box(15.px)
|
||||
spacing = 15.px
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ class PrimaryView : View() {
|
||||
|
||||
init {
|
||||
onDoubleClick {
|
||||
tab?.select() ?: (mainTabPane as TabPane).logTab(
|
||||
tab?.select() ?: mainTabPane.logTab(
|
||||
text = item.uin.toString(),
|
||||
logs = item.logHistory
|
||||
).select().also { tab = it }
|
||||
|
@ -38,6 +38,17 @@ class SettingsView : View() {
|
||||
}
|
||||
}
|
||||
|
||||
fieldset("背景目录") {
|
||||
field {
|
||||
jfxTextfield((System.getProperty("user.dir") + "/background/").replace("//", "/")) { isEditable = false }
|
||||
jfxButton("打开目录").action {
|
||||
(System.getProperty("user.dir") + "/background/").replace("//", "/").also { path ->
|
||||
Desktop.getDesktop().takeIf { it.isSupported(Desktop.Action.OPEN) }?.open(File(path))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fieldset("最大日志容量") {
|
||||
field {
|
||||
jfxTextfield().bind(settingModel.maxLogNum)
|
||||
|
Loading…
Reference in New Issue
Block a user