more codes

This commit is contained in:
minjaesong
2025-01-19 19:54:40 +09:00
parent 3d34b9162b
commit ed9d8cffd6
8 changed files with 192 additions and 17 deletions

View File

@@ -132,8 +132,8 @@ id;classname;tags
320;net.torvald.terrarum.modulebasegame.gameitems.ItemWorldPortal;FIXTURE,STATION
# industrial
#2048;net.torvald.terrarum.modulebasegame.gameitems.ItemInductionMotor;FIXTURE,POWER,KINETIC
#2049;net.torvald.terrarum.modulebasegame.gameitems.ItemGearbox;FIXTURE,POWER,KINETIC
2048;net.torvald.terrarum.modulebasegame.gameitems.ItemInductionMotor;FIXTURE,POWER,KINETIC
2049;net.torvald.terrarum.modulebasegame.gameitems.ItemGearbox;FIXTURE,POWER,KINETIC
# data storage (discs; 256)
# 32768 is a reserved number for a blank disc
@@ -148,7 +148,7 @@ id;classname;tags
32777;net.torvald.terrarum.modulebasegame.gameitems.MusicDisc09;MUSIC,PHONO
# data storage (tapestries; 256)
#33024;net.torvald.terrarum.modulebasegame.gameitems.ItemTapestry;FIXTURE,BASEOBJECT
33024;net.torvald.terrarum.modulebasegame.gameitems.ItemTapestry;FIXTURE,BASEOBJECT
# data storage (text signs; 256)
33280;net.torvald.terrarum.modulebasegame.gameitems.ItemTextSignCopper;FIXTURE,BASEOBJECT
@@ -181,3 +181,4 @@ id;classname;tags
# reserved for debug items
#16777216;net.torvald.terrarum.modulebasegame.gameitems.ItemBottomlessWaterBucket;DEBUG,TOOL
#16777217;net.torvald.terrarum.modulebasegame.gameitems.ItemBottomlessLavaBucket;DEBUG,TOOL
16777472;net.torvald.terrarum.modulebasegame.gameitems.ItemMysteriousATM;DEBUG
1 id classname tags
132 32774 net.torvald.terrarum.modulebasegame.gameitems.MusicDisc06 MUSIC,PHONO
133 32775 net.torvald.terrarum.modulebasegame.gameitems.MusicDisc07 MUSIC,PHONO
134 32776 net.torvald.terrarum.modulebasegame.gameitems.MusicDisc08 MUSIC,PHONO
135 32777 net.torvald.terrarum.modulebasegame.gameitems.MusicDisc09 MUSIC,PHONO
136 # data storage (tapestries 256)
137 #33024 33024 net.torvald.terrarum.modulebasegame.gameitems.ItemTapestry FIXTURE,BASEOBJECT
138 # data storage (text signs 256)
139 33280 net.torvald.terrarum.modulebasegame.gameitems.ItemTextSignCopper FIXTURE,BASEOBJECT
148 # 100300h..1003FFh : container type 3 x Fluid type 0..255
149 # 100400h..1004FFh : container type 4 x Fluid type 0..255
150 # 100500h..1005FFh : container type 5 x Fluid type 0..255
151 # ...
152 # 10FF00h..10FFFFh : container type 255 x Fluid type 0..255
153 1048576 net.torvald.terrarum.modulebasegame.gameitems.ItemBucketWooden00 FLUIDSTORAGE,OPENSTORAGE,NOEXTREMETHERM,FLUIDSTORAGEEMPTY
154 1048577 net.torvald.terrarum.modulebasegame.gameitems.ItemBucketWooden01 FLUIDSTORAGE,OPENSTORAGE,NOEXTREMETHERM
181
182
183
184

View File

@@ -1,3 +1,4 @@
## this file is auto-generated using Prebuild.kt ##
# The name that will be displayed in-game
propername=Terrarum
@@ -44,10 +45,10 @@ package=net.torvald.terrarum.modulebasegame
entrypoint=net.torvald.terrarum.modulebasegame.EntryPoint
# Release date in YYYY-MM-DD
releasedate=2024-03-28
releasedate=2025-01-19
# The version, must follow Semver 2.0.0 scheme (https://semver.org/)
version=0.4.2
version=0.5.2
# External JAR that the module is compiled. If your module requires yet another library, the JAR must be compiled as a "Fatjar";
# Due to security reasons, loading an arbitrary JAR is not allowed.

View File

@@ -0,0 +1,44 @@
package net.torvald.terrarum.modulebasegame.gameactors
import net.torvald.terrarum.TerrarumAppConfiguration.TILE_SIZE
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.UIRedeemCodeMachine
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
import org.dyn4j.geometry.Vector2
/**
* Created by minjaesong on 2025-01-19.
*/
class FixtureMysteriousATM : Electric {
constructor() : super(
BlockBox(BlockBox.ALLOW_MOVE_DOWN, 2, 2),
nameFun = { Lang["ITEM_MYSTERIOUS_ATM"] },
mainUI = UIRedeemCodeMachine()
)
init {
val itemImage = FixtureItemBase.getItemImageFromSingleImage("basegame", "sprites/fixtures/mysterious_atm.tga")
val itemImage2 = FixtureItemBase.getItemImageFromSingleImage("basegame", "sprites/fixtures/mysterious_atm_emsv.tga")
density = 2800.0
setHitboxDimension(TILE_SIZE * 2, TILE_SIZE * 2, 0, 0)
makeNewSprite(TextureRegionPack(itemImage.texture, TILE_SIZE * 2, TILE_SIZE * 2)).let {
it.setRowsAndFrames(1,1)
}
makeNewSpriteEmissive(TextureRegionPack(itemImage2.texture, TILE_SIZE * 2, TILE_SIZE * 2)).let {
it.setRowsAndFrames(1,1)
}
actorValue[AVKey.BASEMASS] = 2000.0
setWireSinkAt(0, 2, "appliance_power")
setWireConsumptionAt(0, 2, Vector2(100.0, 0.0))
}
}

View File

@@ -0,0 +1,21 @@
package net.torvald.terrarum.modulebasegame.gameitems
import net.torvald.terrarum.gameitems.ItemID
/**
* Created by minjaesong on 2025-01-19.
*/
class ItemMysteriousATM(originalID: ItemID) : FixtureItemBase(originalID, "net.torvald.terrarum.modulebasegame.gameactors.FixtureMysteriousATM") {
override var baseMass = 2000.0
override val canBeDynamic = false
override val materialId = ""
init {
itemImage = FixtureItemBase.getItemImageFromSingleImage("basegame", "sprites/fixtures/mysterious_atm.tga")
}
// it's supposed to be turned off when you pick it up
// @Transient override val itemImageEmissive = FixtureItemBase.getItemImageFromSingleImage("basegame", "sprites/fixtures/mysterious_atm_emsv.tga")
override var originalName = "ITEM_MYSTERIOUS_ATM"
}

View File

@@ -0,0 +1,76 @@
package net.torvald.terrarum.modulebasegame.ui
import com.badlogic.gdx.Input
import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.graphics.OrthographicCamera
import com.badlogic.gdx.graphics.g2d.SpriteBatch
import net.torvald.terrarum.App
import net.torvald.terrarum.ControlPresets
import net.torvald.terrarum.INGAME
import net.torvald.terrarum.RunningEnvironment
import net.torvald.terrarum.langpack.Lang
import net.torvald.terrarum.ui.Toolkit
import net.torvald.terrarum.ui.UICanvas
import net.torvald.terrarum.ui.UIItemInventoryElemSimple
import net.torvald.terrarum.ui.UIItemRedeemCodeArea
import net.torvald.unicode.getKeycapPC
/**
* Created by minjaesong on 2025-01-19.
*/
class UIRedeemCodeMachine : UICanvas(
toggleKeyLiteral = null, // no Q key to close
toggleButtonLiteral = "control_gamepad_start",
) {
override var width = Toolkit.drawWidth
override var height = App.scr.height
val inputPanel = UIItemRedeemCodeArea(this,
(Toolkit.drawWidth - UIItemRedeemCodeArea.estimateWidth(14)) / 2,
App.scr.halfh - UIItemRedeemCodeArea.estimateHeight(4) - 48,
14, 4)
init {
addUIitem(inputPanel)
}
private val controlHelp: String
get() = if (App.environment == RunningEnvironment.PC)
"${getKeycapPC(Input.Keys.ESCAPE)} ${Lang["GAME_ACTION_CLOSE"]}"
else
"${App.gamepadLabelStart} ${Lang["GAME_ACTION_CLOSE"]} "
override fun updateImpl(delta: Float) {
uiItems.forEach { it.update(delta) }
}
private val halfSlotOffset = (UIItemInventoryElemSimple.height + UIItemInventoryItemGrid.listGap) / 2
private val thisOffsetX = UIInventoryFull.INVENTORY_CELLS_OFFSET_X() + UIItemInventoryElemSimple.height + UIItemInventoryItemGrid.listGap - halfSlotOffset
private val yEnd = -UIInventoryFull.YPOS_CORRECTION + (App.scr.height + UIInventoryFull.internalHeight).div(2).toFloat()
override fun renderImpl(frameDelta: Float, batch: SpriteBatch, camera: OrthographicCamera) {
UIInventoryFull.drawBackground(batch, 1f)
uiItems.forEach { it.render(frameDelta, batch, camera) }
val controlHintXPos = thisOffsetX + 2f
App.fontGame.draw(batch, controlHelp, controlHintXPos, yEnd - 20)
}
override fun doOpening(delta: Float) {
super.doOpening(delta)
INGAME.pause()
}
override fun doClosing(delta: Float) {
super.doClosing(delta)
INGAME.resume()
}
override fun dispose() {
}
}

View File

@@ -167,6 +167,10 @@ abstract class UICanvas(
/**
* Do not modify ui.handler.openCloseCounter here.
*
* When you override this function, you usually append either of following functions:
* - `INGAME.pause()` to literally pause the game and disable the player control
* - `INGAME.disablePlayerControl()` to not pause the game but still disable the player control
*/
open fun doOpening(delta: Float) {
handler.opacity = handler.openCloseCounter / openCloseTime
@@ -175,6 +179,10 @@ abstract class UICanvas(
/**
* Do not modify ui.handler.openCloseCounter here.
*
* When you override this function, you usually append either of following functions:
* - `INGAME.resume()` if your `doOpening()` paused the game
* - `INGAME.resumePlayerControl()` if `doOpening()` disabled the player control
*/
open fun doClosing(delta: Float) {
handler.opacity = (openCloseTime - handler.openCloseCounter) / openCloseTime

View File

@@ -21,11 +21,16 @@ class UIItemRedeemCodeArea(
) : UIItem(parentUI, initialX, initialY) {
override val width = textCols * CELL_W
override val height = textRows * CELL_H
companion object {
private val CELL_W = 16
private val CELL_H = 24
override val width = textCols * CELL_W
override val height = textRows * CELL_H
fun estimateWidth(cols: Int) = CELL_W * cols
fun estimateHeight(rows: Int) = CELL_H * rows
}
init {
CommonResourcePool.addToLoadingList("spritesheet:terrarum_redeem_code_form") {
@@ -75,6 +80,14 @@ class UIItemRedeemCodeArea(
private val caretCol = Toolkit.Theme.COL_SELECTED
private var cursorBlinkTimer = 0f
override fun update(delta: Float) {
super.update(delta)
cursorBlinkTimer += delta
if (cursorBlinkTimer >= 1f) cursorBlinkTimer -= 1f
}
override fun render(frameDelta: Float, batch: SpriteBatch, camera: OrthographicCamera) {
super.render(frameDelta, batch, camera)
@@ -84,6 +97,10 @@ class UIItemRedeemCodeArea(
batch.color = lineCol
Toolkit.drawBoxBorder(batch, posX, posY, width, height)
// draw cells back
batch.color = Toolkit.Theme.COL_CELL_FILL
Toolkit.fillArea(batch, posX, posY, CELL_W * textCols, CELL_H * textRows)
// draw cells
batch.color = Toolkit.Theme.COL_INACTIVE
for (y in 0 until textRows) {
@@ -100,7 +117,7 @@ class UIItemRedeemCodeArea(
for (x in 0 until textCols) {
BigAlphNum.draw(
batch,
"${inputText.getOrElse(y * textRows + x) { 'A' }}",
"${inputText.getOrElse(y * textRows + x) { ' ' }}",
posX + CELL_W * x + 2f,
posY + CELL_H * y + 4f
)
@@ -108,13 +125,20 @@ class UIItemRedeemCodeArea(
}
// draw caret
if (cursorBlinkTimer < 0.5f) {
batch.color = caretCol
val cx = textCaret % textCols
val cy = textCaret / textCols
Toolkit.drawStraightLine(batch,
Toolkit.drawStraightLine(
batch,
posX + CELL_W * cx - 1,
posY + CELL_H * cy + 1,
posY + CELL_H * cy + 1 + 20, 2, true)
posY + CELL_H * cy + 1 + 20, 2, true
)
}
batch.color = Color.WHITE
}
override fun dispose() {