Add a colorEnd() method to the companion object of ColoredElement, render more things in the ClickBox class and edit en_us.json
This commit is contained in:
		
							parent
							
								
									f3d291e180
								
							
						
					
					
						commit
						31bb7be602
					
				@ -7,25 +7,39 @@ import net.minecraft.client.Minecraft
 | 
				
			|||||||
import net.minecraft.network.chat.TranslatableComponent
 | 
					import net.minecraft.network.chat.TranslatableComponent
 | 
				
			||||||
import org.lwjgl.opengl.GL20
 | 
					import org.lwjgl.opengl.GL20
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class ClickBox(x: Double, y: Double, private val name: TranslatableComponent? = null): ColoredElement(x, y, 80, 10, 0x6C9E9D) {
 | 
					class ClickBox(x: Double, y: Double, private val name: TranslatableComponent? = null): ColoredElement(x, y, 80, 10, 0x6C9E9D, 0.5F) {
 | 
				
			||||||
    var opacity = 0.5F
 | 
					    private companion object {
 | 
				
			||||||
 | 
					        const val inclination: Double = 2.5
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
    override fun render(poseStack: PoseStack?) {
 | 
					    override fun render(poseStack: PoseStack?) {
 | 
				
			||||||
        RenderSystem.disableTexture()
 | 
					        RenderSystem.disableTexture()
 | 
				
			||||||
        RenderSystem.enableBlend()
 | 
					        RenderSystem.enableBlend()
 | 
				
			||||||
        RenderSystem.defaultBlendFunc()
 | 
					        RenderSystem.defaultBlendFunc()
 | 
				
			||||||
        with(buffer) {
 | 
					        with(buffer) {
 | 
				
			||||||
            begin(GL20.GL_POLYGON, DefaultVertexFormat.POSITION_COLOR)
 | 
					            begin(GL20.GL_POLYGON, DefaultVertexFormat.POSITION_COLOR)
 | 
				
			||||||
            vertex(x, y + height, 0.0).colorIt(color, opacity).endVertex()
 | 
					            // Render the header:
 | 
				
			||||||
            vertex(x + width, y + height, 0.0).colorIt(color, opacity).endVertex()
 | 
					            vertex(x, y + height, 0.0).colorEnd()
 | 
				
			||||||
            vertex(x + width, y, 0.0).colorIt(color, opacity).endVertex()
 | 
					            vertex(x + width + inclination, y + height, 0.0).colorEnd()
 | 
				
			||||||
            vertex(x, y, 0.0).colorIt(color, opacity).endVertex()
 | 
					            vertex(x + width, y, 0.0).colorEnd()
 | 
				
			||||||
 | 
					            vertex(x + inclination, y, 0.0).colorEnd()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            // Render the box:
 | 
				
			||||||
 | 
					            val fullHeight = (y + height) * 6
 | 
				
			||||||
 | 
					            vertex(x, fullHeight, 0.0).colorEnd()
 | 
				
			||||||
 | 
					            vertex(x + width + inclination, fullHeight, 0.0).colorEnd()
 | 
				
			||||||
 | 
					            vertex(x + width + inclination, y + height, 0.0).colorEnd()
 | 
				
			||||||
 | 
					            tessellator.end()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            begin(GL20.GL_LINES, DefaultVertexFormat.POSITION_COLOR)
 | 
				
			||||||
 | 
					            vertex(x + inclination, y + height, 0.0).colorIt(0xF2F2FC).endVertex()
 | 
				
			||||||
 | 
					            vertex(x + width, y + height, 0.0).colorIt(0xF2F2FC).endVertex()
 | 
				
			||||||
            tessellator.end()
 | 
					            tessellator.end()
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        RenderSystem.enableTexture()
 | 
					        RenderSystem.enableTexture()
 | 
				
			||||||
        RenderSystem.disableBlend()
 | 
					        RenderSystem.disableBlend()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if ((name != null) && (poseStack != null)) {
 | 
					        if ((name != null) && (poseStack != null)) {
 | 
				
			||||||
            Minecraft.getInstance().font.draw(poseStack, name.string, x.toFloat() + 2, y.toFloat() + 1.5F, TransparentColor)
 | 
					            Minecraft.getInstance().font.draw(poseStack, name.string, x.toFloat() + 5, y.toFloat() + 1.5F, TransparentColor)
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@ -18,7 +18,7 @@ abstract class Element(
 | 
				
			|||||||
    var hidden: Boolean = false
 | 
					    var hidden: Boolean = false
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
abstract class ColoredElement(x: Double, y: Double, width: Int, height: Int, val color: Int) : Element(x, y, width, height) {
 | 
					abstract class ColoredElement(x: Double, y: Double, width: Int, height: Int, val color: Int, val opacity: Float) : Element(x, y, width, height) {
 | 
				
			||||||
    companion object {
 | 
					    companion object {
 | 
				
			||||||
        const val TransparentColor: Int = -0x1
 | 
					        const val TransparentColor: Int = -0x1
 | 
				
			||||||
        @JvmStatic protected fun VertexConsumer.colorIt(color: Int, opacity: Float = 1F): VertexConsumer {
 | 
					        @JvmStatic protected fun VertexConsumer.colorIt(color: Int, opacity: Float = 1F): VertexConsumer {
 | 
				
			||||||
@ -27,6 +27,7 @@ abstract class ColoredElement(x: Double, y: Double, width: Int, height: Int, val
 | 
				
			|||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					    protected fun VertexConsumer.colorEnd() = colorIt(color, opacity).endVertex()
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
fun hextoRGB(hex: Int): MutableList<Float> {
 | 
					fun hextoRGB(hex: Int): MutableList<Float> {
 | 
				
			||||||
 | 
				
			|||||||
@ -4,6 +4,6 @@
 | 
				
			|||||||
  "category.snowy.keycategory": "SnowyGUI",
 | 
					  "category.snowy.keycategory": "SnowyGUI",
 | 
				
			||||||
  "key.snowy.opengui": "Open the snowy gui",
 | 
					  "key.snowy.opengui": "Open the snowy gui",
 | 
				
			||||||
  "key.snowy.configkey": "Open the snowy configuration screen",
 | 
					  "key.snowy.configkey": "Open the snowy configuration screen",
 | 
				
			||||||
  "snowy.clickbox.misc": "Misc",
 | 
					  "snowy.clickbox.misc": "Miscellaneous",
 | 
				
			||||||
  "snowy.clickbox.rendering": "Rendering"
 | 
					  "snowy.clickbox.rendering": "Rendering"
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user