Refactored a lot. Only ContainerManager and Main Class are missing.
This commit is contained in:
@@ -14,28 +14,37 @@ public class Config {
|
||||
/**
|
||||
* Defines the config string for the keys-category.
|
||||
*/
|
||||
public static final String categoryKeys = "keys";
|
||||
protected static final String categoryKeys = "keys";
|
||||
|
||||
/**
|
||||
* Defines the config string for the other-category.
|
||||
*/
|
||||
public static final String categoryOther = "other";
|
||||
/**
|
||||
* Defines all 11 Keys you can use with Crafting Keys.
|
||||
*/
|
||||
public static Property keyTopLeft, keyTopCenter, keyTopRight,
|
||||
keyCenterLeft, keyCenterCenter, keyCenterRight,
|
||||
keyLowerLeft, keyLowerCenter, keyLowerRight,
|
||||
keyStack, keyInteract;
|
||||
/**
|
||||
* Defines, if NumPad is always active for crafting.
|
||||
*/
|
||||
public static Property enableNumPad;
|
||||
|
||||
protected static final String categoryOther = "other";
|
||||
/**
|
||||
* Provides the Suggested Config File.
|
||||
*/
|
||||
public static Configuration configFile;
|
||||
protected static Configuration configFile = null;
|
||||
/**
|
||||
* Defines all 11 Keys you can use with Crafting Keys.
|
||||
*/
|
||||
private static Property keyTopLeft, keyTopCenter, keyTopRight,
|
||||
keyCenterLeft, keyCenterCenter, keyCenterRight,
|
||||
keyLowerLeft, keyLowerCenter, keyLowerRight,
|
||||
keyStack, keyInteract, keyDrop;
|
||||
/**
|
||||
* Defines, if NumPad is always active for crafting.
|
||||
*/
|
||||
private static Property enableNumPad;
|
||||
|
||||
public static boolean isNumPadEnabled() {
|
||||
return enableNumPad.getBoolean(true);
|
||||
}
|
||||
|
||||
|
||||
public static int getKeyCode(KeyType key) {
|
||||
//return ((Property)(Config.class.getField((key.toString())))..getInt(-1); // TODO!
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the configFile Files, loads all values (or sets them to default).
|
||||
@@ -59,7 +68,12 @@ public class Config {
|
||||
*/
|
||||
public static void syncConfig() {
|
||||
|
||||
syncProperties();
|
||||
if (configFile == null) {
|
||||
// TODO: Throw Error!
|
||||
return;
|
||||
}
|
||||
|
||||
syncProperties(); // TODO: Why here?
|
||||
|
||||
if (configFile.hasChanged())
|
||||
configFile.save();
|
||||
@@ -101,8 +115,9 @@ public class Config {
|
||||
|
||||
// Special Keys
|
||||
|
||||
keyStack = configFile.get(categoryKeys, "Stack Key", Keyboard.KEY_LSHIFT, "Key to move stacks instead of single items");
|
||||
keyInteract = configFile.get(categoryKeys, "Interaction Key", Keyboard.KEY_LCONTROL, "Key to interact with e.g. crafting output");
|
||||
keyStack = configFile.get(categoryKeys, "Stack Key", Keyboard.KEY_LSHIFT, "Key to move stacks instead of single items (key value)");
|
||||
keyInteract = configFile.get(categoryKeys, "Interaction Key", Keyboard.KEY_LCONTROL, "Key to interact with e.g. crafting output (key value)");
|
||||
keyDrop = configFile.get(categoryKeys, "Drop Key", Keyboard.KEY_SPACE, "Key to drop all items from crafting (key value)");
|
||||
|
||||
// Other Settings
|
||||
|
||||
@@ -110,4 +125,11 @@ public class Config {
|
||||
|
||||
}
|
||||
|
||||
public enum KeyType {
|
||||
keyTopLeft, keyTopCenter, keyTopRight,
|
||||
keyCenterLeft, keyCenterCenter, keyCenterRight,
|
||||
keyLowerLeft, keyLowerCenter, keyLowerRight,
|
||||
keyStack, keyInteract, keyDrop
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -17,7 +17,6 @@ public class ConfigGui extends GuiConfig {
|
||||
public ConfigGui(GuiScreen parent) {
|
||||
super(parent, getConfigElements(),
|
||||
CraftingKeys.MODID, false, false, CraftingKeys.NAME);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -28,8 +27,8 @@ public class ConfigGui extends GuiConfig {
|
||||
private static List<IConfigElement> getConfigElements() {
|
||||
List<IConfigElement> list = new ArrayList<IConfigElement>();
|
||||
|
||||
list.add(categoryElement(Config.categoryKeys, Config.categoryKeys, "de.skate702.craftingkeys.keys"));
|
||||
list.add(categoryElement(Config.categoryOther, Config.categoryOther, "de.skate702.craftingkeys.other"));
|
||||
list.add(categoryElement(Config.categoryKeys, Config.categoryKeys, "de.skate702.craftingkeys.config.keys"));
|
||||
list.add(categoryElement(Config.categoryOther, Config.categoryOther, "de.skate702.craftingkeys.config.other"));
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
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 = "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),
|
||||
};
|
||||
|
||||
/**
|
||||
* Initializes all key bindings and registers them to the client-side. Bindings are exclusive.
|
||||
* Do NOT use until there is a solution for this!
|
||||
*/
|
||||
@Deprecated
|
||||
public static void init() {
|
||||
for (KeyBinding binding : bindings) {
|
||||
ClientRegistry.registerKeyBinding(binding);
|
||||
}
|
||||
ClientRegistry.registerKeyBinding(Minecraft.getMinecraft().gameSettings.keyBindRight);
|
||||
//Minecraft.getMinecraft().gameSettings.keybind
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user