mirror of
https://gitlab.com/cc-ru/ocelot/ocelot-desktop.git
synced 2025-12-20 02:59:19 +01:00
Emulate clipboard limits
See ocelot-brain#44.
This commit is contained in:
parent
d0682ea063
commit
eb6f6b0d8d
@ -1 +1 @@
|
||||
Subproject commit 495332f2d60083403cdf0f501a563fcb54841142
|
||||
Subproject commit 6364f58eeeff7b2a25d3d0eec17957bbcf6c283b
|
||||
@ -1,5 +1,6 @@
|
||||
package ocelot.desktop.ui.widget
|
||||
|
||||
import ocelot.desktop.audio.{SoundBuffers, SoundCategory, SoundSource}
|
||||
import ocelot.desktop.geometry.{Rect2D, Size2D, Vector2D}
|
||||
import ocelot.desktop.graphics.Graphics
|
||||
import ocelot.desktop.graphics.Texture.MinFilteringMode
|
||||
@ -13,7 +14,7 @@ import ocelot.desktop.util.{Keybind, Persistable, Register}
|
||||
import ocelot.desktop.{ColorScheme, OcelotDesktop, Settings}
|
||||
import org.lwjgl.input.Keyboard
|
||||
import totoro.ocelot.brain.nbt.NBTTagCompound
|
||||
import totoro.ocelot.brain.util.Tier
|
||||
import totoro.ocelot.brain.util.{ClipboardSplitter, Tier}
|
||||
|
||||
// TODO: use an interface instead of ScreenNode.
|
||||
abstract class ScreenView(screenNode: ScreenNode) extends Widget with Persistable {
|
||||
@ -21,7 +22,7 @@ abstract class ScreenView(screenNode: ScreenNode) extends Widget with Persistabl
|
||||
|
||||
private var lastMousePos = Vector2D.Zero
|
||||
|
||||
val scale = Register(1f)
|
||||
val scale: Register.Writeable[Float] = Register(1f)
|
||||
def scaleX: Float = (FontWidth * scale.value).floor / FontWidth
|
||||
def scaleY: Float = (FontHeight * scale.value).floor / FontHeight
|
||||
|
||||
@ -81,7 +82,7 @@ abstract class ScreenView(screenNode: ScreenNode) extends Widget with Persistabl
|
||||
|
||||
// note: in OpenComputers, key_down signal is fired __before__ clipboard signal
|
||||
if (event.code == Settings.get.keymap(Keybind.Insert)) {
|
||||
screenNode.screen.clipboard(UiHandler.clipboard, OcelotDesktop.player)
|
||||
sendClipboard()
|
||||
}
|
||||
|
||||
case KeyEvent.State.Release =>
|
||||
@ -109,7 +110,7 @@ abstract class ScreenView(screenNode: ScreenNode) extends Widget with Persistabl
|
||||
|
||||
case MouseEvent.State.Released =>
|
||||
if (inBounds && event.button == MouseEvent.Button.Middle) {
|
||||
screenNode.screen.clipboard(UiHandler.clipboard, OcelotDesktop.player)
|
||||
sendClipboard()
|
||||
event.consume()
|
||||
}
|
||||
|
||||
@ -130,6 +131,20 @@ abstract class ScreenView(screenNode: ScreenNode) extends Widget with Persistabl
|
||||
event.consume()
|
||||
}
|
||||
|
||||
private val clipboardSplitter = new ClipboardSplitter
|
||||
|
||||
private def sendClipboard(): Unit = {
|
||||
clipboardSplitter.split(UiHandler.clipboard) match {
|
||||
case Some(value) =>
|
||||
for (part <- value) {
|
||||
screenNode.screen.clipboard(part, OcelotDesktop.player)
|
||||
}
|
||||
|
||||
case None =>
|
||||
SoundSource.fromBuffer(SoundBuffers.NoteBlock("harp"), SoundCategory.Records).play()
|
||||
}
|
||||
}
|
||||
|
||||
override def save(nbt: NBTTagCompound): Unit = {
|
||||
nbt.setFloat(ScaleTag, scale.value)
|
||||
super.save(nbt)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user