monitor adjustment screen, changed "calibrate" to "adjust" (NOT the STRING_ID of langpack)

Former-commit-id: ffae41e5876e54e2e0aedb5a93092db8e8f75d01
Former-commit-id: 65883b385a205d47b76c60f18a91186c2be922b2
This commit is contained in:
Song Minjae
2016-07-06 20:17:51 +09:00
parent 4843819d84
commit 186d6a8cb9
53 changed files with 425 additions and 215 deletions

View File

@@ -43,7 +43,7 @@ class BasicDebugInfoWindow:UICanvas {
}
override fun update(gc: GameContainer, delta: Int) {
val player = Terrarum.game.player
val player = Terrarum.ingame.player
val hitbox = player.hitbox
xdelta = hitbox.pointedX - prevPlayerX
@@ -58,13 +58,13 @@ class BasicDebugInfoWindow:UICanvas {
fun Int.rawG() = this % LightmapRenderer.MUL_2 / LightmapRenderer.MUL
fun Int.rawB() = this % LightmapRenderer.MUL
val player = Terrarum.game.player
val player = Terrarum.ingame.player
val sb = StringBuilder()
val formatter = Formatter(sb)
val mouseTileX = ((MapCamera.cameraX + gc.input.mouseX / Terrarum.game.screenZoom) / MapDrawer.TILE_SIZE).toInt()
val mouseTileY = ((MapCamera.cameraY + gc.input.mouseY / Terrarum.game.screenZoom) / MapDrawer.TILE_SIZE).toInt()
val mouseTileX = ((MapCamera.cameraX + gc.input.mouseX / Terrarum.ingame.screenZoom) / MapDrawer.TILE_SIZE).toInt()
val mouseTileY = ((MapCamera.cameraY + gc.input.mouseY / Terrarum.ingame.screenZoom) / MapDrawer.TILE_SIZE).toInt()
g.font = Terrarum.smallNumbers
g.color = GameFontBase.codeToCol["y"]
@@ -114,7 +114,7 @@ class BasicDebugInfoWindow:UICanvas {
printLine(g, 7, "light@cursor $ccG$lightVal")
val tileNo: String
val tileNumRaw = Terrarum.game.map.getTileFromTerrain(mouseTileX, mouseTileY) ?: -1
val tileNumRaw = Terrarum.ingame.map.getTileFromTerrain(mouseTileX, mouseTileY) ?: -1
val tilenum = tileNumRaw / PairedMapLayer.RANGE
val tiledmg = tileNumRaw % PairedMapLayer.RANGE
tileNo = if (tileNumRaw == -1) "" else "$tilenum:$tiledmg"
@@ -127,8 +127,8 @@ class BasicDebugInfoWindow:UICanvas {
printLineColumn(g, 2, 1, "VSync $ccG" + Terrarum.appgc.isVSyncRequested)
printLineColumn(g, 2, 2, "Env colour temp $ccG" + MapDrawer.getColTemp())
printLineColumn(g, 2, 5, "Time $ccG${Terrarum.game.map.worldTime.elapsedSeconds()}" +
" (${Terrarum.game.map.worldTime.getFormattedTime()})")
printLineColumn(g, 2, 5, "Time $ccG${Terrarum.ingame.map.worldTime.elapsedSeconds()}" +
" (${Terrarum.ingame.map.worldTime.getFormattedTime()})")
printLineColumn(g, 2, 6, "Mass $ccG${player.mass}")
drawHistogram(g, LightmapRenderer.histogram,
@@ -147,20 +147,20 @@ class BasicDebugInfoWindow:UICanvas {
(Terrarum.WIDTH - 2 - 6*8).toFloat(), 10f)
g.color = GameFontBase.codeToCol["g"]
g.drawString("${Terrarum.game.memInUse}M",
g.drawString("${Terrarum.ingame.memInUse}M",
(Terrarum.WIDTH - 11 * 8 - 2).toFloat(), 2f)
g.drawString("/${Terrarum.game.totalVMMem}M",
g.drawString("/${Terrarum.ingame.totalVMMem}M",
(Terrarum.WIDTH - 6 * 8 - 2).toFloat(), 2f)
/**
* Bottom left
*/
g.drawString("${ccY}Actors total $ccG${Terrarum.game.actorContainer.size + Terrarum.game.actorContainerInactive.size}",
g.drawString("${ccY}Actors total $ccG${Terrarum.ingame.actorContainer.size + Terrarum.ingame.actorContainerInactive.size}",
2f, Terrarum.HEIGHT - 10f)
g.drawString("${ccY}Active $ccG${Terrarum.game.actorContainer.size}",
g.drawString("${ccY}Active $ccG${Terrarum.ingame.actorContainer.size}",
(2 + 17*8).toFloat(), Terrarum.HEIGHT - 10f)
g.drawString("${ccY}Dormant $ccG${Terrarum.game.actorContainerInactive.size}",
g.drawString("${ccY}Dormant $ccG${Terrarum.ingame.actorContainerInactive.size}",
(2 + 28*8).toFloat(), Terrarum.HEIGHT - 10f)
}

View File

@@ -151,7 +151,7 @@ class ConsoleWindow : UICanvas, UITypable {
prevCommand = ""
commandInputPool = StringBuilder()
if (Terrarum.game.auth.b()) sendMessage(Lang["DEV_MESSAGE_CONSOLE_CODEX"])
if (Terrarum.ingame.auth.b()) sendMessage(Lang["DEV_MESSAGE_CONSOLE_CODEX"])
}
override fun doOpening(gc: GameContainer, delta: Int) {

View File

@@ -0,0 +1,15 @@
package net.torvald.terrarum.ui
import org.newdawn.slick.Graphics
/**
* Created by minjaesong on 16-07-06.
*/
object Typesetter {
fun printCentered(string: String, screenPosY: Int, ui: UICanvas, g: Graphics) {
val stringW = g.font.getWidth(string)
val targetW = ui.width
g.drawString(string, targetW.minus(stringW).ushr(1).toFloat(), screenPosY.toFloat())
}
}

View File

@@ -4,8 +4,13 @@ import net.torvald.terrarum.mapdrawer.MapCamera
import net.torvald.terrarum.Terrarum
import com.jme3.math.FastMath
import org.newdawn.slick.*
import org.newdawn.slick.state.StateBasedGame
/**
* UIHandler is a handler for UICanvas. It opens/closes the attached UI, moves the "window" (or "canvas")
* to the coordinate of displayed cartesian coords, and update and render the UI.
* It also process game inputs and send control events to the UI so that the UI can handle them.
*
* Created by minjaesong on 15-12-31.
*/
class UIHandler
@@ -33,10 +38,15 @@ constructor(val UI: UICanvas) {
private var opening = false
private var closing = false
private var opened = false // fully opened
private var _visible = false
val visible: Boolean
var visible: Boolean = false
get() = if (alwaysVisible) true
else _visible
else field
set(value) {
if (alwaysVisible)
throw RuntimeException("[UIHandler] Tried to 'set visibility of' constant UI")
field = value
}
var openCloseCounter = 0
@@ -51,12 +61,12 @@ constructor(val UI: UICanvas) {
fun update(gc: GameContainer, delta: Int) {
if (_visible || alwaysVisible) {
if (visible || alwaysVisible) {
UI.update(gc, delta)
}
if (opening) {
_visible = true
visible = true
openCloseCounter += delta
// println("UI ${UI.javaClass.simpleName} (open)")
@@ -87,23 +97,31 @@ constructor(val UI: UICanvas) {
UI.endClosing(gc, delta)
closing = false
opened = false
_visible = false
visible = false
openCloseCounter = 0
}
}
}
fun render(gc: GameContainer, gameGraphicInstance: Graphics) {
if (_visible || alwaysVisible) {
fun render(gc: GameContainer, sbg: StateBasedGame, gameGraphicInstance: Graphics) {
if (visible || alwaysVisible) {
UIGraphicInstance.clear()
UIGraphicInstance.font = Terrarum.gameFont
UI.render(gc, UIGraphicInstance)
gameGraphicInstance.drawImage(UIDrawnCanvas,
posX + MapCamera.cameraX * Terrarum.game.screenZoom,
posY + MapCamera.cameraY * Terrarum.game.screenZoom
)// compensate for screenZoom AND camera translation
// (see Game.render -> g.translate())
if (sbg.currentStateID == Terrarum.SCENE_ID_GAME) {
gameGraphicInstance.drawImage(UIDrawnCanvas,
posX + MapCamera.cameraX * Terrarum.ingame.screenZoom,
posY + MapCamera.cameraY * Terrarum.ingame.screenZoom
)// compensate for screenZoom AND camera translation
// (see Game.render -> g.translate())
}
else {
gameGraphicInstance.drawImage(UIDrawnCanvas,
posX.toFloat(),
posY.toFloat()
)
}
}
}
@@ -112,22 +130,17 @@ constructor(val UI: UICanvas) {
posY = y
}
fun setVisibility(b: Boolean) {
if (alwaysVisible) {
throw RuntimeException("[UIHandler] Tried to 'set visibility of' constant UI")
}
_visible = b
}
fun setAsAlwaysVisible() {
alwaysVisible = true
_visible = true
visible = true
opened = true
opening = false
closing = false
}
/**
* Send OPEN signal to the attached UI.
*/
fun setAsOpening() {
if (alwaysVisible) {
throw RuntimeException("[UIHandler] Tried to 'open' constant UI")
@@ -136,6 +149,9 @@ constructor(val UI: UICanvas) {
opening = true
}
/**
* Send CLOSE signal to the attached UI.
*/
fun setAsClosing() {
if (alwaysVisible) {
throw RuntimeException("[UIHandler] Tried to 'close' constant UI")
@@ -148,7 +164,7 @@ constructor(val UI: UICanvas) {
if (alwaysVisible) {
throw RuntimeException("[UIHandler] Tried to 'toggle opening of' constant UI")
}
if (_visible) {
if (visible) {
if (!closing) {
setAsClosing()
}
@@ -161,61 +177,61 @@ constructor(val UI: UICanvas) {
}
fun processInput(input: Input) {
if (_visible) {
if (visible) {
UI.processInput(input)
}
}
fun keyPressed(key: Int, c: Char) {
if (_visible && UI is UITypable) {
if (visible && UI is UITypable) {
UI.keyPressed(key, c)
}
}
fun keyReleased(key: Int, c: Char) {
if (_visible && UI is UITypable) {
if (visible && UI is UITypable) {
UI.keyReleased(key, c)
}
}
fun mouseMoved(oldx: Int, oldy: Int, newx: Int, newy: Int) {
if (_visible && UI is UIClickable) {
if (visible && UI is UIClickable) {
UI.mouseMoved(oldx, oldy, newx, newy)
}
}
fun mouseDragged(oldx: Int, oldy: Int, newx: Int, newy: Int) {
if (_visible && UI is UIClickable) {
if (visible && UI is UIClickable) {
UI.mouseDragged(oldx, oldy, newx, newy)
}
}
fun mousePressed(button: Int, x: Int, y: Int) {
if (_visible && UI is UIClickable) {
if (visible && UI is UIClickable) {
UI.mousePressed(button, x, y)
}
}
fun mouseReleased(button: Int, x: Int, y: Int) {
if (_visible && UI is UIClickable) {
if (visible && UI is UIClickable) {
UI.mouseReleased(button, x, y)
}
}
fun mouseWheelMoved(change: Int) {
if (_visible && UI is UIClickable) {
if (visible && UI is UIClickable) {
UI.mouseWheelMoved(change)
}
}
fun controllerButtonPressed(controller: Int, button: Int) {
if (_visible && UI is UIClickable) {
if (visible && UI is UIClickable) {
UI.controllerButtonPressed(controller, button)
}
}
fun controllerButtonReleased(controller: Int, button: Int) {
if (_visible && UI is UIClickable) {
if (visible && UI is UIClickable) {
UI.controllerButtonReleased(controller, button)
}
}
@@ -226,6 +242,6 @@ constructor(val UI: UICanvas) {
if (alwaysVisible) {
return false
}
return _visible && !opening
return visible && !opening
}
}