]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Replace "F1", "F2", etc... with "F%d"
authorterencehill <piuntn@gmail.com>
Mon, 22 Apr 2019 07:58:52 +0000 (09:58 +0200)
committerterencehill <piuntn@gmail.com>
Mon, 22 Apr 2019 07:58:52 +0000 (09:58 +0200)
qcsrc/common/util.qc

index 676ae4c4b3e6d0365f7a44e322d80cd5eebfbbdc..af7bc76cace610ce982cb3a30896d0bfee015370 100644 (file)
@@ -1459,19 +1459,6 @@ string translate_key(string key)
                case "CTRL":                    return _("CTRL");
                case "SHIFT":                   return _("SHIFT");
 
-               case "F1":                              return _("F1");
-               case "F2":                              return _("F2");
-               case "F3":                              return _("F3");
-               case "F4":                              return _("F4");
-               case "F5":                              return _("F5");
-               case "F6":                              return _("F6");
-               case "F7":                              return _("F7");
-               case "F8":                              return _("F8");
-               case "F9":                              return _("F9");
-               case "F10":                             return _("F10");
-               case "F11":                             return _("F11");
-               case "F12":                             return _("F12");
-
                case "INS":                             return _("INS");
                case "DEL":                             return _("DEL");
                case "PGDN":                    return _("PGDN");
@@ -1493,6 +1480,16 @@ string translate_key(string key)
                case "BACKSLASH":               return _("BACKSLASH");
        }
 
+       if (substring(key, 0, 1) == "F")
+       {
+               string subkey = substring(key, 1, -1);
+               if (IS_DIGIT(substring(key, 3, 1))) // check only first digit
+               {
+                       return sprintf(_("F%d"), stof(subkey));
+               }
+               // continue in case there is another key name starting with F
+       }
+
        if (substring(key, 0, 3) == "KP_")
        {
                string subkey = substring(key, 3, -1);