diff --git a/assets/mods/basegame/crafting/fixtures.json b/assets/mods/basegame/crafting/fixtures.json index 32d94695e..483dc6445 100644 --- a/assets/mods/basegame/crafting/fixtures.json +++ b/assets/mods/basegame/crafting/fixtures.json @@ -32,11 +32,19 @@ ] }, "item@basegame:36": { /* wire rolling mill */ - "workbench": "basiccrafting", + "workbench": "basiccrafting,metalworking", "ingredients": [ [1, 1, "$WOOD", 2, "$ROCK", 5, "item@basegame:113"] /* 1 plank, 2 stone, 5 iron ingot */ ] }, + "item@basegame:48": { /* alloying furnace */ + "workbench": "basiccrafting,metalworking", + "ingredients": [ + [1, 15, "$ROCK", 10, "item@basegame:25", 15, "item@basegame:113"] /* 1 smelter = 15 rocks, 10 clay balls, 15 iron ingot */ + ] + }, + + "item@basegame:256": { /* oak door */ "workbench": "basiccrafting", diff --git a/src/net/torvald/terrarum/modulebasegame/gameactors/FixtureAlloyingFurnace.kt b/src/net/torvald/terrarum/modulebasegame/gameactors/FixtureAlloyingFurnace.kt index fddb569ac..fcbb65ba0 100644 --- a/src/net/torvald/terrarum/modulebasegame/gameactors/FixtureAlloyingFurnace.kt +++ b/src/net/torvald/terrarum/modulebasegame/gameactors/FixtureAlloyingFurnace.kt @@ -296,7 +296,7 @@ class FixtureAlloyingFurnace : FixtureBase { (Terrarum.ingame as TerrarumIngame).addParticle( ParticleVanishingSprite( CommonResourcePool.getAsTextureRegionPack("particles-tiki_smoke.tga"), - 25f, true, hitbox.startX + TILE_SIZED, hitbox.startY + 16, false, (Math.random() * 256).toInt() + 25f, true, hitbox.startX + TILE_SIZED / 2, hitbox.startY + 16, false, (Math.random() * 256).toInt() ) ) diff --git a/src/net/torvald/terrarum/modulebasegame/ui/SmelterGuiEventBuilder.kt b/src/net/torvald/terrarum/modulebasegame/ui/SmelterGuiEventBuilder.kt index 8c6011260..67b4865c2 100644 --- a/src/net/torvald/terrarum/modulebasegame/ui/SmelterGuiEventBuilder.kt +++ b/src/net/torvald/terrarum/modulebasegame/ui/SmelterGuiEventBuilder.kt @@ -3,6 +3,7 @@ package net.torvald.terrarum.modulebasegame.ui import net.torvald.terrarum.App import net.torvald.terrarum.ItemCodex import net.torvald.terrarum.gameitems.GameItem +import net.torvald.terrarum.gameitems.ItemID import net.torvald.terrarum.modulebasegame.gameactors.ActorInventory import net.torvald.terrarum.modulebasegame.gameactors.InventoryPair import net.torvald.terrarum.modulebasegame.gameactors.SmelterItemStatus @@ -158,6 +159,8 @@ object SmelterGuiEventBuilder { oreItemStatus: SmelterItemStatus, oreSlotIndex: Int, + oreItemFilter: (ItemID) -> Boolean, + getPlayerInventory: () -> ActorInventory, itemListUpdate: ((InventoryPair) -> Boolean) -> Unit, @@ -169,7 +172,7 @@ object SmelterGuiEventBuilder { theButton.forceHighlighted = true buttonsToUnhighlight().forEach { it.forceHighlighted = false } playerThings.itemList.itemPage = 0 - itemListUpdate { ItemCodex.hasTag(it.itm, "SMELTABLE") } + itemListUpdate { oreItemFilter(it.itm) } } else if (oreItemStatus.isNotNull()) { val removeCount = if (mouseButton == App.getConfigInt("config_mouseprimary")) diff --git a/src/net/torvald/terrarum/modulebasegame/ui/UIAlloyingFurnace.kt b/src/net/torvald/terrarum/modulebasegame/ui/UIAlloyingFurnace.kt index 38e4e7e2f..f0d9d6ff0 100644 --- a/src/net/torvald/terrarum/modulebasegame/ui/UIAlloyingFurnace.kt +++ b/src/net/torvald/terrarum/modulebasegame/ui/UIAlloyingFurnace.kt @@ -3,21 +3,21 @@ 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.App -import net.torvald.terrarum.CommonResourcePool -import net.torvald.terrarum.INGAME -import net.torvald.terrarum.ModMgr +import net.torvald.colourutil.cieluv_getGradient +import net.torvald.terrarum.* +import net.torvald.terrarum.langpack.Lang import net.torvald.terrarum.modulebasegame.gameactors.ActorInventory import net.torvald.terrarum.modulebasegame.gameactors.FixtureAlloyingFurnace +import net.torvald.terrarum.modulebasegame.gameactors.FixtureSmelterBasic import net.torvald.terrarum.modulebasegame.gameactors.InventoryPair -import net.torvald.terrarum.ui.Toolkit -import net.torvald.terrarum.ui.UICanvas -import net.torvald.terrarum.ui.UIItemCatBar -import net.torvald.terrarum.ui.UIItemInventoryElemWide +import net.torvald.terrarum.ui.* import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack +import net.torvald.unicode.getKeycapPC +import net.torvald.unicode.getMouseButton import java.util.concurrent.atomic.AtomicInteger +import kotlin.math.roundToInt -class UIAlloyingFurnace(smelter: FixtureAlloyingFurnace) : UICanvas( +class UIAlloyingFurnace(val smelter: FixtureAlloyingFurnace) : UICanvas( toggleKeyLiteral = "control_key_inventory", toggleButtonLiteral = "control_gamepad_start" ) { @@ -70,20 +70,105 @@ class UIAlloyingFurnace(smelter: FixtureAlloyingFurnace) : UICanvas( private val backdropX = (leftPanelX + (leftPanelWidth - smelterBackdrops.tileW * backdropZoom) / 2).toFloat() private val backdropY = (leftPanelY + (leftPanelHeight - smelterBackdrops.tileH * backdropZoom) / 2).toFloat() - private val oreX1 = backdropX + 6 * backdropZoom + 6 - private val oreX2 = backdropX + 18 * backdropZoom + 6 - private val oreY = backdropY + 23 * backdropZoom + 3 + private val oreX1 = backdropX + -1 * backdropZoom + 6 + 6 + private val oreX2 = backdropX + 9 * backdropZoom + 6 - 5 + private val oreY1 = backdropY + 3 * backdropZoom + 3 + private val oreY2 = backdropY + 3 * backdropZoom + 3 - private val fireboxX = backdropX + 12 * backdropZoom + 6 - private val fireboxY = backdropY + 39 * backdropZoom + 3 + private val fireboxX = backdropX + 4 * backdropZoom + 6 + private val fireboxY = backdropY + 19 * backdropZoom + 3 - private val productX = backdropX + 37 * backdropZoom + 3 - private val productY = backdropY + 39 * backdropZoom + 3 + private val productX = backdropX + 19 * backdropZoom + 3 + private val productY = backdropY + 7 * backdropZoom + 3 - private val thermoX = (backdropX + 24 * backdropZoom + 1).toInt() - private val thermoY = (backdropY + 39 * backdropZoom + 3).toInt() + private val thermoX = (backdropX + 16 * backdropZoom + 1).toInt() + private val thermoY = (backdropY + 19 * backdropZoom + 3).toInt() + private val oreItemSlot1: UIItemInventoryElemSimple = UIItemInventoryElemSimple( + this, oreX1.toInt(), oreY1.toInt(), + updateOnNull = true, + emptyCellIcon = smelterCellIcons.get(1, 1), + keyDownFun = { _, _, _, _, _ -> }, + touchDownFun = SmelterGuiEventBuilder.getOreItemSlotTouchDownFun( + clickedOnState, + { listOf(fireboxItemSlot, oreItemSlot2) }, + playerThings, + smelter.oreItem1Status, 0, + { ItemCodex.hasAnyTagOf(it, "SMELTABLE", "INGOT") && ItemCodex.hasNoTagOf(it, "ALLOY") }, + { getPlayerInventory() }, + { filter -> itemListUpdate(filter) }, + { itemListUpdateKeepCurrentFilter() } + ), + wheelFun = SmelterGuiEventBuilder.getOreItemSlotWheelFun( + clickedOnState, + smelter.oreItem1Status, 0, + { getPlayerInventory() }, + { itemListUpdateKeepCurrentFilter() } + ) + ) + private val oreItemSlot2: UIItemInventoryElemSimple = UIItemInventoryElemSimple( + this, oreX2.toInt(), oreY2.toInt(), + updateOnNull = true, + emptyCellIcon = smelterCellIcons.get(1, 1), + keyDownFun = { _, _, _, _, _ -> }, + touchDownFun = SmelterGuiEventBuilder.getOreItemSlotTouchDownFun( + clickedOnState, + { listOf(fireboxItemSlot, oreItemSlot1) }, + playerThings, + smelter.oreItem2Status, 1, + { ItemCodex.hasAnyTagOf(it, "SMELTABLE", "INGOT") && ItemCodex.hasNoTagOf(it, "ALLOY") }, + { getPlayerInventory() }, + { filter -> itemListUpdate(filter) }, + { itemListUpdateKeepCurrentFilter() } + ), + wheelFun = SmelterGuiEventBuilder.getOreItemSlotWheelFun( + clickedOnState, + smelter.oreItem2Status, 1, + { getPlayerInventory() }, + { itemListUpdateKeepCurrentFilter() } + ) + ) + private val fireboxItemSlot: UIItemInventoryElemSimple = UIItemInventoryElemSimple( + this, fireboxX.toInt(), fireboxY.toInt(), + emptyCellIcon = smelterCellIcons.get(0, 0), + updateOnNull = true, + keyDownFun = { _, _, _, _, _ -> }, + touchDownFun = SmelterGuiEventBuilder.getFireboxItemSlotTouchDownFun( + clickedOnState, + { listOf(oreItemSlot1, oreItemSlot2) }, + playerThings, + smelter.fireboxItemStatus, + { getPlayerInventory() }, + { filter -> itemListUpdate(filter) }, + { itemListUpdateKeepCurrentFilter() } + ), + wheelFun = SmelterGuiEventBuilder.getFireboxItemSlotWheelFun( + clickedOnState, + smelter.fireboxItemStatus, + { getPlayerInventory() }, + { itemListUpdateKeepCurrentFilter() } + ) + ) + private val productItemslot: UIItemInventoryElemSimple = UIItemInventoryElemSimple( + this, productX.toInt(), productY.toInt(), + emptyCellIcon = smelterCellIcons.get(1, 0), + keyDownFun = { _, _, _, _, _ -> }, + touchDownFun = SmelterGuiEventBuilder.getProductItemSlotTouchDownFun( + clickedOnState, + { listOf(oreItemSlot1, oreItemSlot2, fireboxItemSlot) }, + playerThings, + smelter.productItemStatus, + { getPlayerInventory() }, + { itemListUpdate() }, + { itemListUpdateKeepCurrentFilter() } + ), + wheelFun = SmelterGuiEventBuilder.getProductItemSlotWheelFun( + smelter.productItemStatus, + { getPlayerInventory() }, + { itemListUpdateKeepCurrentFilter() } + ) + ) private var encumbrancePerc = 0f @@ -112,21 +197,261 @@ class UIAlloyingFurnace(smelter: FixtureAlloyingFurnace) : UICanvas( init { addUIitem(playerThings) -// addUIitem(oreItemSlot) -// addUIitem(fireboxItemSlot) -// addUIitem(productItemslot) + addUIitem(oreItemSlot1) + addUIitem(oreItemSlot2) + addUIitem(fireboxItemSlot) + addUIitem(productItemslot) } + override fun show() { + super.show() + + clickedOnState.set(SmelterGuiEventBuilder.PRODUCT_SLOT) + oreItemSlot1.forceHighlighted = false + oreItemSlot2.forceHighlighted = false + fireboxItemSlot.forceHighlighted = false + + playerThings.setGetInventoryFun { INGAME.actorNowPlaying!!.inventory } + itemListUpdate() + + UIItemInventoryCellCommonRes.tooltipShowing.clear() + INGAME.setTooltipMessage(null) + } + + override fun updateImpl(delta: Float) { - TODO("Not yet implemented") + uiItems.forEach { it.update(delta) } + + oreItemSlot1.item = ItemCodex[smelter.oreItem1?.itm] + oreItemSlot1.itemImage = ItemCodex.getItemImage(smelter.oreItem1?.itm) + oreItemSlot1.amount = smelter.oreItem1?.qty ?: UIItemInventoryElemWide.UNIQUE_ITEM_HAS_NO_AMOUNT + + oreItemSlot2.item = ItemCodex[smelter.oreItem2?.itm] + oreItemSlot2.itemImage = ItemCodex.getItemImage(smelter.oreItem2?.itm) + oreItemSlot2.amount = smelter.oreItem2?.qty ?: UIItemInventoryElemWide.UNIQUE_ITEM_HAS_NO_AMOUNT + + fireboxItemSlot.item = ItemCodex[smelter.fireboxItem?.itm] + fireboxItemSlot.itemImage = ItemCodex.getItemImage(smelter.fireboxItem?.itm) + fireboxItemSlot.amount = smelter.fireboxItem?.qty ?: UIItemInventoryElemWide.UNIQUE_ITEM_HAS_NO_AMOUNT + + productItemslot.item = ItemCodex[smelter.productItem?.itm] + productItemslot.itemImage = ItemCodex.getItemImage(smelter.productItem?.itm) + productItemslot.amount = smelter.productItem?.qty ?: UIItemInventoryElemWide.UNIQUE_ITEM_HAS_NO_AMOUNT } + override fun touchDown(screenX: Int, screenY: Int, pointer: Int, button: Int): Boolean { + super.touchDown(screenX, screenY, pointer, button) + + // unhighlight all cells when clicked outside + if (!oreItemSlot1.mouseUp && + !oreItemSlot2.mouseUp && + !fireboxItemSlot.mouseUp && + !productItemslot.mouseUp && + !playerThings.itemList.mouseUp && + !playerThings.itemList.navRemoCon.mouseUp + ) { + + clickedOnState.set(SmelterGuiEventBuilder.PRODUCT_SLOT) + + oreItemSlot1.forceHighlighted = false + oreItemSlot2.forceHighlighted = false + fireboxItemSlot.forceHighlighted = false + itemListUpdate() + } + + return true + } + + private val SP = "\u3000" + private val ML = getMouseButton(App.getConfigInt("config_mouseprimary")) + private val MR = getMouseButton(App.getConfigInt("config_mousesecondary")) + private val MW = getMouseButton(2) + private val controlHelpForSmelter = listOf( + // no slot selected + { if (App.environment == RunningEnvironment.PC) + "${getKeycapPC(ControlPresets.getKey("control_key_inventory"))} ${Lang["GAME_ACTION_CLOSE"]}$SP" + + "$ML ${Lang["GAME_ACTION_SELECT_SLOT"]}" + else + "${App.gamepadLabelStart} ${Lang["GAME_ACTION_CLOSE"]}" }, + // ore slot + { if (App.environment == RunningEnvironment.PC) + "${getKeycapPC(ControlPresets.getKey("control_key_inventory"))} ${Lang["GAME_ACTION_CLOSE"]}$SP" + + "$ML ${Lang["GAME_ACTION_TAKE_ALL_CONT"]}$SP" + + "$MW$MR ${Lang["GAME_ACTION_TAKE_ONE_CONT"]}" + else + "${App.gamepadLabelStart} ${Lang["GAME_ACTION_CLOSE"]}" }, + // firebox slot + { if (App.environment == RunningEnvironment.PC) + "${getKeycapPC(ControlPresets.getKey("control_key_inventory"))} ${Lang["GAME_ACTION_CLOSE"]}$SP" + + "$ML ${Lang["GAME_ACTION_TAKE_ALL_CONT"]}$SP" + + "$MW$MR ${Lang["GAME_ACTION_TAKE_ONE_CONT"]}" + else + "${App.gamepadLabelStart} ${Lang["GAME_ACTION_CLOSE"]}" } + ) + + private val controlHelpForInventory = listOf( + // no slot selected + { "" }, + // ore slot + { if (App.environment == RunningEnvironment.PC) + "$ML ${Lang["GAME_ACTION_PUT_ALL_CONT"]}$SP" + + "$MW$MR ${Lang["GAME_ACTION_PUT_ONE_CONT"]}" + else + "${App.gamepadLabelStart} ${Lang["GAME_ACTION_CLOSE"]}" }, + // firebox slot + { if (App.environment == RunningEnvironment.PC) + "$ML ${Lang["GAME_ACTION_PUT_ALL_CONT"]}$SP" + + "$MW$MR ${Lang["GAME_ACTION_PUT_ONE_CONT"]}" + else + "${App.gamepadLabelStart} ${Lang["GAME_ACTION_CLOSE"]}" } + ) + + private val controlHelpForInventoryTwoRows = listOf( + // no slot selected + { "" }, + // ore slot + { if (App.environment == RunningEnvironment.PC) + "$ML ${Lang["GAME_ACTION_PUT_ALL"]}$SP" + + "$MW$MR ${Lang["GAME_ACTION_PUT_ONE"]}" + else + "${App.gamepadLabelStart} ${Lang["GAME_ACTION_CLOSE"]}" }, + // firebox slot + { if (App.environment == RunningEnvironment.PC) + "$ML ${Lang["GAME_ACTION_PUT_ALL"]}$SP" + + "$MW$MR ${Lang["GAME_ACTION_PUT_ONE"]}" + else + "${App.gamepadLabelStart} ${Lang["GAME_ACTION_CLOSE"]}" } + ) + + override fun renderImpl(frameDelta: Float, batch: SpriteBatch, camera: OrthographicCamera) { - TODO("Not yet implemented") + val clickedOn = clickedOnState.get() / SmelterGuiEventBuilder.SLOT_INDEX_STRIDE + + + batch.color = backdropColour +// batch.draw(smelterBackdrops.get(1,0), backdropX, backdropY, smelterBackdrops.tileW * 6f, smelterBackdrops.tileH * 6f) +// batch.color = backdropColour mul Color(1f, 1f, 1f, smelter.temperature) + batch.draw(smelterBackdrops.get(0,0), backdropX, backdropY, smelterBackdrops.tileW * 6f, smelterBackdrops.tileH * 6f) + + uiItems.forEach { it.render(frameDelta, batch, camera) } + + drawProgressGauge(batch, oreItemSlot1.posX, oreItemSlot1.posY, smelter.progress / FixtureSmelterBasic.CALORIES_PER_ROASTING) + drawProgressGauge(batch, fireboxItemSlot.posX, fireboxItemSlot.posY, (smelter.fuelCaloriesNow / (smelter.fuelCaloriesMax ?: Double.POSITIVE_INFINITY)).toFloat()) + drawThermoGauge(batch, thermoX, thermoY, smelter.temperature) + + + // control hints + batch.color = Color.WHITE + val controlHintXPos = leftPanelX + 2f + val controlHintXPos2 = playerThings.posX + 2f + blendNormalStraightAlpha(batch) + App.fontGame.draw(batch, controlHelpForSmelter[clickedOn](), controlHintXPos, UIInventoryFull.yEnd - 20) + + // deal with the text that is too long + val encumbBarXPos = playerThings.posX + playerThings.width - UIInventoryCells.weightBarWidth + 36 + val encumbBarYPos = UIInventoryFull.yEnd - 20 + 3f + + val tr = controlHelpForInventory[clickedOn]() + val trLen = App.fontGame.getWidth(tr) + val encumbTextX = encumbBarXPos - 6 - App.fontGame.getWidth(Lang["GAME_INVENTORY_ENCUMBRANCE"]) + if (controlHintXPos2 + trLen + 4 >= encumbTextX) { + controlHelpForInventoryTwoRows[clickedOn]().split(SP).forEachIndexed { index, s -> + App.fontGame.draw(batch, s, controlHintXPos2, UIInventoryFull.yEnd - 20 + 20 * index) + } + } + else { + App.fontGame.draw(batch, controlHelpForInventory[clickedOn](), controlHintXPos2, UIInventoryFull.yEnd - 20) + } + + + + if (INGAME.actorNowPlaying != null) { + //draw player encumb + UIInventoryCells.drawEncumbranceBar(batch, encumbBarXPos, encumbBarYPos, encumbrancePerc, INGAME.actorNowPlaying!!.inventory) + } + + + blendNormalStraightAlpha(batch) + } + + private val colProgress = Color(0xbbbbbbff.toInt()) + private val colTemp1 = Color(0x99000bff.toInt()) + private val colTemp2 = Color(0xffe200ff.toInt()) + + + + /** + * @param x x-position of the inventory cell that will have the gauge + * @param y y-position of the inventory cell that will have the gauge + */ + private fun drawProgressGauge(batch: SpriteBatch, x: Int, y: Int, percentage: Float) { + val percentage = percentage.coerceIn(0f, 1f) + + batch.color = Toolkit.Theme.COL_CELL_FILL + Toolkit.fillArea(batch, x - 7, y, 6, UIItemInventoryElemSimple.height) + + batch.color = Toolkit.Theme.COL_INVENTORY_CELL_BORDER + Toolkit.drawStraightLine(batch, x - 7, y - 1, x - 1, 1, false) + Toolkit.drawStraightLine(batch, x - 7, y + UIItemInventoryElemSimple.height, x - 1, 1, false) + Toolkit.drawStraightLine(batch, x - 8, y, y + UIItemInventoryElemSimple.height, 1, true) + + batch.color = colProgress + Toolkit.fillArea(batch, x - 7, y + UIItemInventoryElemSimple.height, 6, -(percentage * UIItemInventoryElemSimple.height).roundToInt()) + } + + private fun drawThermoGauge(batch: SpriteBatch, x: Int, y: Int, percentage: Float) { + val percentage = percentage.coerceIn(0f, 1f) + + batch.color = Toolkit.Theme.COL_INVENTORY_CELL_BORDER + Toolkit.drawStraightLine(batch, x, y - 1, x + 4, 1, false) + Toolkit.drawStraightLine(batch, x, y + UIItemInventoryElemSimple.height + 7, x + 4, 1, false) + + Toolkit.drawStraightLine(batch, x - 1, y, y + UIItemInventoryElemSimple.height, 1, true) + Toolkit.drawStraightLine(batch, x + 4, y, y + UIItemInventoryElemSimple.height, 1, true) + Toolkit.drawStraightLine(batch, x - 1, y + UIItemInventoryElemSimple.height + 6, y + UIItemInventoryElemSimple.height + 7, 1, true) + Toolkit.drawStraightLine(batch, x + 4, y + UIItemInventoryElemSimple.height + 6, y + UIItemInventoryElemSimple.height + 7, 1, true) + + Toolkit.drawStraightLine(batch, x - 2, y + UIItemInventoryElemSimple.height, y + UIItemInventoryElemSimple.height + 1, 1, true) + Toolkit.drawStraightLine(batch, x + 5, y + UIItemInventoryElemSimple.height, y + UIItemInventoryElemSimple.height + 1, 1, true) + Toolkit.drawStraightLine(batch, x - 2, y + UIItemInventoryElemSimple.height + 5, y + UIItemInventoryElemSimple.height + 6, 1, true) + Toolkit.drawStraightLine(batch, x + 5, y + UIItemInventoryElemSimple.height + 5, y + UIItemInventoryElemSimple.height + 6, 1, true) + + Toolkit.drawStraightLine(batch, x - 3, y + UIItemInventoryElemSimple.height + 1, y + UIItemInventoryElemSimple.height + 5, 1, true) + Toolkit.drawStraightLine(batch, x + 6, y + UIItemInventoryElemSimple.height + 1, y + UIItemInventoryElemSimple.height + 5, 1, true) + + + batch.color = cieluv_getGradient(percentage, colTemp1, colTemp2) + Toolkit.fillArea(batch, x, y + UIItemInventoryElemSimple.height, 4, -(percentage * UIItemInventoryElemSimple.height).roundToInt()) + + Toolkit.fillArea(batch, x, y + UIItemInventoryElemSimple.height, 4, 6) + Toolkit.fillArea(batch, x - 1, y + UIItemInventoryElemSimple.height + 1, 6, 4) + } + + + + override fun doOpening(delta: Float) { + super.doOpening(delta) + INGAME.disablePlayerControl() + INGAME.setTooltipMessage(null) + } + + override fun doClosing(delta: Float) { + super.doClosing(delta) + INGAME.resumePlayerControl() + INGAME.setTooltipMessage(null) + } + + override fun endOpening(delta: Float) { + super.endOpening(delta) + } + + override fun endClosing(delta: Float) { + super.endClosing(delta) + UIItemInventoryCellCommonRes.tooltipShowing.clear() + INGAME.setTooltipMessage(null) // required! } override fun dispose() { - TODO("Not yet implemented") } } diff --git a/src/net/torvald/terrarum/modulebasegame/ui/UISmelterBasic.kt b/src/net/torvald/terrarum/modulebasegame/ui/UISmelterBasic.kt index 1b51e9da7..a326f7f01 100644 --- a/src/net/torvald/terrarum/modulebasegame/ui/UISmelterBasic.kt +++ b/src/net/torvald/terrarum/modulebasegame/ui/UISmelterBasic.kt @@ -113,14 +113,15 @@ class UISmelterBasic(val smelter: FixtureSmelterBasic) : UICanvas( clickedOnState, { listOf(fireboxItemSlot) }, playerThings, - smelter.oreItemStatus, 1, + smelter.oreItemStatus, 0, + { ItemCodex.hasTag(it, "SMELTABLE") }, { getPlayerInventory() }, { filter -> itemListUpdate(filter) }, { itemListUpdateKeepCurrentFilter() } ), wheelFun = SmelterGuiEventBuilder.getOreItemSlotWheelFun( clickedOnState, - smelter.oreItemStatus, 1, + smelter.oreItemStatus, 0, { getPlayerInventory() }, { itemListUpdateKeepCurrentFilter() } ) @@ -230,6 +231,7 @@ class UISmelterBasic(val smelter: FixtureSmelterBasic) : UICanvas( override fun touchDown(screenX: Int, screenY: Int, pointer: Int, button: Int): Boolean { super.touchDown(screenX, screenY, pointer, button) + // unhighlight all cells when clicked outside if (!oreItemSlot.mouseUp && !fireboxItemSlot.mouseUp && !productItemslot.mouseUp && @@ -320,7 +322,7 @@ class UISmelterBasic(val smelter: FixtureSmelterBasic) : UICanvas( uiItems.forEach { it.render(frameDelta, batch, camera) } - drawProgressGauge(batch, oreItemSlot.posX, oreItemSlot.posY, smelter.progress.toFloat() / FixtureSmelterBasic.CALORIES_PER_ROASTING) + drawProgressGauge(batch, oreItemSlot.posX, oreItemSlot.posY, smelter.progress / FixtureSmelterBasic.CALORIES_PER_ROASTING) drawProgressGauge(batch, fireboxItemSlot.posX, fireboxItemSlot.posY, (smelter.fuelCaloriesNow / (smelter.fuelCaloriesMax ?: Double.POSITIVE_INFINITY)).toFloat()) drawThermoGauge(batch, thermoX, thermoY, smelter.temperature)