Merge branch 'feature/insert-key-remapping' into develop

This commit is contained in:
Fingercomp 2025-07-18 14:44:09 +03:00
commit 35f060451b
No known key found for this signature in database
GPG Key ID: BBC71CEE45D86E37
4 changed files with 18 additions and 2 deletions

View File

@ -0,0 +1,8 @@
package ocelot.desktop
import org.lwjgl.input.Keyboard
/** The default Ocelot keymap (unless overridden by the setting). */
object Keymap {
val Insert: Int = Keyboard.KEY_INSERT
}

View File

@ -44,6 +44,8 @@ class Settings(val config: Config) extends SettingsData {
windowSize.y -= 16
}
keymapInsert = config.getIntOrElse("ocelot.keymap.insert", Keymap.Insert)
recentWorkspace = config.getOptionalString("ocelot.workspace.recent")
pinNewWindows = config.getBooleanOrElse("ocelot.workspace.pinNewWindows", default = true)
unfocusedWindowTransparency = config.getDoubleOrElse("ocelot.workspace.unfocusedWindowTransparency", 0.5)
@ -105,6 +107,9 @@ object Settings extends Logging {
def withValue(path: String, value: Option[Any]): Config =
config.withValue(path, ConfigValueFactory.fromAnyRef(value.orNull))
def withValue(path: String, value: Int): Config =
config.withValue(path, ConfigValueFactory.fromAnyRef(value))
}
class Int2D(var x: Int, var y: Int) {
@ -186,6 +191,7 @@ object Settings extends Logging {
.withValuePreserveOrigin("ocelot.window.fullscreen", settings.windowFullscreen)
.withValuePreserveOrigin("ocelot.window.disableVsync", settings.disableVsync)
.withValuePreserveOrigin("ocelot.window.debugLwjgl", settings.debugLwjgl)
.withValue("ocelot.keymap.insert", settings.keymapInsert)
.withValue("ocelot.workspace.recent", settings.recentWorkspace)
.withValuePreserveOrigin("ocelot.workspace.pinNewWindows", settings.pinNewWindows)
.withValuePreserveOrigin("ocelot.workspace.unfocusedWindowTransparency", settings.unfocusedWindowTransparency)

View File

@ -1,5 +1,6 @@
package ocelot.desktop.util
import ocelot.desktop.Keymap
import ocelot.desktop.Settings.Int2D
import ocelot.desktop.util.SettingsData.Fields
@ -33,6 +34,8 @@ class SettingsData {
var disableVsync: Boolean = false
var debugLwjgl: Boolean = false
var keymapInsert: Int = Keymap.Insert
var recentWorkspace: Option[String] = None
var pinNewWindows: Boolean = true

View File

@ -15,7 +15,6 @@ import ocelot.desktop.util.{DrawUtils, Logging}
import ocelot.desktop.windows.ScreenWindow._
import ocelot.desktop.{ColorScheme, OcelotDesktop, Settings}
import org.apache.commons.lang3.StringUtils
import org.lwjgl.input.Keyboard
import totoro.ocelot.brain.entity.Screen
import totoro.ocelot.brain.nbt.NBTTagCompound
import totoro.ocelot.brain.util.Tier
@ -59,7 +58,7 @@ class ScreenWindow(screenNode: ScreenNode) extends BasicWindow with Logging {
screen.keyDown(event.char, event.code, OcelotDesktop.player)
// note: in OpenComputers, key_down signal is fired __before__ clipboard signal
if (event.code == Keyboard.KEY_INSERT)
if (event.code == Settings.get.keymapInsert)
screen.clipboard(UiHandler.clipboard, OcelotDesktop.player)
case KeyEvent.State.Release =>