diff options
Diffstat (limited to 'tools')
-rw-r--r-- | tools/SCsub | 164 | ||||
-rw-r--r-- | tools/editor/SCsub | 126 | ||||
-rw-r--r-- | tools/editor/icons/SCsub | 120 | ||||
-rw-r--r-- | tools/scripts/addheader.py | 62 | ||||
-rwxr-xr-x | tools/scripts/file-hex-array.py | 56 | ||||
-rw-r--r-- | tools/scripts/make_bmfhdr.py | 64 | ||||
-rw-r--r-- | tools/scripts/make_glwrapper.py | 100 | ||||
-rw-r--r-- | tools/scripts/makeargs.py | 28 | ||||
-rw-r--r-- | tools/scripts/memsort.py | 24 | ||||
-rw-r--r-- | tools/scripts/svgs_2_pngs.py | 4 | ||||
-rwxr-xr-x | tools/translations/extract.py | 132 |
11 files changed, 440 insertions, 440 deletions
diff --git a/tools/SCsub b/tools/SCsub index b0b33d4f01..a54b8f48a2 100644 --- a/tools/SCsub +++ b/tools/SCsub @@ -11,115 +11,115 @@ Export('env') def make_translations_header(target,source,env): - dst = target[0].srcnode().abspath + dst = target[0].srcnode().abspath - g = open(dst,"wb") + g = open(dst,"wb") - - """" + + """" """ - g.write("/* THIS FILE IS GENERATED DO NOT EDIT */\n") - g.write("#ifndef _EDITOR_TRANSLATIONS_H\n") - g.write("#define _EDITOR_TRANSLATIONS_H\n") + g.write("/* THIS FILE IS GENERATED DO NOT EDIT */\n") + g.write("#ifndef _EDITOR_TRANSLATIONS_H\n") + g.write("#define _EDITOR_TRANSLATIONS_H\n") - import zlib - import os.path + import zlib + import os.path - paths = [node.srcnode().abspath for node in source] - sorted_paths = sorted(paths, key=lambda path: os.path.splitext(os.path.basename(path))[0]) + paths = [node.srcnode().abspath for node in source] + sorted_paths = sorted(paths, key=lambda path: os.path.splitext(os.path.basename(path))[0]) - xl_names=[] - for i in range(len(sorted_paths)): - print("Appending translation: "+sorted_paths[i]) - f = open(sorted_paths[i],"rb") - buf = f.read() - decomp_size = len(buf) - buf = zlib.compress(buf) - name = os.path.splitext(os.path.basename(sorted_paths[i]))[0] + xl_names=[] + for i in range(len(sorted_paths)): + print("Appending translation: "+sorted_paths[i]) + f = open(sorted_paths[i],"rb") + buf = f.read() + decomp_size = len(buf) + buf = zlib.compress(buf) + name = os.path.splitext(os.path.basename(sorted_paths[i]))[0] - #g.write("static const int _translation_"+name+"_compressed_size="+str(len(buf))+";\n") - #g.write("static const int _translation_"+name+"_uncompressed_size="+str(decomp_size)+";\n") - g.write("static const unsigned char _translation_"+name+"_compressed[]={\n") - for i in range(len(buf)): - g.write(str(ord(buf[i]))+",\n") + #g.write("static const int _translation_"+name+"_compressed_size="+str(len(buf))+";\n") + #g.write("static const int _translation_"+name+"_uncompressed_size="+str(decomp_size)+";\n") + g.write("static const unsigned char _translation_"+name+"_compressed[]={\n") + for i in range(len(buf)): + g.write(str(ord(buf[i]))+",\n") - g.write("};\n") + g.write("};\n") - xl_names.append([name,len(buf),str(decomp_size)]) + xl_names.append([name,len(buf),str(decomp_size)]) - g.write("struct EditorTranslationList {\n") - g.write("\tconst char* lang;\n"); - g.write("\tint comp_size;\n"); - g.write("\tint uncomp_size;\n"); - g.write("\tconst unsigned char* data;\n"); - g.write("};\n\n"); - g.write("static EditorTranslationList _editor_translations[]={\n") - for x in xl_names: - g.write("\t{ \""+x[0]+"\", "+str(x[1])+", "+str(x[2])+",_translation_"+x[0]+"_compressed},\n") - g.write("\t{NULL,0,0,NULL}\n") - g.write("};\n") + g.write("struct EditorTranslationList {\n") + g.write("\tconst char* lang;\n"); + g.write("\tint comp_size;\n"); + g.write("\tint uncomp_size;\n"); + g.write("\tconst unsigned char* data;\n"); + g.write("};\n\n"); + g.write("static EditorTranslationList _editor_translations[]={\n") + for x in xl_names: + g.write("\t{ \""+x[0]+"\", "+str(x[1])+", "+str(x[2])+",_translation_"+x[0]+"_compressed},\n") + g.write("\t{NULL,0,0,NULL}\n") + g.write("};\n") - g.write("#endif") + g.write("#endif") def make_fonts_header(target,source,env): - dst = target[0].srcnode().abspath + dst = target[0].srcnode().abspath + + g = open(dst,"wb") - g = open(dst,"wb") - - """" + """" """ - g.write("/* THIS FILE IS GENERATED DO NOT EDIT */\n") - g.write("#ifndef _EDITOR_FONTS_H\n") - g.write("#define _EDITOR_FONTS_H\n") - - #saving uncompressed, since freetype will reference from memory pointer - xl_names=[] - for i in range(len(source)): - print("Appending font: "+source[i].srcnode().abspath) - f = open(source[i].srcnode().abspath,"rb") - buf = f.read() - import os.path - - name = os.path.splitext(os.path.basename(source[i].srcnode().abspath))[0] - - g.write("static const int _font_"+name+"_size="+str(len(buf))+";\n") - g.write("static const unsigned char _font_"+name+"[]={\n") - for i in range(len(buf)): - g.write(str(ord(buf[i]))+",\n") - - g.write("};\n") - - g.write("#endif") - - + g.write("/* THIS FILE IS GENERATED DO NOT EDIT */\n") + g.write("#ifndef _EDITOR_FONTS_H\n") + g.write("#define _EDITOR_FONTS_H\n") + + #saving uncompressed, since freetype will reference from memory pointer + xl_names=[] + for i in range(len(source)): + print("Appending font: "+source[i].srcnode().abspath) + f = open(source[i].srcnode().abspath,"rb") + buf = f.read() + import os.path + + name = os.path.splitext(os.path.basename(source[i].srcnode().abspath))[0] + + g.write("static const int _font_"+name+"_size="+str(len(buf))+";\n") + g.write("static const unsigned char _font_"+name+"[]={\n") + for i in range(len(buf)): + g.write(str(ord(buf[i]))+",\n") + + g.write("};\n") + + g.write("#endif") + + if (env["tools"]!="no"): - import glob + import glob - dir = env.Dir('.').abspath - tlist = glob.glob(dir + "/translations/*.po") + dir = env.Dir('.').abspath + tlist = glob.glob(dir + "/translations/*.po") - print("translations: ",tlist) - env.Depends('#tools/editor/translations.h',tlist) - env.Command('#tools/editor/translations.h',tlist,make_translations_header) + print("translations: ",tlist) + env.Depends('#tools/editor/translations.h',tlist) + env.Command('#tools/editor/translations.h',tlist,make_translations_header) - flist = glob.glob(dir + "/editor_fonts/*.ttf") - flist.append( glob.glob(dir + "/editor_fonts/*.otf") ) + flist = glob.glob(dir + "/editor_fonts/*.ttf") + flist.append( glob.glob(dir + "/editor_fonts/*.otf") ) - print("fonts: ",flist) - env.Depends('#tools/editor/builtin_fonts.h',flist) - env.Command('#tools/editor/builtin_fonts.h',flist,make_fonts_header) + print("fonts: ",flist) + env.Depends('#tools/editor/builtin_fonts.h',flist) + env.Command('#tools/editor/builtin_fonts.h',flist,make_fonts_header) - SConscript('editor/SCsub'); - SConscript('collada/SCsub'); - SConscript('doc/SCsub') + SConscript('editor/SCsub'); + SConscript('collada/SCsub'); + SConscript('doc/SCsub') - lib = env.Library("tool",env.tool_sources) + lib = env.Library("tool",env.tool_sources) - env.Prepend(LIBS=[lib]) + env.Prepend(LIBS=[lib]) diff --git a/tools/editor/SCsub b/tools/editor/SCsub index f6cb16dc24..41b4386e21 100644 --- a/tools/editor/SCsub +++ b/tools/editor/SCsub @@ -5,51 +5,51 @@ Import('env') def make_doc_header(target,source,env): - src = source[0].srcnode().abspath - dst = target[0].srcnode().abspath - f = open(src,"rb") - g = open(dst,"wb") - buf = f.read() - decomp_size = len(buf) - import zlib - buf = zlib.compress(buf) + src = source[0].srcnode().abspath + dst = target[0].srcnode().abspath + f = open(src,"rb") + g = open(dst,"wb") + buf = f.read() + decomp_size = len(buf) + import zlib + buf = zlib.compress(buf) - g.write("/* THIS FILE IS GENERATED DO NOT EDIT */\n") - g.write("#ifndef _DOC_DATA_RAW_H\n") - g.write("#define _DOC_DATA_RAW_H\n") - g.write("static const int _doc_data_compressed_size="+str(len(buf))+";\n") - g.write("static const int _doc_data_uncompressed_size="+str(decomp_size)+";\n") - g.write("static const unsigned char _doc_data_compressed[]={\n") - for i in range(len(buf)): - g.write(str(ord(buf[i]))+",\n") - g.write("};\n") - g.write("#endif") + g.write("/* THIS FILE IS GENERATED DO NOT EDIT */\n") + g.write("#ifndef _DOC_DATA_RAW_H\n") + g.write("#define _DOC_DATA_RAW_H\n") + g.write("static const int _doc_data_compressed_size="+str(len(buf))+";\n") + g.write("static const int _doc_data_uncompressed_size="+str(decomp_size)+";\n") + g.write("static const unsigned char _doc_data_compressed[]={\n") + for i in range(len(buf)): + g.write(str(ord(buf[i]))+",\n") + g.write("};\n") + g.write("#endif") def make_certs_header(target,source,env): - src = source[0].srcnode().abspath - dst = target[0].srcnode().abspath - f = open(src,"rb") - g = open(dst,"wb") - buf = f.read() - decomp_size = len(buf) - import zlib - buf = zlib.compress(buf) + src = source[0].srcnode().abspath + dst = target[0].srcnode().abspath + f = open(src,"rb") + g = open(dst,"wb") + buf = f.read() + decomp_size = len(buf) + import zlib + buf = zlib.compress(buf) - g.write("/* THIS FILE IS GENERATED DO NOT EDIT */\n") - g.write("#ifndef _CERTS_RAW_H\n") - g.write("#define _CERTS_RAW_H\n") - g.write("static const int _certs_compressed_size="+str(len(buf))+";\n") - g.write("static const int _certs_uncompressed_size="+str(decomp_size)+";\n") - g.write("static const unsigned char _certs_compressed[]={\n") - for i in range(len(buf)): - g.write(str(ord(buf[i]))+",\n") - g.write("};\n") - g.write("#endif") + g.write("/* THIS FILE IS GENERATED DO NOT EDIT */\n") + g.write("#ifndef _CERTS_RAW_H\n") + g.write("#define _CERTS_RAW_H\n") + g.write("static const int _certs_compressed_size="+str(len(buf))+";\n") + g.write("static const int _certs_uncompressed_size="+str(decomp_size)+";\n") + g.write("static const unsigned char _certs_compressed[]={\n") + for i in range(len(buf)): + g.write(str(ord(buf[i]))+",\n") + g.write("};\n") + g.write("#endif") @@ -59,30 +59,30 @@ def make_certs_header(target,source,env): if (env["tools"]=="yes"): - reg_exporters_inc='#include "register_exporters.h"\n' - reg_exporters='void register_exporters() {\n' - for e in env.platform_exporters: - env.tool_sources.append("#platform/"+e+"/export/export.cpp") - reg_exporters+='\tregister_'+e+'_exporter();\n' - reg_exporters_inc+='#include "platform/'+e+'/export/export.h"\n' - reg_exporters+='}\n' - f = open("register_exporters.cpp","wb") - f.write(reg_exporters_inc) - f.write(reg_exporters) - f.close() - - env.Depends("#tools/editor/doc_data_compressed.h","#doc/base/classes.xml") - env.Command("#tools/editor/doc_data_compressed.h","#doc/base/classes.xml",make_doc_header) - - env.Depends("#tools/editor/certs_compressed.h","#tools/certs/ca-certificates.crt") - env.Command("#tools/editor/certs_compressed.h","#tools/certs/ca-certificates.crt",make_certs_header) - - #make_doc_header(env.File("#tools/editor/doc_data_raw.h").srcnode().abspath,env.File("#doc/base/classes.xml").srcnode().abspath,env) - - env.add_source_files(env.tool_sources,"*.cpp") - - Export('env') - SConscript('icons/SCsub'); - SConscript('plugins/SCsub'); - SConscript('fileserver/SCsub'); - SConscript('io_plugins/SCsub'); + reg_exporters_inc='#include "register_exporters.h"\n' + reg_exporters='void register_exporters() {\n' + for e in env.platform_exporters: + env.tool_sources.append("#platform/"+e+"/export/export.cpp") + reg_exporters+='\tregister_'+e+'_exporter();\n' + reg_exporters_inc+='#include "platform/'+e+'/export/export.h"\n' + reg_exporters+='}\n' + f = open("register_exporters.cpp","wb") + f.write(reg_exporters_inc) + f.write(reg_exporters) + f.close() + + env.Depends("#tools/editor/doc_data_compressed.h","#doc/base/classes.xml") + env.Command("#tools/editor/doc_data_compressed.h","#doc/base/classes.xml",make_doc_header) + + env.Depends("#tools/editor/certs_compressed.h","#tools/certs/ca-certificates.crt") + env.Command("#tools/editor/certs_compressed.h","#tools/certs/ca-certificates.crt",make_certs_header) + + #make_doc_header(env.File("#tools/editor/doc_data_raw.h").srcnode().abspath,env.File("#doc/base/classes.xml").srcnode().abspath,env) + + env.add_source_files(env.tool_sources,"*.cpp") + + Export('env') + SConscript('icons/SCsub'); + SConscript('plugins/SCsub'); + SConscript('fileserver/SCsub'); + SConscript('io_plugins/SCsub'); diff --git a/tools/editor/icons/SCsub b/tools/editor/icons/SCsub index 9e05d8f391..4806a89df2 100644 --- a/tools/editor/icons/SCsub +++ b/tools/editor/icons/SCsub @@ -4,93 +4,93 @@ Import('env') def make_editor_icons_action(target, source, env): - import os - import cStringIO + import os + import cStringIO - dst = target[0].srcnode().abspath - pixmaps = source + dst = target[0].srcnode().abspath + pixmaps = source - s = cStringIO.StringIO() + s = cStringIO.StringIO() - s.write("#include \"editor_icons.h\"\n\n") - s.write("#include \"editor_scale.h\"\n\n") - s.write("#include \"scene/resources/theme.h\"\n\n") + s.write("#include \"editor_icons.h\"\n\n") + s.write("#include \"editor_scale.h\"\n\n") + s.write("#include \"scene/resources/theme.h\"\n\n") - hidpi_list=[] + hidpi_list=[] - for x in pixmaps: + for x in pixmaps: - x=str(x) - var_str=os.path.basename(x)[:-4]+"_png"; - #print(var_str) + x=str(x) + var_str=os.path.basename(x)[:-4]+"_png"; + #print(var_str) - s.write("static const unsigned char "+ var_str +"[]={\n"); + s.write("static const unsigned char "+ var_str +"[]={\n"); - pngf=open(x,"rb"); + pngf=open(x,"rb"); - b=pngf.read(1); - while(len(b)==1): - s.write(hex(ord(b))) - b=pngf.read(1); - if (len(b)==1): - s.write(",") + b=pngf.read(1); + while(len(b)==1): + s.write(hex(ord(b))) + b=pngf.read(1); + if (len(b)==1): + s.write(",") - s.write("\n};\n\n"); + s.write("\n};\n\n"); - pngf.close(); - var_str=os.path.basename(x)[:-4]+"_hidpi_png"; - try: + pngf.close(); + var_str=os.path.basename(x)[:-4]+"_hidpi_png"; + try: - pngf = open(os.path.dirname(x)+"/2x/"+os.path.basename(x), "rb") + pngf = open(os.path.dirname(x)+"/2x/"+os.path.basename(x), "rb") - s.write("static const unsigned char "+ var_str +"[]={\n"); + s.write("static const unsigned char "+ var_str +"[]={\n"); - b=pngf.read(1); - while(len(b)==1): - s.write(hex(ord(b))) - b=pngf.read(1); - if (len(b)==1): - s.write(",") + b=pngf.read(1); + while(len(b)==1): + s.write(hex(ord(b))) + b=pngf.read(1); + if (len(b)==1): + s.write(",") - s.write("\n};\n\n\n"); - hidpi_list.append(x) + s.write("\n};\n\n\n"); + hidpi_list.append(x) - except: - s.write("static const unsigned char* "+ var_str +"=NULL;\n\n\n"); + except: + s.write("static const unsigned char* "+ var_str +"=NULL;\n\n\n"); - s.write("static Ref<ImageTexture> make_icon(const uint8_t* p_png,const uint8_t* p_hidpi_png) {\n") - s.write("\tRef<ImageTexture> texture( memnew( ImageTexture ) );\n") - s.write("\tbool use_hidpi_image=(editor_get_scale()>1.0&&p_hidpi_png);\n") - s.write("\tImage img(use_hidpi_image?p_hidpi_png:p_png);\n") - s.write("\tif (editor_get_scale()>1.0 && !p_hidpi_png) { img.convert(Image::FORMAT_RGBA); img.expand_x2_hq2x(); use_hidpi_image=true;}\n") - s.write("\timg.resize(img.get_width()*EDSCALE/(use_hidpi_image?2:1),img.get_height()*EDSCALE/(use_hidpi_image?2:1));\n") - s.write("\ttexture->create_from_image( img,ImageTexture::FLAG_FILTER );\n") - s.write("\treturn texture;\n") - s.write("}\n\n") + s.write("static Ref<ImageTexture> make_icon(const uint8_t* p_png,const uint8_t* p_hidpi_png) {\n") + s.write("\tRef<ImageTexture> texture( memnew( ImageTexture ) );\n") + s.write("\tbool use_hidpi_image=(editor_get_scale()>1.0&&p_hidpi_png);\n") + s.write("\tImage img(use_hidpi_image?p_hidpi_png:p_png);\n") + s.write("\tif (editor_get_scale()>1.0 && !p_hidpi_png) { img.convert(Image::FORMAT_RGBA); img.expand_x2_hq2x(); use_hidpi_image=true;}\n") + s.write("\timg.resize(img.get_width()*EDSCALE/(use_hidpi_image?2:1),img.get_height()*EDSCALE/(use_hidpi_image?2:1));\n") + s.write("\ttexture->create_from_image( img,ImageTexture::FLAG_FILTER );\n") + s.write("\treturn texture;\n") + s.write("}\n\n") - s.write("void editor_register_icons(Ref<Theme> p_theme) {\n\n") + s.write("void editor_register_icons(Ref<Theme> p_theme) {\n\n") - for x in pixmaps: + for x in pixmaps: - x=os.path.basename(str(x)) - type=x[5:-4].title().replace("_",""); - var_str=x[:-4]+"_png"; - var_str_hidpi=x[:-4]+"_hidpi_png"; - s.write("\tp_theme->set_icon(\""+type+"\",\"EditorIcons\",make_icon("+var_str+","+var_str_hidpi+"));\n"); + x=os.path.basename(str(x)) + type=x[5:-4].title().replace("_",""); + var_str=x[:-4]+"_png"; + var_str_hidpi=x[:-4]+"_hidpi_png"; + s.write("\tp_theme->set_icon(\""+type+"\",\"EditorIcons\",make_icon("+var_str+","+var_str_hidpi+"));\n"); - s.write("\n\n}\n\n"); + s.write("\n\n}\n\n"); - f = open(dst,"wb") - f.write(s.getvalue()) - f.close() - s.close() + f = open(dst,"wb") + f.write(s.getvalue()) + f.close() + s.close() make_editor_icons_builder = Builder(action=make_editor_icons_action, - suffix = '.cpp', - src_suffix = '.png') + suffix = '.cpp', + src_suffix = '.png') env['BUILDERS']['MakeEditorIconsBuilder']=make_editor_icons_builder env.Alias('editor_icons',[env.MakeEditorIconsBuilder('#tools/editor/editor_icons.cpp',Glob("*.png"))]) diff --git a/tools/scripts/addheader.py b/tools/scripts/addheader.py index d040d8b5d6..fac35372de 100644 --- a/tools/scripts/addheader.py +++ b/tools/scripts/addheader.py @@ -34,39 +34,39 @@ f = open("files","rb") fname = f.readline() while (fname!=""): - fr = open(fname.strip(),"rb") - l = fr.readline() - bc=False - fsingle = fname.strip() + fr = open(fname.strip(),"rb") + l = fr.readline() + bc=False + fsingle = fname.strip() - if (fsingle.find("/")!=-1): - fsingle=fsingle[fsingle.rfind("/")+1:] - rep_fl="$filename" - rep_fi=fsingle - len_fl=len(rep_fl) - len_fi=len(rep_fi) - if (len_fi<len_fl): - for x in range(len_fl-len_fi): - rep_fi+=" " - elif (len_fl<len_fi): - for x in range(len_fi-len_fl): - rep_fl+=" " - if (header.find(rep_fl)!=-1): - text=header.replace(rep_fl,rep_fi) - else: - text=header.replace("$filename",fsingle) + if (fsingle.find("/")!=-1): + fsingle=fsingle[fsingle.rfind("/")+1:] + rep_fl="$filename" + rep_fi=fsingle + len_fl=len(rep_fl) + len_fi=len(rep_fi) + if (len_fi<len_fl): + for x in range(len_fl-len_fi): + rep_fi+=" " + elif (len_fl<len_fi): + for x in range(len_fi-len_fl): + rep_fl+=" " + if (header.find(rep_fl)!=-1): + text=header.replace(rep_fl,rep_fi) + else: + text=header.replace("$filename",fsingle) - while (l!=""): - if ((l.find("//")!=0 and l.find("/*")!=0 and l.strip()!="") or bc): - text+=l - bc=True - l=fr.readline() + while (l!=""): + if ((l.find("//")!=0 and l.find("/*")!=0 and l.strip()!="") or bc): + text+=l + bc=True + l=fr.readline() - fr.close() - fr=open(fname.strip(),"wb") - fr.write(text) - fr.close() - #print(text) - fname=f.readline() + fr.close() + fr=open(fname.strip(),"wb") + fr.write(text) + fr.close() + #print(text) + fname=f.readline() diff --git a/tools/scripts/file-hex-array.py b/tools/scripts/file-hex-array.py index 05352396f1..f50dcd4e26 100755 --- a/tools/scripts/file-hex-array.py +++ b/tools/scripts/file-hex-array.py @@ -3,33 +3,33 @@ import os.path import sys def tof(filepath): - with open(filepath, 'r') as f: - content = f.read() - content = content.replace("0x","") - content = content.split(',') - for i in range(len(content)): - if len(content[i]) == 1: content[i] = "0" + content[i] - content = "".join(content) - with open(filepath+".file", 'wb') as f: - content = f.write(content.decode("hex")) - print(os.path.basename(filepath)+".file created.") - exit(0) + with open(filepath, 'r') as f: + content = f.read() + content = content.replace("0x","") + content = content.split(',') + for i in range(len(content)): + if len(content[i]) == 1: content[i] = "0" + content[i] + content = "".join(content) + with open(filepath+".file", 'wb') as f: + content = f.write(content.decode("hex")) + print(os.path.basename(filepath)+".file created.") + exit(0) def toa(filepath): - with open(filepath, 'rb') as f: - content = f.read() - content = binascii.hexlify(content) - content = [content[i:i+2] for i in range(0, len(content), 2)] - content = ",0x".join(content) - content = "0x" + content - content = content.replace("0x00","0x0") - with open(filepath+".array", 'w') as f: - content = f.write(content) - print(os.path.basename(filepath)+".array created.") - exit(0) + with open(filepath, 'rb') as f: + content = f.read() + content = binascii.hexlify(content) + content = [content[i:i+2] for i in range(0, len(content), 2)] + content = ",0x".join(content) + content = "0x" + content + content = content.replace("0x00","0x0") + with open(filepath+".array", 'w') as f: + content = f.write(content) + print(os.path.basename(filepath)+".array created.") + exit(0) def usage(): - print("========================================================\n\ + print("========================================================\n\ #\n\ # Usage: python file-hex-array.py [action] [option]\n\ #\n\ @@ -40,13 +40,13 @@ def usage(): # Example : python file-hex-array.py toa 1.png\n\ #\n\ ========================================================") - exit(1) + exit(1) if len(sys.argv) != 3: - usage() + usage() if sys.argv[1] == "toa" and os.path.isfile(sys.argv[2]): - toa(sys.argv[2]) + toa(sys.argv[2]) elif sys.argv[1] == "tof" and os.path.isfile(sys.argv[2]): - tof(sys.argv[2]) + tof(sys.argv[2]) else: - usage()
\ No newline at end of file + usage() diff --git a/tools/scripts/make_bmfhdr.py b/tools/scripts/make_bmfhdr.py index 0f6f453004..3fa97c8fe1 100644 --- a/tools/scripts/make_bmfhdr.py +++ b/tools/scripts/make_bmfhdr.py @@ -3,7 +3,7 @@ import sys if (len(sys.argv)!=2): - print("Pass me a .fnt argument!") + print("Pass me a .fnt argument!") f = open(sys.argv[1],"rb") @@ -19,39 +19,39 @@ font_cc=0 while(l!=""): - fs = l.strip().find(" ") - if (fs==-1): - l=f.readline() - continue - t = l[0:fs] + fs = l.strip().find(" ") + if (fs==-1): + l=f.readline() + continue + t = l[0:fs] - dv = l[fs+1:].split(" ") - d = {} - for x in dv: - if (x.find("=")==-1): - continue - s = x.split("=") - d[ s[0] ] = s[1] + dv = l[fs+1:].split(" ") + d = {} + for x in dv: + if (x.find("=")==-1): + continue + s = x.split("=") + d[ s[0] ] = s[1] - if (t=="common"): - font_height=d["lineHeight"] - font_ascent=d["base"] + if (t=="common"): + font_height=d["lineHeight"] + font_ascent=d["base"] - if (t=="char"): - font_chars.append(d["id"]) - font_chars.append(d["x"]) - font_chars.append(d["y"]) - font_chars.append(d["width"]) - font_chars.append(d["height"]) - font_chars.append(d["xoffset"]) - font_chars.append(d["yoffset"]) - font_chars.append(d["xadvance"]) - font_cc+=1 + if (t=="char"): + font_chars.append(d["id"]) + font_chars.append(d["x"]) + font_chars.append(d["y"]) + font_chars.append(d["width"]) + font_chars.append(d["height"]) + font_chars.append(d["xoffset"]) + font_chars.append(d["yoffset"]) + font_chars.append(d["xadvance"]) + font_cc+=1 - l = f.readline() + l = f.readline() print("static const int _bi_font_"+name+"_height="+str(font_height)+";") @@ -60,11 +60,11 @@ print("static const int _bi_font_"+name+"_charcount="+str(font_cc)+";") cstr="static const int _bi_font_"+name+"_characters={" for i in range(len(font_chars)): - c=font_chars[i] - if (i>0): - cstr+=", " - cstr+=c + c=font_chars[i] + if (i>0): + cstr+=", " + cstr+=c cstr+=("};") -print(cstr)
\ No newline at end of file +print(cstr) diff --git a/tools/scripts/make_glwrapper.py b/tools/scripts/make_glwrapper.py index b4c582f1eb..8da4e28c89 100644 --- a/tools/scripts/make_glwrapper.py +++ b/tools/scripts/make_glwrapper.py @@ -2,8 +2,8 @@ import sys if (len(sys.argv)<2): - print("usage: make_glwrapper.py <headers>") - sys.exit(255) + print("usage: make_glwrapper.py <headers>") + sys.exit(255) functions=[] @@ -17,16 +17,16 @@ READ_CONSTANTS=2 read_what=READ_TYPES for x in (range(len(sys.argv)-1)): - f=open(sys.argv[x+1],"r") + f=open(sys.argv[x+1],"r") - while(True): + while(True): - line=f.readline() - if (line==""): - break + line=f.readline() + if (line==""): + break - line=line.replace("\n","").strip() - """ + line=line.replace("\n","").strip() + """ if (line.find("[types]")!=-1): read_what=READ_TYPES continue @@ -38,53 +38,53 @@ for x in (range(len(sys.argv)-1)): continue """ - if (line.find("#define")!=-1): - if (line.find("0x")==-1 and line.find("GL_VERSION")==-1): - continue - constants.append(line) - elif (line.find("typedef")!=-1): - if (line.find("(")!=-1 or line.find(")")!=-1 or line.find("ARB")!=-1 or line.find("EXT")!=-1 or line.find("GL")==-1): - continue - types.append(line) - elif (line.find("APIENTRY")!=-1 and line.find("GLAPI")!=-1): + if (line.find("#define")!=-1): + if (line.find("0x")==-1 and line.find("GL_VERSION")==-1): + continue + constants.append(line) + elif (line.find("typedef")!=-1): + if (line.find("(")!=-1 or line.find(")")!=-1 or line.find("ARB")!=-1 or line.find("EXT")!=-1 or line.find("GL")==-1): + continue + types.append(line) + elif (line.find("APIENTRY")!=-1 and line.find("GLAPI")!=-1): - if (line.find("ARB")!=-1 or line.find("EXT")!=-1 or line.find("NV")!=-1): - continue + if (line.find("ARB")!=-1 or line.find("EXT")!=-1 or line.find("NV")!=-1): + continue - line=line.replace("APIENTRY","") - line=line.replace("GLAPI","") + line=line.replace("APIENTRY","") + line=line.replace("GLAPI","") - glpos=line.find(" gl") - if (glpos==-1): + glpos=line.find(" gl") + if (glpos==-1): - glpos=line.find("\tgl") - if (glpos==-1): - continue + glpos=line.find("\tgl") + if (glpos==-1): + continue - ret=line[:glpos].strip(); + ret=line[:glpos].strip(); - line=line[glpos:].strip() - namepos=line.find("(") + line=line[glpos:].strip() + namepos=line.find("(") - if (namepos==-1): - continue + if (namepos==-1): + continue - name=line[:namepos].strip() - line=line[namepos:] + name=line[:namepos].strip() + line=line[namepos:] - argpos=line.rfind(")") - if (argpos==-1): - continue + argpos=line.rfind(")") + if (argpos==-1): + continue - args=line[1:argpos] + args=line[1:argpos] - funcdata={} - funcdata["ret"]=ret - funcdata["name"]=name - funcdata["args"]=args + funcdata={} + funcdata["ret"]=ret + funcdata["name"]=name + funcdata["args"]=args - functions.append(funcdata) - print(funcdata) + functions.append(funcdata) + print(funcdata) @@ -137,18 +137,18 @@ f.write("#else\n"); f.write("#define GLWRP_APIENTRY \n") f.write("#endif\n\n"); for x in types: - f.write(x+"\n") + f.write(x+"\n") f.write("\n\n") for x in constants: - f.write(x+"\n") + f.write(x+"\n") f.write("\n\n") for x in functions: - f.write("extern "+x["ret"]+" GLWRP_APIENTRY (*__wrapper_"+x["name"]+")("+x["args"]+");\n") - f.write("#define "+x["name"]+" __wrapper_"+x["name"]+"\n") + f.write("extern "+x["ret"]+" GLWRP_APIENTRY (*__wrapper_"+x["name"]+")("+x["args"]+");\n") + f.write("#define "+x["name"]+" __wrapper_"+x["name"]+"\n") f.write("\n\n") f.write("typedef void (*GLWrapperFuncPtr)(void);\n\n"); @@ -165,14 +165,14 @@ f.write("#include \"glwrapper.h\"\n") f.write("\n\n") for x in functions: - f.write(x["ret"]+" GLWRP_APIENTRY (*__wrapper_"+x["name"]+")("+x["args"]+")=NULL;\n") + f.write(x["ret"]+" GLWRP_APIENTRY (*__wrapper_"+x["name"]+")("+x["args"]+")=NULL;\n") f.write("\n\n") f.write("void glWrapperInit( GLWrapperFuncPtr (*wrapperFunc)(const char*) ) {\n") f.write("\n") for x in functions: - f.write("\t__wrapper_"+x["name"]+"=("+x["ret"]+" GLWRP_APIENTRY (*)("+x["args"]+"))wrapperFunc(\""+x["name"]+"\");\n") + f.write("\t__wrapper_"+x["name"]+"=("+x["ret"]+" GLWRP_APIENTRY (*)("+x["args"]+"))wrapperFunc(\""+x["name"]+"\");\n") f.write("\n\n") f.write("}\n") diff --git a/tools/scripts/makeargs.py b/tools/scripts/makeargs.py index 8c5539c5fe..7db9da82a8 100644 --- a/tools/scripts/makeargs.py +++ b/tools/scripts/makeargs.py @@ -67,20 +67,20 @@ text=""" for i in range(1,8): - tp="" - p="" - t="" - for j in range(i): - if (j>0): - tp+=", " - p+=", " - t+=", " - tp +=("m_arg"+str(j+1)+" p"+str(j+1)) - p+=("p"+str(j+1)) - t+=("m_arg"+str(j+1)) - - t = text.replace("$argtp",tp).replace("$argp",p).replace("$argt",t).replace("$num",str(i)) - print(t) + tp="" + p="" + t="" + for j in range(i): + if (j>0): + tp+=", " + p+=", " + t+=", " + tp +=("m_arg"+str(j+1)+" p"+str(j+1)) + p+=("p"+str(j+1)) + t+=("m_arg"+str(j+1)) + + t = text.replace("$argtp",tp).replace("$argp",p).replace("$argt",t).replace("$num",str(i)) + print(t) diff --git a/tools/scripts/memsort.py b/tools/scripts/memsort.py index d2e4fe0226..15b4e7a84b 100644 --- a/tools/scripts/memsort.py +++ b/tools/scripts/memsort.py @@ -4,7 +4,7 @@ import sys arg="memdump.txt" if (len(sys.argv)>1): - arg=sys.argv[1] + arg=sys.argv[1] f = open(arg,"rb") @@ -18,18 +18,18 @@ cnt={} while(l!=""): - s=l.split("-") - amount = int(s[1]) - what=s[2] - if (what in sum): - sum[what]+=amount - cnt[what]+=1 - else: - sum[what]=amount - cnt[what]=1 + s=l.split("-") + amount = int(s[1]) + what=s[2] + if (what in sum): + sum[what]+=amount + cnt[what]+=1 + else: + sum[what]=amount + cnt[what]=1 - l=f.readline() + l=f.readline() for x in sum: - print(x.strip()+"("+str(cnt[x])+"):\n: "+str(sum[x])) + print(x.strip()+"("+str(cnt[x])+"):\n: "+str(sum[x])) diff --git a/tools/scripts/svgs_2_pngs.py b/tools/scripts/svgs_2_pngs.py index 879926ab42..4de69a14b4 100644 --- a/tools/scripts/svgs_2_pngs.py +++ b/tools/scripts/svgs_2_pngs.py @@ -130,8 +130,8 @@ special_icons = { } theme_icons = { - 'icon_close': dict(output_names=['close', 'close_hl']), - 'tab_menu': dict(output_names=['tab_menu_hl']) + 'icon_close': dict(output_names=['close', 'close_hl']), + 'tab_menu': dict(output_names=['tab_menu_hl']) } export_icons() diff --git a/tools/translations/extract.py b/tools/translations/extract.py index 61b07b5799..f2ee1ecb19 100755 --- a/tools/translations/extract.py +++ b/tools/translations/extract.py @@ -10,27 +10,27 @@ import sys line_nb = False for arg in sys.argv[1:]: - if (arg == "--with-line-nb"): - print("Enabling line numbers in the context locations.") - line_nb = True - else: - os.sys.exit("Non supported argument '" + arg + "'. Aborting.") + if (arg == "--with-line-nb"): + print("Enabling line numbers in the context locations.") + line_nb = True + else: + os.sys.exit("Non supported argument '" + arg + "'. Aborting.") if (not os.path.exists("tools")): - os.sys.exit("ERROR: This script should be started from the root of the git repo.") + os.sys.exit("ERROR: This script should be started from the root of the git repo.") matches = [] for root, dirnames, filenames in os.walk('.'): - for filename in fnmatch.filter(filenames, '*.cpp'): - if (filename.find("collada") != -1): - continue - matches.append(os.path.join(root, filename)) - for filename in fnmatch.filter(filenames, '*.h'): - if (filename.find("collada") != -1): - continue - matches.append(os.path.join(root, filename)) + for filename in fnmatch.filter(filenames, '*.cpp'): + if (filename.find("collada") != -1): + continue + matches.append(os.path.join(root, filename)) + for filename in fnmatch.filter(filenames, '*.h'): + if (filename.find("collada") != -1): + continue + matches.append(os.path.join(root, filename)) matches.sort() @@ -55,51 +55,51 @@ print("Updating the tools.pot template...") for fname in matches: - f = open(fname, "rb") - - l = f.readline() - lc = 1 - while (l): - - patterns = ['RTR(\"', 'TTR(\"'] - idx = 0 - pos = 0 - while (pos >= 0): - pos = l.find(patterns[idx], pos) - if (pos == -1): - if (idx < len(patterns) - 1): - idx += 1 - pos = 0 - continue - pos += 5 - - msg = "" - while (pos < len(l) and (l[pos] != '"' or l[pos - 1] == '\\')): - msg += l[pos] - pos += 1 - - location = os.path.relpath(fname).replace('\\','/') - if (line_nb): - location += ":" + str(lc) - - if (not msg in unique_str): - main_po += "\n#: " + location + "\n" - main_po += 'msgid "' + msg + '"\n' - main_po += 'msgstr ""\n' - unique_str.append(msg) - unique_loc[msg] = [location] - elif (not location in unique_loc[msg]): - # Add additional location to previous occurence too - msg_pos = main_po.find('\nmsgid "' + msg + '"') - if (msg_pos == -1): - print("Someone apparently thought writing Python was as easy as GDScript. Ping Akien.") - main_po = main_po[:msg_pos] + ' ' + location + main_po[msg_pos:] - unique_loc[msg].append(location) - - l = f.readline() - lc += 1 - - f.close() + f = open(fname, "rb") + + l = f.readline() + lc = 1 + while (l): + + patterns = ['RTR(\"', 'TTR(\"'] + idx = 0 + pos = 0 + while (pos >= 0): + pos = l.find(patterns[idx], pos) + if (pos == -1): + if (idx < len(patterns) - 1): + idx += 1 + pos = 0 + continue + pos += 5 + + msg = "" + while (pos < len(l) and (l[pos] != '"' or l[pos - 1] == '\\')): + msg += l[pos] + pos += 1 + + location = os.path.relpath(fname).replace('\\','/') + if (line_nb): + location += ":" + str(lc) + + if (not msg in unique_str): + main_po += "\n#: " + location + "\n" + main_po += 'msgid "' + msg + '"\n' + main_po += 'msgstr ""\n' + unique_str.append(msg) + unique_loc[msg] = [location] + elif (not location in unique_loc[msg]): + # Add additional location to previous occurence too + msg_pos = main_po.find('\nmsgid "' + msg + '"') + if (msg_pos == -1): + print("Someone apparently thought writing Python was as easy as GDScript. Ping Akien.") + main_po = main_po[:msg_pos] + ' ' + location + main_po[msg_pos:] + unique_loc[msg].append(location) + + l = f.readline() + lc += 1 + + f.close() f = open("tools.pot", "wb") @@ -107,15 +107,15 @@ f.write(main_po) f.close() if (os.name == "posix"): - print("Wrapping template at 79 characters for compatibility with Weblate.") - os.system("msgmerge -w79 tools.pot tools.pot > tools.pot.wrap") - shutil.move("tools.pot.wrap", "tools.pot") + print("Wrapping template at 79 characters for compatibility with Weblate.") + os.system("msgmerge -w79 tools.pot tools.pot > tools.pot.wrap") + shutil.move("tools.pot.wrap", "tools.pot") shutil.move("tools.pot", "tools/translations/tools.pot") # TODO: Make that in a portable way, if we care; if not, kudos to Unix users if (os.name == "posix"): - added = subprocess.check_output("git diff tools/translations/tools.pot | grep \+msgid | wc -l", shell = True) - removed = subprocess.check_output("git diff tools/translations/tools.pot | grep \\\-msgid | wc -l", shell = True) - print("\n# Template changes compared to the staged status:") - print("# Additions: %s msgids.\n# Deletions: %s msgids." % (int(added), int(removed))) + added = subprocess.check_output("git diff tools/translations/tools.pot | grep \+msgid | wc -l", shell = True) + removed = subprocess.check_output("git diff tools/translations/tools.pot | grep \\\-msgid | wc -l", shell = True) + print("\n# Template changes compared to the staged status:") + print("# Additions: %s msgids.\n# Deletions: %s msgids." % (int(added), int(removed))) |