@@ -0,0 +1,28 @@
|
||||
|
||||
package appeng.client;
|
||||
|
||||
|
||||
import org.lwjgl.input.Keyboard;
|
||||
|
||||
|
||||
public enum ActionKey
|
||||
{
|
||||
TOGGLE_FOCUS( Keyboard.KEY_TAB );
|
||||
|
||||
private final int defaultKey;
|
||||
|
||||
private ActionKey( int defaultKey )
|
||||
{
|
||||
this.defaultKey = defaultKey;
|
||||
}
|
||||
|
||||
public String getTranslationKey()
|
||||
{
|
||||
return "key." + this.name().toLowerCase() + ".desc";
|
||||
}
|
||||
|
||||
public int getDefaultKey()
|
||||
{
|
||||
return this.defaultKey;
|
||||
}
|
||||
}
|
||||
@@ -21,11 +21,13 @@ package appeng.client;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.EnumMap;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.settings.KeyBinding;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
@@ -40,6 +42,7 @@ import net.minecraftforge.client.model.ModelLoaderRegistry;
|
||||
import net.minecraftforge.common.ForgeModContainer;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.fml.client.FMLClientHandler;
|
||||
import net.minecraftforge.fml.client.registry.ClientRegistry;
|
||||
import net.minecraftforge.fml.client.registry.RenderingRegistry;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
|
||||
@@ -74,6 +77,9 @@ import appeng.util.Platform;
|
||||
|
||||
public class ClientHelper extends ServerHelper
|
||||
{
|
||||
private final static String KEY_CATEGORY = "key.appliedenergistics2.category";
|
||||
|
||||
private final EnumMap<ActionKey, KeyBinding> bindings = new EnumMap<>( ActionKey.class );
|
||||
|
||||
@Override
|
||||
public void preinit()
|
||||
@@ -92,6 +98,12 @@ public class ClientHelper extends ServerHelper
|
||||
@Override
|
||||
public void init()
|
||||
{
|
||||
for( ActionKey key : ActionKey.values() )
|
||||
{
|
||||
final KeyBinding binding = new KeyBinding( key.getTranslationKey(), key.getDefaultKey(), KEY_CATEGORY );
|
||||
ClientRegistry.registerKeyBinding( binding );
|
||||
this.bindings.put( key, binding );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -332,4 +344,16 @@ public class ClientHelper extends ServerHelper
|
||||
ParticleTextures.registerSprite( event );
|
||||
InscriberTESR.registerTexture( event );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isKeyPressed( ActionKey key )
|
||||
{
|
||||
return this.bindings.get( key ).isPressed();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isActionKey( ActionKey key, int pressedKeyCode )
|
||||
{
|
||||
return this.bindings.get( key ).isActiveAndMatches( pressedKeyCode );
|
||||
}
|
||||
}
|
||||
@@ -40,6 +40,7 @@ import appeng.api.storage.ITerminalHost;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.util.IConfigManager;
|
||||
import appeng.api.util.IConfigurableObject;
|
||||
import appeng.client.ActionKey;
|
||||
import appeng.client.gui.AEBaseMEGui;
|
||||
import appeng.client.gui.widgets.GuiImgButton;
|
||||
import appeng.client.gui.widgets.GuiScrollbar;
|
||||
@@ -54,6 +55,7 @@ import appeng.container.slot.SlotCraftingMatrix;
|
||||
import appeng.container.slot.SlotFakeCraftingMatrix;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.AELog;
|
||||
import appeng.core.AppEng;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
@@ -481,7 +483,7 @@ public class GuiMEMonitorable extends AEBaseMEGui implements ISortSource, IConfi
|
||||
|
||||
if( !this.checkHotbarKeys( key ) )
|
||||
{
|
||||
if( key == Keyboard.KEY_TAB )
|
||||
if( AppEng.proxy.isActionKey( ActionKey.TOGGLE_FOCUS, key ) )
|
||||
{
|
||||
this.searchField.setFocused( !this.searchField.isFocused() );
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user