Ver Fonte

force rebind without checking for current binding (for reading a config)

Kajetan Johannes Hammerle há 4 anos atrás
pai
commit
c76576fe40
1 ficheiros alterados com 6 adições e 4 exclusões
  1. 6 4
      src/me/hammerle/snuviengine/api/KeyHandler.java

+ 6 - 4
src/me/hammerle/snuviengine/api/KeyHandler.java

@@ -28,11 +28,10 @@ public final class KeyHandler
     
     public static void rebind(KeyBinding binding, int key)
     {
-        if(BINDINGS.containsKey(key))
+        if(BINDINGS.get(binding.getKey()) == binding)
         {
-            return;
+            BINDINGS.remove(binding.getKey());
         }
-        BINDINGS.remove(binding.getKey());
         binding.setKey(key);
         BINDINGS.put(key, binding);
     }
@@ -42,7 +41,10 @@ public final class KeyHandler
         if(rebind != null)
         {
             rebind.setIsRebinding(false);
-            rebind(rebind, key);
+            if(!BINDINGS.containsKey(key))
+            {
+                rebind(rebind, key);
+            }
             rebind = null;
             return;
         }