Allowed Keyboard Inputs in GuiMouseInput
This commit is contained in:
@@ -59,6 +59,7 @@ public class ReplayMod {
|
||||
public static boolean firstMainMenu = true;
|
||||
public static RecordingHandler recordingHandler;
|
||||
public static ChatMessageHandler chatMessageHandler = new ChatMessageHandler();
|
||||
public static KeyInputHandler keyInputHandler = new KeyInputHandler();
|
||||
public static ReplaySender replaySender;
|
||||
public static int TP_DISTANCE_LIMIT = 128;
|
||||
public static FileCopyHandler fileCopyHandler;
|
||||
@@ -94,7 +95,7 @@ public class ReplayMod {
|
||||
FMLCommonHandler.instance().bus().register(new ConnectionEventHandler());
|
||||
MinecraftForge.EVENT_BUS.register(new GuiEventHandler());
|
||||
|
||||
FMLCommonHandler.instance().bus().register(new KeyInputHandler());
|
||||
FMLCommonHandler.instance().bus().register(keyInputHandler);
|
||||
MinecraftForge.EVENT_BUS.register(new MouseInputHandler());
|
||||
|
||||
recordingHandler = new RecordingHandler();
|
||||
|
||||
@@ -12,6 +12,7 @@ import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.settings.KeyBinding;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.gameevent.InputEvent.KeyInputEvent;
|
||||
import org.lwjgl.LWJGLException;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
|
||||
public class KeyInputHandler {
|
||||
@@ -21,10 +22,10 @@ public class KeyInputHandler {
|
||||
private boolean escDown = false;
|
||||
|
||||
@SubscribeEvent
|
||||
public void onKeyInput(KeyInputEvent event) {
|
||||
public void onKeyInput(KeyInputEvent event) throws LWJGLException {
|
||||
|
||||
if(!ReplayHandler.isInReplay()) return;
|
||||
if(mc.currentScreen != null) {
|
||||
if(mc.currentScreen != null && !(mc.currentScreen instanceof GuiMouseInput)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -34,6 +35,7 @@ public class KeyInputHandler {
|
||||
mc.displayGuiScreen(new GuiCancelRender());
|
||||
}
|
||||
|
||||
if(!Keyboard.isCreated()) Keyboard.create();
|
||||
escDown = Keyboard.isKeyDown(Keyboard.KEY_ESCAPE) && Keyboard.getEventKeyState();
|
||||
|
||||
boolean found = false;
|
||||
@@ -90,19 +92,7 @@ public class KeyInputHandler {
|
||||
break;
|
||||
}
|
||||
|
||||
//Custom registered handlers
|
||||
if(kb.getKeyDescription().equals(KeybindRegistry.KEY_THUMBNAIL) && kb.isPressed() && !found) {
|
||||
TickAndRenderListener.requestScreenshot();
|
||||
//TODO: Make this properly work
|
||||
}
|
||||
|
||||
if(kb.getKeyDescription().equals(KeybindRegistry.KEY_SPECTATE) && kb.isPressed() && !found) {
|
||||
SpectateHandler.openSpectateSelection();
|
||||
}
|
||||
|
||||
if(kb.getKeyDescription().equals(KeybindRegistry.KEY_LIGHTING) && kb.isPressed()) {
|
||||
ReplayMod.replaySettings.setLightingEnabled(!ReplayMod.replaySettings.isLightingEnabled());
|
||||
}
|
||||
handleCustomKeybindings(kb, found, null);
|
||||
|
||||
} catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -110,4 +100,28 @@ public class KeyInputHandler {
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
|
||||
public void handleCustomKeybindings(KeyBinding kb, boolean found, Integer keyCode) {
|
||||
//Custom registered handlers
|
||||
if(kb.getKeyDescription().equals(KeybindRegistry.KEY_THUMBNAIL) && (kb.isPressed() || kb.getKeyCode() == keyCode) && !found) {
|
||||
TickAndRenderListener.requestScreenshot();
|
||||
//TODO: Make this properly work
|
||||
}
|
||||
|
||||
if(kb.getKeyDescription().equals(KeybindRegistry.KEY_SPECTATE) && (kb.isPressed() || kb.getKeyCode() == keyCode) && !found) {
|
||||
SpectateHandler.openSpectateSelection();
|
||||
}
|
||||
|
||||
if(kb.getKeyDescription().equals(KeybindRegistry.KEY_LIGHTING) && (kb.isPressed() || kb.getKeyCode() == keyCode)) {
|
||||
ReplayMod.replaySettings.setLightingEnabled(!ReplayMod.replaySettings.isLightingEnabled());
|
||||
}
|
||||
|
||||
if(kb.getKeyDescription().equals(KeybindRegistry.KEY_CLEAR_KEYFRAMES) && (kb.isPressed() || kb.getKeyCode() == keyCode)) {
|
||||
ReplayHandler.resetKeyframes();
|
||||
}
|
||||
|
||||
if(kb.getKeyDescription().equals(KeybindRegistry.KEY_SYNC_TIMELINE) && (kb.isPressed() || kb.getKeyCode() == keyCode)) {
|
||||
ReplayHandler.syncTimeCursor(Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,19 @@
|
||||
package eu.crushedpixel.replaymod.gui;
|
||||
|
||||
import eu.crushedpixel.replaymod.ReplayMod;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.settings.KeyBinding;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class GuiMouseInput extends GuiScreen {
|
||||
|
||||
@Override
|
||||
protected void keyTyped(char typedChar, int keyCode) throws IOException {
|
||||
for(KeyBinding kb : Minecraft.getMinecraft().gameSettings.keyBindings)
|
||||
ReplayMod.keyInputHandler.handleCustomKeybindings(kb, false, keyCode);
|
||||
|
||||
super.keyTyped(typedChar, keyCode);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user