diff --git a/src/net/torvald/terrarum/modulebasegame/console/SetBulletin.kt b/src/net/torvald/terrarum/modulebasegame/console/SetBulletin.kt index ca8412413..312c29013 100644 --- a/src/net/torvald/terrarum/modulebasegame/console/SetBulletin.kt +++ b/src/net/torvald/terrarum/modulebasegame/console/SetBulletin.kt @@ -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) { //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 ...") } } diff --git a/src/net/torvald/terrarum/modulebasegame/ui/Notification.kt b/src/net/torvald/terrarum/modulebasegame/ui/Notification.kt index 264174009..af335e116 100644 --- a/src/net/torvald/terrarum/modulebasegame/ui/Notification.kt +++ b/src/net/torvald/terrarum/modulebasegame/ui/Notification.kt @@ -36,6 +36,7 @@ class Notification : UICanvas() { internal var message: List = 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 diff --git a/src/net/torvald/terrarum/ui/Toolkit.kt b/src/net/torvald/terrarum/ui/Toolkit.kt index a158c610a..b96397eff 100644 --- a/src/net/torvald/terrarum/ui/Toolkit.kt +++ b/src/net/torvald/terrarum/ui/Toolkit.kt @@ -147,12 +147,15 @@ object Toolkit : Disposable { fun fillCircle(batch: SpriteBatch, x: Int, y: Int, w: Int, h: Int) { batch.draw(textureWhiteCircle, x.toFloat(), y.toFloat(), w.toFloat(), h.toFloat()) } - fun drawStraightLine(batch: SpriteBatch, x: Int, y: Int, otherEnd: Int, thickness: Int, isVertical: Boolean) { + fun drawStraightLine(batch: SpriteBatch, x: Float, y: Float, otherEnd: Float, thickness: Float, isVertical: Boolean) { if (!isVertical) fillArea(batch, x, y, otherEnd - x, thickness) else fillArea(batch, x, y, thickness, otherEnd - y) } + fun drawStraightLine(batch: SpriteBatch, x: Int, y: Int, otherEnd: Int, thickness: Int, isVertical: Boolean) { + drawStraightLine(batch, x.toFloat(), y.toFloat(), otherEnd.toFloat(), thickness.toFloat(), isVertical) + } fun drawBoxBorder(batch: SpriteBatch, x: Float, y: Float, w: Float, h: Float) = drawBoxBorder(batch, x.roundToInt(), y.roundToInt(), w.roundToInt(), h.roundToInt())