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

@@ -0,0 +1,13 @@
{
"MENU_MONITOR_CALI_TITLE": "Display check",
"MENU_MONITOR_CALI_LABEL_1": "You should be able to see bar 1 from the background",
"MENU_MONITOR_CALI_LABEL_2": "and clearly distinguish bar 30, 31 and 32",
"MENU_MONITOR_CALI_LABEL_3": " ",
"MENU_MONITOR_CALI_LABEL_4": "A bad monitor will not show few leftmost bars, will not show a difference",
"MENU_MONITOR_CALI_LABEL_5": "between the rightmost few, or shows a relatively large jump between 31 and 32",
"MENU_MONITOR_CALI_LABEL_6": " ",
"MENU_MONITOR_CALI_LABEL_7": "On a good monitor, you should see roughly equal steps in brightness",
"MENU_MONITOR_CALI_LABEL_8": "over the full 1 to 32 range",
"MENU_MONITOR_CALI_LABEL_9": " ",
"MENU_MONITOR_CALI_LABEL_10": "Adjust the contrast and brightness setting of the monitor to improve the image"
}

View File

@@ -2,5 +2,5 @@
"MENU_LABEL_NEW_WORLD": "New World", "MENU_LABEL_NEW_WORLD": "New World",
"COPYRIGHT_PROPRIETARY": "All rights reserved.", "COPYRIGHT_PROPRIETARY": "All rights reserved.",
"APP_CALIBRATE_YOUR_MONITOR": "Best player experience can be achieved with properly calibrated monitor. If you have not, please do it before you play." "APP_CALIBRATE_YOUR_MONITOR": "Best player experience can be achieved with properly adjusted monitor. If you have not, please do it before you play."
} }

View File

@@ -2,5 +2,5 @@
"MENU_LABEL_NEW_WORLD": "Uusi Maailma", "MENU_LABEL_NEW_WORLD": "Uusi Maailma",
"COPYRIGHT_PROPRIETARY": "Kaikki oikeudet pidätetään", "COPYRIGHT_PROPRIETARY": "Kaikki oikeudet pidätetään",
"APP_CALIBRATE_YOUR_MONITOR": "Paras pelikokemus saavutetaan on oikealla kalibroitu näytöllä. Jos et ole ollut, kalibroi ennen pelaamista." "APP_CALIBRATE_YOUR_MONITOR": "Paras pelikokemus saavutetaan on oikealla säädetty näytöllä. Jos et ole ollut, säädä ennen pelaamista."
} }

View File

@@ -2,5 +2,5 @@
"MENU_LABEL_NEW_WORLD": "Nouveau Monde", "MENU_LABEL_NEW_WORLD": "Nouveau Monde",
"COPYRIGHT_PROPRIETARY": "Tous les droits sont réservés.", "COPYRIGHT_PROPRIETARY": "Tous les droits sont réservés.",
"APP_CALIBRATE_YOUR_MONITOR": "Meilleure expérience de joueur peut être réalisé avec écran correctement calibré. Si vous ne l'avez pas, s.v.p. le calibrez avant de jouer." "APP_CALIBRATE_YOUR_MONITOR": "Meilleure expérience de joueur peut être réalisé avec écran correctement réglé. Si vous ne l'avez pas, s.v.p. le réglez avant de jouer."
} }

View File

@@ -2107,19 +2107,19 @@
}, },
{ {
"n": "MENU_LABEL_PRESS_ANYKEY", "n": "MENU_LABEL_PRESS_ANYKEY",
"s": "Press any key" "s": "Ýttu á takka"
}, },
{ {
"n": "MENU_LABEL_PRESS_ANYKEY_CONTINUE", "n": "MENU_LABEL_PRESS_ANYKEY_CONTINUE",
"s": "Press any key to continue" "s": "Ýttu á takka til að halda áfram"
}, },
{ {
"n": "MENU_LABEL_PRESS_START", "n": "MENU_LABEL_PRESS_START",
"s": "Press Start" "s": "Ýttu „Start"
}, },
{ {
"n": "MENU_LABEL_PRESS_START_CONTINUE", "n": "MENU_LABEL_PRESS_START_CONTINUE",
"s": "Press Start to continue" "s": "Ýttu „Start til að halda áfram"
}, },
{ {
"n": "MENU_LABEL_PREVIOUS", "n": "MENU_LABEL_PREVIOUS",
@@ -2227,11 +2227,11 @@
}, },
{ {
"n": "MENU_LANGUAGE_THIS", "n": "MENU_LANGUAGE_THIS",
"s": "English" "s": "Íslenska"
}, },
{ {
"n": "MENU_LANGUAGE_THIS_EN", "n": "MENU_LANGUAGE_THIS_EN",
"s": "English" "s": "Icelandic"
}, },
{ {
"n": "MENU_LOGIN", "n": "MENU_LOGIN",
@@ -2319,19 +2319,19 @@
}, },
{ {
"n": "MENU_NAME", "n": "MENU_NAME",
"s": "Name" "s": "Nafn"
}, },
{ {
"n": "MENU_NAME_FIRST", "n": "MENU_NAME_FIRST",
"s": "First Name" "s": "Fornafn"
}, },
{ {
"n": "MENU_NAME_LAST", "n": "MENU_NAME_LAST",
"s": "Last Name" "s": "Eftirnafn"
}, },
{ {
"n": "MENU_NAME_USER", "n": "MENU_NAME_USER",
"s": "Username" "s": "Notandanafn"
}, },
{ {
"n": "MENU_OPTIONS", "n": "MENU_OPTIONS",
@@ -2351,7 +2351,7 @@
}, },
{ {
"n": "MENU_OPTIONS_CONTROLS", "n": "MENU_OPTIONS_CONTROLS",
"s": "Controls" "s": "Stýringar"
}, },
{ {
"n": "MENU_OPTIONS_DIFFICULTY", "n": "MENU_OPTIONS_DIFFICULTY",
@@ -2359,7 +2359,7 @@
}, },
{ {
"n": "MENU_OPTIONS_DISPLAY", "n": "MENU_OPTIONS_DISPLAY",
"s": "Display" "s": "Skjár"
}, },
{ {
"n": "MENU_OPTIONS_EFFECT_DETAIL", "n": "MENU_OPTIONS_EFFECT_DETAIL",
@@ -2447,7 +2447,7 @@
}, },
{ {
"n": "MENU_OPTIONS_SIZE", "n": "MENU_OPTIONS_SIZE",
"s": "Size" "s": "Stærð"
}, },
{ {
"n": "MENU_OPTIONS_SOUND", "n": "MENU_OPTIONS_SOUND",

View File

@@ -0,0 +1,13 @@
{
"MENU_MONITOR_CALI_TITLE": "모니터 확인",
"MENU_MONITOR_CALI_LABEL_1": "1번 막대가 배경에서 눈에 띄어야 하고",
"MENU_MONITOR_CALI_LABEL_2": "30·31·32번 막대가 확실히 구분되어야 합니다",
"MENU_MONITOR_CALI_LABEL_3": " ",
"MENU_MONITOR_CALI_LABEL_4": "부적절한 모니터에서는 왼쪽 끝의 막대 몇 개가 보이지 않거나",
"MENU_MONITOR_CALI_LABEL_5": "오른쪽 끝의 막대 몇 개가 똑같게 보이거나",
"MENU_MONITOR_CALI_LABEL_6": "31번과 32번의 차이가 크게 보일 것입니다",
"MENU_MONITOR_CALI_LABEL_7": " ",
"MENU_MONITOR_CALI_LABEL_8": "적절한 모니터에서는 1번 막대에서 32번 막대까지 거의 일정하게 밝아지는 것으로 보입니다",
"MENU_MONITOR_CALI_LABEL_9": " ",
"MENU_MONITOR_CALI_LABEL_10": "모니터의 대비와 밝기 설정을 조절해 모니터를 조정해 주십시오"
}

View File

@@ -2,5 +2,5 @@
"MENU_LABEL_NEW_WORLD": "새 세계", "MENU_LABEL_NEW_WORLD": "새 세계",
"COPYRIGHT_PROPRIETARY": "모든 권리 보유.", "COPYRIGHT_PROPRIETARY": "모든 권리 보유.",
"APP_CALIBRATE_YOUR_MONITOR": "본 게임은 적절히 정된 모니터에서 최상으로 즐길 수 있습니다. 정하지 않았다면 플레이하기 전에 정해 주십시오." "APP_CALIBRATE_YOUR_MONITOR": "본 게임은 적절히 정된 모니터에서 최상으로 즐길 수 있습니다. 정하지 않았다면 플레이하기 전에 정해 주십시오."
} }

View File

@@ -29,7 +29,7 @@ object WriteGameMapData {
val path = Paths.get("${Terrarum.defaultSaveDir}" + val path = Paths.get("${Terrarum.defaultSaveDir}" +
"/$saveDirectoryName/${WriteMeta.META_FILENAME}") "/$saveDirectoryName/${WriteMeta.META_FILENAME}")
val tempPath = Files.createTempFile(path.toString(), "_temp") val tempPath = Files.createTempFile(path.toString(), "_temp")
val map = Terrarum.game.map val map = Terrarum.ingame.map
// TODO gzip // TODO gzip

View File

@@ -4,7 +4,7 @@
package net.torvald.spriteanimation package net.torvald.spriteanimation
import net.torvald.terrarum.StateGame import net.torvald.terrarum.StateInGame
import net.torvald.terrarum.Terrarum import net.torvald.terrarum.Terrarum
import com.jme3.math.FastMath import com.jme3.math.FastMath
import org.newdawn.slick.Graphics import org.newdawn.slick.Graphics
@@ -121,7 +121,7 @@ constructor() {
*/ */
@JvmOverloads fun render(g: Graphics, posX: Float, posY: Float, scale: Float = 1f) { @JvmOverloads fun render(g: Graphics, posX: Float, posY: Float, scale: Float = 1f) {
var scale = scale var scale = scale
scale *= Terrarum.game.screenZoom scale *= Terrarum.ingame.screenZoom
// Null checking // Null checking
if (currentImage == null) { if (currentImage == null) {
@@ -139,8 +139,8 @@ constructor() {
flippedImage.startUse() flippedImage.startUse()
flippedImage.drawEmbedded( flippedImage.drawEmbedded(
Math.round(posX * Terrarum.game.screenZoom).toFloat(), Math.round(posX * Terrarum.ingame.screenZoom).toFloat(),
Math.round(posY * Terrarum.game.screenZoom).toFloat(), Math.round(posY * Terrarum.ingame.screenZoom).toFloat(),
FastMath.floor(width * scale).toFloat(), FastMath.floor(width * scale).toFloat(),
FastMath.floor(height * scale).toFloat() FastMath.floor(height * scale).toFloat()
) )

View File

@@ -27,5 +27,5 @@ class StateFontTester : BasicGameState() {
} }
override fun getID(): Int = 666 override fun getID(): Int = Terrarum.SCENE_ID_TEST_FONT
} }

View File

@@ -35,7 +35,7 @@ import java.util.*
/** /**
* Created by minjaesong on 15-12-30. * Created by minjaesong on 15-12-30.
*/ */
class StateGame @Throws(SlickException::class) class StateInGame @Throws(SlickException::class)
constructor() : BasicGameState() { constructor() : BasicGameState() {
private val ACTOR_UPDATE_RANGE = 4096 private val ACTOR_UPDATE_RANGE = 4096
@@ -128,7 +128,7 @@ constructor() : BasicGameState() {
notifier = UIHandler(Notification()) notifier = UIHandler(Notification())
notifier.setPosition( notifier.setPosition(
(Terrarum.WIDTH - notifier.UI.width) / 2, Terrarum.HEIGHT - notifier.UI.height) (Terrarum.WIDTH - notifier.UI.width) / 2, Terrarum.HEIGHT - notifier.UI.height)
notifier.setVisibility(true) notifier.visible = true
// set smooth lighting as in config // set smooth lighting as in config
KeyToggler.forceSet(KEY_LIGHTMAP_SMOOTH, Terrarum.getConfigBoolean("smoothlighting")) KeyToggler.forceSet(KEY_LIGHTMAP_SMOOTH, Terrarum.getConfigBoolean("smoothlighting"))
@@ -251,10 +251,10 @@ constructor() : BasicGameState() {
// draw UIs // draw UIs
run { run {
uiContainer.forEach { ui -> ui.render(gc, g) } uiContainer.forEach { ui -> ui.render(gc, sbg, g) }
debugWindow.render(gc, g) debugWindow.render(gc, sbg, g)
consoleHandler.render(gc, g) consoleHandler.render(gc, sbg, g)
notifier.render(gc, g) notifier.render(gc, sbg, g)
} }
} }
@@ -415,8 +415,8 @@ constructor() : BasicGameState() {
(a.hitbox.centeredX - p.hitbox.centeredX).sqr() + (a.hitbox.centeredY - p.hitbox.centeredY).sqr() (a.hitbox.centeredX - p.hitbox.centeredX).sqr() + (a.hitbox.centeredY - p.hitbox.centeredY).sqr()
/** whether the actor is within screen */ /** whether the actor is within screen */
private fun Visible.inScreen() = distToActorSqr(this, player) <= private fun Visible.inScreen() = distToActorSqr(this, player) <=
(Terrarum.WIDTH.plus(this.hitbox.width.div(2)).times(1 / Terrarum.game.screenZoom).sqr() + (Terrarum.WIDTH.plus(this.hitbox.width.div(2)).times(1 / Terrarum.ingame.screenZoom).sqr() +
Terrarum.HEIGHT.plus(this.hitbox.height.div(2)).times(1 / Terrarum.game.screenZoom).sqr()) Terrarum.HEIGHT.plus(this.hitbox.height.div(2)).times(1 / Terrarum.ingame.screenZoom).sqr())
/** whether the actor is within update range */ /** whether the actor is within update range */
private fun Visible.inUpdateRange() = distToActorSqr(this, player) <= ACTOR_UPDATE_RANGE.sqr() private fun Visible.inUpdateRange() = distToActorSqr(this, player) <= ACTOR_UPDATE_RANGE.sqr()
/** /**

View File

@@ -0,0 +1,153 @@
package net.torvald.terrarum
import net.torvald.terrarum.langpack.Lang
import net.torvald.terrarum.ui.Typesetter
import net.torvald.terrarum.ui.UICanvas
import net.torvald.terrarum.ui.UIHandler
import net.torvald.terrarum.ui.UITypable
import org.newdawn.slick.Color
import org.newdawn.slick.GameContainer
import org.newdawn.slick.Graphics
import org.newdawn.slick.Input
import org.newdawn.slick.state.BasicGameState
import org.newdawn.slick.state.StateBasedGame
/**
* Created by minjaesong on 16-07-06.
*/
class StateMonitorCheck : BasicGameState() {
private lateinit var uiMonitorCheck: UIHandler
override fun init(gc: GameContainer, g: StateBasedGame) {
uiMonitorCheck = UIHandler(MonitorCheckUI())
uiMonitorCheck.visible = true
}
override fun update(gc: GameContainer, sbg: StateBasedGame, delta: Int) {
uiMonitorCheck.update(gc, delta)
}
override fun render(gc: GameContainer, sbg: StateBasedGame, g: Graphics) {
uiMonitorCheck.render(gc, sbg, g)
}
override fun keyPressed(key: Int, c: Char) {
//uiMonitorCheck.setAsClosing()
}
override fun getID(): Int = Terrarum.SCENE_ID_CONFIG_CALIBRATE
class MonitorCheckUI : UICanvas {
override var width = Terrarum.WIDTH
override var height = Terrarum.HEIGHT
override var openCloseTime = 150
private val colourLUT = arrayOf(
0x08, 0x10, 0x18, 0x20, 0x28, 0x30, 0x38, 0x40,
0x48, 0x50, 0x58, 0x60, 0x68, 0x70, 0x78, 0x80,
0x88, 0x90, 0x98, 0xA0, 0xA8, 0xB0, 0xB8, 0xC0,
0xC8, 0xD0, 0xD8, 0xE0, 0xE8, 0xF0, 0xF8, 0xFF
)
override fun update(gc: GameContainer, delta: Int) {
}
override fun render(gc: GameContainer, g: Graphics) {
val titleY = Terrarum.HEIGHT * 7 / 16
val instructionY = Terrarum.HEIGHT * 9 / 16
val anykeyY = Terrarum.HEIGHT * 15 / 16
val barWidthAll = Terrarum.WIDTH.div(100).times(100) * 9 / 10
val barWidth: Int = barWidthAll / 32 + 1
val barHeight = 90
val yCentre = Terrarum.HEIGHT.shr(1)
val barNumberGap = 5
g.background = Color.black
// draw bars
for (i in 0..31) {
val labelW = g.font.getWidth(i.plus(1).toString())
val labelH = g.font.lineHeight
val barXstart = center(Terrarum.WIDTH, barWidthAll) + i.times(barWidth)
val barYstart = center(yCentre, barHeight)
// bar start point indicator
if (i == 0) {
g.color = Color(0x404040)
g.drawLine(
barXstart.toFloat(), barYstart - barNumberGap - labelH.toFloat(),
barXstart.toFloat(), barYstart - barNumberGap.toFloat()
)
}
// bar numbers
if (i.plus(1) and 0x1 == 0 || i.plus(1) == 1) {
g.color = Color.white
g.drawString(
i.plus(1).toString(),
barXstart + center(barWidth, labelW).toFloat(),
barYstart - barNumberGap - labelH.toFloat()
)
}
// actual bar
g.color = Color(colourLUT[i], colourLUT[i], colourLUT[i])
g.fillRect(
barXstart.toFloat(),
barYstart.toFloat(),
barWidth.toFloat(),
barHeight.toFloat()
)
}
// messages background
g.color = Color(0x404040)
g.fillRect(
0f, Terrarum.HEIGHT.shr(1).toFloat(),
Terrarum.WIDTH.toFloat(), Terrarum.HEIGHT.shr(1).plus(1).toFloat()
)
// labels
g.color = Color.white
Typesetter.printCentered(
Lang["MENU_MONITOR_CALI_TITLE"],
titleY,
this, g
)
(1..10).forEach {
Typesetter.printCentered(
Lang["MENU_MONITOR_CALI_LABEL_$it"],
instructionY + it.minus(2).times(g.font.lineHeight),
this, g
)
}
Typesetter.printCentered(
Lang["MENU_LABEL_PRESS_ANYKEY_CONTINUE"],
anykeyY,
this, g
)
}
override fun processInput(input: Input) {
}
override fun doOpening(gc: GameContainer, delta: Int) {
}
override fun doClosing(gc: GameContainer, delta: Int) {
}
override fun endOpening(gc: GameContainer, delta: Int) {
}
override fun endClosing(gc: GameContainer, delta: Int) {
}
private fun center(x1: Int, x2: Int) = x1.minus(x2).div(2)
}
}

View File

@@ -47,6 +47,8 @@ constructor(gamename: String) : StateBasedGame(gamename) {
@Throws(SlickException::class) @Throws(SlickException::class)
override fun initStatesList(gc: GameContainer) { override fun initStatesList(gc: GameContainer) {
gc.input.enableKeyRepeat()
gameFont = GameFontWhite() gameFont = GameFontWhite()
smallNumbers = TinyAlphNum() smallNumbers = TinyAlphNum()
@@ -57,14 +59,20 @@ constructor(gamename: String) : StateBasedGame(gamename) {
} }
} }
appgc.input.enableKeyRepeat() //game = StateGame()
//addState(game)
game = StateGame() addState(StateMonitorCheck())
addState(game)
} }
companion object { companion object {
val sysLang: String
get() {
val lan = System.getProperty("user.language")
val country = System.getProperty("user.country")
return lan + country
}
/** /**
* To be used with physics simulator * To be used with physics simulator
*/ */
@@ -86,7 +94,7 @@ constructor(gamename: String) : StateBasedGame(gamename) {
var VSYNC = true var VSYNC = true
val VSYNC_TRIGGER_THRESHOLD = 56 val VSYNC_TRIGGER_THRESHOLD = 56
lateinit var game: StateGame lateinit var ingame: StateInGame
lateinit var gameConfig: GameConfig lateinit var gameConfig: GameConfig
lateinit var OSName: String lateinit var OSName: String
@@ -101,7 +109,7 @@ constructor(gamename: String) : StateBasedGame(gamename) {
private set private set
private val localeSimple = arrayOf("de", "en", "es", "it") private val localeSimple = arrayOf("de", "en", "es", "it")
var gameLocale = "en" // locale override var gameLocale = "####" // locale override
set(value) { set(value) {
if (localeSimple.contains(value.substring(0..1))) if (localeSimple.contains(value.substring(0..1)))
field = value.substring(0..1) field = value.substring(0..1)
@@ -114,8 +122,14 @@ constructor(gamename: String) : StateBasedGame(gamename) {
lateinit var smallNumbers: Font lateinit var smallNumbers: Font
private set private set
val SCENE_ID_HOME = 1 // 0x0 - 0xF: Game-related
val SCENE_ID_GAME = 3 // 0x10 - 0x1F: Config
// 0x100 and onward: unit tests for dev
val SCENE_ID_HOME = 0x1
val SCENE_ID_GAME = 0x3
val SCENE_ID_CONFIG_CALIBRATE = 0x11
val SCENE_ID_TEST_FONT = 0x100
var hasController = false var hasController = false
val CONTROLLER_DEADZONE = 0.1f val CONTROLLER_DEADZONE = 0.1f
@@ -258,20 +272,6 @@ constructor(gamename: String) : StateBasedGame(gamename) {
} }
// exception handling
val sysLang: String
get() {
val lan = System.getProperty("user.language")
var country = System.getProperty("user.country")
if (lan == "en") country = "US"
else if (lan == "fr") country = "FR"
else if (lan == "de") country = "DE"
else if (lan == "ko") country = "KR"
return lan + country
}
/** /**
* Return config from config set. If the config does not exist, default value will be returned. * Return config from config set. If the config does not exist, default value will be returned.
* @param key * @param key

View File

@@ -22,7 +22,7 @@ class Authenticator : ConsoleCommand {
Echo().execute(msg) Echo().execute(msg)
println("[Authenticator] " + msg) println("[Authenticator] " + msg)
a = !a a = !a
(Terrarum.game.consoleHandler.UI as ConsoleWindow).reset() (Terrarum.ingame.consoleHandler.UI as ConsoleWindow).reset()
} }
else { else {
printUsage() // thou shalt not pass! printUsage() // thou shalt not pass!

View File

@@ -1,6 +1,6 @@
package net.torvald.terrarum.console package net.torvald.terrarum.console
import net.torvald.terrarum.StateGame import net.torvald.terrarum.StateInGame
import net.torvald.terrarum.langpack.Lang import net.torvald.terrarum.langpack.Lang
import net.torvald.terrarum.ui.ConsoleWindow import net.torvald.terrarum.ui.ConsoleWindow

View File

@@ -29,7 +29,7 @@ object CommandDict {
Pair("exportav", ExportAV()), Pair("exportav", ExportAV()),
Pair("setgl", SetGlobalLightLevel()), Pair("setgl", SetGlobalLightLevel()),
Pair("getfaction", GetFactioning()), Pair("getfaction", GetFactioning()),
Pair("auth", Terrarum.game.auth), Pair("auth", Terrarum.ingame.auth),
Pair("spawnball", SpawnPhysTestBall()), Pair("spawnball", SpawnPhysTestBall()),
Pair("batch", Batch()), Pair("batch", Batch()),
Pair("settime", SetTime()), Pair("settime", SetTime()),

View File

@@ -43,7 +43,7 @@ object CommandInterpreter {
commandObj = CommandDict.getCommand(single_command.name.toLowerCase()) commandObj = CommandDict.getCommand(single_command.name.toLowerCase())
} }
else { else {
if (Terrarum.game.auth.b()) { if (Terrarum.ingame.auth.b()) {
commandObj = CommandDict.getCommand( commandObj = CommandDict.getCommand(
single_command.name.toLowerCase()) single_command.name.toLowerCase())
} }

View File

@@ -19,13 +19,13 @@ internal class Echo : ConsoleCommand {
val sb = StringBuilder() val sb = StringBuilder()
for (ch in single_line) { for (ch in single_line) {
if (ch == '\n') { if (ch == '\n') {
(Terrarum.game.consoleHandler.UI as ConsoleWindow).sendMessage(sb.toString()) (Terrarum.ingame.consoleHandler.UI as ConsoleWindow).sendMessage(sb.toString())
sb.delete(0, sb.length - 1) sb.delete(0, sb.length - 1)
} }
else else
sb.append(ch) sb.append(ch)
} }
(Terrarum.game.consoleHandler.UI as ConsoleWindow).sendMessage(sb.toString()) (Terrarum.ingame.consoleHandler.UI as ConsoleWindow).sendMessage(sb.toString())
} }
override fun printUsage() { override fun printUsage() {

View File

@@ -14,7 +14,7 @@ class Error : ConsoleCommand {
} }
fun execute(single_line: String) { fun execute(single_line: String) {
(Terrarum.game.consoleHandler.UI as ConsoleWindow).sendMessage("${GameFontBase.colToCode["r"]}$single_line") (Terrarum.ingame.consoleHandler.UI as ConsoleWindow).sendMessage("${GameFontBase.colToCode["r"]}$single_line")
} }
override fun printUsage() { override fun printUsage() {

View File

@@ -13,7 +13,7 @@ class ExportAV : ConsoleCommand {
if (args.size == 2) { if (args.size == 2) {
try { try {
JsonWriter.writeToFile( JsonWriter.writeToFile(
Terrarum.game.player.actorValue, Terrarum.ingame.player.actorValue,
Terrarum.defaultDir + "/Exports/" + args[1] + ".json") Terrarum.defaultDir + "/Exports/" + args[1] + ".json")
Echo().execute("ExportAV: exported to " + args[1] + ".json") Echo().execute("ExportAV: exported to " + args[1] + ".json")

View File

@@ -22,10 +22,10 @@ class ExportMap : ConsoleCommand {
if (args.size == 2) { if (args.size == 2) {
buildColorTable() buildColorTable()
var mapData = ByteArray(Terrarum.game.map.width * Terrarum.game.map.height * 3) var mapData = ByteArray(Terrarum.ingame.map.width * Terrarum.ingame.map.height * 3)
var mapDataPointer = 0 var mapDataPointer = 0
for (tile in Terrarum.game.map.terrainIterator()) { for (tile in Terrarum.ingame.map.terrainIterator()) {
val colArray = (colorTable as Map<Int, Col4096>) val colArray = (colorTable as Map<Int, Col4096>)
.getOrElse(tile, { Col4096(0xFFF) }).toByteArray() .getOrElse(tile, { Col4096(0xFFF) }).toByteArray()
@@ -44,7 +44,7 @@ class ExportMap : ConsoleCommand {
try { try {
RasterWriter.writePNG_RGB( RasterWriter.writePNG_RGB(
Terrarum.game.map.width, Terrarum.game.map.height, mapData, dir + args[1] + ".png") Terrarum.ingame.map.width, Terrarum.ingame.map.height, mapData, dir + args[1] + ".png")
Echo().execute("ExportMap: exported to " + args[1] + ".png") Echo().execute("ExportMap: exported to " + args[1] + ".png")
} }

View File

@@ -23,7 +23,7 @@ class GetAV : ConsoleCommand {
try { try {
if (args.size == 1) { if (args.size == 1) {
// print all actorvalue of player // print all actorvalue of player
val av = Terrarum.game.player.actorValue val av = Terrarum.ingame.player.actorValue
val keyset = av.keySet val keyset = av.keySet
echo.execute("$ccW== ActorValue list for ${ccY}player $ccW==") echo.execute("$ccW== ActorValue list for ${ccY}player $ccW==")
@@ -41,19 +41,19 @@ class GetAV : ConsoleCommand {
if (!args[1].isNum()) { // args[1] is ActorValue name if (!args[1].isNum()) { // args[1] is ActorValue name
echo.execute("${ccW}player.$ccM${args[1]} $ccW= " + echo.execute("${ccW}player.$ccM${args[1]} $ccW= " +
ccG + ccG +
Terrarum.game.player.actorValue[args[1]] + Terrarum.ingame.player.actorValue[args[1]] +
" $ccO" + " $ccO" +
Terrarum.game.player.actorValue[args[1]]!!.javaClass.simpleName Terrarum.ingame.player.actorValue[args[1]]!!.javaClass.simpleName
) )
println("[GetAV] player.${args[1]} = " + println("[GetAV] player.${args[1]} = " +
Terrarum.game.player.actorValue[args[1]] + Terrarum.ingame.player.actorValue[args[1]] +
" " + " " +
Terrarum.game.player.actorValue[args[1]]!!.javaClass.simpleName Terrarum.ingame.player.actorValue[args[1]]!!.javaClass.simpleName
) )
} }
else { else {
// args[1] is actor ID // args[1] is actor ID
val actor = Terrarum.game.getActorByID(args[1].toInt()) val actor = Terrarum.ingame.getActorByID(args[1].toInt())
val av = actor.actorValue val av = actor.actorValue
val keyset = av.keySet val keyset = av.keySet
@@ -75,14 +75,14 @@ class GetAV : ConsoleCommand {
val id = args[1].toInt() val id = args[1].toInt()
val av = args[2] val av = args[2]
echo.execute("$ccW$id.$ccM$av $ccW= $ccG" + echo.execute("$ccW$id.$ccM$av $ccW= $ccG" +
Terrarum.game.getActorByID(id).actorValue[av] + Terrarum.ingame.getActorByID(id).actorValue[av] +
" $ccO" + " $ccO" +
Terrarum.game.getActorByID(id).actorValue[av]!!.javaClass.simpleName Terrarum.ingame.getActorByID(id).actorValue[av]!!.javaClass.simpleName
) )
println("id.av = " + println("id.av = " +
Terrarum.game.getActorByID(id).actorValue[av] + Terrarum.ingame.getActorByID(id).actorValue[av] +
" " + " " +
Terrarum.game.getActorByID(id).actorValue[av]!!.javaClass.simpleName Terrarum.ingame.getActorByID(id).actorValue[av]!!.javaClass.simpleName
) )
} }
} }

View File

@@ -25,7 +25,7 @@ class GetFactioning : ConsoleCommand {
val error = Error() val error = Error()
fun printOutFactioning(id: Int) { fun printOutFactioning(id: Int) {
val a = Terrarum.game.getActorByID(id) val a = Terrarum.ingame.getActorByID(id)
if (a is Factionable) { if (a is Factionable) {
echo.execute("$ccW== Faction assignment for $ccY${if (id == Player.PLAYER_REF_ID) "player" else id.toString()} $ccW==") echo.execute("$ccW== Faction assignment for $ccY${if (id == Player.PLAYER_REF_ID) "player" else id.toString()} $ccW==")
println("[GetFactioning] == Faction assignment for '${if (id == Player.PLAYER_REF_ID) "player" else id.toString()}' ==") println("[GetFactioning] == Faction assignment for '${if (id == Player.PLAYER_REF_ID) "player" else id.toString()}' ==")

View File

@@ -8,7 +8,7 @@ import net.torvald.terrarum.Terrarum
class GetTime : ConsoleCommand { class GetTime : ConsoleCommand {
override fun execute(args: Array<String>) { override fun execute(args: Array<String>) {
val echo = Echo() val echo = Echo()
val worldTime = Terrarum.game.map.worldTime val worldTime = Terrarum.ingame.map.worldTime
echo.execute("Year ${worldTime.years}, Month ${worldTime.months}, " + echo.execute("Year ${worldTime.years}, Month ${worldTime.months}, " +
"Day ${worldTime.days} (${worldTime.getDayNameShort()}), " + "Day ${worldTime.days} (${worldTime.getDayNameShort()}), " +
"${worldTime.getFormattedTime()}" "${worldTime.getFormattedTime()}"

View File

@@ -14,7 +14,7 @@ import java.io.IOException
class GsonTest : ConsoleCommand { class GsonTest : ConsoleCommand {
override fun execute(args: Array<String>) { override fun execute(args: Array<String>) {
if (args.size == 2) { if (args.size == 2) {
val avelem = Gson().toJsonTree(Terrarum.game.player) val avelem = Gson().toJsonTree(Terrarum.ingame.player)
val jsonString = avelem.toString() val jsonString = avelem.toString()

View File

@@ -13,7 +13,7 @@ class Seed : ConsoleCommand {
// tsalagi // tsalagi
override fun execute(args: Array<String>) { override fun execute(args: Array<String>) {
Echo().execute("${ccY}Map$ccW: $ccG${Terrarum.game.map.generatorSeed}") Echo().execute("${ccY}Map$ccW: $ccG${Terrarum.ingame.map.generatorSeed}")
// TODO display randomiser seed // TODO display randomiser seed
} }

View File

@@ -1,7 +1,7 @@
package net.torvald.terrarum.console package net.torvald.terrarum.console
import net.torvald.imagefont.GameFontBase import net.torvald.imagefont.GameFontBase
import net.torvald.terrarum.StateGame import net.torvald.terrarum.StateInGame
import net.torvald.terrarum.Terrarum import net.torvald.terrarum.Terrarum
/** /**
@@ -70,7 +70,7 @@ internal class SetAV : ConsoleCommand {
return return
} }
Terrarum.game.player.actorValue[args[1]] = `val` Terrarum.ingame.player.actorValue[args[1]] = `val`
echo.execute("${ccW}Set $ccM${args[1]} ${ccW}for ${ccY}player ${ccW}to $ccG$`val`") echo.execute("${ccW}Set $ccM${args[1]} ${ccW}for ${ccY}player ${ccW}to $ccG$`val`")
println("[SetAV] set ActorValue '${args[1]}' for player to '$`val`'.") println("[SetAV] set ActorValue '${args[1]}' for player to '$`val`'.")
} }
@@ -78,7 +78,7 @@ internal class SetAV : ConsoleCommand {
try { try {
val id = args[1].toInt() val id = args[1].toInt()
val `val` = parseAVInput(args[3]) val `val` = parseAVInput(args[3])
val actor = Terrarum.game.getActorByID(id) val actor = Terrarum.ingame.getActorByID(id)
// check if av is number // check if av is number
if (args[2].isNum()) { if (args[2].isNum()) {

View File

@@ -25,7 +25,7 @@ class SetBulletin : ConsoleCommand {
* @param message real message * @param message real message
*/ */
fun send(message: Array<String>) { fun send(message: Array<String>) {
Terrarum.game.sendNotification(message) Terrarum.ingame.sendNotification(message)
println("sent notifinator") println("sent notifinator")
} }
} }

View File

@@ -15,7 +15,7 @@ class SetGlobalLightLevel : ConsoleCommand {
val b = args[3].toInt() val b = args[3].toInt()
val GL = LightmapRenderer.constructRGBFromInt(r, g, b) val GL = LightmapRenderer.constructRGBFromInt(r, g, b)
Terrarum.game.map.globalLight = GL Terrarum.ingame.map.globalLight = GL
} }
catch (e: NumberFormatException) { catch (e: NumberFormatException) {
Echo().execute("Wrong number input.") Echo().execute("Wrong number input.")
@@ -33,7 +33,7 @@ class SetGlobalLightLevel : ConsoleCommand {
Echo().execute("Range: 0-" + (LightmapRenderer.COLOUR_RANGE_SIZE - 1)) Echo().execute("Range: 0-" + (LightmapRenderer.COLOUR_RANGE_SIZE - 1))
} }
else { else {
Terrarum.game.map.globalLight = GL Terrarum.ingame.map.globalLight = GL
} }
} }
catch (e: NumberFormatException) { catch (e: NumberFormatException) {

View File

@@ -11,10 +11,10 @@ class SetTime : ConsoleCommand {
if (args.size == 2) { if (args.size == 2) {
val timeToSet = WorldTime.parseTime(args[1]) val timeToSet = WorldTime.parseTime(args[1])
Terrarum.game.map.worldTime.setTime(timeToSet) Terrarum.ingame.map.worldTime.setTime(timeToSet)
Echo().execute("Set time to ${Terrarum.game.map.worldTime.elapsedSeconds()} " + Echo().execute("Set time to ${Terrarum.ingame.map.worldTime.elapsedSeconds()} " +
"(${Terrarum.game.map.worldTime.hours}h${formatMin(Terrarum.game.map.worldTime.minutes)})") "(${Terrarum.ingame.map.worldTime.hours}h${formatMin(Terrarum.ingame.map.worldTime.minutes)})")
} }
else { else {
printUsage() printUsage()

View File

@@ -14,11 +14,11 @@ class SetTimeDelta : ConsoleCommand {
if (args[1].toInt() > HARD_LIMIT) if (args[1].toInt() > HARD_LIMIT)
Error().execute("Delta too large -- acceptable delta is 0-60.") Error().execute("Delta too large -- acceptable delta is 0-60.")
Terrarum.game.map.worldTime.setTimeDelta(args[1].toInt()) Terrarum.ingame.map.worldTime.setTimeDelta(args[1].toInt())
if (Terrarum.game.map.worldTime.timeDelta == 0) if (Terrarum.ingame.map.worldTime.timeDelta == 0)
Echo().execute("時間よ止まれ!ザ・ワルド!!") Echo().execute("時間よ止まれ!ザ・ワルド!!")
else else
Echo().execute("Set time delta to ${Terrarum.game.map.worldTime.timeDelta}") Echo().execute("Set time delta to ${Terrarum.ingame.map.worldTime.timeDelta}")
} }
else { else {
printUsage() printUsage()

View File

@@ -25,7 +25,7 @@ class SpawnPhysTestBall : ConsoleCommand {
) )
ball.elasticity = elasticity ball.elasticity = elasticity
Terrarum.game.addActor(ball) Terrarum.ingame.addActor(ball)
} }
else { else {
printUsage() printUsage()

View File

@@ -1,6 +1,6 @@
package net.torvald.terrarum.console package net.torvald.terrarum.console
import net.torvald.terrarum.StateGame import net.torvald.terrarum.StateInGame
import net.torvald.terrarum.mapdrawer.MapDrawer import net.torvald.terrarum.mapdrawer.MapDrawer
import net.torvald.terrarum.Terrarum import net.torvald.terrarum.Terrarum
@@ -26,7 +26,7 @@ class TeleportPlayer : ConsoleCommand {
return return
} }
Terrarum.game.player.setPosition(x.toDouble(), y.toDouble()) Terrarum.ingame.player.setPosition(x.toDouble(), y.toDouble())
} }
} }

View File

@@ -1,6 +1,6 @@
package net.torvald.terrarum.console package net.torvald.terrarum.console
import net.torvald.terrarum.StateGame import net.torvald.terrarum.StateInGame
import net.torvald.terrarum.Terrarum import net.torvald.terrarum.Terrarum
/** /**
@@ -8,9 +8,9 @@ import net.torvald.terrarum.Terrarum
*/ */
class ToggleNoClip : ConsoleCommand { class ToggleNoClip : ConsoleCommand {
override fun execute(args: Array<String>) { override fun execute(args: Array<String>) {
val status = Terrarum.game.player.isNoClip() val status = Terrarum.ingame.player.isNoClip()
Terrarum.game.player.setNoClip(!status) Terrarum.ingame.player.setNoClip(!status)
Echo().execute("Set no-clip status to " + (!status).toString()) Echo().execute("Set no-clip status to " + (!status).toString())
} }

View File

@@ -18,14 +18,14 @@ class Zoom : ConsoleCommand {
return return
} }
if (zoom < Terrarum.game.ZOOM_MIN) { if (zoom < Terrarum.ingame.ZOOM_MIN) {
zoom = Terrarum.game.ZOOM_MIN zoom = Terrarum.ingame.ZOOM_MIN
} }
else if (zoom > Terrarum.game.ZOOM_MAX) { else if (zoom > Terrarum.ingame.ZOOM_MAX) {
zoom = Terrarum.game.ZOOM_MAX zoom = Terrarum.ingame.ZOOM_MAX
} }
Terrarum.game.screenZoom = zoom Terrarum.ingame.screenZoom = zoom
System.gc() System.gc()

View File

@@ -40,7 +40,7 @@ abstract class Actor : Comparable<Actor>, Runnable {
var ret: Int var ret: Int
do { do {
ret = HQRNG().nextInt().and(0x7FFFFFFF) // set new ID ret = HQRNG().nextInt().and(0x7FFFFFFF) // set new ID
} while (Terrarum.game.hasActor(ret) || ret < ItemPropCodex.ITEM_UNIQUE_MAX) // check for collision } while (Terrarum.ingame.hasActor(ret) || ret < ItemPropCodex.ITEM_UNIQUE_MAX) // check for collision
return ret return ret
} }
} }

View File

@@ -24,7 +24,7 @@ open class ActorWithBody : Actor(), Visible {
@Transient var sprite: SpriteAnimation? = null @Transient var sprite: SpriteAnimation? = null
@Transient var spriteGlow: SpriteAnimation? = null @Transient var spriteGlow: SpriteAnimation? = null
@Transient private val map: GameMap = Terrarum.game.map @Transient private val map: GameMap = Terrarum.ingame.map
var hitboxTranslateX: Double = 0.0// relative to spritePosX var hitboxTranslateX: Double = 0.0// relative to spritePosX
var hitboxTranslateY: Double = 0.0// relative to spritePosY var hitboxTranslateY: Double = 0.0// relative to spritePosY
@@ -234,7 +234,7 @@ open class ActorWithBody : Actor(), Visible {
baseHitboxH * scale) baseHitboxH * scale)
} }
override fun run() = update(Terrarum.appgc, Terrarum.game.UPDATE_DELTA) override fun run() = update(Terrarum.appgc, Terrarum.ingame.UPDATE_DELTA)
/** /**
* Add vector value to the velocity, in the time unit of single frame. * Add vector value to the velocity, in the time unit of single frame.
@@ -929,8 +929,8 @@ open class ActorWithBody : Actor(), Visible {
private fun div16TruncateToMapWidth(x: Int): Int { private fun div16TruncateToMapWidth(x: Int): Int {
if (x < 0) if (x < 0)
return 0 return 0
else if (x >= Terrarum.game.map.width shl 4) else if (x >= Terrarum.ingame.map.width shl 4)
return Terrarum.game.map.width - 1 return Terrarum.ingame.map.width - 1
else else
return x and 0x7FFFFFFF shr 4 return x and 0x7FFFFFFF shr 4
} }
@@ -938,8 +938,8 @@ open class ActorWithBody : Actor(), Visible {
private fun div16TruncateToMapHeight(y: Int): Int { private fun div16TruncateToMapHeight(y: Int): Int {
if (y < 0) if (y < 0)
return 0 return 0
else if (y >= Terrarum.game.map.height shl 4) else if (y >= Terrarum.ingame.map.height shl 4)
return Terrarum.game.map.height - 1 return Terrarum.ingame.map.height - 1
else else
return y and 0x7FFFFFFF shr 4 return y and 0x7FFFFFFF shr 4
} }

View File

@@ -75,11 +75,11 @@ open class NPCIntelligentBase : ActorWithBody()
} }
override fun addHouseTile(x: Int, y: Int) { override fun addHouseTile(x: Int, y: Int) {
houseTiles.add(Terrarum.game.map.width * y + x) houseTiles.add(Terrarum.ingame.map.width * y + x)
} }
override fun removeHouseTile(x: Int, y: Int) { override fun removeHouseTile(x: Int, y: Int) {
houseTiles.remove(Terrarum.game.map.width * y + x) houseTiles.remove(Terrarum.ingame.map.width * y + x)
} }
override fun clearHouseDesignation() { override fun clearHouseDesignation() {

View File

@@ -10,6 +10,6 @@ class ThreadActorUpdate(val startIndex: Int, val endIndex: Int,
val gc: GameContainer, val delta: Int) : Runnable { val gc: GameContainer, val delta: Int) : Runnable {
override fun run() { override fun run() {
for (i in startIndex..endIndex) for (i in startIndex..endIndex)
Terrarum.game.actorContainer[i].update(gc, delta) Terrarum.ingame.actorContainer[i].update(gc, delta)
} }
} }

View File

@@ -39,7 +39,7 @@ object CollisionSolver {
collCandidateY.clear() collCandidateY.clear()
// mark list x // mark list x
Terrarum.game.actorContainer.forEach { it -> Terrarum.ingame.actorContainer.forEach { it ->
if (it is ActorWithBody) { if (it is ActorWithBody) {
collListX.add(CollisionMarkings(it.hitbox.hitboxStart.x, STARTPOINT, it)) collListX.add(CollisionMarkings(it.hitbox.hitboxStart.x, STARTPOINT, it))
collListX.add(CollisionMarkings(it.hitbox.hitboxEnd.x, ENDPOINT, it)) collListX.add(CollisionMarkings(it.hitbox.hitboxEnd.x, ENDPOINT, it))
@@ -68,7 +68,7 @@ object CollisionSolver {
collCandidateStack.clear() collCandidateStack.clear()
// mark list y // mark list y
Terrarum.game.actorContainer.forEach { it -> Terrarum.ingame.actorContainer.forEach { it ->
if (it is ActorWithBody) { if (it is ActorWithBody) {
collListY.add(CollisionMarkings(it.hitbox.hitboxStart.y, STARTPOINT, it)) collListY.add(CollisionMarkings(it.hitbox.hitboxStart.y, STARTPOINT, it))
collListY.add(CollisionMarkings(it.hitbox.hitboxEnd.y, ENDPOINT, it)) collListY.add(CollisionMarkings(it.hitbox.hitboxEnd.y, ENDPOINT, it))

View File

@@ -16,33 +16,33 @@ import org.newdawn.slick.Input
object GameController { object GameController {
fun processInput(input: Input) { fun processInput(input: Input) {
val mouseTileX = ((MapCamera.cameraX + input.mouseX / Terrarum.game.screenZoom) / MapDrawer.TILE_SIZE).toInt() val mouseTileX = ((MapCamera.cameraX + input.mouseX / Terrarum.ingame.screenZoom) / MapDrawer.TILE_SIZE).toInt()
val mouseTileY = ((MapCamera.cameraY + input.mouseY / Terrarum.game.screenZoom) / MapDrawer.TILE_SIZE).toInt() val mouseTileY = ((MapCamera.cameraY + input.mouseY / Terrarum.ingame.screenZoom) / MapDrawer.TILE_SIZE).toInt()
KeyToggler.update(input) KeyToggler.update(input)
if (!Terrarum.game.consoleHandler.isTakingControl) { if (!Terrarum.ingame.consoleHandler.isTakingControl) {
if (Terrarum.game.player.vehicleRiding != null) { if (Terrarum.ingame.player.vehicleRiding != null) {
Terrarum.game.player.vehicleRiding!!.processInput(input) Terrarum.ingame.player.vehicleRiding!!.processInput(input)
} }
Terrarum.game.player.processInput(input) Terrarum.ingame.player.processInput(input)
for (ui in Terrarum.game.uiContainer) { for (ui in Terrarum.ingame.uiContainer) {
ui.processInput(input) ui.processInput(input)
} }
} }
else { else {
Terrarum.game.consoleHandler.processInput(input) Terrarum.ingame.consoleHandler.processInput(input)
} }
if (input.isMouseButtonDown(Input.MOUSE_LEFT_BUTTON)) { if (input.isMouseButtonDown(Input.MOUSE_LEFT_BUTTON)) {
// test tile remove // test tile remove
try { try {
Terrarum.game.map.setTileTerrain(mouseTileX, mouseTileY, TileNameCode.AIR) Terrarum.ingame.map.setTileTerrain(mouseTileX, mouseTileY, TileNameCode.AIR)
// terrarum.game.map.setTileWall(mouseTileX, mouseTileY, TileNameCode.AIR); // terrarum.game.map.setTileWall(mouseTileX, mouseTileY, TileNameCode.AIR);
} }
catch (e: ArrayIndexOutOfBoundsException) { catch (e: ArrayIndexOutOfBoundsException) {
@@ -52,7 +52,7 @@ object GameController {
else if (input.isMouseButtonDown(Input.MOUSE_RIGHT_BUTTON)) { else if (input.isMouseButtonDown(Input.MOUSE_RIGHT_BUTTON)) {
// test tile place // test tile place
try { try {
Terrarum.game.map.setTileTerrain(mouseTileX, mouseTileY, Terrarum.game.player.actorValue.getAsInt("selectedtile")!!) Terrarum.ingame.map.setTileTerrain(mouseTileX, mouseTileY, Terrarum.ingame.player.actorValue.getAsInt("selectedtile")!!)
} }
catch (e: ArrayIndexOutOfBoundsException) { catch (e: ArrayIndexOutOfBoundsException) {
} }
@@ -62,23 +62,23 @@ object GameController {
fun keyPressed(key: Int, c: Char) { fun keyPressed(key: Int, c: Char) {
if (keyPressedByCode(key, EnumKeyFunc.UI_CONSOLE)) { if (keyPressedByCode(key, EnumKeyFunc.UI_CONSOLE)) {
Terrarum.game.consoleHandler.toggleOpening() Terrarum.ingame.consoleHandler.toggleOpening()
} }
else if (keyPressedByCode(key, EnumKeyFunc.UI_BASIC_INFO)) { else if (keyPressedByCode(key, EnumKeyFunc.UI_BASIC_INFO)) {
Terrarum.game.debugWindow.toggleOpening() Terrarum.ingame.debugWindow.toggleOpening()
} }
if (!Terrarum.game.consoleHandler.isTakingControl) { if (!Terrarum.ingame.consoleHandler.isTakingControl) {
if (Terrarum.game.player.vehicleRiding != null) { if (Terrarum.ingame.player.vehicleRiding != null) {
Terrarum.game.player.vehicleRiding!!.keyPressed(key, c) Terrarum.ingame.player.vehicleRiding!!.keyPressed(key, c)
} }
Terrarum.game.player.keyPressed(key, c) Terrarum.ingame.player.keyPressed(key, c)
} }
else { else {
Terrarum.game.consoleHandler.keyPressed(key, c) Terrarum.ingame.consoleHandler.keyPressed(key, c)
} }
//System.out.println(String.valueOf(key) + ", " + String.valueOf(c)); //System.out.println(String.valueOf(key) + ", " + String.valueOf(c));

View File

@@ -32,7 +32,7 @@ object ItemPropCodex {
if (code < ITEM_UNIQUE_MAX) // generic item if (code < ITEM_UNIQUE_MAX) // generic item
return itemCodex[code] return itemCodex[code]
else { else {
val a = Terrarum.game.getActorByID(code) // actor item val a = Terrarum.ingame.getActorByID(code) // actor item
if (a is CanBeAnItem) return a.itemData if (a is CanBeAnItem) return a.itemData
throw IllegalArgumentException("Attempted to get item data of actor that cannot be an item. ($a)") throw IllegalArgumentException("Attempted to get item data of actor that cannot be an item. ($a)")

View File

@@ -20,16 +20,16 @@ object LightmapRenderer {
val overscan_open: Int = Math.min(32, 256f.div(TilePropCodex.getProp(TileNameCode.AIR).opacity and 0xFF).toFloat().ceil()) val overscan_open: Int = Math.min(32, 256f.div(TilePropCodex.getProp(TileNameCode.AIR).opacity and 0xFF).toFloat().ceil())
val overscan_opaque: Int = Math.min(8, 256f.div(TilePropCodex.getProp(TileNameCode.STONE).opacity and 0xFF).toFloat().ceil()) val overscan_opaque: Int = Math.min(8, 256f.div(TilePropCodex.getProp(TileNameCode.STONE).opacity and 0xFF).toFloat().ceil())
private val LIGHTMAP_WIDTH = Terrarum.game.ZOOM_MIN.inv().times(Terrarum.WIDTH) private val LIGHTMAP_WIDTH = Terrarum.ingame.ZOOM_MIN.inv().times(Terrarum.WIDTH)
.div(MapDrawer.TILE_SIZE).ceil() + overscan_open * 2 + 3 .div(MapDrawer.TILE_SIZE).ceil() + overscan_open * 2 + 3
private val LIGHTMAP_HEIGHT = Terrarum.game.ZOOM_MIN.inv().times(Terrarum.HEIGHT) private val LIGHTMAP_HEIGHT = Terrarum.ingame.ZOOM_MIN.inv().times(Terrarum.HEIGHT)
.div(MapDrawer.TILE_SIZE).ceil() + overscan_open * 2 + 3 .div(MapDrawer.TILE_SIZE).ceil() + overscan_open * 2 + 3
/** /**
* 8-Bit RGB values * 8-Bit RGB values
*/ */
private val lightmap: Array<IntArray> = Array(LIGHTMAP_HEIGHT) { IntArray(LIGHTMAP_WIDTH) } private val lightmap: Array<IntArray> = Array(LIGHTMAP_HEIGHT) { IntArray(LIGHTMAP_WIDTH) }
private val lanternMap = ArrayList<Lantern>(Terrarum.game.ACTORCONTAINER_INITIAL_SIZE * 4) private val lanternMap = ArrayList<Lantern>(Terrarum.ingame.ACTORCONTAINER_INITIAL_SIZE * 4)
private val AIR = TileNameCode.AIR private val AIR = TileNameCode.AIR
@@ -171,7 +171,7 @@ object LightmapRenderer {
// scan for luminous actors and store their lighting info to the lanterns // scan for luminous actors and store their lighting info to the lanterns
lanternMap.clear() lanternMap.clear()
Terrarum.game.actorContainer.forEach { it -> Terrarum.ingame.actorContainer.forEach { it ->
if (it is Luminous && it is Visible) { if (it is Luminous && it is Visible) {
// put lanterns to the area the luminantBox is occupying // put lanterns to the area the luminantBox is occupying
for (lightBox in it.lightBoxList) { for (lightBox in it.lightBoxList) {
@@ -228,11 +228,11 @@ object LightmapRenderer {
private fun calculate(x: Int, y: Int, doNotCalculateAmbient: Boolean): Int { private fun calculate(x: Int, y: Int, doNotCalculateAmbient: Boolean): Int {
var lightLevelThis: Int = 0 var lightLevelThis: Int = 0
val thisTerrain = Terrarum.game.map.getTileFromTerrain(x, y) val thisTerrain = Terrarum.ingame.map.getTileFromTerrain(x, y)
val thisWall = Terrarum.game.map.getTileFromWall(x, y) val thisWall = Terrarum.ingame.map.getTileFromWall(x, y)
val thisTileLuminosity = TilePropCodex.getProp(thisTerrain).luminosity val thisTileLuminosity = TilePropCodex.getProp(thisTerrain).luminosity
val thisTileOpacity = TilePropCodex.getProp(thisTerrain).opacity val thisTileOpacity = TilePropCodex.getProp(thisTerrain).opacity
val sunLight = Terrarum.game.map.globalLight val sunLight = Terrarum.ingame.map.globalLight
// MIX TILE // MIX TILE
// open air // open air
@@ -315,8 +315,8 @@ object LightmapRenderer {
var x = this_x_start var x = this_x_start
while (x < this_x_end) { while (x < this_x_end) {
// smoothing enabled // smoothing enabled
if (Terrarum.game.screenZoom >= 1 if (Terrarum.ingame.screenZoom >= 1
&& Terrarum.gameConfig.getAsBoolean("smoothlighting") ?: false) { && Terrarum.gameConfig.getAsBoolean("smoothlighting") ?: false) {
val thisLightLevel = getLight(x, y) ?: 0 val thisLightLevel = getLight(x, y) ?: 0
@@ -333,10 +333,10 @@ object LightmapRenderer {
g.color = Color(0) g.color = Color(0)
g.fillRect( g.fillRect(
(x.toFloat() * TSIZE.toFloat() * Terrarum.game.screenZoom).round().toFloat(), (x.toFloat() * TSIZE.toFloat() * Terrarum.ingame.screenZoom).round().toFloat(),
(y.toFloat() * TSIZE.toFloat() * Terrarum.game.screenZoom).round().toFloat(), (y.toFloat() * TSIZE.toFloat() * Terrarum.ingame.screenZoom).round().toFloat(),
((TSIZE * Terrarum.game.screenZoom).ceil() * zeroLevelCounter).toFloat(), ((TSIZE * Terrarum.ingame.screenZoom).ceil() * zeroLevelCounter).toFloat(),
(TSIZE * Terrarum.game.screenZoom).ceil().toFloat() (TSIZE * Terrarum.ingame.screenZoom).ceil().toFloat()
) )
x += zeroLevelCounter - 1 x += zeroLevelCounter - 1
@@ -382,12 +382,12 @@ object LightmapRenderer {
g.color = Color(colourMapItoL[iy * 2 + ix].rgb30ClampTo24()) g.color = Color(colourMapItoL[iy * 2 + ix].rgb30ClampTo24())
g.fillRect( g.fillRect(
(x.toFloat() * TSIZE.toFloat() * Terrarum.game.screenZoom).round() (x.toFloat() * TSIZE.toFloat() * Terrarum.ingame.screenZoom).round()
+ ix * TSIZE / 2 * Terrarum.game.screenZoom, + ix * TSIZE / 2 * Terrarum.ingame.screenZoom,
(y.toFloat() * TSIZE.toFloat() * Terrarum.game.screenZoom).round() (y.toFloat() * TSIZE.toFloat() * Terrarum.ingame.screenZoom).round()
+ iy * TSIZE / 2 * Terrarum.game.screenZoom, + iy * TSIZE / 2 * Terrarum.ingame.screenZoom,
(TSIZE * Terrarum.game.screenZoom / 2).ceil().toFloat(), (TSIZE * Terrarum.ingame.screenZoom / 2).ceil().toFloat(),
(TSIZE * Terrarum.game.screenZoom / 2).ceil().toFloat() (TSIZE * Terrarum.ingame.screenZoom / 2).ceil().toFloat()
) )
} }
} }
@@ -408,10 +408,10 @@ object LightmapRenderer {
g.color = Color((getLight(x, y) ?: 0).rgb30ClampTo24()) g.color = Color((getLight(x, y) ?: 0).rgb30ClampTo24())
g.fillRect( g.fillRect(
(x.toFloat() * TSIZE.toFloat() * Terrarum.game.screenZoom).round().toFloat(), (x.toFloat() * TSIZE.toFloat() * Terrarum.ingame.screenZoom).round().toFloat(),
(y.toFloat() * TSIZE.toFloat() * Terrarum.game.screenZoom).round().toFloat(), (y.toFloat() * TSIZE.toFloat() * Terrarum.ingame.screenZoom).round().toFloat(),
((TSIZE * Terrarum.game.screenZoom).ceil() * sameLevelCounter).toFloat(), ((TSIZE * Terrarum.ingame.screenZoom).ceil() * sameLevelCounter).toFloat(),
(TSIZE * Terrarum.game.screenZoom).ceil().toFloat() (TSIZE * Terrarum.ingame.screenZoom).ceil().toFloat()
) )
x += sameLevelCounter - 1 x += sameLevelCounter - 1

View File

@@ -20,7 +20,7 @@ import java.util.*
* Created by minjaesong on 16-01-19. * Created by minjaesong on 16-01-19.
*/ */
object MapCamera { object MapCamera {
val map: GameMap = Terrarum.game.map; val map: GameMap = Terrarum.ingame.map;
var cameraX = 0 var cameraX = 0
private set private set
@@ -229,10 +229,10 @@ object MapCamera {
) )
fun update(gc: GameContainer, delta_t: Int) { fun update(gc: GameContainer, delta_t: Int) {
val player = Terrarum.game.player val player = Terrarum.ingame.player
renderWidth = FastMath.ceil(Terrarum.WIDTH / Terrarum.game.screenZoom) // div, not mul renderWidth = FastMath.ceil(Terrarum.WIDTH / Terrarum.ingame.screenZoom) // div, not mul
renderHeight = FastMath.ceil(Terrarum.HEIGHT / Terrarum.game.screenZoom) renderHeight = FastMath.ceil(Terrarum.HEIGHT / Terrarum.ingame.screenZoom)
// position - (WH / 2) // position - (WH / 2)
cameraX = Math.round(FastMath.clamp( cameraX = Math.round(FastMath.clamp(
@@ -425,13 +425,13 @@ object MapCamera {
} }
private fun drawTile(mode: Int, tilewisePosX: Int, tilewisePosY: Int, sheetX: Int, sheetY: Int) { private fun drawTile(mode: Int, tilewisePosX: Int, tilewisePosY: Int, sheetX: Int, sheetY: Int) {
if (Terrarum.game.screenZoom == 1f) { if (Terrarum.ingame.screenZoom == 1f) {
tilesetBook[mode].renderInUse( tilesetBook[mode].renderInUse(
FastMath.floor((tilewisePosX * TSIZE).toFloat()), FastMath.floor((tilewisePosY * TSIZE).toFloat()), sheetX, sheetY) FastMath.floor((tilewisePosX * TSIZE).toFloat()), FastMath.floor((tilewisePosY * TSIZE).toFloat()), sheetX, sheetY)
} else { } else {
tilesetBook[mode].getSprite( tilesetBook[mode].getSprite(
sheetX, sheetY).drawEmbedded( sheetX, sheetY).drawEmbedded(
Math.round(tilewisePosX.toFloat() * TSIZE.toFloat() * Terrarum.game.screenZoom).toFloat(), Math.round(tilewisePosY.toFloat() * TSIZE.toFloat() * Terrarum.game.screenZoom).toFloat(), FastMath.ceil(TSIZE * Terrarum.game.screenZoom).toFloat(), FastMath.ceil(TSIZE * Terrarum.game.screenZoom).toFloat()) Math.round(tilewisePosX.toFloat() * TSIZE.toFloat() * Terrarum.ingame.screenZoom).toFloat(), Math.round(tilewisePosY.toFloat() * TSIZE.toFloat() * Terrarum.ingame.screenZoom).toFloat(), FastMath.ceil(TSIZE * Terrarum.ingame.screenZoom).toFloat(), FastMath.ceil(TSIZE * Terrarum.ingame.screenZoom).toFloat())
} }
} }

View File

@@ -47,7 +47,7 @@ object MapDrawer {
val colTemp_cold = colTempLinearFunc(onscreen_cold_tiles / onscreen_tiles_cap) val colTemp_cold = colTempLinearFunc(onscreen_cold_tiles / onscreen_tiles_cap)
val colTemp_warm = colTempLinearFunc(-(onscreen_warm_tiles / onscreen_tiles_cap)) val colTemp_warm = colTempLinearFunc(-(onscreen_warm_tiles / onscreen_tiles_cap))
colTemp = colTemp_warm + colTemp_cold - ENV_COLTEMP_NOON colTemp = colTemp_warm + colTemp_cold - ENV_COLTEMP_NOON
val zoom = Terrarum.game.screenZoom val zoom = Terrarum.ingame.screenZoom
g.color = getColourFromMap(colTemp) g.color = getColourFromMap(colTemp)
//g.color = getColourFromMap(3022) //g.color = getColourFromMap(3022)

View File

@@ -8,17 +8,17 @@ import net.torvald.terrarum.gameactors.faction.FactionCodex
*/ */
object RealEstateUtility { object RealEstateUtility {
fun getAbsoluteTileNumber(x: Int, y: Int): Long = fun getAbsoluteTileNumber(x: Int, y: Int): Long =
(Terrarum.game.map.width * y).toLong() + x (Terrarum.ingame.map.width * y).toLong() + x
fun resolveAbsoluteTileNumber(t: Long): Pair<Int, Int> = fun resolveAbsoluteTileNumber(t: Long): Pair<Int, Int> =
Pair((t % Terrarum.game.map.width).toInt(), (t / Terrarum.game.map.width).toInt()) Pair((t % Terrarum.ingame.map.width).toInt(), (t / Terrarum.ingame.map.width).toInt())
/** /**
* Get owner ID as an Actor/Faction * Get owner ID as an Actor/Faction
*/ */
fun resolveOwner(id: Long): Any = fun resolveOwner(id: Long): Any =
if (id < 0x80000000L) if (id < 0x80000000L)
Terrarum.game.getActorByID(id.toInt()) Terrarum.ingame.getActorByID(id.toInt())
else else
FactionCodex.getFactionByID(id) FactionCodex.getFactionByID(id)
} }

View File

@@ -92,8 +92,8 @@ object TilePropUtil {
fun getDynamicLumFunc(baseLum: Int, type: Int): Int { fun getDynamicLumFunc(baseLum: Int, type: Int): Int {
return when (type) { return when (type) {
1 -> getTorchFlicker(baseLum) 1 -> getTorchFlicker(baseLum)
2 -> Terrarum.game.map.globalLight // current global light 2 -> Terrarum.ingame.map.globalLight // current global light
3 -> Terrarum.game.globalLightByTime(WorldTime.DAY_LENGTH / 2) // daylight at noon 3 -> Terrarum.ingame.globalLightByTime(WorldTime.DAY_LENGTH / 2) // daylight at noon
4 -> getSlowBreath(baseLum) 4 -> getSlowBreath(baseLum)
5 -> getPulsate(baseLum) 5 -> getPulsate(baseLum)
else -> baseLum else -> baseLum

View File

@@ -27,8 +27,8 @@ object TileStats {
// Get stats on no-zoomed screen area. In other words, will behave as if screen zoom were 1.0 // Get stats on no-zoomed screen area. In other words, will behave as if screen zoom were 1.0
// no matter how the screen is zoomed. // no matter how the screen is zoomed.
val map = Terrarum.game.map val map = Terrarum.ingame.map
val player = Terrarum.game.player val player = Terrarum.ingame.player
val renderWidth = FastMath.ceil(Terrarum.WIDTH.toFloat()) val renderWidth = FastMath.ceil(Terrarum.WIDTH.toFloat())
val renderHeight = FastMath.ceil(Terrarum.HEIGHT.toFloat()) val renderHeight = FastMath.ceil(Terrarum.HEIGHT.toFloat())

View File

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

View File

@@ -151,7 +151,7 @@ class ConsoleWindow : UICanvas, UITypable {
prevCommand = "" prevCommand = ""
commandInputPool = StringBuilder() 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) { 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 net.torvald.terrarum.Terrarum
import com.jme3.math.FastMath import com.jme3.math.FastMath
import org.newdawn.slick.* 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. * Created by minjaesong on 15-12-31.
*/ */
class UIHandler class UIHandler
@@ -33,10 +38,15 @@ constructor(val UI: UICanvas) {
private var opening = false private var opening = false
private var closing = false private var closing = false
private var opened = false // fully opened private var opened = false // fully opened
private var _visible = false var visible: Boolean = false
val visible: Boolean
get() = if (alwaysVisible) true 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 var openCloseCounter = 0
@@ -51,12 +61,12 @@ constructor(val UI: UICanvas) {
fun update(gc: GameContainer, delta: Int) { fun update(gc: GameContainer, delta: Int) {
if (_visible || alwaysVisible) { if (visible || alwaysVisible) {
UI.update(gc, delta) UI.update(gc, delta)
} }
if (opening) { if (opening) {
_visible = true visible = true
openCloseCounter += delta openCloseCounter += delta
// println("UI ${UI.javaClass.simpleName} (open)") // println("UI ${UI.javaClass.simpleName} (open)")
@@ -87,23 +97,31 @@ constructor(val UI: UICanvas) {
UI.endClosing(gc, delta) UI.endClosing(gc, delta)
closing = false closing = false
opened = false opened = false
_visible = false visible = false
openCloseCounter = 0 openCloseCounter = 0
} }
} }
} }
fun render(gc: GameContainer, gameGraphicInstance: Graphics) { fun render(gc: GameContainer, sbg: StateBasedGame, gameGraphicInstance: Graphics) {
if (_visible || alwaysVisible) { if (visible || alwaysVisible) {
UIGraphicInstance.clear() UIGraphicInstance.clear()
UIGraphicInstance.font = Terrarum.gameFont UIGraphicInstance.font = Terrarum.gameFont
UI.render(gc, UIGraphicInstance) UI.render(gc, UIGraphicInstance)
gameGraphicInstance.drawImage(UIDrawnCanvas, if (sbg.currentStateID == Terrarum.SCENE_ID_GAME) {
posX + MapCamera.cameraX * Terrarum.game.screenZoom, gameGraphicInstance.drawImage(UIDrawnCanvas,
posY + MapCamera.cameraY * Terrarum.game.screenZoom posX + MapCamera.cameraX * Terrarum.ingame.screenZoom,
)// compensate for screenZoom AND camera translation posY + MapCamera.cameraY * Terrarum.ingame.screenZoom
// (see Game.render -> g.translate()) )// 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 posY = y
} }
fun setVisibility(b: Boolean) {
if (alwaysVisible) {
throw RuntimeException("[UIHandler] Tried to 'set visibility of' constant UI")
}
_visible = b
}
fun setAsAlwaysVisible() { fun setAsAlwaysVisible() {
alwaysVisible = true alwaysVisible = true
_visible = true visible = true
opened = true opened = true
opening = false opening = false
closing = false closing = false
} }
/**
* Send OPEN signal to the attached UI.
*/
fun setAsOpening() { fun setAsOpening() {
if (alwaysVisible) { if (alwaysVisible) {
throw RuntimeException("[UIHandler] Tried to 'open' constant UI") throw RuntimeException("[UIHandler] Tried to 'open' constant UI")
@@ -136,6 +149,9 @@ constructor(val UI: UICanvas) {
opening = true opening = true
} }
/**
* Send CLOSE signal to the attached UI.
*/
fun setAsClosing() { fun setAsClosing() {
if (alwaysVisible) { if (alwaysVisible) {
throw RuntimeException("[UIHandler] Tried to 'close' constant UI") throw RuntimeException("[UIHandler] Tried to 'close' constant UI")
@@ -148,7 +164,7 @@ constructor(val UI: UICanvas) {
if (alwaysVisible) { if (alwaysVisible) {
throw RuntimeException("[UIHandler] Tried to 'toggle opening of' constant UI") throw RuntimeException("[UIHandler] Tried to 'toggle opening of' constant UI")
} }
if (_visible) { if (visible) {
if (!closing) { if (!closing) {
setAsClosing() setAsClosing()
} }
@@ -161,61 +177,61 @@ constructor(val UI: UICanvas) {
} }
fun processInput(input: Input) { fun processInput(input: Input) {
if (_visible) { if (visible) {
UI.processInput(input) UI.processInput(input)
} }
} }
fun keyPressed(key: Int, c: Char) { fun keyPressed(key: Int, c: Char) {
if (_visible && UI is UITypable) { if (visible && UI is UITypable) {
UI.keyPressed(key, c) UI.keyPressed(key, c)
} }
} }
fun keyReleased(key: Int, c: Char) { fun keyReleased(key: Int, c: Char) {
if (_visible && UI is UITypable) { if (visible && UI is UITypable) {
UI.keyReleased(key, c) UI.keyReleased(key, c)
} }
} }
fun mouseMoved(oldx: Int, oldy: Int, newx: Int, newy: Int) { 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) UI.mouseMoved(oldx, oldy, newx, newy)
} }
} }
fun mouseDragged(oldx: Int, oldy: Int, newx: Int, newy: Int) { 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) UI.mouseDragged(oldx, oldy, newx, newy)
} }
} }
fun mousePressed(button: Int, x: Int, y: Int) { fun mousePressed(button: Int, x: Int, y: Int) {
if (_visible && UI is UIClickable) { if (visible && UI is UIClickable) {
UI.mousePressed(button, x, y) UI.mousePressed(button, x, y)
} }
} }
fun mouseReleased(button: Int, x: Int, y: Int) { fun mouseReleased(button: Int, x: Int, y: Int) {
if (_visible && UI is UIClickable) { if (visible && UI is UIClickable) {
UI.mouseReleased(button, x, y) UI.mouseReleased(button, x, y)
} }
} }
fun mouseWheelMoved(change: Int) { fun mouseWheelMoved(change: Int) {
if (_visible && UI is UIClickable) { if (visible && UI is UIClickable) {
UI.mouseWheelMoved(change) UI.mouseWheelMoved(change)
} }
} }
fun controllerButtonPressed(controller: Int, button: Int) { fun controllerButtonPressed(controller: Int, button: Int) {
if (_visible && UI is UIClickable) { if (visible && UI is UIClickable) {
UI.controllerButtonPressed(controller, button) UI.controllerButtonPressed(controller, button)
} }
} }
fun controllerButtonReleased(controller: Int, button: Int) { fun controllerButtonReleased(controller: Int, button: Int) {
if (_visible && UI is UIClickable) { if (visible && UI is UIClickable) {
UI.controllerButtonReleased(controller, button) UI.controllerButtonReleased(controller, button)
} }
} }
@@ -226,6 +242,6 @@ constructor(val UI: UICanvas) {
if (alwaysVisible) { if (alwaysVisible) {
return false return false
} }
return _visible && !opening return visible && !opening
} }
} }

Binary file not shown.