mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-07 12:21:52 +09:00
fix: workbench is opening calendar ui
This commit is contained in:
@@ -680,18 +680,25 @@ open class TerrarumIngame(batch: FlippingSpriteBatch) : IngameInstance(batch) {
|
||||
// what if there's multiple of such fixtures? whatever, you are supposed to DISALLOW such situation.
|
||||
for (kk in actorsUnderMouse.indices) {
|
||||
if (mouseInInteractableRange(actor) { _, _, _, _ ->
|
||||
actorsUnderMouse[kk].mainUI?.let {
|
||||
uiOpened = true
|
||||
actorsUnderMouse[kk].let { fixture ->
|
||||
fixture.mainUI?.let { ui ->
|
||||
uiOpened = true
|
||||
|
||||
// property 'uiFixture' is a dedicated property that the TerrarumIngame recognises.
|
||||
// when it's not null, the UI will be updated and rendered
|
||||
// when the UI is closed, it'll be replaced with a null value
|
||||
uiFixture = it
|
||||
it.setPosition(
|
||||
(Toolkit.drawWidth - it.width) / 4,
|
||||
(App.scr.height - it.height) / 4 // what the fuck?
|
||||
)
|
||||
it.setAsOpen()
|
||||
// property 'uiFixture' is a dedicated property that the TerrarumIngame recognises.
|
||||
// when it's not null, the UI will be updated and rendered
|
||||
// when the UI is closed, it'll be replaced with a null value
|
||||
uiFixture = ui
|
||||
ui.setPosition(
|
||||
(Toolkit.drawWidth - ui.width) / 4,
|
||||
(App.scr.height - ui.height) / 4 // what the fuck?
|
||||
)
|
||||
if (fixture.mainUIopenFun == null) {
|
||||
ui.setAsOpen()
|
||||
}
|
||||
else {
|
||||
fixture.mainUIopenFun!!.invoke(ui)
|
||||
}
|
||||
}
|
||||
}
|
||||
0L
|
||||
} == 0L) break
|
||||
|
||||
@@ -145,6 +145,8 @@ open class FixtureBase : ActorWithBody, CuedByTerrainChange {
|
||||
@Transient var mainUI: UICanvas? = null
|
||||
var inventory: FixtureInventory? = null
|
||||
|
||||
@Transient var mainUIopenFun: ((UICanvas) -> Unit)? = null
|
||||
|
||||
protected var actorThatInstalledThisFixture: UUID? = null
|
||||
|
||||
protected constructor() : super(RenderOrder.BEHIND, PhysProperties.IMMOBILE, null)
|
||||
|
||||
@@ -1,10 +1,14 @@
|
||||
package net.torvald.terrarum.modulebasegame.gameactors
|
||||
|
||||
import net.torvald.terrarum.BlockCodex
|
||||
import net.torvald.terrarum.INGAME
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.blockproperties.Block
|
||||
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.UIInventoryFull
|
||||
import net.torvald.terrarum.modulebasegame.ui.UIWallCalendar
|
||||
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
||||
|
||||
@@ -18,7 +22,7 @@ class FixtureWorkbench : FixtureBase, CraftingStation {
|
||||
constructor() : super(
|
||||
BlockBox(BlockBox.ALLOW_MOVE_DOWN, 2, 1),
|
||||
nameFun = { Lang["ITEM_WORKBENCH"] },
|
||||
mainUI = UIWallCalendar()
|
||||
mainUI = (INGAME as? TerrarumIngame)?.uiInventoryPlayer
|
||||
) {
|
||||
val itemImage = FixtureItemBase.getItemImageFromSingleImage("basegame", "sprites/fixtures/workbench.tga")
|
||||
|
||||
@@ -30,6 +34,10 @@ class FixtureWorkbench : FixtureBase, CraftingStation {
|
||||
}
|
||||
|
||||
actorValue[AVKey.BASEMASS] = 20.0
|
||||
|
||||
mainUIopenFun = { ui ->
|
||||
(mainUI as? UIInventoryFull)?.openCrafting(mainUI!!.handler)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -11,6 +11,7 @@ import net.torvald.terrarum.langpack.Lang
|
||||
import net.torvald.terrarum.modulebasegame.gameactors.ActorHumanoid
|
||||
import net.torvald.terrarum.ui.Toolkit
|
||||
import net.torvald.terrarum.ui.UICanvas
|
||||
import net.torvald.terrarum.ui.UIHandler
|
||||
import net.torvald.terrarum.ui.UIItemHorizontalFadeSlide
|
||||
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
||||
import net.torvald.unicode.*
|
||||
@@ -251,12 +252,8 @@ class UIInventoryFull(
|
||||
// allow "control_key_gamemenu" to open this UI and bring system menu immediately
|
||||
this.handler.toggleKeyExtra.add("control_key_gamemenu" )
|
||||
this.handler.toggleKeyExtraAction.add {
|
||||
if (it.isClosed) {
|
||||
INGAME.setTooltipMessage(null)
|
||||
transitionPanel.forcePosition(2)
|
||||
catBar.setSelectedPanel(2)
|
||||
it.setAsOpen()
|
||||
}
|
||||
if (it.isClosed)
|
||||
openGamemenu(it)
|
||||
else if (it.isOpened)
|
||||
setAsClose()
|
||||
}
|
||||
@@ -264,20 +261,29 @@ class UIInventoryFull(
|
||||
// allow "control_key_crafting" to open this UI and bring system menu immediately
|
||||
this.handler.toggleKeyExtra.add("control_key_crafting")
|
||||
this.handler.toggleKeyExtraAction.add {
|
||||
if (it.isClosed) {
|
||||
INGAME.setTooltipMessage(null)
|
||||
transitionPanel.forcePosition(0)
|
||||
catBar.setSelectedPanel(0)
|
||||
transitionalCraftingUI.resetUI()
|
||||
it.setAsOpen()
|
||||
}
|
||||
if (it.isClosed)
|
||||
openCrafting(it)
|
||||
else if (it.isOpened)
|
||||
setAsClose()
|
||||
}
|
||||
|
||||
|
||||
rebuildList()
|
||||
}
|
||||
|
||||
fun openGamemenu(it: UIHandler) {
|
||||
INGAME.setTooltipMessage(null)
|
||||
transitionPanel.forcePosition(2)
|
||||
catBar.setSelectedPanel(2)
|
||||
it.setAsOpen()
|
||||
}
|
||||
|
||||
fun openCrafting(it: UIHandler) {
|
||||
INGAME.setTooltipMessage(null)
|
||||
transitionPanel.forcePosition(0)
|
||||
catBar.setSelectedPanel(0)
|
||||
transitionalCraftingUI.resetUI()
|
||||
it.setAsOpen()
|
||||
}
|
||||
|
||||
override fun show() {
|
||||
|
||||
Reference in New Issue
Block a user