mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-07 12:21:52 +09:00
world portal wip
This commit is contained in:
@@ -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
|
||||
|
||||
|
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.
|
||||
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) {
|
||||
|
||||
@@ -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:259", 995) // doors
|
||||
|
||||
inventory.add("item@basegame:320", 1) // portal
|
||||
|
||||
WireCodex.getAll().forEach {
|
||||
try {
|
||||
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.
|
||||
*/
|
||||
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)
|
||||
}
|
||||
|
||||
|
||||
@@ -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) }
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -154,6 +154,7 @@ abstract class UICanvas(
|
||||
*/
|
||||
open fun doOpening(delta: Float) {
|
||||
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