diff options
author | Juan Linietsky <reduzio@gmail.com> | 2016-06-08 17:48:31 -0300 |
---|---|---|
committer | Juan Linietsky <reduzio@gmail.com> | 2016-06-08 17:49:06 -0300 |
commit | c1705899299566609fece7ff890c658505557f19 (patch) | |
tree | 1483364347688fc85492e2ab4525471f110e2ea5 /tools | |
parent | 73fa537472eeb216bfbd98deb80290b995c040ba (diff) |
-properly use hidpi icons in hidpi, looks pretty!
Diffstat (limited to 'tools')
-rw-r--r-- | tools/editor/icons/SCsub | 39 |
1 files changed, 34 insertions, 5 deletions
diff --git a/tools/editor/icons/SCsub b/tools/editor/icons/SCsub index f3216b092d..7132968c88 100644 --- a/tools/editor/icons/SCsub +++ b/tools/editor/icons/SCsub @@ -14,6 +14,8 @@ def make_editor_icons_action(target, source, env): s.write("#include \"editor_scale.h\"\n\n") s.write("#include \"scene/resources/theme.h\"\n\n") + hidpi_list=[] + for x in pixmaps: x=str(x) @@ -31,13 +33,39 @@ def make_editor_icons_action(target, source, env): if (len(b)==1): s.write(",") - s.write("\n};\n\n\n"); + s.write("\n};\n\n"); + pngf.close(); + var_str=os.path.basename(x)[:-4]+"_hidpi_png"; +#print("TRY OPEN: "+os.path.dirname(x)+"/2x/"+os.path.basename(x)+"\n") + try: + + pngf = open(os.path.dirname(x)+"/2x/"+os.path.basename(x)) + + #print(var_str) + + 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(",") + + s.write("\n};\n\n\n"); + hidpi_list.append(x) + + 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) {\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("\tImage img(p_png);\n") - s.write("\tif (editor_is_hidpi()) img.expand_x2_hq2x();\n") + s.write("\tImage img((editor_is_hidpi()&&p_hidpi_png)?p_hidpi_png:p_png);\n") + s.write("\tif (editor_is_hidpi() && !p_hidpi_png) img.expand_x2_hq2x();\n") s.write("\ttexture->create_from_image( img,ImageTexture::FLAG_FILTER );\n") s.write("\treturn texture;\n") s.write("}\n\n") @@ -49,7 +77,8 @@ def make_editor_icons_action(target, source, env): x=os.path.basename(str(x)) type=x[5:-4].title().replace("_",""); var_str=x[:-4]+"_png"; - s.write("\tp_theme->set_icon(\""+type+"\",\"EditorIcons\",make_icon("+var_str+"));\n"); + 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"); |