Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 65eb99c0ad | |||
| e191df2cbd | |||
| 46791002e4 | |||
| a09e2c389a | |||
| ff7c473ecb |
@ -1,27 +0,0 @@
|
|||||||
<component name="ProjectRunConfigurationManager">
|
|
||||||
<configuration default="false" name="SnowyGUI [build]" type="GradleRunConfiguration" factoryName="Gradle">
|
|
||||||
<ExternalSystemSettings>
|
|
||||||
<option name="executionName" />
|
|
||||||
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
|
||||||
<option name="externalSystemIdString" value="GRADLE" />
|
|
||||||
<option name="scriptParameters" value="-PdevBuild=true" />
|
|
||||||
<option name="taskDescriptions">
|
|
||||||
<list />
|
|
||||||
</option>
|
|
||||||
<option name="taskNames">
|
|
||||||
<list>
|
|
||||||
<option value="build" />
|
|
||||||
</list>
|
|
||||||
</option>
|
|
||||||
<option name="vmOptions" />
|
|
||||||
</ExternalSystemSettings>
|
|
||||||
<ExternalSystemDebugServerProcess>true</ExternalSystemDebugServerProcess>
|
|
||||||
<ExternalSystemReattachDebugProcess>true</ExternalSystemReattachDebugProcess>
|
|
||||||
<ExternalSystemDebugDisabled>false</ExternalSystemDebugDisabled>
|
|
||||||
<DebugAllEnabled>false</DebugAllEnabled>
|
|
||||||
<RunAsTest>false</RunAsTest>
|
|
||||||
<GradleProfilingDisabled>false</GradleProfilingDisabled>
|
|
||||||
<GradleCoverageDisabled>false</GradleCoverageDisabled>
|
|
||||||
<method v="2" />
|
|
||||||
</configuration>
|
|
||||||
</component>
|
|
||||||
@ -1,27 +0,0 @@
|
|||||||
<component name="ProjectRunConfigurationManager">
|
|
||||||
<configuration default="false" name="SnowyGUI [build-release]" type="GradleRunConfiguration" factoryName="Gradle">
|
|
||||||
<ExternalSystemSettings>
|
|
||||||
<option name="executionName" />
|
|
||||||
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
|
||||||
<option name="externalSystemIdString" value="GRADLE" />
|
|
||||||
<option name="scriptParameters" value="-PdevBuild=false" />
|
|
||||||
<option name="taskDescriptions">
|
|
||||||
<list />
|
|
||||||
</option>
|
|
||||||
<option name="taskNames">
|
|
||||||
<list>
|
|
||||||
<option value="build" />
|
|
||||||
</list>
|
|
||||||
</option>
|
|
||||||
<option name="vmOptions" />
|
|
||||||
</ExternalSystemSettings>
|
|
||||||
<ExternalSystemDebugServerProcess>true</ExternalSystemDebugServerProcess>
|
|
||||||
<ExternalSystemReattachDebugProcess>true</ExternalSystemReattachDebugProcess>
|
|
||||||
<ExternalSystemDebugDisabled>false</ExternalSystemDebugDisabled>
|
|
||||||
<DebugAllEnabled>false</DebugAllEnabled>
|
|
||||||
<RunAsTest>false</RunAsTest>
|
|
||||||
<GradleProfilingDisabled>false</GradleProfilingDisabled>
|
|
||||||
<GradleCoverageDisabled>false</GradleCoverageDisabled>
|
|
||||||
<method v="2" />
|
|
||||||
</configuration>
|
|
||||||
</component>
|
|
||||||
@ -4,22 +4,21 @@ import com.modrinth.minotaur.dependencies.DependencyType
|
|||||||
import masecla.modrinth4j.model.version.ProjectVersion.VersionType
|
import masecla.modrinth4j.model.version.ProjectVersion.VersionType
|
||||||
import net.fabricmc.loom.LoomGradleExtension
|
import net.fabricmc.loom.LoomGradleExtension
|
||||||
import net.fabricmc.loom.api.LoomGradleExtensionAPI
|
import net.fabricmc.loom.api.LoomGradleExtensionAPI
|
||||||
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
|
|
||||||
|
|
||||||
buildscript {
|
buildscript {
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath("com.guardsquare:proguard-gradle:[7.8, 7.9[") {
|
classpath("com.guardsquare:proguard-gradle:[7.5, 7.7[") {
|
||||||
exclude("com.android.tools.build")
|
exclude("com.android.tools.build")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
kotlin("jvm") version "2.3.0"
|
kotlin("jvm") version "2.0.0"
|
||||||
kotlin("plugin.serialization") version "2.3.0"
|
kotlin("plugin.serialization") version "2.0.0"
|
||||||
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.160, 3.5["
|
id("architectury-plugin") version "[3.4.160, 3.5["
|
||||||
id("dev.architectury.loom") version "[1.13.464, 1.14[" apply false
|
id("dev.architectury.loom") version "1.9-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"
|
||||||
@ -27,7 +26,7 @@ plugins {
|
|||||||
}
|
}
|
||||||
|
|
||||||
group = "fr.username404"
|
group = "fr.username404"
|
||||||
version = "0.4.2"
|
version = "0.3.7"
|
||||||
val groupAndName = "${rootProject.group}.${rootProject.name.lowercase()}"
|
val groupAndName = "${rootProject.group}.${rootProject.name.lowercase()}"
|
||||||
|
|
||||||
val javaVer: String = "21"
|
val javaVer: String = "21"
|
||||||
@ -39,7 +38,6 @@ val minecraftVersion: String = (rootProject.property("minecraft") as String).als
|
|||||||
architectury { minecraft = it }
|
architectury { minecraft = it }
|
||||||
}
|
}
|
||||||
val kotlinX: String = "org.jetbrains.kotlinx"
|
val kotlinX: String = "org.jetbrains.kotlinx"
|
||||||
val devBuild = rootProject.hasProperty("devBuild") && rootProject.property("devBuild").toString().toBoolean()
|
|
||||||
|
|
||||||
subprojects {
|
subprojects {
|
||||||
group = rootProject.group.toString()
|
group = rootProject.group.toString()
|
||||||
@ -58,7 +56,12 @@ subprojects {
|
|||||||
}
|
}
|
||||||
mappingsDep = layered {
|
mappingsDep = layered {
|
||||||
silentMojangMappingsLicense()
|
silentMojangMappingsLicense()
|
||||||
officialMojangMappings().parchment("org.parchmentmc.data:parchment-1.21.11:2025.12.20")
|
officialMojangMappings().parchment("org.parchmentmc.data:parchment-1.21:2024.06.23")
|
||||||
|
}
|
||||||
|
val refmap = "snowygui-${project.name}-refmap.json"
|
||||||
|
mixin {
|
||||||
|
useLegacyMixinAp = true
|
||||||
|
defaultRefmapName = refmap
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
apply(plugin = "com.github.johnrengelman.shadow")
|
apply(plugin = "com.github.johnrengelman.shadow")
|
||||||
@ -164,16 +167,14 @@ subprojects {
|
|||||||
mergeinterfacesaggressively()
|
mergeinterfacesaggressively()
|
||||||
}
|
}
|
||||||
withType(net.fabricmc.loom.task.RemapJarTask::class) {
|
withType(net.fabricmc.loom.task.RemapJarTask::class) {
|
||||||
if (!devBuild) {
|
dependsOn(shrinkJar)
|
||||||
dependsOn(shrinkJar)
|
val shrinkedJar = shrinkJar.get().outJarFileCollection.singleFile
|
||||||
val shrinkedJar = shrinkJar.get().outJarFileCollection.singleFile
|
|
||||||
inputFile.set(shrinkedJar)
|
|
||||||
} else inputFile.set(shadowJar.archiveFile)
|
|
||||||
archiveBaseName.set(shadowJar.archiveBaseName)
|
archiveBaseName.set(shadowJar.archiveBaseName)
|
||||||
archiveVersion.set("[${rootProject.version}+$minecraftVersion]")
|
archiveVersion.set("[${rootProject.version}+$minecraftVersion]")
|
||||||
archiveClassifier.set(this@subprojects.name)
|
archiveClassifier.set(this@subprojects.name)
|
||||||
if (this@subprojects.name.contains("forge"))
|
if (this@subprojects.name.contains("forge"))
|
||||||
atAccessWideners.set(listOf("${rootProject.name.lowercase()}.accessWidener"))
|
atAccessWideners.set(listOf("${rootProject.name.lowercase()}.accessWidener"))
|
||||||
|
inputFile.set(shrinkedJar)
|
||||||
if (!archiveFileName.get().contains("common")) destinationDirectory.set(file("$rootDir/remappedJars"))
|
if (!archiveFileName.get().contains("common")) destinationDirectory.set(file("$rootDir/remappedJars"))
|
||||||
}
|
}
|
||||||
getByName("modrinth").dependsOn(build)
|
getByName("modrinth").dependsOn(build)
|
||||||
@ -200,18 +201,19 @@ allprojects {
|
|||||||
}
|
}
|
||||||
tasks {
|
tasks {
|
||||||
withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile::class) {
|
withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile::class) {
|
||||||
compilerOptions {
|
with(kotlinOptions) {
|
||||||
// https://github.com/JetBrains/kotlin/blob/master/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/K2JVMCompilerArguments.kt
|
// https://github.com/JetBrains/kotlin/blob/master/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/K2JVMCompilerArguments.kt
|
||||||
freeCompilerArgs = listOf(
|
freeCompilerArgs = listOf(
|
||||||
"-Xjvm-default=all", "-Xlambdas=indy", "-Xtype-enhancement-improvements-strict-mode",
|
"-Xjvm-default=all", "-Xlambdas=indy", "-Xtype-enhancement-improvements-strict-mode",
|
||||||
"-Xmultifile-parts-inherit",
|
"-Xmultifile-parts-inherit",
|
||||||
"-Xbackend-threads=0", "-Xno-param-assertions", "-Xno-call-assertions",
|
"-Xbackend-threads=0", "-Xno-param-assertions", "-Xno-call-assertions",
|
||||||
"-opt-in=kotlin.RequiresOptIn", "-Xassertions=jvm", "-progressive"
|
"-opt-in=kotlin.RequiresOptIn", "-Xextended-compiler-checks", "-Xassertions=jvm", "-progressive"
|
||||||
)
|
)
|
||||||
|
jvmTarget = javaVer
|
||||||
|
// Uncomment when updating to architectury-loom 1.9
|
||||||
//languageVersion = (kotlinSplitVersion[0] + '.' + (kotlinSplitVersion[1].toShort() + 1).toString())
|
//languageVersion = (kotlinSplitVersion[0] + '.' + (kotlinSplitVersion[1].toShort() + 1).toString())
|
||||||
//apiVersion = "${kotlinSplitVersion[0]}.${kotlinSplitVersion[1]}"
|
//apiVersion = "${kotlinSplitVersion[0]}.${kotlinSplitVersion[1]}"
|
||||||
}
|
}
|
||||||
compilerOptions.jvmTarget.set(JvmTarget.fromTarget(javaVer))
|
|
||||||
}
|
}
|
||||||
withType(JavaCompile::class) {
|
withType(JavaCompile::class) {
|
||||||
with(options) {
|
with(options) {
|
||||||
@ -240,7 +242,7 @@ allprojects {
|
|||||||
"forge_version" to rootProject.property("forge_version")
|
"forge_version" to rootProject.property("forge_version")
|
||||||
)
|
)
|
||||||
inputs.properties(modProperties)
|
inputs.properties(modProperties)
|
||||||
filesNotMatching(listOf("*.png", "*.accessWidener")) {
|
filesNotMatching(listOf("*.png")) {
|
||||||
expand(modProperties)
|
expand(modProperties)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,23 +0,0 @@
|
|||||||
package fr.username404.snowygui.mixins;
|
|
||||||
|
|
||||||
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
|
|
||||||
import fr.username404.snowygui.gui.feature.GammaBoost;
|
|
||||||
import net.minecraft.client.renderer.LightTexture;
|
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
|
||||||
|
|
||||||
@Mixin(LightTexture.class)
|
|
||||||
abstract class GammaMixin {
|
|
||||||
@ModifyExpressionValue(
|
|
||||||
method = "updateLightTexture(F)V", at = @At(
|
|
||||||
value = "INVOKE",
|
|
||||||
target = "Ljava/lang/Double;floatValue()F",
|
|
||||||
ordinal = 1
|
|
||||||
)
|
|
||||||
)
|
|
||||||
public float highGamma(float original) {
|
|
||||||
if (GammaBoost.INSTANCE.getToggled())
|
|
||||||
return GammaBoost.BOOST;
|
|
||||||
return original;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -4,9 +4,7 @@ import fr.username404.snowygui.gui.ColoredElement
|
|||||||
import fr.username404.snowygui.gui.Element
|
import fr.username404.snowygui.gui.Element
|
||||||
import fr.username404.snowygui.gui.SnowyScreen
|
import fr.username404.snowygui.gui.SnowyScreen
|
||||||
import fr.username404.snowygui.gui.elements.ClickBox
|
import fr.username404.snowygui.gui.elements.ClickBox
|
||||||
import net.minecraft.client.input.MouseButtonEvent
|
|
||||||
import org.lwjgl.glfw.GLFW
|
import org.lwjgl.glfw.GLFW
|
||||||
import kotlin.math.roundToInt
|
|
||||||
|
|
||||||
object ClickGui: SnowyScreen() {
|
object ClickGui: SnowyScreen() {
|
||||||
override val components = mutableSetOf<Element>()
|
override val components = mutableSetOf<Element>()
|
||||||
@ -19,32 +17,28 @@ object ClickGui: SnowyScreen() {
|
|||||||
|
|
||||||
private var draggingBox: String? = null
|
private var draggingBox: String? = null
|
||||||
private inline fun currentBoxContext(args: ClickBox.() -> Unit): Unit? = draggingBox?.run { boxContext { if (name.string == draggingBox) args() } }
|
private inline fun currentBoxContext(args: ClickBox.() -> Unit): Unit? = draggingBox?.run { boxContext { if (name.string == draggingBox) args() } }
|
||||||
private var offsetX: Double = 0.0
|
private var offsetX: Double = 0.0;
|
||||||
private var offsetY: Double = 0.0
|
private var offsetY: Double = 0.0;
|
||||||
override fun mouseClicked(event: MouseButtonEvent, isDoubleClick: Boolean): Boolean {
|
override fun mouseClicked(d: Double, e: Double, i: Int): Boolean {
|
||||||
if (event.input() == GLFW.GLFW_MOUSE_BUTTON_LEFT) {
|
if (i == GLFW.GLFW_MOUSE_BUTTON_LEFT) {
|
||||||
clickBoxes.find { it.isWithinBounds(event.x, event.y) }?.let { draggingBox = it.name.string }
|
clickBoxes.find { it.isWithinBounds(d, e) }?.let { draggingBox = it.name.string }
|
||||||
currentBoxContext {
|
currentBoxContext {
|
||||||
offsetX = event.x - (x + width)
|
offsetX = d - (x + width)
|
||||||
offsetY = event.y - (y + height)
|
offsetY = e - (y + height)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
buttonsContext { this.mouseClicked(event, isDoubleClick) }; return super.mouseClicked(event, isDoubleClick);
|
buttonsContext { this.mouseClicked(d, e, i) }; return super.mouseClicked(d, e, i);
|
||||||
}
|
}
|
||||||
override fun mouseReleased(event: MouseButtonEvent): Boolean { draggingBox = null; buttonsContext { this.mouseReleased(event) }; return false }
|
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, scrollY: Double): Boolean { boxContext { scroll(d, e, scrollY) }; return false }
|
override fun mouseScrolled(d: Double, e: Double, f: Double, scrollY: Double): Boolean { boxContext { scroll(d, e, scrollY) }; return false }
|
||||||
|
|
||||||
override fun mouseDragged(event: MouseButtonEvent, mouseX: Double, mouseY: Double): Boolean {
|
override fun mouseDragged(d: Double, e: Double, i: Int, f: Double, g: Double): Boolean {
|
||||||
if (event.input() == GLFW.GLFW_MOUSE_BUTTON_LEFT) {
|
if (i == GLFW.GLFW_MOUSE_BUTTON_LEFT) {
|
||||||
currentBoxContext {
|
currentBoxContext {
|
||||||
val targetX = (event.x + offsetX).coerceIn(0.0..this@ClickGui.width - width.toDouble())
|
x = (d + offsetX).coerceIn(0.0..this@ClickGui.width - width.toDouble())
|
||||||
val targetY = (event.y + offsetY).coerceIn(0.0..this@ClickGui.height - height.toDouble())
|
y = (e + offsetY).coerceIn(0.0..this@ClickGui.height - height.toDouble())
|
||||||
|
|
||||||
// Snap to integer pixels => stable spacing
|
|
||||||
x = targetX.roundToInt().toDouble()
|
|
||||||
y = targetY.roundToInt().toDouble()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return super.mouseDragged(event, mouseX, mouseY)
|
return super.mouseDragged(d, e, i, f, g)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1,6 +1,6 @@
|
|||||||
package fr.username404.snowygui
|
package fr.username404.snowygui
|
||||||
|
|
||||||
import fr.username404.snowygui.config.LazyConfiguration
|
import fr.username404.snowygui.config.Configuration
|
||||||
import fr.username404.snowygui.gui.feature.ButtonImpl
|
import fr.username404.snowygui.gui.feature.ButtonImpl
|
||||||
import fr.username404.snowygui.gui.feature.ButtonInfo
|
import fr.username404.snowygui.gui.feature.ButtonInfo
|
||||||
import fr.username404.snowygui.misc.AddKeyMaps
|
import fr.username404.snowygui.misc.AddKeyMaps
|
||||||
@ -13,30 +13,30 @@ import java.lang.reflect.Modifier
|
|||||||
abstract class Snowy {
|
abstract class Snowy {
|
||||||
protected fun Class<*>.isValidForButtonCollection(): Boolean =
|
protected fun Class<*>.isValidForButtonCollection(): Boolean =
|
||||||
!Modifier.isAbstract(modifiers) && declaredAnnotations.any { it is ButtonInfo && !it.ignored }
|
!Modifier.isAbstract(modifiers) && declaredAnnotations.any { it is ButtonInfo && !it.ignored }
|
||||||
private val displayInitMessage: Lazy<Boolean> by LazyConfiguration
|
private val displayInitMessage: Boolean by Configuration
|
||||||
abstract val annotatedButtons: Lazy<Set<Class<out ButtonImpl>>>
|
abstract val annotatedButtons: Set<Class<out ButtonImpl>>
|
||||||
companion object {
|
companion object {
|
||||||
val MissingComponent: Component = translatable("MISSING_COMPONENT")
|
val MissingComponent: Component = translatable("MISSING_COMPONENT")
|
||||||
@Suppress("JVM_STATIC_ON_CONST_OR_JVM_FIELD") // See KT-39868
|
@Suppress("JVM_STATIC_ON_CONST_OR_JVM_FIELD") // See KT-39868
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
protected const val FEATURE_PACKAGE: String = "fr.username404.snowygui.gui.feature"
|
protected const val FeaturePackage: String = "fr.username404.snowygui.gui.feature"
|
||||||
lateinit var annotatedButtons: () -> Set<Class<out ButtonImpl>>
|
lateinit var annotatedButtons: () -> Set<Class<out ButtonImpl>>
|
||||||
fun onEvent(e: Any, lambda: argsLambda) = EventSnowy[e.toString()].add(lambda)
|
fun onEvent(e: Any, lambda: argsLambda) = EventSnowy[e.toString()].add(lambda)
|
||||||
@JvmField
|
@JvmField
|
||||||
val logs: Logger = LogManager.getLogger()
|
val logs: Logger = LogManager.getLogger()
|
||||||
}
|
}
|
||||||
init { Companion.annotatedButtons = { annotatedButtons.value } }
|
init { Companion.annotatedButtons = ::annotatedButtons::get }
|
||||||
private fun eventsInit() {
|
private fun eventsInit() {
|
||||||
onEvent("EndTick") {
|
onEvent("EndTick") {
|
||||||
for (key in AddKeyMaps.list.keys) {
|
for (Key in AddKeyMaps.list.keys) {
|
||||||
if (key.isDown) {
|
if (Key.isDown) {
|
||||||
AddKeyMaps.list[key]?.invoke()
|
AddKeyMaps.list[Key]?.invoke()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fun atInit() {
|
fun atInit() {
|
||||||
if (displayInitMessage.value) logs.info("Init point of SnowyGUI hit.")
|
if (displayInitMessage) logs.info("Init point of SnowyGUI hit.")
|
||||||
eventsInit()
|
eventsInit()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2,10 +2,10 @@ package fr.username404.snowygui.config
|
|||||||
|
|
||||||
import fr.username404.snowygui.ClickGui
|
import fr.username404.snowygui.ClickGui
|
||||||
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.sortAlphabetically
|
import fr.username404.snowygui.gui.elements.ClickBox.Companion.sortAlphabetically
|
||||||
import fr.username404.snowygui.gui.feature.*
|
import fr.username404.snowygui.gui.feature.*
|
||||||
import fr.username404.snowygui.utils.FontUtil
|
import fr.username404.snowygui.utils.FontUtil
|
||||||
import me.shedaniel.clothconfig2.gui.entries.StringListListEntry
|
|
||||||
import net.minecraft.client.gui.GuiGraphics
|
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
|
||||||
@ -49,9 +49,9 @@ val SnowyConfigScreen: Screen = object: Screen(translationComponent) {
|
|||||||
startBooleanToggle(translatable("$confPrefix.behavior.sortalphabetically"), sortAlphabetically)
|
startBooleanToggle(translatable("$confPrefix.behavior.sortalphabetically"), sortAlphabetically)
|
||||||
.setDefaultValue(true).requireRestart()
|
.setDefaultValue(true).requireRestart()
|
||||||
.setSaveConsumer { sortAlphabetically = it }.build(),
|
.setSaveConsumer { sortAlphabetically = it }.build(),
|
||||||
startFloatField(translatable("$confPrefix.behavior.zoom.factor"), Zoom.zoomFactor).setSaveConsumer {
|
startDoubleField(translatable("$confPrefix.behavior.zoom.factor"), Zoom.zoomFactor).setSaveConsumer {
|
||||||
Zoom.zoomFactor = it
|
Zoom.zoomFactor = it
|
||||||
}.setMin(1.1F).build(),
|
}.setMin(1.1).build(),
|
||||||
startBooleanToggle(translatable("$confPrefix.behavior.zoom.smoothcamera"), Zoom.smoothCameraOnZoom).setSaveConsumer {
|
startBooleanToggle(translatable("$confPrefix.behavior.zoom.smoothcamera"), Zoom.smoothCameraOnZoom).setSaveConsumer {
|
||||||
Zoom.smoothCameraOnZoom = it
|
Zoom.smoothCameraOnZoom = it
|
||||||
Zoom.execAction()
|
Zoom.execAction()
|
||||||
@ -75,9 +75,9 @@ val SnowyConfigScreen: Screen = object: Screen(translationComponent) {
|
|||||||
}.build()).addEntry(startStrList(
|
}.build()).addEntry(startStrList(
|
||||||
Category.MACROS.box.name,
|
Category.MACROS.box.name,
|
||||||
macrosButtons.getTitleCommand()
|
macrosButtons.getTitleCommand()
|
||||||
).setCreateNewInstance {
|
).setInsertInFront(false).setDefaultValue(Configuration.foundMacros.getTitleCommand()).setErrorSupplier { list ->
|
||||||
entry -> StringListListEntry.StringListCell("ExampleMacro: say hello", entry)
|
supplyComponent(if (list.size > buttonsMax) "$confPrefix.general.macros.toomuchbuttons" else null)
|
||||||
}.setInsertInFront(false).setDefaultValue(Configuration.foundMacros.getTitleCommand()).setCellErrorSupplier { cell ->
|
}.setCellErrorSupplier { cell ->
|
||||||
with(cell.split(":")) {
|
with(cell.split(":")) {
|
||||||
supplyComponent(
|
supplyComponent(
|
||||||
when {
|
when {
|
||||||
|
|||||||
@ -21,6 +21,7 @@ import kotlinx.coroutines.CoroutineStart
|
|||||||
import kotlinx.coroutines.coroutineScope
|
import kotlinx.coroutines.coroutineScope
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import kotlinx.coroutines.runBlocking
|
import kotlinx.coroutines.runBlocking
|
||||||
|
import kotlinx.serialization.encodeToString
|
||||||
import kotlinx.serialization.json.Json
|
import kotlinx.serialization.json.Json
|
||||||
import net.minecraft.network.chat.contents.TranslatableContents
|
import net.minecraft.network.chat.contents.TranslatableContents
|
||||||
import org.jetbrains.annotations.ApiStatus
|
import org.jetbrains.annotations.ApiStatus
|
||||||
@ -118,13 +119,13 @@ object Configuration {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
private fun Config.withFullModifiableValues() = @Suppress("DEPRECATION_ERROR")
|
private fun Config.withFullModifiableValues() = @Suppress("DEPRECATION_ERROR")
|
||||||
ModifiableValues.entries.fold(this) { previous, entry ->
|
ModifiableValues.entries.fold(this) { previous, entry ->
|
||||||
previous.withValue(entry.key, entry.value.let {
|
previous.withValue(entry.key, entry.value.let {
|
||||||
ConfigValueFactory.fromAnyRef(
|
ConfigValueFactory.fromAnyRef(
|
||||||
if (it !is Lazy<*>) it else it.value
|
if (it !is Lazy<*>) it else it.value
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
private suspend fun writeConfig(c: Config) = coroutineScope {
|
private suspend fun writeConfig(c: Config) = coroutineScope {
|
||||||
launch(start = CoroutineStart.UNDISPATCHED) {
|
launch(start = CoroutineStart.UNDISPATCHED) {
|
||||||
file.writeText(
|
file.writeText(
|
||||||
@ -173,11 +174,5 @@ object Configuration {
|
|||||||
convertValue(T::class) ?: throw e
|
convertValue(T::class) ?: throw e
|
||||||
}
|
}
|
||||||
operator fun <T> setValue(ref: Any?, property: KProperty<*>, value: T) = @Suppress("DEPRECATION_ERROR")
|
operator fun <T> setValue(ref: Any?, property: KProperty<*>, value: T) = @Suppress("DEPRECATION_ERROR")
|
||||||
ModifiableValues.setValue(ref, property, value)
|
ModifiableValues.setValue(ref, property, value)
|
||||||
}
|
|
||||||
|
|
||||||
object LazyConfiguration {
|
|
||||||
inline operator fun <reified T: Any> getValue(ref: Any?, property: KProperty<*>): Lazy<T> = lazy {
|
|
||||||
Configuration.getValue<T>(ref, property);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
package fr.username404.snowygui.gui
|
package fr.username404.snowygui.gui
|
||||||
|
|
||||||
import com.mojang.blaze3d.vertex.VertexConsumer
|
import com.mojang.blaze3d.vertex.*
|
||||||
import fr.username404.snowygui.Snowy
|
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
|
||||||
@ -58,12 +58,8 @@ abstract class ColoredElement(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal fun VertexConsumer.colorEnd(color: Int = this@ColoredElement.color) = colorIt(color, opacity)
|
internal fun VertexConsumer.colorEnd(color: Int = this@ColoredElement.color) = colorIt(color, opacity)
|
||||||
|
protected fun defaultRectFunc() = RenderingUtil.drawRectangle(x, y, height, width, color, opacity)
|
||||||
protected fun defaultRectFunc(guiGraphics: GuiGraphics?) = guiGraphics?.let {
|
|
||||||
RenderingUtil.drawRectangle(it, x, y, height, width, color, opacity)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun hextoRGB(hex: Int): MutableList<Float> {
|
fun hextoRGB(hex: Int): MutableList<Float> {
|
||||||
|
|||||||
@ -1,21 +1,23 @@
|
|||||||
package fr.username404.snowygui.gui.elements
|
package fr.username404.snowygui.gui.elements
|
||||||
|
|
||||||
|
import com.mojang.blaze3d.vertex.BufferUploader
|
||||||
|
import com.mojang.blaze3d.vertex.DefaultVertexFormat
|
||||||
|
import com.mojang.blaze3d.vertex.VertexFormat
|
||||||
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 fr.username404.snowygui.gui.ColoredElement
|
import fr.username404.snowygui.gui.ColoredElement
|
||||||
import fr.username404.snowygui.gui.feature.ButtonImpl
|
import fr.username404.snowygui.gui.feature.ButtonImpl
|
||||||
import fr.username404.snowygui.gui.feature.Category
|
import fr.username404.snowygui.gui.feature.Category
|
||||||
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.colorShader
|
||||||
|
import fr.username404.snowygui.utils.RenderingUtil.endDraw
|
||||||
|
import fr.username404.snowygui.utils.RenderingUtil.prepareDraw
|
||||||
|
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.client.gui.GuiGraphics
|
||||||
import net.minecraft.network.chat.Component
|
import net.minecraft.network.chat.Component
|
||||||
import net.minecraft.util.ARGB
|
|
||||||
import kotlin.math.floor
|
|
||||||
import kotlin.math.max
|
|
||||||
import kotlin.math.min
|
|
||||||
import kotlin.math.roundToInt
|
|
||||||
import org.jetbrains.annotations.ApiStatus
|
import org.jetbrains.annotations.ApiStatus
|
||||||
import java.util.TreeSet
|
import java.util.TreeSet
|
||||||
import kotlin.collections.LinkedHashSet
|
import kotlin.collections.LinkedHashSet
|
||||||
@ -25,7 +27,7 @@ class ClickBox(
|
|||||||
x: Double, y: Double,
|
x: Double, y: Double,
|
||||||
val name: Component = MissingComponent,
|
val name: Component = MissingComponent,
|
||||||
override var color: Int = savedColors?.get(name.string) ?: Colors.BLUE.hexValue,
|
override var color: Int = savedColors?.get(name.string) ?: Colors.BLUE.hexValue,
|
||||||
) : ColoredElement(x, y, 80, 10, color, 0.5F) {
|
): ColoredElement(x, y, 80, 10, color, 0.5F) {
|
||||||
fun isCategory(c: Category): Boolean = (name.string == c.box.name.string)
|
fun isCategory(c: Category): Boolean = (name.string == c.box.name.string)
|
||||||
val buttons: MutableSet<ButtonImpl> =
|
val buttons: MutableSet<ButtonImpl> =
|
||||||
if (sortAlphabetically)
|
if (sortAlphabetically)
|
||||||
@ -44,28 +46,24 @@ class ClickBox(
|
|||||||
) {
|
) {
|
||||||
override val color: Int get() = this@ClickBox.color
|
override val color: Int get() = this@ClickBox.color
|
||||||
override fun render(guiGraphics: GuiGraphics?) {
|
override fun render(guiGraphics: GuiGraphics?) {
|
||||||
defaultRectFunc(guiGraphics)
|
prepareDraw()
|
||||||
|
colorShader(); defaultRectFunc()
|
||||||
|
endDraw()
|
||||||
}
|
}
|
||||||
init { height = 8 }
|
init { height = 8 }
|
||||||
}
|
}
|
||||||
|
var barStage: Int = 1; private set
|
||||||
var barStage: Int = 0; private set
|
|
||||||
|
|
||||||
fun scroll(d: Double, e: Double, supplied: Double) {
|
fun scroll(d: Double, e: Double, supplied: Double) {
|
||||||
if (!isWithinBounds(d, e, offsetHeight = clickboxHeightOffset.toDouble())) return
|
if (isWithinBounds(d, e, offsetHeight = clickboxHeightOffset.toDouble())) {
|
||||||
if (buttons.isEmpty()) return
|
with(buttonsProgressBar) {
|
||||||
|
if ((height > 8 || (supplied < 0)) && (((height < (buttons.size * 8)) && (height < originalHeight)) || (supplied > 0))) {
|
||||||
// This allows scrolling until only the last button is visible at the top
|
height -= supplied.toInt()
|
||||||
val maxScroll = max(0, buttons.size - 1)
|
if (buttons.isNotEmpty()) (height / 8).let {
|
||||||
|
if (it > 0) barStage = it
|
||||||
val step = when {
|
}
|
||||||
supplied < 0 -> 1
|
}
|
||||||
supplied > 0 -> -1
|
}
|
||||||
else -> 0
|
|
||||||
}
|
}
|
||||||
if (step == 0) return
|
|
||||||
|
|
||||||
barStage = (barStage + step).coerceIn(0, maxScroll)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
@ -75,96 +73,58 @@ class ClickBox(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
var sortAlphabetically: Boolean by Configuration
|
var sortAlphabetically: Boolean by Configuration
|
||||||
|
const val buttonsMax: Short = 16 // TODO Remove the buttons limit
|
||||||
const val clickboxHeightOffset: Int = 80
|
const val clickboxHeightOffset: Int = 80
|
||||||
private const val inclination: Float = 2.5F
|
private const val inclination: Float = 2.5F
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun render(guiGraphics: GuiGraphics?) {
|
override fun render(guiGraphics: GuiGraphics?) {
|
||||||
val xi = floor(x).toInt()
|
val x = x.toFloat()
|
||||||
val yi = floor(y).toInt()
|
val y = y.toFloat()
|
||||||
|
val currentHeight = y + (height + clickboxHeightOffset)
|
||||||
|
prepareDraw()
|
||||||
|
with(tessellator.begin(VertexFormat.Mode.TRIANGLE_FAN, DefaultVertexFormat.POSITION_COLOR)) {
|
||||||
|
// Render the header:
|
||||||
|
addVertex(x, y + height, 0.0F).colorEnd()
|
||||||
|
addVertex(x + width + inclination, y + height, 0.0F).colorEnd()
|
||||||
|
addVertex(x + width, y, 0.0F).colorEnd()
|
||||||
|
addVertex(x + inclination, y, 0.0F).colorEnd()
|
||||||
|
|
||||||
// Header
|
// Render the box:
|
||||||
RenderingUtil.drawSlantedHeader(
|
addVertex(x, currentHeight, 0.0F).colorEnd()
|
||||||
guiGraphics = guiGraphics,
|
addVertex(x + width + inclination, currentHeight, 0.0F).colorEnd()
|
||||||
x = xi,
|
addVertex(x + width + inclination, y + height, 0.0F).colorEnd()
|
||||||
y = yi,
|
BufferUploader.drawWithShader(buildOrThrow())
|
||||||
width = width,
|
|
||||||
height = height,
|
|
||||||
slantTop = inclination,
|
|
||||||
color = color,
|
|
||||||
opacity = opacity
|
|
||||||
)
|
|
||||||
|
|
||||||
// Body
|
colorShader()
|
||||||
RenderingUtil.drawRectangle(
|
with(tessellator.begin(VertexFormat.Mode.DEBUG_LINES, DefaultVertexFormat.POSITION_COLOR)) {
|
||||||
guiGraphics = guiGraphics,
|
addVertex(x + inclination, y + height, 0.0F).colorEnd(Colors.WHITE_LINES.hexValue)
|
||||||
x = xi.toDouble(),
|
addVertex(x + width, y + height, 0.0F).colorEnd(Colors.WHITE_LINES.hexValue)
|
||||||
y = (yi + height).toDouble(),
|
BufferUploader.drawWithShader(buildOrThrow())
|
||||||
height = clickboxHeightOffset,
|
}
|
||||||
width = width + inclination.roundToInt(),
|
}
|
||||||
color = color,
|
endDraw()
|
||||||
opacity = opacity
|
|
||||||
)
|
|
||||||
|
|
||||||
// Separator line
|
|
||||||
RenderingUtil.hLine(
|
|
||||||
guiGraphics = guiGraphics,
|
|
||||||
x1 = (xi + inclination).toInt(),
|
|
||||||
x2 = (xi + width),
|
|
||||||
y = (yi + height),
|
|
||||||
rgb = Colors.WHITE_LINES.hexValue,
|
|
||||||
opacity = 1f
|
|
||||||
)
|
|
||||||
|
|
||||||
if (buttons.isNotEmpty()) {
|
if (buttons.isNotEmpty()) {
|
||||||
val barWidth = 3
|
|
||||||
val leftPadding = 3
|
|
||||||
val gapToBar = 1
|
|
||||||
|
|
||||||
val rowHeight = 9
|
|
||||||
val visibleRows = 8
|
|
||||||
val maxScroll = max(0, buttons.size - visibleRows)
|
|
||||||
|
|
||||||
val actualContentHeight = min(buttons.size, visibleRows) * rowHeight
|
|
||||||
|
|
||||||
val minBarH = 8
|
|
||||||
val currentBarH = if (maxScroll == 0) minBarH*(barStage + 1)
|
|
||||||
else minBarH + ((actualContentHeight - minBarH).toFloat() * barStage / maxScroll).roundToInt()
|
|
||||||
|
|
||||||
buttonsProgressBar.apply {
|
buttonsProgressBar.apply {
|
||||||
this.width = barWidth
|
this.x = this@ClickBox.x + this@ClickBox.width - 3
|
||||||
this.height = currentBarH.coerceAtMost(actualContentHeight)
|
this.y = this@ClickBox.y + this@ClickBox.height + 3
|
||||||
this.x = (xi + this@ClickBox.width - barWidth).toDouble()
|
|
||||||
this.y = (yi + this@ClickBox.height + 3).toDouble()
|
|
||||||
}.display(guiGraphics)
|
}.display(guiGraphics)
|
||||||
|
|
||||||
val buttonWidth = (this@ClickBox.width - leftPadding - barWidth - gapToBar).coerceAtLeast(10)
|
|
||||||
|
|
||||||
val contentStartY = yi + height + 3
|
|
||||||
val maxContentY = contentStartY + (8 * 9)
|
|
||||||
|
|
||||||
buttons.forEachIndexed { num, button ->
|
buttons.forEachIndexed { num, button ->
|
||||||
val rowOffset = num - barStage
|
val fullHeight = (y + height.toDouble())..(this.y + height + clickboxHeightOffset)
|
||||||
val yPos = contentStartY + (rowOffset * 9)
|
|
||||||
|
|
||||||
button.also {
|
button.also {
|
||||||
it.x = (xi + leftPadding).toDouble()
|
it.x = this.x + 3
|
||||||
it.y = yPos.toDouble()
|
it.y = this.y + 3 + height + (((num + 1) - barStage) * 9)
|
||||||
it.width = buttonWidth
|
it.hidden = if ((num + 1) <= 8) ((it.y) !in fullHeight) else ((it.y + it.height) !in fullHeight)
|
||||||
it.hidden = (rowOffset < 0) || (yPos + it.height > maxContentY)
|
|
||||||
}.display(guiGraphics)
|
}.display(guiGraphics)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
guiGraphics?.run {
|
||||||
with(Minecraft.getInstance().font) {
|
with(Minecraft.getInstance().font) {
|
||||||
guiGraphics?.drawString(
|
drawInBatch(name.string,
|
||||||
this,
|
(x + 5), (y + 2), Colors.TRANSPARENT.hexValue, false,
|
||||||
Component.nullToEmpty(name.string),
|
pose().last().pose(), bufferSource(), Font.DisplayMode.NORMAL, 0, 15728880, isBidirectional
|
||||||
(xi + 5 + (inclination / 2f)).toInt(),
|
)
|
||||||
(yi + 2),
|
}
|
||||||
ARGB.opaque(Colors.WHITE.hexValue),
|
|
||||||
false
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,8 +6,10 @@ 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.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.utils.RenderingUtil.endDraw
|
||||||
|
import fr.username404.snowygui.utils.RenderingUtil.prepareDraw
|
||||||
import net.minecraft.client.gui.GuiGraphics
|
import net.minecraft.client.gui.GuiGraphics
|
||||||
import net.minecraft.client.input.MouseButtonEvent
|
|
||||||
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) {
|
||||||
@ -43,26 +45,20 @@ sealed class ButtonImpl: ColoredElement(0.0, 0.0, 73, 8, opacity = 0.60F) {
|
|||||||
}.plus(Configuration.foundMacros).toTypedArray()
|
}.plus(Configuration.foundMacros).toTypedArray()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
var isDisabled: Boolean = false; set(value) {
|
var isDisabled: Boolean = false; set(value) {
|
||||||
field = value
|
field = value
|
||||||
hidden = value
|
hidden = value
|
||||||
}
|
}
|
||||||
|
|
||||||
@JvmField
|
@JvmField
|
||||||
val info = this::class.findAnnotation<ButtonInfo>() ?: throw Exception("Missing @ButtonInfo annotaton")
|
val info = this::class.findAnnotation<ButtonInfo>() ?: throw Exception("Missing @ButtonInfo annotaton")
|
||||||
|
|
||||||
final override var color = info.parent.categoryColor; get() {
|
final override var color = info.parent.categoryColor; get() {
|
||||||
return info.parent.box.color.let {
|
return info.parent.box.color.let {
|
||||||
if (field == it) field else it
|
if (field == it) field else it
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
open val title: String = this@ButtonImpl::class.simpleName.toString()
|
open val title: String = this@ButtonImpl::class.simpleName.toString()
|
||||||
protected open fun execAction() = Unit
|
protected open fun execAction() = Unit
|
||||||
|
|
||||||
private var wasWithinBounds: Boolean = false
|
private var wasWithinBounds: Boolean = false
|
||||||
|
|
||||||
var toggled: Boolean = false; private set(value) {
|
var toggled: Boolean = false; private set(value) {
|
||||||
if (field xor value) {
|
if (field xor value) {
|
||||||
if (value) lightUp() else lightDown()
|
if (value) lightUp() else lightDown()
|
||||||
@ -70,12 +66,10 @@ sealed class ButtonImpl: ColoredElement(0.0, 0.0, 73, 8, opacity = 0.60F) {
|
|||||||
execAction()
|
execAction()
|
||||||
} else field = value
|
} else field = value
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun lightUp() { opacity += ButtonInfo.lightningFactor }
|
private fun lightUp() { opacity += ButtonInfo.lightningFactor }
|
||||||
private fun lightDown() { opacity -= ButtonInfo.lightningFactor }
|
private fun lightDown() { opacity -= ButtonInfo.lightningFactor }
|
||||||
|
final override fun mouseClicked(d: Double, e: Double, i: Int): Boolean {
|
||||||
final override fun mouseClicked(event: MouseButtonEvent, isDoubleClick: Boolean): Boolean {
|
wasWithinBounds = isWithinBounds(d, e).also {
|
||||||
wasWithinBounds = isWithinBounds(event.x, event.y).also {
|
|
||||||
if (it) {
|
if (it) {
|
||||||
if (info.kind == Type.TOGGLE) {
|
if (info.kind == Type.TOGGLE) {
|
||||||
toggled = !toggled
|
toggled = !toggled
|
||||||
@ -85,16 +79,16 @@ sealed class ButtonImpl: ColoredElement(0.0, 0.0, 73, 8, opacity = 0.60F) {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
final override fun mouseReleased(event: MouseButtonEvent): Boolean {
|
final override fun mouseReleased(d: Double, e: Double, i: Int): Boolean {
|
||||||
if (wasWithinBounds && (info.kind == Type.CLICK)) {
|
if (wasWithinBounds && (info.kind == Type.CLICK)) {
|
||||||
execAction()
|
execAction()
|
||||||
lightDown()
|
lightDown()
|
||||||
}
|
}; return false
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
final override fun render(guiGraphics: GuiGraphics?) {
|
final override fun render(guiGraphics: GuiGraphics?) {
|
||||||
defaultRectFunc(guiGraphics)
|
prepareDraw()
|
||||||
|
colorShader(); defaultRectFunc()
|
||||||
|
endDraw()
|
||||||
if (guiGraphics != null) {
|
if (guiGraphics != null) {
|
||||||
FontUtil.drawScaled(guiGraphics, title, x + 1, y + 1, 0.75F)
|
FontUtil.drawScaled(guiGraphics, title, x + 1, y + 1, 0.75F)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,16 +3,11 @@ package fr.username404.snowygui.gui.feature
|
|||||||
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.Minecraft
|
|
||||||
import net.minecraft.client.gui.GuiGraphics
|
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 = {
|
private val generatedLambda: argsLambda = { hudRenderLambda.render(it.first() as GuiGraphics?) }
|
||||||
if (!Minecraft.getInstance().options.hideGui) {
|
|
||||||
hudRenderLambda.render(it.first() as GuiGraphics?)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
final override fun execAction() {
|
final override fun execAction() {
|
||||||
EventSnowy["HudRender"].run {
|
EventSnowy["HudRender"].run {
|
||||||
if (toggled) add(generatedLambda)
|
if (toggled) add(generatedLambda)
|
||||||
|
|||||||
@ -28,7 +28,7 @@ annotation class ButtonInfo(
|
|||||||
HUD("snowy.clickbox.hud", Colors.DARK_PURPLE),
|
HUD("snowy.clickbox.hud", Colors.DARK_PURPLE),
|
||||||
MACROS("snowy.clickbox.macros", Colors.GREEN);
|
MACROS("snowy.clickbox.macros", Colors.GREEN);
|
||||||
companion object {
|
companion object {
|
||||||
fun fromBox(box: ClickBox): Category? = entries.find {
|
fun fromBox(box: ClickBox): Category? = values().find {
|
||||||
box.isCategory(it)
|
box.isCategory(it)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,19 @@
|
|||||||
package fr.username404.snowygui.gui.feature
|
package fr.username404.snowygui.gui.feature
|
||||||
|
|
||||||
|
import net.minecraft.client.Minecraft
|
||||||
|
|
||||||
@ButtonInfo(Category.MISC)
|
@ButtonInfo(Category.MISC)
|
||||||
object GammaBoost: ButtonImpl() {
|
object GammaBoost: ButtonImpl() {
|
||||||
const val BOOST = 1400.0F
|
private const val boost = 1400.0
|
||||||
|
private var oldGamma = 0.0
|
||||||
|
override fun execAction() {
|
||||||
|
with(Minecraft.getInstance().options) {
|
||||||
|
val gamma = gamma().get()
|
||||||
|
gamma().value =
|
||||||
|
if (toggled) {
|
||||||
|
if (gamma < boost) oldGamma = gamma
|
||||||
|
boost
|
||||||
|
} else oldGamma
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@ -44,7 +44,7 @@ object Keystrokes: ButtonImplWithHud() {
|
|||||||
private fun drawKey(x: Double, y: Double, key: Int, guiGraphics: GuiGraphics?) {
|
private fun drawKey(x: Double, y: Double, key: Int, guiGraphics: GuiGraphics?) {
|
||||||
RenderingUtil.prepareDraw()
|
RenderingUtil.prepareDraw()
|
||||||
RenderingUtil.drawRectangle(
|
RenderingUtil.drawRectangle(
|
||||||
guiGraphics, 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()
|
||||||
@ -68,7 +68,7 @@ object Keystrokes: ButtonImplWithHud() {
|
|||||||
hud.display(it)
|
hud.display(it)
|
||||||
}
|
}
|
||||||
init {
|
init {
|
||||||
if (!Position.entries.map { it.value }.contains(currentPosition)) {
|
if (!Position.values().map { it.value }.contains(currentPosition)) {
|
||||||
currentPosition = Position.LEFT.value
|
currentPosition = Position.LEFT.value
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,7 +3,6 @@ package fr.username404.snowygui.gui.feature
|
|||||||
import fr.username404.snowygui.gui.feature.ButtonInfo.Companion.Type
|
import fr.username404.snowygui.gui.feature.ButtonInfo.Companion.Type
|
||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.Serializable
|
||||||
import net.minecraft.client.Minecraft
|
import net.minecraft.client.Minecraft
|
||||||
import net.minecraft.server.permissions.Permissions
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @property command The command to execute
|
* @property command The command to execute
|
||||||
@ -18,7 +17,7 @@ data class Macro(
|
|||||||
override fun execAction(): Unit = with(Minecraft.getInstance().player!!) {
|
override fun execAction(): Unit = with(Minecraft.getInstance().player!!) {
|
||||||
connection.run {
|
connection.run {
|
||||||
command.let {
|
command.let {
|
||||||
if (it.startsWith("say") && !this@with.permissions().hasPermission(Permissions.COMMANDS_GAMEMASTER)) {
|
if (it.startsWith("say") && !hasPermissions(2)) {
|
||||||
sendChat(it.drop(4))
|
sendChat(it.drop(4))
|
||||||
} else sendCommand(it)
|
} else sendCommand(it)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,9 +6,9 @@ import net.minecraft.client.Minecraft
|
|||||||
@ButtonInfo(Category.MISC, shouldSave = false)
|
@ButtonInfo(Category.MISC, shouldSave = false)
|
||||||
object Zoom: ButtonImpl() {
|
object Zoom: ButtonImpl() {
|
||||||
var smoothCameraOnZoom: Boolean by Configuration
|
var smoothCameraOnZoom: Boolean by Configuration
|
||||||
var zoomFactor: Float by Configuration
|
var zoomFactor: Double by Configuration
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun getNewZoom(fov: Float): Float = fov / zoomFactor
|
fun getNewZoom(fov: Double): Double = fov / zoomFactor
|
||||||
public override fun execAction() {
|
public override fun execAction() {
|
||||||
Minecraft.getInstance().options.smoothCamera = toggled && smoothCameraOnZoom
|
Minecraft.getInstance().options.smoothCamera = toggled && smoothCameraOnZoom
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,26 +6,20 @@ import fr.username404.snowygui.config.SnowyConfigScreen
|
|||||||
import fr.username404.snowygui.config.configScreenParent
|
import fr.username404.snowygui.config.configScreenParent
|
||||||
import net.minecraft.client.KeyMapping
|
import net.minecraft.client.KeyMapping
|
||||||
import net.minecraft.client.Minecraft
|
import net.minecraft.client.Minecraft
|
||||||
import net.minecraft.resources.Identifier
|
|
||||||
import org.lwjgl.glfw.GLFW.GLFW_KEY_U
|
import org.lwjgl.glfw.GLFW.GLFW_KEY_U
|
||||||
import org.lwjgl.glfw.GLFW.GLFW_KEY_Y
|
import org.lwjgl.glfw.GLFW.GLFW_KEY_Y
|
||||||
|
|
||||||
private typealias privateLambda = (() -> Unit)?
|
private typealias privateLambda = (() -> Unit)?
|
||||||
object AddKeyMaps {
|
object AddKeyMaps {
|
||||||
private const val prefix = "snowy"
|
private const val prefix = "snowy"
|
||||||
var category: KeyMapping.Category? = null; private set
|
|
||||||
@JvmOverloads
|
@JvmOverloads
|
||||||
internal fun mkMap(
|
internal fun mkMap(
|
||||||
translationSuffix: String,
|
translationSuffix: String,
|
||||||
key: Int, category: String = "controls",
|
key: Int, category: String = "keycategory",
|
||||||
lambda: privateLambda = null
|
lambda: privateLambda = null
|
||||||
): Pair<KeyMapping, privateLambda> = KeyMapping(
|
): Pair<KeyMapping, privateLambda> = KeyMapping(
|
||||||
"key.$prefix.$translationSuffix", InputConstants.Type.KEYSYM,
|
"key.$prefix.$translationSuffix", InputConstants.Type.KEYSYM,
|
||||||
key, this.category ?: run {
|
key, "category.$prefix.$category"
|
||||||
this.category = KeyMapping.Category.register(
|
|
||||||
Identifier.fromNamespaceAndPath("snowygui", category)
|
|
||||||
); this.category
|
|
||||||
}!!
|
|
||||||
) to lambda
|
) to lambda
|
||||||
val list: MutableMap<KeyMapping, privateLambda> = with(Minecraft.getInstance()) {
|
val list: MutableMap<KeyMapping, privateLambda> = with(Minecraft.getInstance()) {
|
||||||
mutableMapOf(
|
mutableMapOf(
|
||||||
|
|||||||
@ -3,18 +3,13 @@ package fr.username404.snowygui.utils
|
|||||||
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
|
import net.minecraft.client.gui.GuiGraphics
|
||||||
import net.minecraft.util.ARGB
|
|
||||||
|
|
||||||
object FontUtil {
|
object FontUtil {
|
||||||
fun drawScaled(guiGraphics: GuiGraphics, text: String, x: Double, y: Double, scaleFactor: Float, color: Colors = Colors.BLACK) {
|
fun drawScaled(guiGraphics: GuiGraphics, text: String, x: Double, y: Double, scaleFactor: Float, color: Colors = Colors.BLACK) {
|
||||||
val stack = guiGraphics.pose()
|
val stack = guiGraphics.pose()
|
||||||
stack.scale(scaleFactor, scaleFactor)
|
stack.scale(scaleFactor, scaleFactor, scaleFactor)
|
||||||
guiGraphics.drawString(
|
guiGraphics.drawString(Minecraft.getInstance().font, text, (x / scaleFactor).toInt(), (y / scaleFactor).toInt(), color.hexValue, false)
|
||||||
Minecraft.getInstance().font, text,
|
|
||||||
(x / scaleFactor).toInt(), (y / scaleFactor).toInt(),
|
|
||||||
ARGB.opaque(color.hexValue), false
|
|
||||||
)
|
|
||||||
val factorToOriginal = 1F / scaleFactor
|
val factorToOriginal = 1F / scaleFactor
|
||||||
stack.scale(factorToOriginal, factorToOriginal)
|
stack.scale(factorToOriginal, factorToOriginal, factorToOriginal)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,104 +1,43 @@
|
|||||||
package fr.username404.snowygui.utils
|
package fr.username404.snowygui.utils
|
||||||
|
|
||||||
import com.mojang.blaze3d.opengl.GlStateManager
|
import com.mojang.blaze3d.systems.RenderSystem
|
||||||
|
import com.mojang.blaze3d.vertex.BufferUploader
|
||||||
|
import com.mojang.blaze3d.vertex.DefaultVertexFormat
|
||||||
|
import com.mojang.blaze3d.vertex.Tesselator
|
||||||
|
import com.mojang.blaze3d.vertex.VertexConsumer
|
||||||
|
import com.mojang.blaze3d.vertex.VertexFormat
|
||||||
import fr.username404.snowygui.gui.feature.Colors
|
import fr.username404.snowygui.gui.feature.Colors
|
||||||
import net.minecraft.client.gui.GuiGraphics
|
import fr.username404.snowygui.gui.hextoRGB
|
||||||
import net.minecraft.util.ARGB
|
import net.minecraft.client.renderer.GameRenderer
|
||||||
import kotlin.math.ceil
|
|
||||||
import kotlin.math.floor
|
|
||||||
import kotlin.math.max
|
|
||||||
import kotlin.math.min
|
|
||||||
|
|
||||||
object RenderingUtil {
|
object RenderingUtil {
|
||||||
fun prepareDraw() = GlStateManager._enableBlend()
|
@JvmField val tessellator: Tesselator = Tesselator.getInstance()
|
||||||
fun endDraw() = GlStateManager._disableBlend()
|
@JvmStatic
|
||||||
|
fun VertexConsumer.colorIt(color: Int, opacity: Float = 1F): VertexConsumer = hextoRGB(color).run {
|
||||||
private fun argbFromRgb(rgb: Int, opacity: Float = 1f): Int {
|
setColor(get(0), get(1), get(2), opacity)
|
||||||
return ARGB.color(
|
}
|
||||||
(opacity.coerceIn(0f, 1f) * 255f).toInt().coerceIn(0, 255),
|
fun colorShader() {
|
||||||
(rgb shr 16) and 0xFF,
|
RenderSystem.setShader(GameRenderer::getPositionColorShader)
|
||||||
(rgb shr 8) and 0xFF,
|
RenderSystem.setShaderColor(1F, 1F, 1F, 1F)
|
||||||
rgb and 0xFF
|
}
|
||||||
)
|
fun prepareDraw() {
|
||||||
|
colorShader()
|
||||||
|
RenderSystem.enableBlend()
|
||||||
|
RenderSystem.defaultBlendFunc()
|
||||||
|
}
|
||||||
|
fun endDraw() {
|
||||||
|
RenderSystem.disableBlend()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun drawRectangle(
|
fun drawRectangle(
|
||||||
guiGraphics: GuiGraphics?,
|
x: Double, y: Double, height: Int, width: Int,
|
||||||
x: Double,
|
color: Int = Colors.TRANSPARENT(), opacity: Float = 1F
|
||||||
y: Double,
|
): Unit = tessellator.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_COLOR).run {
|
||||||
height: Int,
|
fun VertexConsumer.colorIt() = colorIt(color, opacity)
|
||||||
width: Int,
|
val x = x.toFloat() ; val y = y.toFloat()
|
||||||
color: Int = Colors.TRANSPARENT(),
|
addVertex(x, y + height, 0.0F).colorIt()
|
||||||
opacity: Float = 1F
|
addVertex(x + width, y + height, 0.0F).colorIt()
|
||||||
) {
|
addVertex(x + width, y, 0.0F).colorIt()
|
||||||
if (guiGraphics == null) return
|
addVertex(x, y, 0.0F).colorIt()
|
||||||
|
BufferUploader.drawWithShader(buildOrThrow())
|
||||||
val x1 = floor(x).toInt()
|
|
||||||
val y1 = floor(y).toInt()
|
|
||||||
val x2 = ceil(x + width).toInt()
|
|
||||||
val y2 = ceil(y + height).toInt()
|
|
||||||
|
|
||||||
prepareDraw()
|
|
||||||
guiGraphics.fill(x1, y1, x2, y2, argbFromRgb(color, opacity))
|
|
||||||
endDraw()
|
|
||||||
}
|
|
||||||
|
|
||||||
fun drawSlantedHeader(
|
|
||||||
guiGraphics: GuiGraphics?,
|
|
||||||
x: Int,
|
|
||||||
y: Int,
|
|
||||||
width: Int,
|
|
||||||
height: Int,
|
|
||||||
slantTop: Float,
|
|
||||||
color: Int,
|
|
||||||
opacity: Float
|
|
||||||
) {
|
|
||||||
if (guiGraphics == null) return
|
|
||||||
if (width <= 0 || height <= 0) return
|
|
||||||
|
|
||||||
val slant = slantTop.toDouble()
|
|
||||||
val baseArgb = argbFromRgb(color, opacity)
|
|
||||||
|
|
||||||
prepareDraw()
|
|
||||||
for (dy in 0 until height) {
|
|
||||||
val t = if (height == 1) 0.0 else dy.toDouble() / (height - 1).toDouble()
|
|
||||||
|
|
||||||
val leftF = x + slant * (1.0 - t)
|
|
||||||
val rightF = x + width + slant * t
|
|
||||||
|
|
||||||
val left = min(leftF, rightF)
|
|
||||||
val right = max(leftF, rightF)
|
|
||||||
|
|
||||||
val lx = floor(left).toInt()
|
|
||||||
val rx = floor(right).toInt()
|
|
||||||
val yy = y + dy
|
|
||||||
|
|
||||||
val midStart = lx + 1
|
|
||||||
val midEnd = rx
|
|
||||||
if (midEnd > midStart) {
|
|
||||||
guiGraphics.fill(midStart, yy, midEnd, yy + 1, baseArgb)
|
|
||||||
}
|
|
||||||
|
|
||||||
val leftFrac = (left - floor(left)).toFloat().coerceIn(0f, 1f)
|
|
||||||
val rightFrac = (right - floor(right)).toFloat().coerceIn(0f, 1f)
|
|
||||||
|
|
||||||
val leftAlpha = (1f - leftFrac) * opacity
|
|
||||||
val rightAlpha = rightFrac * opacity
|
|
||||||
|
|
||||||
if (leftAlpha > 0f) guiGraphics.fill(lx, yy, lx + 1, yy + 1, argbFromRgb(color, leftAlpha))
|
|
||||||
if (rightAlpha > 0f) guiGraphics.fill(rx, yy, rx + 1, yy + 1, argbFromRgb(color, rightAlpha))
|
|
||||||
|
|
||||||
if (rx <= lx) {
|
|
||||||
guiGraphics.fill(lx, yy, lx + 1, yy + 1, baseArgb)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
endDraw()
|
|
||||||
}
|
|
||||||
|
|
||||||
fun hLine(guiGraphics: GuiGraphics?, x1: Int, x2: Int, y: Int, rgb: Int, opacity: Float = 1f) {
|
|
||||||
if (guiGraphics == null) return
|
|
||||||
prepareDraw()
|
|
||||||
guiGraphics.hLine(x1, x2, y, argbFromRgb(rgb, opacity))
|
|
||||||
endDraw()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -7,13 +7,14 @@
|
|||||||
"screen.snowy.config.general.macros.missingelement": "Missing element(s) next to the separator",
|
"screen.snowy.config.general.macros.missingelement": "Missing element(s) next to the separator",
|
||||||
"screen.snowy.config.general.macros.toomuchdelimiters": "Too much separators (only one is allowed)",
|
"screen.snowy.config.general.macros.toomuchdelimiters": "Too much separators (only one is allowed)",
|
||||||
"screen.snowy.config.general.macros.toomuchcharacters": "Too much characters (16 is the maximum)",
|
"screen.snowy.config.general.macros.toomuchcharacters": "Too much characters (16 is the maximum)",
|
||||||
|
"screen.snowy.config.general.macros.toomuchbuttons": "Too much entries (16 is the maximum)",
|
||||||
"screen.snowy.config.colors": "Box colors",
|
"screen.snowy.config.colors": "Box colors",
|
||||||
"screen.snowy.config.behavior": "Behavior",
|
"screen.snowy.config.behavior": "Behavior",
|
||||||
"screen.snowy.config.behavior.sortalphabetically": "Sort buttons alphabetically",
|
"screen.snowy.config.behavior.sortalphabetically": "Sort buttons alphabetically",
|
||||||
"screen.snowy.config.behavior.zoom.factor": "Zoom factor",
|
"screen.snowy.config.behavior.zoom.factor": "Zoom factor",
|
||||||
"screen.snowy.config.behavior.zoom.smoothcamera": "Smooth camera on zoom",
|
"screen.snowy.config.behavior.zoom.smoothcamera": "Smooth camera on zoom",
|
||||||
"screen.snowy.config.behavior.keystrokes.position": "Position of the keystrokes HUD element",
|
"screen.snowy.config.behavior.keystrokes.position": "Position of the keystrokes HUD element",
|
||||||
"key.category.snowygui.controls": "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": "Miscellaneous",
|
"snowy.clickbox.misc": "Miscellaneous",
|
||||||
|
|||||||
@ -7,13 +7,14 @@
|
|||||||
"screen.snowy.config.general.macros.missingelement": "Élément(s) manquant(s) avant ou après le séparateur",
|
"screen.snowy.config.general.macros.missingelement": "Élément(s) manquant(s) avant ou après le séparateur",
|
||||||
"screen.snowy.config.general.macros.toomuchdelimiters": "Séparateurs trop nombreux (un seul est autorisé)",
|
"screen.snowy.config.general.macros.toomuchdelimiters": "Séparateurs trop nombreux (un seul est autorisé)",
|
||||||
"screen.snowy.config.general.macros.toomuchcharacters": "Trop de caractères (le maximum est de 16)",
|
"screen.snowy.config.general.macros.toomuchcharacters": "Trop de caractères (le maximum est de 16)",
|
||||||
|
"screen.snowy.config.general.macros.toomuchbuttons": "Trop d'entrées (le maximum est de 16)",
|
||||||
"screen.snowy.config.colors": "Couleurs des boîtes",
|
"screen.snowy.config.colors": "Couleurs des boîtes",
|
||||||
"screen.snowy.config.behavior": "Comportement",
|
"screen.snowy.config.behavior": "Comportement",
|
||||||
"screen.snowy.config.behavior.sortalphabetically": "Trier les boutons alphabétiquement",
|
"screen.snowy.config.behavior.sortalphabetically": "Trier les boutons alphabétiquement",
|
||||||
"screen.snowy.config.behavior.zoom.factor": "Facteur de zoom",
|
"screen.snowy.config.behavior.zoom.factor": "Facteur de zoom",
|
||||||
"screen.snowy.config.behavior.zoom.smoothcamera": "Caméra fluide pendant le zoom",
|
"screen.snowy.config.behavior.zoom.smoothcamera": "Caméra fluide pendant le zoom",
|
||||||
"screen.snowy.config.behavior.keystrokes.position": "Position de l'élément keystrokes de l'ATH",
|
"screen.snowy.config.behavior.keystrokes.position": "Position de l'élément keystrokes de l'ATH",
|
||||||
"key.category.snowygui.controls": "SnowyGUI",
|
"category.snowy.keycategory": "SnowyGUI",
|
||||||
"key.snowy.opengui": "Ouvrir l'interface de snowy",
|
"key.snowy.opengui": "Ouvrir l'interface de snowy",
|
||||||
"key.snowy.configkey": "Ouvrir l'écran de configuration de snowy",
|
"key.snowy.configkey": "Ouvrir l'écran de configuration de snowy",
|
||||||
"snowy.clickbox.misc": "Divers",
|
"snowy.clickbox.misc": "Divers",
|
||||||
|
|||||||
@ -2,11 +2,10 @@
|
|||||||
"required": true,
|
"required": true,
|
||||||
"package": "fr.username404.snowygui.mixins",
|
"package": "fr.username404.snowygui.mixins",
|
||||||
"compatibilityLevel": "JAVA_18",
|
"compatibilityLevel": "JAVA_18",
|
||||||
"client": [
|
"client": [],
|
||||||
"GammaMixin"
|
|
||||||
],
|
|
||||||
"injectors": {
|
"injectors": {
|
||||||
"defaultRequire": 1
|
"defaultRequire": 1
|
||||||
},
|
},
|
||||||
"minVersion": "0.8"
|
"minVersion": "0.8",
|
||||||
|
"refmap": "snowygui-common-refmap.json"
|
||||||
}
|
}
|
||||||
@ -1,9 +1,3 @@
|
|||||||
accessWidener v2 named
|
accessWidener v2 named
|
||||||
|
|
||||||
accessible field net/minecraft/client/OptionInstance value Ljava/lang/Object;
|
accessible field net/minecraft/client/OptionInstance value Ljava/lang/Object;
|
||||||
mutable field net/minecraft/client/OptionInstance value Ljava/lang/Object;
|
mutable field net/minecraft/client/OptionInstance value Ljava/lang/Object;
|
||||||
|
|
||||||
accessible field com/mojang/blaze3d/opengl/GlCommandEncoder inRenderPass Z
|
|
||||||
mutable field com/mojang/blaze3d/opengl/GlCommandEncoder inRenderPass Z
|
|
||||||
|
|
||||||
accessible method net/minecraft/client/KeyMapping$Category register (Ljava/lang/String;)Lnet/minecraft/client/KeyMapping$Category;
|
|
||||||
@ -14,10 +14,10 @@ architectury { platformSetupLoomIde(); fabric() }
|
|||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
modImplementation("${Groups.Fabric}:fabric-loader:${rootProject.property("fabric_loader_version")}")
|
modImplementation("${Groups.Fabric}:fabric-loader:${rootProject.property("fabric_loader_version")}")
|
||||||
modApi("${Groups.FabricApi}:fabric-rendering-v1:${rootProject.property("fabric_rendering_api_version")}")
|
include(modApi("${Groups.FabricApi}:fabric-rendering-v1:${rootProject.property("fabric_rendering_api_version")}")!!)
|
||||||
modApi("${Groups.FabricApi}:fabric-api-base:${rootProject.property("fabric_api_base_version")}")
|
include(modApi("${Groups.FabricApi}:fabric-api-base:${rootProject.property("fabric_api_base_version")}")!!)
|
||||||
modApi("me.shedaniel.cloth:cloth-config-fabric:${rootProject.property("clothconfig_version")}") { exclude(group = Groups.FabricApi) }
|
modApi("me.shedaniel.cloth:cloth-config-fabric:${rootProject.property("clothconfig_version")}") { exclude(group = Groups.FabricApi) }
|
||||||
modImplementation("${Groups.FabricApi}:fabric-resource-loader-v0:${rootProject.property("fabric_resource_loader_version")}")
|
include(modImplementation("${Groups.FabricApi}:fabric-resource-loader-v0:${rootProject.property("fabric_resource_loader_version")}")!!)
|
||||||
modImplementation(group = "net.fabricmc", name = "fabric-language-kotlin", version = rootProject.property("fabric_language_kotlin") as String)
|
modImplementation(group = "net.fabricmc", name = "fabric-language-kotlin", version = rootProject.property("fabric_language_kotlin") as String)
|
||||||
modImplementation("com.terraformersmc:modmenu:${rootProject.property("modmenu_version")}") {
|
modImplementation("com.terraformersmc:modmenu:${rootProject.property("modmenu_version")}") {
|
||||||
exclude(group = Groups.FabricApi, module = "fabric-api-base")
|
exclude(group = Groups.FabricApi, module = "fabric-api-base")
|
||||||
|
|||||||
@ -25,11 +25,14 @@ abstract class KeyMappings {
|
|||||||
|
|
||||||
@Inject(method = "<init>*", at = @At("RETURN"))
|
@Inject(method = "<init>*", at = @At("RETURN"))
|
||||||
private void onSettingsConstructed(Minecraft minecraft, File file, CallbackInfo ci) {
|
private void onSettingsConstructed(Minecraft minecraft, File file, CallbackInfo ci) {
|
||||||
final var categoryList = KeysAccessor.getSortedCategoryList();
|
final var categoryMap = KeysAccessor.getSortedCategoryMap();
|
||||||
var newKeys = Lists.newArrayList(keyMappings);
|
var newKeys = Lists.newArrayList(keyMappings);
|
||||||
for (KeyMapping key : keysToAdd) {
|
for (KeyMapping key : keysToAdd) {
|
||||||
if (!categoryList.contains(key.getCategory()))
|
if (!categoryMap.containsKey(key.getCategory())) {
|
||||||
categoryList.add(key.getCategory());
|
Optional<Integer> biggest = categoryMap.values().stream().max(Integer::compareTo);
|
||||||
|
int biggestInt = biggest.orElse(0);
|
||||||
|
categoryMap.put(key.getCategory(), biggestInt + 1);
|
||||||
|
}
|
||||||
newKeys.remove(key);
|
newKeys.remove(key);
|
||||||
newKeys.add(key);
|
newKeys.add(key);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,10 +4,10 @@ import net.minecraft.client.KeyMapping;
|
|||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.gen.Accessor;
|
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.Map;
|
||||||
|
|
||||||
@Mixin(KeyMapping.Category.class)
|
@Mixin(KeyMapping.class)
|
||||||
public interface KeysAccessor {
|
public interface KeysAccessor {
|
||||||
@Accessor("SORT_ORDER")
|
@Accessor("CATEGORY_SORT_ORDER")
|
||||||
static List<KeyMapping.Category> getSortedCategoryList() { throw new AssertionError(); }
|
static Map<String, Integer> getSortedCategoryMap() { throw new AssertionError(); }
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,17 +4,16 @@ import fr.username404.snowygui.ClickGui;
|
|||||||
import fr.username404.snowygui.gui.feature.ButtonImpl;
|
import fr.username404.snowygui.gui.feature.ButtonImpl;
|
||||||
import net.minecraft.client.gui.screens.TitleScreen;
|
import net.minecraft.client.gui.screens.TitleScreen;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.Unique;
|
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
import org.spongepowered.asm.mixin.injection.Inject;
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
|
|
||||||
@Mixin(TitleScreen.class)
|
@Mixin(TitleScreen.class)
|
||||||
abstract class TitleScreenMixin {
|
abstract class TitleScreenMixin {
|
||||||
@Unique private static boolean buttonsInitialized = false;
|
private static boolean buttonsInitialized = false;
|
||||||
@Unique private static synchronized void setButtonsInitialized() { buttonsInitialized = true; }
|
private static synchronized void setButtonsInitialized() { buttonsInitialized = true; }
|
||||||
@Inject(method = "createNormalMenuOptions", at = @At(value = "RETURN"))
|
@Inject(method = "createNormalMenuOptions", at = @At(value = "RETURN"))
|
||||||
public void createNormalMenuOptions(int i, int j, CallbackInfoReturnable<Integer> cir) {
|
public void createNormalMenuOptions(int i, int j, CallbackInfo ci) {
|
||||||
if (!buttonsInitialized) {
|
if (!buttonsInitialized) {
|
||||||
ClickGui.INSTANCE.tick();
|
ClickGui.INSTANCE.tick();
|
||||||
ButtonImpl.initButtons();
|
ButtonImpl.initButtons();
|
||||||
|
|||||||
@ -11,8 +11,8 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
|||||||
|
|
||||||
@Mixin(GameRenderer.class)
|
@Mixin(GameRenderer.class)
|
||||||
abstract class ZoomMixin {
|
abstract class ZoomMixin {
|
||||||
@Inject(at = @At(value = "RETURN"), method = "getFov(Lnet/minecraft/client/Camera;FZ)F", cancellable = true)
|
@Inject(at = @At(value = "RETURN"), method = "getFov(Lnet/minecraft/client/Camera;FZ)D", cancellable = true)
|
||||||
private void getFov(Camera camera, float f, boolean bl, CallbackInfoReturnable<Float> cir) {
|
private void getFov(Camera camera, float f, boolean bl, CallbackInfoReturnable<Double> cir) {
|
||||||
if (Zoom.INSTANCE.getToggled() && !OkZoomerCompatKt.isOkZoomerPresent) {
|
if (Zoom.INSTANCE.getToggled() && !OkZoomerCompatKt.isOkZoomerPresent) {
|
||||||
cir.setReturnValue(Zoom.getNewZoom(cir.getReturnValue()));
|
cir.setReturnValue(Zoom.getNewZoom(cir.getReturnValue()));
|
||||||
}
|
}
|
||||||
|
|||||||
@ -7,7 +7,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.fabricmc.loader.launch.common.FabricLauncherBase
|
|
||||||
import net.minecraft.client.DeltaTracker
|
import net.minecraft.client.DeltaTracker
|
||||||
import net.minecraft.client.gui.GuiGraphics
|
import net.minecraft.client.gui.GuiGraphics
|
||||||
import kotlin.io.path.exists
|
import kotlin.io.path.exists
|
||||||
@ -22,25 +21,20 @@ 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, tickCounter: DeltaTracker) = fire(guiGraphics)
|
override fun onHudRender(guiGraphics: GuiGraphics?, tickCounter: DeltaTracker?) = fire(guiGraphics)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
override val annotatedButtons = lazy {
|
override val annotatedButtons = FabricLoader.getInstance().allMods.mapNotNull {
|
||||||
FabricLoader.getInstance().allMods.mapNotNull {
|
it.findPath(FeaturePackage.replace('.', '/')).getOrNull()
|
||||||
it.findPath(FEATURE_PACKAGE.replace('.', '/')).getOrNull()
|
}.filter { it.exists() && it.isDirectory() }.flatMap { buttonsDirectory ->
|
||||||
}.filter { it.exists() && it.isDirectory() }.flatMap { buttonsDirectory ->
|
mutableSetOf<Class<out ButtonImpl>>().apply {
|
||||||
buttonsDirectory.listDirectoryEntries("*.class").mapNotNull { file ->
|
buttonsDirectory.listDirectoryEntries("*.class").forEach { file ->
|
||||||
@Suppress("DEPRECATION")
|
@Suppress("DEPRECATION") net.fabricmc.loader.launch.common.
|
||||||
FabricLauncherBase.getClass(
|
FabricLauncherBase.getClass(file.pathString.drop(1).replace('/', '.').removeSuffix(".class")).let { foundClass ->
|
||||||
file.pathString.drop(1)
|
if (foundClass.isValidForButtonCollection()) add(foundClass.asSubclass(ButtonImpl::class.java))
|
||||||
.replace('/', '.').removeSuffix(".class")
|
|
||||||
).let { foundClass ->
|
|
||||||
if (foundClass.isValidForButtonCollection())
|
|
||||||
foundClass.asSubclass(ButtonImpl::class.java)
|
|
||||||
else null
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}.toSet()
|
}
|
||||||
}
|
}.toSet()
|
||||||
}
|
}
|
||||||
@ -1,22 +1,22 @@
|
|||||||
org.gradle.daemon=false
|
org.gradle.daemon=false
|
||||||
kotlin.code.style=official
|
kotlin.code.style=official
|
||||||
org.gradle.jvmargs=-Xmx2G -XX:+IgnoreUnrecognizedVMOptions -XX:+UnlockExperimentalVMOptions -XX:+AlwaysPreTouch
|
org.gradle.jvmargs=-Xmx2G -XX:+IgnoreUnrecognizedVMOptions -XX:+UnlockExperimentalVMOptions -XX:+UseShenandoahGC -XX:+AlwaysPreTouch
|
||||||
kotlin.incremental=true
|
kotlin.incremental=true
|
||||||
org.gradle.caching=true
|
org.gradle.caching=true
|
||||||
org.gradle.parallel=true
|
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.21.11
|
minecraft=1.21
|
||||||
forge_version=21.11.38-beta
|
forge_version=21.0.143
|
||||||
kotlinforforge=6.1.0
|
kotlinforforge=5.4.0
|
||||||
kotlinVer=2.3.0
|
kotlinVer=2.0.0
|
||||||
kotlin_coroutines_version=1.10.2
|
kotlin_coroutines_version=1.7.1
|
||||||
serializationVer=1.9.0
|
serializationVer=1.7.0
|
||||||
fabric_loader_version=0.18.4
|
fabric_loader_version=0.14.20
|
||||||
fabric_language_kotlin=1.13.8+kotlin.2.3.0
|
fabric_language_kotlin=1.11.0+kotlin.2.0.0
|
||||||
fabric_resource_loader_version=3.3.4+4fc5413f53
|
fabric_resource_loader_version=1.1.3+b559734490
|
||||||
fabric_rendering_api_version=16.2.5+1fb1cde953
|
fabric_rendering_api_version=5.0.3+d132107690
|
||||||
fabric_api_base_version=1.0.5+4ebb5c0853
|
fabric_api_base_version=0.4.42+6573ed8c90
|
||||||
clothconfig_version=21.11.151
|
clothconfig_version=15.0.127
|
||||||
modmenu_version=17.0.0-beta.2
|
modmenu_version=11.0.0
|
||||||
|
|||||||
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@ -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.14.4-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14-rc-1-bin.zip
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
|
|||||||
@ -1,6 +1,5 @@
|
|||||||
package fr.username404.snowygui.forge
|
package fr.username404.snowygui.forge
|
||||||
|
|
||||||
import fr.username404.snowygui.ClickGui
|
|
||||||
import fr.username404.snowygui.Snowy
|
import fr.username404.snowygui.Snowy
|
||||||
import fr.username404.snowygui.config.SnowyConfigScreen
|
import fr.username404.snowygui.config.SnowyConfigScreen
|
||||||
import fr.username404.snowygui.config.configScreenParent
|
import fr.username404.snowygui.config.configScreenParent
|
||||||
@ -12,29 +11,22 @@ import net.neoforged.fml.event.lifecycle.FMLClientSetupEvent
|
|||||||
import net.neoforged.neoforge.client.gui.IConfigScreenFactory
|
import net.neoforged.neoforge.client.gui.IConfigScreenFactory
|
||||||
import net.neoforged.neoforge.common.NeoForge
|
import net.neoforged.neoforge.common.NeoForge
|
||||||
import net.neoforged.neoforgespi.language.ModFileScanData
|
import net.neoforged.neoforgespi.language.ModFileScanData
|
||||||
|
import org.objectweb.asm.Type
|
||||||
|
|
||||||
@Mod("snowygui")
|
@Mod("snowygui")
|
||||||
@Suppress("UNUSED_PARAMETER")
|
@Suppress("UNUSED_PARAMETER")
|
||||||
class ForgeInit(container: ModContainer): Snowy() {
|
class ForgeInit(container: ModContainer): Snowy() {
|
||||||
private fun initSetup(event: FMLClientSetupEvent) {
|
private fun initSetup(event: FMLClientSetupEvent) = atInit()
|
||||||
atInit()
|
override val annotatedButtons = ModList.get() // Forge-specific reflection
|
||||||
ClickGui.tick()
|
.allScanData
|
||||||
ButtonImpl.initButtons()
|
.flatMap { obj: ModFileScanData -> obj.classes }
|
||||||
}
|
.filter { data: ModFileScanData.ClassData? ->
|
||||||
override val annotatedButtons = lazy { // Forge-specific reflection
|
(data!!.javaClass.getDeclaredField("clazz").apply { isAccessible = true }.get(data) as Type).className.let { classname ->
|
||||||
ModList.get()
|
classname.startsWith(FeaturePackage) && Class.forName(classname).isValidForButtonCollection()
|
||||||
.allScanData
|
|
||||||
.flatMap { obj: ModFileScanData -> obj.classes }
|
|
||||||
.filter { data: ModFileScanData.ClassData? ->
|
|
||||||
data!!.clazz.className.startsWith(FEATURE_PACKAGE)
|
|
||||||
}
|
}
|
||||||
.mapNotNull {
|
}
|
||||||
Class.forName((it!!.clazz.className), false, this::class.java.classLoader).run {
|
.map { Class.forName((it!!.javaClass.getDeclaredField("clazz").apply { isAccessible = true }.get(it) as Type).className).asSubclass(ButtonImpl::class.java)}
|
||||||
takeIf { isValidForButtonCollection() }
|
.toSet()
|
||||||
}?.asSubclass(ButtonImpl::class.java)
|
|
||||||
}
|
|
||||||
.toSet()
|
|
||||||
}
|
|
||||||
init {
|
init {
|
||||||
container.eventBus!!.run {
|
container.eventBus!!.run {
|
||||||
addListener(this@ForgeInit::initSetup)
|
addListener(this@ForgeInit::initSetup)
|
||||||
|
|||||||
@ -1,10 +1,18 @@
|
|||||||
package fr.username404.snowygui.forge
|
package fr.username404.snowygui.forge
|
||||||
|
|
||||||
|
import fr.username404.snowygui.ClickGui
|
||||||
|
import fr.username404.snowygui.gui.feature.ButtonImpl
|
||||||
import fr.username404.snowygui.misc.AddKeyMaps
|
import fr.username404.snowygui.misc.AddKeyMaps
|
||||||
import net.neoforged.bus.api.SubscribeEvent
|
import net.neoforged.bus.api.SubscribeEvent
|
||||||
import net.neoforged.neoforge.client.event.RegisterKeyMappingsEvent
|
import net.neoforged.neoforge.client.event.RegisterKeyMappingsEvent
|
||||||
|
import net.neoforged.neoforge.client.event.RegisterMenuScreensEvent
|
||||||
|
|
||||||
object MiscModBusHandlers {
|
object MiscModBusHandlers {
|
||||||
|
@SubscribeEvent
|
||||||
|
fun handleClickGuiInit(event: RegisterMenuScreensEvent) {
|
||||||
|
ClickGui.tick()
|
||||||
|
ButtonImpl.initButtons()
|
||||||
|
}
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
fun handleKeys(event: RegisterKeyMappingsEvent) {
|
fun handleKeys(event: RegisterKeyMappingsEvent) {
|
||||||
AddKeyMaps.list.forEach {
|
AddKeyMaps.list.forEach {
|
||||||
|
|||||||
@ -7,6 +7,6 @@ import net.neoforged.neoforge.client.event.ComputeFovModifierEvent
|
|||||||
object ZoomHandler {
|
object ZoomHandler {
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
fun onFOVEvent(event: ComputeFovModifierEvent) {
|
fun onFOVEvent(event: ComputeFovModifierEvent) {
|
||||||
if (Zoom.toggled) event.newFovModifier = Zoom.getNewZoom(event.newFovModifier)
|
if (Zoom.toggled) event.newFovModifier = Zoom.getNewZoom(event.newFovModifier.toDouble()).toFloat()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue
Block a user