mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-07 12:21:52 +09:00
ui theme updates
This commit is contained in:
@@ -465,7 +465,7 @@ class UICrafting(val full: UIInventoryFull) : UICanvas(), HasInventory {
|
||||
|
||||
|
||||
// control hints
|
||||
val controlHintXPos = thisOffsetX.toFloat()
|
||||
val controlHintXPos = thisOffsetX + 2f
|
||||
blendNormalStraightAlpha(batch)
|
||||
App.fontGame.draw(batch, controlHelp, controlHintXPos, full.yEnd - 20)
|
||||
|
||||
@@ -475,7 +475,7 @@ class UICrafting(val full: UIInventoryFull) : UICanvas(), HasInventory {
|
||||
// encumbrance meter
|
||||
val encumbranceText = Lang["GAME_INVENTORY_ENCUMBRANCE"]
|
||||
// encumbrance bar will go one row down if control help message is too long
|
||||
val encumbBarXPos = thisXend - UIInventoryCells.weightBarWidth
|
||||
val encumbBarXPos = thisXend - UIInventoryCells.weightBarWidth + 36
|
||||
val encumbBarTextXPos = encumbBarXPos - 6 - App.fontGame.getWidth(encumbranceText)
|
||||
val encumbBarYPos = full.yEnd-20 + 3f +
|
||||
if (App.fontGame.getWidth(full.listControlHelp) + 2 + controlHintXPos >= encumbBarTextXPos)
|
||||
|
||||
@@ -90,7 +90,7 @@ internal class UIInventoryCells(
|
||||
|
||||
|
||||
// control hints
|
||||
val controlHintXPos = full.offsetX
|
||||
val controlHintXPos = full.offsetX - 34
|
||||
blendNormalStraightAlpha(batch)
|
||||
batch.color = Color.WHITE
|
||||
App.fontGame.draw(batch, full.listControlHelp, controlHintXPos, full.yEnd - 20)
|
||||
|
||||
@@ -48,7 +48,7 @@ open class UIItemInventoryItemGrid(
|
||||
touchDownFun: (GameItem?, Long, Int, Any?, UIItemInventoryCellBase) -> Unit, // Item, Amount, Button, extra info, self
|
||||
protected val useHighlightingManager: Boolean = true, // only used by UIItemCraftingCandidateGrid which addresses buttons directly to set highlighting
|
||||
open protected val highlightEquippedItem: Boolean = true, // for some UIs that only cares about getting equipped slot number but not highlighting
|
||||
colourTheme: InventoryCellColourTheme = defaultInventoryCellTheme
|
||||
private val colourTheme: InventoryCellColourTheme = defaultInventoryCellTheme
|
||||
) : UIItem(parentUI, initialX, initialY) {
|
||||
|
||||
// deal with the moving position
|
||||
@@ -225,10 +225,8 @@ open class UIItemInventoryItemGrid(
|
||||
private val iconPosX = if (drawScrollOnRightside)
|
||||
posX + width + LIST_TO_CONTROL_GAP
|
||||
else
|
||||
posX - LIST_TO_CONTROL_GAP - catBar.catIcons.tileW + 2
|
||||
posX - LIST_TO_CONTROL_GAP - catBar.catIcons.tileW
|
||||
|
||||
private fun getIconPosY(index: Int) =
|
||||
posY - 1 + (4 + UIItemInventoryElemWide.height - catBar.catIcons.tileH) * index
|
||||
|
||||
/** Long/compact mode buttons */
|
||||
val gridModeButtons = Array<UIItemImageButton>(2) { index ->
|
||||
@@ -321,6 +319,9 @@ open class UIItemInventoryItemGrid(
|
||||
|
||||
private val upDownButtonGapToDots = 7 // apparent gap may vary depend on the texture itself
|
||||
|
||||
private fun getIconPosY(index: Int) =
|
||||
posY + 8 + 26 * index
|
||||
|
||||
override fun render(batch: SpriteBatch, camera: Camera) {
|
||||
val posXDelta = posX - oldPosX
|
||||
itemGrid.forEach { it.posX += posXDelta }
|
||||
@@ -332,7 +333,7 @@ open class UIItemInventoryItemGrid(
|
||||
}
|
||||
|
||||
|
||||
fun getScrollDotYHeight(i: Int) = scrollUpButton.posY + 10 + upDownButtonGapToDots + 10 * i
|
||||
fun getScrollDotYHeight(i: Int) = scrollUpButton.posY + 14 + upDownButtonGapToDots + 10 * i
|
||||
|
||||
|
||||
scrollDownButton.posY = getScrollDotYHeight(itemPageCount) + upDownButtonGapToDots
|
||||
@@ -345,6 +346,13 @@ open class UIItemInventoryItemGrid(
|
||||
}
|
||||
|
||||
if (!hideSidebar) {
|
||||
// draw the tray
|
||||
batch.color = Toolkit.Theme.COL_CELL_FILL
|
||||
Toolkit.fillArea(batch, iconPosX - 4, getIconPosY(0) - 8, 28, height)
|
||||
// cell border
|
||||
batch.color = colourTheme.cellHighlightNormalCol
|
||||
Toolkit.drawBoxBorder(batch, iconPosX - 4, getIconPosY(0) - 8, 28, height)
|
||||
|
||||
gridModeButtons.forEach { it.render(batch, camera) }
|
||||
scrollUpButton.render(batch, camera)
|
||||
scrollDownButton.render(batch, camera)
|
||||
@@ -356,7 +364,7 @@ open class UIItemInventoryItemGrid(
|
||||
batch.color = colour
|
||||
batch.draw(
|
||||
catBar.catIcons.get(if (i == itemPage) 20 else 21, 0),
|
||||
scrollUpButton.posX.toFloat(),
|
||||
iconPosX.toFloat(),
|
||||
getScrollDotYHeight(i).toFloat()
|
||||
)
|
||||
}
|
||||
@@ -369,8 +377,8 @@ open class UIItemInventoryItemGrid(
|
||||
walletText.forEachIndexed { index, it ->
|
||||
batch.draw(
|
||||
walletFont.get(0, it - '0'),
|
||||
gridModeButtons[0].posX.toFloat(), // scroll button size: 20px, font width: 20 px
|
||||
gridModeButtons[0].posY + height - index * walletFont.tileH - 1f
|
||||
gridModeButtons[0].posX - 1f, // scroll button size: 20px, font width: 20 px
|
||||
gridModeButtons[0].posY + height - index * walletFont.tileH - 18f
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -532,17 +532,19 @@ class UIItemPlayerCells(
|
||||
|
||||
private val litCol = Toolkit.Theme.COL_MOUSE_UP
|
||||
private val cellCol = CELL_COL
|
||||
private val defaultCol = Toolkit.Theme.COL_LIST_DEFAULT
|
||||
private val defaultCol = Toolkit.Theme.COL_INACTIVE
|
||||
private val hruleCol = Color(1f,1f,1f,0.35f)
|
||||
private val hruleColLit = litCol.cpy().sub(0f,0f,0f,0.65f)
|
||||
|
||||
private val icons = CommonResourcePool.getAsTextureRegionPack("inventory_category")
|
||||
|
||||
private var highlightCol: Color = defaultCol
|
||||
private var highlightTextCol: Color = defaultCol
|
||||
|
||||
override fun update(delta: Float) {
|
||||
super.update(delta)
|
||||
highlightCol = if (mouseUp) litCol else defaultCol
|
||||
highlightTextCol = if (mouseUp) litCol else Toolkit.Theme.COL_LIST_DEFAULT
|
||||
}
|
||||
|
||||
override fun render(batch: SpriteBatch, camera: Camera) {
|
||||
@@ -632,6 +634,7 @@ class UIItemPlayerCells(
|
||||
Toolkit.drawBoxBorder(batch, posX + 115, posY + 33, width - 114, 88)
|
||||
|
||||
// texts
|
||||
batch.color = highlightTextCol
|
||||
val playTimeTextLen = App.fontGame.getWidth(totalPlayTime)
|
||||
App.fontGame.draw(batch, playerName, x + 146f, y + height - 82f)
|
||||
App.fontGame.draw(batch, worldName, x + 146f, y + height - 53f)
|
||||
|
||||
@@ -190,7 +190,7 @@ internal class UIStorageChest : UICanvas(
|
||||
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 encumbBarXPos = itemListPlayer.posX + itemListPlayer.width - UIInventoryCells.weightBarWidth + 36
|
||||
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
|
||||
@@ -224,7 +224,7 @@ internal class UIStorageChest : UICanvas(
|
||||
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)
|
||||
App.fontGame.draw(batch, controlHelp, thisOffsetX - 34f, encumbBarYPos - 3)
|
||||
|
||||
// encumb text
|
||||
batch.color = Color.WHITE
|
||||
|
||||
@@ -53,7 +53,7 @@ class UIWorldPortalListing(val full: UIWorldPortal) : UICanvas() {
|
||||
private val listHeight = UIItemWorldCellsSimple.height + (listCount - 1) * (UIItemWorldCellsSimple.height + gridGap)
|
||||
|
||||
private val memoryGaugeWidth = textAreaW
|
||||
private val deleteButtonWidth = (memoryGaugeWidth - gridGap) / 2
|
||||
private val deleteButtonWidth = (thumbw - gridGap) / 2
|
||||
private val buttonDeleteWorld = UIItemTextButton(this,
|
||||
"MENU_LABEL_DELETE_WORLD",
|
||||
hx - gridGap/2 - deleteButtonWidth,
|
||||
@@ -232,6 +232,7 @@ class UIWorldPortalListing(val full: UIWorldPortal) : UICanvas() {
|
||||
override fun renderUI(batch: SpriteBatch, camera: Camera) {
|
||||
val memoryGaugeXpos = hx - memoryGaugeWidth - gridGap/2
|
||||
val memoryGaugeYpos = y + listHeight - buttonHeight - gridGap - buttonHeight
|
||||
val textXpos = memoryGaugeXpos + 3
|
||||
|
||||
// draw background //
|
||||
// screencap panel
|
||||
@@ -241,15 +242,22 @@ class UIWorldPortalListing(val full: UIWorldPortal) : UICanvas() {
|
||||
|
||||
// draw border //
|
||||
// screencap panel
|
||||
batch.color = Toolkit.Theme.COL_LIST_DEFAULT
|
||||
batch.color = if (selected?.worldInfo == null) Toolkit.Theme.COL_INVENTORY_CELL_BORDER else Toolkit.Theme.COL_INACTIVE
|
||||
Toolkit.drawBoxBorder(batch, hx - thumbw - gridGap/2 - 1, y - 1, thumbw + 2, thumbh + 2)
|
||||
|
||||
|
||||
// memory gauge
|
||||
val barCol = UIItemInventoryCellCommonRes.getHealthMeterColour(chunksMax - chunksUsed, 0, chunksMax)
|
||||
val barBack = barCol mul UIItemInventoryCellCommonRes.meterBackDarkening
|
||||
|
||||
batch.color = Toolkit.Theme.COL_CELL_FILL
|
||||
Toolkit.fillArea(batch, (memoryGaugeXpos - iconSizeGap + 10).toInt(), memoryGaugeYpos, buttonHeight + 6, buttonHeight)
|
||||
batch.color = Toolkit.Theme.COL_INACTIVE
|
||||
Toolkit.drawBoxBorder(batch, (memoryGaugeXpos - iconSizeGap + 10).toInt() - 1, memoryGaugeYpos - 1, buttonHeight + 7, buttonHeight + 2)
|
||||
batch.color = Color.WHITE
|
||||
batch.draw(icons.get(2, 2), memoryGaugeXpos - iconSizeGap, memoryGaugeYpos + 2f)
|
||||
batch.draw(icons.get(2, 2), textXpos - iconSizeGap, memoryGaugeYpos + 2f)
|
||||
|
||||
batch.color = Toolkit.Theme.COL_INACTIVE
|
||||
Toolkit.drawBoxBorder(batch, memoryGaugeXpos - 1, memoryGaugeYpos - 1, memoryGaugeWidth + 2, buttonHeight + 2)
|
||||
batch.color = barBack
|
||||
Toolkit.fillArea(batch, memoryGaugeXpos, memoryGaugeYpos, memoryGaugeWidth, buttonHeight)
|
||||
@@ -260,8 +268,8 @@ class UIWorldPortalListing(val full: UIWorldPortal) : UICanvas() {
|
||||
if (selected?.worldInfo != null) {
|
||||
// some texts
|
||||
worldTexts.forEachIndexed { index, (icon, str) ->
|
||||
batch.draw(icon, memoryGaugeXpos - iconSizeGap, y + thumbh + 16f + textualListHeight * index)
|
||||
App.fontGame.draw(batch, str, memoryGaugeXpos.toFloat(), y + thumbh + 16f + textualListHeight * index)
|
||||
batch.draw(icon, textXpos - iconSizeGap, y + thumbh + 16f + textualListHeight * index)
|
||||
App.fontGame.draw(batch, str, textXpos.toFloat(), y + thumbh + 16f + textualListHeight * index)
|
||||
}
|
||||
// size indicator on the memory gauge
|
||||
Toolkit.fillArea(batch, memoryGaugeXpos, memoryGaugeYpos, (memoryGaugeWidth * (selected?.worldInfo!!.dimensionInChunks / chunksMax.toFloat())).ceilInt(), buttonHeight)
|
||||
@@ -280,7 +288,7 @@ class UIWorldPortalListing(val full: UIWorldPortal) : UICanvas() {
|
||||
|
||||
// control hints
|
||||
batch.color = Color.WHITE
|
||||
App.fontGame.draw(batch, full.portalListingControlHelp, (hx - textAreaW - gridGap/2).toInt(), (full.yEnd - 20).toInt())
|
||||
App.fontGame.draw(batch, full.portalListingControlHelp, hx - thumbw - gridGap/2 + 2, (full.yEnd - 20).toInt())
|
||||
}
|
||||
|
||||
override fun hide() {
|
||||
@@ -359,12 +367,18 @@ class UIItemWorldCellsSimple(
|
||||
batch.color = UIInventoryFull.CELL_COL
|
||||
Toolkit.fillArea(batch, posX, posY, width, height)
|
||||
|
||||
// draw border
|
||||
val mouseUp = mouseUp && worldInfo != null
|
||||
|
||||
val bcol = if (highlighted || mouseUp && mousePushed) Toolkit.Theme.COL_SELECTED
|
||||
else if (mouseUp) Toolkit.Theme.COL_MOUSE_UP else Toolkit.Theme.COL_LIST_DEFAULT
|
||||
else if (mouseUp) Toolkit.Theme.COL_MOUSE_UP else (if (worldInfo == null) Toolkit.Theme.COL_INVENTORY_CELL_BORDER else Toolkit.Theme.COL_INACTIVE)
|
||||
val tcol = if (highlighted || mouseUp && mousePushed) Toolkit.Theme.COL_SELECTED
|
||||
else if (mouseUp) Toolkit.Theme.COL_MOUSE_UP else (if (worldInfo == null) Toolkit.Theme.COL_INACTIVE else Toolkit.Theme.COL_LIST_DEFAULT)
|
||||
|
||||
// draw border
|
||||
batch.color = bcol
|
||||
Toolkit.drawBoxBorder(batch, posX - 1, posY - 1, width + 2, height + 2)
|
||||
// draw texts
|
||||
batch.color = tcol
|
||||
batch.draw(icons.get(0, 1), posX + 4f, posY + 1f)
|
||||
App.fontGame.draw(batch, worldName ?: "$EMDASH", posX + 32, posY + 1)
|
||||
batch.draw(icons.get(1, 1), posX + 4f, posY + 25f)
|
||||
|
||||
Reference in New Issue
Block a user