world portal wip

This commit is contained in:
minjaesong
2023-05-28 18:41:21 +09:00
parent a3ecd4a4f4
commit ef6f39632d
11 changed files with 121 additions and 33 deletions

View File

@@ -14,4 +14,6 @@ id;classname
258;net.torvald.terrarum.modulebasegame.gameitems.ItemSwingingDoorBirch
259;net.torvald.terrarum.modulebasegame.gameitems.ItemSwingingDoorRosewood
320;net.torvald.terrarum.modulebasegame.gameitems.ItemWorldPortal
999999;net.torvald.terrarum.modulebasegame.gameitems.ItemTapestry
1 id classname
14 259 net.torvald.terrarum.modulebasegame.gameitems.ItemSwingingDoorRosewood
15 999999 320 net.torvald.terrarum.modulebasegame.gameitems.ItemTapestry net.torvald.terrarum.modulebasegame.gameitems.ItemWorldPortal
16 999999 net.torvald.terrarum.modulebasegame.gameitems.ItemTapestry
17
18
19

Binary file not shown.

View File

@@ -654,21 +654,21 @@ 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].mainUI?.let {
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()
}
0L
} == 0L) break
// 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()
}
0L
} == 0L) break
}
if (!uiOpened) {

View File

@@ -0,0 +1,40 @@
package net.torvald.terrarum.modulebasegame.gameactors
import net.torvald.terrarum.gameactors.AVKey
import net.torvald.terrarum.langpack.Lang
import net.torvald.terrarum.modulebasegame.gameitems.FixtureItemBase
import net.torvald.terrarum.modulebasegame.ui.UIWorldPortal
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
/**
* Created by minjaesong on 2023-05-28.
*/
class FixtureWorldPortal : FixtureBase {
constructor() : super(
BlockBox(BlockBox.NO_COLLISION, 5, 2),
nameFun = { Lang["ITEM_WORLD_PORTAL"] },
mainUI = UIWorldPortal()
) {
// TODO do something with (mainUI as UIWorldPortal).***
}
init {
val itemImage = FixtureItemBase.getItemImageFromSheet("basegame", "sprites/fixtures/portal_device.tga", 80, 32)
density = 2900.0
setHitboxDimension(80, 32, 0, 0)
makeNewSprite(TextureRegionPack(itemImage.texture, 80, 32)).let {
it.setRowsAndFrames(1,1)
}
actorValue[AVKey.BASEMASS] = FixtureLogicSignalEmitter.MASS
}
override fun reload() {
super.reload()
// TODO do something with (mainUI as UIWorldPortal).***
}
}

View File

@@ -98,6 +98,8 @@ object PlayerBuilderSigrid {
inventory.add("item@basegame:258", 995) // doors
inventory.add("item@basegame:259", 995) // doors
inventory.add("item@basegame:320", 1) // portal
WireCodex.getAll().forEach {
try {
inventory.add(it.id, 9995)

View File

@@ -0,0 +1,29 @@
package net.torvald.terrarum.modulebasegame.gameitems
import com.badlogic.gdx.graphics.g2d.TextureRegion
import net.torvald.terrarum.gameitems.ItemID
import net.torvald.terrarum.modulebasegame.gameactors.FixtureTikiTorch
/**
* Created by minjaesong on 2023-05-28.
*/
class ItemWorldPortal(originalID: ItemID) : FixtureItemBase(originalID, "net.torvald.terrarum.modulebasegame.gameactors.FixtureWorldPortal") {
override var dynamicID: ItemID = originalID
override val originalName = "ITEM_WORLD_PORTAL"
override var baseMass = 6000.0
override var stackable = true
override var inventoryCategory = Category.MISC
override val isUnique = false
override val isDynamic = false
override val materialId = ""
override val itemImage: TextureRegion
get() = getItemImageFromSheet("basegame", "sprites/fixtures/portal_device.tga", 80, 32)
override var baseToolSize: Double? = baseMass
init {
equipPosition = EquipPosition.HAND_GRIP
}
}

View File

@@ -18,7 +18,10 @@ import net.torvald.terrarum.ui.UIItemHorizontalFadeSlide
*
* Created by minjaesong on 2023-05-19.
*/
class UIWorldPortal : UICanvas() {
class UIWorldPortal : UICanvas(
toggleKeyLiteral = App.getConfigInt("control_key_inventory"),
toggleButtonLiteral = App.getConfigInt("control_gamepad_start"),
) {
override var width = App.scr.width
override var height = App.scr.height
@@ -97,11 +100,13 @@ class UIWorldPortal : UICanvas() {
override fun doOpening(delta: Float) {
super.doOpening(delta)
resetUI()
INGAME.pause()
INGAME.setTooltipMessage(null)
}
override fun doClosing(delta: Float) {
super.doClosing(delta)
INGAME.resume()
INGAME.setTooltipMessage(null)
}

View File

@@ -30,7 +30,7 @@ class UIWorldPortalListing(val full: UIWorldPortal) : UICanvas() {
private val buttonHeight = 24
private val gridGap = listGap
private var worldList: List<Pair<UUID, DiskSkimmer>>
private val worldList = ArrayList<Pair<UUID, DiskSkimmer>>()
private var selectedWorld: DiskSkimmer? = null
@@ -70,13 +70,15 @@ class UIWorldPortalListing(val full: UIWorldPortal) : UICanvas() {
addUIitem(buttonReset)
worldList = (INGAME.actorGamer.actorValue.getAsString(AVKey.WORLD_PORTAL_DICT) ?: "").split(",").map {
it.ascii85toUUID().let { it to App.savegameWorlds[it] }
}.filter { it.second != null } as List<Pair<UUID, DiskSkimmer>>
}
override fun show() {
worldList.clear()
worldList.addAll((INGAME.actorGamer.actorValue.getAsString(AVKey.WORLD_PORTAL_DICT) ?: "").split(",").filter { it.isNotBlank() }.map {
it.ascii85toUUID().let { it to App.savegameWorlds[it] }
}.filter { it.second != null } as List<Pair<UUID, DiskSkimmer>>)
}
override fun updateUI(delta: Float) {
@@ -84,24 +86,22 @@ class UIWorldPortalListing(val full: UIWorldPortal) : UICanvas() {
override fun renderUI(batch: SpriteBatch, camera: Camera) {
batch.inUse {
// draw background //
// screencap panel
batch.color = cellCol
Toolkit.fillArea(batch, hx - thumbw - gridGap/2, y, thumbw, thumbh)
// draw background //
// screencap panel
batch.color = cellCol
Toolkit.fillArea(batch, hx - thumbw - gridGap/2, y, thumbw, thumbh)
// draw border //
// screencap panel
batch.color = highlightCol
Toolkit.drawBoxBorder(batch, hx - thumbw - gridGap/2 - 1, y - 1, thumbw + 2, thumbh + 2)
// memory gauge
Toolkit.drawBoxBorder(batch, hx - 330 - gridGap/2 - 1, y + listHeight - 1, 240 + 2, buttonHeight + 2)
// draw border //
// screencap panel
batch.color = highlightCol
Toolkit.drawBoxBorder(batch, hx - thumbw - gridGap/2 - 1, y - 1, thumbw + 2, thumbh + 2)
// memory gauge
Toolkit.drawBoxBorder(batch, hx - 330 - gridGap/2 - 1, y + listHeight - 1, 240 + 2, buttonHeight + 2)
uiItems.forEach { it.render(batch, camera) }
}
uiItems.forEach { it.render(batch, camera) }
}

View File

@@ -154,6 +154,7 @@ abstract class UICanvas(
*/
open fun doOpening(delta: Float) {
handler.opacity = handler.openCloseCounter / openCloseTime
}
/**

Binary file not shown.