diff --git a/li/cil/oc/client/components/Screen.scala b/li/cil/oc/client/components/Screen.scala index 7b89ee678..8076e798a 100644 --- a/li/cil/oc/client/components/Screen.scala +++ b/li/cil/oc/client/components/Screen.scala @@ -9,6 +9,7 @@ class Screen(owner: TileEntityScreen) extends IScreen { override def toString = buffer.toString + def resolution = buffer.size def resolution_=(value: (Int, Int)) = { buffer.size = value owner.updateGui(buffer.toString) diff --git a/li/cil/oc/common/components/IScreen.scala b/li/cil/oc/common/components/IScreen.scala index d93954132..35f7312a7 100644 --- a/li/cil/oc/common/components/IScreen.scala +++ b/li/cil/oc/common/components/IScreen.scala @@ -5,7 +5,7 @@ import li.cil.oc.server.components.IComponent trait IScreen { def resolution_=(value: (Int, Int)): Unit - def resolution {} // Required for setter. + def resolution:(Int,Int) // Required for setter. def set(col: Int, row: Int, s: String): Unit diff --git a/li/cil/oc/common/container/ContainerComputer.scala b/li/cil/oc/common/container/ContainerComputer.scala index 087ccdfe5..88dd57c46 100644 --- a/li/cil/oc/common/container/ContainerComputer.scala +++ b/li/cil/oc/common/container/ContainerComputer.scala @@ -6,6 +6,7 @@ import net.minecraft.inventory.Slot import net.minecraft.item.ItemStack class ContainerComputer(playerInventory: InventoryPlayer, computer: TileEntityComputer) extends GenericInventoryContainer(playerInventory, computer) { + // Show the computer's inventory. // TODO nicer layout, separate for types, based on background image once it exists for (slotY <- 0 until 3) { diff --git a/li/cil/oc/common/gui/GuiComputer.scala b/li/cil/oc/common/gui/GuiComputer.scala index 515deb577..f33f39d45 100644 --- a/li/cil/oc/common/gui/GuiComputer.scala +++ b/li/cil/oc/common/gui/GuiComputer.scala @@ -26,13 +26,11 @@ class GuiComputer(inventory: InventoryPlayer, val tileEntity: TileEntityComputer //draw your Gui here, only thing you need to change is the path GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); this.mc.renderEngine.func_110577_a(new ResourceLocation("")); - val x = (width - xSize * 2) / 2; - val y = (height - ySize * 2) / 2; - this.drawTexturedModalRect(x, y, 0, 0, xSize * 2, ySize * 2); + val x = (width - xSize) / 2 + val y = (height - ySize) / 2; + this.drawTexturedModalRect(x, y, 0, 0, xSize, ySize); } - - override def drawScreen(mouseX: Int, mouseY: Int, dt: Float) = { super.drawScreen(mouseX, mouseY, dt); diff --git a/li/cil/oc/common/gui/GuiMultilineTextField.java b/li/cil/oc/common/gui/GuiMultilineTextField.java index 2450c854b..6443dea3f 100644 --- a/li/cil/oc/common/gui/GuiMultilineTextField.java +++ b/li/cil/oc/common/gui/GuiMultilineTextField.java @@ -93,6 +93,7 @@ public class GuiMultilineTextField extends Gui { int xStart = this.xPos + 4; int yStart = this.yPos + 4; int currentX = xStart; + for (String line : lines) { @@ -100,22 +101,30 @@ public class GuiMultilineTextField extends Gui { while (!completeLinePrinted) { String s = fontRenderer.trimStringToWidth(line, getWidth()); if (s.length() != line.length()) { + int end = s.lastIndexOf(" "); + if (end == -1) { + end = s.length(); + } s = s.substring(0, end); - line = line.substring(end+1); - } - else{ + line = line.substring(end + 1); + } else { completeLinePrinted = true; } if (s.length() > 0) { - int heightOld = fontRenderer.FONT_HEIGHT; currentX = fontRenderer.drawStringWithShadow(s, xStart, yStart, color); yStart += heightOld; + } else { } + if (yStart > height + yPos) { + + return; + } + } } diff --git a/li/cil/oc/common/gui/ScreenGui.scala b/li/cil/oc/common/gui/ScreenGui.scala index 5d1441943..c2084eb03 100644 --- a/li/cil/oc/common/gui/ScreenGui.scala +++ b/li/cil/oc/common/gui/ScreenGui.scala @@ -9,7 +9,15 @@ class ScreenGui(val tileEntity: TileEntityScreen) extends GuiScreen { override def initGui() = { super.initGui() - textField = new GuiMultilineTextField(this.fontRenderer, 20, 20, 200, 100) + var(w,h) = tileEntity.component.resolution + println(" widht: "+w) + println("heigth:" +h) + w *=2 + h *=2 + var x = (width - w)/2 + var y = (height -h)/2 + + textField = new GuiMultilineTextField(this.fontRenderer, x, y, w, h) textField.setText(tileEntity.text) } diff --git a/li/cil/oc/server/components/GraphicsCard.scala b/li/cil/oc/server/components/GraphicsCard.scala index f17881f33..9dea21464 100644 --- a/li/cil/oc/server/components/GraphicsCard.scala +++ b/li/cil/oc/server/components/GraphicsCard.scala @@ -21,7 +21,7 @@ class GraphicsCard(val nbt: NBTTagCompound) extends IComponent { val resolutions = List(List(40, 24), List(80, 24)) - private val buffer = new TextBuffer(40, 24) + private val buffer = new TextBuffer(80, 24) var screen: Screen = null diff --git a/li/cil/oc/server/components/Screen.scala b/li/cil/oc/server/components/Screen.scala index 9ad7b9106..c050d86b4 100644 --- a/li/cil/oc/server/components/Screen.scala +++ b/li/cil/oc/server/components/Screen.scala @@ -11,6 +11,7 @@ class Screen(val owner: TileEntityScreen) extends IScreen with IComponent { val (w, h) = value PacketSender.sendScreenResolutionChange(owner, w, h) } + def resolution = throw new NotImplementedError def set(col: Int, row: Int, s: String) = PacketSender.sendScreenSet(owner, col, row, s)