Ver código fonte

close stuff and add focus keybind

Close #102
Close #100
Close #29
Unknown 6 anos atrás
pai
commit
3302678d9a

+ 2 - 0
src/main/java/me/shedaniel/rei/api/ClientHelper.java

@@ -78,6 +78,8 @@ public interface ClientHelper {
      */
     boolean executeUsageKeyBind(ItemStack stack);
     
+    FabricKeyBinding getFocusSearchFieldKeyBinding();
+    
     /**
      * Gets the mod from an item
      *

+ 8 - 1
src/main/java/me/shedaniel/rei/client/ClientHelperImpl.java

@@ -52,8 +52,9 @@ public class ClientHelperImpl implements ClientHelper, ClientModInitializer {
     private final Identifier hideKeybind = new Identifier("roughlyenoughitems", "hide_keybind");
     private final Identifier previousPageKeybind = new Identifier("roughlyenoughitems", "previous_page");
     private final Identifier nextPageKeybind = new Identifier("roughlyenoughitems", "next_page");
+    private final Identifier focusSearchFieldKeybind = new Identifier("roughlyenoughitems", "focus_search");
     private final Map<String, String> modNameCache = Maps.newHashMap();
-    public FabricKeyBinding recipe, usage, hide, previousPage, nextPage;
+    public FabricKeyBinding recipe, usage, hide, previousPage, nextPage,focusSearchField;
     
     public String getFormattedModNoItalicFromItem(Item item) {
         String mod = getModFromItem(item);
@@ -103,6 +104,11 @@ public class ClientHelperImpl implements ClientHelper, ClientModInitializer {
         return nextPage;
     }
     
+    @Override
+    public FabricKeyBinding getFocusSearchFieldKeyBinding() {
+        return focusSearchField;
+    }
+    
     @Override
     public String getModFromItem(Item item) {
         if (item.equals(Items.AIR))
@@ -260,6 +266,7 @@ public class ClientHelperImpl implements ClientHelper, ClientModInitializer {
         KeyBindingRegistryImpl.INSTANCE.register(hide = FabricKeyBinding.Builder.create(hideKeybind, InputUtil.Type.KEYSYM, 79, category).build());
         KeyBindingRegistryImpl.INSTANCE.register(previousPage = FabricKeyBinding.Builder.create(previousPageKeybind, InputUtil.Type.KEYSYM, -1, category).build());
         KeyBindingRegistryImpl.INSTANCE.register(nextPage = FabricKeyBinding.Builder.create(nextPageKeybind, InputUtil.Type.KEYSYM, -1, category).build());
+        KeyBindingRegistryImpl.INSTANCE.register(focusSearchField = FabricKeyBinding.Builder.create(focusSearchFieldKeybind, InputUtil.Type.KEYSYM, -1, category).build());
     }
     
 }

+ 5 - 0
src/main/java/me/shedaniel/rei/gui/ContainerScreenOverlay.java

@@ -500,6 +500,11 @@ public class ContainerScreenOverlay extends AbstractParentElement implements Dra
             else if (ClientHelper.getInstance().getUsageKeyBinding().matchesKey(int_1, int_2))
                 return ClientHelper.getInstance().executeUsageKeyBind(itemStack);
         }
+        if (ClientHelper.getInstance().getFocusSearchFieldKeyBinding().matchesKey(int_1, int_2)) {
+            ScreenHelper.searchField.setFocused(true);
+            setFocused(ScreenHelper.searchField);
+            return true;
+        }
         return false;
     }
     

+ 1 - 0
src/main/resources/assets/roughlyenoughitems/lang/en_us.json

@@ -5,6 +5,7 @@
   "key.roughlyenoughitems.usage_keybind": "Show Uses",
   "key.roughlyenoughitems.next_page": "Next Page",
   "key.roughlyenoughitems.previous_page": "Previous Page",
+  "key.roughlyenoughitems.focus_search": "Focus Search Field",
   "text.rei.config.general": "General",
   "text.rei.config.action": "Action",
   "text.rei.config.cheating": "Cheating:",