From add557c91497ea3fa560be8e42731f26b669f0ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20N=C3=BCcke?= Date: Tue, 17 Dec 2013 23:57:36 +0100 Subject: [PATCH] overlay for up/down facing screens indicating their orientation to make it less confusing why screens won't connect --- .../textures/blocks/screen/up_indicator.png | Bin 0 -> 216 bytes .../renderer/tileentity/ScreenRenderer.scala | 70 ++++++++++++++---- 2 files changed, 55 insertions(+), 15 deletions(-) create mode 100644 assets/opencomputers/textures/blocks/screen/up_indicator.png diff --git a/assets/opencomputers/textures/blocks/screen/up_indicator.png b/assets/opencomputers/textures/blocks/screen/up_indicator.png new file mode 100644 index 0000000000000000000000000000000000000000..3a20853472b93dbedf478ec76b3a27e49de6952b GIT binary patch literal 216 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`k|nMYCBgY=CFO}lsSJ)O`AMk? zp1FzXsX?iUDV2pMQ*D5XsytmBLn>}1{rUgjo>{e_v(f1QQ}P+B?$CRTUh)ppJ&e`f zFtu+^KX24vFv-!S`XJ*fL7oqihg>|26`f~vT fadeDistanceSq) { RenderState.setBlendAlpha(math.max(0, 1 - ((distance - fadeDistanceSq) * fadeRatio).toFloat)) } - MonospaceFontRenderer.init(tileEntityRenderer.renderEngine) - val list = cache.get(screen, this) - compileOrDraw(list) + if (screen.hasPower) { + MonospaceFontRenderer.init(tileEntityRenderer.renderEngine) + val list = cache.get(screen, this) + compileOrDraw(list) + } GL11.glPopMatrix() GL11.glPopAttrib() } - private def compileOrDraw(list: Int) = if (screen.bufferIsDirty && !RenderState.compilingDisplayList) { - screen.bufferIsDirty = false - val sx = screen.width - val sy = screen.height - val tw = sx * 16f - val th = sy * 16f - - GL11.glNewList(list, GL11.GL_COMPILE_AND_EXECUTE) - + private def transform() { screen.yaw match { case ForgeDirection.WEST => GL11.glRotatef(-90, 0, 1, 0) case ForgeDirection.NORTH => GL11.glRotatef(180, 0, 1, 0) @@ -98,10 +99,49 @@ object ScreenRenderer extends TileEntitySpecialRenderer with Callable[Int] with // Fit area to screen (bottom left = bottom left). GL11.glTranslatef(-0.5f, -0.5f, 0.5f) - GL11.glTranslatef(0, sy, 0) + GL11.glTranslatef(0, screen.height, 0) // Flip text upside down. GL11.glScalef(1, -1, 1) + } + + private def drawOverlay() = if (screen.facing == ForgeDirection.UP || screen.facing == ForgeDirection.DOWN) { + // Show up vector overlay when holding same screen block. + val stack = Minecraft.getMinecraft.thePlayer.getHeldItem + if (stack != null) { + if (BuildCraft.holdsApplicableWrench(Minecraft.getMinecraft.thePlayer, screen.x, screen.y, screen.z) || + (stack.getItem match { + case block: block.Item => block.getMetadata(stack.getItemDamage) == screen.getBlockMetadata + case _ => false + })) { + GL11.glPushMatrix() + transform() + bindTexture(upIndicator) + GL11.glDepthMask(false) + GL11.glTranslatef(screen.width / 2f - 0.5f, screen.height / 2f - 0.5f, 0.05f) + val t = Tessellator.instance + t.startDrawingQuads() + t.addVertexWithUV(0, 1, 0, 0, 1) + t.addVertexWithUV(1, 1, 0, 1, 1) + t.addVertexWithUV(1, 0, 0, 1, 0) + t.addVertexWithUV(0, 0, 0, 0, 0) + t.draw() + GL11.glDepthMask(true) + GL11.glPopMatrix() + } + } + } + + private def compileOrDraw(list: Int) = if (screen.bufferIsDirty && !RenderState.compilingDisplayList) { + screen.bufferIsDirty = false + val sx = screen.width + val sy = screen.height + val tw = sx * 16f + val th = sy * 16f + + GL11.glNewList(list, GL11.GL_COMPILE_AND_EXECUTE) + + transform() // Offset from border. GL11.glTranslatef(sx * 2.25f / tw, sy * 2.25f / th, 0)