crafting guide wip and stash for next version

This commit is contained in:
minjaesong
2024-02-19 01:44:31 +09:00
parent 0911e70a69
commit 1cbf0f4582
13 changed files with 252 additions and 72 deletions

View File

@@ -100,7 +100,6 @@ class UIBuildingMakerBlockChooser(val parent: BuildingMaker): UICanvas() {
height = TILESREGION_SIZE,
highlightCol = Color.WHITE,
activeCol = Color.WHITE,
backgroundCol = Color(0)
)
val paletteItem2 = UIItemImageButton(
this, ItemCodex.getItemImage(prop.id)!!,
@@ -112,7 +111,6 @@ class UIBuildingMakerBlockChooser(val parent: BuildingMaker): UICanvas() {
highlightCol = Color.WHITE,
activeCol = WALL_OVERLAY_COLOUR,
inactiveCol = WALL_OVERLAY_COLOUR,
backgroundCol = Color(0)
)
paletteItem.clickOnceListener = { _, _ -> parent.setPencilColour(prop.id) }

View File

@@ -58,9 +58,6 @@ class UIBuildingMakerPenMenu(val parent: BuildingMaker): UICanvas() {
UIItemImageButton(
this, toolIcons.get(it, 0),
backgroundCol = Color(0),
highlightBackCol = Color(0),
activeBackCol = Color(0),
initialX = newvec.x.roundToInt(),
initialY = newvec.y.roundToInt(),
width = ICON_SIZE, height = ICON_SIZE,

View File

@@ -91,8 +91,11 @@ class UICrafting(val full: UIInventoryFull?) : UICanvas(
}}
}
private val itemListCraftable: UIItemCraftingCandidateGrid // might be changed to something else
private val itemListIngredients: UIItemInventoryItemGrid // this one is definitely not to be changed
private val catIcons = CommonResourcePool.getAsTextureRegionPack("inventory_category")
internal val itemListCraftable: UIItemCraftingCandidateGrid // might be changed to something else
internal val itemListIngredients: UIItemInventoryItemGrid // this one is definitely not to be changed
private val buttonCraft: UIItemTextButton
private val spinnerCraftCount: UIItemSpinner
@@ -311,11 +314,40 @@ class UICrafting(val full: UIInventoryFull?) : UICanvas(
handler.allowESCtoClose = true
val menuButtonTechView = UIItemImageButton(
this, catIcons.get(20, 1),
initialX = itemListCraftable.navRemoCon.posX + 12,
initialY = itemListCraftable.navRemoCon.getIconPosY(-2) - 8,
highlightable = true
).also {
it.clickOnceListener = { _, _ ->
full?.transitionPanel?.setLeftUIto(1)
full?.transitionPanel?.uis?.get(0)?.show()
it.highlighted = false
}
}
val menuButtonCraft = UIItemImageButton(
this, catIcons.get(19, 1),
initialX = itemListCraftable.navRemoCon.posX + 12,
initialY = itemListCraftable.navRemoCon.getIconPosY(-1) - 8,
activeCol = Toolkit.Theme.COL_SELECTED,
inactiveCol = Toolkit.Theme.COL_SELECTED,
highlightable = true
)
addUIitem(itemListCraftable)
addUIitem(itemListIngredients)
addUIitem(playerThings)
addUIitem(spinnerCraftCount)
addUIitem(buttonCraft)
// temporarily disabled for 0.4 release
if (TerrarumAppConfiguration.VERSION_RAW >= 0x0000_000005_000000) {
addUIitem(menuButtonCraft)
addUIitem(menuButtonTechView)
}
}
private fun filterPlayerListUsing(recipe: CraftingCodex.CraftingRecipe?) {

View File

@@ -246,17 +246,18 @@ class UIInventoryFull(
// private val transitionalMinimap = UIInventoryMinimap(this)
private val transitionalCraftingUI = UICrafting(this)
private val transitionalItemCells = UIInventoryCells(this)
private val transitionalEscMenu = UIInventoryEscMenu(this)
private val transitionPanel = UIItemHorizontalFadeSlide(
internal val transitionalCraftingUI = UICrafting(this)
internal val transitionalTechTreeViewUI = UITechView(this)
internal val transitionalItemCells = UIInventoryCells(this)
internal val transitionalEscMenu = UIInventoryEscMenu(this)
val transitionPanel = UIItemHorizontalFadeSlide(
this,
(width - internalWidth) / 2,
INVENTORY_CELLS_OFFSET_Y(),
width,
App.scr.height,
1f,
listOf(transitionalCraftingUI),
listOf(transitionalCraftingUI, transitionalTechTreeViewUI),
listOf(transitionalItemCells),
listOf(transitionalEscMenu)
)
@@ -319,6 +320,7 @@ class UIInventoryFull(
transitionPanel.forcePosition(0)
catBar.setSelectedPanel(0)
transitionalCraftingUI.resetUI()
transitionalTechTreeViewUI.resetUI()
it.setAsOpen()
}
@@ -387,7 +389,7 @@ class UIInventoryFull(
override fun doOpening(delta: Float) {
super.doOpening(delta)
transitionPanel.uis.forEach { it.opacity = FastMath.pow(opacity, 0.5f) }
transitionPanel.allUIs.forEach { it.opacity = FastMath.pow(opacity, 0.5f) }
INGAME.pause()
INGAME.setTooltipMessage(null)
@@ -399,7 +401,7 @@ class UIInventoryFull(
override fun doClosing(delta: Float) {
super.doClosing(delta)
transitionPanel.uis.forEach { it.opacity = FastMath.pow(opacity, 0.5f) }
transitionPanel.allUIs.forEach { it.opacity = FastMath.pow(opacity, 0.5f) }
INGAME.resume()
INGAME.setTooltipMessage(null)
@@ -415,14 +417,14 @@ class UIInventoryFull(
override fun endOpening(delta: Float) {
super.endOpening(delta)
transitionPanel.uis.forEach { it.opacity = FastMath.pow(opacity, 0.5f) }
transitionPanel.allUIs.forEach { it.opacity = 1f }
shouldIFadeIn = null
}
override fun endClosing(delta: Float) {
super.endClosing(delta)
transitionPanel.uis.forEach { it.opacity = FastMath.pow(opacity, 0.5f) }
transitionPanel.allUIs.forEach { it.opacity = 0f }
INGAME.setTooltipMessage(null) // required!
// MinimapComposer.revalidateAll()

View File

@@ -34,8 +34,12 @@ class UIItemListNavBarVertical(
const val LIST_TO_CONTROL_GAP = 12
}
private fun getIconPosY(index: Int) =
posY + 26 * index
fun getIconPosY(index: Int) =
if (index >= 0)
posY + 26 * index
else
(posY + height) + (26 * index)
private val catIcons = CommonResourcePool.getAsTextureRegionPack("inventory_category")
private val iconPosX = posX + LIST_TO_CONTROL_GAP
@@ -43,11 +47,6 @@ class UIItemListNavBarVertical(
UIItemImageButton(
parentUI,
catIcons.get(index + 14, 0),
backgroundCol = Color(0),
activeBackCol = Color(0),
highlightBackCol = Color(0),
activeBackBlendMode = BlendMode.NORMAL,
activeCol = Toolkit.Theme.COL_MOUSE_UP,
initialX = iconPosX,
initialY = getIconPosY(index),
highlightable = true
@@ -57,10 +56,6 @@ class UIItemListNavBarVertical(
val scrollUpButton = UIItemImageButton(
parentUI,
catIcons.get(18, 0),
backgroundCol = Color(0),
activeBackCol = Color(0),
activeBackBlendMode = BlendMode.NORMAL,
activeCol = Toolkit.Theme.COL_MOUSE_UP,
initialX = iconPosX,
initialY = getIconPosY(2 - (!hasGridModeButtons).toInt(1)),
highlightable = false
@@ -69,10 +64,6 @@ class UIItemListNavBarVertical(
val scrollDownButton = UIItemImageButton(
parentUI,
catIcons.get(19, 0),
backgroundCol = Color(0),
activeBackCol = Color(0),
activeBackBlendMode = BlendMode.NORMAL,
activeCol = Toolkit.Theme.COL_MOUSE_UP,
initialX = iconPosX,
initialY = getIconPosY(3 - (!hasGridModeButtons).toInt(1)),
highlightable = false

View File

@@ -401,37 +401,37 @@ class UIItemControlPaletteBaloon(val parent: UIKeyboardControlPanel, initialX: I
// TEXT IS MANUALLY PRINTED ON render() !!
private val iconButtons = arrayOf(
// left up right down
UIItemImageButton(parent, Keebsym.LEFT, initialX = col0 - 34, initialY = initialY + 43, highlightable = false, backgroundCol = Color(0), activeBackCol = Color(0), highlightBackCol = Color(0)),
UIItemImageButton(parent, Keebsym.UP, initialX = col0, initialY = initialY + 26, highlightable = false, backgroundCol = Color(0), activeBackCol = Color(0), highlightBackCol = Color(0)),
UIItemImageButton(parent, Keebsym.DOWN, initialX = col0, initialY = initialY + 60, highlightable = false, backgroundCol = Color(0), activeBackCol = Color(0), highlightBackCol = Color(0)),
UIItemImageButton(parent, Keebsym.RIGHT, initialX = col0 + 34, initialY = initialY + 43, highlightable = false, backgroundCol = Color(0), activeBackCol = Color(0), highlightBackCol = Color(0)),
UIItemImageButton(parent, Keebsym.LEFT, initialX = col0 - 34, initialY = initialY + 43, highlightable = false),
UIItemImageButton(parent, Keebsym.UP, initialX = col0, initialY = initialY + 26, highlightable = false),
UIItemImageButton(parent, Keebsym.DOWN, initialX = col0, initialY = initialY + 60, highlightable = false),
UIItemImageButton(parent, Keebsym.RIGHT, initialX = col0 + 34, initialY = initialY + 43, highlightable = false),
// jump
UIItemImageButton(parent, Keebsym.JUMP, initialX = col1, initialY = initialY + 43, highlightable = false, backgroundCol = Color(0), activeBackCol = Color(0), highlightBackCol = Color(0)),
UIItemImageButton(parent, Keebsym.JUMP, initialX = col1, initialY = initialY + 43, highlightable = false),
// inventory
UIItemImageButton(parent, Keebsym.INVENTORY, initialX = col0, initialY = row1, highlightable = false, backgroundCol = Color(0), activeBackCol = Color(0), highlightBackCol = Color(0)),
UIItemImageButton(parent, Keebsym.INVENTORY, initialX = col0, initialY = row1, highlightable = false),
// crafting
UIItemImageButton(parent, Keebsym.CRAFTING, initialX = col0, initialY = row2, highlightable = false, backgroundCol = Color(0), activeBackCol = Color(0), highlightBackCol = Color(0)),
UIItemImageButton(parent, Keebsym.CRAFTING, initialX = col0, initialY = row2, highlightable = false),
// hook
UIItemImageButton(parent, Keebsym.HOOK, initialX = col0, initialY = row3, highlightable = false, backgroundCol = Color(0), activeBackCol = Color(0), highlightBackCol = Color(0)),
UIItemImageButton(parent, Keebsym.HOOK, initialX = col0, initialY = row3, highlightable = false),
// quicksel
UIItemImageButton(parent, Keebsym.PIE, initialX = col0, initialY = row4, highlightable = false, backgroundCol = Color(0), activeBackCol = Color(0), highlightBackCol = Color(0)),
UIItemImageButton(parent, Keebsym.PIE, initialX = col0, initialY = row4, highlightable = false),
// zoom
UIItemImageButton(parent, Keebsym.ZOOM, initialX = col1, initialY = row1, highlightable = false, backgroundCol = Color(0), activeBackCol = Color(0), highlightBackCol = Color(0)),
UIItemImageButton(parent, Keebsym.ZOOM, initialX = col1, initialY = row1, highlightable = false),
// IME
UIItemImageButton(parent, Keebsym.IME(), initialX = col1, initialY = row2, highlightable = false, backgroundCol = Color(0), activeBackCol = Color(0), highlightBackCol = Color(0)),
UIItemImageButton(parent, Keebsym.IME(), initialX = col1, initialY = row2, highlightable = false),
// system menu
UIItemImageButton(parent, Keebsym.MENU, initialX = col1, initialY = row3, highlightable = false, backgroundCol = Color(0), activeBackCol = Color(0), highlightBackCol = Color(0)),
UIItemImageButton(parent, Keebsym.MENU, initialX = col1, initialY = row3, highlightable = false),
// toss item
UIItemImageButton(parent, Keebsym.DISCARD, initialX = col1, initialY = row4, highlightable = false, backgroundCol = Color(0), activeBackCol = Color(0), highlightBackCol = Color(0)),
UIItemImageButton(parent, Keebsym.DISCARD, initialX = col1, initialY = row4, highlightable = false),
)
// close button is just for the cosmetics; the uiitem closes when you click anywhere on the UI
private val closeButton2 = UIItemImageButton(parent, Keebsym.CLOSE, initialX = initialX + width - 20, initialY = initialY, highlightable = false, backgroundCol = Color(0), activeBackCol = Color(0), highlightBackCol = Color(0))
private val closeButton1 = UIItemImageButton(parent, Keebsym.CLOSE, initialX = initialX + 1, initialY = initialY, highlightable = false, backgroundCol = Color(0), activeBackCol = Color(0), highlightBackCol = Color(0))
private val closeButton2 = UIItemImageButton(parent, Keebsym.CLOSE, initialX = initialX + width - 20, initialY = initialY, highlightable = false)
private val closeButton1 = UIItemImageButton(parent, Keebsym.CLOSE, initialX = initialX + 1, initialY = initialY, highlightable = false)
// indices must correspond with what's on the UIItemControlPaletteBaloon.iconButtons
companion object {

View File

@@ -0,0 +1,144 @@
package net.torvald.terrarum.modulebasegame.ui
import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.graphics.OrthographicCamera
import com.badlogic.gdx.graphics.g2d.SpriteBatch
import net.torvald.terrarum.*
import net.torvald.terrarum.langpack.Lang
import net.torvald.terrarum.ui.Toolkit
import net.torvald.terrarum.ui.UICanvas
import net.torvald.terrarum.ui.UIItemImageButton
import net.torvald.terrarum.ui.UIItemInventoryElemSimple
import net.torvald.unicode.getKeycapPC
/**
* Created by minjaesong on 2024-02-18.
*/
class UITechView(val full: UIInventoryFull?, private val colourTheme: InventoryCellColourTheme = UIItemInventoryCellCommonRes.defaultInventoryCellTheme,
) : UICanvas(
toggleKeyLiteral = if (full == null) "control_key_inventory" else null,
toggleButtonLiteral = if (full == null) "control_gamepad_start" else null
) {
override var width = Toolkit.drawWidth
override var height = App.scr.height
private val verticalCells = UIInventoryFull.CELLS_VRT
private val halfSlotOffset = (UIItemInventoryElemSimple.height + UIItemInventoryItemGrid.listGap) / 2
private val posX0 = UIInventoryFull.INVENTORY_CELLS_OFFSET_X() + UIItemInventoryElemSimple.height + UIItemInventoryItemGrid.listGap - halfSlotOffset
private val posY0 = UIInventoryFull.INVENTORY_CELLS_OFFSET_Y()
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 = full!!.transitionalCraftingUI.itemListCraftable.navRemoCon.posX + 12
private val navbarY = full!!.transitionalCraftingUI.itemListCraftable.navRemoCon.posY - 8
private val navbarWidth = UIItemListNavBarVertical.WIDTH
private val navbarHeight = full!!.transitionalCraftingUI.itemListCraftable.height
private val panelX = 32 + navbarX
private val panelY = navbarY
private val panelWidth = 720
private val panelHeight = navbarHeight
private val catIcons = CommonResourcePool.getAsTextureRegionPack("inventory_category")
private val menuButtonTechView = UIItemImageButton(
this, catIcons.get(20, 1),
initialX = navbarX,
initialY = getIconPosY(-2),
activeCol = Toolkit.Theme.COL_SELECTED,
inactiveCol = Toolkit.Theme.COL_SELECTED,
highlightable = false
)
private val menuButtonCraft = UIItemImageButton(
this, catIcons.get(19, 1),
initialX = navbarX,
initialY = getIconPosY(-1),
highlightable = true
).also {
it.clickOnceListener = { _, _ ->
full?.transitionPanel?.setLeftUIto(0)
full?.transitionPanel?.uis?.get(0)?.show()
it.highlighted = false
}
}
fun getIconPosY(index: Int) =
if (index >= 0)
posY1 + 26 * index
else
(posY1 + navbarHeight) + (26 * index)
init {
addUIitem(menuButtonCraft)
addUIitem(menuButtonTechView)
}
private val thisOffsetX = UIInventoryFull.INVENTORY_CELLS_OFFSET_X() + UIItemInventoryElemSimple.height + UIItemInventoryItemGrid.listGap - halfSlotOffset
override fun renderImpl(frameDelta: Float, batch: SpriteBatch, camera: OrthographicCamera) {
// draw fake navbar //
// draw the tray
batch.color = Toolkit.Theme.COL_CELL_FILL
Toolkit.fillArea(batch, navbarX - 4, navbarY, navbarWidth, navbarHeight)
// cell border
batch.color = colourTheme.cellHighlightNormalCol
Toolkit.drawBoxBorder(batch, navbarX - 4, navbarY, navbarWidth, navbarHeight)
// draw window //
batch.color = Toolkit.Theme.COL_CELL_FILL
Toolkit.fillArea(batch, panelX, panelY, panelWidth, panelHeight)
// cell border
batch.color = colourTheme.cellHighlightNormalCol
Toolkit.drawBoxBorder(batch, panelX, panelY, panelWidth, panelHeight)
uiItems.forEach { it.render(frameDelta, batch, camera) }
// control hints
val controlHintXPos = thisOffsetX + 2f
blendNormalStraightAlpha(batch)
batch.color = Color.WHITE
App.fontGame.draw(batch, controlHelp, controlHintXPos, UIInventoryFull.yEnd - 20)
}
private val controlHelp: String
get() = if (App.environment == RunningEnvironment.PC)
"${getKeycapPC(ControlPresets.getKey("control_key_inventory"))} ${Lang["GAME_ACTION_CLOSE"]}"
else
"${App.gamepadLabelStart} ${Lang["GAME_ACTION_CLOSE"]}\u3000 " +
"${App.gamepadLabelLEFTRIGHT} ${Lang["GAME_OBJECTIVE_MULTIPLIER"]}\u3000 " +
"${App.gamepadLabelWest} ${Lang["GAME_ACTION_CRAFT"]}"
override fun updateImpl(delta: Float) {
}
override fun doOpening(delta: Float) {
handler.opacity = 1f
}
override fun doClosing(delta: Float) {
handler.opacity = 1f
}
override fun endOpening(delta: Float) {
handler.opacity = 1f
}
override fun endClosing(delta: Float) {
handler.opacity = 1f
}
override fun dispose() {
}
fun resetUI() {
}
}