From 2d9764da8c0651c99a04d3e0bc02e6ad1dd67dab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20N=C3=BCcke?= Date: Fri, 10 Apr 2015 17:56:11 +0200 Subject: [PATCH] Tried to improve and stabilize masking logic for manual content a bit. --- .../doc/en_US/block/chameliumBlock.md | 2 +- src/main/scala/li/cil/oc/client/Manual.scala | 2 +- .../client/renderer/markdown/Document.scala | 29 +++++++++---------- .../opencomputers/ModOpenComputers.scala | 10 +++---- 4 files changed, 20 insertions(+), 23 deletions(-) diff --git a/src/main/resources/assets/opencomputers/doc/en_US/block/chameliumBlock.md b/src/main/resources/assets/opencomputers/doc/en_US/block/chameliumBlock.md index 083eb538d..502ef4612 100644 --- a/src/main/resources/assets/opencomputers/doc/en_US/block/chameliumBlock.md +++ b/src/main/resources/assets/opencomputers/doc/en_US/block/chameliumBlock.md @@ -4,4 +4,4 @@ A bunch of [Chaemlium](../item/chamelium.md) slapped together, this can be nice to decorate parts of your base, if you want a clean, monochrome block. Can be dyed to take any one of the 16 common Minecraft colors. -Another use is to pick its texture and use that in your [3D prints](print.m3d), if you want something clean white to apply a tint to. +Another use is to pick its texture and use that in your [3D prints](print.md), if you want something clean white to apply a tint to. diff --git a/src/main/scala/li/cil/oc/client/Manual.scala b/src/main/scala/li/cil/oc/client/Manual.scala index f9f09b1fb..a5acb2850 100644 --- a/src/main/scala/li/cil/oc/client/Manual.scala +++ b/src/main/scala/li/cil/oc/client/Manual.scala @@ -111,7 +111,7 @@ object Manual extends ManualAPI { def reset(): Unit = { history.clear() - history.push(new History(s"doc/$LanguageKey/index.md")) + history.push(new History(s"$LanguageKey/index.md")) } override def navigate(path: String): Unit = { diff --git a/src/main/scala/li/cil/oc/client/renderer/markdown/Document.scala b/src/main/scala/li/cil/oc/client/renderer/markdown/Document.scala index b067bfdd1..a159d2a47 100644 --- a/src/main/scala/li/cil/oc/client/renderer/markdown/Document.scala +++ b/src/main/scala/li/cil/oc/client/renderer/markdown/Document.scala @@ -35,30 +35,27 @@ object Document { def render(document: Iterable[Segment], x: Int, y: Int, maxWidth: Int, maxHeight: Int, yOffset: Int, renderer: FontRenderer, mouseX: Int, mouseY: Int): Option[InteractiveSegment] = { val mc = Minecraft.getMinecraft - // Create a flat, inset area in the depth buffer. + // Clear depth mask, then create masks in foreground above and below scroll area. GL11.glColor4f(1, 1, 1, 1) - GL11.glPushMatrix() - GL11.glTranslatef(0, 0, 300) - GL11.glDepthFunc(GL11.GL_ALWAYS) + GL11.glClear(GL11.GL_DEPTH_BUFFER_BIT) + GL11.glEnable(GL11.GL_DEPTH_TEST) + GL11.glDepthFunc(GL11.GL_LEQUAL) GL11.glDepthMask(true) GL11.glColorMask(false, false, false, false) + + GL11.glPushMatrix() + GL11.glTranslatef(0, 0, 300) GL11.glBegin(GL11.GL_QUADS) - GL11.glVertex2f(0, mc.displayHeight) - GL11.glVertex2f(mc.displayWidth, mc.displayHeight) + GL11.glVertex2f(0, y) + GL11.glVertex2f(mc.displayWidth, y) GL11.glVertex2f(mc.displayWidth, 0) GL11.glVertex2f(0, 0) + GL11.glVertex2f(0, mc.displayHeight) + GL11.glVertex2f(mc.displayWidth, mc.displayHeight) + GL11.glVertex2f(mc.displayWidth, y + maxHeight) + GL11.glVertex2f(0, y + maxHeight) GL11.glEnd() - GL11.glPopMatrix() - GL11.glBegin(GL11.GL_QUADS) - GL11.glVertex2f(x - 1, y - 1) - GL11.glVertex2f(x - 1, y + 1 + maxHeight) - GL11.glVertex2f(x + 1 + maxWidth, y + 1 + maxHeight) - GL11.glVertex2f(x + 1 + maxWidth, y - 1) - GL11.glEnd() - - // Use that flat area to mask the output area. - GL11.glDepthFunc(GL11.GL_LEQUAL) GL11.glColorMask(true, true, true, true) // Actual rendering. diff --git a/src/main/scala/li/cil/oc/integration/opencomputers/ModOpenComputers.scala b/src/main/scala/li/cil/oc/integration/opencomputers/ModOpenComputers.scala index 6fad3ec28..8a9337709 100644 --- a/src/main/scala/li/cil/oc/integration/opencomputers/ModOpenComputers.scala +++ b/src/main/scala/li/cil/oc/integration/opencomputers/ModOpenComputers.scala @@ -202,14 +202,14 @@ object ModOpenComputers extends ModProxy { } api.Manual.addProvider(DefinitionPathProvider) - api.Manual.addProvider(new ResourceContentProvider(Settings.resourceDomain)) + api.Manual.addProvider(new ResourceContentProvider(Settings.resourceDomain, "doc/")) api.Manual.addProvider("", TextureImageProvider) api.Manual.addProvider("item", ItemImageProvider) api.Manual.addProvider("block", BlockImageProvider) api.Manual.addProvider("oredict", OreDictImageProvider) - api.Manual.addTab(new ItemStackTabIconRenderer(api.Items.get("case1").createItemStack(1)), "oc:gui.Manual.Blocks", "doc/%LANGUAGE%/block/index.md") - api.Manual.addTab(new ItemStackTabIconRenderer(api.Items.get("chip1").createItemStack(1)), "oc:gui.Manual.Items", "doc/%LANGUAGE%/item/index.md") + api.Manual.addTab(new ItemStackTabIconRenderer(api.Items.get("case1").createItemStack(1)), "oc:gui.Manual.Blocks", "%LANGUAGE%/block/index.md") + api.Manual.addTab(new ItemStackTabIconRenderer(api.Items.get("chip1").createItemStack(1)), "oc:gui.Manual.Items", "%LANGUAGE%/item/index.md") } private def blacklistHost(host: Class[_], itemNames: String*) { @@ -239,8 +239,8 @@ object ModOpenComputers extends ModProxy { private def checkBlacklisted(info: ItemInfo): String = if (info == null || Blacklist.contains(info.name)) null - else if (info.block != null) "doc/%LANGUAGE%/block/" + info.name + ".md" - else "doc/%LANGUAGE%/item/" + info.name + ".md" + else if (info.block != null) "%LANGUAGE%/block/" + info.name + ".md" + else "%LANGUAGE%/item/" + info.name + ".md" } }