wider module info cells

This commit is contained in:
minjaesong
2022-02-24 14:55:57 +09:00
parent 8ee221b93d
commit 2e3a9e6fa0
6 changed files with 50 additions and 21 deletions

View File

@@ -5,6 +5,10 @@
<element id="module-output" name="ModuleComputers" /> <element id="module-output" name="ModuleComputers" />
<element id="extracted-dir" path="$PROJECT_DIR$/ModuleComputers/lib/TerrarumTSVM.jar" path-in-jar="/" /> <element id="extracted-dir" path="$PROJECT_DIR$/ModuleComputers/lib/TerrarumTSVM.jar" path-in-jar="/" />
<element id="extracted-dir" path="$PROJECT_DIR$/ModuleComputers/lib/TerranVirtualDisk.jar" path-in-jar="/" /> <element id="extracted-dir" path="$PROJECT_DIR$/ModuleComputers/lib/TerranVirtualDisk.jar" path-in-jar="/" />
<element id="extracted-dir" path="$PROJECT_DIR$/lib/kotlinx-coroutines-core-1.4.1.jar" path-in-jar="/" />
<element id="extracted-dir" path="$PROJECT_DIR$/lib/kotlin-stdlib-1.4.0.jar" path-in-jar="/" />
<element id="extracted-dir" path="$PROJECT_DIR$/lib/annotations-13.0.jar" path-in-jar="/" />
<element id="extracted-dir" path="$PROJECT_DIR$/lib/kotlin-stdlib-common-1.4.0.jar" path-in-jar="/" />
</root> </root>
</artifact> </artifact>
</component> </component>

View File

@@ -44,17 +44,26 @@ class ItemWearableWorldRadar(originalID: String) : GameItem(originalID) {
VMProgramRom(ModMgr.getGdxFile("dwarventech", "bios/pipboot.rom").path()), VMProgramRom(ModMgr.getGdxFile("dwarventech", "bios/pipboot.rom").path()),
VMProgramRom(ModMgr.getGdxFile("dwarventech", "bios/pipcode.bas").path()) VMProgramRom(ModMgr.getGdxFile("dwarventech", "bios/pipcode.bas").path())
)) ))
private val vmRunner: VMRunner
private val coroutineJob: Job
private val ui = WearableWorldRadarUI(vm) private val ui = WearableWorldRadarUI(vm)
// FIXME initialise computer stuff when the Item is first used, not when it's registered by the Modmgr // FIXME initialise computer stuff when the Item is first used, not when it's registered by the Modmgr
init { init {
super.equipPosition = EquipPosition.HAND_GRIP super.equipPosition = EquipPosition.HAND_GRIP
}
private var booted = false
private var disposed = false
private lateinit var vmRunner: VMRunner
private lateinit var coroutineJob: Job
init {
App.disposables.add(ui)
}
private fun boot() {
vm.getIO().blockTransferPorts[1].attachDevice(WorldRadar()) vm.getIO().blockTransferPorts[1].attachDevice(WorldRadar())
vm.peripheralTable[1] = PeripheralEntry( vm.peripheralTable[1] = PeripheralEntry(
ExtDisp(vm, 160, 140), 32768, 1, 0 ExtDisp(vm, 160, 140), 32768, 1, 0
) )
// MMIO stops working when somethingStream is not defined // MMIO stops working when somethingStream is not defined
@@ -68,20 +77,32 @@ class ItemWearableWorldRadar(originalID: String) : GameItem(originalID) {
} }
INGAME.disposables.add(Disposable { INGAME.disposables.add(Disposable {
closeVM()
})
booted = true
}
private fun closeVM() {
if (!disposed) {
vmRunner.close() vmRunner.close()
coroutineJob.cancel("item disposal") coroutineJob.cancel("item disposal")
vm.dispose() vm.dispose()
}) }
App.disposables.add(ui) disposed = true
booted = false
} }
override fun effectWhileEquipped(actor: ActorWithBody, delta: Float) { override fun effectWhileEquipped(actor: ActorWithBody, delta: Float) {
if (!booted) {
booted = true
boot()
}
(Terrarum.ingame!! as TerrarumIngame).wearableDeviceUI = ui (Terrarum.ingame!! as TerrarumIngame).wearableDeviceUI = ui
} }
override fun effectOnUnequip(actor: ActorWithBody, delta: Float) { override fun effectOnUnequip(actor: ActorWithBody, delta: Float) {
(Terrarum.ingame!! as TerrarumIngame).wearableDeviceUI = null (Terrarum.ingame!! as TerrarumIngame).wearableDeviceUI = null
closeVM()
} }
} }

View File

@@ -350,6 +350,7 @@ object ModMgr {
FileSystems.getDefault().getPath("$modDirExternal/$module/$path").toFile() FileSystems.getDefault().getPath("$modDirExternal/$module/$path").toFile()
} }
fun hasFile(module: String, path: String): Boolean { fun hasFile(module: String, path: String): Boolean {
if (!moduleInfo.containsKey(module)) return false
return getFile(module, path).exists() return getFile(module, path).exists()
} }
fun getFiles(module: String, path: String): Array<File> { fun getFiles(module: String, path: String): Array<File> {

View File

@@ -87,7 +87,7 @@ class NoModuleDefaultTitlescreen(batch: FlippingSpriteBatch) : IngameInstance(ba
App.fontGame.draw(it, pathText, pathButtonX, pathButtonY) App.fontGame.draw(it, pathText, pathButtonX, pathButtonY)
} }
if (Gdx.input.isKeyPressed(Keys.ESCAPE)) gamemode = 1 // if (Gdx.input.isKeyPressed(Keys.ESCAPE)) gamemode = 1
} }
else if (gamemode == 1) { else if (gamemode == 1) {

View File

@@ -16,8 +16,8 @@ import net.torvald.terrarum.ui.UICanvas
import net.torvald.terrarum.ui.UIItemModuleInfoCell import net.torvald.terrarum.ui.UIItemModuleInfoCell
import kotlin.math.roundToInt import kotlin.math.roundToInt
val MODULEINFO_CELL_WIDTH = 480 val MODULEINFO_CELL_WIDTH = 540
val MODULEINFO_CELL_HEIGHT = 48 val MODULEINFO_CELL_HEIGHT = 24*3
/** /**
* Created by minjaesong on 2017-08-01. * Created by minjaesong on 2017-08-01.

View File

@@ -38,6 +38,7 @@ class UIItemModuleInfoCell(
private val modVer = modProp.version private val modVer = modProp.version
private val modDate = modProp.releaseDate private val modDate = modProp.releaseDate
private val modAuthor = modProp.author private val modAuthor = modProp.author
private val modDesc = modProp.description
init { init {
modIcon.flip(false, false) modIcon.flip(false, false)
@@ -56,40 +57,42 @@ class UIItemModuleInfoCell(
private val ccZero2 = App.fontGame.toColorCode(12,12,12) private val ccZero2 = App.fontGame.toColorCode(12,12,12)
private val ccNum = App.fontGame.toColorCode(15,14,6) private val ccNum = App.fontGame.toColorCode(15,14,6)
private val ccNum2 = App.fontGame.toColorCode(12,11,4) private val ccNum2 = App.fontGame.toColorCode(12,11,4)
private val ccDesc = App.fontGame.toColorCode(13,13,13)
override fun render(batch: SpriteBatch, camera: Camera) { override fun render(batch: SpriteBatch, camera: Camera) {
blendNormal(batch) blendNormal(batch)
batch.color = Toolkit.Theme.COL_CELL_FILL batch.color = Toolkit.Theme.COL_CELL_FILL
Toolkit.fillArea(batch, initialX, initialY, 32, 48) Toolkit.fillArea(batch, initialX, initialY, 32, height)
Toolkit.fillArea(batch, initialX + 35, initialY, 48, 48) Toolkit.fillArea(batch, initialX + 35, initialY, 48, height)
Toolkit.fillArea(batch, initialX + 86, initialY, width - 86, 48) Toolkit.fillArea(batch, initialX + 86, initialY, width - 86, height)
batch.color = Toolkit.Theme.COL_INACTIVE batch.color = Toolkit.Theme.COL_INACTIVE
Toolkit.drawBoxBorder(batch, initialX - 1, initialY - 1, width + 2, height + 2) Toolkit.drawBoxBorder(batch, initialX - 1, initialY - 1, width + 2, height + 2)
Toolkit.fillArea(batch, initialX + 33, initialY, 1, 48) Toolkit.fillArea(batch, initialX + 33, initialY, 1, height)
Toolkit.fillArea(batch, initialX + 84, initialY, 1, 48) Toolkit.fillArea(batch, initialX + 84, initialY, 1, height)
if (order < 9) if (order < 9)
App.fontSmallNumbers.draw(batch, "${order+1}", initialX + 13f, initialY + 18f) App.fontSmallNumbers.draw(batch, "${order+1}", initialX + 13f, initialY + 18f + 12f)
else if (order < 99) else if (order < 99)
App.fontSmallNumbers.draw(batch, "${order+1}", initialX + 9f, initialY + 18f) App.fontSmallNumbers.draw(batch, "${order+1}", initialX + 9f, initialY + 18f + 12f)
else else
App.fontSmallNumbers.draw(batch, "${order+1}", initialX + 6f, initialY + 18f) App.fontSmallNumbers.draw(batch, "${order+1}", initialX + 6f, initialY + 18f + 12f)
batch.color = Color.WHITE batch.color = Color.WHITE
if (modErrored) { if (modErrored) {
batch.shader = App.shaderGhastlyWhite batch.shader = App.shaderGhastlyWhite
batch.color = Color.LIGHT_GRAY batch.color = Color.LIGHT_GRAY
} }
batch.draw(modIcon, initialX + 35f, initialY.toFloat()) batch.draw(modIcon, initialX + 35f, initialY + 12f)
batch.shader = null batch.shader = null
batch.color = Color.WHITE batch.color = Color.WHITE
App.fontGame.draw(batch, "$ccZero${modName.toUpperCase()}$ccNum $modVer", initialX + 86f + 6f, initialY + 2f) App.fontGame.draw(batch, "$ccZero${modName.toUpperCase()}$ccNum $modVer", initialX + 86f + 3f, initialY + 2f)
App.fontGame.draw(batch, "$ccZero2$modAuthor$ccNum2 $modDate", initialX + 86f + 6f, initialY + 26f) App.fontGame.draw(batch, "$ccDesc$modDesc", initialX + 86f + 3f, initialY + 26f)
App.fontGame.draw(batch, "$ccZero2$modAuthor$ccNum2 $modDate", initialX + 86f + 3f, initialY + 50f)
if (modErrored) { if (modErrored) {
batch.draw(CommonResourcePool.getAsTextureRegion("basegame_errored_icon32"), initialX + width - 40f, initialY + 8f) batch.draw(CommonResourcePool.getAsTextureRegion("basegame_errored_icon32"), initialX + width - 40f, initialY + 8f + 12f)
} }
} }