godot/tools/editor/icons/SCsub
Juan Linietsky 3e8eb396d7 Finalized DynamicFont implementation
-DynamicFont uses Freetype by default
-Editor fonts are now scalable thanks to this
-Cleaned up documentation browser and added fonts for this
2016-05-29 11:37:52 -03:00

68 lines
1.6 KiB
Plaintext

Import('env')
def make_editor_icons_action(target, source, env):
import os
import cStringIO
dst = target[0].srcnode().abspath
pixmaps = source
s = cStringIO.StringIO()
s.write("#include \"editor_icons.h\"\n\n")
s.write("#include \"scene/resources/theme.h\"\n\n")
for x in pixmaps:
x=str(x)
var_str=os.path.basename(x)[:-4]+"_png";
#print(var_str)
s.write("static const unsigned char "+ var_str +"[]={\n");
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(",")
s.write("\n};\n\n\n");
pngf.close();
s.write("static Ref<ImageTexture> make_icon(const uint8_t* p_png) {\n")
s.write("\tRef<ImageTexture> texture( memnew( ImageTexture ) );\n")
s.write("\tImage img(p_png);\n")
#s.write("\timg.expand_x2_hq2x();\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")
for x in pixmaps:
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");
s.write("\n\n}\n\n");
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')
env['BUILDERS']['MakeEditorIconsBuilder']=make_editor_icons_builder
env.Alias('editor_icons',[env.MakeEditorIconsBuilder('#tools/editor/editor_icons.cpp',Glob("*.png"))])
env.tool_sources.append("#tools/editor/editor_icons.cpp")
Export('env')