mirror of
https://github.com/godotengine/godot.git
synced 2026-01-05 06:11:29 +03:00
Reorder the folders in tools to prepare moving tools/editor
- `certs` and `editor_fonts` go to `thirdparty` - `dist` and `scripts` go to a new `misc` folder - `collada` and `doc` go to `tools/editor` The next step will be to rename `tools/editor` to `editor` directly, but this will be done at the right time to avoid breaking too many PRs.
This commit is contained in:
70
misc/scripts/addheader.py
Normal file
70
misc/scripts/addheader.py
Normal file
@@ -0,0 +1,70 @@
|
||||
header = """\
|
||||
/*************************************************************************/
|
||||
/* $filename */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
/* "Software"), to deal in the Software without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* */
|
||||
/* The above copyright notice and this permission notice shall be */
|
||||
/* included in all copies or substantial portions of the Software. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
"""
|
||||
|
||||
f = open("files", "rb")
|
||||
|
||||
fname = f.readline()
|
||||
while (fname != ""):
|
||||
|
||||
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)
|
||||
|
||||
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()
|
||||
56
misc/scripts/file-hex-array.py
Executable file
56
misc/scripts/file-hex-array.py
Executable file
@@ -0,0 +1,56 @@
|
||||
import binascii
|
||||
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)
|
||||
|
||||
|
||||
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)
|
||||
|
||||
|
||||
def usage():
|
||||
print("========================================================\n\
|
||||
#\n\
|
||||
# Usage: python file-hex-array.py [action] [option]\n\
|
||||
#\n\
|
||||
# Arguments:\n\
|
||||
# action ==> toa # convert file to array [option is file path]\n\
|
||||
# tof # convert array to file [option is array file path]\n\
|
||||
#\n\
|
||||
# Example : python file-hex-array.py toa 1.png\n\
|
||||
#\n\
|
||||
========================================================")
|
||||
exit(1)
|
||||
|
||||
if len(sys.argv) != 3:
|
||||
usage()
|
||||
if sys.argv[1] == "toa" and os.path.isfile(sys.argv[2]):
|
||||
toa(sys.argv[2])
|
||||
elif sys.argv[1] == "tof" and os.path.isfile(sys.argv[2]):
|
||||
tof(sys.argv[2])
|
||||
else:
|
||||
usage()
|
||||
67
misc/scripts/make_bmfhdr.py
Normal file
67
misc/scripts/make_bmfhdr.py
Normal file
@@ -0,0 +1,67 @@
|
||||
|
||||
|
||||
import sys
|
||||
|
||||
if (len(sys.argv) != 2):
|
||||
print("Pass me a .fnt argument!")
|
||||
|
||||
f = open(sys.argv[1], "rb")
|
||||
|
||||
name = sys.argv[1].lower().replace(".fnt", "")
|
||||
|
||||
l = f.readline()
|
||||
|
||||
font_height = 0
|
||||
font_ascent = 0
|
||||
font_charcount = 0
|
||||
font_chars = []
|
||||
font_cc = 0
|
||||
|
||||
while(l != ""):
|
||||
|
||||
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]
|
||||
|
||||
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
|
||||
|
||||
l = f.readline()
|
||||
|
||||
|
||||
print("static const int _bi_font_" + name + "_height=" + str(font_height) + ";")
|
||||
print("static const int _bi_font_" + name + "_ascent=" + str(font_ascent) + ";")
|
||||
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
|
||||
|
||||
cstr += ("};")
|
||||
|
||||
print(cstr)
|
||||
178
misc/scripts/make_glwrapper.py
Normal file
178
misc/scripts/make_glwrapper.py
Normal file
@@ -0,0 +1,178 @@
|
||||
#! /usr/bin/env python
|
||||
import sys
|
||||
|
||||
if (len(sys.argv) < 2):
|
||||
print("usage: make_glwrapper.py <headers>")
|
||||
sys.exit(255)
|
||||
|
||||
|
||||
functions = []
|
||||
types = []
|
||||
constants = []
|
||||
|
||||
READ_FUNCTIONS = 0
|
||||
READ_TYPES = 1
|
||||
READ_CONSTANTS = 2
|
||||
|
||||
read_what = READ_TYPES
|
||||
|
||||
for x in (range(len(sys.argv) - 1)):
|
||||
f = open(sys.argv[x + 1], "r")
|
||||
|
||||
while(True):
|
||||
|
||||
line = f.readline()
|
||||
if (line == ""):
|
||||
break
|
||||
|
||||
line = line.replace("\n", "").strip()
|
||||
"""
|
||||
if (line.find("[types]")!=-1):
|
||||
read_what=READ_TYPES
|
||||
continue
|
||||
elif (line.find("[constants]")!=-1):
|
||||
read=READ_TYPES
|
||||
continue
|
||||
elif (line.find("[functions]")!=-1):
|
||||
read_what=READ_FUNCTIONS
|
||||
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("ARB") != -1 or line.find("EXT") != -1 or line.find("NV") != -1):
|
||||
continue
|
||||
|
||||
line = line.replace("APIENTRY", "")
|
||||
line = line.replace("GLAPI", "")
|
||||
|
||||
glpos = line.find(" gl")
|
||||
if (glpos == -1):
|
||||
|
||||
glpos = line.find("\tgl")
|
||||
if (glpos == -1):
|
||||
continue
|
||||
|
||||
ret = line[:glpos].strip()
|
||||
|
||||
line = line[glpos:].strip()
|
||||
namepos = line.find("(")
|
||||
|
||||
if (namepos == -1):
|
||||
continue
|
||||
|
||||
name = line[:namepos].strip()
|
||||
line = line[namepos:]
|
||||
|
||||
argpos = line.rfind(")")
|
||||
if (argpos == -1):
|
||||
continue
|
||||
|
||||
args = line[1:argpos]
|
||||
|
||||
funcdata = {}
|
||||
funcdata["ret"] = ret
|
||||
funcdata["name"] = name
|
||||
funcdata["args"] = args
|
||||
|
||||
functions.append(funcdata)
|
||||
print(funcdata)
|
||||
|
||||
|
||||
# print(types)
|
||||
# print(constants)
|
||||
# print(functions)
|
||||
|
||||
|
||||
f = open("glwrapper.h", "w")
|
||||
|
||||
f.write("#ifndef GL_WRAPPER\n")
|
||||
f.write("#define GL_WRAPPER\n\n\n")
|
||||
|
||||
header_code = """\
|
||||
#if defined(__gl_h_) || defined(__GL_H__)
|
||||
#error gl.h included before glwrapper.h
|
||||
#endif
|
||||
#if defined(__glext_h_) || defined(__GLEXT_H_)
|
||||
#error glext.h included before glwrapper.h
|
||||
#endif
|
||||
#if defined(__gl_ATI_h_)
|
||||
#error glATI.h included before glwrapper.h
|
||||
#endif
|
||||
|
||||
#define __gl_h_
|
||||
#define __GL_H__
|
||||
#define __glext_h_
|
||||
#define __GLEXT_H_
|
||||
#define __gl_ATI_h_
|
||||
|
||||
#define GL_TRUE 1
|
||||
#define GL_FALSE 0
|
||||
|
||||
#define GL_ZERO 0
|
||||
#define GL_ONE 1
|
||||
#define GL_NONE 0
|
||||
#define GL_NO_ERROR 0
|
||||
|
||||
\n\n
|
||||
"""
|
||||
|
||||
f.write("#include <stddef.h>\n\n\n")
|
||||
|
||||
f.write(header_code)
|
||||
|
||||
f.write("#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n\n")
|
||||
f.write("#if defined(_WIN32) && !defined(__CYGWIN__)\n")
|
||||
f.write("#define GLWRP_APIENTRY __stdcall\n")
|
||||
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("\n\n")
|
||||
|
||||
for x in constants:
|
||||
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("\n\n")
|
||||
f.write("typedef void (*GLWrapperFuncPtr)(void);\n\n")
|
||||
f.write("void glWrapperInit( GLWrapperFuncPtr (*wrapperFunc)(const char*) );\n")
|
||||
|
||||
f.write("#ifdef __cplusplus\n}\n#endif\n")
|
||||
|
||||
f.write("#endif\n\n")
|
||||
|
||||
f = open("glwrapper.c", "w")
|
||||
|
||||
f.write("\n\n")
|
||||
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("\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("\n\n")
|
||||
f.write("}\n")
|
||||
f.write("\n\n")
|
||||
5
misc/scripts/make_icons.sh
Normal file
5
misc/scripts/make_icons.sh
Normal file
@@ -0,0 +1,5 @@
|
||||
convert -resize 32x32 ../../icon.svg icon32.ico
|
||||
convert -resize 32x32 ../../icon.svg icon32.icns
|
||||
for s in 16 24 32 64 96 128 256; do convert -resize ${s}x$s ../../icon.svg icon$s.png; done
|
||||
zip icons.zip icon*.png
|
||||
rm icon*.png
|
||||
82
misc/scripts/makeargs.py
Normal file
82
misc/scripts/makeargs.py
Normal file
@@ -0,0 +1,82 @@
|
||||
|
||||
text = """
|
||||
#define FUNC$numR(m_r,m_func,$argt)\\
|
||||
virtual m_r m_func($argtp) { \\
|
||||
if (Thread::get_caller_ID()!=server_thread) {\\
|
||||
m_r ret;\\
|
||||
command_queue.push_and_ret( visual_server, &VisualServer::m_func,$argp,&ret);\\
|
||||
return ret;\\
|
||||
} else {\\
|
||||
return visual_server->m_func($argp);\\
|
||||
}\\
|
||||
}
|
||||
|
||||
#define FUNC$numRC(m_r,m_func,$argt)\\
|
||||
virtual m_r m_func($argtp) const { \\
|
||||
if (Thread::get_caller_ID()!=server_thread) {\\
|
||||
m_r ret;\\
|
||||
command_queue.push_and_ret( visual_server, &VisualServer::m_func,$argp,&ret);\\
|
||||
return ret;\\
|
||||
} else {\\
|
||||
return visual_server->m_func($argp);\\
|
||||
}\\
|
||||
}
|
||||
|
||||
|
||||
#define FUNC$numS(m_func,$argt)\\
|
||||
virtual void m_func($argtp) { \\
|
||||
if (Thread::get_caller_ID()!=server_thread) {\\
|
||||
command_queue.push_and_sync( visual_server, &VisualServer::m_func,$argp);\\
|
||||
} else {\\
|
||||
visual_server->m_func($argp);\\
|
||||
}\\
|
||||
}
|
||||
|
||||
#define FUNC$numSC(m_func,$argt)\\
|
||||
virtual void m_func($argtp) const { \\
|
||||
if (Thread::get_caller_ID()!=server_thread) {\\
|
||||
command_queue.push_and_sync( visual_server, &VisualServer::m_func,$argp);\\
|
||||
} else {\\
|
||||
visual_server->m_func($argp);\\
|
||||
}\\
|
||||
}
|
||||
|
||||
|
||||
#define FUNC$num(m_func,$argt)\\
|
||||
virtual void m_func($argtp) { \\
|
||||
if (Thread::get_caller_ID()!=server_thread) {\\
|
||||
command_queue.push( visual_server, &VisualServer::m_func,$argp);\\
|
||||
} else {\\
|
||||
visual_server->m_func($argp);\\
|
||||
}\\
|
||||
}
|
||||
|
||||
#define FUNC$numC(m_func,$argt)\\
|
||||
virtual void m_func($argtp) const { \\
|
||||
if (Thread::get_caller_ID()!=server_thread) {\\
|
||||
command_queue.push( visual_server, &VisualServer::m_func,$argp);\\
|
||||
} else {\\
|
||||
visual_server->m_func($argp);\\
|
||||
}\\
|
||||
}
|
||||
|
||||
|
||||
"""
|
||||
|
||||
|
||||
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)
|
||||
35
misc/scripts/memsort.py
Normal file
35
misc/scripts/memsort.py
Normal file
@@ -0,0 +1,35 @@
|
||||
|
||||
import sys
|
||||
|
||||
arg = "memdump.txt"
|
||||
|
||||
if (len(sys.argv) > 1):
|
||||
arg = sys.argv[1]
|
||||
|
||||
f = open(arg, "rb")
|
||||
|
||||
|
||||
l = f.readline()
|
||||
|
||||
|
||||
sum = {}
|
||||
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
|
||||
|
||||
l = f.readline()
|
||||
|
||||
|
||||
for x in sum:
|
||||
print(x.strip() + "(" + str(cnt[x]) + "):\n: " + str(sum[x]))
|
||||
29
misc/scripts/sort-demos.sh
Normal file
29
misc/scripts/sort-demos.sh
Normal file
@@ -0,0 +1,29 @@
|
||||
#!/bin/bash
|
||||
# When scanning for demos, the project manager sorts them based on their
|
||||
# timestamp, i.e. last modification date. This can make for a pretty
|
||||
# messy output, so this script 'touches' each godot.cfg file in reverse
|
||||
# alphabetical order to ensure a nice listing.
|
||||
#
|
||||
# It's good practice to run it once before packaging demos on the build
|
||||
# server.
|
||||
|
||||
if [ ! -d "demos" ]; then
|
||||
echo "Run this script from the root directory where 'demos/' is contained."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -e demos.list ]; then
|
||||
rm -f demos.list
|
||||
fi
|
||||
|
||||
for dir in 2d 3d gui misc viewport; do
|
||||
find "demos/$dir" -name "godot.cfg" |sort >> demos.list
|
||||
done
|
||||
cat demos.list |sort -r > demos_r.list
|
||||
|
||||
while read line; do
|
||||
touch $line
|
||||
sleep 0.2
|
||||
done < demos_r.list
|
||||
|
||||
#rm -f demos.list demos_r.list
|
||||
137
misc/scripts/svgs_2_pngs.py
Normal file
137
misc/scripts/svgs_2_pngs.py
Normal file
@@ -0,0 +1,137 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Basic exporter for svg icons
|
||||
|
||||
from os import listdir
|
||||
from os.path import isfile, join, dirname, realpath
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
import rsvg
|
||||
import cairo
|
||||
|
||||
last_svg_path = None
|
||||
last_svg_data = None
|
||||
|
||||
SCRIPT_FOLDER = dirname(realpath(__file__)) + '/'
|
||||
theme_dir_base = SCRIPT_FOLDER + '../../scene/resources/default_theme/'
|
||||
theme_dir_source = theme_dir_base + 'source/'
|
||||
icons_dir_base = SCRIPT_FOLDER + '../editor/icons/'
|
||||
icons_dir_2x = icons_dir_base + '2x/'
|
||||
icons_dir_source = icons_dir_base + 'source/'
|
||||
|
||||
|
||||
def svg_to_png(svg_path, png_path, dpi):
|
||||
global last_svg_path, last_svg_data
|
||||
|
||||
zoom = int(dpi / 90)
|
||||
if last_svg_path != svg_path:
|
||||
last_svg_data = open(svg_path, 'r').read()
|
||||
last_svg_path = svg_path
|
||||
svg = rsvg.Handle(data=last_svg_data)
|
||||
img = cairo.ImageSurface(
|
||||
cairo.FORMAT_ARGB32,
|
||||
svg.props.width * zoom,
|
||||
svg.props.height * zoom
|
||||
)
|
||||
ctx = cairo.Context(img)
|
||||
ctx.set_antialias(cairo.ANTIALIAS_DEFAULT)
|
||||
ctx.scale(zoom, zoom)
|
||||
svg.render_cairo(ctx)
|
||||
img.write_to_png('%s.png' % png_path)
|
||||
svg.close()
|
||||
|
||||
|
||||
def export_icons():
|
||||
svgs_path = icons_dir_source
|
||||
|
||||
file_names = [f for f in listdir(svgs_path) if isfile(join(svgs_path, f))]
|
||||
|
||||
for file_name in file_names:
|
||||
# name without extensions
|
||||
name_only = file_name.replace('.svg', '')
|
||||
|
||||
out_icon_names = [name_only] # export to a png with the same file name
|
||||
theme_out_icon_names = []
|
||||
# special cases
|
||||
if special_icons.has_key(name_only):
|
||||
special_icon = special_icons[name_only]
|
||||
if type(special_icon) is dict:
|
||||
if special_icon.get('avoid_self'):
|
||||
out_icon_names = []
|
||||
if special_icon.has_key('output_names'):
|
||||
out_icon_names += special_icon['output_names']
|
||||
if special_icon.has_key('theme_output_names'):
|
||||
theme_out_icon_names += special_icon['theme_output_names']
|
||||
|
||||
source_path = '%s%s.svg' % (svgs_path, name_only)
|
||||
|
||||
for out_icon_name in out_icon_names:
|
||||
svg_to_png(source_path, icons_dir_base + out_icon_name, 90)
|
||||
svg_to_png(source_path, icons_dir_2x + out_icon_name, 180)
|
||||
for theme_out_icon_name in theme_out_icon_names:
|
||||
svg_to_png(source_path, theme_dir_base + theme_out_icon_name, 90)
|
||||
|
||||
|
||||
def export_theme():
|
||||
svgs_path = theme_dir_source
|
||||
file_names = [f for f in listdir(svgs_path) if isfile(join(svgs_path, f))]
|
||||
|
||||
for file_name in file_names:
|
||||
# name without extensions
|
||||
name_only = file_name.replace('.svg', '')
|
||||
|
||||
out_icon_names = [name_only] # export to a png with the same file name
|
||||
# special cases
|
||||
if theme_icons.has_key(name_only):
|
||||
special_icon = theme_icons[name_only]
|
||||
if type(special_icon) is dict:
|
||||
if special_icon.has_key('output_names'):
|
||||
out_icon_names += special_icon['output_names']
|
||||
|
||||
source_path = '%s%s.svg' % (svgs_path, name_only)
|
||||
|
||||
for out_icon_name in out_icon_names:
|
||||
svg_to_png(source_path, theme_dir_base + out_icon_name, 90)
|
||||
|
||||
|
||||
# special cases for icons that will be exported to multiple target pngs or that require transforms.
|
||||
special_icons = {
|
||||
'icon_add_track': dict(
|
||||
output_names=['icon_add'],
|
||||
theme_output_names=['icon_add', 'icon_zoom_more']
|
||||
),
|
||||
'icon_new': dict(output_names=['icon_file']),
|
||||
'icon_animation_tree_player': dict(output_names=['icon_animation_tree']),
|
||||
'icon_tool_rotate': dict(
|
||||
output_names=['icon_reload'],
|
||||
theme_output_names=['icon_reload']
|
||||
),
|
||||
'icon_multi_edit': dict(output_names=['icon_multi_node_edit']),
|
||||
'icon_folder': dict(
|
||||
output_names=['icon_load', 'icon_open'],
|
||||
theme_output_names=['icon_folder']
|
||||
),
|
||||
'icon_file_list': dict(output_names=['icon_enum']),
|
||||
'icon_collision_2d': dict(output_names=['icon_collision_polygon_2d', 'icon_polygon_2d']),
|
||||
'icon_class_list': dict(output_names=['icon_filesystem']),
|
||||
'icon_color_ramp': dict(output_names=['icon_graph_color_ramp']),
|
||||
'icon_translation': dict(output_names=['icon_p_hash_translation']),
|
||||
'icon_shader': dict(output_names=['icon_shader_material', 'icon_material_shader']),
|
||||
'icon_canvas_item_shader_graph': dict(output_names=['icon_material_shader_graph']),
|
||||
|
||||
'icon_color_pick': dict(theme_output_names=['icon_color_pick'], avoid_self=True),
|
||||
'icon_play': dict(theme_output_names=['icon_play']),
|
||||
'icon_stop': dict(theme_output_names=['icon_stop']),
|
||||
'icon_zoom_less': dict(theme_output_names=['icon_zoom_less'], avoid_self=True),
|
||||
'icon_zoom_reset': dict(theme_output_names=['icon_zoom_reset'], avoid_self=True),
|
||||
'icon_snap': dict(theme_output_names=['icon_snap'])
|
||||
}
|
||||
|
||||
theme_icons = {
|
||||
'icon_close': dict(output_names=['close', 'close_hl']),
|
||||
'tab_menu': dict(output_names=['tab_menu_hl'])
|
||||
}
|
||||
|
||||
export_icons()
|
||||
export_theme()
|
||||
Reference in New Issue
Block a user