remaining time gauge for notifier

This commit is contained in:
minjaesong
2023-10-21 02:47:55 +09:00
parent 6634a8dccb
commit d57f23d4f1
3 changed files with 24 additions and 4 deletions

View File

@@ -2,6 +2,7 @@ package net.torvald.terrarum.modulebasegame.console
import net.torvald.terrarum.Terrarum
import net.torvald.terrarum.console.ConsoleCommand
import net.torvald.terrarum.console.Echo
import net.torvald.terrarum.modulebasegame.TerrarumIngame
/**
@@ -11,12 +12,17 @@ internal object SetBulletin : ConsoleCommand {
override fun execute(args: Array<String>) {
//send(Lang["ERROR_SAVE_CORRUPTED"], Lang["MENU_LABEL_CONTINUE_QUESTION"])
(Terrarum.ingame!! as TerrarumIngame).sendNotification(args.sliceArray(1..args.lastIndex))
println("sent notifinator")
if (args.size >= 2) {
(Terrarum.ingame!! as TerrarumIngame).sendNotification(args.sliceArray(1..args.lastIndex))
println("sent notifinator")
}
else {
printUsage()
}
}
override fun printUsage() {
Echo("Usage: Setbulletin msg1 msg2 ...")
}
}

View File

@@ -36,6 +36,7 @@ class Notification : UICanvas() {
internal var message: List<String> = listOf("")
private val timeGaugeCol = Color(0x707070ff)
init {
}
@@ -68,6 +69,16 @@ class Notification : UICanvas() {
Toolkit.drawBaloon(batch, 0f, -textHeight, displayedTextWidth.toFloat(), textHeight, handler.opacity * OPACITY)
// draw time gauge
if (displayTimer != 0f) {
batch.color = timeGaugeCol
val time = 1f - (displayTimer / visibleTime)
val bw = displayedTextWidth * time
val bx = (displayedTextWidth - bw) / 2
Toolkit.drawStraightLine(batch, bx, 2f, bx + bw, 2f, false)
}
// draw texts
batch.color = fontCol
message.forEachIndexed { index, s ->
val xoff = 6 + (displayedTextWidth - realTextWidth) / 2