Merge branch 'master' of github.com:MightyPirates/OpenComputers into MC1.7

Conflicts:
	src/main/scala/li/cil/oc/CraftingHandler.scala
	src/main/scala/li/cil/oc/client/gui/Case.scala
	src/main/scala/li/cil/oc/client/gui/Rack.scala
	src/main/scala/li/cil/oc/client/gui/Robot.scala
This commit is contained in:
Florian Nücke 2014-05-16 01:01:36 +02:00
commit 2bae20fea1
7 changed files with 82 additions and 12 deletions

View File

@ -17,7 +17,7 @@ local text = require("text")
local args, options = shell.parse(...)
if #args < 1 then
print("Usage: irc nickname [server:port]")
print("Usage: irc <nickname> [server:port]")
return
end
@ -457,4 +457,4 @@ end
if not result then
error(reason, 0)
end
return reason
return reason

View File

@ -42,7 +42,7 @@ class Case(playerInventory: InventoryPlayer, val computer: tileentity.Case) exte
val tooltip = new java.util.ArrayList[String]
val which = if (computer.isRunning) "gui.Robot.TurnOff" else "gui.Robot.TurnOn"
tooltip.add(StatCollector.translateToLocal(Settings.namespace + which))
drawHoveringText(tooltip, mouseX - guiLeft, mouseY - guiTop, fontRendererObj)
copiedDrawHoveringText(tooltip, mouseX - guiLeft, mouseY - guiTop, fontRendererObj)
}
GL11.glPopAttrib()
}

View File

@ -0,0 +1,72 @@
package li.cil.oc.client.gui
import net.minecraft.client.gui.inventory.GuiContainer
import java.util
import net.minecraft.client.gui.FontRenderer
import org.lwjgl.opengl.{GL12, GL11}
import net.minecraft.client.renderer.RenderHelper
import scala.collection.convert.WrapAsScala._
import net.minecraft.inventory.Container
// Workaround because certain other mods *cough*TMI*cough* do base class
// transformations that break things! Such fun. Many annoyed. And yes, this
// is a common issue, have a look at EnderIO and Enchanting Plus. They have
// to work around this, too.
abstract class CustomGuiContainer(container: Container) extends GuiContainer(container) {
// Pretty much Scalaified copy-pasta from base-class.
override def drawHoveringText(text: util.List[_], x: Int, y: Int, font: FontRenderer) {
copiedDrawHoveringText(text, x, y, font)
}
protected def copiedDrawHoveringText(text: util.List[_], x: Int, y: Int, font: FontRenderer) {
if (!text.isEmpty) {
GL11.glDisable(GL12.GL_RESCALE_NORMAL)
RenderHelper.disableStandardItemLighting()
GL11.glDisable(GL11.GL_LIGHTING)
GL11.glDisable(GL11.GL_DEPTH_TEST)
val textWidth = text.map(line => font.getStringWidth(line.asInstanceOf[String])).max
var posX = x + 12
var posY = y - 12
var textHeight = 8
if (text.size > 1) {
textHeight += 2 + (text.size - 1) * 10
}
if (posX + textWidth > width) {
posX -= 28 + textWidth
}
if (posY + textHeight + 6 > height) {
posY = height - textHeight - 6
}
zLevel = 300f
val bg = 0xF0100010
drawGradientRect(posX - 3, posY - 4, posX + textWidth + 3, posY - 3, bg, bg)
drawGradientRect(posX - 3, posY + textHeight + 3, posX + textWidth + 3, posY + textHeight + 4, bg, bg)
drawGradientRect(posX - 3, posY - 3, posX + textWidth + 3, posY + textHeight + 3, bg, bg)
drawGradientRect(posX - 4, posY - 3, posX - 3, posY + textHeight + 3, bg, bg)
drawGradientRect(posX + textWidth + 3, posY - 3, posX + textWidth + 4, posY + textHeight + 3, bg, bg)
val color1 = 0x505000FF
val color2 = 0x505000FE
drawGradientRect(posX - 3, posY - 3 + 1, posX - 3 + 1, posY + textHeight + 3 - 1, color1, color2)
drawGradientRect(posX + textWidth + 2, posY - 3 + 1, posX + textWidth + 3, posY + textHeight + 3 - 1, color1, color2)
drawGradientRect(posX - 3, posY - 3, posX + textWidth + 3, posY - 3 + 1, color1, color1)
drawGradientRect(posX - 3, posY + textHeight + 2, posX + textWidth + 3, posY + textHeight + 3, color2, color2)
for ((line, index) <- text.zipWithIndex) {
font.drawStringWithShadow(line.asInstanceOf[String], posX, posY, -1)
if (index == 0) {
posY += 2
}
posY += 10
}
zLevel = 0f
GL11.glEnable(GL11.GL_LIGHTING)
GL11.glEnable(GL11.GL_DEPTH_TEST)
RenderHelper.enableStandardItemLighting()
GL11.glEnable(GL12.GL_RESCALE_NORMAL)
}
}
}

View File

@ -3,14 +3,13 @@ package li.cil.oc.client.gui
import li.cil.oc.client.Textures
import li.cil.oc.common.container.ComponentSlot
import li.cil.oc.util.RenderState
import net.minecraft.client.gui.inventory.GuiContainer
import net.minecraft.client.renderer.Tessellator
import net.minecraft.client.renderer.texture.TextureMap
import net.minecraft.inventory.{Slot, Container}
import net.minecraft.util.StatCollector
import org.lwjgl.opengl.GL11
abstract class DynamicGuiContainer(container: Container) extends GuiContainer(container) {
abstract class DynamicGuiContainer(container: Container) extends CustomGuiContainer(container) {
override def drawGuiContainerForegroundLayer(mouseX: Int, mouseY: Int) {
fontRendererObj.drawString(
StatCollector.translateToLocal("container.inventory"),

View File

@ -122,7 +122,7 @@ class Rack(playerInventory: InventoryPlayer, val rack: tileentity.Rack) extends
val tooltip = new java.util.ArrayList[String]
val which = if (rack.isRunning(i)) "gui.Robot.TurnOff" else "gui.Robot.TurnOn"
tooltip.add(StatCollector.translateToLocal(Settings.namespace + which))
drawHoveringText(tooltip, mouseX - guiLeft, mouseY - guiTop, fontRendererObj)
copiedDrawHoveringText(tooltip, mouseX - guiLeft, mouseY - guiTop, fontRendererObj)
}
GL11.glPopAttrib()

View File

@ -10,7 +10,6 @@ import li.cil.oc.common.tileentity
import li.cil.oc.Settings
import li.cil.oc.util.RenderState
import net.minecraft.client.gui.GuiButton
import net.minecraft.client.gui.inventory.GuiContainer
import net.minecraft.client.Minecraft
import net.minecraft.client.renderer.Tessellator
import net.minecraft.client.renderer.texture.TextureMap
@ -20,7 +19,7 @@ import net.minecraft.util.StatCollector
import org.lwjgl.input.Keyboard
import org.lwjgl.opengl.GL11
class Robot(playerInventory: InventoryPlayer, val robot: tileentity.Robot) extends GuiContainer(new container.Robot(playerInventory, robot)) with Buffer {
class Robot(playerInventory: InventoryPlayer, val robot: tileentity.Robot) extends CustomGuiContainer(new container.Robot(playerInventory, robot)) with Buffer {
xSize = 256
ySize = 242
@ -92,13 +91,13 @@ class Robot(playerInventory: InventoryPlayer, val robot: tileentity.Robot) exten
((robot.globalBuffer / robot.globalBufferSize) * 100).toInt,
robot.globalBuffer.toInt,
robot.globalBufferSize.toInt))
drawHoveringText(tooltip, mouseX - guiLeft, mouseY - guiTop, fontRendererObj)
copiedDrawHoveringText(tooltip, mouseX - guiLeft, mouseY - guiTop, fontRendererObj)
}
if (powerButton.func_146115_a) {
val tooltip = new java.util.ArrayList[String]
val which = if (robot.isRunning) "gui.Robot.TurnOff" else "gui.Robot.TurnOn"
tooltip.add(StatCollector.translateToLocal(Settings.namespace + which))
drawHoveringText(tooltip, mouseX - guiLeft, mouseY - guiTop, fontRendererObj)
copiedDrawHoveringText(tooltip, mouseX - guiLeft, mouseY - guiTop, fontRendererObj)
}
GL11.glPopAttrib()
}

View File

@ -90,10 +90,10 @@ private[oc] object Registry extends api.detail.DriverAPI {
case arg: Array[_] => arg.map {
case (value: AnyRef) => convertRecursively(value)
}
case arg: Map[_, _] => arg.map {
case arg: Map[_, _] => arg.collect {
case (key: AnyRef, value: AnyRef) => convertRecursively(key) -> convertRecursively(value)
}
case arg: java.util.Map[_, _] => arg.map {
case arg: java.util.Map[_, _] => arg.collect {
case (key: AnyRef, value: AnyRef) => convertRecursively(key) -> convertRecursively(value)
}