mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-11 02:54:04 +09:00
world portal wip
This commit is contained in:
@@ -14,4 +14,6 @@ id;classname
|
|||||||
258;net.torvald.terrarum.modulebasegame.gameitems.ItemSwingingDoorBirch
|
258;net.torvald.terrarum.modulebasegame.gameitems.ItemSwingingDoorBirch
|
||||||
259;net.torvald.terrarum.modulebasegame.gameitems.ItemSwingingDoorRosewood
|
259;net.torvald.terrarum.modulebasegame.gameitems.ItemSwingingDoorRosewood
|
||||||
|
|
||||||
|
320;net.torvald.terrarum.modulebasegame.gameitems.ItemWorldPortal
|
||||||
|
|
||||||
999999;net.torvald.terrarum.modulebasegame.gameitems.ItemTapestry
|
999999;net.torvald.terrarum.modulebasegame.gameitems.ItemTapestry
|
||||||
|
|||||||
|
BIN
assets/mods/basegame/sprites/fixtures/portal_device.tga
LFS
Normal file
BIN
assets/mods/basegame/sprites/fixtures/portal_device.tga
LFS
Normal file
Binary file not shown.
@@ -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.
|
// what if there's multiple of such fixtures? whatever, you are supposed to DISALLOW such situation.
|
||||||
for (kk in actorsUnderMouse.indices) {
|
for (kk in actorsUnderMouse.indices) {
|
||||||
if (mouseInInteractableRange(actor) {
|
if (mouseInInteractableRange(actor) {
|
||||||
actorsUnderMouse[kk].mainUI?.let {
|
actorsUnderMouse[kk].mainUI?.let {
|
||||||
uiOpened = true
|
uiOpened = true
|
||||||
|
|
||||||
// property 'uiFixture' is a dedicated property that the TerrarumIngame recognises.
|
// property 'uiFixture' is a dedicated property that the TerrarumIngame recognises.
|
||||||
// when it's not null, the UI will be updated and rendered
|
// 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
|
// when the UI is closed, it'll be replaced with a null value
|
||||||
uiFixture = it
|
uiFixture = it
|
||||||
it.setPosition(
|
it.setPosition(
|
||||||
(Toolkit.drawWidth - it.width) / 4,
|
(Toolkit.drawWidth - it.width) / 4,
|
||||||
(App.scr.height - it.height) / 4 // what the fuck?
|
(App.scr.height - it.height) / 4 // what the fuck?
|
||||||
)
|
)
|
||||||
it.setAsOpen()
|
it.setAsOpen()
|
||||||
}
|
}
|
||||||
0L
|
0L
|
||||||
} == 0L) break
|
} == 0L) break
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!uiOpened) {
|
if (!uiOpened) {
|
||||||
|
|||||||
@@ -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).***
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -98,6 +98,8 @@ object PlayerBuilderSigrid {
|
|||||||
inventory.add("item@basegame:258", 995) // doors
|
inventory.add("item@basegame:258", 995) // doors
|
||||||
inventory.add("item@basegame:259", 995) // doors
|
inventory.add("item@basegame:259", 995) // doors
|
||||||
|
|
||||||
|
inventory.add("item@basegame:320", 1) // portal
|
||||||
|
|
||||||
WireCodex.getAll().forEach {
|
WireCodex.getAll().forEach {
|
||||||
try {
|
try {
|
||||||
inventory.add(it.id, 9995)
|
inventory.add(it.id, 9995)
|
||||||
|
|||||||
@@ -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
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -18,7 +18,10 @@ import net.torvald.terrarum.ui.UIItemHorizontalFadeSlide
|
|||||||
*
|
*
|
||||||
* Created by minjaesong on 2023-05-19.
|
* 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 width = App.scr.width
|
||||||
override var height = App.scr.height
|
override var height = App.scr.height
|
||||||
@@ -97,11 +100,13 @@ class UIWorldPortal : UICanvas() {
|
|||||||
override fun doOpening(delta: Float) {
|
override fun doOpening(delta: Float) {
|
||||||
super.doOpening(delta)
|
super.doOpening(delta)
|
||||||
resetUI()
|
resetUI()
|
||||||
|
INGAME.pause()
|
||||||
INGAME.setTooltipMessage(null)
|
INGAME.setTooltipMessage(null)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun doClosing(delta: Float) {
|
override fun doClosing(delta: Float) {
|
||||||
super.doClosing(delta)
|
super.doClosing(delta)
|
||||||
|
INGAME.resume()
|
||||||
INGAME.setTooltipMessage(null)
|
INGAME.setTooltipMessage(null)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ class UIWorldPortalListing(val full: UIWorldPortal) : UICanvas() {
|
|||||||
private val buttonHeight = 24
|
private val buttonHeight = 24
|
||||||
private val gridGap = listGap
|
private val gridGap = listGap
|
||||||
|
|
||||||
private var worldList: List<Pair<UUID, DiskSkimmer>>
|
private val worldList = ArrayList<Pair<UUID, DiskSkimmer>>()
|
||||||
private var selectedWorld: DiskSkimmer? = null
|
private var selectedWorld: DiskSkimmer? = null
|
||||||
|
|
||||||
|
|
||||||
@@ -70,13 +70,15 @@ class UIWorldPortalListing(val full: UIWorldPortal) : UICanvas() {
|
|||||||
|
|
||||||
addUIitem(buttonReset)
|
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) {
|
override fun updateUI(delta: Float) {
|
||||||
|
|
||||||
@@ -84,24 +86,22 @@ class UIWorldPortalListing(val full: UIWorldPortal) : UICanvas() {
|
|||||||
|
|
||||||
override fun renderUI(batch: SpriteBatch, camera: Camera) {
|
override fun renderUI(batch: SpriteBatch, camera: Camera) {
|
||||||
|
|
||||||
batch.inUse {
|
|
||||||
|
|
||||||
// draw background //
|
// draw background //
|
||||||
// screencap panel
|
// screencap panel
|
||||||
batch.color = cellCol
|
batch.color = cellCol
|
||||||
Toolkit.fillArea(batch, hx - thumbw - gridGap/2, y, thumbw, thumbh)
|
Toolkit.fillArea(batch, hx - thumbw - gridGap/2, y, thumbw, thumbh)
|
||||||
|
|
||||||
|
|
||||||
// draw border //
|
// draw border //
|
||||||
// screencap panel
|
// screencap panel
|
||||||
batch.color = highlightCol
|
batch.color = highlightCol
|
||||||
Toolkit.drawBoxBorder(batch, hx - thumbw - gridGap/2 - 1, y - 1, thumbw + 2, thumbh + 2)
|
Toolkit.drawBoxBorder(batch, hx - thumbw - gridGap/2 - 1, y - 1, thumbw + 2, thumbh + 2)
|
||||||
// memory gauge
|
// memory gauge
|
||||||
Toolkit.drawBoxBorder(batch, hx - 330 - gridGap/2 - 1, y + listHeight - 1, 240 + 2, buttonHeight + 2)
|
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) }
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -154,6 +154,7 @@ abstract class UICanvas(
|
|||||||
*/
|
*/
|
||||||
open fun doOpening(delta: Float) {
|
open fun doOpening(delta: Float) {
|
||||||
handler.opacity = handler.openCloseCounter / openCloseTime
|
handler.opacity = handler.openCloseCounter / openCloseTime
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
BIN
work_files/graphics/sprites/fixtures/crops_-_part_of_1x3_fixtures_collection.png
LFS
Normal file
BIN
work_files/graphics/sprites/fixtures/crops_-_part_of_1x3_fixtures_collection.png
LFS
Normal file
Binary file not shown.
BIN
work_files/graphics/sprites/fixtures/portal_device.kra
LFS
Normal file
BIN
work_files/graphics/sprites/fixtures/portal_device.kra
LFS
Normal file
Binary file not shown.
Reference in New Issue
Block a user