v0.8.0: added an initial window for key bindings, more work needed
This commit is contained in:
@@ -28,4 +28,6 @@ public class GameAction {
|
||||
public static final int BACK = 1;
|
||||
public static final int MENU = 2;
|
||||
|
||||
public static final int TOTAL_ACTIONS = 3;
|
||||
|
||||
}
|
||||
|
||||
@@ -21,11 +21,16 @@
|
||||
|
||||
package com.watabou.input;
|
||||
|
||||
import java.util.HashMap;
|
||||
import com.badlogic.gdx.Input;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
|
||||
//TODO maybe just move to game action?
|
||||
public class KeyBindings {
|
||||
|
||||
private static HashMap<Integer, Integer> bindings = new HashMap<>();
|
||||
private static LinkedHashMap<Integer, Integer> bindings = new LinkedHashMap<>();
|
||||
private static HashMap<Integer, String> names = new HashMap<>();
|
||||
|
||||
public static void addBinding( int keyCode, int keyAction){
|
||||
@@ -40,6 +45,26 @@ public class KeyBindings {
|
||||
return bindings.get( event.code );
|
||||
}
|
||||
|
||||
public static ArrayList<Integer> getBindings( int gameAction ){
|
||||
ArrayList<Integer> result = new ArrayList<>();
|
||||
for( int i : bindings.keySet()){
|
||||
if (bindings.get(i) == gameAction){
|
||||
result.add(i);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public static String getKeyName( int keyCode ){
|
||||
String result = Input.Keys.toString(keyCode);
|
||||
|
||||
if (result.equals("Plus")){
|
||||
return "+";
|
||||
} else {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
public static void addName( int keyAction, String name ){
|
||||
names.put(keyAction, name);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user