Skip to content

Commit

Permalink
dvd to nvg renderer, unfinished
Browse files Browse the repository at this point in the history
  • Loading branch information
Stivais committed Dec 2, 2024
1 parent 937eeeb commit 00cc734
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 19 deletions.
4 changes: 2 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ allprojects {
annotationProcessor("org.spongepowered:mixin:0.8.5-SNAPSHOT")
implementation("org.spongepowered:mixin:0.7.11-SNAPSHOT") { isTransitive = false }

// implementation("com.github.stivais:AuroraUI:0.9.1-beta")
implementation("com.github.stivais:AuroraUI:0.9.1-beta")
// todo: create releases for aurora
implementation("com.github.stivais:AuroraUI:e8cff5402b")
// implementation("com.github.stivais:AuroraUI:e8cff5402b")

implementation("com.github.odtheking:odin-lwjgl:faeaa48b39")

Expand Down
41 changes: 27 additions & 14 deletions src/main/kotlin/me/odinmain/features/impl/render/DVD.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,30 @@ import me.odinmain.features.Module
import me.odinmain.features.settings.impl.BooleanSetting
import me.odinmain.features.settings.impl.NumberSetting
import me.odinmain.features.settings.impl.StringSetting
import me.odinmain.utils.render.RenderUtils.bind
import me.odinmain.utils.skyblock.PlayerUtils
import me.odinmain.utils.skyblock.modMessage
import net.minecraft.client.gui.ScaledResolution
import me.odinmain.utils.ui.renderer.NVGRenderer
import net.minecraftforge.client.event.RenderGameOverlayEvent
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import net.minecraftforge.fml.common.gameevent.TickEvent
import org.lwjgl.opengl.Display
import java.awt.Color.getHSBColor

object DVD : Module(
name = "DVD",
description = "No further explanation."
) {
private val boxWidth by NumberSetting("Box Width", 50, 0, 150, 1, description = "Width of the DVD box.")
private val boxHeight by NumberSetting("Box Height", 50, 0, 150, 1, description = "Height of the DVD box.")
private val boxWidth by NumberSetting("Box Width", 50f, 0, 150, 1, description = "Width of the DVD box.")
private val boxHeight by NumberSetting("Box Height", 50f, 0, 150, 1, description = "Height of the DVD box.")
private val roundedCorners by BooleanSetting("Rounded Corners", true, description = "Whether the DVD box should have rounded corners.")

private val speed by NumberSetting("Speed", 1, .1, 2, .1, description = "Speed of the DVD box.")
private val text by StringSetting("Text", "ODVD", description = "Text to display on the DVD box.")
private val textScale by NumberSetting("Text Scale", 1.5f, 0.1f, 2f, 0.1f, description = "Scale of the text.")

override fun onEnable() {
x = Display.getWidth() / 4
y = Display.getHeight() / 4
x = Display.getWidth() / 4f
y = Display.getHeight() / 4f
super.onEnable()
}

Expand All @@ -41,8 +41,8 @@ object DVD : Module(
private var dx = 1
private var dy = 1

private var x = Display.getWidth() / 2
private var y = Display.getHeight() / 2
private var x = Display.getWidth() / 2f
private var y = Display.getHeight() / 2f
private var color = Color.WHITE

private fun getDVDColor() {
Expand All @@ -52,26 +52,39 @@ object DVD : Module(
color = Color.RGB(javaColor.red, javaColor.green, javaColor.blue)
}

// THIS SHOULD/WILL BE THE ONLY "HUD" TO NOT USE HUD SYSTEM (and directly renders).
// I am not redoing it just so it can support this single joke module.

@SubscribeEvent
fun onRenderOverlay(event: RenderGameOverlayEvent.Post) {
if (event.type != RenderGameOverlayEvent.ElementType.ALL) return


NVGRenderer.beginFrame(Display.getWidth().toFloat(), Display.getHeight().toFloat())
val r = if (roundedCorners) 12f else 0f
NVGRenderer.rect(x, y, boxWidth, boxHeight, color.rgba, r, r, r, r)
NVGRenderer.endFrame()
/*roundedRectangle(x, y, boxWidth, boxHeight, color, if (roundedCorners) 12f else 0f)
mcText(text, x + boxWidth / 2, y + boxHeight / 2 - getMCTextHeight() * textScale / 2 , textScale, color, true)*/
Color.WHITE.bind()
}

@SubscribeEvent
fun onTick(event: TickEvent.ClientTickEvent) {
if (event.phase == TickEvent.Phase.END) return

}

private fun updateDVD() {
x += dx
y += dy
val sr = ScaledResolution(mc)

// Get screen dimensions
val screenWidth = sr.scaledWidth
val screenHeight = sr.scaledHeight
val screenWidth = Display.getWidth()
val screenHeight = Display.getHeight()

// Check collision with screen edges
if (x <= 0) {
x = 0 // Reset x position to prevent going out of bounds
x = 0f // Reset x position to prevent going out of bounds
getDVDColor()
dx = -dx // Reverse horizontal direction
} else if (x + boxWidth >= screenWidth) {
Expand All @@ -81,7 +94,7 @@ object DVD : Module(
}

if (y <= 0) {
y = 0 // Reset y position to prevent going out of bounds
y = 0f // Reset y position to prevent going out of bounds
getDVDColor()
dy = -dy // Reverse vertical direction
} else if (y + boxHeight >= screenHeight) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,9 @@ class StringSetting(
hoverColor.animate(0.25.seconds, style = Animation.Style.EaseOutQuad)
}
}
}//
}
}

private fun getLengthColor(string: String) =
if (string.length > length) Color.RED else Color.RGB(200, 200, 200)
if (string.length >= length) Color.RED else Color.RGB(200, 200, 200)
}
5 changes: 4 additions & 1 deletion src/main/kotlin/me/odinmain/utils/ui/renderer/NVGRenderer.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package me.odinmain.utils.ui.renderer

import com.github.stivais.aurora.color.Color
import com.github.stivais.aurora.renderer.Renderer
import com.github.stivais.aurora.renderer.data.Font
import com.github.stivais.aurora.renderer.data.Gradient
Expand Down Expand Up @@ -153,7 +154,7 @@ object NVGRenderer : Renderer, Lwjgl3Wrapper by wrapper {
nvgRGBA(0, 0, 0, 125, nvgColor)
nvgRGBA(0, 0, 0, 0, nvgColor2)

// TODO: fix gradient bug i have no clue why its doing that
// TODO: fix gradient bug i have no clue why its doing that
nvgBoxGradient(vg, x - spread, y - spread, width + 2 * spread, height + 2 * spread, tl + spread, blur, nvgColor, nvgColor2, nvgPaint)
nvgBeginPath(vg)
nvgRoundedRect(vg, x - spread - blur, y - spread - blur, width + 2 * spread + 2 * blur, height + 2 * spread + 2 * blur, tl + spread)
Expand Down Expand Up @@ -193,6 +194,8 @@ object NVGRenderer : Renderer, Lwjgl3Wrapper by wrapper {
nvgImagePattern(vg, x, y, w, h, 0f, getImage(image), 1f, nvgPaint)
nvgBeginPath(vg)
nvgRoundedRectVarying(vg, x, y, w, h, tl, tr, br, bl)
color(Color.RED.rgba)
nvgFillColor(vg, nvgColor)
nvgFillPaint(vg, nvgPaint)
nvgFill(vg)
}
Expand Down

0 comments on commit 00cc734

Please sign in to comment.