mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-10 22:01:52 +09:00
inventory ui: number of cells can be given on creation
This commit is contained in:
@@ -39,10 +39,13 @@ class UIInventoryFull(
|
|||||||
override var width: Int = AppLoader.screenW
|
override var width: Int = AppLoader.screenW
|
||||||
override var height: Int = AppLoader.screenH
|
override var height: Int = AppLoader.screenH
|
||||||
|
|
||||||
|
private val CELLS_HOR = 10
|
||||||
|
private val CELLS_VRT = 8
|
||||||
|
|
||||||
private val itemListToEquipViewGap = UIItemInventoryDynamicList.listGap // used to be 24; figured out that the extra gap does nothig
|
private val itemListToEquipViewGap = UIItemInventoryDynamicList.listGap // used to be 24; figured out that the extra gap does nothig
|
||||||
|
|
||||||
val internalWidth: Int = UIItemInventoryDynamicList.WIDTH + UIItemInventoryEquippedView.WIDTH + itemListToEquipViewGap
|
val internalWidth: Int = UIItemInventoryDynamicList.getEstimatedW(CELLS_HOR) + UIItemInventoryEquippedView.WIDTH + itemListToEquipViewGap
|
||||||
val internalHeight: Int = 166 + UIItemInventoryDynamicList.HEIGHT // grad_begin..grad_end..contents..grad_begin..grad_end
|
val internalHeight: Int = 166 + UIItemInventoryDynamicList.getEstimatedH(CELLS_VRT) // grad_begin..grad_end..contents..grad_begin..grad_end
|
||||||
|
|
||||||
init {
|
init {
|
||||||
handler.allowESCtoClose = true
|
handler.allowESCtoClose = true
|
||||||
@@ -105,12 +108,13 @@ class UIInventoryFull(
|
|||||||
override var openCloseTime: Second = 0.0f
|
override var openCloseTime: Second = 0.0f
|
||||||
|
|
||||||
|
|
||||||
private val itemList: UIItemInventoryDynamicList =
|
internal val itemList: UIItemInventoryDynamicList =
|
||||||
UIItemInventoryDynamicList(
|
UIItemInventoryDynamicList(
|
||||||
this,
|
this,
|
||||||
actor.inventory,
|
actor.inventory,
|
||||||
0 + (AppLoader.screenW - internalWidth) / 2,
|
0 + (AppLoader.screenW - internalWidth) / 2,
|
||||||
107 + (AppLoader.screenH - internalHeight) / 2
|
107 + (AppLoader.screenH - internalHeight) / 2,
|
||||||
|
CELLS_HOR, CELLS_VRT
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@@ -349,7 +353,7 @@ class UIInventoryFull(
|
|||||||
get() = (currentScreen) * AppLoader.screenW
|
get() = (currentScreen) * AppLoader.screenW
|
||||||
|
|
||||||
private val MINIMAP_WIDTH = 800f
|
private val MINIMAP_WIDTH = 800f
|
||||||
private val MINIMAP_HEIGHT = UIItemInventoryDynamicList.HEIGHT.toFloat()
|
private val MINIMAP_HEIGHT = itemList.height.toFloat()
|
||||||
private val MINIMAP_SKYCOL = Color(0x88bbddff.toInt())
|
private val MINIMAP_SKYCOL = Color(0x88bbddff.toInt())
|
||||||
private var minimapZoom = 1f
|
private var minimapZoom = 1f
|
||||||
private var minimapPanX = -MinimapComposer.totalWidth / 2f
|
private var minimapPanX = -MinimapComposer.totalWidth / 2f
|
||||||
|
|||||||
@@ -34,6 +34,8 @@ class UIItemInventoryDynamicList(
|
|||||||
val inventory: ActorInventory, // when you're going to display List of Craftables, you could implement a Delegator...? Or just build a virtual inventory
|
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 horizontalCells: Int,
|
||||||
|
val verticalCells: Int,
|
||||||
val drawScrollOnRightside: Boolean = false,
|
val drawScrollOnRightside: Boolean = false,
|
||||||
val drawWallet: Boolean = true
|
val drawWallet: Boolean = true
|
||||||
) : UIItem(parentUI) {
|
) : UIItem(parentUI) {
|
||||||
@@ -42,9 +44,10 @@ class UIItemInventoryDynamicList(
|
|||||||
override var oldPosX = posX
|
override var oldPosX = posX
|
||||||
override var oldPosY = posY
|
override var oldPosY = posY
|
||||||
|
|
||||||
override val width = WIDTH
|
override val width = horizontalCells * UIItemInventoryElemSimple.height + (horizontalCells - 1) * listGap
|
||||||
override val height = HEIGHT
|
override val height = verticalCells * UIItemInventoryElemSimple.height + (verticalCells - 1) * listGap
|
||||||
|
|
||||||
|
val largeListWidth = (horizontalCells * UIItemInventoryElemSimple.height + (horizontalCells - 2) * listGap) / 2
|
||||||
val backColour = CELLCOLOUR_BLACK
|
val backColour = CELLCOLOUR_BLACK
|
||||||
|
|
||||||
private val catArrangement = parentUI.catArrangement
|
private val catArrangement = parentUI.catArrangement
|
||||||
@@ -98,13 +101,16 @@ class UIItemInventoryDynamicList(
|
|||||||
|
|
||||||
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
|
const val LIST_TO_CONTROL_GAP = 12
|
||||||
val largeListWidth = (horizontalCells * UIItemInventoryElemSimple.height + (horizontalCells - 2) * listGap) / 2
|
|
||||||
|
|
||||||
val WIDTH = horizontalCells * UIItemInventoryElemSimple.height + (horizontalCells - 1) * listGap
|
//val largeListWidth = (horizontalCells * UIItemInventoryElemSimple.height + (horizontalCells - 2) * listGap) / 2
|
||||||
val HEIGHT = verticalCells * UIItemInventoryElemSimple.height + (verticalCells - 1) * listGap
|
//val WIDTH = horizontalCells * UIItemInventoryElemSimple.height + (horizontalCells - 1) * listGap
|
||||||
|
//val HEIGHT = verticalCells * UIItemInventoryElemSimple.height + (verticalCells - 1) * listGap
|
||||||
|
|
||||||
|
fun getEstimatedW(horizontalCells: Int) = horizontalCells * UIItemInventoryElemSimple.height + (horizontalCells - 1) * listGap
|
||||||
|
fun getEstimatedH(verticalCells: Int) = verticalCells * UIItemInventoryElemSimple.height + (verticalCells - 1) * listGap
|
||||||
}
|
}
|
||||||
|
|
||||||
private val itemGrid = Array<UIItemInventoryCellBase>(horizontalCells * verticalCells) {
|
private val itemGrid = Array<UIItemInventoryCellBase>(horizontalCells * verticalCells) {
|
||||||
@@ -123,6 +129,7 @@ class UIItemInventoryDynamicList(
|
|||||||
inactiveTextCol = defaultTextColour
|
inactiveTextCol = defaultTextColour
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
// TODO automatically determine how much columns are needed. Minimum width = 5 grids
|
||||||
private val itemList = Array<UIItemInventoryCellBase>(verticalCells * 2) {
|
private val itemList = Array<UIItemInventoryCellBase>(verticalCells * 2) {
|
||||||
UIItemInventoryElem(
|
UIItemInventoryElem(
|
||||||
parentUI = inventoryUI,
|
parentUI = inventoryUI,
|
||||||
|
|||||||
@@ -24,12 +24,13 @@ class UIItemInventoryEquippedView(
|
|||||||
override var posY: Int
|
override var posY: Int
|
||||||
) : UIItem(parentUI) {
|
) : UIItem(parentUI) {
|
||||||
|
|
||||||
|
|
||||||
override val width = WIDTH
|
override val width = WIDTH
|
||||||
override val height = HEIGHT
|
override val height = parentUI.itemList.height
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
val WIDTH = 2 * UIItemInventoryElemSimple.height + UIItemInventoryDynamicList.listGap
|
val WIDTH = 2 * UIItemInventoryElemSimple.height + UIItemInventoryDynamicList.listGap
|
||||||
val HEIGHT = UIItemInventoryDynamicList.HEIGHT
|
//val HEIGHT = UIItemInventoryDynamicList.HEIGHT
|
||||||
val SPRITE_DRAW_COL = Color(0xddddddff.toInt())
|
val SPRITE_DRAW_COL = Color(0xddddddff.toInt())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user