mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-13 20:14:05 +09:00
calendar UI
This commit is contained in:
@@ -1,26 +1,17 @@
|
|||||||
package net.torvald.terrarum.modulecomputers.gameactors
|
package net.torvald.terrarum.modulecomputers.gameactors
|
||||||
|
|
||||||
import com.badlogic.gdx.Gdx
|
|
||||||
import com.badlogic.gdx.Input
|
|
||||||
import com.badlogic.gdx.graphics.*
|
|
||||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
|
||||||
import com.badlogic.gdx.graphics.glutils.FrameBuffer
|
|
||||||
import com.badlogic.gdx.utils.Disposable
|
import com.badlogic.gdx.utils.Disposable
|
||||||
import kotlin.coroutines.*
|
|
||||||
import net.torvald.terrarum.*
|
import net.torvald.terrarum.*
|
||||||
import net.torvald.terrarum.TerrarumAppConfiguration.TILE_SIZE
|
import net.torvald.terrarum.TerrarumAppConfiguration.TILE_SIZE
|
||||||
import net.torvald.terrarum.gameactors.AVKey
|
import net.torvald.terrarum.gameactors.AVKey
|
||||||
import net.torvald.terrarum.langpack.Lang
|
|
||||||
import net.torvald.terrarum.modulebasegame.gameactors.BlockBox
|
import net.torvald.terrarum.modulebasegame.gameactors.BlockBox
|
||||||
import net.torvald.terrarum.modulebasegame.gameactors.FixtureBase
|
import net.torvald.terrarum.modulebasegame.gameactors.FixtureBase
|
||||||
import net.torvald.terrarum.modulebasegame.gameactors.FixtureInventory
|
import net.torvald.terrarum.modulebasegame.gameactors.FixtureInventory
|
||||||
import net.torvald.terrarum.ui.Toolkit
|
import net.torvald.terrarum.modulecomputers.ui.UIHomeComputer
|
||||||
import net.torvald.terrarum.ui.UICanvas
|
|
||||||
import net.torvald.tsvm.*
|
import net.torvald.tsvm.*
|
||||||
import net.torvald.tsvm.peripheral.AdapterConfig
|
import net.torvald.tsvm.peripheral.AdapterConfig
|
||||||
import net.torvald.tsvm.peripheral.GraphicsAdapter
|
import net.torvald.tsvm.peripheral.GraphicsAdapter
|
||||||
import net.torvald.tsvm.peripheral.VMProgramRom
|
import net.torvald.tsvm.peripheral.VMProgramRom
|
||||||
import net.torvald.unicode.*
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by minjaesong on 2021-12-04.
|
* Created by minjaesong on 2021-12-04.
|
||||||
@@ -131,77 +122,3 @@ class FixtureHomeComputer : FixtureBase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal class UIHomeComputer : UICanvas(
|
|
||||||
toggleKeyLiteral = Input.Keys.ESCAPE, // FIXME why do I have specify ESC for it to function? ESC should be work as the default key
|
|
||||||
toggleButtonLiteral = App.getConfigInt("control_gamepad_start"),
|
|
||||||
) {
|
|
||||||
override var width = 640
|
|
||||||
override var height = 480
|
|
||||||
override var openCloseTime = 0f
|
|
||||||
|
|
||||||
private val drawOffX = (width - 560).div(2).toFloat()
|
|
||||||
private val drawOffY = (height - 448).div(2).toFloat()
|
|
||||||
|
|
||||||
private var batch: FlippingSpriteBatch
|
|
||||||
private var camera: OrthographicCamera
|
|
||||||
|
|
||||||
internal lateinit var vm: VM
|
|
||||||
internal lateinit var fixture: FixtureHomeComputer
|
|
||||||
|
|
||||||
init {
|
|
||||||
batch = FlippingSpriteBatch()
|
|
||||||
camera = OrthographicCamera(width.toFloat(), height.toFloat())
|
|
||||||
//val m = Matrix4()
|
|
||||||
//m.setToOrtho2D(0f, 0f, width.toFloat(), height.toFloat())
|
|
||||||
batch.projectionMatrix = camera.combined
|
|
||||||
}
|
|
||||||
|
|
||||||
private val fbo = FrameBuffer(Pixmap.Format.RGBA8888, width, height, false)
|
|
||||||
|
|
||||||
private val controlHelp =
|
|
||||||
"${getKeycapPC(App.getConfigInt("control_key_inventory"))} ${Lang["GAME_ACTION_CLOSE"]}\u3000 " +
|
|
||||||
"$KEYCAP_CTRL$KEYCAP_SHIFT$KEYCAP_T$KEYCAP_R Terminate\u3000" +
|
|
||||||
"$KEYCAP_CTRL$KEYCAP_SHIFT$KEYCAP_R$KEYCAP_S Reset\u3000" +
|
|
||||||
"$KEYCAP_CTRL$KEYCAP_SHIFT$KEYCAP_R$KEYCAP_Q SysRq"
|
|
||||||
|
|
||||||
override fun updateUI(delta: Float) {
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun renderUI(otherBatch: SpriteBatch, otherCamera: Camera) {
|
|
||||||
otherBatch.end()
|
|
||||||
|
|
||||||
fbo.inAction(camera, batch) {
|
|
||||||
Gdx.gl.glClearColor(0f,0f,0f,1f)
|
|
||||||
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT) // to hide the crap might be there
|
|
||||||
|
|
||||||
(vm.peripheralTable[1].peripheral as? GraphicsAdapter)?.let { gpu ->
|
|
||||||
val clearCol = gpu.getBackgroundColour()
|
|
||||||
Gdx.gl.glClearColor(clearCol.r, clearCol.g, clearCol.b, clearCol.a)
|
|
||||||
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT)
|
|
||||||
|
|
||||||
gpu.render(Gdx.graphics.deltaTime, batch, drawOffX, drawOffY, true, fbo) // gpu.render will internally end() the fbo then begin() again before using the batch I've fed in
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
otherBatch.begin()
|
|
||||||
otherBatch.shader = null
|
|
||||||
blendNormalStraightAlpha(otherBatch)
|
|
||||||
otherBatch.color = Color.WHITE
|
|
||||||
otherBatch.draw(fbo.colorBufferTexture, posX.toFloat(), posY.toFloat(), width.toFloat(), height.toFloat())
|
|
||||||
otherBatch.color = Toolkit.Theme.COL_INACTIVE
|
|
||||||
Toolkit.drawBoxBorder(otherBatch, posX - 1, posY - 1, width + 2, height + 2)
|
|
||||||
|
|
||||||
App.fontGame.draw(otherBatch, controlHelp, posX, posY + height + 4)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun doOpening(delta: Float) {
|
|
||||||
super.doOpening(delta)
|
|
||||||
fixture.startVM()
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
override fun dispose() {
|
|
||||||
fbo.dispose()
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,93 @@
|
|||||||
|
package net.torvald.terrarum.modulecomputers.ui
|
||||||
|
|
||||||
|
import com.badlogic.gdx.Gdx
|
||||||
|
import com.badlogic.gdx.Input
|
||||||
|
import com.badlogic.gdx.graphics.*
|
||||||
|
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||||
|
import com.badlogic.gdx.graphics.glutils.FrameBuffer
|
||||||
|
import net.torvald.terrarum.App
|
||||||
|
import net.torvald.terrarum.FlippingSpriteBatch
|
||||||
|
import net.torvald.terrarum.blendNormalStraightAlpha
|
||||||
|
import net.torvald.terrarum.inAction
|
||||||
|
import net.torvald.terrarum.langpack.Lang
|
||||||
|
import net.torvald.terrarum.modulecomputers.gameactors.FixtureHomeComputer
|
||||||
|
import net.torvald.terrarum.ui.Toolkit
|
||||||
|
import net.torvald.terrarum.ui.UICanvas
|
||||||
|
import net.torvald.tsvm.VM
|
||||||
|
import net.torvald.tsvm.peripheral.GraphicsAdapter
|
||||||
|
import net.torvald.unicode.*
|
||||||
|
|
||||||
|
internal class UIHomeComputer : UICanvas(
|
||||||
|
toggleKeyLiteral = Input.Keys.ESCAPE, // FIXME why do I have specify ESC for it to function? ESC should be work as the default key
|
||||||
|
toggleButtonLiteral = App.getConfigInt("control_gamepad_start"),
|
||||||
|
) {
|
||||||
|
override var width = 640
|
||||||
|
override var height = 480
|
||||||
|
override var openCloseTime = 0f
|
||||||
|
|
||||||
|
private val drawOffX = (width - 560).div(2).toFloat()
|
||||||
|
private val drawOffY = (height - 448).div(2).toFloat()
|
||||||
|
|
||||||
|
private var batch: FlippingSpriteBatch
|
||||||
|
private var camera: OrthographicCamera
|
||||||
|
|
||||||
|
internal lateinit var vm: VM
|
||||||
|
internal lateinit var fixture: FixtureHomeComputer
|
||||||
|
|
||||||
|
init {
|
||||||
|
batch = FlippingSpriteBatch()
|
||||||
|
camera = OrthographicCamera(width.toFloat(), height.toFloat())
|
||||||
|
//val m = Matrix4()
|
||||||
|
//m.setToOrtho2D(0f, 0f, width.toFloat(), height.toFloat())
|
||||||
|
batch.projectionMatrix = camera.combined
|
||||||
|
}
|
||||||
|
|
||||||
|
private val fbo = FrameBuffer(Pixmap.Format.RGBA8888, width, height, false)
|
||||||
|
|
||||||
|
private val controlHelp =
|
||||||
|
"${getKeycapPC(App.getConfigInt("control_key_inventory"))} ${Lang["GAME_ACTION_CLOSE"]}\u3000 " +
|
||||||
|
"$KEYCAP_CTRL$KEYCAP_SHIFT$KEYCAP_T$KEYCAP_R Terminate\u3000" +
|
||||||
|
"$KEYCAP_CTRL$KEYCAP_SHIFT$KEYCAP_R$KEYCAP_S Reset\u3000" +
|
||||||
|
"$KEYCAP_CTRL$KEYCAP_SHIFT$KEYCAP_R$KEYCAP_Q SysRq"
|
||||||
|
|
||||||
|
override fun updateUI(delta: Float) {
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun renderUI(otherBatch: SpriteBatch, otherCamera: Camera) {
|
||||||
|
otherBatch.end()
|
||||||
|
|
||||||
|
fbo.inAction(camera, batch) {
|
||||||
|
Gdx.gl.glClearColor(0f,0f,0f,1f)
|
||||||
|
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT) // to hide the crap might be there
|
||||||
|
|
||||||
|
(vm.peripheralTable[1].peripheral as? GraphicsAdapter)?.let { gpu ->
|
||||||
|
val clearCol = gpu.getBackgroundColour()
|
||||||
|
Gdx.gl.glClearColor(clearCol.r, clearCol.g, clearCol.b, clearCol.a)
|
||||||
|
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT)
|
||||||
|
|
||||||
|
gpu.render(Gdx.graphics.deltaTime, batch, drawOffX, drawOffY, true, fbo) // gpu.render will internally end() the fbo then begin() again before using the batch I've fed in
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
otherBatch.begin()
|
||||||
|
otherBatch.shader = null
|
||||||
|
blendNormalStraightAlpha(otherBatch)
|
||||||
|
otherBatch.color = Color.WHITE
|
||||||
|
otherBatch.draw(fbo.colorBufferTexture, posX.toFloat(), posY.toFloat(), width.toFloat(), height.toFloat())
|
||||||
|
otherBatch.color = Toolkit.Theme.COL_INACTIVE
|
||||||
|
Toolkit.drawBoxBorder(otherBatch, posX - 1, posY - 1, width + 2, height + 2)
|
||||||
|
|
||||||
|
App.fontGame.draw(otherBatch, controlHelp, posX, posY + height + 4)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun doOpening(delta: Float) {
|
||||||
|
super.doOpening(delta)
|
||||||
|
fixture.startVM()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
override fun dispose() {
|
||||||
|
fbo.dispose()
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -10,6 +10,7 @@
|
|||||||
"CONTEXT_CALENDAR_SEASON_SUMM": "Summ",
|
"CONTEXT_CALENDAR_SEASON_SUMM": "Summ",
|
||||||
"CONTEXT_CALENDAR_SEASON_AUTM": "Autm",
|
"CONTEXT_CALENDAR_SEASON_AUTM": "Autm",
|
||||||
"CONTEXT_CALENDAR_SEASON_WINT": "Wint",
|
"CONTEXT_CALENDAR_SEASON_WINT": "Wint",
|
||||||
|
"CONTEXT_CALENDAR_DATE_FORMAT_Y": "Year {0}",
|
||||||
"CONTEXT_CALENDAR_DATE_FORMAT_YMD": "Year {0} {1} {2}",
|
"CONTEXT_CALENDAR_DATE_FORMAT_YMD": "Year {0} {1} {2}",
|
||||||
"CONTEXT_CALENDAR_DATE_FORMAT_YMD_DDD": "Year {0} {1} {2} {3}",
|
"CONTEXT_CALENDAR_DATE_FORMAT_YMD_DDD": "Year {0} {1} {2} {3}",
|
||||||
|
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
"CONTEXT_CALENDAR_SEASON_SUMM": "여름",
|
"CONTEXT_CALENDAR_SEASON_SUMM": "여름",
|
||||||
"CONTEXT_CALENDAR_SEASON_AUTM": "가을",
|
"CONTEXT_CALENDAR_SEASON_AUTM": "가을",
|
||||||
"CONTEXT_CALENDAR_SEASON_WINT": "겨울",
|
"CONTEXT_CALENDAR_SEASON_WINT": "겨울",
|
||||||
|
"CONTEXT_CALENDAR_DATE_FORMAT_Y": "{0}년",
|
||||||
"CONTEXT_CALENDAR_DATE_FORMAT_YMD": "{0}년 {1} {2}일",
|
"CONTEXT_CALENDAR_DATE_FORMAT_YMD": "{0}년 {1} {2}일",
|
||||||
"CONTEXT_CALENDAR_DATE_FORMAT_YMD_DDD": "{0}년 {1} {2}일 {3}"
|
"CONTEXT_CALENDAR_DATE_FORMAT_YMD_DDD": "{0}년 {1} {2}일 {3}"
|
||||||
}
|
}
|
||||||
@@ -17,6 +17,10 @@ import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
|||||||
*/
|
*/
|
||||||
class UIBasicInfo() : UICanvas() {
|
class UIBasicInfo() : UICanvas() {
|
||||||
|
|
||||||
|
init {
|
||||||
|
handler.allowESCtoClose = false
|
||||||
|
}
|
||||||
|
|
||||||
val player: ActorHumanoid?
|
val player: ActorHumanoid?
|
||||||
get() = Terrarum.ingame?.actorNowPlaying
|
get() = Terrarum.ingame?.actorNowPlaying
|
||||||
|
|
||||||
|
|||||||
@@ -14,6 +14,10 @@ import net.torvald.terrarum.ui.UICanvas
|
|||||||
*/
|
*/
|
||||||
class UICheatDetected : UICanvas() {
|
class UICheatDetected : UICanvas() {
|
||||||
|
|
||||||
|
init {
|
||||||
|
handler.allowESCtoClose = false
|
||||||
|
}
|
||||||
|
|
||||||
override var width: Int
|
override var width: Int
|
||||||
get() = App.scr.width
|
get() = App.scr.width
|
||||||
set(value) { throw UnsupportedOperationException() }
|
set(value) { throw UnsupportedOperationException() }
|
||||||
|
|||||||
@@ -157,7 +157,6 @@ class UIInventoryFull(
|
|||||||
//val INVENTORY_CELLS_OFFSET_Y: Int = 107 + (AppLoader.terrarumAppConfig.screenH - internalHeight) / 2
|
//val INVENTORY_CELLS_OFFSET_Y: Int = 107 + (AppLoader.terrarumAppConfig.screenH - internalHeight) / 2
|
||||||
|
|
||||||
init {
|
init {
|
||||||
handler.allowESCtoClose = true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private val SP = "\u3000 "
|
private val SP = "\u3000 "
|
||||||
|
|||||||
@@ -18,6 +18,11 @@ import kotlin.math.roundToInt
|
|||||||
* Created by minjaesong on 2016-07-20.
|
* Created by minjaesong on 2016-07-20.
|
||||||
*/
|
*/
|
||||||
class UIQuickslotBar : UICanvas() {
|
class UIQuickslotBar : UICanvas() {
|
||||||
|
|
||||||
|
init {
|
||||||
|
handler.allowESCtoClose = false
|
||||||
|
}
|
||||||
|
|
||||||
private val cellSize = ItemSlotImageFactory.slotImage.tileW // 38
|
private val cellSize = ItemSlotImageFactory.slotImage.tileW // 38
|
||||||
|
|
||||||
private val gutter = 10 - 6 // do -6 to get a gutter size of not-enlarged cells
|
private val gutter = 10 - 6 // do -6 to get a gutter size of not-enlarged cells
|
||||||
|
|||||||
@@ -21,6 +21,11 @@ import kotlin.math.roundToInt
|
|||||||
* Created by minjaesong on 2016-07-20.
|
* Created by minjaesong on 2016-07-20.
|
||||||
*/
|
*/
|
||||||
class UIQuickslotPie : UICanvas() {
|
class UIQuickslotPie : UICanvas() {
|
||||||
|
|
||||||
|
init {
|
||||||
|
handler.allowESCtoClose = false
|
||||||
|
}
|
||||||
|
|
||||||
private val cellSize = ItemSlotImageFactory.slotImage.tileW
|
private val cellSize = ItemSlotImageFactory.slotImage.tileW
|
||||||
|
|
||||||
private val slotCount = UIQuickslotBar.SLOT_COUNT
|
private val slotCount = UIQuickslotBar.SLOT_COUNT
|
||||||
|
|||||||
@@ -21,6 +21,10 @@ class UIScreenZoom : UICanvas(
|
|||||||
App.getConfigInt("control_key_zoom")
|
App.getConfigInt("control_key_zoom")
|
||||||
) {
|
) {
|
||||||
|
|
||||||
|
init {
|
||||||
|
handler.allowESCtoClose = false
|
||||||
|
}
|
||||||
|
|
||||||
val zoomText = "${getKeycapPC(handler.toggleKeyLiteral!!)} $EMDASH Zoom Out"
|
val zoomText = "${getKeycapPC(handler.toggleKeyLiteral!!)} $EMDASH Zoom Out"
|
||||||
|
|
||||||
override var width = App.fontGame.getWidth(zoomText)
|
override var width = App.fontGame.getWidth(zoomText)
|
||||||
|
|||||||
@@ -14,6 +14,10 @@ import net.torvald.terrarum.ui.UICanvas
|
|||||||
*/
|
*/
|
||||||
class UITooltip : UICanvas() {
|
class UITooltip : UICanvas() {
|
||||||
|
|
||||||
|
init {
|
||||||
|
handler.allowESCtoClose = false
|
||||||
|
}
|
||||||
|
|
||||||
override var openCloseTime: Second = 0f
|
override var openCloseTime: Second = 0f
|
||||||
|
|
||||||
private val tooltipBackCol = Color.WHITE
|
private val tooltipBackCol = Color.WHITE
|
||||||
|
|||||||
@@ -21,6 +21,10 @@ class UIVitalMetre(
|
|||||||
val order: Int
|
val order: Int
|
||||||
) : UICanvas() {
|
) : UICanvas() {
|
||||||
|
|
||||||
|
init {
|
||||||
|
handler.allowESCtoClose = false
|
||||||
|
}
|
||||||
|
|
||||||
init {
|
init {
|
||||||
// semitransparent
|
// semitransparent
|
||||||
color?.a = 0.91f
|
color?.a = 0.91f
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package net.torvald.terrarum.modulebasegame.ui
|
package net.torvald.terrarum.modulebasegame.ui
|
||||||
|
|
||||||
import com.badlogic.gdx.graphics.Camera
|
import com.badlogic.gdx.graphics.Camera
|
||||||
|
import com.badlogic.gdx.graphics.Color
|
||||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||||
import net.torvald.terrarum.App
|
import net.torvald.terrarum.App
|
||||||
import net.torvald.terrarum.INGAME
|
import net.torvald.terrarum.INGAME
|
||||||
@@ -19,7 +20,8 @@ class UIWallCalendar : UICanvas(
|
|||||||
toggleKeyLiteral = App.getConfigInt("control_key_inventory"),
|
toggleKeyLiteral = App.getConfigInt("control_key_inventory"),
|
||||||
toggleButtonLiteral = App.getConfigInt("control_gamepad_start"),
|
toggleButtonLiteral = App.getConfigInt("control_gamepad_start"),
|
||||||
) {
|
) {
|
||||||
private val cellWidth = 96
|
private val yearCellWidth = 200
|
||||||
|
private val cellWidth = 80
|
||||||
private val cellHeight = 24
|
private val cellHeight = 24
|
||||||
|
|
||||||
override var width: Int = Toolkit.drawWidth
|
override var width: Int = Toolkit.drawWidth
|
||||||
@@ -37,43 +39,96 @@ class UIWallCalendar : UICanvas(
|
|||||||
else
|
else
|
||||||
"${App.gamepadLabelStart} ${Lang["GAME_ACTION_CLOSE"]}"
|
"${App.gamepadLabelStart} ${Lang["GAME_ACTION_CLOSE"]}"
|
||||||
|
|
||||||
|
|
||||||
|
private var todayCell = -1
|
||||||
|
|
||||||
|
private val cellBackCols = listOf(
|
||||||
|
Color(0x3f1e22_C8), // OKLCh 14, 5, 18
|
||||||
|
Color(0x022f3a_C8), // OKLCh 218, 5, 18
|
||||||
|
Color(0x2d2b09_C8), // OKLCh 105, 5, 18
|
||||||
|
Color(0x252934_C8) // OKLCh 265, 2, 18
|
||||||
|
)
|
||||||
|
private val seasonMarkers = listOf(
|
||||||
|
7 to "CONTEXT_CALENDAR_SEASON_SPRING",
|
||||||
|
39 to "CONTEXT_CALENDAR_SEASON_SUMMER",
|
||||||
|
71 to "CONTEXT_CALENDAR_SEASON_AUTUMN",
|
||||||
|
103 to "CONTEXT_CALENDAR_SEASON_WINTER"
|
||||||
|
)
|
||||||
|
|
||||||
|
private var mouseOverCell = -1
|
||||||
|
|
||||||
override fun updateUI(delta: Float) {
|
override fun updateUI(delta: Float) {
|
||||||
|
mouseOverCell = if (relativeMouseX in drawStartX until drawStartX + 8 * (cellWidth + 1) &&
|
||||||
|
relativeMouseY in cellsStartY - 1 until cellsStartY - 1 + 17 * (cellHeight + 3)) {
|
||||||
|
|
||||||
|
val x = (relativeMouseX - drawStartX) / (cellWidth + 1)
|
||||||
|
val y = (relativeMouseY - cellsStartY + 1) / (cellHeight + 3)
|
||||||
|
|
||||||
|
// disable highlighting on invalid date (verddag and not winter 30)
|
||||||
|
if (x == 7 && y < 16) -1
|
||||||
|
else y * 8 + x
|
||||||
|
}
|
||||||
|
else -1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
override fun renderUI(batch: SpriteBatch, camera: Camera) {
|
override fun renderUI(batch: SpriteBatch, camera: Camera) {
|
||||||
UIInventoryFull.drawBackground(batch, 1f)
|
UIInventoryFull.drawBackground(batch, 1f)
|
||||||
|
|
||||||
|
val thisYear = INGAME.world.worldTime.years
|
||||||
val today = INGAME.world.worldTime.ordinalDay + 1
|
val today = INGAME.world.worldTime.ordinalDay + 1
|
||||||
val todayOfWeek = INGAME.world.worldTime.dayOfWeek
|
val todayOfWeek = INGAME.world.worldTime.dayOfWeek
|
||||||
|
|
||||||
// cell background
|
// cell background
|
||||||
batch.color = UIInventoryFull.CELL_COL
|
batch.color = Toolkit.Theme.COL_CELL_FILL
|
||||||
|
Toolkit.fillArea(batch, (width - yearCellWidth) / 2, y - 34, yearCellWidth, 24)
|
||||||
for (week in 0..7) {
|
for (week in 0..7) {
|
||||||
Toolkit.fillArea(batch, drawStartX + (cellWidth + 1) * week + 1, y, cellWidth - 2, 24)
|
Toolkit.fillArea(batch, drawStartX + (cellWidth + 1) * week + 1, y, cellWidth - 2, 24)
|
||||||
}
|
}
|
||||||
for (cellNum in 0 until 17 * 8) {
|
for (cellNum in 0 until 17 * 8) {
|
||||||
|
batch.color = when (cellNum) {
|
||||||
|
in 0 until 34 -> cellBackCols[0]
|
||||||
|
in 34 until 68 -> cellBackCols[1]
|
||||||
|
in 68 until 102 -> cellBackCols[2]
|
||||||
|
else -> cellBackCols[3]
|
||||||
|
}
|
||||||
|
|
||||||
Toolkit.fillArea(batch, drawStartX + (cellWidth + 1) * (cellNum % 8) + 1, cellsStartY + (cellHeight + 3) * (cellNum / 8), cellWidth - 2, cellHeight)
|
Toolkit.fillArea(batch, drawStartX + (cellWidth + 1) * (cellNum % 8) + 1, cellsStartY + (cellHeight + 3) * (cellNum / 8), cellWidth - 2, cellHeight)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// cell border
|
// cell border
|
||||||
batch.color = Toolkit.Theme.COL_INACTIVE
|
batch.color = Toolkit.Theme.COL_INACTIVE
|
||||||
|
Toolkit.drawBoxBorder(batch, (width - yearCellWidth) / 2 - 1, y - 35, yearCellWidth + 2, 26)
|
||||||
Toolkit.drawBoxBorder(batch, drawStartX, y - 1, 8 * (cellWidth + 1) - 1, 26)
|
Toolkit.drawBoxBorder(batch, drawStartX, y - 1, 8 * (cellWidth + 1) - 1, 26)
|
||||||
for (week in 0..7) {
|
for (week in 0..7) {
|
||||||
Toolkit.drawBoxBorder(batch, drawStartX + (cellWidth + 1) * week, y - 1, cellWidth, 26)
|
Toolkit.drawBoxBorder(batch, drawStartX + (cellWidth + 1) * week, y - 1, cellWidth, 26)
|
||||||
}
|
}
|
||||||
|
// highlight a day name of mouse-up
|
||||||
|
batch.color = Toolkit.Theme.COL_MOUSE_UP
|
||||||
|
if (mouseOverCell >= 0) Toolkit.drawBoxBorder(batch, drawStartX + (cellWidth + 1) * (mouseOverCell % 8), y - 1, cellWidth, 26)
|
||||||
|
// highlight today's week name
|
||||||
|
batch.color = Toolkit.Theme.COL_SELECTED
|
||||||
|
Toolkit.drawBoxBorder(batch, drawStartX + (cellWidth + 1) * todayOfWeek, y - 1, cellWidth, 26)
|
||||||
|
|
||||||
|
|
||||||
|
// draw days grid
|
||||||
|
batch.color = Toolkit.Theme.COL_INACTIVE
|
||||||
Toolkit.drawBoxBorder(batch, drawStartX, cellsStartY - 1, 8 * (cellWidth + 1) - 1, 17 * (cellHeight + 3) - 1)
|
Toolkit.drawBoxBorder(batch, drawStartX, cellsStartY - 1, 8 * (cellWidth + 1) - 1, 17 * (cellHeight + 3) - 1)
|
||||||
for (cellNum in 0 until 17 * 8) {
|
for (cellNum in 0 until 17 * 8) {
|
||||||
Toolkit.drawBoxBorder(batch, drawStartX + (cellWidth + 1) * (cellNum % 8), cellsStartY + (cellHeight + 3) * (cellNum / 8) - 1, cellWidth, cellHeight + 2)
|
Toolkit.drawBoxBorder(batch, drawStartX + (cellWidth + 1) * (cellNum % 8), cellsStartY + (cellHeight + 3) * (cellNum / 8) - 1, cellWidth, cellHeight + 2)
|
||||||
}
|
}
|
||||||
|
// highlight a day of mouse-up
|
||||||
|
batch.color = Toolkit.Theme.COL_MOUSE_UP
|
||||||
|
if (mouseOverCell >= 0) Toolkit.drawBoxBorder(batch, drawStartX + (cellWidth + 1) * (mouseOverCell % 8), cellsStartY + (cellHeight + 3) * (mouseOverCell / 8) - 1, cellWidth, cellHeight + 2)
|
||||||
|
|
||||||
|
|
||||||
// cell texts
|
// cell texts
|
||||||
|
batch.color = Toolkit.Theme.COL_LIST_DEFAULT
|
||||||
|
Toolkit.drawTextCentered(batch, App.fontGame, Lang.getAndUseTemplate("CONTEXT_CALENDAR_DATE_FORMAT_Y", false, thisYear), yearCellWidth, (width - yearCellWidth) / 2, y - 34)
|
||||||
for (week in 0..7) {
|
for (week in 0..7) {
|
||||||
batch.color = if (week == todayOfWeek) Toolkit.Theme.COL_MOUSE_UP else Toolkit.Theme.COL_LIST_DEFAULT
|
// highlight this week and the mouse-up
|
||||||
|
batch.color = if (week == todayOfWeek) Toolkit.Theme.COL_SELECTED else if (week == mouseOverCell % 8) Toolkit.Theme.COL_MOUSE_UP else Toolkit.Theme.COL_LIST_DEFAULT
|
||||||
|
|
||||||
val t = WorldTime.getDayName(week)
|
val t = WorldTime.getDayName(week)
|
||||||
val tlen = App.fontGame.getWidth(t)
|
val tlen = App.fontGame.getWidth(t)
|
||||||
App.fontGame.draw(batch, t, drawStartX + (cellWidth + 1) * week + (cellWidth - tlen) / 2, y)
|
App.fontGame.draw(batch, t, drawStartX + (cellWidth + 1) * week + (cellWidth - tlen) / 2, y)
|
||||||
@@ -83,13 +138,31 @@ class UIWallCalendar : UICanvas(
|
|||||||
val day = if (cellNum == 17*8-1) 120 else if (cellNum % 8 == 7) 0 else dayAkku
|
val day = if (cellNum == 17*8-1) 120 else if (cellNum % 8 == 7) 0 else dayAkku
|
||||||
|
|
||||||
if (day > 0) {
|
if (day > 0) {
|
||||||
batch.color = if (day == today) Toolkit.Theme.COL_SELECTED else Toolkit.Theme.COL_LIST_DEFAULT
|
// highlight today and the mouse-up
|
||||||
|
batch.color = if (day == today) Toolkit.Theme.COL_SELECTED else if (cellNum == mouseOverCell) Toolkit.Theme.COL_MOUSE_UP else Toolkit.Theme.COL_LIST_DEFAULT
|
||||||
|
|
||||||
val t = "${(day % MONTH_LENGTH).let { if (it == 0) MONTH_LENGTH else it }}".padStart(2, '\u2007')
|
val t = "${(day % MONTH_LENGTH).let { if (it == 0) MONTH_LENGTH else it }}".padStart(2, '\u2007')
|
||||||
App.fontGame.draw(batch, t, drawStartX + (cellWidth + 1) * (cellNum % 8) + 1 + cellWidth - 23, cellsStartY + (cellHeight + 3) * (cellNum / 8))
|
App.fontGame.draw(batch, t, drawStartX + (cellWidth + 1) * (cellNum % 8) - 20 + cellWidth - 4, cellsStartY + (cellHeight + 3) * (cellNum / 8))
|
||||||
|
|
||||||
|
if (day == today) todayCell = cellNum
|
||||||
|
|
||||||
dayAkku += 1
|
dayAkku += 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
batch.color = Toolkit.Theme.COL_INACTIVE
|
||||||
|
seasonMarkers.forEach { (cellNum, key) ->
|
||||||
|
App.fontGame.draw(batch, Lang[key], drawStartX + (cellWidth + 1) * (cellNum % 8) + 1 + 4, cellsStartY + (cellHeight + 3) * (cellNum / 8))
|
||||||
|
}
|
||||||
|
|
||||||
|
// highlight today cell
|
||||||
|
if (todayCell >= 0) {
|
||||||
|
batch.color = Toolkit.Theme.COL_SELECTED
|
||||||
|
Toolkit.drawBoxBorder(batch, drawStartX + (cellWidth + 1) * (todayCell % 8), cellsStartY + (cellHeight + 3) * (todayCell / 8) - 1, cellWidth, cellHeight + 2)
|
||||||
|
}
|
||||||
|
|
||||||
|
// control hints
|
||||||
|
batch.color = Color.WHITE
|
||||||
|
App.fontGame.draw(batch, controlHelp, drawStartX + 2, cellsStartY+ 17 * (cellHeight + 3) + 6)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun doOpening(delta: Float) {
|
override fun doOpening(delta: Float) {
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ class UIHandler(//var UI: UICanvas,
|
|||||||
// UI positions itself? (you must g.flush() yourself after the g.translate(Int, Int))
|
// UI positions itself? (you must g.flush() yourself after the g.translate(Int, Int))
|
||||||
var customPositioning: Boolean = false, // mainly used by vital meter
|
var customPositioning: Boolean = false, // mainly used by vital meter
|
||||||
var doNotWarnConstant: Boolean = false,
|
var doNotWarnConstant: Boolean = false,
|
||||||
internal var allowESCtoClose: Boolean = false,
|
internal var allowESCtoClose: Boolean = true,
|
||||||
var uiTogglerFunctionDefault: ((UIHandler) -> Unit)? = null
|
var uiTogglerFunctionDefault: ((UIHandler) -> Unit)? = null
|
||||||
): Disposable {
|
): Disposable {
|
||||||
|
|
||||||
@@ -214,7 +214,7 @@ void main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ESC is a master key for closing
|
// ESC is a master key for closing
|
||||||
if (allowESCtoClose && Gdx.input.isKeyJustPressed(Input.Keys.ESCAPE) && isOpened) {
|
if (!alwaysVisible && allowESCtoClose && Gdx.input.isKeyJustPressed(Input.Keys.ESCAPE) && isOpened) {
|
||||||
setAsClose()
|
setAsClose()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user