Added new Keybinding. Config GUI is 95% finished. Only the info part is left.
This commit is contained in:
@@ -10,10 +10,13 @@ import cpw.mods.fml.common.event.FMLInitializationEvent;
|
||||
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
|
||||
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import cpw.mods.fml.common.gameevent.InputEvent;
|
||||
import cpw.mods.fml.common.gameevent.TickEvent;
|
||||
import cpw.mods.fml.common.network.NetworkRegistry;
|
||||
import de.skate702.craftingkeys.config.Config;
|
||||
import de.skate702.craftingkeys.config.GuiConfig;
|
||||
import de.skate702.craftingkeys.config.GuiConfigHandler;
|
||||
import de.skate702.craftingkeys.config.KeyBindings;
|
||||
import de.skate702.craftingkeys.manager.*;
|
||||
import de.skate702.craftingkeys.proxies.CraftingKeysProxy;
|
||||
import de.skate702.craftingkeys.util.Logger;
|
||||
@@ -29,8 +32,7 @@ import net.minecraftforge.common.MinecraftForge;
|
||||
*
|
||||
* @author skate702
|
||||
*/
|
||||
@Mod(modid = CraftingKeys.MODID, name = CraftingKeys.NAME, version = CraftingKeys.VERSION,
|
||||
guiFactory = "de.skate702.craftingkeys.config.ConfigGuiFactory")
|
||||
@Mod(modid = CraftingKeys.MODID, name = CraftingKeys.NAME, version = CraftingKeys.VERSION)
|
||||
public class CraftingKeys {
|
||||
|
||||
public static final String MODID = "craftingkeys";
|
||||
@@ -74,6 +76,7 @@ public class CraftingKeys {
|
||||
FMLCommonHandler.instance().bus().register(this);
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
NetworkRegistry.INSTANCE.registerGuiHandler(instance, new GuiConfigHandler());
|
||||
KeyBindings.init();
|
||||
Logger.info("load(e)", "Registered Mod.");
|
||||
|
||||
}
|
||||
@@ -87,6 +90,18 @@ public class CraftingKeys {
|
||||
public void postInit(FMLPostInitializationEvent event) {
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onKeyInput(InputEvent.KeyInputEvent event) {
|
||||
if (KeyBindings.openGuiBinding.isPressed()) {
|
||||
Logger.info("onKeyInput(e)", "Open Crafting Keys Config Gui.");
|
||||
Util.client.thePlayer.openGui(instance, GuiConfig.GuiID, Util.client.theWorld,
|
||||
((int) Util.client.thePlayer.posX), (int) Util.client.thePlayer.posY,
|
||||
(int) Util.client.thePlayer.posZ);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will be executed when the Config is changed. Update!
|
||||
*
|
||||
@@ -108,7 +123,7 @@ public class CraftingKeys {
|
||||
@SubscribeEvent
|
||||
public void onGuiOpened(GuiOpenEvent event) {
|
||||
if (event.gui instanceof GuiMainMenu) {
|
||||
//event.gui = new GuiConfig(); // Delete this!
|
||||
//event.gui = new GuiConfig(); // (Only for testing)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -120,10 +135,6 @@ public class CraftingKeys {
|
||||
@SubscribeEvent
|
||||
public void onTick(TickEvent.ClientTickEvent tick) {
|
||||
|
||||
if (Util.client.currentScreen == null) {
|
||||
Util.client.thePlayer.openGui(instance, 702, Util.client.theWorld, 0, 0, 0);
|
||||
}
|
||||
|
||||
// Get current Screen, then test
|
||||
GuiScreen currentScreen = Util.client.currentScreen;
|
||||
|
||||
|
||||
@@ -146,40 +146,27 @@ public class Config {
|
||||
private static void syncProperties() {
|
||||
// Standard Keys
|
||||
|
||||
keyTopLeft = configFile.get(categoryKeys, "1.0-keyTopLeft", Keyboard.KEY_Q, "Top Left crafting key (key value)");
|
||||
keyTopLeft.setLanguageKey("key.topleft");
|
||||
keyTopCenter = configFile.get(categoryKeys, "1.1-2keyTopCenter", Keyboard.KEY_W, "Top Center crafting key (key value)");
|
||||
keyTopCenter.setLanguageKey("key.topcenter");
|
||||
keyTopRight = configFile.get(categoryKeys, "1.2-keyTopRight", Keyboard.KEY_E, "Top Right crafting key (key value)");
|
||||
keyTopRight.setLanguageKey("key.topright");
|
||||
keyTopLeft = configFile.get(categoryKeys, "keyTopLeft", Keyboard.KEY_Q);
|
||||
keyTopCenter = configFile.get(categoryKeys, "keyTopCenter", Keyboard.KEY_W);
|
||||
keyTopRight = configFile.get(categoryKeys, "keyTopRight", Keyboard.KEY_E);
|
||||
|
||||
keyCenterLeft = configFile.get(categoryKeys, "2.0-keyCenterLeft", Keyboard.KEY_A, "Center Left crafting key (key value)");
|
||||
keyCenterLeft.setLanguageKey("key.centerleft");
|
||||
keyCenterCenter = configFile.get(categoryKeys, "2.1-keyCenterCenter", Keyboard.KEY_S, "Center Center crafting key (key value)");
|
||||
keyCenterCenter.setLanguageKey("key.centercenter");
|
||||
keyCenterRight = configFile.get(categoryKeys, "2.2-keyCenterRight", Keyboard.KEY_D, "Center Right crafting key (key value)");
|
||||
keyCenterRight.setLanguageKey("key.centerright");
|
||||
keyCenterLeft = configFile.get(categoryKeys, "keyCenterLeft", Keyboard.KEY_A);
|
||||
keyCenterCenter = configFile.get(categoryKeys, "keyCenterCenter", Keyboard.KEY_S);
|
||||
keyCenterRight = configFile.get(categoryKeys, "keyCenterRight", Keyboard.KEY_D);
|
||||
|
||||
keyLowerLeft = configFile.get(categoryKeys, "3.0-keyLowerLeft", Keyboard.KEY_Y, "Lower Left crafting key (key value)"); // German Keyboard Layout
|
||||
keyLowerLeft.setLanguageKey("key.lowerleft");
|
||||
keyLowerCenter = configFile.get(categoryKeys, "3.1-keyLowerCenter", Keyboard.KEY_X, "Lower Center crafting key (key value)");
|
||||
keyLowerCenter.setLanguageKey("key.lowercenter");
|
||||
keyLowerRight = configFile.get(categoryKeys, "3.2-keyLowerRight", Keyboard.KEY_C, "Lower Right crafting key (key value)");
|
||||
keyLowerRight.setLanguageKey("key.lowerright");
|
||||
keyLowerLeft = configFile.get(categoryKeys, "keyLowerLeft", Keyboard.KEY_Y); // German Keyboard Layout
|
||||
keyLowerCenter = configFile.get(categoryKeys, "keyLowerCenter", Keyboard.KEY_X);
|
||||
keyLowerRight = configFile.get(categoryKeys, "keyLowerRight", Keyboard.KEY_C);
|
||||
|
||||
// Special Keys
|
||||
|
||||
keyStack = configFile.get(categoryKeys, "4.0-keyStack", Keyboard.KEY_LSHIFT, "Key to move stacks instead of single items (key value)");
|
||||
keyStack.setLanguageKey("key.stack");
|
||||
keyInteract = configFile.get(categoryKeys, "4.1-keyInteract", Keyboard.KEY_LCONTROL, "Key to interact with e.g. crafting output (key value)");
|
||||
keyInteract.setLanguageKey("key.interact");
|
||||
keyDrop = configFile.get(categoryKeys, "4.2-keyDrop", Keyboard.KEY_SPACE, "Key to drop all items from crafting (key value)");
|
||||
keyDrop.setLanguageKey("key.drop");
|
||||
keyStack = configFile.get(categoryKeys, "keyStack", Keyboard.KEY_LSHIFT);
|
||||
keyInteract = configFile.get(categoryKeys, "keyInteract", Keyboard.KEY_LCONTROL);
|
||||
keyDrop = configFile.get(categoryKeys, "keyDrop", Keyboard.KEY_SPACE);
|
||||
|
||||
// Other Settings
|
||||
|
||||
enableNumPad = configFile.get(categoryOther, "numPadEnabled", true, "Activates the NumPad for crafting");
|
||||
enableNumPad.setLanguageKey("options.numpadEnabled");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ package de.skate702.craftingkeys.config;
|
||||
|
||||
import de.skate702.craftingkeys.util.LanguageLocalizer;
|
||||
import de.skate702.craftingkeys.util.Logger;
|
||||
import de.skate702.craftingkeys.util.Util;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
@@ -131,13 +130,11 @@ public class GuiConfig extends GuiScreen {
|
||||
public void actionPerformed(GuiButton button) {
|
||||
if (button.id == buttonAbortID) {
|
||||
Logger.info("actionPerformed(b)", "Closing Crafting Keys GUI now!");
|
||||
Util.client.thePlayer.closeScreen();
|
||||
mc.thePlayer.closeScreen();
|
||||
Util.client.displayGuiScreen(null);
|
||||
} else if (button.id == buttonSaveID) {
|
||||
save();
|
||||
Logger.info("actionPerformed(b)", "Saving & closing Crafting Keys GUI now!");
|
||||
Util.client.thePlayer.closeScreen();
|
||||
mc.thePlayer.closeScreen();
|
||||
} else if (button.id >= 0 && button.id <= 11) {
|
||||
if (selectedButtonID == -1) {
|
||||
selectedButtonID = button.id;
|
||||
@@ -166,8 +163,14 @@ public class GuiConfig extends GuiScreen {
|
||||
public void keyTyped(char character, int keyCode) {
|
||||
|
||||
if (keyCode == Keyboard.KEY_ESCAPE) {
|
||||
selectedButtonID = -1;
|
||||
drawKeyValues();
|
||||
if (selectedButtonID != -1) {
|
||||
selectedButtonID = -1;
|
||||
drawKeyValues();
|
||||
} else {
|
||||
Logger.info("keyTyped(c,i)", "Trying to close inventory with esc.");
|
||||
super.keyTyped(character, keyCode); // Enable standard gui closing
|
||||
}
|
||||
|
||||
} else if (selectedButtonID != -1) {
|
||||
if (!ArrayUtils.contains(keyValues, keyCode)) { // No double keys
|
||||
keyValues[selectedButtonID] = keyCode;
|
||||
@@ -178,10 +181,7 @@ public class GuiConfig extends GuiScreen {
|
||||
|
||||
}
|
||||
|
||||
// TODO: Lang files
|
||||
// TODO: Config files
|
||||
// TODO: Crafting symbols
|
||||
// TODO: KeyBindings
|
||||
// TODO: Crafting symbols & labels
|
||||
|
||||
private void drawCraftingTable() {
|
||||
GL11.glColor4f(1F, 1F, 1F, 1F);
|
||||
|
||||
@@ -1,49 +1,24 @@
|
||||
package de.skate702.craftingkeys.config;
|
||||
|
||||
import cpw.mods.fml.client.registry.ClientRegistry;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.settings.KeyBinding;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
|
||||
/**
|
||||
* Provides all Key Bindings and methods to register and check them.
|
||||
*/
|
||||
@Deprecated
|
||||
public class KeyBindings {
|
||||
|
||||
// WARNING: This does NOT work! Have to use own Option Dialog OR Settings file. Bindings are exclusive. Shit!
|
||||
private static final String category = "craftingkeys.binding.cat";
|
||||
|
||||
|
||||
private static final String category = "key.categories.craftingkeys";
|
||||
|
||||
private static KeyBinding[] bindings = { // Inspired by CSS Position Properties
|
||||
new KeyBinding("key.topleft", Keyboard.KEY_Q, category),
|
||||
new KeyBinding("key.topcenter", Keyboard.KEY_W, category),
|
||||
new KeyBinding("key.topright", Keyboard.KEY_E, category),
|
||||
|
||||
new KeyBinding("key.centerleft", Keyboard.KEY_A, category),
|
||||
new KeyBinding("key.centercenter", Keyboard.KEY_S, category),
|
||||
new KeyBinding("key.centerright", Keyboard.KEY_D, category),
|
||||
|
||||
new KeyBinding("key.lowerleft", Keyboard.KEY_Y, category), // GERMAN Keyboard layout
|
||||
new KeyBinding("key.lowercenter", Keyboard.KEY_X, category),
|
||||
new KeyBinding("key.lowerright", Keyboard.KEY_C, category),
|
||||
|
||||
new KeyBinding("key.stack", Keyboard.KEY_LSHIFT, category),
|
||||
new KeyBinding("key.interact", Keyboard.KEY_LCONTROL, category),
|
||||
};
|
||||
public static KeyBinding openGuiBinding = new KeyBinding("craftingkeys.binding.opengui",
|
||||
Keyboard.KEY_K, category);
|
||||
|
||||
/**
|
||||
* Initializes all key bindings and registers them to the client-side. Bindings are exclusive.
|
||||
* Do NOT use until there is a solution for this!
|
||||
* Initializes all key bindings and registers them to the client-side.
|
||||
*/
|
||||
@Deprecated
|
||||
public static void init() {
|
||||
for (KeyBinding binding : bindings) {
|
||||
ClientRegistry.registerKeyBinding(binding);
|
||||
}
|
||||
ClientRegistry.registerKeyBinding(Minecraft.getMinecraft().gameSettings.keyBindRight);
|
||||
//Minecraft.getMinecraft().gameSettings.keybind
|
||||
ClientRegistry.registerKeyBinding(openGuiBinding);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user