|
@@ -1,9 +1,8 @@
|
|
|
package pathgame.gameplay;
|
|
|
|
|
|
-import java.io.BufferedReader;
|
|
|
+import java.io.DataInputStream;
|
|
|
import java.io.File;
|
|
|
-import java.io.FileNotFoundException;
|
|
|
-import java.io.FileReader;
|
|
|
+import java.io.FileInputStream;
|
|
|
import java.io.IOException;
|
|
|
import me.hammerle.snuviengine.api.KeyBinding;
|
|
|
import me.hammerle.snuviengine.api.KeyHandler;
|
|
@@ -12,64 +11,49 @@ import org.lwjgl.glfw.GLFW;
|
|
|
public class Keys
|
|
|
{
|
|
|
|
|
|
- public static final KeyBinding UP_KEY;// = KeyHandler.register(GLFW.GLFW_KEY_W);
|
|
|
- public static final KeyBinding DOWN_KEY;// = KeyHandler.register(GLFW.GLFW_KEY_S);
|
|
|
- public static final KeyBinding LEFT_KEY;// = KeyHandler.register(GLFW.GLFW_KEY_A);
|
|
|
- public static final KeyBinding RIGHT_KEY;// = KeyHandler.register(GLFW.GLFW_KEY_D);
|
|
|
- public static final KeyBinding ZOOM_IN_KEY;// = KeyHandler.register(GLFW.GLFW_KEY_I);
|
|
|
- public static final KeyBinding ZOOM_OUT_KEY;// = KeyHandler.register(GLFW.GLFW_KEY_O);
|
|
|
- public static final KeyBinding CONFIRM_KEY;// = KeyHandler.register(GLFW.GLFW_KEY_ENTER);
|
|
|
- public static final KeyBinding ESCAPE_KEY;// = KeyHandler.register(GLFW.GLFW_KEY_ESCAPE);
|
|
|
+ public static final KeyBinding UP_KEY = KeyHandler.register(GLFW.GLFW_KEY_W);
|
|
|
+ public static final KeyBinding DOWN_KEY = KeyHandler.register(GLFW.GLFW_KEY_S);
|
|
|
+ public static final KeyBinding LEFT_KEY = KeyHandler.register(GLFW.GLFW_KEY_A);
|
|
|
+ public static final KeyBinding RIGHT_KEY = KeyHandler.register(GLFW.GLFW_KEY_D);
|
|
|
+ public static final KeyBinding ZOOM_IN_KEY = KeyHandler.register(GLFW.GLFW_KEY_I);
|
|
|
+ public static final KeyBinding ZOOM_OUT_KEY = KeyHandler.register(GLFW.GLFW_KEY_O);
|
|
|
+ public static final KeyBinding CONFIRM_KEY = KeyHandler.register(GLFW.GLFW_KEY_ENTER);
|
|
|
+ public static final KeyBinding ESCAPE_KEY = KeyHandler.register(GLFW.GLFW_KEY_ESCAPE);
|
|
|
public static final KeyBinding CAM_UP_KEY = KeyHandler.register(GLFW.GLFW_KEY_UP);
|
|
|
public static final KeyBinding CAM_DOWN_KEY = KeyHandler.register(GLFW.GLFW_KEY_DOWN);
|
|
|
public static final KeyBinding CAM_LEFT_KEY = KeyHandler.register(GLFW.GLFW_KEY_LEFT);
|
|
|
public static final KeyBinding CAM_RIGHT_KEY = KeyHandler.register(GLFW.GLFW_KEY_RIGHT);
|
|
|
public static final KeyBinding TEST_KEY = KeyHandler.register(GLFW.GLFW_KEY_T);
|
|
|
|
|
|
- public static final KeyBinding[] KEYS;
|
|
|
+ public static final KeyBinding[] KEYS = new KeyBinding[]
|
|
|
+ {
|
|
|
+ UP_KEY, DOWN_KEY, LEFT_KEY, RIGHT_KEY, ZOOM_IN_KEY, ZOOM_OUT_KEY,
|
|
|
+ CONFIRM_KEY, ESCAPE_KEY, CAM_UP_KEY, CAM_DOWN_KEY, CAM_LEFT_KEY,
|
|
|
+ CAM_RIGHT_KEY
|
|
|
+ };
|
|
|
+
|
|
|
public static final String[] KEYNAMES =
|
|
|
{
|
|
|
- "Up Key", "Down Key", "Left Key", "Right Key", "Zoom In Key", "Zoom Out Key", "Confirm Key", "Escape Key", //"Cam Up Key", "Cam Down Key", "Cam Left Key", "Cam Right Key"
|
|
|
+ "Up Key", "Down Key", "Left Key", "Right Key", "Zoom In Key",
|
|
|
+ "Zoom Out Key", "Confirm Key", "Escape Key", "Cam Up Key",
|
|
|
+ "Cam Down Key", "Cam Left Key", "Cam Right Key"
|
|
|
};
|
|
|
|
|
|
static
|
|
|
{
|
|
|
- String line[] = new String[KEYNAMES.length];
|
|
|
- File f = new File("resources/config.txt");
|
|
|
- System.out.println(f.getName());
|
|
|
+ File f = new File("resources/config.bin");
|
|
|
if(f.exists())
|
|
|
{
|
|
|
- FileReader reader = null;
|
|
|
- try
|
|
|
+ try(DataInputStream reader = new DataInputStream(new FileInputStream(f)))
|
|
|
{
|
|
|
- reader = new FileReader(f);
|
|
|
- BufferedReader bReader = new BufferedReader(reader);
|
|
|
- for(int i = 0; i < KEYNAMES.length; ++i)
|
|
|
+ for(int i = 0; i < KEYS.length; ++i)
|
|
|
{
|
|
|
- try
|
|
|
- {
|
|
|
- line[i] = bReader.readLine();
|
|
|
- }
|
|
|
- catch(IOException ex)
|
|
|
- {
|
|
|
- }
|
|
|
+ KeyHandler.rebind(KEYS[i], reader.readInt());
|
|
|
}
|
|
|
}
|
|
|
- catch(FileNotFoundException ex)
|
|
|
+ catch(IOException ex)
|
|
|
{
|
|
|
}
|
|
|
}
|
|
|
- UP_KEY = KeyHandler.register(Integer.parseInt(line[0].substring(line[0].indexOf(":") + 2, line[0].length())));
|
|
|
- DOWN_KEY = KeyHandler.register(Integer.parseInt(line[1].substring(line[1].indexOf(":") + 2, line[1].length())));
|
|
|
- LEFT_KEY = KeyHandler.register(Integer.parseInt(line[2].substring(line[2].indexOf(":") + 2, line[2].length())));
|
|
|
- RIGHT_KEY = KeyHandler.register(Integer.parseInt(line[3].substring(line[3].indexOf(":") + 2, line[3].length())));
|
|
|
- ZOOM_IN_KEY = KeyHandler.register(Integer.parseInt(line[4].substring(line[4].indexOf(":") + 2, line[4].length())));
|
|
|
- ZOOM_OUT_KEY = KeyHandler.register(Integer.parseInt(line[5].substring(line[5].indexOf(":") + 2, line[5].length())));
|
|
|
- CONFIRM_KEY = KeyHandler.register(Integer.parseInt(line[6].substring(line[6].indexOf(":") + 2, line[6].length())));
|
|
|
- ESCAPE_KEY = KeyHandler.register(Integer.parseInt(line[7].substring(line[7].indexOf(":") + 2, line[7].length())));
|
|
|
- KEYS = new KeyBinding[]
|
|
|
- {
|
|
|
- UP_KEY, DOWN_KEY, LEFT_KEY, RIGHT_KEY, ZOOM_IN_KEY, ZOOM_OUT_KEY, CONFIRM_KEY, ESCAPE_KEY, //CAM_UP_KEY, CAM_DOWN_KEY, CAM_LEFT_KEY, CAM_RIGHT_KEY
|
|
|
- };
|
|
|
}
|
|
|
}
|