aboutsummaryrefslogtreecommitdiff
path: root/backends/vkeybd/packs/vkeybdpack.py
diff options
context:
space:
mode:
authorJohn Willis2009-06-08 09:10:12 +0000
committerJohn Willis2009-06-08 09:10:12 +0000
commit4ff5a39f757b5b3840d152ae74ad1dcd357107e0 (patch)
tree55bd47a1fa09db756af6e39f79df2274aab82eed /backends/vkeybd/packs/vkeybdpack.py
parent78de280f121503843905bdc2f91c2cd5d2b22211 (diff)
downloadscummvm-rg350-4ff5a39f757b5b3840d152ae74ad1dcd357107e0.tar.gz
scummvm-rg350-4ff5a39f757b5b3840d152ae74ad1dcd357107e0.tar.bz2
scummvm-rg350-4ff5a39f757b5b3840d152ae74ad1dcd357107e0.zip
Virtual Keyboard: Add source files for the default keyboard pack seperate from ZIP archive (makes it easier to version the packs vkeybd.xml and track fixes) and add script to build keyboard pack(s) ZIP's from source files (based on /gui/themes/scummtheme.py).
svn-id: r41366
Diffstat (limited to 'backends/vkeybd/packs/vkeybdpack.py')
-rwxr-xr-xbackends/vkeybd/packs/vkeybdpack.py73
1 files changed, 73 insertions, 0 deletions
diff --git a/backends/vkeybd/packs/vkeybdpack.py b/backends/vkeybd/packs/vkeybdpack.py
new file mode 100755
index 0000000000..e7b1c63543
--- /dev/null
+++ b/backends/vkeybd/packs/vkeybdpack.py
@@ -0,0 +1,73 @@
+#!/usr/bin/env python
+# encoding: utf-8
+import sys
+import re
+import os
+import zipfile
+
+PACK_FILE_EXTENSIONS = ('.xml', '.bmp')
+
+def buildPack(packName):
+ if not os.path.isdir(packName):
+ print ("Invalid pack name: " + packName)
+ return
+
+ zf = zipfile.ZipFile(packName + ".zip", 'w')
+
+ print ("Building '" + packName + "' pack:")
+ os.chdir(packName)
+
+ for filename in os.listdir('.'):
+ if os.path.isfile(filename) and not filename[0] == '.' and filename.endswith(PACK_FILE_EXTENSIONS):
+ zf.write(filename, './' + filename)
+ print (" Adding file: " + filename)
+
+ os.chdir('../')
+
+ zf.close()
+
+def buildAllPacks():
+ for f in os.listdir('.'):
+ if os.path.isdir(os.path.join('.', f)) and not f[0] == '.':
+ buildPack(f)
+
+def parseSTX(pack_file, def_file):
+ comm = re.compile("<!--(.*?)-->", re.DOTALL)
+ head = re.compile("<\?(.*?)\?>")
+
+ output = ""
+ for line in pack_file:
+ output += line.rstrip("\r\n\t ").lstrip() + " \n"
+
+ output = re.sub(comm, "", output)
+ output = re.sub(head, "", output)
+ output = output.replace("\t", " ").replace(" ", " ").replace("\"", "'")
+ output = output.replace(" = ", "=").replace(", ", ",")
+
+ for line in output.splitlines():
+ if line and not line.isspace():
+ def_file.write("\"" + line + "\"\n")
+
+def printUsage():
+ print ("===============================================")
+ print ("ScummVM Virtual Keyboard Pack Generation Script")
+ print ("===============================================")
+ print ("Usage:")
+ print ("vkeybdpack.py makeall")
+ print (" Builds all the available pack.\n")
+ print ("vkeybdpack.py make [packname]")
+ print (" Builds the pack called 'packname'.\n")
+
+def main():
+
+ if len(sys.argv) == 2 and sys.argv[1] == "makeall":
+ buildAllPacks()
+
+ elif len(sys.argv) == 3 and sys.argv[1] == "make":
+ buildPack(sys.argv[2])
+
+ else:
+ printUsage()
+
+if __name__ == "__main__":
+ sys.exit(main())