mirror of
https://github.com/MightyPirates/OpenComputers.git
synced 2025-09-16 02:39:48 -04:00
made display resolution dependent
only display text if within the textfield
This commit is contained in:
parent
95a15ede56
commit
677f0757bf
@ -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)
|
||||
|
@ -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
|
||||
|
||||
|
@ -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) {
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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)
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
@ -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)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user