mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-07 12:21:52 +09:00
all crafting stations now use UICrafting
This commit is contained in:
@@ -735,12 +735,10 @@ open class TerrarumIngame(batch: FlippingSpriteBatch) : IngameInstance(batch) {
|
||||
(Toolkit.drawWidth - ui.width) / 4,
|
||||
(App.scr.height - ui.height) / 4 // what the fuck?
|
||||
)
|
||||
if (fixture.mainUIopenFun == null) {
|
||||
// if (fixture.mainUIopenFun == null)
|
||||
ui.setAsOpen()
|
||||
}
|
||||
else {
|
||||
fixture.mainUIopenFun!!.invoke(ui)
|
||||
}
|
||||
// else
|
||||
// fixture.mainUIopenFun!!.invoke(ui)
|
||||
}
|
||||
}
|
||||
0L
|
||||
|
||||
@@ -158,7 +158,7 @@ open class FixtureBase : ActorWithBody, CuedByTerrainChange {
|
||||
@Transient var mainUI: UICanvas? = null
|
||||
var inventory: FixtureInventory? = null
|
||||
|
||||
@Transient var mainUIopenFun: ((UICanvas) -> Unit)? = null
|
||||
// @Transient var mainUIopenFun: ((UICanvas) -> Unit)? = null
|
||||
|
||||
internal var actorThatInstalledThisFixture: UUID? = null
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ import net.torvald.terrarum.gameparticles.ParticleVanishingSprite
|
||||
import net.torvald.terrarum.langpack.Lang
|
||||
import net.torvald.terrarum.modulebasegame.TerrarumIngame
|
||||
import net.torvald.terrarum.modulebasegame.gameitems.FixtureItemBase
|
||||
import net.torvald.terrarum.modulebasegame.ui.UICrafting
|
||||
import net.torvald.terrarum.modulebasegame.ui.UIInventoryFull
|
||||
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
||||
|
||||
@@ -26,7 +27,8 @@ class FixtureSmelterBasic : FixtureBase, CraftingStation {
|
||||
|
||||
constructor() : super(
|
||||
BlockBox(BlockBox.NO_COLLISION, 3, 4), // temporary value, will be overwritten by spawn()
|
||||
nameFun = { Lang["ITEM_SMELTER_SMALL"] }
|
||||
nameFun = { Lang["ITEM_SMELTER_SMALL"] },
|
||||
mainUI = UICrafting(null)
|
||||
) {
|
||||
CommonResourcePool.addToLoadingList("particles-tiki_smoke.tga") {
|
||||
TextureRegionPack(ModMgr.getGdxFile("basegame", "particles/bigger_smoke.tga"), 16, 16)
|
||||
@@ -48,10 +50,6 @@ class FixtureSmelterBasic : FixtureBase, CraftingStation {
|
||||
}
|
||||
|
||||
actorValue[AVKey.BASEMASS] = 100.0
|
||||
|
||||
mainUIopenFun = { ui ->
|
||||
(mainUI as? UIInventoryFull)?.openCrafting(mainUI!!.handler)
|
||||
}
|
||||
}
|
||||
|
||||
@Transient override var lightBoxList = arrayListOf(Lightbox(Hitbox(0.0, 2*TILE_SIZED, TILE_SIZED * 2, TILE_SIZED * 2), Cvec(0.5f, 0.18f, 0f, 0f)))
|
||||
@@ -74,16 +72,7 @@ class FixtureSmelterBasic : FixtureBase, CraftingStation {
|
||||
private var nextDelay = 0.25f
|
||||
private var spawnTimer = 0f
|
||||
|
||||
@Transient private var mainUIhookHackInstalled = false
|
||||
override fun update(delta: Float) {
|
||||
// adding UI to the fixture as players may right-click on the workbenches instead of pressing a keyboard key
|
||||
(INGAME as? TerrarumIngame)?.let { ingame ->
|
||||
if (!mainUIhookHackInstalled && ingame.uiInventoryPlayerReady) {
|
||||
mainUIhookHackInstalled = true
|
||||
this.mainUI = ingame.uiInventoryPlayer // this field is initialised only after a full load so this hack is necessary
|
||||
}
|
||||
}
|
||||
|
||||
super.update(delta)
|
||||
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ import net.torvald.terrarum.gameactors.AVKey
|
||||
import net.torvald.terrarum.langpack.Lang
|
||||
import net.torvald.terrarum.modulebasegame.TerrarumIngame
|
||||
import net.torvald.terrarum.modulebasegame.gameitems.FixtureItemBase
|
||||
import net.torvald.terrarum.modulebasegame.ui.UICrafting
|
||||
import net.torvald.terrarum.modulebasegame.ui.UIInventoryFull
|
||||
import net.torvald.terrarum.modulebasegame.ui.UIWallCalendar
|
||||
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
||||
@@ -21,7 +22,8 @@ class FixtureWorkbench : FixtureBase, CraftingStation {
|
||||
|
||||
constructor() : super(
|
||||
BlockBox(BlockBox.ALLOW_MOVE_DOWN, 2, 1),
|
||||
nameFun = { Lang["ITEM_WORKBENCH"] }
|
||||
nameFun = { Lang["ITEM_WORKBENCH"] },
|
||||
mainUI = UICrafting(null)
|
||||
) {
|
||||
val itemImage = FixtureItemBase.getItemImageFromSingleImage("basegame", "sprites/fixtures/workbench.tga")
|
||||
|
||||
@@ -33,23 +35,6 @@ class FixtureWorkbench : FixtureBase, CraftingStation {
|
||||
}
|
||||
|
||||
actorValue[AVKey.BASEMASS] = 20.0
|
||||
|
||||
mainUIopenFun = { ui ->
|
||||
(mainUI as? UIInventoryFull)?.openCrafting(mainUI!!.handler)
|
||||
}
|
||||
}
|
||||
|
||||
@Transient private var mainUIhookHackInstalled = false
|
||||
override fun update(delta: Float) {
|
||||
// adding UI to the fixture as players may right-click on the workbenches instead of pressing a keyboard key
|
||||
(INGAME as? TerrarumIngame)?.let { ingame ->
|
||||
if (!mainUIhookHackInstalled && ingame.uiInventoryPlayerReady) {
|
||||
mainUIhookHackInstalled = true
|
||||
this.mainUI = ingame.uiInventoryPlayer // this field is initialised only after a full load so this hack is necessary
|
||||
}
|
||||
}
|
||||
|
||||
super.update(delta)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -33,9 +33,6 @@ class UICrafting(val full: UIInventoryFull?) : UICanvas(
|
||||
toggleButtonLiteral = if (full == null) "control_gamepad_start" else null
|
||||
), HasInventory {
|
||||
|
||||
private val catBarx: UIItemCatBar?
|
||||
get() = full?.catBar
|
||||
|
||||
override var width = App.scr.width
|
||||
override var height = App.scr.height
|
||||
|
||||
|
||||
Reference in New Issue
Block a user