Auto generate editor_icons.cpp to make it more easy to update editor icons
This commit is contained in:
parent
45a509282e
commit
f5421cdaf3
4 changed files with 51 additions and 2254 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -15,6 +15,7 @@ core/method_bind.inc
|
|||
core/global_defaults.cpp
|
||||
tools/editor/register_exporters.cpp
|
||||
tools/editor/doc_data_compressed.h
|
||||
tools/editor/editor_icons.cpp
|
||||
-fpic
|
||||
|
||||
# Android specific
|
||||
|
|
|
@ -48,6 +48,8 @@ if (env["tools"]=="yes"):
|
|||
env.Command("#tools/editor/doc_data_compressed.h","#doc/base/classes.xml",make_doc_header)
|
||||
|
||||
#make_doc_header(env.File("#tools/editor/doc_data_raw.h").srcnode().abspath,env.File("#doc/base/classes.xml").srcnode().abspath,env)
|
||||
|
||||
SConscript('icons/SCsub');
|
||||
env.add_source_files(env.tool_sources,"*.cpp")
|
||||
|
||||
Export('env')
|
||||
|
|
File diff suppressed because one or more lines are too long
48
tools/editor/icons/SCsub
Normal file
48
tools/editor/icons/SCsub
Normal file
|
@ -0,0 +1,48 @@
|
|||
Import('env')
|
||||
|
||||
def make_editor_icons():
|
||||
|
||||
import glob
|
||||
|
||||
pixmaps = glob.glob("*.png")
|
||||
|
||||
f = open("../editor_icons.cpp","wb")
|
||||
f.write("#include \"editor_icons.h\"\n\n")
|
||||
f.write("#include \"scene/resources/theme.h\"\n\n")
|
||||
|
||||
for x in pixmaps:
|
||||
|
||||
var_str=x[:-4]+"_png";
|
||||
|
||||
f.write("static const unsigned char "+ var_str +"[]={\n");
|
||||
|
||||
pngf=open(x,"rb");
|
||||
|
||||
b=pngf.read(1);
|
||||
while(len(b)==1):
|
||||
f.write(hex(ord(b)))
|
||||
b=pngf.read(1);
|
||||
if (len(b)==1):
|
||||
f.write(",")
|
||||
|
||||
f.write("\n};\n\n\n");
|
||||
pngf.close();
|
||||
|
||||
f.write("static Ref<ImageTexture> make_icon(const uint8_t* p_png) {\n")
|
||||
f.write("\tRef<ImageTexture> texture( memnew( ImageTexture ) );\n")
|
||||
f.write("\ttexture->create_from_image( Image(p_png),ImageTexture::FLAG_FILTER );\n")
|
||||
f.write("\treturn texture;\n")
|
||||
f.write("}\n\n")
|
||||
|
||||
f.write("void editor_register_icons(Ref<Theme> p_theme) {\n\n")
|
||||
|
||||
for x in pixmaps:
|
||||
|
||||
type=x[5:-4].title().replace("_","");
|
||||
var_str=x[:-4]+"_png";
|
||||
f.write("\tp_theme->set_icon(\""+type+"\",\"EditorIcons\",make_icon("+var_str+"));\n");
|
||||
|
||||
f.write("\n\n}\n\n");
|
||||
f.close()
|
||||
|
||||
make_editor_icons()
|
Loading…
Reference in a new issue