FIX: quickbar opacity bug, Notification won't display, remaned majuscule to fullwidth, keyboard layouts for control helper

Former-commit-id: 99c51499131a7cbae1b7345c15d804bd5340e7b6
Former-commit-id: 1326b69cb920d3590fe2cbe33013c85c9eeb1191
This commit is contained in:
Song Minjae
2016-07-29 21:02:24 +09:00
parent ee647652d2
commit fb11d5c9c2
42 changed files with 232 additions and 115 deletions

View File

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

View File

Before

Width:  |  Height:  |  Size: 21 KiB

After

Width:  |  Height:  |  Size: 21 KiB

View File

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

View File

Before

Width:  |  Height:  |  Size: 2.0 KiB

After

Width:  |  Height:  |  Size: 2.0 KiB

View File

Before

Width:  |  Height:  |  Size: 197 B

After

Width:  |  Height:  |  Size: 197 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 KiB

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 349 KiB

After

Width:  |  Height:  |  Size: 353 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 20 KiB

After

Width:  |  Height:  |  Size: 280 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 507 B

52
res/keylayout.json Normal file
View File

@@ -0,0 +1,52 @@
{
"qwerty": {
"layout": "1234567890-=QWERTYUIOP[]ASDFGHJKL;'ZXCVBNM,./",
"capslock": "Caps",
"name": "QWERTY"
},
"qwertz": {
"layout": "1234567890-=QWERTZUIOP[]ASDFGHJKL;'YXCVBNM,./",
"capslock": "Caps",
"name": "QWERTZ"
},
"azerty": {
"layout": "1234567890-=AZERTYUIOP[]QSDFGHJKL;'WXCVBNM,./",
"capslock": "Caps",
"name": "AZERTY"
},
"colemak": {
"layout": "1234567890-=QWFPGJLUY;[]ARSTDHNEIO'ZXCVBKM,./",
"capslock": "Back",
"name": "Colemak"
},
"workman": {
"layout": "1234567890-=QDRWBJFUP;[]ASHTGYNEOI'ZXMCVKL,./",
"capslock": "Back",
"name": "Workman"
},
"dvorak": {
"layout": "1234567890[]',.PYFGCRL/=AOEUIDHTNS-;QJKXBMWVZ",
"capslock": "Caps",
"name": "Dvorak"
},
"bepo": {
"layout": "1234567890=%BÉPOÈ!VDLJZWAUIE,CTSRNMÀYX.K'QGHF",
"capslock": "Caps",
"name": "Bépo"
},
"turk-f": {
"layout": "1234567890/-FGĞIODRNHPQWUİEAÜTKMLYŞJÖVCÇZSB.,",
"capslock": "Caps",
"name": "F klavye"
},
"qwerty-jis-apple": {
"layout": "1234567890-=QWERTYUIOP[]ASDFGHJKL;'ZXCVBNM,./",
"capslock": "Ctrl",
"name": "Apple 日本語"
},
"hhkb": {
"layout": "1234567890-=QWERTYUIOP[]ASDFGHJKL;'ZXCVBNM,./",
"capslock": "Ctrl",
"name": "HHKB2"
}
}

View File

@@ -349,7 +349,7 @@
}, },
{ {
"n": "CONTEXT_ITEM_HAMMER", "n": "CONTEXT_ITEM_HAMMER",
"s": "철퇴" "s": "망치"
}, },
{ {
"n": "CONTEXT_ITEM_HELMET", "n": "CONTEXT_ITEM_HELMET",

View File

@@ -16,7 +16,7 @@ object CSVFetcher {
private var csvString: StringBuffer? = null private var csvString: StringBuffer? = null
@Throws(IOException::class) @Throws(IOException::class)
fun readCSV(csvFilePath: String): List<CSVRecord> { operator fun invoke(csvFilePath: String): List<CSVRecord> {
csvString = StringBuffer() // reset buffer every time it called csvString = StringBuffer() // reset buffer every time it called
readCSVasString(csvFilePath) readCSVasString(csvFilePath)

View File

@@ -18,7 +18,7 @@ object JsonFetcher {
private var jsonString: StringBuffer? = null private var jsonString: StringBuffer? = null
@Throws(IOException::class) @Throws(IOException::class)
fun readJson(jsonFilePath: String): JsonObject { operator fun invoke(jsonFilePath: String): JsonObject {
jsonString = StringBuffer() // reset buffer every time it called jsonString = StringBuffer() // reset buffer every time it called
readJsonFileAsString(jsonFilePath) readJsonFileAsString(jsonFilePath)
@@ -31,7 +31,7 @@ object JsonFetcher {
} }
@Throws(IOException::class) @Throws(IOException::class)
fun readJson(jsonFile: File): JsonObject { operator fun invoke(jsonFile: File): JsonObject {
jsonString = StringBuffer() // reset buffer every time it called jsonString = StringBuffer() // reset buffer every time it called
readJsonFileAsString(jsonFile.canonicalPath) readJsonFileAsString(jsonFile.canonicalPath)

View File

@@ -5,18 +5,19 @@ import java.util.function.Consumer
/** /**
* Simple ArrayList wrapper that acts as history keeper. You can append any data but cannot delete. * Simple ArrayList wrapper that acts as history keeper. You can append any data but cannot delete.
*
* Created by minjaesong on 16-07-13. * Created by minjaesong on 16-07-13.
*/ */
class HistoryArray<T>(val historyMax: Int) { class HistoryArray<T>(val historyMax: Int) {
val history = ArrayList<T?>(Math.min(historyMax, 256)) // 256: arbitrary-set upper bound val history = ArrayList<T?>(Math.min(historyMax, 256)) // 256: arbitrary set upper bound
fun add(value: T) { fun add(value: T) {
if (history.size == 0) { if (history.size == 0) {
history.add(value) history.add(value)
return return
} }
// push existing values to back 1 index // push existing values to an index
else { else {
for (i in history.size - 1 downTo 0) { for (i in history.size - 1 downTo 0) {
// if history.size is smaller than historyMax, make room by appending // if history.size is smaller than historyMax, make room by appending

View File

@@ -14,13 +14,13 @@ constructor() : GameFontBase() {
GameFontBase.hangulSheet = SpriteSheet( GameFontBase.hangulSheet = SpriteSheet(
"./res/graphics/fonts/han_johab.png", GameFontBase.W_CJK, GameFontBase.H_HANGUL) "./res/graphics/fonts/han_johab.png", GameFontBase.W_CJK, GameFontBase.H_HANGUL)
GameFontBase.asciiSheet = SpriteSheet( GameFontBase.asciiSheet = SpriteSheet(
"./res/graphics/fonts/ascii_majuscule.png", GameFontBase.W_LATIN_WIDE, GameFontBase.H) "./res/graphics/fonts/ascii_fullwidth.png", GameFontBase.W_LATIN_WIDE, GameFontBase.H)
GameFontBase.asciiSheetEF = SpriteSheet( GameFontBase.asciiSheetEF = SpriteSheet(
"./res/graphics/fonts/ascii_special_ef.png", GameFontBase.W_LATIN_NARROW, GameFontBase.H) "./res/graphics/fonts/ascii_special_ef.png", GameFontBase.W_LATIN_NARROW, GameFontBase.H)
GameFontBase.runicSheet = SpriteSheet( GameFontBase.runicSheet = SpriteSheet(
"./res/graphics/fonts/futhark.png", GameFontBase.W_LATIN_WIDE, GameFontBase.H) "./res/graphics/fonts/futhark.png", GameFontBase.W_LATIN_WIDE, GameFontBase.H)
GameFontBase.extASheet = SpriteSheet( GameFontBase.extASheet = SpriteSheet(
"./res/graphics/fonts/LatinExtA_majuscule.png", GameFontBase.W_LATIN_WIDE, GameFontBase.H) "./res/graphics/fonts/LatinExtA_fullwidth.png", GameFontBase.W_LATIN_WIDE, GameFontBase.H)
GameFontBase.extASheetEF = SpriteSheet( GameFontBase.extASheetEF = SpriteSheet(
"./res/graphics/fonts/LatinExtA_ef.png", GameFontBase.W_LATIN_NARROW, GameFontBase.H) "./res/graphics/fonts/LatinExtA_ef.png", GameFontBase.W_LATIN_NARROW, GameFontBase.H)
GameFontBase.kanaSheet = SpriteSheet( GameFontBase.kanaSheet = SpriteSheet(
@@ -35,7 +35,7 @@ constructor() : GameFontBase() {
, W_UNIHAN, H_UNIHAN , W_UNIHAN, H_UNIHAN
);*/ );*/
GameFontBase.cyrilic = SpriteSheet( GameFontBase.cyrilic = SpriteSheet(
"./res/graphics/fonts/cyrilic_majuscule.png", GameFontBase.W_LATIN_WIDE, GameFontBase.H) "./res/graphics/fonts/cyrilic_fullwidth.png", GameFontBase.W_LATIN_WIDE, GameFontBase.H)
GameFontBase.cyrilicEF = SpriteSheet( GameFontBase.cyrilicEF = SpriteSheet(
"./res/graphics/fonts/cyrilic_ef.png", GameFontBase.W_LATIN_NARROW, GameFontBase.H) "./res/graphics/fonts/cyrilic_ef.png", GameFontBase.W_LATIN_NARROW, GameFontBase.H)
GameFontBase.fullwidthForms = SpriteSheet( GameFontBase.fullwidthForms = SpriteSheet(
@@ -47,11 +47,11 @@ constructor() : GameFontBase() {
GameFontBase.wenQuanYi_2 = SpriteSheet( GameFontBase.wenQuanYi_2 = SpriteSheet(
"./res/graphics/fonts/wenquanyi_11pt_part2.png", 16, 18, 2) "./res/graphics/fonts/wenquanyi_11pt_part2.png", 16, 18, 2)
GameFontBase.greekSheet = SpriteSheet( GameFontBase.greekSheet = SpriteSheet(
"./res/graphics/fonts/greek_majuscule.png", GameFontBase.W_LATIN_WIDE, GameFontBase.H) "./res/graphics/fonts/greek_fullwidth.png", GameFontBase.W_LATIN_WIDE, GameFontBase.H)
GameFontBase.greekSheetEF = SpriteSheet( GameFontBase.greekSheetEF = SpriteSheet(
"./res/graphics/fonts/greek_ef.png", GameFontBase.W_LATIN_NARROW, GameFontBase.H) "./res/graphics/fonts/greek_ef.png", GameFontBase.W_LATIN_NARROW, GameFontBase.H)
GameFontBase.romanianSheet = SpriteSheet( GameFontBase.romanianSheet = SpriteSheet(
"./res/graphics/fonts/romana_majuscule.png", GameFontBase.W_LATIN_WIDE, GameFontBase.H) "./res/graphics/fonts/romana_fullwidth.png", GameFontBase.W_LATIN_WIDE, GameFontBase.H)
GameFontBase.romanianSheetEF = SpriteSheet( GameFontBase.romanianSheetEF = SpriteSheet(
"./res/graphics/fonts/romana_ef.png", GameFontBase.W_LATIN_NARROW, GameFontBase.H) "./res/graphics/fonts/romana_ef.png", GameFontBase.W_LATIN_NARROW, GameFontBase.H)
GameFontBase.thaiSheet = SpriteSheet( GameFontBase.thaiSheet = SpriteSheet(

View File

@@ -140,7 +140,7 @@ constructor() {
flippedImage.startUse() flippedImage.startUse()
flippedImage.drawEmbedded( flippedImage.drawEmbedded(
Math.round(posX * Terrarum.ingame.screenZoom).toFloat(), Math.round(posX * Terrarum.ingame.screenZoom).toFloat(),
Math.round(posY * Terrarum.ingame.screenZoom).toFloat(), FastMath.floor(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

@@ -48,7 +48,7 @@ object DefaultConfig {
jsonObject.addProperty("keygamemenu", Key.TAB) jsonObject.addProperty("keygamemenu", Key.TAB)
jsonObject.addProperty("keyquicksel", Key.CAPS_LOCK) // pie menu jsonObject.addProperty("keyquicksel", Key.CAPS_LOCK) // pie menu
val keyquickselalt = JsonArray(); keyquickselalt.add(Key.BACKSPACE); keyquickselalt.add(Key.L_COMMAND); keyquickselalt.add(Key.L_CONTROL) val keyquickselalt = JsonArray(); keyquickselalt.add(Key.BACKSPACE); keyquickselalt.add(Key.L_COMMAND); keyquickselalt.add(Key.L_CONTROL)
// some pro typers assign CapsLock to Backspace, LControl, or LCommand (Mac). Honestly, Control (Command for mac) and CapsLock must swap their places! // Colemak, Workman and some typers use CapsLock as Backspace, Apple-JIS and HHKB has Control in place of CapsLock and often re-assigned to Command
jsonObject.add("keyquickselalt", keyquickselalt) jsonObject.add("keyquickselalt", keyquickselalt)
jsonObject.addProperty("keyjump", Key.SPACE) jsonObject.addProperty("keyjump", Key.SPACE)

View File

@@ -128,9 +128,9 @@ constructor() : BasicGameState() {
// init notifier // init notifier
notifier = UIHandler(Notification()) notifier = UIHandler(Notification())
notifier.UI.handler = notifier
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.isVisible = 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"))
@@ -358,8 +358,7 @@ constructor() : BasicGameState() {
/** Send message to notifier UI and toggle the UI as opened. */ /** Send message to notifier UI and toggle the UI as opened. */
fun sendNotification(msg: Array<String>) { fun sendNotification(msg: Array<String>) {
(notifier.UI as Notification).sendNotification(Terrarum.appgc, UPDATE_DELTA, msg) (notifier.UI as Notification).sendNotification(msg)
notifier.setAsOpen()
} }
fun wakeDormantActors() { fun wakeDormantActors() {

View File

@@ -41,7 +41,6 @@ class StateMonitorCheck : BasicGameState() {
override var width = Terrarum.WIDTH override var width = Terrarum.WIDTH
override var height = Terrarum.HEIGHT override var height = Terrarum.HEIGHT
override var openCloseTime = 150 override var openCloseTime = 150
override var openCloseTimer: Int = 0
override var handler: UIHandler? = null override var handler: UIHandler? = null

View File

@@ -254,7 +254,7 @@ constructor(gamename: String) : StateBasedGame(gamename) {
private fun readConfigJson(): Boolean { private fun readConfigJson(): Boolean {
try { try {
// read from disk and build config from it // read from disk and build config from it
val jsonObject = JsonFetcher.readJson(configDir) val jsonObject = JsonFetcher(configDir)
// make config // make config
jsonObject.entrySet().forEach { entry -> gameConfig[entry.key] = entry.value } jsonObject.entrySet().forEach { entry -> gameConfig[entry.key] = entry.value }

View File

@@ -404,6 +404,7 @@ open class ActorWithBody : Actor(), Visible {
grounded = true grounded = true
} }
else if (isTouchingSide(nextHitbox, COLLIDING_BOTTOM) && !isColliding(nextHitbox)) { // actor hit something on its bottom else if (isTouchingSide(nextHitbox, COLLIDING_BOTTOM) && !isColliding(nextHitbox)) { // actor hit something on its bottom
hitAndReflectY()
grounded = true grounded = true
} }
else { // the actor is not grounded at all else { // the actor is not grounded at all
@@ -751,11 +752,14 @@ open class ActorWithBody : Actor(), Visible {
internal val bodyFriction: Int internal val bodyFriction: Int
get() { get() {
var friction = 0 var friction = 0
val frictionCalcHitbox = if (isWalking) val frictionCalcHitbox =
Hitbox(nextHitbox.posX + 1.0, nextHitbox.posY + 1.0, if (!isWalking)
nextHitbox.width - 2.0, nextHitbox.height - 2.0) Hitbox(nextHitbox.posX, nextHitbox.posY,
else nextHitbox.width + 2.0, nextHitbox.height + 2.0)
nextHitbox.clone() // when not walking, enlarge the hitbox for calculation so that
// feet tiles are to be taken into calculation
else
nextHitbox.clone()
// take highest value // take highest value
val tilePosXStart = (frictionCalcHitbox.posX / TSIZE).floorInt() val tilePosXStart = (frictionCalcHitbox.posX / TSIZE).floorInt()

View File

@@ -24,7 +24,7 @@ object CreatureRawInjector {
*/ */
@Throws(IOException::class, SlickException::class) @Throws(IOException::class, SlickException::class)
fun inject(actorValueRef: ActorValue, jsonFileName: String) { fun inject(actorValueRef: ActorValue, jsonFileName: String) {
val jsonObj = JsonFetcher.readJson(JSONPATH + jsonFileName) val jsonObj = JsonFetcher(JSONPATH + jsonFileName)
val elementsString = arrayOf(AVKey.RACENAME, AVKey.RACENAMEPLURAL) val elementsString = arrayOf(AVKey.RACENAME, AVKey.RACENAMEPLURAL)
val elementsDouble = arrayOf(AVKey.BASEHEIGHT, AVKey.BASEMASS, AVKey.ACCEL, AVKey.TOOLSIZE, AVKey.ENCUMBRANCE) val elementsDouble = arrayOf(AVKey.BASEHEIGHT, AVKey.BASEMASS, AVKey.ACCEL, AVKey.TOOLSIZE, AVKey.ENCUMBRANCE)

View File

@@ -277,8 +277,6 @@ class Player : ActorWithBody(), Controllable, Pocketed, Factionable, Luminous, L
jumpAcc = -pwr * timedJumpCharge * JUMP_ACCELERATION_MOD * Math.sqrt(scale) // positive value jumpAcc = -pwr * timedJumpCharge * JUMP_ACCELERATION_MOD * Math.sqrt(scale) // positive value
applyForce(Vector2(0.0, jumpAcc)) applyForce(Vector2(0.0, jumpAcc))
if (jumpAcc != 0.0) println(jumpAcc)
} }
// for mob ai: // for mob ai:

View File

@@ -17,7 +17,7 @@ object FactionFactory {
*/ */
@Throws(IOException::class) @Throws(IOException::class)
fun create(filename: String): Faction { fun create(filename: String): Faction {
val jsonObj = JsonFetcher.readJson(JSONPATH + filename) val jsonObj = JsonFetcher(JSONPATH + filename)
val factionObj = Faction(jsonObj.get("factionname").asString) val factionObj = Faction(jsonObj.get("factionname").asString)
jsonObj.get("factionamicable").asJsonArray.forEach { s -> factionObj.addFactionAmicable(s.asString) } jsonObj.get("factionamicable").asJsonArray.forEach { s -> factionObj.addFactionAmicable(s.asString) }

View File

@@ -0,0 +1,81 @@
package net.torvald.terrarum.gamecontroller
import net.torvald.JsonFetcher
import java.util.*
/**
* Created by minjaesong on 16-07-28.
*/
object KeyLayout {
/**
* HashMap<identifier: String, KeyLayoutClass>
*/
val layouts: HashMap<String, KeyLayoutClass>
init {
layouts = HashMap<String, KeyLayoutClass>()
val json = JsonFetcher("./res/keylayout.json")
json.entrySet().forEach { it ->
layouts.put(
it.key,
KeyLayoutClass(
it.value.asJsonObject.get("layout").asString,
it.value.asJsonObject.get("name").asString,
it.value.asJsonObject.get("capslock").asString
)
)
}
}
}
class KeyLayoutClass(layoutString: String, val layoutName: String, capsMode: String) {
val disposition = intArrayOf(
// alphanumeric
2, 3, 4, 5, 6, 7, 8, 9,10,11,12,13,
16,17,18,19,20,21,22,23,24,25,26,27,
30,31,32,33,34,35,36,37,38,39,40,
44,45,46,47,48,49,50,51,52,53,
// control keys
14, // back
15, // tab
58, 28, // capslock, return/enter
42, // lshift
29, 57 // lcontrol, space
)
val engraving = ArrayList<String>(disposition.size)
init {
/* ================== *
* parse layoutString *
* ================== */
// zero-fill engraving
for (i in 1..disposition.size) engraving.add("")
// Backspace
engraving[disposition.indexOf(14)] = "BACK"
// Tab
engraving[disposition.indexOf(15)] = "TAB"
// Capslock
engraving[disposition.indexOf(58)] = "CAPS"
// Enter
engraving[disposition.indexOf(28)] = "ENTER"
// LShift
engraving[disposition.indexOf(42)] = "SHIFT"
// Control
engraving[disposition.indexOf(29)] = "CTRL"
// Space
engraving[disposition.indexOf(57)] = "SPACE"
// alphanumeric
for (i in 0..layoutString.length - 1) {
engraving[disposition.indexOf(i)] = layoutString[i].toString()
}
}
fun codeToLabel(code: Int) = engraving[disposition.indexOf(code)]
fun labelToCode(char: Char) = disposition[engraving.indexOf(char.toUpperCase().toString())]
}

View File

@@ -55,7 +55,7 @@ object Lang {
for (lang in languageList) { for (lang in languageList) {
// load polyglot first // load polyglot first
val polyglotFile = File("$PATH_TO_LANG$lang/$PREFIX_POLYGLOT$lang.json") val polyglotFile = File("$PATH_TO_LANG$lang/$PREFIX_POLYGLOT$lang.json")
val json = JsonFetcher.readJson(polyglotFile) val json = JsonFetcher(polyglotFile)
/* /*
* Polyglot JSON structure is: * Polyglot JSON structure is:
* *
@@ -92,7 +92,7 @@ object Lang {
// --> put json entries in langpack // --> put json entries in langpack
for (langFile in langFileList) { for (langFile in langFileList) {
val json = JsonFetcher.readJson(langFile) val json = JsonFetcher(langFile)
/* /*
* Terrarum langpack JSON structure is: * Terrarum langpack JSON structure is:
* *

View File

@@ -64,6 +64,8 @@ object MapCamera {
*/ */
val TILES_CONNECT_SELF = arrayOf( val TILES_CONNECT_SELF = arrayOf(
TileNameCode.ICE_MAGICAL TileNameCode.ICE_MAGICAL
, TileNameCode.GLASS_CRUDE
, TileNameCode.GLASS_CLEAN
, TileNameCode.ILLUMINATOR_BLACK , TileNameCode.ILLUMINATOR_BLACK
, TileNameCode.ILLUMINATOR_BLUE , TileNameCode.ILLUMINATOR_BLUE
, TileNameCode.ILLUMINATOR_BROWN , TileNameCode.ILLUMINATOR_BROWN

View File

@@ -56,6 +56,9 @@ object TileNameCode {
val ICE_NATURAL = TilePropCodex.idDamageToIndex(9, 2) val ICE_NATURAL = TilePropCodex.idDamageToIndex(9, 2)
val ICE_MAGICAL = TilePropCodex.idDamageToIndex(9, 3) val ICE_MAGICAL = TilePropCodex.idDamageToIndex(9, 3)
val GLASS_CRUDE = TilePropCodex.idDamageToIndex(9, 4)
val GLASS_CLEAN = TilePropCodex.idDamageToIndex(9, 5)
val PLATFORM_STONE = TilePropCodex.idDamageToIndex(10, 0) val PLATFORM_STONE = TilePropCodex.idDamageToIndex(10, 0)
val PLATFORM_WOODEN = TilePropCodex.idDamageToIndex(10, 1) val PLATFORM_WOODEN = TilePropCodex.idDamageToIndex(10, 1)
val PLATFORM_EBONY = TilePropCodex.idDamageToIndex(10, 2) val PLATFORM_EBONY = TilePropCodex.idDamageToIndex(10, 2)

View File

@@ -29,7 +29,7 @@ object TilePropCodex {
try { try {
// todo verify CSV using pre-calculated SHA256 hash // todo verify CSV using pre-calculated SHA256 hash
val records = CSVFetcher.readCSV(CSV_PATH) val records = CSVFetcher(CSV_PATH)
println("[TilePropCodex] Building tile properties table") println("[TilePropCodex] Building tile properties table")

View File

@@ -38,6 +38,8 @@
"9"; "1";"TILE_ICE_FRAGILE" ; "13644813"; "1"; "930"; "0"; "1"; "0"; "0"; "9"; "1"; "0"; "0";"16" "9"; "1";"TILE_ICE_FRAGILE" ; "13644813"; "1"; "930"; "0"; "1"; "0"; "0"; "9"; "1"; "0"; "0";"16"
"9"; "2";"TILE_ICE_NATURAL" ; "27289626"; "25"; "930"; "0"; "1"; "1"; "0"; "9"; "2"; "0"; "0"; "8" "9"; "2";"TILE_ICE_NATURAL" ; "27289626"; "25"; "930"; "0"; "1"; "1"; "0"; "9"; "2"; "0"; "0"; "8"
"9"; "3";"TILE_ICE_CLEAR_MAGICAL" ; "33587232"; "25";"3720"; "0"; "1"; "1"; "19955770"; "9"; "3"; "0"; "0"; "8" "9"; "3";"TILE_ICE_CLEAR_MAGICAL" ; "33587232"; "25";"3720"; "0"; "1"; "1"; "19955770"; "9"; "3"; "0"; "0"; "8"
"9"; "4";"TILE_GLASS_CRUDE" ; "3146755"; "1";"2500"; "0"; "1"; "1"; "0"; "9"; "4"; "0"; "0";"16"
"9"; "5";"TILE_GLASS_CLEAN" ; "1049601"; "1";"2203"; "0"; "1"; "1"; "0"; "9"; "5"; "0"; "0";"16"
"10"; "0";"TILE_PLATFORM_STONE" ; "8396808"; "1"; "N/A"; "0"; "0"; "0"; "0"; "10"; "0"; "0"; "0";"16" "10"; "0";"TILE_PLATFORM_STONE" ; "8396808"; "1"; "N/A"; "0"; "0"; "0"; "0"; "10"; "0"; "0"; "0";"16"
"10"; "1";"TILE_PLATFORM_WOODEN" ; "8396808"; "1"; "N/A"; "0"; "0"; "0"; "0"; "10"; "1"; "0"; "0";"16" "10"; "1";"TILE_PLATFORM_WOODEN" ; "8396808"; "1"; "N/A"; "0"; "0"; "0"; "0"; "10"; "1"; "0"; "0";"16"
"10"; "2";"TILE_PLATFORM_EBONY" ; "8396808"; "1"; "N/A"; "0"; "0"; "0"; "0"; "10"; "2"; "0"; "0";"16" "10"; "2";"TILE_PLATFORM_EBONY" ; "8396808"; "1"; "N/A"; "0"; "0"; "0"; "0"; "10"; "2"; "0"; "0";"16"
Can't render this file because it contains an unexpected character in line 1 and column 18.

View File

@@ -25,7 +25,6 @@ class BasicDebugInfoWindow : UICanvas {
override var height: Int = Terrarum.HEIGHT override var height: Int = Terrarum.HEIGHT
override var openCloseTime: Int = 0 override var openCloseTime: Int = 0
override var openCloseTimer: Int = 0
override var handler: UIHandler? = null override var handler: UIHandler? = null

View File

@@ -34,7 +34,6 @@ class ConsoleWindow : UICanvas, KeyboardControlled {
override var height: Int = LINE_HEIGHT * (MESSAGES_DISPLAY_COUNT + 1) override var height: Int = LINE_HEIGHT * (MESSAGES_DISPLAY_COUNT + 1)
override var openCloseTime: Int = 0 override var openCloseTime: Int = 0
override var openCloseTimer: Int = 0
private var drawOffX: Float = 0f private var drawOffX: Float = 0f
private var drawOffY: Float = -height.toFloat() private var drawOffY: Float = -height.toFloat()

View File

@@ -27,13 +27,8 @@ constructor(override var width: Int, isBlackVariant: Boolean) : UICanvas {
override var openCloseTime: Int = OPEN_CLOSE_TIME override var openCloseTime: Int = OPEN_CLOSE_TIME
internal var opacity = 0f
override var openCloseTimer = 0
override var handler: UIHandler? = null override var handler: UIHandler? = null
private lateinit var uidrawCanvas: Image // render all the images and fonts here; will be faded
init { init {
if (!isBlackVariant) { if (!isBlackVariant) {
segmentLeft = Image("./res/graphics/gui/message_twoline_white_left.png"); segmentLeft = Image("./res/graphics/gui/message_twoline_white_left.png");
@@ -49,7 +44,6 @@ constructor(override var width: Int, isBlackVariant: Boolean) : UICanvas {
height = segmentLeft!!.height height = segmentLeft!!.height
messageWindowRadius = segmentLeft!!.width messageWindowRadius = segmentLeft!!.width
messagesList = arrayOf("", "") messagesList = arrayOf("", "")
uidrawCanvas = Image(FastMath.nearestPowerOfTwo(width), FastMath.nearestPowerOfTwo(height))
} }
fun setMessage(messagesList: Array<String>) { fun setMessage(messagesList: Array<String>) {
@@ -61,25 +55,21 @@ constructor(override var width: Int, isBlackVariant: Boolean) : UICanvas {
} }
override fun render(gc: GameContainer, g: Graphics) { override fun render(gc: GameContainer, g: Graphics) {
val canvasG = uidrawCanvas.graphics
setBlendDisable() setBlendDisable()
drawSegments(canvasG)
canvasG.setDrawMode(Graphics.MODE_ALPHA_MAP)
drawSegments(canvasG)
canvasG.font = uiFont drawSegments(g)
g.setDrawMode(Graphics.MODE_ALPHA_MAP)
drawSegments(g)
canvasG.setDrawMode(Graphics.MODE_NORMAL) g.font = uiFont
g.setDrawMode(Graphics.MODE_NORMAL)
for (i in 0..Math.min(messagesList.size, MESSAGES_DISPLAY) - 1) { for (i in 0..Math.min(messagesList.size, MESSAGES_DISPLAY) - 1) {
canvasG.color = fontCol g.color = fontCol
canvasG.drawString(messagesList[i], (messageWindowRadius + 4).toFloat(), (messageWindowRadius + GLYPH_HEIGHT * i).toFloat()) g.drawString(messagesList[i], (messageWindowRadius + 4).toFloat(), (messageWindowRadius + GLYPH_HEIGHT * i).toFloat())
} }
setBlendNormal() setBlendNormal()
g.drawImage(uidrawCanvas, 0f, 0f, Color(1f,1f,1f,opacity))
canvasG.clear()
} }
override fun processInput(input: Input) { override fun processInput(input: Input) {
@@ -87,27 +77,15 @@ constructor(override var width: Int, isBlackVariant: Boolean) : UICanvas {
} }
override fun doOpening(gc: GameContainer, delta: Int) { override fun doOpening(gc: GameContainer, delta: Int) {
openCloseTimer += delta
opacity = FastMath.interpolateLinear(openCloseTimer.toFloat() / openCloseTime.toFloat(),
0f, 1f
)
} }
override fun doClosing(gc: GameContainer, delta: Int) { override fun doClosing(gc: GameContainer, delta: Int) {
openCloseTimer += delta
opacity = FastMath.interpolateLinear(openCloseTimer.toFloat() / openCloseTime.toFloat(),
1f, 0f
)
} }
override fun endOpening(gc: GameContainer, delta: Int) { override fun endOpening(gc: GameContainer, delta: Int) {
opacity = 1f
openCloseTimer = 0
} }
override fun endClosing(gc: GameContainer, delta: Int) { override fun endClosing(gc: GameContainer, delta: Int) {
opacity = 0f
openCloseTimer = 0
} }
private fun drawSegments(g: Graphics) { private fun drawSegments(g: Graphics) {

View File

@@ -1,5 +1,6 @@
package net.torvald.terrarum.ui package net.torvald.terrarum.ui
import com.jme3.math.FastMath
import net.torvald.terrarum.Terrarum import net.torvald.terrarum.Terrarum
import org.newdawn.slick.GameContainer import org.newdawn.slick.GameContainer
import org.newdawn.slick.Graphics import org.newdawn.slick.Graphics
@@ -12,78 +13,68 @@ import org.newdawn.slick.SlickException
class Notification @Throws(SlickException::class) class Notification @Throws(SlickException::class)
constructor() : UICanvas { constructor() : UICanvas {
override var width: Int = 0 private val SHOWUP_MAX = 15000
override var height: Int = 0
internal var visibleTime: Int override var width: Int = 500
override var openCloseTimer = 0
internal var msgUI = MessageWindow(width, true)
override var height: Int = msgUI.height
private val visibleTime = Math.min(
Terrarum.getConfigInt("notificationshowuptime"),
SHOWUP_MAX
)
private var displayTimer = 0
internal var isShowing = false
internal var message: Array<String> = Array(MessageWindow.MESSAGES_DISPLAY, { i -> ""}) internal var message: Array<String> = Array(MessageWindow.MESSAGES_DISPLAY, { i -> ""})
internal var msgUI: MessageWindow
override var openCloseTime: Int = MessageWindow.OPEN_CLOSE_TIME override var openCloseTime: Int = MessageWindow.OPEN_CLOSE_TIME
override var handler: UIHandler? = null override var handler: UIHandler? = null
private val SHOWUP_MAX = 15000
init { init {
width = 500
msgUI = MessageWindow(width, true)
height = msgUI.height
visibleTime = Math.min(
Terrarum.getConfigInt("notificationshowuptime"),
SHOWUP_MAX
)
} }
override fun update(gc: GameContainer, delta: Int) { override fun update(gc: GameContainer, delta: Int) {
if (openCloseTimer >= visibleTime && isShowing) { if (handler!!.isOpened)
// invoke closing mode displayTimer += delta
doClosing(gc, delta)
// check if msgUI is fully fade out
if (msgUI.opacity <= 0.001f) {
endClosing(gc, delta)
isShowing = false
}
}
if (isShowing) { if (displayTimer >= visibleTime)
openCloseTimer += delta handler!!.setAsClose()
}
} }
override fun render(gc: GameContainer, g: Graphics) { override fun render(gc: GameContainer, g: Graphics) {
if (isShowing) { msgUI.render(gc, g)
msgUI.render(gc, g)
}
} }
override fun doOpening(gc: GameContainer, delta: Int) { override fun doOpening(gc: GameContainer, delta: Int) {
msgUI.doOpening(gc, delta) handler!!.opacity = FastMath.interpolateLinear(handler!!.openCloseCounter.toFloat() / openCloseTime.toFloat(),
0f, 1f
)
} }
override fun doClosing(gc: GameContainer, delta: Int) { override fun doClosing(gc: GameContainer, delta: Int) {
msgUI.doClosing(gc, delta) handler!!.opacity = FastMath.interpolateLinear(handler!!.openCloseCounter.toFloat() / openCloseTime.toFloat(),
1f, 0f
)
} }
override fun endOpening(gc: GameContainer, delta: Int) { override fun endOpening(gc: GameContainer, delta: Int) {
msgUI.endOpening(gc, delta) handler!!.opacity = 1f
} }
override fun endClosing(gc: GameContainer, delta: Int) { override fun endClosing(gc: GameContainer, delta: Int) {
msgUI.endClosing(gc, delta) handler!!.opacity = 0f
} }
override fun processInput(input: Input) { override fun processInput(input: Input) {
} }
fun sendNotification(gc: GameContainer, delta: Int, message: Array<String>) { fun sendNotification(message: Array<String>) {
isShowing = true
this.message = message this.message = message
msgUI.setMessage(this.message) msgUI.setMessage(this.message)
openCloseTimer = 0 handler!!.openCloseCounter = 0
handler!!.opacity = 0f
handler!!.setAsOpen()
} }
} }

View File

@@ -12,16 +12,17 @@ interface UICanvas {
var width: Int var width: Int
var height: Int var height: Int
/**
* Usage: (in StateInGame:) uiHandlerField.ui.handler = uiHandlerField
*/
var handler: UIHandler? var handler: UIHandler?
/** /**
* In milliseconds * In milliseconds
*
* Timer itself is implemented in the handler.
*/ */
var openCloseTime: Int var openCloseTime: Int
/**
* Usage: get() = handler!!.openCloseCounter
*/
var openCloseTimer: Int
fun update(gc: GameContainer, delta: Int) fun update(gc: GameContainer, delta: Int)
@@ -29,11 +30,23 @@ interface UICanvas {
fun processInput(input: Input) fun processInput(input: Input)
/**
* Do not modify handler!!.openCloseCounter here.
*/
fun doOpening(gc: GameContainer, delta: Int) fun doOpening(gc: GameContainer, delta: Int)
/**
* Do not modify handler!!.openCloseCounter here.
*/
fun doClosing(gc: GameContainer, delta: Int) fun doClosing(gc: GameContainer, delta: Int)
/**
* Do not modify handler!!.openCloseCounter here.
*/
fun endOpening(gc: GameContainer, delta: Int) fun endOpening(gc: GameContainer, delta: Int)
/**
* Do not modify handler!!.openCloseCounter here.
*/
fun endClosing(gc: GameContainer, delta: Int) fun endClosing(gc: GameContainer, delta: Int)
} }

View File

@@ -27,8 +27,6 @@ class UIPieMenu : UICanvas {
* In milliseconds * In milliseconds
*/ */
override var openCloseTime: Int = 160 override var openCloseTime: Int = 160
override var openCloseTimer: Int = 0
get() = handler!!.openCloseCounter
private val smallenSize = 0.93f private val smallenSize = 0.93f
@@ -82,12 +80,12 @@ class UIPieMenu : UICanvas {
} }
override fun doOpening(gc: GameContainer, delta: Int) { override fun doOpening(gc: GameContainer, delta: Int) {
handler!!.opacity = openCloseTimer.toFloat() / openCloseTime handler!!.opacity = handler!!.openCloseCounter.toFloat() / openCloseTime
handler!!.scale = smallenSize + (1f.minus(smallenSize) * handler!!.opacity) handler!!.scale = smallenSize + (1f.minus(smallenSize) * handler!!.opacity)
} }
override fun doClosing(gc: GameContainer, delta: Int) { override fun doClosing(gc: GameContainer, delta: Int) {
handler!!.opacity = (openCloseTime - openCloseTimer.toFloat()) / openCloseTime handler!!.opacity = (openCloseTime - handler!!.openCloseCounter.toFloat()) / openCloseTime
handler!!.scale = smallenSize + (1f.minus(smallenSize) * handler!!.opacity) handler!!.scale = smallenSize + (1f.minus(smallenSize) * handler!!.opacity)
} }

View File

@@ -17,7 +17,6 @@ class UIQuickBar : UICanvas, MouseControlled {
* In milliseconds * In milliseconds
*/ */
override var openCloseTime: Int = 160 override var openCloseTime: Int = 160
override var openCloseTimer: Int = 0
private val startPointX = ItemSlotImageBuilder.slotLarge.width / 2 private val startPointX = ItemSlotImageBuilder.slotLarge.width / 2
private val startPointY = ItemSlotImageBuilder.slotLarge.height / 2 private val startPointY = ItemSlotImageBuilder.slotLarge.height / 2
@@ -56,11 +55,11 @@ class UIQuickBar : UICanvas, MouseControlled {
} }
override fun doOpening(gc: GameContainer, delta: Int) { override fun doOpening(gc: GameContainer, delta: Int) {
handler!!.opacity = openCloseTimer.toFloat() / openCloseTime handler!!.opacity = handler!!.openCloseCounter.toFloat() / openCloseTime
} }
override fun doClosing(gc: GameContainer, delta: Int) { override fun doClosing(gc: GameContainer, delta: Int) {
handler!!.opacity = (openCloseTime - openCloseTimer.toFloat()) / openCloseTime handler!!.opacity = (openCloseTime - handler!!.openCloseCounter.toFloat()) / openCloseTime
} }
override fun endOpening(gc: GameContainer, delta: Int) { override fun endOpening(gc: GameContainer, delta: Int) {

View File

@@ -159,7 +159,7 @@ object WeatherMixer {
*/ */
val pathToImage = "./res/graphics/weathers" val pathToImage = "./res/graphics/weathers"
val JSON = JsonFetcher.readJson(path) val JSON = JsonFetcher(path)
val globalLightInJson = JSON.get("globalLight").asJsonPrimitive val globalLightInJson = JSON.get("globalLight").asJsonPrimitive
val skyboxInJson = JSON.get("skyboxGradColourMap").asJsonPrimitive val skyboxInJson = JSON.get("skyboxGradColourMap").asJsonPrimitive

View File

@@ -37,8 +37,7 @@ import org.dyn4j.Epsilon
* [Vector2.project], and [Vector2.normalize] require the [Vector2] * [Vector2.project], and [Vector2.normalize] require the [Vector2]
* to be non-zero in length. * to be non-zero in length.
* *
* * ===============================================================================
* Chaining is not available.
* *
* In this Kotlin code, you can use regular operators like + - * /. * In this Kotlin code, you can use regular operators like + - * /.
* *