12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- package me.hammerle.supersnuvi;
- import me.hammerle.snuviengine.api.KeyBinding;
- import me.hammerle.snuviengine.api.KeyHandler;
- import me.hammerle.supersnuvi.savegame.SimpleConfig;
- import static org.lwjgl.glfw.GLFW.*;
- public class Keys
- {
- public final static KeyBinding UP = KeyHandler.register(GLFW_KEY_UP);
- public final static KeyBinding DOWN = KeyHandler.register(GLFW_KEY_DOWN);
- public final static KeyBinding LEFT = KeyHandler.register(GLFW_KEY_LEFT);
- public final static KeyBinding RIGHT = KeyHandler.register(GLFW_KEY_RIGHT);
-
- public final static KeyBinding JUMP = KeyHandler.register(GLFW_KEY_SPACE);
- public final static KeyBinding RUN = KeyHandler.register(GLFW_KEY_LEFT_SHIFT);
- public final static KeyBinding ESCAPE = KeyHandler.register(GLFW_KEY_ESCAPE);
- public final static KeyBinding ENTER = KeyHandler.register(GLFW_KEY_ENTER);
-
- public final static KeyBinding COMBAT = KeyHandler.register(GLFW_KEY_A);
- public final static KeyBinding COMBAT_SWITCH_FACE = KeyHandler.register(GLFW_KEY_S);
- public final static KeyBinding COMBAT_DASH = KeyHandler.register(GLFW_KEY_D);
- public final static KeyBinding COMBAT_DODGE = KeyHandler.register(GLFW_KEY_F);
- public final static KeyBinding COMBAT_BLOCK = KeyHandler.register(GLFW_KEY_G);
- public final static KeyBinding COMBAT_ATTACK = KeyHandler.register(GLFW_KEY_H);
-
- private final static KeyBinding[] KEYS =
- {
- UP, DOWN, LEFT, RIGHT,
- JUMP, RUN, ESCAPE, ENTER,
- COMBAT, COMBAT_SWITCH_FACE, COMBAT_DASH, COMBAT_DODGE, COMBAT_BLOCK, COMBAT_ATTACK
- };
-
- public static void rebind(KeyBinding binding)
- {
- KeyHandler.rebind(binding);
- }
-
- public static int getAmount()
- {
- return KEYS.length;
- }
-
- public static KeyBinding get(int index)
- {
- return KEYS[index];
- }
-
- public static void read(SimpleConfig config)
- {
- KeyHandler.rebind(UP, config.getInt("key.up", GLFW_KEY_UP));
- KeyHandler.rebind(DOWN, config.getInt("key.down", GLFW_KEY_DOWN));
- KeyHandler.rebind(LEFT, config.getInt("key.left", GLFW_KEY_LEFT));
- KeyHandler.rebind(RIGHT, config.getInt("key.right", GLFW_KEY_RIGHT));
-
- KeyHandler.rebind(JUMP, config.getInt("key.jump", GLFW_KEY_SPACE));
- KeyHandler.rebind(RUN, config.getInt("key.run", GLFW_KEY_LEFT_SHIFT));
- KeyHandler.rebind(ESCAPE, config.getInt("key.escape", GLFW_KEY_ESCAPE));
- KeyHandler.rebind(ENTER, config.getInt("key.enter", GLFW_KEY_ENTER));
-
- KeyHandler.rebind(COMBAT, config.getInt("key.combat", GLFW_KEY_A));
- KeyHandler.rebind(COMBAT_SWITCH_FACE, config.getInt("key.combat.switchface", GLFW_KEY_S));
- KeyHandler.rebind(COMBAT_DASH, config.getInt("key.combat.dash", GLFW_KEY_D));
- KeyHandler.rebind(COMBAT_DODGE, config.getInt("key.combat.dodge", GLFW_KEY_F));
- KeyHandler.rebind(COMBAT_BLOCK, config.getInt("key.combat.block", GLFW_KEY_G));
- KeyHandler.rebind(COMBAT_ATTACK, config.getInt("key.combat.attack", GLFW_KEY_H));
- }
-
- public static void write(SimpleConfig config)
- {
- config.set("key.up", UP.getKey());
- config.set("key.down", DOWN.getKey());
- config.set("key.left", LEFT.getKey());
- config.set("key.right", RIGHT.getKey());
-
- config.set("key.jump", JUMP.getKey());
- config.set("key.run", RUN.getKey());
- config.set("key.escape", ESCAPE.getKey());
- config.set("key.enter", ENTER.getKey());
- config.set("key.combat", COMBAT.getKey());
- config.set("key.combat.switchface", COMBAT_SWITCH_FACE.getKey());
- config.set("key.combat.dash", COMBAT_DASH.getKey());
- config.set("key.combat.dodge", COMBAT_DODGE.getKey());
- config.set("key.combat.block", COMBAT_BLOCK.getKey());
- config.set("key.combat.attack", COMBAT_ATTACK.getKey());
- }
- }
|