mirror of
https://github.com/mamoe/mirai.git
synced 2025-01-26 16:10:11 +08:00
Graphical log color
This commit is contained in:
parent
62e71ef3a5
commit
25083f8b2e
@ -27,7 +27,7 @@ class MiraiGraphicalUIController : Controller(), MiraiConsoleUI {
|
|||||||
private val settingModel = find<GlobalSettingModel>()
|
private val settingModel = find<GlobalSettingModel>()
|
||||||
private val loginSolver = GraphicalLoginSolver()
|
private val loginSolver = GraphicalLoginSolver()
|
||||||
private val cache = mutableMapOf<Long, BotModel>()
|
private val cache = mutableMapOf<Long, BotModel>()
|
||||||
val mainLog = observableListOf<String>()
|
val mainLog = observableListOf<Pair<String, String>>()
|
||||||
|
|
||||||
|
|
||||||
val botList = observableListOf<BotModel>()
|
val botList = observableListOf<BotModel>()
|
||||||
@ -69,7 +69,7 @@ class MiraiGraphicalUIController : Controller(), MiraiConsoleUI {
|
|||||||
} else {
|
} else {
|
||||||
cache[identity]?.logHistory
|
cache[identity]?.logHistory
|
||||||
}?.apply {
|
}?.apply {
|
||||||
add("[$time] $identityStr $message")
|
add("[$time] $identityStr $message" to priority.name)
|
||||||
trim()
|
trim()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,7 @@ class BotModel(val uin: Long) {
|
|||||||
val botProperty = SimpleObjectProperty<Bot>(null)
|
val botProperty = SimpleObjectProperty<Bot>(null)
|
||||||
var bot: Bot by botProperty
|
var bot: Bot by botProperty
|
||||||
|
|
||||||
val logHistory = observableListOf<String>()
|
val logHistory = observableListOf<Pair<String, String>>()
|
||||||
val admins = observableListOf<Long>()
|
val admins = observableListOf<Long>()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -124,6 +124,15 @@ class PrimaryStyleSheet : BaseStyleSheet() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
listCell {
|
listCell {
|
||||||
|
|
||||||
|
and(":WARNING") {
|
||||||
|
backgroundColor += c("FFFF00", 0.3) // Yellow
|
||||||
|
}
|
||||||
|
|
||||||
|
and(":ERROR") {
|
||||||
|
backgroundColor += c("FF0000", 0.3) // Red
|
||||||
|
}
|
||||||
|
|
||||||
and(":selected") {
|
and(":selected") {
|
||||||
backgroundColor += c(stressColor, 1.0)
|
backgroundColor += c(stressColor, 1.0)
|
||||||
}
|
}
|
||||||
|
@ -151,7 +151,7 @@ private fun TabPane.fixedTab(title: String) = tab(title) { isClosable = false }
|
|||||||
|
|
||||||
private fun TabPane.logTab(
|
private fun TabPane.logTab(
|
||||||
text: String? = null,
|
text: String? = null,
|
||||||
logs: ObservableList<String>,
|
logs: ObservableList<Pair<String, String>>,
|
||||||
closeable: Boolean = true,
|
closeable: Boolean = true,
|
||||||
op: Tab.() -> Unit = {}
|
op: Tab.() -> Unit = {}
|
||||||
) = tab(text) {
|
) = tab(text) {
|
||||||
@ -174,7 +174,7 @@ private fun TabPane.logTab(
|
|||||||
path.firstOrNull()?.run {
|
path.firstOrNull()?.run {
|
||||||
if (!exists()) createNewFile()
|
if (!exists()) createNewFile()
|
||||||
writer().use {
|
writer().use {
|
||||||
logs.forEach { log -> it.appendln(log) }
|
logs.forEach { log -> it.appendln(log.first) }
|
||||||
}
|
}
|
||||||
true
|
true
|
||||||
} ?: false
|
} ?: false
|
||||||
@ -188,7 +188,10 @@ private fun TabPane.logTab(
|
|||||||
|
|
||||||
fitToParentSize()
|
fitToParentSize()
|
||||||
cellFormat {
|
cellFormat {
|
||||||
graphic = label(it) {
|
|
||||||
|
addPseudoClass(it.second)
|
||||||
|
|
||||||
|
graphic = label(it.first) {
|
||||||
maxWidthProperty().bind(this@listview.widthProperty())
|
maxWidthProperty().bind(this@listview.widthProperty())
|
||||||
isWrapText = true
|
isWrapText = true
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user