mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-11 02:54:04 +09:00
alloying furnace gui wip
This commit is contained in:
@@ -46,6 +46,7 @@ id;classname;tags
|
|||||||
45;net.torvald.terrarum.modulebasegame.gameitems.ItemLogicSignalLatch;FIXTURE,SIGNAL
|
45;net.torvald.terrarum.modulebasegame.gameitems.ItemLogicSignalLatch;FIXTURE,SIGNAL
|
||||||
46;net.torvald.terrarum.modulebasegame.gameitems.ItemLogicSignalRepeaterHorz;FIXTURE,SIGNAL
|
46;net.torvald.terrarum.modulebasegame.gameitems.ItemLogicSignalRepeaterHorz;FIXTURE,SIGNAL
|
||||||
47;net.torvald.terrarum.modulebasegame.gameitems.ItemWrench;TOOL,WRENCH
|
47;net.torvald.terrarum.modulebasegame.gameitems.ItemWrench;TOOL,WRENCH
|
||||||
|
48;net.torvald.terrarum.modulebasegame.gameitems.ItemAlloyingFurnace;FIXTURE,STATION
|
||||||
|
|
||||||
# ingots
|
# ingots
|
||||||
112;net.torvald.terrarum.modulebasegame.gameitems.IngotCopper;INGOT
|
112;net.torvald.terrarum.modulebasegame.gameitems.IngotCopper;INGOT
|
||||||
|
|||||||
|
Binary file not shown.
@@ -42,7 +42,8 @@
|
|||||||
"TOOLTIP_item@basegame:28": "A music vending machine (free to play)",
|
"TOOLTIP_item@basegame:28": "A music vending machine (free to play)",
|
||||||
"TOOLTIP_item@basegame:29": "A coal lookalike that burns just as well and is renewable",
|
"TOOLTIP_item@basegame:29": "A coal lookalike that burns just as well and is renewable",
|
||||||
"TOOLTIP_item@basegame:36": "Creates wires from metal ingots",
|
"TOOLTIP_item@basegame:36": "Creates wires from metal ingots",
|
||||||
"TOOLTIP_item@basegame:47": "Reorients electronic components",
|
"TOOLTIP_item@basegame:47": "Reorients gadgets",
|
||||||
|
"TOOLTIP_item@basegame:48": "Melts two metal ingots to make a bar of alloy",
|
||||||
|
|
||||||
"TOOLTIP_item@basegame:114": "A precious fuel for the steel production",
|
"TOOLTIP_item@basegame:114": "A precious fuel for the steel production",
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
{
|
{
|
||||||
|
"ITEM_ALLOYING_FURNACE": "Alloying Furnace",
|
||||||
"ITEM_CALENDAR": "Calendar",
|
"ITEM_CALENDAR": "Calendar",
|
||||||
"ITEM_CHARCOAL": "Charcoal",
|
"ITEM_CHARCOAL": "Charcoal",
|
||||||
"ITEM_CHERRY_BOMB": "Bomb",
|
"ITEM_CHERRY_BOMB": "Bomb",
|
||||||
|
|||||||
@@ -41,7 +41,8 @@
|
|||||||
"TOOLTIP_item@basegame:28": "음악 자판기입이다 (무료 플레이)",
|
"TOOLTIP_item@basegame:28": "음악 자판기입이다 (무료 플레이)",
|
||||||
"TOOLTIP_item@basegame:29": "석탄과 비슷하고 똑같이 잘 타지만 재생 가능합니다",
|
"TOOLTIP_item@basegame:29": "석탄과 비슷하고 똑같이 잘 타지만 재생 가능합니다",
|
||||||
"TOOLTIP_item@basegame:36": "금속 주괴를 사용해 철사를 뽑아냅니다",
|
"TOOLTIP_item@basegame:36": "금속 주괴를 사용해 철사를 뽑아냅니다",
|
||||||
"TOOLTIP_item@basegame:47": "전자 장치의 방향을 바꿉니다",
|
"TOOLTIP_item@basegame:47": "기기의 방향을 바꿉니다",
|
||||||
|
"TOOLTIP_item@basegame:48": "두 금속 괴를 녹여 합금을 만듭니다",
|
||||||
|
|
||||||
"TOOLTIP_item@basegame:114": "강철 생산의 소중한 연료입니다",
|
"TOOLTIP_item@basegame:114": "강철 생산의 소중한 연료입니다",
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
{
|
{
|
||||||
|
"ITEM_ALLOYING_FURNACE": "합금 화로",
|
||||||
"ITEM_CALENDAR": "달력",
|
"ITEM_CALENDAR": "달력",
|
||||||
"ITEM_CHARCOAL": "목탄",
|
"ITEM_CHARCOAL": "목탄",
|
||||||
"ITEM_CHERRY_BOMB": "폭탄",
|
"ITEM_CHERRY_BOMB": "폭탄",
|
||||||
|
|||||||
Binary file not shown.
@@ -47,7 +47,7 @@ class EntryPoint : ModuleEntryPoint() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
println("\n[Basegame.EntryPoint] Welcome back!")
|
println("\n[Basegame.EntryPoint] Welcome back!")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -20,13 +20,13 @@ import net.torvald.terrarum.gameitems.ItemID
|
|||||||
import net.torvald.terrarum.gameparticles.ParticleVanishingSprite
|
import net.torvald.terrarum.gameparticles.ParticleVanishingSprite
|
||||||
import net.torvald.terrarum.langpack.Lang
|
import net.torvald.terrarum.langpack.Lang
|
||||||
import net.torvald.terrarum.modulebasegame.TerrarumIngame
|
import net.torvald.terrarum.modulebasegame.TerrarumIngame
|
||||||
import net.torvald.terrarum.modulebasegame.ui.UISmelterBasic
|
import net.torvald.terrarum.modulebasegame.ui.UIAlloyingFurnace
|
||||||
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by minjaesong on 2024-03-09.
|
* Created by minjaesong on 2024-03-09.
|
||||||
*/
|
*/
|
||||||
class FixtureAlloyingCrucible : FixtureBase {
|
class FixtureAlloyingFurnace : FixtureBase {
|
||||||
|
|
||||||
|
|
||||||
var fuelCaloriesNow = 0.0 // arbitrary number, may as well be watts or joules
|
var fuelCaloriesNow = 0.0 // arbitrary number, may as well be watts or joules
|
||||||
@@ -146,7 +146,7 @@ class FixtureAlloyingCrucible : FixtureBase {
|
|||||||
|
|
||||||
constructor() : super(
|
constructor() : super(
|
||||||
BlockBox(BlockBox.NO_COLLISION, 2, 2), // temporary value, will be overwritten by spawn()
|
BlockBox(BlockBox.NO_COLLISION, 2, 2), // temporary value, will be overwritten by spawn()
|
||||||
nameFun = { Lang["ITEM_ALLOYING_SMELTER"] },
|
nameFun = { Lang["ITEM_ALLOYING_FURNACE"] },
|
||||||
) {
|
) {
|
||||||
CommonResourcePool.addToLoadingList("particles-tiki_smoke.tga") {
|
CommonResourcePool.addToLoadingList("particles-tiki_smoke.tga") {
|
||||||
TextureRegionPack(ModMgr.getGdxFile("basegame", "particles/bigger_smoke.tga"), 16, 16)
|
TextureRegionPack(ModMgr.getGdxFile("basegame", "particles/bigger_smoke.tga"), 16, 16)
|
||||||
@@ -167,7 +167,7 @@ class FixtureAlloyingCrucible : FixtureBase {
|
|||||||
|
|
||||||
actorValue[AVKey.BASEMASS] = 100.0
|
actorValue[AVKey.BASEMASS] = 100.0
|
||||||
|
|
||||||
// this.mainUI = UIAlloyingCrucible(this)
|
this.mainUI = UIAlloyingFurnace(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -2,9 +2,7 @@ package net.torvald.terrarum.modulebasegame.gameitems
|
|||||||
|
|
||||||
import com.badlogic.gdx.graphics.g2d.TextureRegion
|
import com.badlogic.gdx.graphics.g2d.TextureRegion
|
||||||
import net.torvald.terrarum.CommonResourcePool
|
import net.torvald.terrarum.CommonResourcePool
|
||||||
import net.torvald.terrarum.ModMgr
|
|
||||||
import net.torvald.terrarum.gameitems.ItemID
|
import net.torvald.terrarum.gameitems.ItemID
|
||||||
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by minjaesong on 2023-12-04.
|
* Created by minjaesong on 2023-12-04.
|
||||||
@@ -18,4 +16,18 @@ class ItemSmelterBasic(originalID: ItemID) : FixtureItemBase(originalID, "net.to
|
|||||||
|
|
||||||
override var baseToolSize: Double? = baseMass
|
override var baseToolSize: Double? = baseMass
|
||||||
override var originalName = "ITEM_SMELTER_SMALL"
|
override var originalName = "ITEM_SMELTER_SMALL"
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by minjaesong on 2024-03-10.
|
||||||
|
*/
|
||||||
|
class ItemAlloyingFurnace(originalID: ItemID) : FixtureItemBase(originalID, "net.torvald.terrarum.modulebasegame.gameactors.FixtureAlloyingFurnace") {
|
||||||
|
override var baseMass = 100.0
|
||||||
|
override val canBeDynamic = false
|
||||||
|
override val materialId = ""
|
||||||
|
override val itemImage: TextureRegion
|
||||||
|
get() = CommonResourcePool.getAsItemSheet("basegame.items").get(13,3)
|
||||||
|
|
||||||
|
override var baseToolSize: Double? = baseMass
|
||||||
|
override var originalName = "ITEM_ALLOYING_FURNACE"
|
||||||
}
|
}
|
||||||
@@ -14,10 +14,11 @@ import java.util.concurrent.atomic.AtomicInteger
|
|||||||
*/
|
*/
|
||||||
object SmelterGuiEventBuilder {
|
object SmelterGuiEventBuilder {
|
||||||
|
|
||||||
|
const val SLOT_INDEX_STRIDE = 16
|
||||||
const val PRODUCT_SLOT = 0
|
const val PRODUCT_SLOT = 0
|
||||||
const val ORE_SLOT_FIRST = 1
|
const val ORE_SLOT_FIRST = SLOT_INDEX_STRIDE
|
||||||
const val FIRE_SLOT_FIRST = 2
|
const val FIRE_SLOT_FIRST = 2*SLOT_INDEX_STRIDE
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -25,7 +26,7 @@ object SmelterGuiEventBuilder {
|
|||||||
clickedOnState: AtomicInteger,
|
clickedOnState: AtomicInteger,
|
||||||
|
|
||||||
fireboxItemStatus: SmelterItemStatus,
|
fireboxItemStatus: SmelterItemStatus,
|
||||||
oreItemStatus: SmelterItemStatus,
|
oreItemStatus: List<SmelterItemStatus>,
|
||||||
|
|
||||||
getPlayerInventory: () -> ActorInventory,
|
getPlayerInventory: () -> ActorInventory,
|
||||||
|
|
||||||
@@ -42,7 +43,10 @@ object SmelterGuiEventBuilder {
|
|||||||
|
|
||||||
// oreslot
|
// oreslot
|
||||||
if (amount != null && gameItem != null) {
|
if (amount != null && gameItem != null) {
|
||||||
if (clickedOnState.get() == ORE_SLOT_FIRST) {
|
val clicked = clickedOnState.get()
|
||||||
|
|
||||||
|
if (clicked in ORE_SLOT_FIRST until ORE_SLOT_FIRST + 16) {
|
||||||
|
val oreItemStatus = oreItemStatus[clicked - ORE_SLOT_FIRST]
|
||||||
if (oreItemStatus.itm == gameItem.dynamicID) {
|
if (oreItemStatus.itm == gameItem.dynamicID) {
|
||||||
playerInventory.remove(gameItem.dynamicID, amount)
|
playerInventory.remove(gameItem.dynamicID, amount)
|
||||||
oreItemStatus.changeCount(amount)
|
oreItemStatus.changeCount(amount)
|
||||||
@@ -53,7 +57,7 @@ object SmelterGuiEventBuilder {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// firebox
|
// firebox
|
||||||
else if (clickedOnState.get() == FIRE_SLOT_FIRST) {
|
else if (clicked == FIRE_SLOT_FIRST) {
|
||||||
if (fireboxItemStatus.isNull()) {
|
if (fireboxItemStatus.isNull()) {
|
||||||
playerInventory.remove(gameItem.dynamicID, amount)
|
playerInventory.remove(gameItem.dynamicID, amount)
|
||||||
fireboxItemStatus.set(gameItem.dynamicID, amount)
|
fireboxItemStatus.set(gameItem.dynamicID, amount)
|
||||||
@@ -73,7 +77,7 @@ object SmelterGuiEventBuilder {
|
|||||||
clickedOnState: AtomicInteger,
|
clickedOnState: AtomicInteger,
|
||||||
|
|
||||||
fireboxItemStatus: SmelterItemStatus,
|
fireboxItemStatus: SmelterItemStatus,
|
||||||
oreItemStatus: SmelterItemStatus,
|
oreItemStatus: List<SmelterItemStatus>,
|
||||||
|
|
||||||
getPlayerInventory: () -> ActorInventory,
|
getPlayerInventory: () -> ActorInventory,
|
||||||
|
|
||||||
@@ -83,33 +87,36 @@ object SmelterGuiEventBuilder {
|
|||||||
val scrollY = -scrollY
|
val scrollY = -scrollY
|
||||||
if (gameItem != null) {
|
if (gameItem != null) {
|
||||||
val addCount1 = scrollY.toLong()
|
val addCount1 = scrollY.toLong()
|
||||||
|
val clicked = clickedOnState.get()
|
||||||
|
if (clicked in ORE_SLOT_FIRST until ORE_SLOT_FIRST + 16) {
|
||||||
|
val oreItemStatus = oreItemStatus[clicked - ORE_SLOT_FIRST]
|
||||||
|
if ((oreItemStatus.isNull() || oreItemStatus.itm == gameItem.dynamicID)) {
|
||||||
|
val itemToUse = oreItemStatus.itm ?: gameItem.dynamicID
|
||||||
|
|
||||||
if (clickedOnState.get() == ORE_SLOT_FIRST && (oreItemStatus.isNull() || oreItemStatus.itm == gameItem.dynamicID)) {
|
val addCount2 = scrollY.toLong().coerceIn(
|
||||||
val itemToUse = oreItemStatus.itm ?: gameItem.dynamicID
|
-(playerInventory.searchByID(itemToUse)?.qty ?: 0L),
|
||||||
|
oreItemStatus.qty ?: 0L,
|
||||||
|
)
|
||||||
|
|
||||||
val addCount2 = scrollY.toLong().coerceIn(
|
// add to the inventory slot
|
||||||
-(playerInventory.searchByID(itemToUse)?.qty ?: 0L),
|
if (oreItemStatus.isNotNull() && addCount1 >= 1L) {
|
||||||
oreItemStatus.qty ?: 0L,
|
playerInventory.add(oreItemStatus.itm!!, addCount2)
|
||||||
)
|
|
||||||
|
|
||||||
// add to the inventory slot
|
|
||||||
if (oreItemStatus.isNotNull() && addCount1 >= 1L) {
|
|
||||||
playerInventory.add(oreItemStatus.itm!!, addCount2)
|
|
||||||
oreItemStatus.changeCount(-addCount2)
|
|
||||||
}
|
|
||||||
// remove from the inventory slot
|
|
||||||
else if (addCount1 <= -1L) {
|
|
||||||
playerInventory.remove(itemToUse, -addCount2)
|
|
||||||
if (oreItemStatus.isNull())
|
|
||||||
oreItemStatus.set(itemToUse, -addCount2)
|
|
||||||
else
|
|
||||||
oreItemStatus.changeCount(-addCount2)
|
oreItemStatus.changeCount(-addCount2)
|
||||||
|
}
|
||||||
|
// remove from the inventory slot
|
||||||
|
else if (addCount1 <= -1L) {
|
||||||
|
playerInventory.remove(itemToUse, -addCount2)
|
||||||
|
if (oreItemStatus.isNull())
|
||||||
|
oreItemStatus.set(itemToUse, -addCount2)
|
||||||
|
else
|
||||||
|
oreItemStatus.changeCount(-addCount2)
|
||||||
|
}
|
||||||
|
if (oreItemStatus.qty == 0L) oreItemStatus.nullify()
|
||||||
|
else if (oreItemStatus.isNotNull() && oreItemStatus.qty!! < 0L) throw Error("Item removal count is larger than what was on the slot")
|
||||||
|
itemListUpdateKeepCurrentFilter()
|
||||||
}
|
}
|
||||||
if (oreItemStatus.qty == 0L) oreItemStatus.nullify()
|
|
||||||
else if (oreItemStatus.isNotNull() && oreItemStatus.qty!! < 0L) throw Error("Item removal count is larger than what was on the slot")
|
|
||||||
itemListUpdateKeepCurrentFilter()
|
|
||||||
}
|
}
|
||||||
else if (clickedOnState.get() == FIRE_SLOT_FIRST && (fireboxItemStatus.isNull() || fireboxItemStatus.itm == gameItem.dynamicID)) {
|
else if (clicked == FIRE_SLOT_FIRST && (fireboxItemStatus.isNull() || fireboxItemStatus.itm == gameItem.dynamicID)) {
|
||||||
val itemToUse = fireboxItemStatus.itm ?: gameItem.dynamicID
|
val itemToUse = fireboxItemStatus.itm ?: gameItem.dynamicID
|
||||||
|
|
||||||
val addCount2 = scrollY.toLong().coerceIn(
|
val addCount2 = scrollY.toLong().coerceIn(
|
||||||
@@ -149,7 +156,7 @@ object SmelterGuiEventBuilder {
|
|||||||
|
|
||||||
playerThings: UITemplateHalfInventory,
|
playerThings: UITemplateHalfInventory,
|
||||||
|
|
||||||
oreItemStatus: SmelterItemStatus,
|
oreItemStatus: SmelterItemStatus, oreSlotIndex: Int,
|
||||||
|
|
||||||
getPlayerInventory: () -> ActorInventory,
|
getPlayerInventory: () -> ActorInventory,
|
||||||
|
|
||||||
@@ -157,8 +164,8 @@ object SmelterGuiEventBuilder {
|
|||||||
itemListUpdateKeepCurrentFilter: () -> Unit
|
itemListUpdateKeepCurrentFilter: () -> Unit
|
||||||
|
|
||||||
): (GameItem?, Long, Int, Any?, UIItemInventoryCellBase) -> Unit { return { gameItem: GameItem?, amount: Long, mouseButton: Int, itemExtraInfo: Any?, theButton: UIItemInventoryCellBase ->
|
): (GameItem?, Long, Int, Any?, UIItemInventoryCellBase) -> Unit { return { gameItem: GameItem?, amount: Long, mouseButton: Int, itemExtraInfo: Any?, theButton: UIItemInventoryCellBase ->
|
||||||
if (clickedOnState.get() != ORE_SLOT_FIRST) {
|
if (clickedOnState.get() != ORE_SLOT_FIRST + oreSlotIndex) {
|
||||||
clickedOnState.set(ORE_SLOT_FIRST)
|
clickedOnState.set(ORE_SLOT_FIRST + oreSlotIndex)
|
||||||
theButton.forceHighlighted = true
|
theButton.forceHighlighted = true
|
||||||
buttonsToUnhighlight().forEach { it.forceHighlighted = false }
|
buttonsToUnhighlight().forEach { it.forceHighlighted = false }
|
||||||
playerThings.itemList.itemPage = 0
|
playerThings.itemList.itemPage = 0
|
||||||
@@ -186,7 +193,7 @@ object SmelterGuiEventBuilder {
|
|||||||
fun getOreItemSlotWheelFun(
|
fun getOreItemSlotWheelFun(
|
||||||
clickedOnState: AtomicInteger,
|
clickedOnState: AtomicInteger,
|
||||||
|
|
||||||
oreItemStatus: SmelterItemStatus,
|
oreItemStatus: SmelterItemStatus, oreSlotIndex: Int,
|
||||||
|
|
||||||
getPlayerInventory: () -> ActorInventory,
|
getPlayerInventory: () -> ActorInventory,
|
||||||
|
|
||||||
@@ -195,7 +202,7 @@ object SmelterGuiEventBuilder {
|
|||||||
): (GameItem?, Long, Float, Float, Any?, UIItemInventoryCellBase) -> Unit { return { gameItem: GameItem?, amount: Long, scrollX: Float, scrollY: Float, itemExtraInfo: Any?, theButton: UIItemInventoryCellBase ->
|
): (GameItem?, Long, Float, Float, Any?, UIItemInventoryCellBase) -> Unit { return { gameItem: GameItem?, amount: Long, scrollX: Float, scrollY: Float, itemExtraInfo: Any?, theButton: UIItemInventoryCellBase ->
|
||||||
val playerInventory = getPlayerInventory()
|
val playerInventory = getPlayerInventory()
|
||||||
val scrollY = -scrollY
|
val scrollY = -scrollY
|
||||||
if (clickedOnState.get() == ORE_SLOT_FIRST && oreItemStatus.isNotNull()) {
|
if (clickedOnState.get() == ORE_SLOT_FIRST + oreSlotIndex && oreItemStatus.isNotNull()) {
|
||||||
val removeCount1 = scrollY.toLong()
|
val removeCount1 = scrollY.toLong()
|
||||||
val removeCount2 = scrollY.toLong().coerceIn(
|
val removeCount2 = scrollY.toLong().coerceIn(
|
||||||
-oreItemStatus.qty!!,
|
-oreItemStatus.qty!!,
|
||||||
|
|||||||
132
src/net/torvald/terrarum/modulebasegame/ui/UIAlloyingFurnace.kt
Normal file
132
src/net/torvald/terrarum/modulebasegame/ui/UIAlloyingFurnace.kt
Normal file
@@ -0,0 +1,132 @@
|
|||||||
|
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.terrarum.modulebasegame.gameactors.ActorInventory
|
||||||
|
import net.torvald.terrarum.modulebasegame.gameactors.FixtureAlloyingFurnace
|
||||||
|
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.terrarumsansbitmap.gdx.TextureRegionPack
|
||||||
|
import java.util.concurrent.atomic.AtomicInteger
|
||||||
|
|
||||||
|
class UIAlloyingFurnace(smelter: FixtureAlloyingFurnace) : UICanvas(
|
||||||
|
toggleKeyLiteral = "control_key_inventory",
|
||||||
|
toggleButtonLiteral = "control_gamepad_start"
|
||||||
|
) {
|
||||||
|
|
||||||
|
|
||||||
|
override var width = Toolkit.drawWidth
|
||||||
|
override var height = App.scr.height
|
||||||
|
|
||||||
|
private var clickedOnState = AtomicInteger(SmelterGuiEventBuilder.PRODUCT_SLOT) // Used to set inventory filter and its behaviour. 0: default, 1: oreslot, 2: firebox
|
||||||
|
|
||||||
|
private val playerThings = UITemplateHalfInventory(this, false).also {
|
||||||
|
it.itemListTouchDownFun = SmelterGuiEventBuilder.getPlayerSlotTouchDownFun(
|
||||||
|
clickedOnState,
|
||||||
|
smelter.fireboxItemStatus,
|
||||||
|
listOf(smelter.oreItem1Status, smelter.oreItem2Status),
|
||||||
|
{ getPlayerInventory() },
|
||||||
|
{ itemListUpdateKeepCurrentFilter() }
|
||||||
|
)
|
||||||
|
it.itemListWheelFun = SmelterGuiEventBuilder.getPlayerSlotWheelFun(
|
||||||
|
clickedOnState,
|
||||||
|
smelter.fireboxItemStatus,
|
||||||
|
listOf(smelter.oreItem1Status, smelter.oreItem2Status),
|
||||||
|
{ getPlayerInventory() },
|
||||||
|
{ itemListUpdateKeepCurrentFilter() }
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getPlayerInventory(): ActorInventory = INGAME.actorNowPlaying!!.inventory
|
||||||
|
|
||||||
|
init {
|
||||||
|
CommonResourcePool.addToLoadingList("basegame_gui_smelter_icons") {
|
||||||
|
TextureRegionPack(ModMgr.getGdxFile("basegame", "gui/smelter_icons.tga"), 20, 20)
|
||||||
|
}
|
||||||
|
CommonResourcePool.loadAll()
|
||||||
|
}
|
||||||
|
|
||||||
|
private val smelterCellIcons = CommonResourcePool.getAsTextureRegionPack("basegame_gui_smelter_icons")
|
||||||
|
|
||||||
|
private var smelterBackdrops =
|
||||||
|
CommonResourcePool.getAsTextureRegionPack("basegame/sprites/fixtures/alloying_furnace.tga")
|
||||||
|
|
||||||
|
|
||||||
|
private val leftPanelWidth = playerThings.width
|
||||||
|
private val leftPanelHeight = playerThings.height
|
||||||
|
private val leftPanelX = playerThings.posX - leftPanelWidth - UIItemInventoryItemGrid.listGap - UIItemInventoryElemWide.height
|
||||||
|
private val leftPanelY = playerThings.posY
|
||||||
|
|
||||||
|
private val backdropColour = Color(0x999999_c8.toInt())
|
||||||
|
private val backdropZoom = 6
|
||||||
|
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 fireboxX = backdropX + 12 * backdropZoom + 6
|
||||||
|
private val fireboxY = backdropY + 39 * backdropZoom + 3
|
||||||
|
|
||||||
|
private val productX = backdropX + 37 * backdropZoom + 3
|
||||||
|
private val productY = backdropY + 39 * backdropZoom + 3
|
||||||
|
|
||||||
|
private val thermoX = (backdropX + 24 * backdropZoom + 1).toInt()
|
||||||
|
private val thermoY = (backdropY + 39 * backdropZoom + 3).toInt()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private var encumbrancePerc = 0f
|
||||||
|
|
||||||
|
private fun itemListUpdate() {
|
||||||
|
// let itemlists be sorted
|
||||||
|
inventoryFilter = { _: InventoryPair -> true }
|
||||||
|
playerThings.rebuild(UIItemCatBar.FILTER_CAT_ALL)
|
||||||
|
encumbrancePerc = getPlayerInventory().encumberment.toFloat()
|
||||||
|
}
|
||||||
|
|
||||||
|
private var inventoryFilter = { _: InventoryPair -> true }
|
||||||
|
|
||||||
|
private fun itemListUpdate(filter: (InventoryPair) -> Boolean) {
|
||||||
|
// let itemlists be sorted
|
||||||
|
inventoryFilter = filter
|
||||||
|
playerThings.rebuild(filter)
|
||||||
|
encumbrancePerc = getPlayerInventory().encumberment.toFloat()
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun itemListUpdateKeepCurrentFilter() {
|
||||||
|
// let itemlists be sorted
|
||||||
|
playerThings.rebuild(inventoryFilter)
|
||||||
|
encumbrancePerc = getPlayerInventory().encumberment.toFloat()
|
||||||
|
}
|
||||||
|
|
||||||
|
init {
|
||||||
|
addUIitem(playerThings)
|
||||||
|
// addUIitem(oreItemSlot)
|
||||||
|
// addUIitem(fireboxItemSlot)
|
||||||
|
// addUIitem(productItemslot)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun updateImpl(delta: Float) {
|
||||||
|
TODO("Not yet implemented")
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun renderImpl(frameDelta: Float, batch: SpriteBatch, camera: OrthographicCamera) {
|
||||||
|
TODO("Not yet implemented")
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun dispose() {
|
||||||
|
TODO("Not yet implemented")
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -10,6 +10,7 @@ import net.torvald.terrarum.modulebasegame.gameactors.ActorInventory
|
|||||||
import net.torvald.terrarum.modulebasegame.gameactors.FixtureSmelterBasic
|
import net.torvald.terrarum.modulebasegame.gameactors.FixtureSmelterBasic
|
||||||
import net.torvald.terrarum.modulebasegame.gameactors.InventoryPair
|
import net.torvald.terrarum.modulebasegame.gameactors.InventoryPair
|
||||||
import net.torvald.terrarum.modulebasegame.ui.SmelterGuiEventBuilder.PRODUCT_SLOT
|
import net.torvald.terrarum.modulebasegame.ui.SmelterGuiEventBuilder.PRODUCT_SLOT
|
||||||
|
import net.torvald.terrarum.modulebasegame.ui.SmelterGuiEventBuilder.SLOT_INDEX_STRIDE
|
||||||
import net.torvald.terrarum.modulebasegame.ui.UIItemInventoryCellCommonRes.tooltipShowing
|
import net.torvald.terrarum.modulebasegame.ui.UIItemInventoryCellCommonRes.tooltipShowing
|
||||||
import net.torvald.terrarum.ui.*
|
import net.torvald.terrarum.ui.*
|
||||||
import net.torvald.terrarum.ui.UIItemCatBar.Companion.FILTER_CAT_ALL
|
import net.torvald.terrarum.ui.UIItemCatBar.Companion.FILTER_CAT_ALL
|
||||||
@@ -37,14 +38,14 @@ class UISmelterBasic(val smelter: FixtureSmelterBasic) : UICanvas(
|
|||||||
it.itemListTouchDownFun = SmelterGuiEventBuilder.getPlayerSlotTouchDownFun(
|
it.itemListTouchDownFun = SmelterGuiEventBuilder.getPlayerSlotTouchDownFun(
|
||||||
clickedOnState,
|
clickedOnState,
|
||||||
smelter.fireboxItemStatus,
|
smelter.fireboxItemStatus,
|
||||||
smelter.oreItemStatus,
|
listOf(smelter.oreItemStatus),
|
||||||
{ getPlayerInventory() },
|
{ getPlayerInventory() },
|
||||||
{ itemListUpdateKeepCurrentFilter() }
|
{ itemListUpdateKeepCurrentFilter() }
|
||||||
)
|
)
|
||||||
it.itemListWheelFun = SmelterGuiEventBuilder.getPlayerSlotWheelFun(
|
it.itemListWheelFun = SmelterGuiEventBuilder.getPlayerSlotWheelFun(
|
||||||
clickedOnState,
|
clickedOnState,
|
||||||
smelter.fireboxItemStatus,
|
smelter.fireboxItemStatus,
|
||||||
smelter.oreItemStatus,
|
listOf(smelter.oreItemStatus),
|
||||||
{ getPlayerInventory() },
|
{ getPlayerInventory() },
|
||||||
{ itemListUpdateKeepCurrentFilter() }
|
{ itemListUpdateKeepCurrentFilter() }
|
||||||
)
|
)
|
||||||
@@ -112,14 +113,14 @@ class UISmelterBasic(val smelter: FixtureSmelterBasic) : UICanvas(
|
|||||||
clickedOnState,
|
clickedOnState,
|
||||||
{ listOf(fireboxItemSlot) },
|
{ listOf(fireboxItemSlot) },
|
||||||
playerThings,
|
playerThings,
|
||||||
smelter.oreItemStatus,
|
smelter.oreItemStatus, 1,
|
||||||
{ getPlayerInventory() },
|
{ getPlayerInventory() },
|
||||||
{ filter -> itemListUpdate(filter) },
|
{ filter -> itemListUpdate(filter) },
|
||||||
{ itemListUpdateKeepCurrentFilter() }
|
{ itemListUpdateKeepCurrentFilter() }
|
||||||
),
|
),
|
||||||
wheelFun = SmelterGuiEventBuilder.getOreItemSlotWheelFun(
|
wheelFun = SmelterGuiEventBuilder.getOreItemSlotWheelFun(
|
||||||
clickedOnState,
|
clickedOnState,
|
||||||
smelter.oreItemStatus,
|
smelter.oreItemStatus, 1,
|
||||||
{ getPlayerInventory() },
|
{ getPlayerInventory() },
|
||||||
{ itemListUpdateKeepCurrentFilter() }
|
{ itemListUpdateKeepCurrentFilter() }
|
||||||
)
|
)
|
||||||
@@ -309,7 +310,7 @@ class UISmelterBasic(val smelter: FixtureSmelterBasic) : UICanvas(
|
|||||||
|
|
||||||
|
|
||||||
override fun renderImpl(frameDelta: Float, batch: SpriteBatch, camera: OrthographicCamera) {
|
override fun renderImpl(frameDelta: Float, batch: SpriteBatch, camera: OrthographicCamera) {
|
||||||
val clickedOn = clickedOnState.get()
|
val clickedOn = clickedOnState.get() / SLOT_INDEX_STRIDE
|
||||||
|
|
||||||
|
|
||||||
batch.color = backdropColour
|
batch.color = backdropColour
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user