mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-10 18:44:05 +09:00
LibGDX, here I am.
This commit is contained in:
@@ -8,8 +8,9 @@ import org.luaj.vm2.lib.TwoArgFunction
|
||||
import org.luaj.vm2.lib.ZeroArgFunction
|
||||
import org.luaj.vm2.lib.jse.JsePlatform
|
||||
import net.torvald.terrarum.KVHashMap
|
||||
import net.torvald.terrarum.Millisec
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.TerrarumGDX
|
||||
import net.torvald.terrarum.gameactors.Second
|
||||
import net.torvald.terrarum.gameactors.ceilInt
|
||||
import net.torvald.terrarum.gameactors.roundInt
|
||||
import net.torvald.terrarum.virtualcomputer.luaapi.*
|
||||
import net.torvald.terrarum.virtualcomputer.peripheral.*
|
||||
@@ -20,8 +21,6 @@ import net.torvald.terrarum.virtualcomputer.worldobject.ComputerPartsCodex
|
||||
import org.lwjgl.BufferUtils
|
||||
import org.lwjgl.openal.AL
|
||||
import org.lwjgl.openal.AL10
|
||||
import org.newdawn.slick.GameContainer
|
||||
import org.newdawn.slick.Input
|
||||
import java.io.*
|
||||
import java.nio.ByteBuffer
|
||||
import java.util.*
|
||||
@@ -74,9 +73,6 @@ class TerrarumComputer(peripheralSlots: Int) {
|
||||
|
||||
var isHalted = false
|
||||
|
||||
lateinit var input: Input
|
||||
private set
|
||||
|
||||
lateinit var term: Teletype
|
||||
private set
|
||||
|
||||
@@ -104,7 +100,7 @@ class TerrarumComputer(peripheralSlots: Int) {
|
||||
// put disk in diskRack
|
||||
if (filename.isNotEmpty() && filename.isNotBlank()) {
|
||||
diskRack[slot] = VDUtil.readDiskArchive(
|
||||
File(Terrarum.currentSaveDir.path + "/computers/$filename").absoluteFile,
|
||||
File(TerrarumGDX.currentSaveDir.path + "/computers/$filename").absoluteFile,
|
||||
Level.WARNING,
|
||||
{ },
|
||||
Filesystem.sysCharset
|
||||
@@ -248,8 +244,7 @@ class TerrarumComputer(peripheralSlots: Int) {
|
||||
}
|
||||
}
|
||||
|
||||
fun update(gc: GameContainer, delta: Int) {
|
||||
input = gc.input
|
||||
fun update(delta: Float) {
|
||||
|
||||
if (currentExecutionThread.state == Thread.State.TERMINATED) {
|
||||
threadRun = false
|
||||
@@ -370,7 +365,7 @@ class TerrarumComputer(peripheralSlots: Int) {
|
||||
}
|
||||
catch (e: LuaError) {
|
||||
e.printStackTrace(System.err)
|
||||
lua.STDERR.println("${SimpleTextTerminal.ASCII_DLE}${e.message}${SimpleTextTerminal.ASCII_DC4}")
|
||||
//lua.STDERR.println("${SimpleTextTerminal.ASCII_DLE}${e.message}${SimpleTextTerminal.ASCII_DC4}")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -401,7 +396,7 @@ class TerrarumComputer(peripheralSlots: Int) {
|
||||
|
||||
class ComputerEmitTone(val computer: TerrarumComputer) : TwoArgFunction() {
|
||||
override fun call(millisec: LuaValue, freq: LuaValue): LuaValue {
|
||||
computer.playTone(millisec.checkint(), freq.checkdouble())
|
||||
computer.playTone(millisec.checkdouble().toFloat(), freq.checkdouble())
|
||||
return LuaValue.NONE
|
||||
}
|
||||
}
|
||||
@@ -410,14 +405,14 @@ class TerrarumComputer(peripheralSlots: Int) {
|
||||
// BEEPER DRIVER //
|
||||
///////////////////
|
||||
|
||||
private val beepMaxLen = 10000
|
||||
private val beepMaxLen = 10f
|
||||
// let's regard it as a tracker...
|
||||
private val beepQueue = ArrayList<Pair<Int, Double>>()
|
||||
private val beepQueue = ArrayList<Pair<Second, Double>>()
|
||||
private var beepCursor = -1
|
||||
private var beepQueueLineExecTimer: Millisec = 0
|
||||
private var beepQueueLineExecTimer: Second = 0f
|
||||
private var beepQueueFired = false
|
||||
|
||||
private fun runBeepQueueManager(delta: Int) {
|
||||
private fun runBeepQueueManager(delta: Float) {
|
||||
// start emitTone queue
|
||||
if (beepQueue.size > 0 && beepCursor == -1) {
|
||||
beepCursor = 0
|
||||
@@ -453,15 +448,15 @@ class TerrarumComputer(peripheralSlots: Int) {
|
||||
fun clearBeepQueue() {
|
||||
beepQueue.clear()
|
||||
beepCursor = -1
|
||||
beepQueueLineExecTimer = 0
|
||||
beepQueueLineExecTimer = 0f
|
||||
|
||||
//AL.destroy()
|
||||
|
||||
if (DEBUG) println("[TerrarumComputer] !! Beep queue clear")
|
||||
}
|
||||
|
||||
fun enqueueBeep(duration: Int, freq: Double) {
|
||||
beepQueue.add(Pair(Math.min(duration, beepMaxLen), freq))
|
||||
fun enqueueBeep(duration: Double, freq: Double) {
|
||||
beepQueue.add(Pair(Math.min(duration.toFloat(), beepMaxLen), freq))
|
||||
}
|
||||
|
||||
fun beepQueueGetLenOfPtn(ptnIndex: Int) = beepQueue[ptnIndex].first
|
||||
@@ -485,11 +480,15 @@ class TerrarumComputer(peripheralSlots: Int) {
|
||||
*
|
||||
* ,---. (true, true) ,---- (true, false) ----. (false, true) ----- (false, false)
|
||||
*/
|
||||
private fun makeAudioData(duration: Millisec, freq: Double,
|
||||
private fun makeAudioData(duration: Second, freq: Double,
|
||||
rampUp: Boolean = true, rampDown: Boolean = true): ByteBuffer {
|
||||
val audioData = BufferUtils.createByteBuffer(duration.times(sampleRate).div(1000))
|
||||
|
||||
val realDuration = duration * sampleRate / 1000
|
||||
TODO("with duration as Seconds")
|
||||
|
||||
val audioDataSize = duration.times(sampleRate).ceilInt()
|
||||
val audioData = BufferUtils.createByteBuffer(audioDataSize)
|
||||
|
||||
/*val realDuration = duration * sampleRate / 1000
|
||||
val chopSize = freq / sampleRate
|
||||
|
||||
val amp = Math.max(4600.0 / freq, 1.0)
|
||||
@@ -505,13 +504,13 @@ class TerrarumComputer(peripheralSlots: Int) {
|
||||
|
||||
// TODO volume ramping?
|
||||
if (freq == 0.0) {
|
||||
for (x in 0..realDuration - 1) {
|
||||
for (_ in 0..audioDataSize - 1) {
|
||||
audioData.put(0x00.toByte())
|
||||
}
|
||||
}
|
||||
else if (freq < transitionThre) { // chopper generator (for low freq)
|
||||
for (x in 0..realDuration - 1) {
|
||||
var sine: Double = amp * Math.cos(Math.PI * 2 * x * chopSize)
|
||||
for (tsart in 0..audioDataSize - 1) {
|
||||
var sine: Double = amp * Math.cos(Math.PI * 2 * () * chopSize)
|
||||
if (sine > 0.79) sine = 0.79
|
||||
else if (sine < -0.79) sine = -0.79
|
||||
audioData.put(
|
||||
@@ -529,14 +528,14 @@ class TerrarumComputer(peripheralSlots: Int) {
|
||||
(0.5 + 0.5 * sine).times(0xFF).roundInt().toByte()
|
||||
)
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
audioData.rewind()
|
||||
|
||||
return audioData
|
||||
}
|
||||
|
||||
private fun playTone(leninmilli: Int, freq: Double) {
|
||||
private fun playTone(length: Second, freq: Double) {
|
||||
/*audioData = makeAudioData(leninmilli, freq)
|
||||
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ import org.luaj.vm2.*
|
||||
import org.luaj.vm2.lib.OneArgFunction
|
||||
import org.luaj.vm2.lib.TwoArgFunction
|
||||
import org.luaj.vm2.lib.ZeroArgFunction
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.TerrarumGDX
|
||||
import net.torvald.terrarum.toHex
|
||||
import net.torvald.terrarum.virtualcomputer.computer.TerrarumComputer
|
||||
import net.torvald.terrarum.virtualcomputer.luaapi.Term.Companion.checkIBM437
|
||||
@@ -63,8 +63,8 @@ internal class FilesystemDir(globals: Globals, computer: TerrarumComputer) {
|
||||
init {
|
||||
try {
|
||||
val uuid = UUID.randomUUID().toString()
|
||||
val lowerCase = File(Terrarum.currentSaveDir, uuid + "oc_rox")
|
||||
val upperCase = File(Terrarum.currentSaveDir, uuid + "OC_ROX")
|
||||
val lowerCase = File(TerrarumGDX.currentSaveDir, uuid + "oc_rox")
|
||||
val upperCase = File(TerrarumGDX.currentSaveDir, uuid + "OC_ROX")
|
||||
// This should NEVER happen but could also lead to VERY weird bugs, so we
|
||||
// make sure the files don't exist.
|
||||
if (lowerCase.exists()) lowerCase.delete()
|
||||
@@ -105,7 +105,7 @@ internal class FilesystemDir(globals: Globals, computer: TerrarumComputer) {
|
||||
*/
|
||||
fun TerrarumComputer.getRealPath(luapath: LuaValue) : String {
|
||||
// direct mounted paths to real path
|
||||
val computerDir = Terrarum.currentSaveDir.absolutePath + "/computers/"
|
||||
val computerDir = TerrarumGDX.currentSaveDir.absolutePath + "/computers/"
|
||||
/* if not begins with "(/?)media/", direct to boot
|
||||
* else, to corresponding drives
|
||||
*
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package net.torvald.terrarum.virtualcomputer.luaapi
|
||||
|
||||
import com.badlogic.gdx.Gdx
|
||||
import org.luaj.vm2.Globals
|
||||
import org.luaj.vm2.LuaTable
|
||||
import org.luaj.vm2.LuaValue
|
||||
@@ -30,7 +31,7 @@ class Input(globals: Globals, computer: TerrarumComputer) {
|
||||
// L_Alt and L_COMMAND are homogeneous
|
||||
if (keys_alt.contains(key)) {
|
||||
for (k in keys_alt) {
|
||||
val down = host.input.isKeyDown(k)
|
||||
val down = Gdx.input.isKeyPressed(k)
|
||||
if (down) return LuaValue.valueOf(true)
|
||||
}
|
||||
}
|
||||
@@ -38,12 +39,12 @@ class Input(globals: Globals, computer: TerrarumComputer) {
|
||||
// Caps, Backspace, L_Control, for Colemak and HHKB
|
||||
if (keys_caps.contains(key)) {
|
||||
for (k in keys_caps) {
|
||||
val down = host.input.isKeyDown(k)
|
||||
val down = Gdx.input.isKeyPressed(k)
|
||||
if (down) return LuaValue.valueOf(true)
|
||||
}
|
||||
}
|
||||
|
||||
return LuaValue.valueOf(host.input.isKeyDown(keyCode.checkint()))
|
||||
return LuaValue.valueOf(Gdx.input.isKeyPressed(keyCode.checkint()))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -71,11 +71,11 @@ class PcSpeakerDriver(val globals: Globals, host: TerrarumComputer) {
|
||||
/**
|
||||
* @param freq: number (hertz) or string (A-4, A4, B#2, ...)
|
||||
*/
|
||||
override fun call(millisec: LuaValue, freq: LuaValue): LuaValue {
|
||||
override fun call(second: LuaValue, freq: LuaValue): LuaValue {
|
||||
if (freq.isnumber())
|
||||
host.enqueueBeep(millisec.checkint(), freq.checkdouble())
|
||||
host.enqueueBeep(second.checkdouble(), freq.checkdouble())
|
||||
else {
|
||||
host.enqueueBeep(millisec.checkint(),
|
||||
host.enqueueBeep(second.checkdouble(),
|
||||
freq.checkjstring().toNoteIndex()
|
||||
.toFreq(host.luaJ_globals["speaker"]["__basefreq__"].checkdouble())
|
||||
)
|
||||
|
||||
@@ -2,7 +2,7 @@ package net.torvald.terrarum.virtualcomputer.luaapi
|
||||
|
||||
import org.luaj.vm2.Globals
|
||||
import org.luaj.vm2.LuaFunction
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.TerrarumGDX
|
||||
import net.torvald.terrarum.gameworld.WorldTime
|
||||
import org.luaj.vm2.LuaTable
|
||||
import org.luaj.vm2.LuaValue
|
||||
@@ -24,7 +24,7 @@ class WorldInformationProvider(globals: Globals) {
|
||||
companion object {
|
||||
fun getWorldTimeInLuaFormat() : LuaTable {
|
||||
val t = LuaTable()
|
||||
val time = if (Terrarum.ingame != null) Terrarum.ingame!!.world.time else WorldTime()
|
||||
val time = if (TerrarumGDX.ingame != null) TerrarumGDX.ingame!!.world.time else WorldTime()
|
||||
|
||||
// int Terrarum World Time format
|
||||
t["hour"] = time.hours
|
||||
@@ -43,7 +43,7 @@ class WorldInformationProvider(globals: Globals) {
|
||||
|
||||
/** evaluate single C date format */
|
||||
fun String.evalAsDate(): String {
|
||||
val time = if (Terrarum.ingame != null) Terrarum.ingame!!.world.time else WorldTime()
|
||||
val time = if (TerrarumGDX.ingame != null) TerrarumGDX.ingame!!.world.time else WorldTime()
|
||||
return when (this) {
|
||||
"%a" -> time.getDayNameShort()
|
||||
"%A" -> time.getDayNameFull()
|
||||
|
||||
@@ -1,18 +1,17 @@
|
||||
package net.torvald.terrarum.virtualcomputer.peripheral
|
||||
|
||||
import com.badlogic.gdx.graphics.g2d.BitmapFont
|
||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||
import net.torvald.terrarum.ModMgr
|
||||
import org.luaj.vm2.Globals
|
||||
import org.newdawn.slick.Graphics
|
||||
import org.newdawn.slick.SpriteSheet
|
||||
import org.newdawn.slick.SpriteSheetFont
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 2017-05-31.
|
||||
*/
|
||||
class PeripheralCharLCD(val width: Int, val height: Int) : Peripheral("charLCD") {
|
||||
companion object {
|
||||
private val fontSheet = SpriteSheet(ModMgr.getPath("dwarventech", "mt-32.tga"), 16, 16)
|
||||
private val font = SpriteSheetFont(fontSheet, 0.toChar())
|
||||
/*companion object {
|
||||
private val fontSheet = BitmapFont(ModMgr.getPath("dwarventech", "mt-32.tga"), 16, 16)
|
||||
private val font = BitmapFont(fontSheet, 0.toChar())
|
||||
private val fontW = fontSheet.width / fontSheet.horizontalCount
|
||||
private val fontH = fontSheet.height / fontSheet.verticalCount
|
||||
}
|
||||
@@ -34,11 +33,19 @@ class PeripheralCharLCD(val width: Int, val height: Int) : Peripheral("charLCD")
|
||||
/**
|
||||
* @param g Frame Buffer that holds the display of LCD screen
|
||||
*/
|
||||
fun render(g: Graphics) {
|
||||
g.font = PeripheralCharLCD.font
|
||||
|
||||
fun render(batch: SpriteBatch) {
|
||||
memory.forEachIndexed { index, byte ->
|
||||
g.drawString("${byte.toChar()}", (index % width) * fontW.toFloat(), (index / width) * fontH.toFloat())
|
||||
font.draw(batch, "${byte.toChar()}", (index % width) * fontW.toFloat(), (index / width) * fontH.toFloat())
|
||||
}
|
||||
}*/
|
||||
override fun loadLib(globals: Globals) {
|
||||
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
|
||||
}
|
||||
|
||||
override fun toString(): String {
|
||||
return super.toString()
|
||||
}
|
||||
|
||||
override val memSize: Int
|
||||
get() = TODO("not implemented") //To change initializer of created properties use File | Settings | File Templates.
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package net.torvald.terrarum.virtualcomputer.peripheral
|
||||
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import com.badlogic.gdx.graphics.Color
|
||||
import net.torvald.terrarum.TerrarumGDX
|
||||
import net.torvald.terrarum.gameactors.DecodeTapestry
|
||||
import net.torvald.terrarum.gameactors.ai.toLua
|
||||
import net.torvald.terrarum.virtualcomputer.computer.TerrarumComputer
|
||||
@@ -8,7 +9,6 @@ import net.torvald.terrarum.virtualcomputer.terminal.Terminal
|
||||
import org.luaj.vm2.*
|
||||
import org.luaj.vm2.lib.*
|
||||
import org.luaj.vm2.lib.ThreeArgFunction
|
||||
import org.newdawn.slick.*
|
||||
import java.util.*
|
||||
|
||||
/**
|
||||
@@ -16,7 +16,7 @@ import java.util.*
|
||||
*
|
||||
* Created by SKYHi14 on 2017-02-08.
|
||||
*/
|
||||
class PeripheralVideoCard(val host: TerrarumComputer, val termW: Int = 80, val termH: Int = 25) :
|
||||
/*class PeripheralVideoCard(val host: TerrarumComputer, val termW: Int = 80, val termH: Int = 25) :
|
||||
Peripheral("ppu") {
|
||||
companion object {
|
||||
val blockW = 8 // MUST BE 8
|
||||
@@ -163,7 +163,7 @@ class PeripheralVideoCard(val host: TerrarumComputer, val termW: Int = 80, val t
|
||||
private val spriteBuffer = ImageBuffer(VSprite.width * 2, VSprite.height)
|
||||
|
||||
fun render(g: Graphics) {
|
||||
cursorBlinkTimer += Terrarum.delta
|
||||
cursorBlinkTimer += Gdx.graphics.deltaTime
|
||||
if (cursorBlinkTimer > cursorBlinkTime) {
|
||||
cursorBlinkTimer -= cursorBlinkTime
|
||||
cursorBlinkOn = !cursorBlinkOn
|
||||
@@ -641,7 +641,7 @@ class VSprite {
|
||||
setPixel(i % width, i / width, data[i])
|
||||
}
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
|
||||
abstract class FourArgFunction : LibFunction() {
|
||||
|
||||
@@ -5,11 +5,6 @@ import net.torvald.terrarum.gameactors.DecodeTapestry
|
||||
import net.torvald.terrarum.gameactors.abs
|
||||
import net.torvald.terrarum.gamecontroller.Key
|
||||
import net.torvald.terrarum.virtualcomputer.computer.TerrarumComputer
|
||||
import net.torvald.terrarum.virtualcomputer.peripheral.PeripheralVideoCard
|
||||
import org.newdawn.slick.Color
|
||||
import org.newdawn.slick.GameContainer
|
||||
import org.newdawn.slick.Graphics
|
||||
import org.newdawn.slick.Image
|
||||
import java.util.*
|
||||
|
||||
/**
|
||||
@@ -18,7 +13,7 @@ import java.util.*
|
||||
*
|
||||
* Created by SKYHi14 on 2017-02-08.
|
||||
*/
|
||||
class GraphicsTerminal(private val host: TerrarumComputer) : Terminal {
|
||||
/*class GraphicsTerminal(private val host: TerrarumComputer) : Terminal {
|
||||
lateinit var videoCard: PeripheralVideoCard
|
||||
|
||||
override val width: Int; get() = videoCard.termW
|
||||
@@ -314,4 +309,4 @@ class GraphicsTerminal(private val host: TerrarumComputer) : Terminal {
|
||||
|
||||
videoScreen = Image(videoCard.width, videoCard.height)
|
||||
}
|
||||
}
|
||||
}*/
|
||||
@@ -1,25 +1,12 @@
|
||||
package net.torvald.terrarum.virtualcomputer.terminal
|
||||
|
||||
import net.torvald.aa.AAFrame
|
||||
import net.torvald.terrarum.*
|
||||
import net.torvald.terrarum.gameactors.DecodeTapestry
|
||||
import net.torvald.terrarum.gameactors.abs
|
||||
import net.torvald.terrarum.gamecontroller.Key
|
||||
import net.torvald.terrarum.virtualcomputer.computer.TerrarumComputer
|
||||
import org.lwjgl.BufferUtils
|
||||
import org.lwjgl.openal.AL
|
||||
import org.lwjgl.openal.AL10
|
||||
import org.lwjgl.openal.AL11
|
||||
import org.newdawn.slick.*
|
||||
import java.nio.ByteBuffer
|
||||
import java.util.*
|
||||
|
||||
/**
|
||||
* Default text terminal.
|
||||
*
|
||||
* Created by minjaesong on 16-09-07.
|
||||
*/
|
||||
open class SimpleTextTerminal(
|
||||
/*open class SimpleTextTerminal(
|
||||
phosphorColour: Color, override val width: Int, override val height: Int, private val host: TerrarumComputer,
|
||||
colour: Boolean = false, hires: Boolean = false
|
||||
) : Terminal {
|
||||
@@ -387,7 +374,7 @@ open class SimpleTextTerminal(
|
||||
|
||||
val CLUT = DecodeTapestry.colourIndices16
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
class ALException(errorCode: Int) : Exception("ALerror: $errorCode") {
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package net.torvald.terrarum.virtualcomputer.terminal
|
||||
|
||||
import org.newdawn.slick.GameContainer
|
||||
import org.newdawn.slick.Graphics
|
||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 16-09-14.
|
||||
@@ -19,8 +18,8 @@ interface Teletype {
|
||||
*/
|
||||
val coloursCount: Int
|
||||
|
||||
fun update(gc: GameContainer, delta: Int)
|
||||
fun render(gc: GameContainer, g: Graphics)
|
||||
fun update(delta: Float)
|
||||
fun render(batch: SpriteBatch)
|
||||
fun keyPressed(key: Int, c: Char)
|
||||
|
||||
/** Prints a char and move cursor accordingly */
|
||||
|
||||
@@ -1,15 +1,14 @@
|
||||
package net.torvald.terrarum.virtualcomputer.terminal
|
||||
|
||||
import net.torvald.imagefont.GameFontBase
|
||||
import net.torvald.terrarumsansbitmap.slick2d.GameFontBase
|
||||
import net.torvald.terrarum.blendMul
|
||||
import net.torvald.terrarum.blendNormal
|
||||
import org.newdawn.slick.*
|
||||
import java.util.*
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 16-09-15.
|
||||
*/
|
||||
class TeletypeTerminal : Teletype {
|
||||
/*class TeletypeTerminal : Teletype {
|
||||
override val width = 40
|
||||
override val displayW: Int
|
||||
get() = width * font.W
|
||||
@@ -203,4 +202,4 @@ class TeletypeTerminal : Teletype {
|
||||
|
||||
private fun charToSpriteNum(ch: Int): Int? = mappingTable[ch]
|
||||
}
|
||||
}
|
||||
}*/
|
||||
@@ -1,10 +1,8 @@
|
||||
package net.torvald.terrarum.virtualcomputer.terminal
|
||||
|
||||
import net.torvald.terrarum.Millisec
|
||||
import org.newdawn.slick.Color
|
||||
import org.newdawn.slick.GameContainer
|
||||
import org.newdawn.slick.Graphics
|
||||
import org.newdawn.slick.Input
|
||||
import com.badlogic.gdx.graphics.Color
|
||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||
import net.torvald.terrarum.gameactors.Second
|
||||
|
||||
/**
|
||||
* A terminal
|
||||
@@ -30,8 +28,8 @@ interface Terminal : Teletype {
|
||||
val displayH: Int
|
||||
|
||||
fun getColor(index: Int): Color
|
||||
override fun update(gc: GameContainer, delta: Int)
|
||||
override fun render(gc: GameContainer, g: Graphics)
|
||||
override fun update(delta: Float)
|
||||
override fun render(batch: SpriteBatch)
|
||||
override fun keyPressed(key: Int, c: Char)
|
||||
|
||||
// API calls
|
||||
@@ -60,7 +58,7 @@ interface Terminal : Teletype {
|
||||
* @param duration: milliseconds
|
||||
* @param freg: Frequency (float)
|
||||
*/
|
||||
fun emitTone(duration: Millisec, freq: Double)
|
||||
fun emitTone(duration: Second, freq: Double)
|
||||
|
||||
override fun bell(pattern: String)
|
||||
}
|
||||
@@ -1,12 +1,11 @@
|
||||
package net.torvald.terrarum.virtualcomputer.worldobject
|
||||
|
||||
import com.badlogic.gdx.graphics.Color
|
||||
import net.torvald.terrarum.gameactors.AVKey
|
||||
import net.torvald.terrarum.gameactors.FixtureBase
|
||||
import net.torvald.terrarum.virtualcomputer.computer.TerrarumComputer
|
||||
import net.torvald.terrarum.virtualcomputer.terminal.SimpleTextTerminal
|
||||
import net.torvald.terrarum.virtualcomputer.terminal.Terminal
|
||||
import net.torvald.terrarum.virtualcomputer.worldobject.ui.UITextTerminal
|
||||
import org.newdawn.slick.Color
|
||||
import java.util.*
|
||||
|
||||
/**
|
||||
@@ -14,7 +13,7 @@ import java.util.*
|
||||
*/
|
||||
class FixtureBasicTerminal(phosphor: Color) : FixtureBase() {
|
||||
|
||||
val computer = TerrarumComputer(8)
|
||||
/*val computer = TerrarumComputer(8)
|
||||
val vt: Terminal = SimpleTextTerminal(phosphor, 80, 25, computer)
|
||||
val ui = UITextTerminal(vt)
|
||||
|
||||
@@ -24,6 +23,6 @@ class FixtureBasicTerminal(phosphor: Color) : FixtureBase() {
|
||||
collisionFlag = COLLISION_PLATFORM
|
||||
|
||||
actorValue[AVKey.UUID] = UUID.randomUUID().toString()
|
||||
}
|
||||
}*/
|
||||
|
||||
}
|
||||
@@ -2,9 +2,7 @@ package net.torvald.terrarum.virtualcomputer.worldobject
|
||||
|
||||
import net.torvald.terrarum.gameactors.FixtureBase
|
||||
import net.torvald.terrarum.virtualcomputer.computer.TerrarumComputer
|
||||
import net.torvald.terrarum.virtualcomputer.terminal.SimpleTextTerminal
|
||||
import net.torvald.terrarum.virtualcomputer.terminal.Terminal
|
||||
import org.newdawn.slick.GameContainer
|
||||
import java.io.PrintStream
|
||||
import java.security.SecureRandom
|
||||
import java.util.*
|
||||
@@ -52,15 +50,15 @@ open class FixtureComputerBase() : FixtureBase() {
|
||||
// game codes //
|
||||
////////////////
|
||||
|
||||
override fun update(gc: GameContainer, delta: Int) {
|
||||
super.update(gc, delta)
|
||||
if (terminal != null) terminal!!.update(gc, delta)
|
||||
override fun update(delta: Float) {
|
||||
super.update(delta)
|
||||
if (terminal != null) terminal!!.update(delta)
|
||||
}
|
||||
|
||||
fun keyPressed(key: Int, c: Char) {
|
||||
if (terminal != null) {
|
||||
/*if (terminal != null) {
|
||||
terminal!!.vt.keyPressed(key, c)
|
||||
computerInside!!.keyPressed(key, c)
|
||||
}
|
||||
}*/
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,10 @@
|
||||
package net.torvald.terrarum.virtualcomputer.worldobject.ui
|
||||
|
||||
import net.torvald.terrarum.Millisec
|
||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||
import net.torvald.terrarum.gameactors.Second
|
||||
import net.torvald.terrarum.ui.*
|
||||
import net.torvald.terrarum.ui.UICanvas.Companion.OPENCLOSE_GENERIC
|
||||
import net.torvald.terrarum.virtualcomputer.terminal.Terminal
|
||||
import org.newdawn.slick.GameContainer
|
||||
import org.newdawn.slick.Graphics
|
||||
import org.newdawn.slick.Image
|
||||
import org.newdawn.slick.Input
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 16-09-08.
|
||||
@@ -37,7 +34,6 @@ class UITextTerminal(val terminal: Terminal) : UICanvas, KeyControlled, MouseCon
|
||||
|
||||
override var width: Int = terminal.displayW// + some
|
||||
override var height: Int = terminal.displayH// + frame
|
||||
private var terminalDisplay = Image(terminal.displayW, terminal.displayH)
|
||||
|
||||
override fun mousePressed(button: Int, x: Int, y: Int) {
|
||||
// monitor on/off, reset switch
|
||||
@@ -59,40 +55,40 @@ class UITextTerminal(val terminal: Terminal) : UICanvas, KeyControlled, MouseCon
|
||||
*
|
||||
* Timer itself is implemented in the handler.
|
||||
*/
|
||||
override var openCloseTime: Millisec = OPENCLOSE_GENERIC
|
||||
override var openCloseTime: Second = OPENCLOSE_GENERIC
|
||||
|
||||
override fun update(gc: GameContainer, delta: Int) {
|
||||
terminal.update(gc, delta)
|
||||
override fun update(delta: Float) {
|
||||
terminal.update(delta)
|
||||
}
|
||||
|
||||
override fun render(gc: GameContainer, g: Graphics) {
|
||||
terminal.render(gc, terminalDisplay.graphics)
|
||||
override fun render(batch: SpriteBatch) {
|
||||
//terminal.render(gc, terminalDisplay.graphics)
|
||||
}
|
||||
|
||||
override fun processInput(gc: GameContainer, delta: Int, input: Input) {
|
||||
override fun processInput(delta: Float) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Do not modify handler!!.openCloseCounter here.
|
||||
*/
|
||||
override fun doOpening(gc: GameContainer, delta: Int) {
|
||||
override fun doOpening(delta: Float) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Do not modify handler!!.openCloseCounter here.
|
||||
*/
|
||||
override fun doClosing(gc: GameContainer, delta: Int) {
|
||||
override fun doClosing(delta: Float) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Do not modify handler!!.openCloseCounter here.
|
||||
*/
|
||||
override fun endOpening(gc: GameContainer, delta: Int) {
|
||||
override fun endOpening(delta: Float) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Do not modify handler!!.openCloseCounter here.
|
||||
*/
|
||||
override fun endClosing(gc: GameContainer, delta: Int) {
|
||||
override fun endClosing(delta: Float) {
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user