mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-13 03:54:06 +09:00
inventorydynamiclist to have more options; fixed wrong shade values for trees; commonresourcepool to check dupes
This commit is contained in:
@@ -18,10 +18,10 @@
|
|||||||
"49";"49";"BLOCK_PLANK_EBONY";"0.1252";"0.1252";"0.1252";"0.1252";"19";"1200";"WOOD";"1";"0";"1";"N/A";"0";"0";"16";"0.0000";"0.0000";"0.0000";"0.0000";"N/A";"N/A"
|
"49";"49";"BLOCK_PLANK_EBONY";"0.1252";"0.1252";"0.1252";"0.1252";"19";"1200";"WOOD";"1";"0";"1";"N/A";"0";"0";"16";"0.0000";"0.0000";"0.0000";"0.0000";"N/A";"N/A"
|
||||||
"50";"50";"BLOCK_PLANK_BIRCH";"0.1252";"0.1252";"0.1252";"0.1252";"15";"670";"WOOD";"1";"0";"1";"N/A";"0";"0";"16";"0.0000";"0.0000";"0.0000";"0.0000";"N/A";"N/A"
|
"50";"50";"BLOCK_PLANK_BIRCH";"0.1252";"0.1252";"0.1252";"0.1252";"15";"670";"WOOD";"1";"0";"1";"N/A";"0";"0";"16";"0.0000";"0.0000";"0.0000";"0.0000";"N/A";"N/A"
|
||||||
"51";"51";"BLOCK_PLANK_BLOODROSE";"0.1252";"0.1252";"0.1252";"0.1252";"17";"900";"WOOD";"1";"0";"1";"N/A";"0";"0";"16";"0.0000";"0.0000";"0.0000";"0.0000";"N/A";"N/A"
|
"51";"51";"BLOCK_PLANK_BLOODROSE";"0.1252";"0.1252";"0.1252";"0.1252";"17";"900";"WOOD";"1";"0";"1";"N/A";"0";"0";"16";"0.0000";"0.0000";"0.0000";"0.0000";"N/A";"N/A"
|
||||||
"64";"64";"BLOCK_TRUNK_NORMAL";"0.1252";"0.1252";"0.1252";"0.1252";"16";"740";"WOOD";"0";"0";"0";"N/A";"0";"0";"16";"0.0000";"0.0000";"0.0000";"0.0000";"N/A";"N/A"
|
"64";"64";"BLOCK_TRUNK_NORMAL";"0.0312";"0.0312";"0.0312";"0.0312";"16";"740";"WOOD";"0";"0";"0";"N/A";"0";"0";"16";"0.0000";"0.0000";"0.0000";"0.0000";"N/A";"N/A"
|
||||||
"65";"65";"BLOCK_TRUNK_EBONY";"0.1252";"0.1252";"0.1252";"0.1252";"19";"1200";"WOOD";"0";"0";"0";"N/A";"0";"0";"16";"0.0000";"0.0000";"0.0000";"0.0000";"N/A";"N/A"
|
"65";"65";"BLOCK_TRUNK_EBONY";"0.0312";"0.0312";"0.0312";"0.0312";"19";"1200";"WOOD";"0";"0";"0";"N/A";"0";"0";"16";"0.0000";"0.0000";"0.0000";"0.0000";"N/A";"N/A"
|
||||||
"66";"66";"BLOCK_TRUNK_BIRCH";"0.1252";"0.1252";"0.1252";"0.1252";"15";"670";"WOOD";"0";"0";"0";"N/A";"0";"0";"16";"0.0000";"0.0000";"0.0000";"0.0000";"N/A";"N/A"
|
"66";"66";"BLOCK_TRUNK_BIRCH";"0.0312";"0.0312";"0.0312";"0.0312";"15";"670";"WOOD";"0";"0";"0";"N/A";"0";"0";"16";"0.0000";"0.0000";"0.0000";"0.0000";"N/A";"N/A"
|
||||||
"67";"67";"BLOCK_TRUNK_BLOODROSE";"0.1252";"0.1252";"0.1252";"0.1252";"17";"900";"WOOD";"0";"0";"0";"N/A";"0";"0";"16";"0.0000";"0.0000";"0.0000";"0.0000";"N/A";"N/A"
|
"67";"67";"BLOCK_TRUNK_BLOODROSE";"0.0312";"0.0312";"0.0312";"0.0312";"17";"900";"WOOD";"0";"0";"0";"N/A";"0";"0";"16";"0.0000";"0.0000";"0.0000";"0.0000";"N/A";"N/A"
|
||||||
"80";"80";"BLOCK_SAND";"0.1252";"0.1252";"0.1252";"0.1252";"24";"2400";"SAND";"1";"0";"0";"0";"0";"4";"16";"0.0000";"0.0000";"0.0000";"0.0000";"N/A";"N/A"
|
"80";"80";"BLOCK_SAND";"0.1252";"0.1252";"0.1252";"0.1252";"24";"2400";"SAND";"1";"0";"0";"0";"0";"4";"16";"0.0000";"0.0000";"0.0000";"0.0000";"N/A";"N/A"
|
||||||
"81";"81";"BLOCK_SAND_WHITE";"0.1252";"0.1252";"0.1252";"0.1252";"24";"2400";"SAND";"1";"0";"0";"0";"0";"4";"16";"0.0000";"0.0000";"0.0000";"0.0000";"N/A";"N/A"
|
"81";"81";"BLOCK_SAND_WHITE";"0.1252";"0.1252";"0.1252";"0.1252";"24";"2400";"SAND";"1";"0";"0";"0";"0";"4";"16";"0.0000";"0.0000";"0.0000";"0.0000";"N/A";"N/A"
|
||||||
"82";"82";"BLOCK_SAND_RED";"0.1252";"0.1252";"0.1252";"0.1252";"24";"2400";"SAND";"1";"0";"0";"0";"0";"4";"16";"0.0000";"0.0000";"0.0000";"0.0000";"N/A";"N/A"
|
"82";"82";"BLOCK_SAND_RED";"0.1252";"0.1252";"0.1252";"0.1252";"24";"2400";"SAND";"1";"0";"0";"0";"0";"4";"16";"0.0000";"0.0000";"0.0000";"0.0000";"N/A";"N/A"
|
||||||
@@ -99,9 +99,9 @@
|
|||||||
"257";"257";"BLOCK_SUNSTONE";"0.1252";"0.1252";"0.1252";"0.1252";"1";"N/A";"ROCK";"1";"0";"0";"N/A";"2";"0";"16";"0.0000";"0.0000";"0.0000";"0.0000";"N/A";"N/A"
|
"257";"257";"BLOCK_SUNSTONE";"0.1252";"0.1252";"0.1252";"0.1252";"1";"N/A";"ROCK";"1";"0";"0";"N/A";"2";"0";"16";"0.0000";"0.0000";"0.0000";"0.0000";"N/A";"N/A"
|
||||||
"258";"258";"BLOCK_DAYLIGHT_CAPACITOR";"0.1252";"0.1252";"0.1252";"0.1252";"1";"N/A";"GLAS";"1";"0";"0";"N/A";"3";"0";"16";"0.0000";"0.0000";"0.0000";"0.0000";"N/A";"N/A"
|
"258";"258";"BLOCK_DAYLIGHT_CAPACITOR";"0.1252";"0.1252";"0.1252";"0.1252";"1";"N/A";"GLAS";"1";"0";"0";"N/A";"3";"0";"16";"0.0000";"0.0000";"0.0000";"0.0000";"N/A";"N/A"
|
||||||
"272";"272";"BLOCK_SCAFFOLDING_NORMAL";"0.0312";"0.0312";"0.0312";"0.0312";"1";"N/A";"WOOD";"0";"1";"0";"6";"0";"0";"16";"0.0";"0.0";"0.0";"0.0";"N/A";"N/A"
|
"272";"272";"BLOCK_SCAFFOLDING_NORMAL";"0.0312";"0.0312";"0.0312";"0.0312";"1";"N/A";"WOOD";"0";"1";"0";"6";"0";"0";"16";"0.0";"0.0";"0.0";"0.0";"N/A";"N/A"
|
||||||
"273";"273";"BLOCK_SCAFFOLDING_EBONY";"0.0312";"0.0312";"0.0312";"0.0312";"1";"N/A";"WOOD";"0";"1";"0";"6";"0";"0";"16";"0.0";"0.0";"0.0";"0.0";"N/A";""
|
"273";"273";"BLOCK_SCAFFOLDING_EBONY";"0.0312";"0.0312";"0.0312";"0.0312";"1";"N/A";"WOOD";"0";"1";"0";"6";"0";"0";"16";"0.0";"0.0";"0.0";"0.0";"N/A";"N/A"
|
||||||
"274";"274";"BLOCK_SCAFFOLDING_BIRCH";"0.0312";"0.0312";"0.0312";"0.0312";"1";"N/A";"WOOD";"0";"1";"0";"6";"0";"0";"16";"0.0";"0.0";"0.0";"0.0";"N/A";""
|
"274";"274";"BLOCK_SCAFFOLDING_BIRCH";"0.0312";"0.0312";"0.0312";"0.0312";"1";"N/A";"WOOD";"0";"1";"0";"6";"0";"0";"16";"0.0";"0.0";"0.0";"0.0";"N/A";"N/A"
|
||||||
"275";"275";"BLOCK_SCAFFOLDING_BLOODROSE";"0.0312";"0.0312";"0.0312";"0.0312";"1";"N/A";"WOOD";"0";"1";"0";"6";"0";"0";"16";"0.0";"0.0";"0.0";"0.0";"N/A";""
|
"275";"275";"BLOCK_SCAFFOLDING_BLOODROSE";"0.0312";"0.0312";"0.0312";"0.0312";"1";"N/A";"WOOD";"0";"1";"0";"6";"0";"0";"16";"0.0";"0.0";"0.0";"0.0";"N/A";"N/A"
|
||||||
"4091";"0";"ACTORBLOCK_NO_COLLISION";"0.0312";"0.0312";"0.0312";"0.0312";"1";"1";"NULL";"0";"0";"0";"N/A";"0";"0";"0";"0.0";"0.0";"0.0";"0.0";"N/A";"N/A"
|
"4091";"0";"ACTORBLOCK_NO_COLLISION";"0.0312";"0.0312";"0.0312";"0.0312";"1";"1";"NULL";"0";"0";"0";"N/A";"0";"0";"0";"0.0";"0.0";"0.0";"0.0";"N/A";"N/A"
|
||||||
"4092";"0";"ACTORBLOCK_FULL_COLLISION";"0.0312";"0.0312";"0.0312";"0.0312";"1";"1";"NULL";"0";"0";"0";"N/A";"0";"0";"0";"0.0";"0.0";"0.0";"0.0";"N/A";"N/A"
|
"4092";"0";"ACTORBLOCK_FULL_COLLISION";"0.0312";"0.0312";"0.0312";"0.0312";"1";"1";"NULL";"0";"0";"0";"N/A";"0";"0";"0";"0.0";"0.0";"0.0";"0.0";"N/A";"N/A"
|
||||||
"4093";"0";"ACTORBLOCK_ALLOW_MOVE_DOWN";"0.0312";"0.0312";"0.0312";"0.0312";"1";"1";"NULL";"0";"1";"0";"N/A";"0";"0";"0";"0.0";"0.0";"0.0";"0.0";"N/A";"N/A"
|
"4093";"0";"ACTORBLOCK_ALLOW_MOVE_DOWN";"0.0312";"0.0312";"0.0312";"0.0312";"1";"1";"NULL";"0";"1";"0";"N/A";"0";"0";"0";"0.0";"0.0";"0.0";"0.0";"N/A";"N/A"
|
||||||
@@ -113,6 +113,7 @@
|
|||||||
|
|
||||||
|
|
||||||
## Notes ##
|
## Notes ##
|
||||||
|
# Every block must have a shade value that is at least as dark as the air block's
|
||||||
#
|
#
|
||||||
# Lava/Water props are left for future references, do not delete them until FluidCodex is built #
|
# Lava/Water props are left for future references, do not delete them until FluidCodex is built #
|
||||||
#
|
#
|
||||||
|
|||||||
|
@@ -46,6 +46,17 @@ object CommonResourcePool {
|
|||||||
t.flip(false, true)
|
t.flip(false, true)
|
||||||
/*return*/t
|
/*return*/t
|
||||||
}
|
}
|
||||||
|
loadAll()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun resourceExists(name: String): Boolean {
|
||||||
|
loadingList.forEach {
|
||||||
|
if (it.name == name) return true
|
||||||
|
}
|
||||||
|
pool.forEach {
|
||||||
|
if (it.key == name) return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -67,26 +78,30 @@ object CommonResourcePool {
|
|||||||
* - net.torvald.UnsafePtr
|
* - net.torvald.UnsafePtr
|
||||||
*/
|
*/
|
||||||
fun addToLoadingList(identifier: String, loadFunction: () -> Any, destroyFunction: (() -> Unit)?) {
|
fun addToLoadingList(identifier: String, loadFunction: () -> Any, destroyFunction: (() -> Unit)?) {
|
||||||
loadingList.addFirst(ResourceLoadingDescriptor(identifier, loadFunction, destroyFunction))
|
// check if resource is already there
|
||||||
|
if (!resourceExists(identifier)) {
|
||||||
|
loadingList.addFirst(ResourceLoadingDescriptor(identifier, loadFunction, destroyFunction))
|
||||||
|
|
||||||
if (loadCounter == -1)
|
if (loadCounter == -1)
|
||||||
loadCounter = 1
|
loadCounter = 1
|
||||||
else
|
else
|
||||||
loadCounter += 1
|
loadCounter += 1
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Consumes the loading list. After the load, the list will be empty
|
* Consumes the loading list. After the load, the list will be empty
|
||||||
*/
|
*/
|
||||||
fun loadAll() {
|
fun loadAll() {
|
||||||
if (loaded) throw IllegalStateException("Assets are already loaded and shipped out :p")
|
if (loaded) return //throw IllegalStateException("Assets are already loaded and shipped out :p")
|
||||||
|
|
||||||
while (!loadingList.isEmpty) {
|
while (!loadingList.isEmpty) {
|
||||||
val (name, loadfun, killfun) = loadingList.removeFirst()
|
val (name, loadfun, killfun) = loadingList.removeFirst()
|
||||||
|
|
||||||
if (pool.containsKey(name)) {
|
// no need for the collision checking; quarantine is done when the loading list is being appended
|
||||||
|
/*if (pool.containsKey(name)) {
|
||||||
throw IllegalArgumentException("Assets with identifier '$name' already exists.")
|
throw IllegalArgumentException("Assets with identifier '$name' already exists.")
|
||||||
}
|
}*/
|
||||||
|
|
||||||
//typesMap[name] = type
|
//typesMap[name] = type
|
||||||
pool[name] = loadfun.invoke()
|
pool[name] = loadfun.invoke()
|
||||||
|
|||||||
@@ -4,8 +4,8 @@ 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.*
|
import net.torvald.terrarum.*
|
||||||
import net.torvald.terrarum.gameworld.fmod
|
|
||||||
import net.torvald.terrarum.gameitem.GameItem
|
import net.torvald.terrarum.gameitem.GameItem
|
||||||
|
import net.torvald.terrarum.gameworld.fmod
|
||||||
import net.torvald.terrarum.itemproperties.ItemCodex
|
import net.torvald.terrarum.itemproperties.ItemCodex
|
||||||
import net.torvald.terrarum.modulebasegame.TerrarumIngame
|
import net.torvald.terrarum.modulebasegame.TerrarumIngame
|
||||||
import net.torvald.terrarum.modulebasegame.gameactors.ActorInventory
|
import net.torvald.terrarum.modulebasegame.gameactors.ActorInventory
|
||||||
@@ -31,9 +31,11 @@ import java.util.*
|
|||||||
*/
|
*/
|
||||||
class UIItemInventoryDynamicList(
|
class UIItemInventoryDynamicList(
|
||||||
parentUI: UIInventoryFull,
|
parentUI: UIInventoryFull,
|
||||||
val inventory: ActorInventory,
|
val inventory: ActorInventory, // when you're going to display List of Craftables, you could implement a Delegator...? Or just build a virtual inventory
|
||||||
override var posX: Int,
|
override var posX: Int,
|
||||||
override var posY: Int
|
override var posY: Int,
|
||||||
|
val drawScrollOnRightside: Boolean = false,
|
||||||
|
val drawWallet: Boolean = true
|
||||||
) : UIItem(parentUI) {
|
) : UIItem(parentUI) {
|
||||||
|
|
||||||
// deal with the moving position
|
// deal with the moving position
|
||||||
@@ -47,7 +49,12 @@ class UIItemInventoryDynamicList(
|
|||||||
|
|
||||||
private val catArrangement = parentUI.catArrangement
|
private val catArrangement = parentUI.catArrangement
|
||||||
|
|
||||||
|
init {
|
||||||
|
CommonResourcePool.addToLoadingList("inventory_walletnumberfont") {
|
||||||
|
TextureRegionPack("./assets/graphics/fonts/inventory_wallet_numbers.tga", 20, 9)
|
||||||
|
}
|
||||||
|
CommonResourcePool.loadAll()
|
||||||
|
}
|
||||||
|
|
||||||
val catIconsMeaning = listOf( // sortedBy: catArrangement
|
val catIconsMeaning = listOf( // sortedBy: catArrangement
|
||||||
arrayOf(GameItem.Category.WEAPON),
|
arrayOf(GameItem.Category.WEAPON),
|
||||||
@@ -87,10 +94,13 @@ class UIItemInventoryDynamicList(
|
|||||||
private val walletFont = TextureRegionPack("./assets/graphics/fonts/inventory_wallet_numbers.tga", 20, 9)
|
private val walletFont = TextureRegionPack("./assets/graphics/fonts/inventory_wallet_numbers.tga", 20, 9)
|
||||||
private var walletText = ""
|
private var walletText = ""
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
const val listGap = 8
|
const val listGap = 8
|
||||||
const val horizontalCells = 11
|
const val horizontalCells = 11
|
||||||
const val verticalCells = 8
|
const val verticalCells = 8
|
||||||
|
const val LIST_TO_CONTROL_GAP = 12
|
||||||
val largeListWidth = (horizontalCells * UIItemInventoryElemSimple.height + (horizontalCells - 2) * listGap) / 2
|
val largeListWidth = (horizontalCells * UIItemInventoryElemSimple.height + (horizontalCells - 2) * listGap) / 2
|
||||||
|
|
||||||
val WIDTH = horizontalCells * UIItemInventoryElemSimple.height + (horizontalCells - 1) * listGap
|
val WIDTH = horizontalCells * UIItemInventoryElemSimple.height + (horizontalCells - 1) * listGap
|
||||||
@@ -140,8 +150,11 @@ class UIItemInventoryDynamicList(
|
|||||||
field = value
|
field = value
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private val iconPosX = if (drawScrollOnRightside)
|
||||||
|
posX + width + LIST_TO_CONTROL_GAP
|
||||||
|
else
|
||||||
|
posX - LIST_TO_CONTROL_GAP - parentUI.catIcons.tileW + 2
|
||||||
|
|
||||||
private val iconPosX = posX - 12 - parentUI.catIcons.tileW + 2
|
|
||||||
private fun getIconPosY(index: Int) =
|
private fun getIconPosY(index: Int) =
|
||||||
posY - 2 + (4 + UIItemInventoryElem.height - (parentUI as UIInventoryFull).catIcons.tileH) * index
|
posY - 2 + (4 + UIItemInventoryElem.height - (parentUI as UIInventoryFull).catIcons.tileH) * index
|
||||||
|
|
||||||
@@ -233,9 +246,9 @@ class UIItemInventoryDynamicList(
|
|||||||
scrollDownButton.posX += posXDelta
|
scrollDownButton.posX += posXDelta
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
fun getScrollDotYHeight(i: Int) = scrollUpButton.posY + 10 + upDownButtonGapToDots + 10 * i
|
fun getScrollDotYHeight(i: Int) = scrollUpButton.posY + 10 + upDownButtonGapToDots + 10 * i
|
||||||
|
|
||||||
|
|
||||||
scrollDownButton.posY = getScrollDotYHeight(itemPageCount) + upDownButtonGapToDots
|
scrollDownButton.posY = getScrollDotYHeight(itemPageCount) + upDownButtonGapToDots
|
||||||
|
|
||||||
|
|
||||||
@@ -252,20 +265,22 @@ class UIItemInventoryDynamicList(
|
|||||||
|
|
||||||
batch.color = colour
|
batch.color = colour
|
||||||
batch.draw(
|
batch.draw(
|
||||||
(parentUI as UIInventoryFull).catIcons.get(if (i == itemPage) 20 else 21,0),
|
(parentUI as UIInventoryFull).catIcons.get(if (i == itemPage) 20 else 21, 0),
|
||||||
scrollUpButton.posX.toFloat(),
|
scrollUpButton.posX.toFloat(),
|
||||||
getScrollDotYHeight(i).toFloat()
|
getScrollDotYHeight(i).toFloat()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
// draw wallet text
|
// draw wallet text
|
||||||
batch.color = Color.WHITE
|
if (drawWallet) {
|
||||||
walletText.forEachIndexed { index, it ->
|
batch.color = Color.WHITE
|
||||||
batch.draw(
|
walletText.forEachIndexed { index, it ->
|
||||||
walletFont.get(0, it - '0'),
|
batch.draw(
|
||||||
gridModeButtons[0].posX.toFloat(), // scroll button size: 20px, font width: 20 px
|
walletFont.get(0, it - '0'),
|
||||||
gridModeButtons[0].posY + height - index * walletFont.tileH.toFloat()
|
gridModeButtons[0].posX.toFloat(), // scroll button size: 20px, font width: 20 px
|
||||||
)
|
gridModeButtons[0].posY + height - index * walletFont.tileH.toFloat()
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
super.render(batch, camera)
|
super.render(batch, camera)
|
||||||
@@ -389,10 +404,11 @@ class UIItemInventoryDynamicList(
|
|||||||
override fun dispose() {
|
override fun dispose() {
|
||||||
itemList.forEach { it.dispose() }
|
itemList.forEach { it.dispose() }
|
||||||
itemGrid.forEach { it.dispose() }
|
itemGrid.forEach { it.dispose() }
|
||||||
gridModeButtons.forEach { it.dispose() }
|
// the icons are using common resources that are disposed when the app quits
|
||||||
scrollUpButton.dispose()
|
//gridModeButtons.forEach { it.dispose() }
|
||||||
scrollDownButton.dispose()
|
//scrollUpButton.dispose()
|
||||||
walletFont.dispose()
|
//scrollDownButton.dispose()
|
||||||
|
//walletFont.dispose()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun touchDown(screenX: Int, screenY: Int, pointer: Int, button: Int): Boolean {
|
override fun touchDown(screenX: Int, screenY: Int, pointer: Int, button: Int): Boolean {
|
||||||
|
|||||||
Reference in New Issue
Block a user