Compare commits
No commits in common. "1.20" and "1.19.4" have entirely different histories.
|
@ -13,11 +13,11 @@ buildscript {
|
||||||
}
|
}
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
kotlin("jvm") version "1.9.24"
|
kotlin("jvm") version "1.9.22"
|
||||||
kotlin("plugin.serialization") version "1.9.24"
|
kotlin("plugin.serialization") version "1.9.22"
|
||||||
id("com.github.johnrengelman.shadow") version "8.1.1" apply false
|
id("com.github.johnrengelman.shadow") version "8.1.1" apply false
|
||||||
id("architectury-plugin") version "[3.4.124, 3.5["
|
id("architectury-plugin") version "[3.4.124, 3.5["
|
||||||
id("dev.architectury.loom") version "1.5-SNAPSHOT" apply false
|
id("dev.architectury.loom") version "1.4-SNAPSHOT" apply false
|
||||||
id("com.github.ben-manes.versions") version "0.51.0"
|
id("com.github.ben-manes.versions") version "0.51.0"
|
||||||
id("net.kyori.indra.git") version "3.1.3"
|
id("net.kyori.indra.git") version "3.1.3"
|
||||||
id("org.cqfn.diktat.diktat-gradle-plugin") version "1.2.5"
|
id("org.cqfn.diktat.diktat-gradle-plugin") version "1.2.5"
|
||||||
|
@ -25,7 +25,7 @@ plugins {
|
||||||
}
|
}
|
||||||
|
|
||||||
group = "fr.username404"
|
group = "fr.username404"
|
||||||
version = "0.3.5"
|
version = "0.3.4"
|
||||||
val groupAndName = "${rootProject.group}.${rootProject.name.toLowerCase()}"
|
val groupAndName = "${rootProject.group}.${rootProject.name.toLowerCase()}"
|
||||||
|
|
||||||
val javaVer: String = "17"
|
val javaVer: String = "17"
|
||||||
|
@ -51,7 +51,7 @@ subprojects {
|
||||||
apply(plugin = "org.jetbrains.kotlin.plugin.serialization")
|
apply(plugin = "org.jetbrains.kotlin.plugin.serialization")
|
||||||
extensions.configure<LoomGradleExtension>("loom") {
|
extensions.configure<LoomGradleExtension>("loom") {
|
||||||
mappingsDep = layered {
|
mappingsDep = layered {
|
||||||
officialMojangMappings().parchment("org.parchmentmc.data:parchment-1.20.1:2023.06.26")
|
officialMojangMappings().parchment("org.parchmentmc.data:parchment-1.19.4:2023.06.26")
|
||||||
}
|
}
|
||||||
silentMojangMappingsLicense()
|
silentMojangMappingsLicense()
|
||||||
val refmap = "snowygui-${project.name}-refmap.json"
|
val refmap = "snowygui-${project.name}-refmap.json"
|
||||||
|
@ -75,8 +75,8 @@ subprojects {
|
||||||
implementation("$kotlinX:kotlinx-serialization-core:$serializationVer")
|
implementation("$kotlinX:kotlinx-serialization-core:$serializationVer")
|
||||||
implementation("$kotlinX:kotlinx-serialization-json:$serializationVer")
|
implementation("$kotlinX:kotlinx-serialization-json:$serializationVer")
|
||||||
listOf(
|
listOf(
|
||||||
"com.typesafe:config:1.4.3",
|
"com.typesafe:config:1.4.2",
|
||||||
"io.github.config4k:config4k:0.6.0",
|
"io.github.config4k:config4k:0.5.0",
|
||||||
"com.github.Vatuu:discord-rpc:1.6.2"
|
"com.github.Vatuu:discord-rpc:1.6.2"
|
||||||
).forEach { implementation(it); shadowC(it) { isTransitive = false; exclude("com.sun.jna") } }
|
).forEach { implementation(it); shadowC(it) { isTransitive = false; exclude("com.sun.jna") } }
|
||||||
"minecraft"("com.mojang:minecraft:${rootProject.property("minecraft")}")
|
"minecraft"("com.mojang:minecraft:${rootProject.property("minecraft")}")
|
||||||
|
|
|
@ -14,29 +14,17 @@ object ClickGui: SnowyScreen() {
|
||||||
private inline fun buttonsContext(args: ColoredElement.() -> Unit) = boxContext { buttons.forEach {
|
private inline fun buttonsContext(args: ColoredElement.() -> Unit) = boxContext { buttons.forEach {
|
||||||
if (it.y > y + height) it.args()
|
if (it.y > y + height) it.args()
|
||||||
} }
|
} }
|
||||||
|
override fun mouseClicked(d: Double, e: Double, i: Int): Boolean { buttonsContext { this.mouseClicked(d, e, i) }; return false }
|
||||||
private var draggingBox: String? = null
|
override fun mouseReleased(d: Double, e: Double, i: Int): Boolean { buttonsContext { this.mouseReleased(d, e, i) }; return false }
|
||||||
private inline fun currentBoxContext(args: ClickBox.() -> Unit): Unit? = draggingBox?.run { boxContext { if (name.string == draggingBox) args() } }
|
|
||||||
private var offsetX: Double = 0.0;
|
|
||||||
private var offsetY: Double = 0.0;
|
|
||||||
override fun mouseClicked(d: Double, e: Double, i: Int): Boolean {
|
|
||||||
if (i == GLFW.GLFW_MOUSE_BUTTON_LEFT) {
|
|
||||||
clickBoxes.find { it.isWithinBounds(d, e) }?.let { draggingBox = it.name.string }
|
|
||||||
currentBoxContext {
|
|
||||||
offsetX = d - (x + width)
|
|
||||||
offsetY = e - (y + height)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
buttonsContext { this.mouseClicked(d, e, i) }; return super.mouseClicked(d, e, i);
|
|
||||||
}
|
|
||||||
override fun mouseReleased(d: Double, e: Double, i: Int): Boolean { draggingBox = null; buttonsContext { this.mouseReleased(d, e, i) }; return false }
|
|
||||||
override fun mouseScrolled(d: Double, e: Double, f: Double): Boolean { boxContext { scroll(d, e, f) }; return false }
|
override fun mouseScrolled(d: Double, e: Double, f: Double): Boolean { boxContext { scroll(d, e, f) }; return false }
|
||||||
|
|
||||||
override fun mouseDragged(d: Double, e: Double, i: Int, f: Double, g: Double): Boolean {
|
override fun mouseDragged(d: Double, e: Double, i: Int, f: Double, g: Double): Boolean {
|
||||||
if (i == GLFW.GLFW_MOUSE_BUTTON_LEFT) {
|
if (i == GLFW.GLFW_MOUSE_BUTTON_LEFT) {
|
||||||
currentBoxContext {
|
components.forEach {
|
||||||
x = (d + offsetX).coerceIn(0.0..this@ClickGui.width - width.toDouble())
|
if (it.isWithinBounds(d.minus(f), e.minus(g)) && !isDragging) {
|
||||||
y = (e + offsetY).coerceIn(0.0..this@ClickGui.height - height.toDouble())
|
isDragging = true
|
||||||
|
it.x = d.minus(f) + (d - (it.x + it.width))
|
||||||
|
it.y = e.minus(g) + (e - (it.y + it.height))
|
||||||
|
} else isDragging = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return super.mouseDragged(d, e, i, f, g)
|
return super.mouseDragged(d, e, i, f, g)
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
package fr.username404.snowygui.config
|
package fr.username404.snowygui.config
|
||||||
|
|
||||||
|
import com.mojang.blaze3d.vertex.PoseStack
|
||||||
import fr.username404.snowygui.ClickGui
|
import fr.username404.snowygui.ClickGui
|
||||||
|
import fr.username404.snowygui.utils.FontUtil
|
||||||
import fr.username404.snowygui.gui.elements.ClickBox
|
import fr.username404.snowygui.gui.elements.ClickBox
|
||||||
import fr.username404.snowygui.gui.elements.ClickBox.Companion.buttonsMax
|
import fr.username404.snowygui.gui.elements.ClickBox.Companion.buttonsMax
|
||||||
import fr.username404.snowygui.gui.elements.ClickBox.Companion.sortAlphabetically
|
import fr.username404.snowygui.gui.elements.ClickBox.Companion.sortAlphabetically
|
||||||
|
@ -9,8 +11,6 @@ import fr.username404.snowygui.gui.feature.Colors
|
||||||
import fr.username404.snowygui.gui.feature.Macro
|
import fr.username404.snowygui.gui.feature.Macro
|
||||||
import fr.username404.snowygui.gui.feature.Keystrokes
|
import fr.username404.snowygui.gui.feature.Keystrokes
|
||||||
import fr.username404.snowygui.gui.feature.Zoom
|
import fr.username404.snowygui.gui.feature.Zoom
|
||||||
import fr.username404.snowygui.utils.FontUtil
|
|
||||||
import net.minecraft.client.gui.GuiGraphics
|
|
||||||
import net.minecraft.client.gui.screens.Screen
|
import net.minecraft.client.gui.screens.Screen
|
||||||
import net.minecraft.network.chat.Component
|
import net.minecraft.network.chat.Component
|
||||||
import net.minecraft.network.chat.Component.translatable
|
import net.minecraft.network.chat.Component.translatable
|
||||||
|
@ -27,9 +27,9 @@ private fun supplyComponent(string: String?): Optional<Component> = string?.run
|
||||||
|
|
||||||
val SnowyConfigScreen: Screen = object: Screen(translationComponent) {
|
val SnowyConfigScreen: Screen = object: Screen(translationComponent) {
|
||||||
override fun isPauseScreen(): Boolean = false
|
override fun isPauseScreen(): Boolean = false
|
||||||
override fun render(guiGraphics: GuiGraphics, i: Int, j: Int, f: Float) {
|
override fun render(poseStack: PoseStack, i: Int, j: Int, f: Float) {
|
||||||
super.renderBackground(guiGraphics)
|
super.renderBackground(poseStack)
|
||||||
FontUtil.drawScaled(guiGraphics,
|
FontUtil.drawScaled(poseStack,
|
||||||
text = "An appropriate version of the Cloth Config mod is required for the configuration of snowygui.", 16.0, 16.0,
|
text = "An appropriate version of the Cloth Config mod is required for the configuration of snowygui.", 16.0, 16.0,
|
||||||
color = Colors.WHITE, scaleFactor = 0.85F
|
color = Colors.WHITE, scaleFactor = 0.85F
|
||||||
)
|
)
|
||||||
|
|
|
@ -5,11 +5,10 @@ import fr.username404.snowygui.Snowy
|
||||||
import fr.username404.snowygui.gui.feature.Colors
|
import fr.username404.snowygui.gui.feature.Colors
|
||||||
import fr.username404.snowygui.utils.RenderingUtil
|
import fr.username404.snowygui.utils.RenderingUtil
|
||||||
import fr.username404.snowygui.utils.RenderingUtil.colorEnd
|
import fr.username404.snowygui.utils.RenderingUtil.colorEnd
|
||||||
import net.minecraft.client.gui.GuiGraphics
|
|
||||||
import net.minecraft.client.gui.components.events.GuiEventListener
|
import net.minecraft.client.gui.components.events.GuiEventListener
|
||||||
|
|
||||||
fun interface Renderable {
|
fun interface Renderable {
|
||||||
fun render(guiGraphics: GuiGraphics?)
|
fun render(poseStack: PoseStack?)
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract class Element(
|
abstract class Element(
|
||||||
|
@ -29,13 +28,13 @@ abstract class Element(
|
||||||
private var caughtError: Boolean = false
|
private var caughtError: Boolean = false
|
||||||
fun fromRenderable(r: Renderable, x: Double, y: Double, width: Int, height: Int): Element {
|
fun fromRenderable(r: Renderable, x: Double, y: Double, width: Int, height: Int): Element {
|
||||||
return object: Element(x, y, width, height) {
|
return object: Element(x, y, width, height) {
|
||||||
override fun render(guiGraphics: GuiGraphics?) = r.render(guiGraphics)
|
override fun render(poseStack: PoseStack?) = r.render(poseStack)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
open fun display(guiGraphics: GuiGraphics? = null) {
|
open fun display(stack: PoseStack? = null) {
|
||||||
if (!hidden && !caughtError) try {
|
if (!hidden && !caughtError) try {
|
||||||
render(guiGraphics)
|
render(stack)
|
||||||
} catch (t: Throwable) {
|
} catch (t: Throwable) {
|
||||||
with(Snowy.logs) {
|
with(Snowy.logs) {
|
||||||
error("An element from snowy threw an error: \n\t$t")
|
error("An element from snowy threw an error: \n\t$t")
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
package fr.username404.snowygui.gui
|
package fr.username404.snowygui.gui
|
||||||
|
|
||||||
import net.minecraft.client.gui.GuiGraphics
|
import com.mojang.blaze3d.vertex.PoseStack
|
||||||
import net.minecraft.client.gui.screens.Screen
|
import net.minecraft.client.gui.screens.Screen
|
||||||
import net.minecraft.network.chat.Component.translatable
|
import net.minecraft.network.chat.Component.translatable
|
||||||
|
|
||||||
abstract class SnowyScreen(translatableString: String = "screen.snowy.gui", private val willPauseScreen: Boolean = false): Screen(translatable(translatableString)) {
|
abstract class SnowyScreen(translatableString: String = "screen.snowy.gui", private val willPauseScreen: Boolean = false): Screen(translatable(translatableString)) {
|
||||||
abstract val components: MutableCollection<Element>
|
abstract val components: MutableCollection<Element>
|
||||||
override fun render(guiGraphics: GuiGraphics, i: Int, j: Int, f: Float) {
|
override fun render(poseStack: PoseStack, i: Int, j: Int, f: Float) {
|
||||||
components.forEach {
|
components.forEach {
|
||||||
it.display(guiGraphics)
|
it.display(poseStack)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
override fun isPauseScreen(): Boolean = willPauseScreen
|
override fun isPauseScreen(): Boolean = willPauseScreen
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package fr.username404.snowygui.gui.elements
|
package fr.username404.snowygui.gui.elements
|
||||||
|
|
||||||
import com.mojang.blaze3d.vertex.DefaultVertexFormat
|
import com.mojang.blaze3d.vertex.DefaultVertexFormat
|
||||||
|
import com.mojang.blaze3d.vertex.PoseStack
|
||||||
import fr.username404.snowygui.Snowy.Companion.MissingComponent
|
import fr.username404.snowygui.Snowy.Companion.MissingComponent
|
||||||
import fr.username404.snowygui.config.Configuration
|
import fr.username404.snowygui.config.Configuration
|
||||||
import com.mojang.blaze3d.vertex.VertexFormat
|
import com.mojang.blaze3d.vertex.VertexFormat
|
||||||
|
@ -15,8 +16,6 @@ import fr.username404.snowygui.utils.RenderingUtil.prepareDraw
|
||||||
import fr.username404.snowygui.utils.RenderingUtil.tessellator
|
import fr.username404.snowygui.utils.RenderingUtil.tessellator
|
||||||
import io.github.config4k.extract
|
import io.github.config4k.extract
|
||||||
import net.minecraft.client.Minecraft
|
import net.minecraft.client.Minecraft
|
||||||
import net.minecraft.client.gui.Font
|
|
||||||
import net.minecraft.client.gui.GuiGraphics
|
|
||||||
import net.minecraft.network.chat.Component
|
import net.minecraft.network.chat.Component
|
||||||
import org.jetbrains.annotations.ApiStatus
|
import org.jetbrains.annotations.ApiStatus
|
||||||
import java.util.TreeSet
|
import java.util.TreeSet
|
||||||
|
@ -33,9 +32,9 @@ class ClickBox(
|
||||||
if (sortAlphabetically)
|
if (sortAlphabetically)
|
||||||
TreeSet(compareBy(String.CASE_INSENSITIVE_ORDER) { it.title })
|
TreeSet(compareBy(String.CASE_INSENSITIVE_ORDER) { it.title })
|
||||||
else LinkedHashSet()
|
else LinkedHashSet()
|
||||||
override fun display(guiGraphics: GuiGraphics?) {
|
override fun display(stack: PoseStack?) {
|
||||||
hidden = buttons.isEmpty() || hidden
|
hidden = buttons.isEmpty() || hidden
|
||||||
super.display(guiGraphics)
|
super.display(stack)
|
||||||
}
|
}
|
||||||
|
|
||||||
@JvmField
|
@JvmField
|
||||||
|
@ -45,7 +44,7 @@ class ClickBox(
|
||||||
opacity = 0.75F
|
opacity = 0.75F
|
||||||
) {
|
) {
|
||||||
override val color: Int get() = this@ClickBox.color
|
override val color: Int get() = this@ClickBox.color
|
||||||
override fun render(guiGraphics: GuiGraphics?) {
|
override fun render(poseStack: PoseStack?) {
|
||||||
prepareDraw()
|
prepareDraw()
|
||||||
colorShader(); defaultRectFunc()
|
colorShader(); defaultRectFunc()
|
||||||
endDraw()
|
endDraw()
|
||||||
|
@ -77,7 +76,7 @@ class ClickBox(
|
||||||
const val clickboxHeightOffset: Int = 80
|
const val clickboxHeightOffset: Int = 80
|
||||||
private const val inclination: Double = 2.5
|
private const val inclination: Double = 2.5
|
||||||
}
|
}
|
||||||
override fun render(guiGraphics: GuiGraphics?) {
|
override fun render(poseStack: PoseStack?) {
|
||||||
val currentHeight = y + (height + clickboxHeightOffset)
|
val currentHeight = y + (height + clickboxHeightOffset)
|
||||||
prepareDraw()
|
prepareDraw()
|
||||||
with(buffer) {
|
with(buffer) {
|
||||||
|
@ -106,23 +105,18 @@ class ClickBox(
|
||||||
buttonsProgressBar.apply {
|
buttonsProgressBar.apply {
|
||||||
x = this@ClickBox.x + this@ClickBox.width - 3
|
x = this@ClickBox.x + this@ClickBox.width - 3
|
||||||
y = this@ClickBox.y + this@ClickBox.height + 3
|
y = this@ClickBox.y + this@ClickBox.height + 3
|
||||||
}.display(guiGraphics)
|
}.display(poseStack)
|
||||||
buttons.forEachIndexed { num, button ->
|
buttons.forEachIndexed { num, button ->
|
||||||
val fullHeight = (y + height.toDouble())..(y + height + clickboxHeightOffset)
|
val fullHeight = (y + height.toDouble())..(y + height + clickboxHeightOffset)
|
||||||
button.also {
|
button.also {
|
||||||
it.x = x + 3
|
it.x = x + 3
|
||||||
it.y = y + 3 + height + (((num + 1) - barStage) * 9)
|
it.y = y + 3 + height + (((num + 1) - barStage) * 9)
|
||||||
it.hidden = if ((num + 1) <= 8) ((it.y) !in fullHeight) else ((it.y + it.height) !in fullHeight)
|
it.hidden = if ((num + 1) <= 8) ((it.y) !in fullHeight) else ((it.y + it.height) !in fullHeight)
|
||||||
}.display(guiGraphics)
|
}.display(poseStack)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
guiGraphics?.run {
|
if (poseStack != null) {
|
||||||
with(Minecraft.getInstance().font) {
|
Minecraft.getInstance().font.draw(poseStack, name.string, x.toFloat() + 5, y.toFloat() + 1.5F, Colors.TRANSPARENT.hexValue)
|
||||||
drawInBatch(name.string,
|
|
||||||
(x + 5).toFloat(), (y + 2).toFloat(), Colors.TRANSPARENT.hexValue, false,
|
|
||||||
pose().last().pose(), bufferSource(), Font.DisplayMode.NORMAL, 0, 15728880, isBidirectional
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,15 +1,15 @@
|
||||||
package fr.username404.snowygui.gui.feature
|
package fr.username404.snowygui.gui.feature
|
||||||
|
|
||||||
|
import com.mojang.blaze3d.vertex.PoseStack
|
||||||
import fr.username404.snowygui.ClickGui
|
import fr.username404.snowygui.ClickGui
|
||||||
import fr.username404.snowygui.Snowy
|
import fr.username404.snowygui.Snowy
|
||||||
import fr.username404.snowygui.config.Configuration
|
import fr.username404.snowygui.config.Configuration
|
||||||
import fr.username404.snowygui.gui.ColoredElement
|
import fr.username404.snowygui.gui.ColoredElement
|
||||||
import fr.username404.snowygui.gui.feature.ButtonInfo.Companion.Type
|
|
||||||
import fr.username404.snowygui.utils.FontUtil
|
import fr.username404.snowygui.utils.FontUtil
|
||||||
import fr.username404.snowygui.utils.RenderingUtil.colorShader
|
import fr.username404.snowygui.gui.feature.ButtonInfo.Companion.Type
|
||||||
import fr.username404.snowygui.utils.RenderingUtil.endDraw
|
import fr.username404.snowygui.utils.RenderingUtil.endDraw
|
||||||
import fr.username404.snowygui.utils.RenderingUtil.prepareDraw
|
import fr.username404.snowygui.utils.RenderingUtil.prepareDraw
|
||||||
import net.minecraft.client.gui.GuiGraphics
|
import fr.username404.snowygui.utils.RenderingUtil.colorShader
|
||||||
import kotlin.reflect.full.findAnnotation
|
import kotlin.reflect.full.findAnnotation
|
||||||
|
|
||||||
sealed class ButtonImpl: ColoredElement(0.0, 0.0, 73, 8, opacity = 0.60F) {
|
sealed class ButtonImpl: ColoredElement(0.0, 0.0, 73, 8, opacity = 0.60F) {
|
||||||
|
@ -90,12 +90,12 @@ sealed class ButtonImpl: ColoredElement(0.0, 0.0, 73, 8, opacity = 0.60F) {
|
||||||
lightDown()
|
lightDown()
|
||||||
}; return false
|
}; return false
|
||||||
}
|
}
|
||||||
final override fun render(guiGraphics: GuiGraphics?) {
|
final override fun render(poseStack: PoseStack?) {
|
||||||
prepareDraw()
|
prepareDraw()
|
||||||
colorShader(); defaultRectFunc()
|
colorShader(); defaultRectFunc()
|
||||||
endDraw()
|
endDraw()
|
||||||
if (guiGraphics != null) {
|
if (poseStack != null) {
|
||||||
FontUtil.drawScaled(guiGraphics, title, x + 1, y + 1, 0.75F)
|
FontUtil.drawScaled(poseStack, title, x + 1, y + 1, 0.75F)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
package fr.username404.snowygui.gui.feature
|
package fr.username404.snowygui.gui.feature
|
||||||
|
|
||||||
|
import com.mojang.blaze3d.vertex.PoseStack
|
||||||
import fr.username404.snowygui.EventSnowy
|
import fr.username404.snowygui.EventSnowy
|
||||||
import fr.username404.snowygui.argsLambda
|
import fr.username404.snowygui.argsLambda
|
||||||
import fr.username404.snowygui.gui.Renderable
|
import fr.username404.snowygui.gui.Renderable
|
||||||
import net.minecraft.client.gui.GuiGraphics
|
|
||||||
|
|
||||||
sealed class ButtonImplWithHud: ButtonImpl() {
|
sealed class ButtonImplWithHud: ButtonImpl() {
|
||||||
protected abstract val hudRenderLambda: Renderable
|
protected abstract val hudRenderLambda: Renderable
|
||||||
private val generatedLambda: argsLambda = { hudRenderLambda.render(it.first() as GuiGraphics?) }
|
private val generatedLambda: argsLambda = { hudRenderLambda.render(it.first() as PoseStack?) }
|
||||||
final override fun execAction() {
|
final override fun execAction() {
|
||||||
EventSnowy["HudRender"].run {
|
EventSnowy["HudRender"].run {
|
||||||
if (toggled) add(generatedLambda)
|
if (toggled) add(generatedLambda)
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
package fr.username404.snowygui.gui.feature
|
package fr.username404.snowygui.gui.feature
|
||||||
|
|
||||||
|
import com.mojang.blaze3d.vertex.PoseStack
|
||||||
import fr.username404.snowygui.config.Configuration
|
import fr.username404.snowygui.config.Configuration
|
||||||
import fr.username404.snowygui.gui.ColoredElement
|
import fr.username404.snowygui.gui.ColoredElement
|
||||||
import fr.username404.snowygui.gui.Renderable
|
import fr.username404.snowygui.gui.Renderable
|
||||||
import fr.username404.snowygui.utils.FontUtil
|
import fr.username404.snowygui.utils.FontUtil
|
||||||
import fr.username404.snowygui.utils.RenderingUtil
|
import fr.username404.snowygui.utils.RenderingUtil
|
||||||
import net.minecraft.client.Minecraft
|
import net.minecraft.client.Minecraft
|
||||||
import net.minecraft.client.gui.GuiGraphics
|
|
||||||
|
|
||||||
@ButtonInfo(Category.HUD)
|
@ButtonInfo(Category.HUD)
|
||||||
object Keystrokes: ButtonImplWithHud() {
|
object Keystrokes: ButtonImplWithHud() {
|
||||||
|
@ -41,14 +41,14 @@ object Keystrokes: ButtonImplWithHud() {
|
||||||
return dynamicOpacity[i]
|
return dynamicOpacity[i]
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun drawKey(x: Double, y: Double, key: Int, guiGraphics: GuiGraphics?) {
|
private fun drawKey(x: Double, y: Double, key: Int, poseStack: PoseStack? = null) {
|
||||||
RenderingUtil.prepareDraw()
|
RenderingUtil.prepareDraw()
|
||||||
RenderingUtil.drawRectangle(
|
RenderingUtil.drawRectangle(
|
||||||
x, y, height / 2, height / 2,
|
x, y, height / 2, height / 2,
|
||||||
color = color, opacity = getDynamicOpacity(key).toFloat()
|
color = color, opacity = getDynamicOpacity(key).toFloat()
|
||||||
)
|
)
|
||||||
RenderingUtil.endDraw()
|
RenderingUtil.endDraw()
|
||||||
guiGraphics?.let {
|
poseStack?.let {
|
||||||
FontUtil.drawScaled(
|
FontUtil.drawScaled(
|
||||||
it, keysArray.first[key].translatedKeyMessage.string.uppercase(),
|
it, keysArray.first[key].translatedKeyMessage.string.uppercase(),
|
||||||
x + height.toDouble() / 5.5, y + height.toDouble() / 6.5,
|
x + height.toDouble() / 5.5, y + height.toDouble() / 6.5,
|
||||||
|
@ -57,11 +57,11 @@ object Keystrokes: ButtonImplWithHud() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private fun getNewPos(i: Int) = x + (i * (2 + (height / 2)))
|
private fun getNewPos(i: Int) = x + (i * (2 + (height / 2)))
|
||||||
override fun render(guiGraphics: GuiGraphics?) = with(RenderingUtil) {
|
override fun render(poseStack: PoseStack?) = with(RenderingUtil) {
|
||||||
for (i in 0 until 3) {
|
for (i in 0 until 3) {
|
||||||
drawKey(getNewPos(i), y, i, guiGraphics)
|
drawKey(getNewPos(i), y, i, poseStack)
|
||||||
}
|
}
|
||||||
drawKey(getNewPos(1), y - (height / 2) - 2, 3, guiGraphics)
|
drawKey(getNewPos(1), y - (height / 2) - 2, 3, poseStack)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
override val hudRenderLambda = Renderable {
|
override val hudRenderLambda = Renderable {
|
||||||
|
|
|
@ -1,14 +1,13 @@
|
||||||
package fr.username404.snowygui.utils
|
package fr.username404.snowygui.utils
|
||||||
|
|
||||||
|
import com.mojang.blaze3d.vertex.PoseStack
|
||||||
import net.minecraft.client.Minecraft
|
import net.minecraft.client.Minecraft
|
||||||
import fr.username404.snowygui.gui.feature.Colors
|
import fr.username404.snowygui.gui.feature.Colors
|
||||||
import net.minecraft.client.gui.GuiGraphics
|
|
||||||
|
|
||||||
object FontUtil {
|
object FontUtil {
|
||||||
fun drawScaled(guiGraphics: GuiGraphics, text: String, x: Double, y: Double, scaleFactor: Float, color: Colors = Colors.BLACK) {
|
fun drawScaled(stack: PoseStack, text: String, x: Double, y: Double, scaleFactor: Float, color: Colors = Colors.BLACK) {
|
||||||
val stack = guiGraphics.pose()
|
|
||||||
stack.scale(scaleFactor, scaleFactor, scaleFactor)
|
stack.scale(scaleFactor, scaleFactor, scaleFactor)
|
||||||
guiGraphics.drawString(Minecraft.getInstance().font, text, (x / scaleFactor).toInt(), (y / scaleFactor).toInt(), color.hexValue, false)
|
Minecraft.getInstance().font.draw(stack, text, (x / scaleFactor).toFloat(), (y / scaleFactor).toFloat(), color.hexValue)
|
||||||
val factorToOriginal = 1F / scaleFactor
|
val factorToOriginal = 1F / scaleFactor
|
||||||
stack.scale(factorToOriginal, factorToOriginal, factorToOriginal)
|
stack.scale(factorToOriginal, factorToOriginal, factorToOriginal)
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,6 @@ import net.fabricmc.api.ClientModInitializer
|
||||||
import net.fabricmc.fabric.api.client.rendering.v1.HudRenderCallback
|
import net.fabricmc.fabric.api.client.rendering.v1.HudRenderCallback
|
||||||
import net.fabricmc.fabric.api.client.rendering.v1.HudRenderCallback.EVENT
|
import net.fabricmc.fabric.api.client.rendering.v1.HudRenderCallback.EVENT
|
||||||
import net.fabricmc.loader.api.FabricLoader
|
import net.fabricmc.loader.api.FabricLoader
|
||||||
import net.minecraft.client.gui.GuiGraphics
|
|
||||||
import kotlin.io.path.exists
|
import kotlin.io.path.exists
|
||||||
import kotlin.io.path.isDirectory
|
import kotlin.io.path.isDirectory
|
||||||
import kotlin.io.path.listDirectoryEntries
|
import kotlin.io.path.listDirectoryEntries
|
||||||
|
@ -21,7 +20,7 @@ class FabricInit: Snowy(), ClientModInitializer {
|
||||||
EVENT.register(
|
EVENT.register(
|
||||||
object: HudRenderCallback, EventSnowy {
|
object: HudRenderCallback, EventSnowy {
|
||||||
override val type: String = "HudRender"
|
override val type: String = "HudRender"
|
||||||
override fun onHudRender(guiGraphics: GuiGraphics?, tickDelta: Float) = fire(guiGraphics)
|
override fun onHudRender(matrixStack: PoseStack?, tickDelta: Float) = fire(matrixStack)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,7 +37,7 @@
|
||||||
"fabric-language-kotlin": ">=${fabric_kotlin}",
|
"fabric-language-kotlin": ">=${fabric_kotlin}",
|
||||||
"fabric-resource-loader-v0": "*",
|
"fabric-resource-loader-v0": "*",
|
||||||
"fabric-rendering-v1": "*",
|
"fabric-rendering-v1": "*",
|
||||||
"minecraft": ">=1.19-alpha.22.16.b"
|
"minecraft": ">=${minecraft_version}"
|
||||||
},
|
},
|
||||||
"recommends": {
|
"recommends": {
|
||||||
"cloth-config2": ">=${clothconfig}"
|
"cloth-config2": ">=${clothconfig}"
|
||||||
|
|
|
@ -8,6 +8,6 @@ object HudHandler: EventSnowy {
|
||||||
override val type: String = "HudRender"
|
override val type: String = "HudRender"
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
fun handleRendering(event: RenderGuiEvent.Post) {
|
fun handleRendering(event: RenderGuiEvent.Post) {
|
||||||
fire(event.guiGraphics)
|
fire(event.poseStack)
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -7,16 +7,16 @@ org.gradle.parallel=true
|
||||||
org.gradle.unsafe.configuration-cache=on
|
org.gradle.unsafe.configuration-cache=on
|
||||||
org.gradle.vfs.watch=true
|
org.gradle.vfs.watch=true
|
||||||
|
|
||||||
minecraft=1.20
|
minecraft=1.19.4
|
||||||
forge_version=46.0
|
forge_version=45.0
|
||||||
kotlinforforge=4.3.0
|
kotlinforforge=4.1.0
|
||||||
kotlinVer=1.8.22
|
kotlinVer=1.8.20
|
||||||
kotlin_coroutines_version=1.7.1
|
kotlin_coroutines_version=1.7.0-RC
|
||||||
serializationVer=1.5.1
|
serializationVer=1.5.0
|
||||||
fabric_loader_version=0.14.19
|
fabric_loader_version=0.14.19
|
||||||
fabric_language_kotlin=1.9.5+kotlin.1.8.22
|
fabric_language_kotlin=1.9.3+kotlin.1.8.20
|
||||||
fabric_resource_loader_version=0.11.7+f7923f6d27
|
fabric_resource_loader_version=0.11.4+bd913b0d4e
|
||||||
fabric_rendering_api_version=3.0.6+b3afc78b27
|
fabric_rendering_api_version=2.1.1+8f878217f4
|
||||||
fabric_api_base_version=0.4.29+b04edc7a27
|
fabric_api_base_version=0.4.5+ec94c6f6e0
|
||||||
clothconfig_version=11.0.99
|
clothconfig_version=10.0.96
|
||||||
modmenu_version=7.0.0
|
modmenu_version=6.2.1
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-rc-1-bin.zip
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
|
|
Loading…
Reference in New Issue