mirror of
https://github.com/Pax1601/DCSOlympus.git
synced 2025-10-29 16:56:34 +00:00
Added tags to unit spawn menu
This commit is contained in:
2
scripts/python/.vscode/launch.json
vendored
2
scripts/python/.vscode/launch.json
vendored
@@ -11,7 +11,7 @@
|
||||
"program": "${file}",
|
||||
"console": "integratedTerminal",
|
||||
"justMyCode": true,
|
||||
"args": ["aircraft"]
|
||||
"args": ["groundunit"]
|
||||
}
|
||||
]
|
||||
}
|
||||
35
scripts/python/convertTags.py
Normal file
35
scripts/python/convertTags.py
Normal file
@@ -0,0 +1,35 @@
|
||||
import sys
|
||||
import json
|
||||
import re
|
||||
|
||||
|
||||
# The database file on which to operate is the first standard argument of the call
|
||||
if len(sys.argv) > 1:
|
||||
if (sys.argv[1] == "aircraft"):
|
||||
filename = '..\\..\\client\\public\\databases\\units\\aircraftdatabase.json'
|
||||
elif (sys.argv[1] == "helicopter"):
|
||||
filename = '..\\..\\client\\public\\databases\\units\\helicopterdatabase.json'
|
||||
elif (sys.argv[1] == "groundunit"):
|
||||
filename = '..\\..\\client\\public\\databases\\units\\groundunitdatabase.json'
|
||||
elif (sys.argv[1] == "navyunit"):
|
||||
filename = '..\\..\\client\\public\\databases\\units\\navyunitdatabase.json'
|
||||
|
||||
# Loads the database
|
||||
with open(filename) as f:
|
||||
database = json.load(f)
|
||||
|
||||
for name in database:
|
||||
label = database[name]['label']
|
||||
print(label)
|
||||
res = re.findall("\((.*?)\)", label)
|
||||
for tag in res:
|
||||
label = label.replace(f"({tag})", "")
|
||||
label = database[name]['label'] = label
|
||||
if len(res) > 0:
|
||||
database[name]["tags"] = "".join([f'{tag}{", " if i < len(res) - 1 else ""}' for i, tag in enumerate(res)])
|
||||
|
||||
# Dump everything in the database
|
||||
with open(filename, "w") as f:
|
||||
json.dump(database, f, indent=2)
|
||||
|
||||
print("Done!")
|
||||
Reference in New Issue
Block a user