Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add config to show/hide dropoff button in inventory #11

Merged
merged 2 commits into from
Dec 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public static void save(JsonObject json) {
general.addProperty("enableDropoff", DropOffHandler.enableDroppOff);
general.addProperty("dropoffRender",DropOffHandler.dropoffRender);
general.addProperty("dropoffChatMessage",DropOffHandler.dropoffChatMessage);
general.addProperty("dropoffButtonShow", DropOffButtonHandler.showButton);
general.addProperty("dropoffButtonX", DropOffButtonHandler.buttonX);
general.addProperty("dropoffButtonY",DropOffButtonHandler.buttonY);
general.addProperty("enableHotbarSwap", HotbarSwap.isEnabled());
Expand Down Expand Up @@ -85,6 +86,7 @@ public static void load(JsonObject json) {
DropOffHandler.enableDroppOff = JsonHelper.getBoolean(general, true, "enableDropoff");
DropOffHandler.dropoffRender = JsonHelper.getBoolean(general, true, "dropoffRender");
DropOffHandler.dropoffChatMessage = JsonHelper.getBoolean(general, true, "dropoffChatMessage");
DropOffButtonHandler.showButton = JsonHelper.getBoolean(general, true, "dropoffButtonShow");
DropOffButtonHandler.buttonX = JsonHelper.getInt(general, 80, "dropoffButtonX");
DropOffButtonHandler.buttonY = JsonHelper.getInt(general, 12, "dropoffButtonY");
HotbarSwap.setEnabled(JsonHelper.getBoolean(general, true, "enableHotbarSwap"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import com.cleanroommc.bogosorter.api.SortRule;
import com.cleanroommc.bogosorter.common.HotbarSwap;
import com.cleanroommc.bogosorter.common.SortConfigChangeEvent;
import com.cleanroommc.bogosorter.common.dropoff.DropOffButtonHandler;
import com.cleanroommc.bogosorter.common.dropoff.DropOffHandler;
import com.cleanroommc.bogosorter.common.sort.NbtSortRule;
import com.cleanroommc.modularui.api.drawable.IDrawable;
Expand Down Expand Up @@ -189,6 +190,20 @@ public IWidget createGeneralConfigUI(GuiContext context) {
.height(14)
.marginLeft(10)
.expanded()))
.child(new Row()
.widthRel(1f).height(14)
.margin(0, 2)
.child(new CycleButtonWidget()
.value(new BoolValue.Dynamic(() -> DropOffButtonHandler.showButton, val -> DropOffButtonHandler.showButton = val))
.stateOverlay(TOGGLE_BUTTON)
.disableHoverBackground()
.size(14, 14)
.margin(8, 0)
.background(IDrawable.EMPTY))
.child(IKey.lang("bogosort.gui.dropoffbutton_enable").asWidget()
.height(14)
.marginLeft(10)
.expanded()))
.child(new Row()
.widthRel(1f).height(14)
.margin(0, 2)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,13 @@ public class DropOffButtonHandler {

public static int buttonX = 120;
public static int buttonY = 12;
public static boolean showButton = true;

@SubscribeEvent
@SideOnly(Side.CLIENT)
public void onGuiInit(GuiScreenEvent.InitGuiEvent.Post event) {
GuiScreen screen = event.gui;
if (screen instanceof GuiContainerCreative) {
if (!showButton || screen instanceof GuiContainerCreative) {
return;
}
try {
Expand All @@ -38,6 +39,8 @@ public void onGuiInit(GuiScreenEvent.InitGuiEvent.Post event) {
public void onDrawScreen(GuiScreenEvent.DrawScreenEvent.Post event) {
GuiScreen screen = event.gui;


if (!showButton) return;
if (screen instanceof GuiInventory) {
for (GuiButton guiButton : ((IGuiContainerAccessor) event.gui).getButtons()) {
if (guiButton instanceof InvButton invButton) {
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/assets/bogosorter/lang/en_US.lang
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ bogosort.gui.hotbar_scrolling=Enable hotbar column scrolling
bogosort.gui.hotbar_scrolling.tooltip=Scroll though inventory column by holding ALT
bogosort.gui.enabled=Enabled
bogosort.gui.dropoff_enable=Enable Dropoff
bogosort.gui.dropoffbutton_enable=Show Dropoff Button in Inventory
bogosort.gui.dropoff_render=Show Dropoff Targets
bogosort.gui.dropoff_chatmessage=Show Dropoff Chat Message

Expand Down
Loading