From 9e59edd83358179ed6eeff45155e7e70ba9731a9 Mon Sep 17 00:00:00 2001 From: Alexander Date: Tue, 10 Sep 2024 20:27:52 +0100 Subject: [PATCH] Always show the inventory context buttons ...unless dragging --- .../mixins/AlwaysShowContextButtons.java | 28 +++++++++++++++++++ .../resources/civchesttracker.mixins.json | 4 ++- 2 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 src/main/java/uk/protonull/civ/chesttracker/mixins/AlwaysShowContextButtons.java diff --git a/src/main/java/uk/protonull/civ/chesttracker/mixins/AlwaysShowContextButtons.java b/src/main/java/uk/protonull/civ/chesttracker/mixins/AlwaysShowContextButtons.java new file mode 100644 index 0000000..2ede0d8 --- /dev/null +++ b/src/main/java/uk/protonull/civ/chesttracker/mixins/AlwaysShowContextButtons.java @@ -0,0 +1,28 @@ +package uk.protonull.civ.chesttracker.mixins; + +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.ModifyVariable; +import red.jackf.chesttracker.impl.gui.invbutton.ui.InventoryButton; + +@Mixin(InventoryButton.class) +public abstract class AlwaysShowContextButtons { + @Shadow(remap = false) + private boolean isDragging; + + @ModifyVariable( + method = "showExtraButtons", + at = @At("HEAD"), + argsOnly = true, + remap = false + ) + protected boolean ctt$modify_variable$showExtraButtons$alwaysShow( + final boolean shouldShow + ) { + if (this.isDragging) { + return shouldShow; + } + return true; + } +} diff --git a/src/main/resources/civchesttracker.mixins.json b/src/main/resources/civchesttracker.mixins.json index 343f5fe..3c4d8f5 100644 --- a/src/main/resources/civchesttracker.mixins.json +++ b/src/main/resources/civchesttracker.mixins.json @@ -8,7 +8,9 @@ "illegal.AlwaysReturnNoBlockSourceMixin", "illegal.DoNotRegisterBlockBreakListenerMixin", "illegal.DoNotRegisterBlockPlaceListenerMixin", - "illegal.DoNotRegisterUseBlockListenerMixin" + "illegal.DoNotRegisterUseBlockListenerMixin", + + "AlwaysShowContextButtons" ], "injectors": { "defaultRequire": 1