diff options
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/utils')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/utils/TimeUtils.kt | 7 | ||||
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/utils/renderables/Renderable.kt | 85 |
2 files changed, 90 insertions, 2 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/TimeUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/TimeUtils.kt index dcb6dcc93..4d7b7ad4d 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/TimeUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/TimeUtils.kt @@ -104,9 +104,12 @@ object TimeUtils { dayAndMonthElement: Boolean = true, yearElement: Boolean = true, hoursAndMinutesElement: Boolean = true, + timeFormat24h: Boolean = false, ): String { - val hour = (this.hour + 11) % 12 + 1 - val timeOfDay = if (this.hour > 11) "pm" else "am" + val hour = if (timeFormat24h) this.hour else (this.hour + 11) % 12 + 1 + val timeOfDay = if (!timeFormat24h) { + if (this.hour > 11) "pm" else "am" + } else "" val minute = this.minute.toString().padStart(2, '0') val month = SkyBlockTime.monthName(this.month) val day = this.day diff --git a/src/main/java/at/hannibal2/skyhanni/utils/renderables/Renderable.kt b/src/main/java/at/hannibal2/skyhanni/utils/renderables/Renderable.kt index 7a6fbce4b..29105459c 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/renderables/Renderable.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/renderables/Renderable.kt @@ -28,6 +28,7 @@ import at.hannibal2.skyhanni.utils.renderables.RenderableUtils.renderXAligned import at.hannibal2.skyhanni.utils.renderables.RenderableUtils.renderXYAligned import at.hannibal2.skyhanni.utils.renderables.RenderableUtils.renderYAligned import at.hannibal2.skyhanni.utils.shader.ShaderManager +import io.github.moulberry.notenoughupdates.util.Utils import io.github.notenoughupdates.moulconfig.gui.GuiScreenElementWrapper import net.minecraft.client.Minecraft import net.minecraft.client.gui.Gui @@ -38,6 +39,7 @@ import net.minecraft.client.renderer.GlStateManager import net.minecraft.entity.player.EntityPlayer import net.minecraft.item.ItemStack import net.minecraft.util.ResourceLocation +import org.lwjgl.opengl.GL11 import java.awt.Color import java.util.Collections import kotlin.math.max @@ -907,6 +909,89 @@ interface Renderable { } } + fun drawInsideRoundedRectOutline( + input: Renderable, + padding: Int = 2, + radius: Int = 10, + smoothness: Int = 2, + topOutlineColor: Int, + bottomOutlineColor: Int, + borderOutlineThickness: Int, + blur: Float = 0.7f, + horizontalAlign: HorizontalAlignment = HorizontalAlignment.LEFT, + verticalAlign: VerticalAlignment = VerticalAlignment.TOP, + ) = object : Renderable { + override val width = input.width + padding * 2 + override val height = input.height + padding * 2 + override val horizontalAlign = horizontalAlign + override val verticalAlign = verticalAlign + + override fun render(posX: Int, posY: Int) { + GlStateManager.translate(padding.toFloat(), padding.toFloat(), 0f) + input.render(posX + padding, posY + padding) + GlStateManager.translate(-padding.toFloat(), -padding.toFloat(), 0f) + + RenderUtils.drawRoundRectOutline( + 0, + 0, + width, + height, + topOutlineColor, + bottomOutlineColor, + borderOutlineThickness, + radius, + blur, + ) + } + } + + fun drawInsideImage( + input: Renderable, + texture: ResourceLocation, + alpha: Int = 255, + padding: Int = 2, + horizontalAlign: HorizontalAlignment = HorizontalAlignment.LEFT, + verticalAlign: VerticalAlignment = VerticalAlignment.TOP, + radius: Int = 0, + ) = object : Renderable { + override val width = input.width + padding * 2 + override val height = input.height + padding * 2 + override val horizontalAlign = horizontalAlign + override val verticalAlign = verticalAlign + + override fun render(posX: Int, posY: Int) { + Minecraft.getMinecraft().textureManager.bindTexture(texture) + GlStateManager.color(1f, 1f, 1f, alpha / 255f) + RenderUtils.drawRoundTexturedRect(0, 0, width, height, GL11.GL_NEAREST, radius) + GlStateManager.color(1f, 1f, 1f, 1f) + + GlStateManager.translate(padding.toFloat(), padding.toFloat(), 0f) + input.render(posX + padding, posY + padding) + GlStateManager.translate(-padding.toFloat(), -padding.toFloat(), 0f) + } + } + + fun image( + texture: ResourceLocation, + width: Int, + height: Int, + alpha: Int = 255, + horizontalAlign: HorizontalAlignment = HorizontalAlignment.LEFT, + verticalAlign: VerticalAlignment = VerticalAlignment.TOP, + ) = object : Renderable { + override val width = width + override val height = height + override val horizontalAlign = horizontalAlign + override val verticalAlign = verticalAlign + + override fun render(posX: Int, posY: Int) { + Minecraft.getMinecraft().textureManager.bindTexture(texture) + GlStateManager.color(1f, 1f, 1f, alpha / 255f) + Utils.drawTexturedRect(0f, 0f, width.toFloat(), height.toFloat(), GL11.GL_NEAREST) + GlStateManager.color(1f, 1f, 1f, 1f) + } + } + fun drawInsideRoundedRectWithOutline( input: Renderable, color: Color, |