mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-11 19:14:05 +09:00
LibGDX, here I am.
This commit is contained in:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user