mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-12 19:18:20 +00:00
Port scripts/gen_keys.py to Python 3, add missing NOLINT comment
This commit is contained in:
parent
86e2d6791f
commit
f500ced16e
|
@ -1,24 +1,24 @@
|
||||||
# pylint: skip-file
|
# pylint: skip-file
|
||||||
# generate keys.h file
|
# generate keys.h file
|
||||||
f = file("src/engine/keys.h", "w")
|
f = open("src/engine/keys.h", "w")
|
||||||
|
|
||||||
keynames = []
|
keynames = []
|
||||||
for i in range(0, 512):
|
for i in range(0, 512):
|
||||||
keynames += ["&%d"%i]
|
keynames += ["&%d"%i]
|
||||||
|
|
||||||
print >>f, "#ifndef ENGINE_KEYS_H"
|
print("#ifndef ENGINE_KEYS_H", file=f)
|
||||||
print >>f, "#define ENGINE_KEYS_H"
|
print("#define ENGINE_KEYS_H", file=f)
|
||||||
|
|
||||||
# KEY_EXECUTE already exists on windows platforms
|
# KEY_EXECUTE already exists on windows platforms
|
||||||
print >>f, "#if defined(CONF_FAMILY_WINDOWS)"
|
print("#if defined(CONF_FAMILY_WINDOWS)", file=f)
|
||||||
print >>f, " #undef KEY_EXECUTE"
|
print(" #undef KEY_EXECUTE", file=f)
|
||||||
print >>f, "#endif"
|
print("#endif", file=f)
|
||||||
|
|
||||||
print >>f, '/* AUTO GENERATED! DO NOT EDIT MANUALLY! */'
|
print('/* AUTO GENERATED! DO NOT EDIT MANUALLY! */', file=f)
|
||||||
print >>f, "enum"
|
print("enum", file=f)
|
||||||
print >>f, "{"
|
print("{", file=f)
|
||||||
|
|
||||||
print >>f, "\tKEY_FIRST = 0,"
|
print("\tKEY_FIRST = 0,", file=f)
|
||||||
|
|
||||||
highestid = 0
|
highestid = 0
|
||||||
for line in open("scripts/SDL_scancode.h"):
|
for line in open("scripts/SDL_scancode.h"):
|
||||||
|
@ -28,48 +28,49 @@ for line in open("scripts/SDL_scancode.h"):
|
||||||
value = int(l[1].split(",")[0].strip())
|
value = int(l[1].split(",")[0].strip())
|
||||||
if key[0:2] == "/*":
|
if key[0:2] == "/*":
|
||||||
continue
|
continue
|
||||||
print >>f, "\t%s = %d,"%(key, value)
|
print("\t%s = %d,"%(key, value), file=f)
|
||||||
|
|
||||||
keynames[value] = key.replace("KEY_", "").lower()
|
keynames[value] = key.replace("KEY_", "").lower()
|
||||||
|
|
||||||
if value > highestid:
|
if value > highestid:
|
||||||
highestid =value
|
highestid = value
|
||||||
|
|
||||||
print >>f, "\tKEY_MOUSE_1 = %d,"%(highestid+1); keynames[highestid+1] = "mouse1"
|
highestid += 1
|
||||||
print >>f, "\tKEY_MOUSE_2 = %d,"%(highestid+2); keynames[highestid+2] = "mouse2"
|
print("\tKEY_MOUSE_1 = %d,"%(highestid), file=f); keynames[highestid] = "mouse1"; highestid += 1
|
||||||
print >>f, "\tKEY_MOUSE_3 = %d,"%(highestid+3); keynames[highestid+3] = "mouse3"
|
print("\tKEY_MOUSE_2 = %d,"%(highestid), file=f); keynames[highestid] = "mouse2"; highestid += 1
|
||||||
print >>f, "\tKEY_MOUSE_4 = %d,"%(highestid+4); keynames[highestid+4] = "mouse4"
|
print("\tKEY_MOUSE_3 = %d,"%(highestid), file=f); keynames[highestid] = "mouse3"; highestid += 1
|
||||||
print >>f, "\tKEY_MOUSE_5 = %d,"%(highestid+5); keynames[highestid+5] = "mouse5"
|
print("\tKEY_MOUSE_4 = %d,"%(highestid), file=f); keynames[highestid] = "mouse4"; highestid += 1
|
||||||
print >>f, "\tKEY_MOUSE_6 = %d,"%(highestid+6); keynames[highestid+6] = "mouse6"
|
print("\tKEY_MOUSE_5 = %d,"%(highestid), file=f); keynames[highestid] = "mouse5"; highestid += 1
|
||||||
print >>f, "\tKEY_MOUSE_7 = %d,"%(highestid+7); keynames[highestid+7] = "mouse7"
|
print("\tKEY_MOUSE_6 = %d,"%(highestid), file=f); keynames[highestid] = "mouse6"; highestid += 1
|
||||||
print >>f, "\tKEY_MOUSE_8 = %d,"%(highestid+8); keynames[highestid+8] = "mouse8"
|
print("\tKEY_MOUSE_7 = %d,"%(highestid), file=f); keynames[highestid] = "mouse7"; highestid += 1
|
||||||
print >>f, "\tKEY_MOUSE_9 = %d,"%(highestid+9); keynames[highestid+9] = "mouse9"
|
print("\tKEY_MOUSE_8 = %d,"%(highestid), file=f); keynames[highestid] = "mouse8"; highestid += 1
|
||||||
print >>f, "\tKEY_MOUSE_WHEEL_UP = %d,"%(highestid+10); keynames[highestid+10] = "mousewheelup"
|
print("\tKEY_MOUSE_9 = %d,"%(highestid), file=f); keynames[highestid] = "mouse9"; highestid += 1
|
||||||
print >>f, "\tKEY_MOUSE_WHEEL_DOWN = %d,"%(highestid+11); keynames[highestid+11] = "mousewheeldown"
|
print("\tKEY_MOUSE_WHEEL_UP = %d,"%(highestid), file=f); keynames[highestid] = "mousewheelup"; highestid += 1
|
||||||
print >>f, "\tKEY_MOUSE_WHEEL_LEFT = %d,"%(highestid+12); keynames[highestid+12] = "mousewheelleft"
|
print("\tKEY_MOUSE_WHEEL_DOWN = %d,"%(highestid), file=f); keynames[highestid] = "mousewheeldown"; highestid += 1
|
||||||
print >>f, "\tKEY_MOUSE_WHEEL_RIGHT = %d,"%(highestid+13); keynames[highestid+13] = "mousewheelright"
|
print("\tKEY_MOUSE_WHEEL_LEFT = %d,"%(highestid), file=f); keynames[highestid] = "mousewheelleft"; highestid += 1
|
||||||
print >>f, "\tKEY_LAST = 512,"
|
print("\tKEY_MOUSE_WHEEL_RIGHT = %d,"%(highestid), file=f); keynames[highestid] = "mousewheelright"; highestid += 1
|
||||||
|
print("\tKEY_LAST = 512,", file=f)
|
||||||
|
|
||||||
print >>f, "};"
|
print("};", file=f)
|
||||||
print >>f, ""
|
print("", file=f)
|
||||||
print >>f, "#endif"
|
print("#endif", file=f)
|
||||||
|
|
||||||
# generate keynames.c file
|
# generate keynames.c file
|
||||||
f = file("src/engine/client/keynames.h", "w")
|
f = open("src/engine/client/keynames.h", "w")
|
||||||
print >>f, '/* AUTO GENERATED! DO NOT EDIT MANUALLY! */'
|
print('/* AUTO GENERATED! DO NOT EDIT MANUALLY! */', file=f)
|
||||||
print >>f, ''
|
print('', file=f)
|
||||||
print >>f, '#ifndef KEYS_INCLUDE'
|
print('#ifndef KEYS_INCLUDE', file=f)
|
||||||
print >>f, '#error do not include this header!'
|
print('#error do not include this header!', file=f)
|
||||||
print >>f, '#endif'
|
print('#endif', file=f)
|
||||||
print >>f, ''
|
print('', file=f)
|
||||||
print >>f, "#include <string.h>"
|
print("#include <string.h>", file=f)
|
||||||
print >>f, ""
|
print("", file=f)
|
||||||
print >>f, "const char g_aaKeyStrings[512][20] ="
|
print("const char g_aaKeyStrings[512][20] = // NOLINT(misc-definitions-in-headers)", file=f)
|
||||||
print >>f, "{"
|
print("{", file=f)
|
||||||
for n in keynames:
|
for n in keynames:
|
||||||
print >>f, '\t"%s",'%n
|
print('\t"%s",'%n, file=f)
|
||||||
|
|
||||||
print >>f, "};"
|
print("};", file=f)
|
||||||
print >>f, ""
|
print("", file=f)
|
||||||
|
|
||||||
f.close()
|
f.close()
|
||||||
|
|
Loading…
Reference in a new issue