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