material and 5 temporary vectors no longer go into the savegame

This commit is contained in:
minjaesong
2023-05-21 11:20:45 +09:00
parent b0d83325a7
commit 6268b99c1c
53 changed files with 777 additions and 5682 deletions

View File

@@ -24,7 +24,7 @@ class ItemHomeComputer(originalID: ItemID) : GameItem(originalID) {
override var inventoryCategory = Category.MISC override var inventoryCategory = Category.MISC
override val isUnique = false override val isUnique = false
override val isDynamic = false override val isDynamic = false
override val material = Material() override val materialId = ""
override val itemImage: TextureRegion override val itemImage: TextureRegion
get() = FixtureItemBase.getItemImageFromSheet("dwarventech", "sprites/fixtures/desktop_computer.tga", TerrarumAppConfiguration.TILE_SIZE, TerrarumAppConfiguration.TILE_SIZE) get() = FixtureItemBase.getItemImageFromSheet("dwarventech", "sprites/fixtures/desktop_computer.tga", TerrarumAppConfiguration.TILE_SIZE, TerrarumAppConfiguration.TILE_SIZE)
override var baseToolSize: Double? = baseMass override var baseToolSize: Double? = baseMass

View File

@@ -32,7 +32,7 @@ class ItemWearableWorldRadar(originalID: String) {// : GameItem(originalID) {
override var inventoryCategory = Category.TOOL override var inventoryCategory = Category.TOOL
override val isUnique = false override val isUnique = false
override val isDynamic = true override val isDynamic = true
override val material = Material() override val materialId = ""
override val itemImage: TextureRegion override val itemImage: TextureRegion
get() = FixtureItemBase.getItemImageFromSingleImage("basegame", "sprites/fixtures/signal_source.tga") get() = FixtureItemBase.getItemImageFromSingleImage("basegame", "sprites/fixtures/signal_source.tga")

File diff suppressed because it is too large Load Diff

View File

@@ -1,8 +0,0 @@
{
"MENU_LABEL_COPYRIGHT": "ちょさくけん",
"COPYRIGHT_ALL_RIGHTS_RESERVED": "ぜんちょさくけん しょゆう",
"COPYRIGHT_GNU_GPL_3": "GNU GPL 3で はいふ",
"APP_WARNING_HEALTH_AND_SAFETY": "けいこくーけんこうと あんぜんの ために",
"MENU_LABEL_PRESS_START_SYMBOL": "> ボタンを おす",
"MENU_MODULES" : "モジュール"
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,23 +0,0 @@
{
"CONTEXT_CHARACTER": "캐리ᄀ터",
"MENU_LABEL_COPYRIGHT": "저자ᄀ구ᅥᄂ",
"COPYRIGHT_ALL_RIGHTS_RESERVED": "모드ᄂ 구ᅥᄂ리 보유",
"COPYRIGHT_GNU_GPL_3": "GNU GPL 3에 ᄃ다라 배포도ᅵᄆ",
"APP_WARNING_HEALTH_AND_SAFETY": "겨ᄋ고—거ᄂ가ᄋ고ᅡ 아ᄂ저ᄂ으ᄅ 우ᅵ하여",
"MENU_LABEL_PRESS_START_SYMBOL": ">으ᄅ 누르세요",
"MENU_MODULES" : "모듀ᄅ",
"GAME_ACTION_MOVE_VERB" : "이도ᄋ하기",
"GAME_ACTION_ZOOM" : "호ᅡᄀ대·추ᄀ소",
"MENU_LABEL_RESET" : "재서ᄅ저ᄋ",
"GAME_32BIT_WARNING1": "32비트 버저ᄂ으ᅵ Java르ᄅ 사요ᄋ주ᄋ이ᄂ 거ᄉ 가ᄐ스ᄇ니다.",
"GAME_32BIT_WARNING2": "아래 리ᄋ크에서 초ᅵ시ᄂ 64비트 Java르ᄅ 내려바ᄃ아 서ᄅ치해주세요.",
"GAME_32BIT_WARNING3": "https://www.java.com/ko/download/",
"MENU_OPTION_STREAMERS_LAYOUT": "채티ᄋ차ᄋ 오버레이",
"MENU_LABEL_RESTART_REQUIRED": "재시자ᄀ 피ᄅ요",
"MENU_LABEL_KEYBOARD_LAYOUT": "자파ᄂ 배여ᄅ",
"MENU_LABEL_IME": "이ᄇ려ᄀ기",
"MENU_OPTIONS_DITHER": "디더리ᄋ",
"MENU_OPTIONS_BLUR": "흐리ᄆ",
"MENU_OPTIONS_PARTICLES": "이ᄇ자 수",
"MENU_IO_IMPORT": "가져오기"
}

Binary file not shown.

View File

@@ -1,14 +0,0 @@
{
"CONTEXT_WORLD_NEW": "あたらしい せかい",
"MENU_LABEL_DELETE_WORLD": "せかいを さくじょ",
"CONTEXT_WORLD_COUNT": "せかい: ",
"MENU_MONITOR_CALI_TITLE": "モニターチェック",
"GAME_INVENTORY_INGREDIENTS" : "ざいりょう",
"GAME_INVENTORY_POTIONS" : "すいやく",
"GAME_INVENTORY_BLOCKS" : "ブロック",
"GAME_INVENTORY_WALLS" : "かべ",
"CONTEXT_ITEM_TOOL_PLURAL" : "どうぐ",
"GAME_INVENTORY_FAVORITES" : "とうろく"
}

View File

@@ -1,78 +0,0 @@
{
"BLOCK_STONE": "도ᄅ",
"BLOCK_STONE_PLURAL": "도ᄅ",
"BLOCK_DIRT": "흐ᄅᄀ",
"BLOCK_DIRT_PLURAL": "흐ᄅᄀ",
"BLOCK_GRASS": "자ᄂ디",
"BLOCK_GRAS_PLURALS": "자ᄂ디",
"BLOCK_PLANK_NORMAL": "나무파ᄂ자",
"BLOCK_PLANK_NORMAL_PLURAL": "나무파ᄂ자",
"BLOCK_PLANK_EBONY": "거ᄆ저ᄋ 나무파ᄂ자",
"BLOCK_PLANK_EBONY_PLURAL": "거ᄆ저ᄋ 나무파ᄂ자",
"BLOCK_PLANK_BIRCH": "하야ᄋ 나무파ᄂ자",
"BLOCK_PLANK_BIRCH_PLURAL": "하야ᄋ 나무파ᄂ자",
"BLOCK_PLANK_BLOODROSE": "ᄇ바ᄅ가ᄋ 나무파ᄂ자",
"BLOCK_PLANK_BLOODROSE_PLURAL": "ᄇ바ᄅ가ᄋ 나무파ᄂ자",
"BLOCK_TRUNK_NORMAL": "토ᄋ나무",
"BLOCK_TRUNK_NORMAL_PLURAL": "토ᄋ나무",
"BLOCK_TRUNK_EBONY": "흐ᄀ다ᄂ나무",
"BLOCK_TRUNK_EBONY_PLURAL": "흐ᄀ다ᄂ나무",
"BLOCK_TRUNK_BIRCH": "자자ᄀ나무",
"BLOCK_TRUNK_BIRCH_PLURAL": "자자ᄀ나무",
"BLOCK_TRUNK_BLOODROSE": "자다ᄂ나무",
"BLOCK_TRUNK_BLOODROSE_PLURAL": "자다ᄂ나무",
"BLOCK_STONE_QUARRIED": "서ᄀ재",
"BLOCK_STONE_QUARRIED_PLURAL": "서ᄀ재",
"BLOCK_SAND": "모래",
"BLOCK_SAND_PLURAL": "모래",
"BLOCK_GRAVEL": "자가ᄅ",
"BLOCK_GRAVEL_PLURAL": "자가ᄅ",
"BLOCK_ORE_MALACHITE": "고ᄋ자ᄀ서ᄀ",
"BLOCK_ORE_MALACHITES": "고ᄋ자ᄀ서ᄀ",
"BLOCK_ORE_HEMATITE": "저ᄀ처ᄅ서ᄀ",
"BLOCK_ORE_HEMATITE_PLURAL": "저ᄀ처ᄅ서ᄀ",
"BLOCK_ORE_NATURAL_GOLD": "자여ᄂ그ᄆ",
"BLOCK_ORE_NATERAL_GOLD_PLURAL": "자여ᄂ그ᄆ",
"BLOCK_ORE_NATURAL_SILVER": "자여ᄂ으ᄂ",
"BLOCK_ORE_NATURAL_SILVER_PLURAL": "자여ᄂ으ᄂ",
"BLOCK_ORE_RUTILE": "그ᄆ호ᄋ서ᄀ",
"BLOCK_ORE_RUTILE_PLURAL": "그ᄆ호ᄋ서ᄀ",
"BLOCK_ORE_AURICHALCUMITE": "지ᄂ그ᄆ서ᄀ",
"BLOCK_ORE_AURICHALCUMITE_PLURAL": "지ᄂ그ᄆ서ᄀ",
"BLOCK_GEM_RUBY": "호ᄋ오ᄀ서ᄀ",
"BLOCK_GEM_RUBY_PLURAL": "호ᄋ오ᄀ서ᄀ",
"BLOCK_GEM_EMERALD": "추ᅵ오ᄀ서ᄀ",
"BLOCK_GEM_EMERALD_PLURAL": "추ᅵ오ᄀ서ᄀ",
"BLOCK_GEM_SAPPHIRE": "처ᄋ오ᄀ서ᄀ",
"BLOCK_GEM_SAPPHIRE_PLURAL": "처ᄋ오ᄀ서ᄀ",
"BLOCK_GEM_TOPAZ": "호ᅡᄋ오ᄀ서ᄀ",
"BLOCK_GEM_TOPAZ_PLURAL": "호ᅡᄋ오ᄀ서ᄀ",
"BLOCK_GEM_DIAMOND": "그ᄆ가ᄋ서ᄀ",
"BLOCK_GEM_DIAMOND_PLURAL": "그ᄆ가ᄋ서ᄀ",
"BLOCK_GEM_AMETHYST": "자수저ᄋ서ᄀ",
"BLOCK_GEM_AMETHYST_PLURAL": "자수저ᄋ서ᄀ",
"BLOCK_SNOW": "누ᄂ",
"BLOCK_SNOW_PLURAL": "누ᄂ",
"BLOCK_ICE_FRAGILE": "사ᄅ어ᄅ으ᄆ",
"BLOCK_ICE_FRAGILE_PLURAL": "사ᄅ어ᄅ으ᄆ",
"BLOCK_ICE_NATURAL": "어ᄅ으ᄆ",
"BLOCK_ICE_NATURAL_PLURAL": "어ᄅ으ᄆ",
"BLOCK_ICE_CLEAR_MAGICAL": "ᄀ개ᄀ그ᄉ하ᄂ 어ᄅ으ᄆ",
"BLOCK_ICE_CLEAR_MAGICAL_PLURAL": "ᄀ개ᄀ그ᄉ하ᄂ 어ᄅ으ᄆ",
"BLOCK_PLATFORM_STONE": "도ᄅ 바ᄅ파ᄂ",
"BLOCK_PLATFORM_STONE_PLURAL": "도ᄅ 바ᄅ파ᄂ",
"BLOCK_PLATFORM_WOODEN": "나무 바ᄅ파ᄂ",
"BLOCK_PLATFORM_WOODEN_PLURAL": "나무 바ᄅ파ᄂ",
"BLOCK_PLATFORM_EBONY": "흐ᄀ다ᄂ 바ᄅ파ᄂ",
"BLOCK_PLATFORM_EBONY_PLURAL": "흐ᄀ다ᄂ 바ᄅ파ᄂ",
"BLOCK_PLATFORM_BIRCH": "배ᄀ다ᄂ 바ᄅ파ᄂ",
"BLOCK_PLATFORM_BIRCH_PLURAL": "배ᄀ다ᄂ 바ᄅ파ᄂ",
"BLOCK_PLATFORM_BLOODROSE": "저ᄀ다ᄂ 바ᄅ파ᄂ",
"BLOCK_PLATFORM_BLOODROSE_PLURAL": "저ᄀ다ᄂ 바ᄅ파ᄂ",
"BLOCK_TORCH": "호ᅢᄉ부ᄅ",
"BLOCK_TORCH_PLURAL": "호ᅢᄉ부ᄅ",
"BLOCK_WATER": "무ᄅ",
"BLOCK_WATER_PLURAL": "무ᄅ",
"BLOCK_LAVA": "요ᄋ아ᄆ",
"BLOCK_LAVA_PLURAL": "요ᄋ아ᄆ"
}

View File

@@ -1,5 +0,0 @@
{
"DEV_MESSAGE_CONSOLE_CODEX": "사요ᄋ 가느ᄋ하ᄂ 며ᄋ려ᄋ어 모ᄀ로ᄀ으ᄅ 보려며ᄂ codex르ᄅ 이ᄇ려ᄀ해 주시ᄇ시오.",
"DEV_MESSAGE_CONSOLE_AVAILABLE_COMMANDS": "며ᄋ려ᄋ어 모ᄀ로ᄀ:",
"DEV_MESSAGE_CONSOLE_COMMAND_UNKNOWN": "%1$s: 아ᄅ 수 어ᄇᄉ느ᄂ 며ᄋ려ᄋ어"
}

View File

@@ -1,18 +0,0 @@
{
"CONTEXT_WORLD_NEW": "새 세계",
"MENU_LABEL_DELETE_WORLD": "새계 사ᄀ제",
"CONTEXT_WORLD_COUNT": "새계: ",
"MENU_MONITOR_CALI_TITLE": "모니터 호ᅡᄀ이ᄂ",
"GAME_INVENTORY_INGREDIENTS": "재료",
"GAME_INVENTORY_POTIONS": "무ᄅ야ᄀ",
"GAME_INVENTORY_BLOCKS": "브ᄅ로ᄀ",
"GAME_INVENTORY_WALLS": "벼ᄀ지",
"CONTEXT_ITEM_TOOL_PLURAL": "도구",
"GAME_INVENTORY_FAVORITES": "즈ᄅ겨차ᄌ기",
"GAME_INVENTORY_REGISTER": "드ᄋ로ᄀ하기",
"MENU_LABEL_MENU": "메뉴",
"CONTEXT_ITEM_MAP": "지도",
"CONTEXT_GENERATOR_SEED": "시드",
"GAME_ACTION_GRAPPLE": "매다ᄅ리기",
"GAME_ACTION_QUICKSEL": "빠르ᄂ 서ᄂ태ᄀ"
}

View File

@@ -1,3 +0,0 @@
{
"ITEM_STORAGE_CHEST": "보고ᅡᄂ사ᄋ자"
}

View File

@@ -1,6 +1,6 @@
package net.torvald.parametricsky.datasets package net.torvald.parametricsky.datasets
import net.torvald.terrarum.serialise.toLittleLong import net.torvald.terrarum.serialise.toLittleInt64
import java.io.File import java.io.File
import java.io.FileInputStream import java.io.FileInputStream
@@ -14,7 +14,7 @@ object DatasetOp {
val ret = DoubleArray(entrysize) { val ret = DoubleArray(entrysize) {
val inputbuf = ByteArray(8) val inputbuf = ByteArray(8)
fis.read(inputbuf) fis.read(inputbuf)
val rawnum = inputbuf.toLittleLong() val rawnum = inputbuf.toLittleInt64()
Double.fromBits(rawnum) Double.fromBits(rawnum)
} }

View File

@@ -22,29 +22,19 @@ object CommonResourcePool {
init { init {
addToLoadingList("itemplaceholder_16") { addToLoadingList("itemplaceholder_16") {
val t = TextureRegion(Texture("assets/item_kari_16.tga")) TextureRegion(Texture("assets/item_kari_16.tga")).also { it.flip(false, false) }
t.flip(false, false)
/*return*/t
} }
addToLoadingList("itemplaceholder_24") { addToLoadingList("itemplaceholder_24") {
val t = TextureRegion(Texture("assets/item_kari_24.tga")) TextureRegion(Texture("assets/item_kari_24.tga")).also { it.flip(false, false) }
t.flip(false, false)
/*return*/t
} }
addToLoadingList("itemplaceholder_32") { addToLoadingList("itemplaceholder_32") {
val t = TextureRegion(Texture("assets/item_kari_32.tga")) TextureRegion(Texture("assets/item_kari_32.tga")).also { it.flip(false, false) }
t.flip(false, false)
/*return*/t
} }
addToLoadingList("itemplaceholder_48") { addToLoadingList("itemplaceholder_48") {
val t = TextureRegion(Texture("assets/item_kari_48.tga")) TextureRegion(Texture("assets/item_kari_48.tga")).also { it.flip(false, false) }
t.flip(false, false)
/*return*/t
} }
addToLoadingList("test_texture") { addToLoadingList("test_texture") {
val t = TextureRegion(Texture("assets/test_texture.tga")) TextureRegion(Texture("assets/test_texture.tga")).also { it.flip(false, false) }
t.flip(false, false)
/*return*/t
} }
loadAll() loadAll()
} }
@@ -130,7 +120,7 @@ object CommonResourcePool {
fun getAsTexture(identifier: String) = getAs<Texture>(identifier) fun getAsTexture(identifier: String) = getAs<Texture>(identifier)
fun dispose() { fun dispose() {
pool.forEach { name, u -> pool.forEach { (name, u) ->
try { try {
when { when {
u is Disposable -> u.dispose() u is Disposable -> u.dispose()

View File

@@ -3,6 +3,12 @@ package net.torvald.terrarum
typealias ItemValue = KVHashMap typealias ItemValue = KVHashMap
/** /**
* Supported Value Types:
* - Int
* - Double (`getAsFloat()` first retrieves the Double value then casts to Float)
* - Boolean
* - String
*
* Created by minjaesong on 2015-12-30. * Created by minjaesong on 2015-12-30.
*/ */
open class KVHashMap { open class KVHashMap {
@@ -42,47 +48,29 @@ open class KVHashMap {
} }
fun getAsInt(key: String): Int? { fun getAsInt(key: String): Int? {
val value = get(key) val value = get(key) ?: return null
if (value == null) return null
return value as Int return value as Int
} }
fun getAsDouble(key: String): Double? { fun getAsDouble(key: String): Double? {
val value = get(key) val value = get(key) ?: return null
if (value is Int) return value.toDouble()
if (value == null) return null
if (value is Int)
return value.toDouble()
return value as Double return value as Double
} }
fun getAsFloat(key: String): Float? { fun getAsFloat(key: String): Float? {
val value = get(key) val value = get(key) ?: return null
if (value is Float) return value
if (value == null) return null
if (value is Float) return value as Float
return getAsDouble(key)?.toFloat() return getAsDouble(key)?.toFloat()
} }
fun getAsString(key: String): String? { fun getAsString(key: String): String? {
val value = get(key) val value = get(key) ?: return null
if (value == null) return null
return value as String return value as String
} }
fun getAsBoolean(key: String): Boolean? { fun getAsBoolean(key: String): Boolean? {
val value = get(key) val value = get(key) ?: return null
if (value == null) return null
return value as Boolean return value as Boolean
} }

View File

@@ -6,6 +6,7 @@ import com.badlogic.gdx.graphics.Pixmap
import com.badlogic.gdx.graphics.Texture import com.badlogic.gdx.graphics.Texture
import com.badlogic.gdx.graphics.g2d.SpriteBatch import com.badlogic.gdx.graphics.g2d.SpriteBatch
import net.torvald.terrarum.gameitems.GameItem import net.torvald.terrarum.gameitems.GameItem
import net.torvald.terrarum.langpack.Lang
import net.torvald.terrarum.ui.* import net.torvald.terrarum.ui.*
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
import kotlin.math.roundToInt import kotlin.math.roundToInt
@@ -41,6 +42,18 @@ class UIItemInventoryCatBar(
arrayOf(GameItem.Category.MISC), arrayOf(GameItem.Category.MISC),
arrayOf(CAT_ALL) arrayOf(CAT_ALL)
) )
internal val catIconsLabels = listOf(
{ Lang["GAME_INVENTORY_WEAPONS"] },
{ Lang["CONTEXT_ITEM_TOOL_PLURAL"] },
{ Lang["CONTEXT_ITEM_ARMOR"] },
{ Lang["GAME_INVENTORY_INGREDIENTS"] },
{ Lang["GAME_INVENTORY_POTIONS"] },
{ Lang["CONTEXT_ITEM_MAGIC"] },
{ Lang["GAME_INVENTORY_BLOCKS"] },
{ Lang["GAME_INVENTORY_WALLS"] },
{ Lang["GAME_GENRE_MISC"] },
{ Lang["MENU_LABEL_ALL"] },
)
private val inventoryUI = parentUI private val inventoryUI = parentUI
@@ -274,12 +287,17 @@ class UIItemInventoryCatBar(
batch.color = underlineColour batch.color = underlineColour
Toolkit.drawStraightLine(batch, posX, posY + height - 1, posX + width, 1, false) Toolkit.drawStraightLine(batch, posX, posY + height - 1, posX + width, 1, false)
// indicator
if (selectedPanel == 1) { if (selectedPanel == 1) {
// indicator
batch.color = underlineHighlightColour batch.color = underlineHighlightColour
batch.draw(underlineIndTex, (highlighterXPos - buttonGapSize / 2).toFloat().round(), posY + highlighterYPos) batch.draw(underlineIndTex, (highlighterXPos - buttonGapSize / 2).round(), posY + highlighterYPos)
}
// label
batch.color = Color.WHITE
catIconsLabels[selectedIcon]().let {
App.fontGame.draw(batch, it, posX + ((width - App.fontGame.getWidth(it)) / 2).toFloat(), posY + highlighterYPos + 4)
}
}
} }

View File

@@ -50,10 +50,7 @@ object AVKey {
const val STRENGTH = "strength" const val STRENGTH = "strength"
const val STRENGTHBUFF = "$STRENGTH$BUFF" const val STRENGTHBUFF = "$STRENGTH$BUFF"
const val ENCUMBRANCE = "encumbrance" const val ENCUMBRANCE = "encumbrance"
/** 30-bit RGB (Int)
* 0000 0010000000 0010000000 0010000000
* ^ Red ^ Green ^ Blue
*/
const val LUMR = "luminosityred" const val LUMR = "luminosityred"
const val LUMG = "luminositygreen" const val LUMG = "luminositygreen"
const val LUMB = "luminosityblue" const val LUMB = "luminosityblue"
@@ -142,4 +139,14 @@ object AVKey {
const val BAREHAND_MINHEIGHT = "barehandactionminheight" const val BAREHAND_MINHEIGHT = "barehandactionminheight"
const val BAREHAND_BASE_DIGSIZE = "basebarehanddiggingsize" const val BAREHAND_BASE_DIGSIZE = "basebarehanddiggingsize"
/** String
* Comma-separated values of UUID for the world, Ascii85-encoded, big endian.
*
* Use extension function `UUID.toAscii85()` and `String.ascii85toUUID()` defined in the file for net.torvald.terrarum.serialise.Ascii85
*
* example value: `"SIxM+kGlrjZgLx5Zeqz7,;:UIZ5Q=2WT35SgKpOp.,vvf'fNW3G<ROimy(Y;E<,-mdtr5|^RGOqr0x*T*lC,YABr1oQwErKG)pGC'gUG"`
*/
const val WORLD_PORTAL_DICT = ""
} }

View File

@@ -3,6 +3,8 @@ package net.torvald.terrarum.gameactors
import net.torvald.terrarum.KVHashMap import net.torvald.terrarum.KVHashMap
/** /**
* For the dictionary of recognised ActorValues, see the source code of [net.torvald.terrarum.gameactors.AVKey]
*
* Created by minjaesong on 2017-04-28. * Created by minjaesong on 2017-04-28.
*/ */
class ActorValue : KVHashMap { class ActorValue : KVHashMap {

View File

@@ -433,15 +433,15 @@ open class ActorWithBody : Actor {
} }
// get() methods are moved to update(), too much stray object being created is definitely not good // get() methods are moved to update(), too much stray object being created is definitely not good
val centrePosVector: Vector2 = Vector2(0.0,0.0) @Transient val centrePosVector: Vector2 = Vector2(0.0,0.0)
//get() = Vector2(hitbox.centeredX, hitbox.centeredY) //get() = Vector2(hitbox.centeredX, hitbox.centeredY)
val centrePosPoint: Point2d = Point2d(0.0, 0.0) @Transient val centrePosPoint: Point2d = Point2d(0.0, 0.0)
//get() = Point2d(hitbox.centeredX, hitbox.centeredY) //get() = Point2d(hitbox.centeredX, hitbox.centeredY)
val feetPosVector: Vector2 = Vector2(0.0,0.0) @Transient val feetPosVector: Vector2 = Vector2(0.0,0.0)
//get() = Vector2(hitbox.centeredX, hitbox.endY) //get() = Vector2(hitbox.centeredX, hitbox.endY)
val feetPosPoint: Point2d = Point2d(0.0,0.0) @Transient val feetPosPoint: Point2d = Point2d(0.0,0.0)
//get() = Point2d(hitbox.centeredX, hitbox.endY) //get() = Point2d(hitbox.centeredX, hitbox.endY)
val feetPosTile: Point2i = Point2i(0,0) @Transient val feetPosTile: Point2i = Point2i(0,0)
//get() = Point2i(hIntTilewiseHitbox.centeredX.floorInt(), hIntTilewiseHitbox.endY.floorInt()) //get() = Point2i(hIntTilewiseHitbox.centeredX.floorInt(), hIntTilewiseHitbox.endY.floorInt())
override fun run() = update(App.UPDATE_RATE) override fun run() = update(App.UPDATE_RATE)

View File

@@ -124,11 +124,7 @@ object IME {
if (langCode.isNotEmpty()) { if (langCode.isNotEmpty()) {
printdbg(this, "Icon order #${(k+1) / 20} - icons[\"$langCode\"] = iconSheet.get(1, ${k/20})") printdbg(this, "Icon order #${(k+1) / 20} - icons[\"$langCode\"] = iconSheet.get(1, ${k/20})")
iconSheet.get(1, k / 20).let { icons["$langCode"] = iconSheet.get(1, k / 20).also { it.flip(false, false) }
it.flip(false, false)
icons["$langCode"] = it
}
} }
} }

View File

@@ -108,7 +108,9 @@ abstract class GameItem(val originalID: ItemID) : Comparable<GameItem>, Cloneabl
*/ */
var equipPosition: Int = EquipPosition.NULL var equipPosition: Int = EquipPosition.NULL
abstract val material: Material internal val material: Material
get() = MaterialCodex.getOrDefault(materialId)
abstract val materialId: String
/** /**
* DO NOT READ FROM THIS VALUE: USE `ItemCodex.getItemImage(item)`; * DO NOT READ FROM THIS VALUE: USE `ItemCodex.getItemImage(item)`;

View File

@@ -88,7 +88,7 @@ class EntryPoint : ModuleEntryPoint() {
override var stackable = true override var stackable = true
override var inventoryCategory = if (isWall) Category.WALL else Category.BLOCK override var inventoryCategory = if (isWall) Category.WALL else Category.BLOCK
override var isDynamic = false override var isDynamic = false
override val material = MaterialCodex.getOrDefault(tile.material) override val materialId = tile.material
// override val itemImage: TextureRegion // override val itemImage: TextureRegion
// get() { // get() {
// val itemSheetNumber = App.tileMaker.tileIDtoItemSheetNumber(originalID) // val itemSheetNumber = App.tileMaker.tileIDtoItemSheetNumber(originalID)

View File

@@ -356,7 +356,9 @@ open class TerrarumIngame(batch: FlippingSpriteBatch) : IngameInstance(batch) {
codices.player.setPosition(it.physics.position) codices.player.setPosition(it.physics.position)
if (isMultiplayer) { if (isMultiplayer) {
printdbg(this, "Using world's ActorValue instead of player's")
codices.player.actorValue = it.actorValue!! codices.player.actorValue = it.actorValue!!
printdbg(this, "Using world's Inventory instead of player's")
codices.player.inventory = it.inventory!! codices.player.inventory = it.inventory!!
} }
} }

View File

@@ -186,9 +186,9 @@ class TitleScreen(batch: FlippingSpriteBatch) : IngameInstance(batch) {
// load a half-gradient texture that would be used throughout the titlescreen and its sub UIs // load a half-gradient texture that would be used throughout the titlescreen and its sub UIs
CommonResourcePool.addToLoadingList("title_halfgrad") { CommonResourcePool.addToLoadingList("title_halfgrad") {
val t = Texture(Gdx.files.internal("./assets/graphics/halfgrad.tga")) Texture(Gdx.files.internal("./assets/graphics/halfgrad.tga")).also {
t.setFilter(Texture.TextureFilter.Linear, Texture.TextureFilter.Linear) it.setFilter(Texture.TextureFilter.Linear, Texture.TextureFilter.Linear)
t }
} }
CommonResourcePool.loadAll() CommonResourcePool.loadAll()

View File

@@ -191,7 +191,7 @@ open class ActorHumanoid : ActorWithBody, Controllable, Pocketed, Factionable, L
override val originalName: String = actorValue.getAsString(AVKey.NAME) ?: "(no name)" override val originalName: String = actorValue.getAsString(AVKey.NAME) ?: "(no name)"
override var stackable = false override var stackable = false
override val isDynamic = false override val isDynamic = false
override val material = Material() override val materialId = ""
} }
override fun update(delta: Float) { override fun update(delta: Float) {

View File

@@ -1,29 +1,12 @@
package net.torvald.terrarum.modulebasegame.gameactors package net.torvald.terrarum.modulebasegame.gameactors
import com.badlogic.gdx.graphics.Camera
import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.graphics.g2d.SpriteBatch
import net.torvald.terrarum.* import net.torvald.terrarum.*
import net.torvald.terrarum.App.gamepadLabelStart
import net.torvald.terrarum.TerrarumAppConfiguration.TILE_SIZE import net.torvald.terrarum.TerrarumAppConfiguration.TILE_SIZE
import net.torvald.terrarum.gameactors.AVKey import net.torvald.terrarum.gameactors.AVKey
import net.torvald.terrarum.gameitems.GameItem
import net.torvald.terrarum.langpack.Lang import net.torvald.terrarum.langpack.Lang
import net.torvald.terrarum.modulebasegame.gameactors.FixtureInventory.Companion.CAPACITY_MODE_COUNT import net.torvald.terrarum.modulebasegame.gameactors.FixtureInventory.Companion.CAPACITY_MODE_COUNT
import net.torvald.terrarum.modulebasegame.ui.* import net.torvald.terrarum.modulebasegame.ui.*
import net.torvald.terrarum.modulebasegame.ui.UIInventoryCells.Companion.weightBarWidth
import net.torvald.terrarum.modulebasegame.ui.UIInventoryFull.Companion.CELLS_VRT
import net.torvald.terrarum.modulebasegame.ui.UIInventoryFull.Companion.INVENTORY_CELLS_OFFSET_X
import net.torvald.terrarum.modulebasegame.ui.UIInventoryFull.Companion.INVENTORY_CELLS_OFFSET_Y
import net.torvald.terrarum.modulebasegame.ui.UIInventoryFull.Companion.catBarWidth
import net.torvald.terrarum.modulebasegame.ui.UIInventoryFull.Companion.controlHelpHeight
import net.torvald.terrarum.modulebasegame.ui.UIInventoryFull.Companion.internalHeight
import net.torvald.terrarum.modulebasegame.ui.UIInventoryFull.Companion.internalWidth
import net.torvald.terrarum.modulebasegame.ui.UIItemInventoryItemGrid.Companion.listGap
import net.torvald.terrarum.ui.Toolkit
import net.torvald.terrarum.ui.UICanvas
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
import net.torvald.unicode.getKeycapPC
/** /**
* Created by minjaesong on 2019-07-08. * Created by minjaesong on 2019-07-08.
@@ -65,236 +48,3 @@ internal class FixtureStorageChest : FixtureBase {
const val MASS = 2.0 const val MASS = 2.0
} }
} }
internal class UIStorageChest : UICanvas(
toggleKeyLiteral = App.getConfigInt("control_key_inventory"),
toggleButtonLiteral = App.getConfigInt("control_gamepad_start"),
), HasInventory {
lateinit var chestInventory: FixtureInventory
lateinit var chestNameFun: () -> String
override var width = App.scr.width
override var height = App.scr.height
private val negotiator = object : InventoryTransactionNegotiator() {
override fun accept(player: FixtureInventory, fixture: FixtureInventory, item: GameItem, amount: Long) {
player.remove(item, amount)
fixture.add(item, amount)
}
override fun reject(fixture: FixtureInventory, player: FixtureInventory, item: GameItem, amount: Long) {
fixture.remove(item, amount)
player.add(item, amount)
}
}
override fun getNegotiator() = negotiator
override fun getFixtureInventory(): FixtureInventory = chestInventory
override fun getPlayerInventory(): FixtureInventory = INGAME.actorNowPlaying!!.inventory
private val catBar: UIItemInventoryCatBar
private val itemListChest: UIItemInventoryItemGrid
private val itemListPlayer: UIItemInventoryItemGrid
private var encumbrancePerc = 0f
private var isEncumbered = false
private var halfSlotOffset = (UIItemInventoryElemSimple.height + listGap) / 2
init {
catBar = UIItemInventoryCatBar(
this,
(App.scr.width - catBarWidth) / 2,
42 - UIInventoryFull.YPOS_CORRECTION + (App.scr.height - internalHeight) / 2,
internalWidth,
catBarWidth,
false
)
catBar.selectionChangeListener = { old, new -> itemListUpdate() }
itemListChest = UIItemInventoryItemGrid(
this,
catBar,
{ getFixtureInventory() },
INVENTORY_CELLS_OFFSET_X() - halfSlotOffset,
INVENTORY_CELLS_OFFSET_Y(),
6, CELLS_VRT,
drawScrollOnRightside = false,
drawWallet = false,
keyDownFun = { _, _, _, _, _ -> Unit },
touchDownFun = { gameItem, amount, _, _, _ ->
if (gameItem != null) {
negotiator.reject(getFixtureInventory(), getPlayerInventory(), gameItem, amount)
}
itemListUpdate()
}
)
// make grid mode buttons work together
itemListChest.gridModeButtons[0].touchDownListener = { _,_,_,_ -> setCompact(false) }
itemListChest.gridModeButtons[1].touchDownListener = { _,_,_,_ -> setCompact(true) }
itemListPlayer = UIItemInventoryItemGrid(
this,
catBar,
{ INGAME.actorNowPlaying!!.inventory }, // literally a player's inventory
INVENTORY_CELLS_OFFSET_X() - halfSlotOffset + (listGap + UIItemInventoryElemWide.height) * 7,
INVENTORY_CELLS_OFFSET_Y(),
6, CELLS_VRT,
drawScrollOnRightside = true,
drawWallet = false,
keyDownFun = { _, _, _, _, _ -> Unit },
touchDownFun = { gameItem, amount, _, _, _ ->
if (gameItem != null) {
negotiator.accept(getPlayerInventory(), getFixtureInventory(), gameItem, amount)
}
itemListUpdate()
}
)
itemListPlayer.gridModeButtons[0].touchDownListener = { _,_,_,_ -> setCompact(false) }
itemListPlayer.gridModeButtons[1].touchDownListener = { _,_,_,_ -> setCompact(true) }
handler.allowESCtoClose = true
addUIitem(catBar)
addUIitem(itemListChest)
addUIitem(itemListPlayer)
}
private var openingClickLatched = false
override fun show() {
itemListPlayer.getInventory = { INGAME.actorNowPlaying!!.inventory }
itemListUpdate()
openingClickLatched = Terrarum.mouseDown
UIItemInventoryItemGrid.tooltipShowing.clear()
INGAME.setTooltipMessage(null)
}
private fun itemListUpdate() {
itemListChest.rebuild(catBar.catIconsMeaning[catBar.selectedIcon])
itemListPlayer.rebuild(catBar.catIconsMeaning[catBar.selectedIcon])
encumbrancePerc = getPlayerInventory().capacity.toFloat() / getPlayerInventory().maxCapacity
isEncumbered = getPlayerInventory().isEncumbered
}
private fun setCompact(yes: Boolean) {
itemListChest.isCompactMode = yes
itemListChest.gridModeButtons[0].highlighted = !yes
itemListChest.gridModeButtons[1].highlighted = yes
itemListChest.itemPage = 0
itemListChest.rebuild(catBar.catIconsMeaning[catBar.selectedIcon])
itemListPlayer.isCompactMode = yes
itemListPlayer.gridModeButtons[0].highlighted = !yes
itemListPlayer.gridModeButtons[1].highlighted = yes
itemListPlayer.itemPage = 0
itemListPlayer.rebuild(catBar.catIconsMeaning[catBar.selectedIcon])
itemListUpdate()
}
override fun touchDown(screenX: Int, screenY: Int, pointer: Int, button: Int): Boolean {
if (!openingClickLatched) {
return super.touchDown(screenX, screenY, pointer, button)
}
return false
}
override fun updateUI(delta: Float) {
catBar.update(delta)
itemListChest.update(delta)
itemListPlayer.update(delta)
if (openingClickLatched && !Terrarum.mouseDown) openingClickLatched = false
}
private val thisOffsetX = UIInventoryFull.INVENTORY_CELLS_OFFSET_X() - halfSlotOffset
private val thisOffsetX2 = thisOffsetX + (listGap + UIItemInventoryElemWide.height) * 7
private val thisOffsetY = UIInventoryFull.INVENTORY_CELLS_OFFSET_Y()
private val cellsWidth = (listGap + UIItemInventoryElemWide.height) * 6 - listGap
private val controlHelp: String
get() = if (App.environment == RunningEnvironment.PC)
"${getKeycapPC(App.getConfigInt("control_key_inventory"))} ${Lang["GAME_ACTION_CLOSE"]}"
else
"$gamepadLabelStart ${Lang["GAME_ACTION_CLOSE"]} "
override fun renderUI(batch: SpriteBatch, camera: Camera) {
// background fill
UIInventoryFull.drawBackground(batch, handler.opacity)
// UI items
batch.color = Color.WHITE
catBar.render(batch, camera)
itemListChest.render(batch, camera)
itemListPlayer.render(batch, camera)
blendNormalStraightAlpha(batch)
// encumbrance meter
val encumbranceText = Lang["GAME_INVENTORY_ENCUMBRANCE"]
val chestName = chestNameFun()
val playerName = INGAME.actorNowPlaying!!.actorValue.getAsString(AVKey.NAME).orEmpty().let { it.ifBlank { Lang["GAME_INVENTORY"] } }
val encumbBarXPos = itemListPlayer.posX + itemListPlayer.width - weightBarWidth
val encumbBarTextXPos = encumbBarXPos - 6 - App.fontGame.getWidth(encumbranceText)
val yEnd = -UIInventoryFull.YPOS_CORRECTION + (App.scr.height + internalHeight).div(2).toFloat() // directly copied from UIInventoryFull.yEnd
val encumbBarYPos = yEnd - 20 + 3 // dunno why but extra 3 px is needed
val encumbCol = UIItemInventoryCellCommonRes.getHealthMeterColour(1f - encumbrancePerc, 0f, 1f)
val encumbBack = encumbCol mul UIItemInventoryCellCommonRes.meterBackDarkening
// encumbrance bar background
batch.color = encumbBack
Toolkit.fillArea(batch, encumbBarXPos, encumbBarYPos, weightBarWidth, controlHelpHeight - 6f)
// encumbrance bar
batch.color = encumbCol
Toolkit.fillArea(batch,
encumbBarXPos, encumbBarYPos,
if (getPlayerInventory().capacityMode == FixtureInventory.CAPACITY_MODE_NO_ENCUMBER)
1f
else // make sure 1px is always be seen
minOf(weightBarWidth, maxOf(1f, weightBarWidth * encumbrancePerc)),
controlHelpHeight - 6f
)
// chest name text
batch.color = Color.WHITE
App.fontGame.draw(batch, chestName, thisOffsetX + (cellsWidth - App.fontGame.getWidth(chestName)) / 2, thisOffsetY - 30)
App.fontGame.draw(batch, playerName, thisOffsetX2 + (cellsWidth - App.fontGame.getWidth(playerName)) / 2, thisOffsetY - 30)
// control hint
App.fontGame.draw(batch, controlHelp, thisOffsetX + 2f, encumbBarYPos - 3)
// encumb text
batch.color = Color.WHITE
App.fontGame.draw(batch, encumbranceText, encumbBarTextXPos, encumbBarYPos - 3f)
}
override fun doOpening(delta: Float) {
INGAME.pause()
INGAME.setTooltipMessage(null)
}
override fun doClosing(delta: Float) {
INGAME.resume()
INGAME.setTooltipMessage(null)
}
override fun endOpening(delta: Float) {
}
override fun endClosing(delta: Float) {
UIItemInventoryItemGrid.tooltipShowing.clear()
INGAME.setTooltipMessage(null) // required!
}
override fun dispose() {
}
}

View File

@@ -48,7 +48,7 @@ open class HumanoidNPC : ActorHumanoid, AIControlled, CanBeAnItem {
override val originalName: String = actorValue.getAsString(AVKey.NAME) ?: "NPC" override val originalName: String = actorValue.getAsString(AVKey.NAME) ?: "NPC"
override var stackable = true override var stackable = true
override val isDynamic = false override val isDynamic = false
override val material = Material() override val materialId = ""
override fun startPrimaryUse(actor: ActorWithBody, delta: Float): Long { override fun startPrimaryUse(actor: ActorWithBody, delta: Float): Long {
try { try {

View File

@@ -44,7 +44,7 @@ open class FixtureItemBase(originalID: ItemID, val fixtureClassName: String) : G
override var inventoryCategory = Category.MISC override var inventoryCategory = Category.MISC
override val isUnique = false override val isUnique = false
override val isDynamic = false override val isDynamic = false
override val material = Material() override val materialId = ""
/** /**
* Do not address the CommonResourcePool directly; just do it like this snippet: * Do not address the CommonResourcePool directly; just do it like this snippet:

View File

@@ -17,7 +17,7 @@ class ItemLogicSignalEmitter(originalID: ItemID) : FixtureItemBase(originalID, "
override var inventoryCategory = Category.MISC override var inventoryCategory = Category.MISC
override val isUnique = false override val isUnique = false
override val isDynamic = false override val isDynamic = false
override val material = Material() override val materialId = ""
override val itemImage: TextureRegion override val itemImage: TextureRegion
get() = getItemImageFromSingleImage("basegame", "sprites/fixtures/signal_source.tga") get() = getItemImageFromSingleImage("basegame", "sprites/fixtures/signal_source.tga")

View File

@@ -19,7 +19,7 @@ class ItemStorageChest(originalID: ItemID) : FixtureItemBase(originalID, "net.to
override var inventoryCategory = Category.MISC override var inventoryCategory = Category.MISC
override val isUnique = false override val isUnique = false
override val isDynamic = false override val isDynamic = false
override val material = Material() override val materialId = ""
override val itemImage: TextureRegion override val itemImage: TextureRegion
get() = CommonResourcePool.getAsTextureRegion("itemplaceholder_48") get() = CommonResourcePool.getAsTextureRegion("itemplaceholder_48")
override var baseToolSize: Double? = baseMass override var baseToolSize: Double? = baseMass

View File

@@ -19,7 +19,7 @@ class ItemSwingingDoorOak(originalID: ItemID) :
override var inventoryCategory = Category.MISC override var inventoryCategory = Category.MISC
override val isUnique = false override val isUnique = false
override val isDynamic = false override val isDynamic = false
override val material = Material() override val materialId = ""
override val itemImage: TextureRegion override val itemImage: TextureRegion
get() = CommonResourcePool.getAsTextureRegion("itemplaceholder_16") get() = CommonResourcePool.getAsTextureRegion("itemplaceholder_16")
override var baseToolSize: Double? = baseMass override var baseToolSize: Double? = baseMass
@@ -44,7 +44,7 @@ class ItemSwingingDoorEbony(originalID: ItemID) :
override var inventoryCategory = Category.MISC override var inventoryCategory = Category.MISC
override val isUnique = false override val isUnique = false
override val isDynamic = false override val isDynamic = false
override val material = Material() override val materialId = ""
override val itemImage: TextureRegion override val itemImage: TextureRegion
get() = CommonResourcePool.getAsTextureRegion("itemplaceholder_16") get() = CommonResourcePool.getAsTextureRegion("itemplaceholder_16")
override var baseToolSize: Double? = baseMass override var baseToolSize: Double? = baseMass
@@ -69,7 +69,7 @@ class ItemSwingingDoorBirch(originalID: ItemID) :
override var inventoryCategory = Category.MISC override var inventoryCategory = Category.MISC
override val isUnique = false override val isUnique = false
override val isDynamic = false override val isDynamic = false
override val material = Material() override val materialId = ""
override val itemImage: TextureRegion override val itemImage: TextureRegion
get() = CommonResourcePool.getAsTextureRegion("itemplaceholder_16") get() = CommonResourcePool.getAsTextureRegion("itemplaceholder_16")
override var baseToolSize: Double? = baseMass override var baseToolSize: Double? = baseMass
@@ -94,7 +94,7 @@ class ItemSwingingDoorRosewood(originalID: ItemID) :
override var inventoryCategory = Category.MISC override var inventoryCategory = Category.MISC
override val isUnique = false override val isUnique = false
override val isDynamic = false override val isDynamic = false
override val material = Material() override val materialId = ""
override val itemImage: TextureRegion override val itemImage: TextureRegion
get() = CommonResourcePool.getAsTextureRegion("itemplaceholder_16") get() = CommonResourcePool.getAsTextureRegion("itemplaceholder_16")
override var baseToolSize: Double? = baseMass override var baseToolSize: Double? = baseMass

View File

@@ -21,7 +21,7 @@ class ItemTapestry(originalID: ItemID) : FixtureItemBase(originalID, "net.torval
override var inventoryCategory = Category.MISC override var inventoryCategory = Category.MISC
override val isUnique = false override val isUnique = false
override val isDynamic = false override val isDynamic = false
override val material = Material() override val materialId = ""
override val itemImage: TextureRegion override val itemImage: TextureRegion
get() = CommonResourcePool.getAsTextureRegion("itemplaceholder_16") get() = CommonResourcePool.getAsTextureRegion("itemplaceholder_16")
override var baseToolSize: Double? = baseMass override var baseToolSize: Double? = baseMass

View File

@@ -17,7 +17,7 @@ class ItemTikiTorch(originalID: ItemID) : FixtureItemBase(originalID, "net.torva
override var inventoryCategory = Category.MISC override var inventoryCategory = Category.MISC
override val isUnique = false override val isUnique = false
override val isDynamic = false override val isDynamic = false
override val material = Material() override val materialId = ""
override val itemImage: TextureRegion override val itemImage: TextureRegion
get() = getItemImageFromSheet("basegame", "sprites/fixtures/tiki_torch.tga", 16, 32) get() = getItemImageFromSheet("basegame", "sprites/fixtures/tiki_torch.tga", 16, 32)

View File

@@ -17,7 +17,7 @@ class ItemTypewriter(originalID: ItemID) : FixtureItemBase(originalID, "net.torv
override var inventoryCategory = Category.MISC override var inventoryCategory = Category.MISC
override val isUnique = false override val isUnique = false
override val isDynamic = false override val isDynamic = false
override val material = Material() override val materialId = ""
override val itemImage: TextureRegion override val itemImage: TextureRegion
get() = getItemImageFromSheet("basegame", "sprites/fixtures/typewriter.tga", 32, 16) get() = getItemImageFromSheet("basegame", "sprites/fixtures/typewriter.tga", 32, 16)

View File

@@ -118,7 +118,7 @@ class PickaxeCopper(originalID: ItemID) : GameItem(originalID) {
override var inventoryCategory = Category.TOOL override var inventoryCategory = Category.TOOL
override val isUnique = false override val isUnique = false
override val isDynamic = true override val isDynamic = true
override val material = MaterialCodex["CUPR"] override val materialId = "CUPR"
override var baseMass = material.density.toDouble() / MaterialCodex["IRON"].density * BASE_MASS_AND_SIZE override var baseMass = material.density.toDouble() / MaterialCodex["IRON"].density * BASE_MASS_AND_SIZE
override val itemImage: TextureRegion override val itemImage: TextureRegion
get() = CommonResourcePool.getAsTextureRegionPack("basegame.items24").get(0,0) get() = CommonResourcePool.getAsTextureRegionPack("basegame.items24").get(0,0)
@@ -148,7 +148,7 @@ class PickaxeIron(originalID: ItemID) : GameItem(originalID) {
override var inventoryCategory = Category.TOOL override var inventoryCategory = Category.TOOL
override val isUnique = false override val isUnique = false
override val isDynamic = true override val isDynamic = true
override val material = MaterialCodex["IRON"] override val materialId = "IRON"
override var baseMass = material.density.toDouble() / MaterialCodex["IRON"].density * BASE_MASS_AND_SIZE override var baseMass = material.density.toDouble() / MaterialCodex["IRON"].density * BASE_MASS_AND_SIZE
override val itemImage: TextureRegion override val itemImage: TextureRegion
get() = CommonResourcePool.getAsTextureRegionPack("basegame.items24").get(1,0) get() = CommonResourcePool.getAsTextureRegionPack("basegame.items24").get(1,0)
@@ -178,7 +178,7 @@ class PickaxeSteel(originalID: ItemID) : GameItem(originalID) {
override var inventoryCategory = Category.TOOL override var inventoryCategory = Category.TOOL
override val isUnique = false override val isUnique = false
override val isDynamic = true override val isDynamic = true
override val material = MaterialCodex["STAL"] override val materialId = "STAL"
override var baseMass = material.density.toDouble() / MaterialCodex["IRON"].density * BASE_MASS_AND_SIZE override var baseMass = material.density.toDouble() / MaterialCodex["IRON"].density * BASE_MASS_AND_SIZE
override val itemImage: TextureRegion override val itemImage: TextureRegion
get() = CommonResourcePool.getAsTextureRegionPack("basegame.items24").get(2,0) get() = CommonResourcePool.getAsTextureRegionPack("basegame.items24").get(2,0)

View File

@@ -92,7 +92,7 @@ class WireCutterAll(originalID: ItemID) : GameItem(originalID) {
override var inventoryCategory = Category.TOOL override var inventoryCategory = Category.TOOL
override val isUnique = true override val isUnique = true
override val isDynamic = false override val isDynamic = false
override val material = Material() override val materialId = ""
override val itemImage: TextureRegion override val itemImage: TextureRegion
get() = CommonResourcePool.getAsTextureRegionPack("basegame.items16").get(0, 9) get() = CommonResourcePool.getAsTextureRegionPack("basegame.items16").get(0, 9)

View File

@@ -18,7 +18,7 @@ class WireGraphDebugger(originalID: ItemID) : GameItem(originalID) {
override var inventoryCategory = Category.TOOL override var inventoryCategory = Category.TOOL
override val isUnique = true override val isUnique = true
override val isDynamic = false override val isDynamic = false
override val material = MaterialCodex["CUPR"] override val materialId = "CUPR"
override var baseMass = 2.0 override var baseMass = 2.0
override val itemImage: TextureRegion override val itemImage: TextureRegion
get() = CommonResourcePool.getAsTextureRegion("itemplaceholder_24") get() = CommonResourcePool.getAsTextureRegion("itemplaceholder_24")

View File

@@ -22,7 +22,7 @@ class WirePieceSignalWire(originalID: ItemID, private val atlasID: String, priva
override var inventoryCategory = Category.WIRE override var inventoryCategory = Category.WIRE
override val isUnique = false override val isUnique = false
override val isDynamic = false override val isDynamic = false
override val material = Material() override val materialId = ""
override val itemImage: TextureRegion override val itemImage: TextureRegion
get() = CommonResourcePool.getAsTextureRegionPack(atlasID).get(sheetX, sheetY) get() = CommonResourcePool.getAsTextureRegionPack(atlasID).get(sheetX, sheetY)

View File

@@ -1,4 +1,4 @@
package net.torvald.terrarum.modulebasegame.gameactors package net.torvald.terrarum.modulebasegame.ui
import com.badlogic.gdx.graphics.Camera import com.badlogic.gdx.graphics.Camera
import com.badlogic.gdx.graphics.Color import com.badlogic.gdx.graphics.Color
@@ -12,6 +12,8 @@ import net.torvald.terrarum.gameitems.GameItem
import net.torvald.terrarum.gameitems.ItemID import net.torvald.terrarum.gameitems.ItemID
import net.torvald.terrarum.itemproperties.CraftingCodex import net.torvald.terrarum.itemproperties.CraftingCodex
import net.torvald.terrarum.langpack.Lang import net.torvald.terrarum.langpack.Lang
import net.torvald.terrarum.modulebasegame.gameactors.FixtureInventory
import net.torvald.terrarum.modulebasegame.gameactors.InventoryPair
import net.torvald.terrarum.modulebasegame.ui.* import net.torvald.terrarum.modulebasegame.ui.*
import net.torvald.terrarum.modulebasegame.ui.UIItemInventoryItemGrid.Companion.listGap import net.torvald.terrarum.modulebasegame.ui.UIItemInventoryItemGrid.Companion.listGap
import net.torvald.terrarum.ui.Toolkit import net.torvald.terrarum.ui.Toolkit

View File

@@ -9,7 +9,6 @@ import net.torvald.terrarum.*
import net.torvald.terrarum.App.* import net.torvald.terrarum.App.*
import net.torvald.terrarum.langpack.Lang import net.torvald.terrarum.langpack.Lang
import net.torvald.terrarum.modulebasegame.gameactors.ActorHumanoid import net.torvald.terrarum.modulebasegame.gameactors.ActorHumanoid
import net.torvald.terrarum.modulebasegame.gameactors.UICrafting
import net.torvald.terrarum.ui.Toolkit import net.torvald.terrarum.ui.Toolkit
import net.torvald.terrarum.ui.UICanvas import net.torvald.terrarum.ui.UICanvas
import net.torvald.terrarum.ui.UIItemHorizontalFadeSlide import net.torvald.terrarum.ui.UIItemHorizontalFadeSlide
@@ -160,6 +159,7 @@ class UIInventoryFull(
fun unlockTransition() { fun unlockTransition() {
panelTransitionLocked = false panelTransitionLocked = false
} }
fun requestTransition(target: Int) = transitionPanel.requestTransition(target)
val catBar = UIItemInventoryCatBar( val catBar = UIItemInventoryCatBar(
this, this,
@@ -167,13 +167,12 @@ class UIInventoryFull(
42 - YPOS_CORRECTION + (App.scr.height - internalHeight) / 2, 42 - YPOS_CORRECTION + (App.scr.height - internalHeight) / 2,
internalWidth, internalWidth,
catBarWidth, catBarWidth,
true, true
{ i -> if (!panelTransitionLocked) requestTransition(i) } ) { i -> if (!panelTransitionLocked) requestTransition(i) }
)
// private val transitionalMinimap = UIInventoryMinimap(this) // PLACEHOLDER // private val transitionalMinimap = UIInventoryMinimap(this)
private val transitionalCraftingUI = UICrafting(this) // PLACEHOLDER private val transitionalCraftingUI = UICrafting(this)
private val transitionalItemCells = UIInventoryCells(this) private val transitionalItemCells = UIInventoryCells(this)
private val transitionalEscMenu = UIInventoryEscMenu(this) private val transitionalEscMenu = UIInventoryEscMenu(this)
private val transitionPanel = UIItemHorizontalFadeSlide( private val transitionPanel = UIItemHorizontalFadeSlide(
@@ -258,8 +257,6 @@ class UIInventoryFull(
internal var offsetY = ((App.scr.height - internalHeight) / 2).toFloat() internal var offsetY = ((App.scr.height - internalHeight) / 2).toFloat()
private set private set
fun requestTransition(target: Int) = transitionPanel.requestTransition(target)
override fun updateUI(delta: Float) { override fun updateUI(delta: Float) {
if (handler.openFired) { if (handler.openFired) {
rebuildList() rebuildList()

View File

@@ -7,7 +7,6 @@ import net.torvald.terrarum.UIItemInventoryCatBar
import net.torvald.terrarum.ceilInt import net.torvald.terrarum.ceilInt
import net.torvald.terrarum.gameitems.GameItem import net.torvald.terrarum.gameitems.GameItem
import net.torvald.terrarum.itemproperties.CraftingCodex import net.torvald.terrarum.itemproperties.CraftingCodex
import net.torvald.terrarum.modulebasegame.gameactors.UICrafting
/** /**
* Created by minjaesong on 2022-06-28. * Created by minjaesong on 2022-06-28.

View File

@@ -85,8 +85,7 @@ class UILoadDemoSavefiles(val remoCon: UIRemoCon) : UICanvas() {
init { init {
CommonResourcePool.addToLoadingList("terrarum-defaultsavegamethumb") { CommonResourcePool.addToLoadingList("terrarum-defaultsavegamethumb") {
val t = TextureRegion(Texture(Gdx.files.internal("assets/graphics/gui/savegame_thumb_placeholder.png"))) TextureRegion(Texture(Gdx.files.internal("assets/graphics/gui/savegame_thumb_placeholder.png")))
t.flip(false, false); t
} }
CommonResourcePool.addToLoadingList("savegame_status_icon") { CommonResourcePool.addToLoadingList("savegame_status_icon") {
TextureRegionPack("assets/graphics/gui/savegame_status_icon.tga", 24, 24) TextureRegionPack("assets/graphics/gui/savegame_status_icon.tga", 24, 24)

View File

@@ -0,0 +1,255 @@
package net.torvald.terrarum.modulebasegame.ui
import com.badlogic.gdx.graphics.Camera
import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.graphics.g2d.SpriteBatch
import net.torvald.terrarum.*
import net.torvald.terrarum.gameactors.AVKey
import net.torvald.terrarum.gameitems.GameItem
import net.torvald.terrarum.langpack.Lang
import net.torvald.terrarum.modulebasegame.gameactors.FixtureInventory
import net.torvald.terrarum.ui.Toolkit
import net.torvald.terrarum.ui.UICanvas
import net.torvald.unicode.getKeycapPC
/**
* Created by minjaesong on 2019-07-08.
*/
internal class UIStorageChest : UICanvas(
toggleKeyLiteral = App.getConfigInt("control_key_inventory"),
toggleButtonLiteral = App.getConfigInt("control_gamepad_start"),
), HasInventory {
lateinit var chestInventory: FixtureInventory
lateinit var chestNameFun: () -> String
override var width = App.scr.width
override var height = App.scr.height
private val negotiator = object : InventoryTransactionNegotiator() {
override fun accept(player: FixtureInventory, fixture: FixtureInventory, item: GameItem, amount: Long) {
player.remove(item, amount)
fixture.add(item, amount)
}
override fun reject(fixture: FixtureInventory, player: FixtureInventory, item: GameItem, amount: Long) {
fixture.remove(item, amount)
player.add(item, amount)
}
}
override fun getNegotiator() = negotiator
override fun getFixtureInventory(): FixtureInventory = chestInventory
override fun getPlayerInventory(): FixtureInventory = INGAME.actorNowPlaying!!.inventory
private val catBar: UIItemInventoryCatBar
private val itemListChest: UIItemInventoryItemGrid
private val itemListPlayer: UIItemInventoryItemGrid
private var encumbrancePerc = 0f
private var isEncumbered = false
private var halfSlotOffset = (UIItemInventoryElemSimple.height + UIItemInventoryItemGrid.listGap) / 2
init {
catBar = UIItemInventoryCatBar(
this,
(App.scr.width - UIInventoryFull.catBarWidth) / 2,
42 - UIInventoryFull.YPOS_CORRECTION + (App.scr.height - UIInventoryFull.internalHeight) / 2,
UIInventoryFull.internalWidth,
UIInventoryFull.catBarWidth,
false
)
catBar.selectionChangeListener = { old, new -> itemListUpdate() }
itemListChest = UIItemInventoryItemGrid(
this,
catBar,
{ getFixtureInventory() },
UIInventoryFull.INVENTORY_CELLS_OFFSET_X() - halfSlotOffset,
UIInventoryFull.INVENTORY_CELLS_OFFSET_Y(),
6, UIInventoryFull.CELLS_VRT,
drawScrollOnRightside = false,
drawWallet = false,
keyDownFun = { _, _, _, _, _ -> Unit },
touchDownFun = { gameItem, amount, _, _, _ ->
if (gameItem != null) {
negotiator.reject(getFixtureInventory(), getPlayerInventory(), gameItem, amount)
}
itemListUpdate()
}
)
// make grid mode buttons work together
itemListChest.gridModeButtons[0].touchDownListener = { _,_,_,_ -> setCompact(false) }
itemListChest.gridModeButtons[1].touchDownListener = { _,_,_,_ -> setCompact(true) }
itemListPlayer = UIItemInventoryItemGrid(
this,
catBar,
{ INGAME.actorNowPlaying!!.inventory }, // literally a player's inventory
UIInventoryFull.INVENTORY_CELLS_OFFSET_X() - halfSlotOffset + (UIItemInventoryItemGrid.listGap + UIItemInventoryElemWide.height) * 7,
UIInventoryFull.INVENTORY_CELLS_OFFSET_Y(),
6, UIInventoryFull.CELLS_VRT,
drawScrollOnRightside = true,
drawWallet = false,
keyDownFun = { _, _, _, _, _ -> Unit },
touchDownFun = { gameItem, amount, _, _, _ ->
if (gameItem != null) {
negotiator.accept(getPlayerInventory(), getFixtureInventory(), gameItem, amount)
}
itemListUpdate()
}
)
itemListPlayer.gridModeButtons[0].touchDownListener = { _,_,_,_ -> setCompact(false) }
itemListPlayer.gridModeButtons[1].touchDownListener = { _,_,_,_ -> setCompact(true) }
handler.allowESCtoClose = true
addUIitem(catBar)
addUIitem(itemListChest)
addUIitem(itemListPlayer)
}
private var openingClickLatched = false
override fun show() {
itemListPlayer.getInventory = { INGAME.actorNowPlaying!!.inventory }
itemListUpdate()
openingClickLatched = Terrarum.mouseDown
UIItemInventoryItemGrid.tooltipShowing.clear()
INGAME.setTooltipMessage(null)
}
private fun itemListUpdate() {
itemListChest.rebuild(catBar.catIconsMeaning[catBar.selectedIcon])
itemListPlayer.rebuild(catBar.catIconsMeaning[catBar.selectedIcon])
encumbrancePerc = getPlayerInventory().capacity.toFloat() / getPlayerInventory().maxCapacity
isEncumbered = getPlayerInventory().isEncumbered
}
private fun setCompact(yes: Boolean) {
itemListChest.isCompactMode = yes
itemListChest.gridModeButtons[0].highlighted = !yes
itemListChest.gridModeButtons[1].highlighted = yes
itemListChest.itemPage = 0
itemListChest.rebuild(catBar.catIconsMeaning[catBar.selectedIcon])
itemListPlayer.isCompactMode = yes
itemListPlayer.gridModeButtons[0].highlighted = !yes
itemListPlayer.gridModeButtons[1].highlighted = yes
itemListPlayer.itemPage = 0
itemListPlayer.rebuild(catBar.catIconsMeaning[catBar.selectedIcon])
itemListUpdate()
}
override fun touchDown(screenX: Int, screenY: Int, pointer: Int, button: Int): Boolean {
if (!openingClickLatched) {
return super.touchDown(screenX, screenY, pointer, button)
}
return false
}
override fun updateUI(delta: Float) {
catBar.update(delta)
itemListChest.update(delta)
itemListPlayer.update(delta)
if (openingClickLatched && !Terrarum.mouseDown) openingClickLatched = false
}
private val thisOffsetX = UIInventoryFull.INVENTORY_CELLS_OFFSET_X() - halfSlotOffset
private val thisOffsetX2 = thisOffsetX + (UIItemInventoryItemGrid.listGap + UIItemInventoryElemWide.height) * 7
private val thisOffsetY = UIInventoryFull.INVENTORY_CELLS_OFFSET_Y()
private val cellsWidth = (UIItemInventoryItemGrid.listGap + UIItemInventoryElemWide.height) * 6 - UIItemInventoryItemGrid.listGap
private val controlHelp: String
get() = if (App.environment == RunningEnvironment.PC)
"${getKeycapPC(App.getConfigInt("control_key_inventory"))} ${Lang["GAME_ACTION_CLOSE"]}"
else
"${App.gamepadLabelStart} ${Lang["GAME_ACTION_CLOSE"]} "
override fun renderUI(batch: SpriteBatch, camera: Camera) {
// background fill
UIInventoryFull.drawBackground(batch, handler.opacity)
// UI items
batch.color = Color.WHITE
catBar.render(batch, camera)
itemListChest.render(batch, camera)
itemListPlayer.render(batch, camera)
blendNormalStraightAlpha(batch)
// encumbrance meter
val encumbranceText = Lang["GAME_INVENTORY_ENCUMBRANCE"]
val chestName = chestNameFun()
val playerName = INGAME.actorNowPlaying!!.actorValue.getAsString(AVKey.NAME).orEmpty().let { it.ifBlank { Lang["GAME_INVENTORY"] } }
val encumbBarXPos = itemListPlayer.posX + itemListPlayer.width - UIInventoryCells.weightBarWidth
val encumbBarTextXPos = encumbBarXPos - 6 - App.fontGame.getWidth(encumbranceText)
val yEnd = -UIInventoryFull.YPOS_CORRECTION + (App.scr.height + UIInventoryFull.internalHeight).div(2).toFloat() // directly copied from UIInventoryFull.yEnd
val encumbBarYPos = yEnd - 20 + 3 // dunno why but extra 3 px is needed
val encumbCol = UIItemInventoryCellCommonRes.getHealthMeterColour(1f - encumbrancePerc, 0f, 1f)
val encumbBack = encumbCol mul UIItemInventoryCellCommonRes.meterBackDarkening
// encumbrance bar background
batch.color = encumbBack
Toolkit.fillArea(
batch,
encumbBarXPos,
encumbBarYPos,
UIInventoryCells.weightBarWidth,
UIInventoryFull.controlHelpHeight - 6f
)
// encumbrance bar
batch.color = encumbCol
Toolkit.fillArea(
batch,
encumbBarXPos, encumbBarYPos,
if (getPlayerInventory().capacityMode == FixtureInventory.CAPACITY_MODE_NO_ENCUMBER)
1f
else // make sure 1px is always be seen
minOf(UIInventoryCells.weightBarWidth, maxOf(1f, UIInventoryCells.weightBarWidth * encumbrancePerc)),
UIInventoryFull.controlHelpHeight - 6f
)
// chest name text
batch.color = Color.WHITE
App.fontGame.draw(batch, chestName, thisOffsetX + (cellsWidth - App.fontGame.getWidth(chestName)) / 2, thisOffsetY - 30)
App.fontGame.draw(batch, playerName, thisOffsetX2 + (cellsWidth - App.fontGame.getWidth(playerName)) / 2, thisOffsetY - 30)
// control hint
App.fontGame.draw(batch, controlHelp, thisOffsetX + 2f, encumbBarYPos - 3)
// encumb text
batch.color = Color.WHITE
App.fontGame.draw(batch, encumbranceText, encumbBarTextXPos, encumbBarYPos - 3f)
}
override fun doOpening(delta: Float) {
INGAME.pause()
INGAME.setTooltipMessage(null)
}
override fun doClosing(delta: Float) {
INGAME.resume()
INGAME.setTooltipMessage(null)
}
override fun endOpening(delta: Float) {
}
override fun endClosing(delta: Float) {
UIItemInventoryItemGrid.tooltipShowing.clear()
INGAME.setTooltipMessage(null) // required!
}
override fun dispose() {
}
}

View File

@@ -4,12 +4,12 @@ import com.badlogic.gdx.graphics.Camera
import com.badlogic.gdx.graphics.Color import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.graphics.g2d.SpriteBatch import com.badlogic.gdx.graphics.g2d.SpriteBatch
import net.torvald.terrarum.App import net.torvald.terrarum.App
import net.torvald.terrarum.Second
import net.torvald.terrarum.Terrarum import net.torvald.terrarum.Terrarum
import net.torvald.terrarum.langpack.Lang import net.torvald.terrarum.langpack.Lang
import net.torvald.terrarum.ui.Toolkit import net.torvald.terrarum.ui.Toolkit
import net.torvald.terrarum.ui.UICanvas import net.torvald.terrarum.ui.UICanvas
import net.torvald.terrarum.ui.UIItemTextButtonList import net.torvald.terrarum.ui.UIItemTextButtonList
import kotlin.math.ceil
class UITitleLanguage(remoCon: UIRemoCon?) : UICanvas() { class UITitleLanguage(remoCon: UIRemoCon?) : UICanvas() {
@@ -22,8 +22,8 @@ class UITitleLanguage(remoCon: UIRemoCon?) : UICanvas() {
private val textButtonLineHeight = 32 private val textButtonLineHeight = 32
private val localeList = Lang.languageList.toList().sorted() private val localeList = Lang.languageList.toList().sorted()
private val localeFirstHalf = localeList.subList(0, localeList.size / 2) private val localeFirstHalf = localeList.subList(0, ceil(localeList.size / 2f).toInt())
private val localeSecondHalf = localeList.subList(localeList.size / 2, localeList.size) private val localeSecondHalf = localeList.subList(ceil(localeList.size / 2f).toInt(), localeList.size)
override var width = 480 override var width = 480
override var height = maxOf(localeFirstHalf.size, localeSecondHalf.size) * textButtonLineHeight override var height = maxOf(localeFirstHalf.size, localeSecondHalf.size) * textButtonLineHeight

View File

@@ -0,0 +1,126 @@
package net.torvald.terrarum.modulebasegame.ui
import com.badlogic.gdx.graphics.Camera
import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.graphics.g2d.SpriteBatch
import net.torvald.terrarum.*
import net.torvald.terrarum.ui.Toolkit
import net.torvald.terrarum.ui.UICanvas
import net.torvald.terrarum.ui.UIItemHorizontalFadeSlide
/**
* Structure:
*
* UIWorldPortal (the container)
* + UIWorldPortalSearch (left panel)
* + UIWorldPortalListing (centre panel)
* + UIWorldPortalCargo (right panel)
*
* Created by minjaesong on 2023-05-19.
*/
class UIWorldPortal : UICanvas() {
override var width = App.scr.width
override var height = App.scr.height
val gradStartCol = Color(0x404040_60)
val gradEndCol = Color(0x000000_70)
val gradHeight = 48f
val controlHelpHeight = App.fontGame.lineHeight
private var panelTransitionLocked = false
fun lockTransition() {
panelTransitionLocked = true
}
fun unlockTransition() {
panelTransitionLocked = false
}
fun requestTransition(target: Int) = transitionPanel.requestTransition(target)
val catBar = UIItemInventoryCatBar(
this,
(width - UIInventoryFull.catBarWidth) / 2,
42 - UIInventoryFull.YPOS_CORRECTION + (App.scr.height - UIInventoryFull.internalHeight) / 2,
UIInventoryFull.internalWidth,
UIInventoryFull.catBarWidth,
true
) { i -> if (!panelTransitionLocked) requestTransition(i) }
private val transitionalSearch = UIWorldPortalSearch(this)
private val transitionalListing = UIWorldPortalListing(this)
private val transitionalCargo = UIWorldPortalCargo(this)
private val transitionPanel = UIItemHorizontalFadeSlide(
this,
(width - UIInventoryFull.internalWidth) / 2,
UIInventoryFull.INVENTORY_CELLS_OFFSET_Y(),
width,
App.scr.height,
1f,
transitionalSearch, transitionalListing, transitionalCargo
)
init {
addUIitem(catBar)
addUIitem(transitionPanel)
}
override fun updateUI(delta: Float) {
}
override fun renderUI(batch: SpriteBatch, camera: Camera) {
UIInventoryFull.drawBackground(batch, handler.opacity)
// UI items
catBar.render(batch, camera)
transitionPanel.render(batch, camera)
}
override fun dispose() {
catBar.dispose()
}
fun resetUI() {
}
override fun doOpening(delta: Float) {
super.doOpening(delta)
resetUI()
INGAME.setTooltipMessage(null)
}
override fun doClosing(delta: Float) {
super.doClosing(delta)
INGAME.setTooltipMessage(null)
}
override fun endOpening(delta: Float) {
super.endOpening(delta)
UIItemInventoryItemGrid.tooltipShowing.clear()
INGAME.setTooltipMessage(null) // required!
}
override fun endClosing(delta: Float) {
super.endClosing(delta)
resetUI()
UIItemInventoryItemGrid.tooltipShowing.clear()
INGAME.setTooltipMessage(null) // required!
}
}

View File

@@ -0,0 +1,25 @@
package net.torvald.terrarum.modulebasegame.ui
import com.badlogic.gdx.graphics.Camera
import com.badlogic.gdx.graphics.g2d.SpriteBatch
import net.torvald.terrarum.App
import net.torvald.terrarum.ui.Toolkit
import net.torvald.terrarum.ui.UICanvas
class UIWorldPortalCargo(val full: UIWorldPortal) : UICanvas() {
override var width: Int = Toolkit.drawWidth
override var height: Int = App.scr.height
override fun updateUI(delta: Float) {
TODO("Not yet implemented")
}
override fun renderUI(batch: SpriteBatch, camera: Camera) {
TODO("Not yet implemented")
}
override fun dispose() {
TODO("Not yet implemented")
}
}

View File

@@ -0,0 +1,129 @@
package net.torvald.terrarum.modulebasegame.ui
import com.badlogic.gdx.graphics.Camera
import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.graphics.Texture
import com.badlogic.gdx.graphics.g2d.SpriteBatch
import com.badlogic.gdx.graphics.g2d.TextureRegion
import net.torvald.terrarum.*
import net.torvald.terrarum.gameactors.AVKey
import net.torvald.terrarum.modulebasegame.ui.UIInventoryFull.Companion.INVENTORY_CELLS_OFFSET_Y
import net.torvald.terrarum.modulebasegame.ui.UIItemInventoryItemGrid.Companion.listGap
import net.torvald.terrarum.savegame.DiskSkimmer
import net.torvald.terrarum.serialise.ascii85toUUID
import net.torvald.terrarum.ui.Toolkit
import net.torvald.terrarum.ui.UICanvas
import net.torvald.terrarum.ui.UIItem
import net.torvald.terrarum.ui.UIItemTextButton
import java.util.*
/**
* Created by minjaesong on 2023-05-19.
*/
class UIWorldPortalListing(val full: UIWorldPortal) : UICanvas() {
override var width: Int = Toolkit.drawWidth
override var height: Int = App.scr.height
private val cellHeight = 48
private val buttonHeight = 24
private val gridGap = listGap
private var worldList: List<Pair<UUID, DiskSkimmer>>
private var selectedWorld: DiskSkimmer? = null
private val cellCol = UIInventoryFull.CELL_COL
private var highlightCol: Color = Color.WHITE
private val thumbw = 360
private val thumbh = 240
private val hx = Toolkit.drawWidth.div(2)
private val y = INVENTORY_CELLS_OFFSET_Y()
private val listCount = UIInventoryFull.CELLS_VRT
private val listHeight = cellHeight * listCount + gridGap * (listCount - 1)
private val deleteButtonWidth = 80
private val buttonReset = UIItemTextButton(this,
"MENU_LABEL_DELETE_WORLD",
hx - gridGap/2 - deleteButtonWidth,
y + listHeight - buttonHeight,
deleteButtonWidth,
readFromLang = true,
hasBorder = true,
alignment = UIItemTextButton.Companion.Alignment.CENTRE
)
init {
CommonResourcePool.addToLoadingList("terrarum-basegame-worldportalicons") {
TextureRegion(Texture(ModMgr.getGdxFile("basegame", "gui/worldportal_catbar.tga")), 20, 20).also {
it.flip(false, false)
}
}
CommonResourcePool.loadAll()
addUIitem(buttonReset)
worldList = (INGAME.actorGamer.actorValue.getAsString(AVKey.WORLD_PORTAL_DICT) ?: "").split(",").map {
it.ascii85toUUID().let { it to App.savegameWorlds[it] }
}.filter { it.second != null } as List<Pair<UUID, DiskSkimmer>>
}
override fun updateUI(delta: Float) {
}
override fun renderUI(batch: SpriteBatch, camera: Camera) {
batch.inUse {
// draw background //
// screencap panel
batch.color = cellCol
Toolkit.fillArea(batch, hx - thumbw - gridGap/2, y, thumbw, thumbh)
// draw border //
// screencap panel
batch.color = highlightCol
Toolkit.drawBoxBorder(batch, hx - thumbw - gridGap/2 - 1, y - 1, thumbw + 2, thumbh + 2)
// memory gauge
Toolkit.drawBoxBorder(batch, hx - 330 - gridGap/2 - 1, y + listHeight - 1, 240 + 2, buttonHeight + 2)
uiItems.forEach { it.render(batch, camera) }
}
}
override fun dispose() {
}
}
class UIItemWorldCellsSimple(
parent: UILoadDemoSavefiles,
initialX: Int,
initialY: Int,
val skimmer: DiskSkimmer
) : UIItem(parent, initialX, initialY) {
override val width: Int = 360
override val height: Int = 46
private val cellCol = UIInventoryFull.CELL_COL
private var highlightCol: Color = Color.WHITE
override fun dispose() {
}
}

View File

@@ -0,0 +1,28 @@
package net.torvald.terrarum.modulebasegame.ui
import com.badlogic.gdx.graphics.Camera
import com.badlogic.gdx.graphics.g2d.SpriteBatch
import net.torvald.terrarum.App
import net.torvald.terrarum.ui.Toolkit
import net.torvald.terrarum.ui.UICanvas
/**
* Created by minjaesong on 2023-05-19.
*/
class UIWorldPortalSearch(val full: UIWorldPortal) : UICanvas() {
override var width: Int = Toolkit.drawWidth
override var height: Int = App.scr.height
override fun updateUI(delta: Float) {
TODO("Not yet implemented")
}
override fun renderUI(batch: SpriteBatch, camera: Camera) {
TODO("Not yet implemented")
}
override fun dispose() {
TODO("Not yet implemented")
}
}

View File

@@ -1,8 +1,11 @@
package net.torvald.terrarum.serialise package net.torvald.terrarum.serialise
import net.torvald.terrarum.savegame.toBigEndian
import java.util.UUID
import kotlin.math.ceil
/** /**
* Standard Ascii85 implementation, except that the character sets used are as defined in * Ascii85 implementation with my own character table based on RFC 1924. Will NOT truncate '00000' into something else;
* RFC 1924 for JSON-compatibility, and will NOT truncate '00000' into something else;
* just gzip the inputstream instead! * just gzip the inputstream instead!
*/ */
object Ascii85 { object Ascii85 {
@@ -31,9 +34,6 @@ object Ascii85 {
INVERSE_TABLE[CHAR_TABLE[i].toInt()] = i.toLong() INVERSE_TABLE[CHAR_TABLE[i].toInt()] = i.toLong()
} }
/**
* Put -1 ([Ascii85.PAD_BYTE]) for null-bytes
*/
fun encode(i1: Int?, i2: Int?, i3: Int?, i4: Int?): String { fun encode(i1: Int?, i2: Int?, i3: Int?, i4: Int?): String {
var b1=i1 ?: PAD_BYTE; var b2=i2 ?: PAD_BYTE; var b3=i3 ?: PAD_BYTE; var b4=i4 ?: PAD_BYTE var b1=i1 ?: PAD_BYTE; var b2=i2 ?: PAD_BYTE; var b3=i3 ?: PAD_BYTE; var b4=i4 ?: PAD_BYTE
var padLen = 0 var padLen = 0
@@ -73,9 +73,6 @@ object Ascii85 {
"${CHAR_TABLE[sum.toInt()]}").substring(0,5 - padLen) "${CHAR_TABLE[sum.toInt()]}").substring(0,5 - padLen)
} }
/**
* Put '\0' ([Ascii85.PAD_CHAR]) for null-chars
*/
fun decode(x1: Char?, x2: Char?, x3: Char?, x4: Char?, x5: Char?): ByteArray { fun decode(x1: Char?, x2: Char?, x3: Char?, x4: Char?, x5: Char?): ByteArray {
var s1=x1 ?: PAD_CHAR; var s2=x2 ?: PAD_CHAR; var s3=x3 ?: PAD_CHAR; var s4=x4 ?: PAD_CHAR; var s5=x5 ?: PAD_CHAR var s1=x1 ?: PAD_CHAR; var s2=x2 ?: PAD_CHAR; var s3=x3 ?: PAD_CHAR; var s4=x4 ?: PAD_CHAR; var s5=x5 ?: PAD_CHAR
var padLen = 0 var padLen = 0
@@ -106,6 +103,47 @@ object Ascii85 {
INVERSE_TABLE[s5.toInt()] INVERSE_TABLE[s5.toInt()]
return ByteArray(4 - padLen) { sum.ushr((3 - it) * 8).and(255).toByte() } return ByteArray(4 - padLen) { sum.ushr((3 - it) * 8).and(255).toByte() }
} }
fun encodeBytes(bytes: ByteArray): String {
val sb = StringBuilder()
for (k in 0..(bytes.size / 4)) {
sb.append(Ascii85.encode(
bytes.getOrNull(k*4)?.toInt(),
bytes.getOrNull(k*4+1)?.toInt(),
bytes.getOrNull(k*4+2)?.toInt(),
bytes.getOrNull(k*4+3)?.toInt()
))
}
return sb.toString()
}
fun decodeBytes(encoded: String): ByteArray {
val bytes = ByteArray(ceil(encoded.length * 0.8).toInt())
var curs = 0
for (k in 0..(encoded.length / 5)) {
Ascii85.decode(
encoded.getOrNull(k*5),
encoded.getOrNull(k*5+1),
encoded.getOrNull(k*5+2),
encoded.getOrNull(k*5+3),
encoded.getOrNull(k*5+4),
).let {
it.forEachIndexed { i, b ->
bytes[curs + i] = b
}
curs += it.size
}
}
return bytes
}
}
fun UUID.toAscii85() =
Ascii85.encodeBytes(this.mostSignificantBits.toBigEndian() + this.leastSignificantBits.toBigEndian())
fun String.ascii85toUUID(): UUID {
val bytes = Ascii85.decodeBytes(this)
val msb = bytes.toBigInt64(0)
val lsb = bytes.toBigInt64(8)
return UUID(msb, lsb)
} }
/*fun main(args: Array<String>) { /*fun main(args: Array<String>) {

View File

@@ -38,39 +38,67 @@ fun Long.toULittle48() = byteArrayOf(
fun Double.toLittle() = java.lang.Double.doubleToRawLongBits(this).toLittle() fun Double.toLittle() = java.lang.Double.doubleToRawLongBits(this).toLittle()
fun Boolean.toLittle() = byteArrayOf(if (this) 0xFF.toByte() else 0.toByte()) fun Boolean.toLittle() = byteArrayOf(if (this) 0xFF.toByte() else 0.toByte())
fun ByteArray.toLittleInt() = fun ByteArray.toLittleInt32(offset: Int = 0) =
if (this.size != 4) throw Error("Array not in size of 4") this[0 + offset].toUint() or
else this[0].toUint() or this[1 + offset].toUint().shl(8) or
this[1].toUint().shl(8) or this[2 + offset].toUint().shl(16) or
this[2].toUint().shl(16) or this[3 + offset].toUint().shl(24)
this[3].toUint().shl(24) fun ByteArray.toULittleShort(offset: Int = 0) =
fun ByteArray.toULittleShort() = this[0 + offset].toUint() or
if (this.size != 4) throw Error("Array not in size of 2") this[1 + offset].toUint().shl(8)
else this[0].toUint() or fun ByteArray.toLittleShort(offset: Int = 0) =
this[1].toUint().shl(8) this[0 + offset].toUint() or
fun ByteArray.toLittleShort() = this[1 + offset].toInt().shl(8)
if (this.size != 4) throw Error("Array not in size of 2") fun ByteArray.toLittleInt64(offset: Int = 0) =
else this[0].toUint() or this[0 + offset].toUlong() or
this[1].toInt().shl(8) this[1 + offset].toUlong().shl(8) or
fun ByteArray.toLittleLong() = this[2 + offset].toUlong().shl(16) or
if (this.size != 8) throw Error("Array not in size of 8") this[3 + offset].toUlong().shl(24) or
else this[0].toUlong() or this[4 + offset].toUlong().shl(32) or
this[1].toUlong().shl(8) or this[5 + offset].toUlong().shl(40) or
this[2].toUlong().shl(16) or this[6 + offset].toUlong().shl(48) or
this[3].toUlong().shl(24) or this[7 + offset].toUlong().shl(56)
this[4].toUlong().shl(32) or fun ByteArray.toLittleInt48(offset: Int = 0) =
this[5].toUlong().shl(40) or this[0 + offset].toUlong() or
this[6].toUlong().shl(48) or this[1 + offset].toUlong().shl(8) or
this[7].toUlong().shl(56) this[2 + offset].toUlong().shl(16) or
fun ByteArray.toLittleInt48() = this[3 + offset].toUlong().shl(24) or
if (this.size != 6) throw Error("Array not in size of 6") this[4 + offset].toUlong().shl(32) or
else this[0].toUlong() or this[5 + offset].toUlong().shl(40)
this[1].toUlong().shl(8) or fun ByteArray.toLittleFloat() = java.lang.Float.intBitsToFloat(this.toLittleInt32())
this[2].toUlong().shl(16) or
this[3].toUlong().shl(24) or
this[4].toUlong().shl(32) or
this[5].toUlong().shl(40)
fun ByteArray.toLittleFloat() = java.lang.Float.intBitsToFloat(this.toLittleInt())
fun ByteArray.toBigInt16(offset: Int = 0): Int {
return this[0 + offset].toUint().shl(8) or
this[1 + offset].toUint()
}
fun ByteArray.toBigInt24(offset: Int = 0): Int {
return this[0 + offset].toUint().shl(16) or
this[1 + offset].toUint().shl(8) or
this[2 + offset].toUint()
}
fun ByteArray.toBigInt32(offset: Int = 0): Int {
return this[0 + offset].toUint().shl(24) or
this[1 + offset].toUint().shl(16) or
this[2 + offset].toUint().shl(8) or
this[3 + offset].toUint()
}
fun ByteArray.toBigInt48(offset: Int = 0): Long {
return this[0 + offset].toUlong().shl(40) or
this[1 + offset].toUlong().shl(32) or
this[2 + offset].toUlong().shl(24) or
this[3 + offset].toUlong().shl(16) or
this[4 + offset].toUlong().shl(8) or
this[5 + offset].toUlong()
}
fun ByteArray.toBigInt64(offset: Int = 0): Long {
return this[0 + offset].toUlong().shl(56) or
this[1 + offset].toUlong().shl(48) or
this[2 + offset].toUlong().shl(40) or
this[3 + offset].toUlong().shl(32) or
this[4 + offset].toUlong().shl(24) or
this[5 + offset].toUlong().shl(16) or
this[6 + offset].toUlong().shl(8) or
this[7 + offset].toUlong()
}
fun Byte.toUlong() = java.lang.Byte.toUnsignedLong(this) fun Byte.toUlong() = java.lang.Byte.toUnsignedLong(this)
fun Byte.toUint() = java.lang.Byte.toUnsignedInt(this) fun Byte.toUint() = java.lang.Byte.toUnsignedInt(this)

View File

@@ -23,14 +23,10 @@ class UIItemToggleButton(
init { init {
CommonResourcePool.addToLoadingList("ui_item_toggler_base") { CommonResourcePool.addToLoadingList("ui_item_toggler_base") {
val t = TextureRegion(Texture(Gdx.files.internal("./assets/graphics/gui/toggler_back.tga"))) TextureRegion(Texture(Gdx.files.internal("./assets/graphics/gui/toggler_back.tga")))
t.flip(false, false)
t
} }
CommonResourcePool.addToLoadingList("ui_item_toggler_handle") { CommonResourcePool.addToLoadingList("ui_item_toggler_handle") {
val t = TextureRegion(Texture(Gdx.files.internal("./assets/graphics/gui/toggler_switch.tga"))) TextureRegion(Texture(Gdx.files.internal("./assets/graphics/gui/toggler_switch.tga")))
t.flip(false, false)
t
} }
CommonResourcePool.loadAll() CommonResourcePool.loadAll()
} }