mirror of
https://github.com/GTNewHorizons/bdlib.git
synced 2026-11-22 21:19:52 +00:00
71 lines
1.9 KiB
Scala
71 lines
1.9 KiB
Scala
/*
|
|
* Copyright (c) bdew, 2013 - 2014
|
|
* https://github.com/bdew/bdlib
|
|
*
|
|
* This mod is distributed under the terms of the Minecraft Mod Public
|
|
* License 1.0, or MMPL. Please check the contents of the license located in
|
|
* https://raw.github.com/bdew/bdlib/master/MMPL-1.0.txt
|
|
*/
|
|
|
|
package net.bdew.lib.gui
|
|
|
|
import net.minecraft.client.gui.inventory.GuiContainer
|
|
import net.minecraft.inventory.Container
|
|
import scala.collection.mutable
|
|
import org.lwjgl.opengl.GL11
|
|
|
|
abstract class BaseScreen(cont: Container, xSz: Int, ySz: Int) extends GuiContainer(cont) {
|
|
xSize = xSz
|
|
ySize = ySz
|
|
|
|
val widgets = new WidgetContainerWindow(this, xSz, ySz)
|
|
|
|
val background: Texture
|
|
|
|
def rect = new Rect(guiLeft, guiTop, xSize, ySize)
|
|
|
|
def getFontRenderer = fontRenderer
|
|
def getZLevel = zLevel
|
|
|
|
override def initGui() {
|
|
super.initGui()
|
|
widgets.clear()
|
|
buttonList.clear()
|
|
}
|
|
|
|
protected override def mouseClicked(x: Int, y: Int, bt: Int) {
|
|
super.mouseClicked(x, y, bt)
|
|
widgets.mouseClicked(Point(x, y) - rect.origin, bt)
|
|
}
|
|
|
|
protected override def keyTyped(c: Char, i: Int) =
|
|
if (!widgets.keyTyped(c, i))
|
|
super.keyTyped(c, i)
|
|
|
|
protected override def drawGuiContainerForegroundLayer(x: Int, y: Int) =
|
|
widgets.draw(Point(x, y) - rect.origin)
|
|
|
|
protected override def drawScreen(x: Int, y: Int, f: Float) {
|
|
super.drawScreen(x, y, f)
|
|
|
|
val tip = mutable.MutableList.empty[String]
|
|
|
|
widgets.handleTooltip(Point(x, y) - rect.origin, tip)
|
|
|
|
import collection.JavaConversions._
|
|
|
|
if (tip.size > 0)
|
|
drawHoveringText(tip, x, y, fontRenderer)
|
|
}
|
|
|
|
protected def drawGuiContainerBackgroundLayer(f: Float, x: Int, y: Int) {
|
|
if (background != null)
|
|
widgets.drawTexture(rect, background)
|
|
|
|
GL11.glPushMatrix()
|
|
GL11.glTranslatef(rect.x, rect.y, 0)
|
|
widgets.drawBackground(Point(x, y) - rect.origin)
|
|
GL11.glPopMatrix()
|
|
}
|
|
}
|