mirror of
https://github.com/MightyPirates/OpenComputers.git
synced 2025-09-17 11:15:12 -04:00
Merge branch 'master-MC1.7.10' of github.com:MightyPirates/OpenComputers into master-MC1.8
Conflicts: src/main/scala/li/cil/oc/client/KeyBindings.scala src/main/scala/li/cil/oc/common/block/Item.scala src/main/scala/li/cil/oc/common/item/Delegate.scala src/main/scala/li/cil/oc/common/item/SimpleItem.scala
This commit is contained in:
commit
2fd539bbd8
@ -1,21 +1,41 @@
|
|||||||
package li.cil.oc.client
|
package li.cil.oc.client
|
||||||
|
|
||||||
|
import li.cil.oc.OpenComputers
|
||||||
import net.minecraft.client.settings.KeyBinding
|
import net.minecraft.client.settings.KeyBinding
|
||||||
import net.minecraftforge.fml.client.FMLClientHandler
|
import net.minecraftforge.fml.client.FMLClientHandler
|
||||||
import org.lwjgl.input.Keyboard
|
import org.lwjgl.input.Keyboard
|
||||||
|
import org.lwjgl.input.Mouse
|
||||||
|
|
||||||
object KeyBindings {
|
object KeyBindings {
|
||||||
def showExtendedTooltips = Keyboard.isCreated && (try Keyboard.isKeyDown(extendedTooltip.getKeyCode) catch {
|
def showExtendedTooltips = isKeybindPressed(extendedTooltip)
|
||||||
case _: Throwable => false // Don't ask me, sometimes things can apparently screw up LWJGL's keyboard handling.
|
|
||||||
})
|
|
||||||
|
|
||||||
def showMaterialCosts = Keyboard.isCreated && (try Keyboard.isKeyDown(materialCosts.getKeyCode) catch {
|
def showMaterialCosts = isKeybindPressed(materialCosts)
|
||||||
case _: Throwable => false // Don't ask me, sometimes things can apparently screw up LWJGL's keyboard handling.
|
|
||||||
})
|
def isPastingClipboard = isKeybindPressed(clipboardPaste)
|
||||||
|
|
||||||
|
def getKeybindName(keyBinding: KeyBinding) = try {
|
||||||
|
if (keyBinding.getKeyCode < 0)
|
||||||
|
Mouse.getButtonName(keyBinding.getKeyCode + 100)
|
||||||
|
else
|
||||||
|
Keyboard.getKeyName(keyBinding.getKeyCode)
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
case _: Throwable => "???"
|
||||||
|
}
|
||||||
|
|
||||||
|
def isKeybindPressed(keyBinding: KeyBinding) = try {
|
||||||
|
if (keyBinding.getKeyCode < 0)
|
||||||
|
Mouse.isCreated && Mouse.isButtonDown(keyBinding.getKeyCode + 100)
|
||||||
|
else
|
||||||
|
Keyboard.isCreated && Keyboard.isKeyDown(keyBinding.getKeyCode)
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
case _: Throwable => false
|
||||||
|
}
|
||||||
|
|
||||||
def extendedTooltip = FMLClientHandler.instance.getClient.gameSettings.keyBindSneak
|
def extendedTooltip = FMLClientHandler.instance.getClient.gameSettings.keyBindSneak
|
||||||
|
|
||||||
val materialCosts = new KeyBinding("key.materialCosts", Keyboard.KEY_LMENU, "OpenComputers")
|
val materialCosts = new KeyBinding("key.materialCosts", Keyboard.KEY_LMENU, OpenComputers.Name)
|
||||||
|
|
||||||
val clipboardPaste = new KeyBinding("key.clipboardPaste", Keyboard.KEY_INSERT, "OpenComputers")
|
val clipboardPaste = new KeyBinding("key.clipboardPaste", Keyboard.KEY_INSERT, OpenComputers.Name)
|
||||||
}
|
}
|
||||||
|
@ -85,7 +85,7 @@ trait InputBuffer extends DisplayBuffer {
|
|||||||
case _ => // Wasn't pressed while viewing the screen.
|
case _ => // Wasn't pressed while viewing the screen.
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Keyboard.isKeyDown(KeyBindings.clipboardPaste.getKeyCode) && Keyboard.getEventKeyState) {
|
if (KeyBindings.clipboardPaste.getKeyCode == code && Keyboard.getEventKeyState) {
|
||||||
buffer.clipboard(GuiScreen.getClipboardString, null)
|
buffer.clipboard(GuiScreen.getClipboardString, null)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -97,7 +97,9 @@ trait InputBuffer extends DisplayBuffer {
|
|||||||
|
|
||||||
override protected def mouseClicked(x: Int, y: Int, button: Int) {
|
override protected def mouseClicked(x: Int, y: Int, button: Int) {
|
||||||
super.mouseClicked(x, y, button)
|
super.mouseClicked(x, y, button)
|
||||||
if (buffer != null && button == 2) {
|
val isMiddleMouseButton = button == 2
|
||||||
|
val isBoundMouseButton = KeyBindings.clipboardPaste.getKeyCode < 0 && button == KeyBindings.clipboardPaste.getKeyCode + 100
|
||||||
|
if (buffer != null && (isMiddleMouseButton || isBoundMouseButton)) {
|
||||||
if (hasKeyboard) {
|
if (hasKeyboard) {
|
||||||
buffer.clipboard(GuiScreen.getClipboardString, null)
|
buffer.clipboard(GuiScreen.getClipboardString, null)
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,6 @@ import net.minecraft.util.BlockPos
|
|||||||
import net.minecraft.util.EnumFacing
|
import net.minecraft.util.EnumFacing
|
||||||
import net.minecraft.util.StatCollector
|
import net.minecraft.util.StatCollector
|
||||||
import net.minecraft.world.World
|
import net.minecraft.world.World
|
||||||
import org.lwjgl.input
|
|
||||||
|
|
||||||
class Item(value: Block) extends ItemBlock(value) {
|
class Item(value: Block) extends ItemBlock(value) {
|
||||||
setHasSubtypes(true)
|
setHasSubtypes(true)
|
||||||
@ -48,13 +47,13 @@ class Item(value: Block) extends ItemBlock(value) {
|
|||||||
case (simple: SimpleBlock, lines: util.List[String]@unchecked) =>
|
case (simple: SimpleBlock, lines: util.List[String]@unchecked) =>
|
||||||
simple.addInformation(getMetadata(stack.getItemDamage), stack, player, lines, advanced)
|
simple.addInformation(getMetadata(stack.getItemDamage), stack, player, lines, advanced)
|
||||||
|
|
||||||
if (input.Keyboard.isKeyDown(input.Keyboard.KEY_LMENU)) {
|
if (KeyBindings.showMaterialCosts) {
|
||||||
ItemCosts.addTooltip(stack, lines)
|
ItemCosts.addTooltip(stack, lines)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
lines.add(StatCollector.translateToLocalFormatted(
|
lines.add(StatCollector.translateToLocalFormatted(
|
||||||
Settings.namespace + "tooltip.MaterialCosts",
|
Settings.namespace + "tooltip.MaterialCosts",
|
||||||
input.Keyboard.getKeyName(KeyBindings.materialCosts.getKeyCode)))
|
KeyBindings.getKeybindName(KeyBindings.materialCosts)))
|
||||||
}
|
}
|
||||||
case _ =>
|
case _ =>
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,6 @@ import net.minecraft.util.EnumFacing
|
|||||||
import net.minecraft.world.World
|
import net.minecraft.world.World
|
||||||
import net.minecraftforge.fml.relauncher.Side
|
import net.minecraftforge.fml.relauncher.Side
|
||||||
import net.minecraftforge.fml.relauncher.SideOnly
|
import net.minecraftforge.fml.relauncher.SideOnly
|
||||||
import org.lwjgl.input
|
|
||||||
|
|
||||||
trait Delegate {
|
trait Delegate {
|
||||||
def parent: Delegator
|
def parent: Delegator
|
||||||
@ -93,7 +92,7 @@ trait Delegate {
|
|||||||
else {
|
else {
|
||||||
tooltip.add(Localization.localizeImmediately(
|
tooltip.add(Localization.localizeImmediately(
|
||||||
Settings.namespace + "tooltip.MaterialCosts",
|
Settings.namespace + "tooltip.MaterialCosts",
|
||||||
input.Keyboard.getKeyName(KeyBindings.materialCosts.getKeyCode)))
|
KeyBindings.getKeybindName(KeyBindings.materialCosts)))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (stack.hasTagCompound && stack.getTagCompound.hasKey(Settings.namespace + "data")) {
|
if (stack.hasTagCompound && stack.getTagCompound.hasKey(Settings.namespace + "data")) {
|
||||||
|
@ -19,7 +19,6 @@ import net.minecraft.world.World
|
|||||||
import net.minecraftforge.common.ChestGenHooks
|
import net.minecraftforge.common.ChestGenHooks
|
||||||
import net.minecraftforge.fml.relauncher.Side
|
import net.minecraftforge.fml.relauncher.Side
|
||||||
import net.minecraftforge.fml.relauncher.SideOnly
|
import net.minecraftforge.fml.relauncher.SideOnly
|
||||||
import org.lwjgl.input
|
|
||||||
|
|
||||||
class SimpleItem extends Item {
|
class SimpleItem extends Item {
|
||||||
setCreativeTab(CreativeTab)
|
setCreativeTab(CreativeTab)
|
||||||
@ -50,7 +49,7 @@ class SimpleItem extends Item {
|
|||||||
else {
|
else {
|
||||||
tt.add(Localization.localizeImmediately(
|
tt.add(Localization.localizeImmediately(
|
||||||
Settings.namespace + "tooltip.MaterialCosts",
|
Settings.namespace + "tooltip.MaterialCosts",
|
||||||
input.Keyboard.getKeyName(KeyBindings.materialCosts.getKeyCode)))
|
KeyBindings.getKeybindName(KeyBindings.materialCosts)))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (stack.hasTagCompound && stack.getTagCompound.hasKey(Settings.namespace + "data")) {
|
if (stack.hasTagCompound && stack.getTagCompound.hasKey(Settings.namespace + "data")) {
|
||||||
|
@ -4,7 +4,6 @@ import li.cil.oc.Localization
|
|||||||
import li.cil.oc.Settings
|
import li.cil.oc.Settings
|
||||||
import li.cil.oc.client.KeyBindings
|
import li.cil.oc.client.KeyBindings
|
||||||
import net.minecraft.client.Minecraft
|
import net.minecraft.client.Minecraft
|
||||||
import org.lwjgl.input.Keyboard
|
|
||||||
|
|
||||||
import scala.collection.convert.WrapAsJava._
|
import scala.collection.convert.WrapAsJava._
|
||||||
import scala.collection.convert.WrapAsScala._
|
import scala.collection.convert.WrapAsScala._
|
||||||
@ -22,7 +21,7 @@ object Tooltip {
|
|||||||
val shouldShorten = (isSubTooltip || font.getStringWidth(tooltip) > maxWidth) && !KeyBindings.showExtendedTooltips
|
val shouldShorten = (isSubTooltip || font.getStringWidth(tooltip) > maxWidth) && !KeyBindings.showExtendedTooltips
|
||||||
if (shouldShorten) {
|
if (shouldShorten) {
|
||||||
if (isSubTooltip) Seq.empty[String]
|
if (isSubTooltip) Seq.empty[String]
|
||||||
else Seq(Localization.localizeImmediately("tooltip.TooLong", Keyboard.getKeyName(KeyBindings.extendedTooltip.getKeyCode)))
|
else Seq(Localization.localizeImmediately("tooltip.TooLong", KeyBindings.getKeybindName(KeyBindings.extendedTooltip)))
|
||||||
}
|
}
|
||||||
else tooltip.
|
else tooltip.
|
||||||
lines.
|
lines.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user