Skip to content

Commit

Permalink
Change logging levels
Browse files Browse the repository at this point in the history
  • Loading branch information
paulyhedral committed Nov 25, 2024
1 parent 644f445 commit 8eeec92
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 11 deletions.
1 change: 1 addition & 0 deletions CHANGELOG/1.18/current.md
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
- `[FIX]` Remove lingering widgets when deleting a recipe from the queue
- `[NEW]` Enabled key bindings to manage display of craft list and shopping list
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import com.sweetrpg.crafttracker.common.lib.Constants;
import com.sweetrpg.crafttracker.common.manager.CraftingQueueManager;
import com.sweetrpg.crafttracker.common.registry.ModKeyBindings;
import com.sweetrpg.crafttracker.common.util.KeyUtil;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.client.gui.screens.inventory.CreativeModeInventoryScreen;
Expand All @@ -19,8 +20,6 @@
import net.minecraftforge.client.event.ScreenEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;

import java.util.UUID;

public class ClientEventHandler {

// static boolean craftListDisplayed = true;
Expand Down Expand Up @@ -62,44 +61,54 @@ public static void onKeyInput(final InputEvent.KeyInputEvent event) {

handleAddToQueue();
}
else if(ModKeyBindings.TOGGLE_CRAFT_LIST_MAPPING.matches(event.getKey(), event.getScanCode())) {
else if(KeyUtil.isKeyDown(event.getKey()) &&
ModKeyBindings.TOGGLE_CRAFT_LIST_MAPPING.matches(event.getKey(), event.getScanCode())) {
CraftTracker.LOGGER.debug("#onKeyInput: TOGGLE_CRAFT_LIST_MAPPING");

handleToggleCraftList();
}
else if(ModKeyBindings.TOGGLE_SHOPPING_LIST_MAPPING.matches(event.getKey(), event.getScanCode())) {
else if(KeyUtil.isKeyDown(event.getKey()) &&
ModKeyBindings.TOGGLE_SHOPPING_LIST_MAPPING.matches(event.getKey(), event.getScanCode())) {
CraftTracker.LOGGER.debug("#onKeyInput: TOGGLE_SHOPPING_LIST_MAPPING");

handleToggleShoppingList();
}
else if(ModKeyBindings.OPEN_QUEUE_MANAGER_MAPPING.matches(event.getKey(), event.getScanCode())) {
else if(KeyUtil.isKeyDown(event.getKey()) &&
ModKeyBindings.OPEN_QUEUE_MANAGER_MAPPING.matches(event.getKey(), event.getScanCode())) {
CraftTracker.LOGGER.debug("#onKeyInput: OPEN_QUEUE_MANAGER_MAPPING");

QueueManagementScreen.open();
}
else if(KeyUtil.isKeyDown(event.getKey()) &&
ModKeyBindings.POPULATE_SHOPPING_LIST_MAPPING.matches(event.getKey(), event.getScanCode())) {
CraftTracker.LOGGER.debug("#onKeyInput: POPULATE_SHOPPING_LIST_MAPPING");

// TODO
}
}

private static void handleToggleCraftList() {
CraftTracker.LOGGER.debug("#handleToggleCraftList");

var player = Minecraft.getInstance().player;
TranslatableComponent msg;
switch(CTRuntime.INSTANCE.queueOverlayRequestedState) {
case SHOW:
CTRuntime.INSTANCE.queueOverlayRequestedState = CTRuntime.OverlayState.HIDE;
msg = new TranslatableComponent(Constants.TRANSLATION_KEY_GUI_MSG_QUEUE_OVERLAY_MODE_HIDE);
Minecraft.getInstance().player.sendMessage(msg, UUID.randomUUID());
player.displayClientMessage(msg, true);
break;

case HIDE:
CTRuntime.INSTANCE.queueOverlayRequestedState = CTRuntime.OverlayState.DYNAMIC;
msg = new TranslatableComponent(Constants.TRANSLATION_KEY_GUI_MSG_QUEUE_OVERLAY_MODE_DYNAMIC);
Minecraft.getInstance().player.sendMessage(msg, UUID.randomUUID());
player.displayClientMessage(msg, true);
break;

case DYNAMIC:
CTRuntime.INSTANCE.queueOverlayRequestedState = CTRuntime.OverlayState.SHOW;
msg = new TranslatableComponent(Constants.TRANSLATION_KEY_GUI_MSG_QUEUE_OVERLAY_MODE_SHOW);
Minecraft.getInstance().player.sendMessage(msg, UUID.randomUUID());
player.displayClientMessage(msg, true);
break;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ public class CraftQueueOverlay {
var text = String.format("%s [%s]",
item.getDescription().getString(MAX_STRING_LENGTH - countText.length() - 3),
countText);
CraftTracker.LOGGER.debug("text: {}", text);
CraftTracker.LOGGER.trace("text: {}", text);
GuiComponent.drawString(poseStack, gui.getFont(), text, x + ITEM_NAME_X_OFFSET, lambdaYpos + 4, TEXT_COLOR);
}
else {
Expand Down Expand Up @@ -215,7 +215,7 @@ public class CraftQueueOverlay {
var text = String.format("%s [%s]",
item.getDescription().getString(MAX_STRING_LENGTH - countText.length() - 3),
countText);
CraftTracker.LOGGER.debug("text: {}", text);
CraftTracker.LOGGER.trace("text: {}", text);
GuiComponent.drawString(poseStack, gui.getFont(), text, x + ITEM_NAME_X_OFFSET, lambdaYpos + 4, TEXT_COLOR);
}
else {
Expand Down Expand Up @@ -273,7 +273,7 @@ public class CraftQueueOverlay {
var text = String.format("%s [%s]",
item.getDescription().getString(MAX_STRING_LENGTH - countText.length() - 3),
countText);
CraftTracker.LOGGER.debug("text: {}", text);
CraftTracker.LOGGER.trace("text: {}", text);
GuiComponent.drawString(poseStack, gui.getFont(), text, x + ITEM_NAME_X_OFFSET, lambdaYpos + 4, TEXT_COLOR);
}
else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public class Constants {
public static final String TRANSLATION_KEY_BINDINGS_TOGGLE_CRAFTLIST_TITLE = "key.toggleCraftList";
public static final String TRANSLATION_KEY_BINDINGS_TOGGLE_SHOPPINGLIST_TITLE = "key.toggleShoppingList";
public static final String TRANSLATION_KEY_BINDINGS_OPEN_QMGR_TITLE = "key.openQueueManager";
public static final String TRANSLATION_KEY_BINDINGS_POPULATE_SHOPPING_LIST_TITLE = "key.populateShoppingList";
public static final String TRANSLATION_KEY_GUI_MSG_QUEUE_OVERLAY_MODE_HIDE = "crafttracker.msg.queue_overlay_mode.hide";
public static final String TRANSLATION_KEY_GUI_MSG_QUEUE_OVERLAY_MODE_SHOW = "crafttracker.msg.queue_overlay_mode.show";
public static final String TRANSLATION_KEY_GUI_MSG_QUEUE_OVERLAY_MODE_DYNAMIC = "crafttracker.msg.queue_overlay_mode.dynamic";
Expand Down
14 changes: 14 additions & 0 deletions src/main/java/com/sweetrpg/crafttracker/common/util/KeyUtil.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.sweetrpg.crafttracker.common.util;

import com.mojang.blaze3d.platform.InputConstants;
import net.minecraft.client.Minecraft;

public class KeyUtil {

public static boolean isKeyDown(int key) {
return InputConstants.isKeyDown(Minecraft.getInstance()
.getWindow()
.getWindow(), key);
}

}

0 comments on commit 8eeec92

Please sign in to comment.