Skip to content

Commit

Permalink
Optimisation
Browse files Browse the repository at this point in the history
  • Loading branch information
tanishisherewithhh committed Apr 17, 2024
1 parent a101dd5 commit beb3e02
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.tanishisherewith.dynamichud.config;

import dev.isxander.yacl3.api.*;
import dev.isxander.yacl3.api.controller.BooleanControllerBuilder;
import dev.isxander.yacl3.api.controller.FloatSliderControllerBuilder;
import dev.isxander.yacl3.config.v2.api.ConfigClassHandler;
import dev.isxander.yacl3.config.v2.api.SerialEntry;
Expand All @@ -25,6 +26,9 @@ public class GlobalConfig {
@SerialEntry
private float scale = 1.0f;

@SerialEntry
private boolean showColorPickerPreview = true;

public static GlobalConfig get() {
return INSTANCE;
}
Expand All @@ -44,6 +48,12 @@ public final Screen createYACLGUI() {
.binding(1.0f, () -> this.scale, newVal -> this.scale = newVal)
.controller(floatOption -> FloatSliderControllerBuilder.create(floatOption).range(0.1f, 2.5f).step(0.1f))
.build())
.option(Option.<Boolean>createBuilder()
.name(Text.literal("Show Color picker preview"))
.description(OptionDescription.of(Text.literal("Shows the preview below your mouse pointer on selecting color from the screen. Note: You may drop some frames with the preview on.")))
.binding(true, () -> this.showColorPickerPreview, newVal -> this.showColorPickerPreview = newVal)
.controller(booleanOption -> BooleanControllerBuilder.create(booleanOption).yesNoFormatter())
.build())
.build())
.build())
.build()
Expand All @@ -52,4 +62,8 @@ public final Screen createYACLGUI() {
public float getScale(){
return scale;
}

public boolean showColorPickerPreview() {
return showColorPickerPreview;
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.tanishisherewith.dynamichud.utils.contextmenu.options.coloroption;

import com.tanishisherewith.dynamichud.config.GlobalConfig;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gl.Framebuffer;
import net.minecraft.client.gui.DrawContext;
Expand Down Expand Up @@ -66,7 +67,7 @@ public void render(DrawContext drawContext, int x1, int y1) {
colorPickerButton.render(drawContext, x + 24 + boxSize, y + client.textRenderer.fontHeight + gradientSlider.getHeight() + 8);
alphaSlider.render(drawContext, x + 10 + boxSize, y + client.textRenderer.fontHeight + gradientSlider.getHeight() + 10);

if (colorPickerButton.isPicking()) {
if (colorPickerButton.isPicking() && GlobalConfig.get().showColorPickerPreview()) {
// Draw the preview box near cursor

//Translate cursor screen position to minecraft's scaled window
Expand Down

0 comments on commit beb3e02

Please sign in to comment.