mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-07 12:21:52 +09:00
tech tree view wip
This commit is contained in:
@@ -86,7 +86,7 @@ internal object SavegameMigrator {
|
||||
if (worldVersion == playerVersion) {
|
||||
this::class.declaredFunctions.filter {
|
||||
annotationMatches(worldVersion, it.findAnnotation())
|
||||
}.forEach { func ->
|
||||
}.sortedBy { it.name }.forEach { func ->
|
||||
printdbg(this, func.toString())
|
||||
actors0.forEach { actor -> func.call(this, actor) }
|
||||
}
|
||||
@@ -122,7 +122,7 @@ internal object SavegameMigrator {
|
||||
|
||||
|
||||
@AppliedVersion("all")
|
||||
fun mergeUnlitBlocks(actor: Actor) {
|
||||
fun b_mergeUnlitBlocksAndFillInInventory(actor: Actor) {
|
||||
if (ItemCodex.isEmpty()) throw Error("ItemCodex is empty")
|
||||
|
||||
if (actor is Pocketed) {
|
||||
@@ -164,7 +164,7 @@ internal object SavegameMigrator {
|
||||
|
||||
|
||||
@AppliedVersion("0.4.0")
|
||||
fun updatePlayerEncumbrance(actor: Actor) {
|
||||
fun a_updatePlayerEncumbrance(actor: Actor) {
|
||||
if (actor is IngamePlayer && actor.actorValue.getAsInt("encumbrance") == 1000) {
|
||||
actor.actorValue.set("encumbrance", 50000)
|
||||
}
|
||||
|
||||
@@ -130,6 +130,12 @@ open class FixtureInventory() {
|
||||
updateEncumbrance()
|
||||
}
|
||||
|
||||
open fun removeEntryForced(itemID: ItemID) {
|
||||
searchByID(itemID)?.let {
|
||||
itemList.remove(it)
|
||||
}
|
||||
}
|
||||
|
||||
open fun remove(itemID: ItemID, count: Long) = remove(ItemCodex[itemID]!!, count) {}
|
||||
open fun remove(item: GameItem, count: Long = 1L) = remove(item, count) {}
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@ import net.torvald.terrarum.modulebasegame.ui.UITemplateHalfInventory.Companion.
|
||||
import net.torvald.terrarum.ui.*
|
||||
import net.torvald.terrarum.ui.UIItemCatBar.Companion.FILTER_CAT_ALL
|
||||
import net.torvald.unicode.getKeycapPC
|
||||
import kotlin.math.roundToInt
|
||||
|
||||
/**
|
||||
* This UI has inventory, but it's just there to display all craftable items and should not be serialised.
|
||||
@@ -122,7 +123,7 @@ class UICraftingWorkbench(val inventoryUI: UIInventoryFull?, val parentContainer
|
||||
private val thisOffsetY = UIInventoryFull.INVENTORY_CELLS_OFFSET_Y()
|
||||
private val cellsWidth = (listGap + UIItemInventoryElemWide.height) * 6 - listGap
|
||||
|
||||
private val LAST_LINE_IN_GRID = ((UIItemInventoryElemWide.height + listGap) * (UIInventoryFull.CELLS_VRT - 2)) + 22//359 // TEMPORARY VALUE!
|
||||
internal val LAST_LINE_IN_GRID = ((UIItemInventoryElemWide.height + listGap) * (UIInventoryFull.CELLS_VRT - 2)) + 22//359 // TEMPORARY VALUE!
|
||||
|
||||
private var recipeClicked: CraftingCodex.CraftingRecipe? = null
|
||||
|
||||
@@ -321,10 +322,14 @@ class UICraftingWorkbench(val inventoryUI: UIInventoryFull?, val parentContainer
|
||||
handler.allowESCtoClose = true
|
||||
|
||||
|
||||
val navbarHeight = 82 // a magic number
|
||||
val fakeNavbarY = itemListIngredients.posY
|
||||
fun getIconPosY2(index: Int) = (fakeNavbarY + ((index*2+1)/4f) * navbarHeight).roundToInt() - catIcons.tileH/2
|
||||
|
||||
val menuButtonTechView = UIItemImageButton(
|
||||
this, catIcons.get(20, 1),
|
||||
initialX = itemListCraftable.navRemoCon.posX + 12,
|
||||
initialY = itemListCraftable.navRemoCon.getIconPosY(-2) - 8,
|
||||
initialY = getIconPosY2(0),
|
||||
highlightable = true
|
||||
).also {
|
||||
it.clickOnceListener = { _, _ ->
|
||||
@@ -336,7 +341,7 @@ class UICraftingWorkbench(val inventoryUI: UIInventoryFull?, val parentContainer
|
||||
val menuButtonCraft = UIItemImageButton(
|
||||
this, catIcons.get(19, 1),
|
||||
initialX = itemListCraftable.navRemoCon.posX + 12,
|
||||
initialY = itemListCraftable.navRemoCon.getIconPosY(-1) - 8,
|
||||
initialY = getIconPosY2(1),
|
||||
activeCol = Toolkit.Theme.COL_SELECTED,
|
||||
inactiveCol = Toolkit.Theme.COL_SELECTED,
|
||||
highlightable = true
|
||||
|
||||
@@ -10,6 +10,7 @@ import net.torvald.terrarum.ui.UICanvas
|
||||
import net.torvald.terrarum.ui.UIItemImageButton
|
||||
import net.torvald.terrarum.ui.UIItemInventoryElemSimple
|
||||
import net.torvald.unicode.getKeycapPC
|
||||
import kotlin.math.roundToInt
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 2024-02-18.
|
||||
@@ -32,24 +33,25 @@ class UITechView(val inventoryUI: UIInventoryFull?, val parentContainer: UICraft
|
||||
private val posX1 = posX0 - UIItemListNavBarVertical.LIST_TO_CONTROL_GAP - UIItemListNavBarVertical.WIDTH - 4
|
||||
private val posY1 = posY0
|
||||
|
||||
// private val navbarX = posX1 + UIItemListNavBarVertical.LIST_TO_CONTROL_GAP
|
||||
// private val navbarY = posY1
|
||||
private val navbarX = parentContainer.transitionalCraftingUI.itemListCraftable.navRemoCon.posX + 12
|
||||
private val navbarY = parentContainer.transitionalCraftingUI.itemListCraftable.navRemoCon.posY - 8
|
||||
private val navbarWidth = UIItemListNavBarVertical.WIDTH
|
||||
private val navbarHeight = parentContainer.transitionalCraftingUI.itemListCraftable.height
|
||||
|
||||
private val panelX = 32 + navbarX
|
||||
private val panelY = navbarY
|
||||
private val panelX = 32 + parentContainer.transitionalCraftingUI.itemListCraftable.navRemoCon.posX + 12
|
||||
private val panelY = parentContainer.transitionalCraftingUI.itemListCraftable.navRemoCon.posY - 8
|
||||
private val panelWidth = 720
|
||||
private val panelHeight = navbarHeight
|
||||
private val panelHeight = parentContainer.transitionalCraftingUI.itemListCraftable.height +
|
||||
parentContainer.transitionalCraftingUI.itemListIngredients.height + 64 // 64 is a magic number
|
||||
|
||||
private val navbarWidth = UIItemListNavBarVertical.WIDTH
|
||||
private val navbarHeight = 82 // a magic number
|
||||
private val navbarX = panelX - 32 // also a magic number
|
||||
private val navbarY = panelY + panelHeight - navbarHeight
|
||||
|
||||
private val fakeNavbarY = parentContainer.transitionalCraftingUI.itemListIngredients.posY
|
||||
|
||||
private val catIcons = CommonResourcePool.getAsTextureRegionPack("inventory_category")
|
||||
|
||||
private val menuButtonTechView = UIItemImageButton(
|
||||
this, catIcons.get(20, 1),
|
||||
initialX = navbarX,
|
||||
initialY = getIconPosY(-2),
|
||||
initialY = getIconPosY(0),
|
||||
activeCol = Toolkit.Theme.COL_SELECTED,
|
||||
inactiveCol = Toolkit.Theme.COL_SELECTED,
|
||||
highlightable = false
|
||||
@@ -57,7 +59,7 @@ class UITechView(val inventoryUI: UIInventoryFull?, val parentContainer: UICraft
|
||||
private val menuButtonCraft = UIItemImageButton(
|
||||
this, catIcons.get(19, 1),
|
||||
initialX = navbarX,
|
||||
initialY = getIconPosY(-1),
|
||||
initialY = getIconPosY(1),
|
||||
highlightable = true
|
||||
).also {
|
||||
it.clickOnceListener = { _, _ ->
|
||||
@@ -66,11 +68,7 @@ class UITechView(val inventoryUI: UIInventoryFull?, val parentContainer: UICraft
|
||||
}
|
||||
}
|
||||
|
||||
fun getIconPosY(index: Int) =
|
||||
if (index >= 0)
|
||||
posY1 + 26 * index
|
||||
else
|
||||
(posY1 + navbarHeight) + (26 * index)
|
||||
fun getIconPosY(index: Int) = (fakeNavbarY + ((index*2+1)/4f) * navbarHeight).roundToInt() - catIcons.tileH/2
|
||||
|
||||
init {
|
||||
addUIitem(menuButtonCraft)
|
||||
@@ -78,6 +76,8 @@ class UITechView(val inventoryUI: UIInventoryFull?, val parentContainer: UICraft
|
||||
}
|
||||
private val thisOffsetX = UIInventoryFull.INVENTORY_CELLS_OFFSET_X() + UIItemInventoryElemSimple.height + UIItemInventoryItemGrid.listGap - halfSlotOffset
|
||||
|
||||
private val cellHighlightNormalCol2 = colourTheme.cellHighlightNormalCol.cpy().also { it.a /= 2f }
|
||||
|
||||
override fun renderImpl(frameDelta: Float, batch: SpriteBatch, camera: OrthographicCamera) {
|
||||
// draw fake navbar //
|
||||
// draw the tray
|
||||
@@ -86,6 +86,10 @@ class UITechView(val inventoryUI: UIInventoryFull?, val parentContainer: UICraft
|
||||
// cell border
|
||||
batch.color = colourTheme.cellHighlightNormalCol
|
||||
Toolkit.drawBoxBorder(batch, navbarX - 4, navbarY, navbarWidth, navbarHeight)
|
||||
// cell divider
|
||||
batch.color = cellHighlightNormalCol2
|
||||
Toolkit.drawStraightLine(batch, navbarX - 3, navbarY + navbarHeight/2, navbarX-3 + navbarWidth-2, 1, false)
|
||||
|
||||
|
||||
|
||||
// draw window //
|
||||
|
||||
Reference in New Issue
Block a user