Search in sources :

Example 1 with PDInputProcessor

use of com.shatteredpixel.shatteredpixeldungeon.input.PDInputProcessor in project shattered-pixel-dungeon-gdx by 00-Evan.

the class WndKeymap method populateList.

private void populateList() {
    listContent.clear();
    tempPos = 0;
    final PDInputProcessor inputProcessor = (PDInputProcessor) Game.instance.getInputProcessor();
    final Map<Integer, PDInputProcessor.GameActionWrapper> keyMappings = inputProcessor.getKeyMappings();
    final Map<GameAction, KeyPair> mappings = new TreeMap<>();
    for (GameAction action : GameAction.values()) {
        if (action.getDescription() != null) {
            mappings.put(action, new KeyPair());
        }
    }
    for (Map.Entry<Integer, PDInputProcessor.GameActionWrapper> entry : keyMappings.entrySet()) {
        final Integer key = entry.getKey();
        final PDInputProcessor.GameActionWrapper value = entry.getValue();
        final GameAction action = value.gameAction;
        final KeyPair keyPair = mappings.get(action);
        /*	if (keyPair == null) {
				mappings.put(action, keyPair = new KeyPair());
			}*/
        if (value.defaultKey) {
            keyPair.key1 = key;
        } else {
            keyPair.key2 = key;
        }
    }
    for (Map.Entry<GameAction, KeyPair> entry : mappings.entrySet()) {
        addKey(listContent, width, entry);
    }
    listContent.setSize(0, tempPos);
}
Also used : PDInputProcessor(com.shatteredpixel.shatteredpixeldungeon.input.PDInputProcessor) TreeMap(java.util.TreeMap) HashMap(java.util.HashMap) TreeMap(java.util.TreeMap) Map(java.util.Map) GameAction(com.shatteredpixel.shatteredpixeldungeon.input.GameAction)

Aggregations

GameAction (com.shatteredpixel.shatteredpixeldungeon.input.GameAction)1 PDInputProcessor (com.shatteredpixel.shatteredpixeldungeon.input.PDInputProcessor)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 TreeMap (java.util.TreeMap)1