Skip to content

Commit

Permalink
Changes
Browse files Browse the repository at this point in the history
  • Loading branch information
tanishisherewithhh committed Apr 13, 2024
1 parent 18665bb commit b932621
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 86 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import net.fabricmc.fabric.api.networking.v1.ServerPlayConnectionEvents;
import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.option.KeyBinding;
import net.minecraft.client.util.InputUtil;
import net.minecraft.resource.LifecycledResourceManager;
import net.minecraft.server.MinecraftServer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ public void onInitializeClient() {
ServerPlayConnectionEvents.DISCONNECT.register((handler, packetSender) -> GlobalConfig.HANDLER.save());
ClientLifecycleEvents.CLIENT_STOPPING.register((minecraftClient)->GlobalConfig.HANDLER.save());


HudRenderCallback.EVENT.register(new HudRender());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ public interface DynamicHudIntegration {
* The key binding for opening the editor screen.
*/
KeyBinding EDITOR_SCREEN_KEY_BINDING = KeyBindingHelper.registerKeyBinding(new KeyBinding(
TRANSLATION_KEY,
INPUT_TYPE,
KEY,
KEYBIND_CATEGORY
"DynamicHud Editor Screen",
InputUtil.Type.KEYSYM,
GLFW.GLFW_KEY_RIGHT_SHIFT,
"DynamicHud"
));

/**
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* <pre>
* {@code
* DynamicValueRegistry dvr = new DynamicValueRegistry("mod_id");
* dvr.registerGlobal("ABC",//YourSupplier);
* dvr.registerLocal("ABC",//YourSupplier);
* Supplier<?> result = dvr.get("ABC");
* }
* </pre>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public void render(DrawContext drawContext, int x, int y, int height) {
int yOffset = y1 + 3;
this.width = 10;
for (Option<?> option : options) {
if(!option.shouldRender())continue;
option.render(drawContext, x + 2, yOffset);
this.width = Math.max(this.width, option.width + padding);
yOffset += option.height + 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,21 @@ public abstract class Option<T> {
protected T defaultValue = null;
protected MinecraftClient mc = MinecraftClient.getInstance();
private Widget selectedWidget; // The widget that this context menu is associated with
public Supplier<Boolean> shouldRender = ()->true;

public Option(Supplier<T> getter, Consumer<T> setter) {
this.getter = getter;
this.setter = setter;
value = get();
defaultValue = get();
}
public Option(Supplier<T> getter, Consumer<T> setter,Supplier<Boolean> shouldRender) {
this.getter = getter;
this.setter = setter;
this.shouldRender = shouldRender;
value = get();
defaultValue = get();
}

protected T get() {
return getter.get();
Expand Down Expand Up @@ -63,4 +71,13 @@ public void keyReleased(int key) {
public boolean isMouseOver(double mouseX, double mouseY) {
return mouseX >= x && mouseX <= x + width && mouseY >= y && mouseY <= y + height;
}

public Option<T> setShouldRender(Supplier<Boolean> shouldRender) {
this.shouldRender = shouldRender;
return this;
}

public boolean shouldRender(){
return shouldRender.get();
}
}

0 comments on commit b932621

Please sign in to comment.