Browse Source

Add support for creating editor icons per module

The functionality is similar to how `doc_classes` are retrieved per module.
The build system will search for custom icons path defined per module via
`get_icons_path()` method in `config.py` or default icons path.
If such paths don't exist, only the editor's own icons will be built.

Most module icons were moved from editor/icons to respective modules.
Andrii Doroshenko (Xrayez) 6 years ago
parent
commit
7c11a1b162

+ 14 - 4
SConstruct

@@ -399,6 +399,7 @@ if selected_platform in platform_list:
     sys.modules.pop('detect')
 
     env.module_list = []
+    env.module_icons_paths = []
     env.doc_class_path = {}
 
     for x in module_list:
@@ -421,13 +422,22 @@ if selected_platform in platform_list:
         if (can_build):
             config.configure(env)
             env.module_list.append(x)
+            
+            # Get doc classes paths (if present)
             try:
-                 doc_classes = config.get_doc_classes()
-                 doc_path = config.get_doc_path()
-                 for c in doc_classes:
-                     env.doc_class_path[c] = "modules/" + x + "/" + doc_path
+                doc_classes = config.get_doc_classes()
+                doc_path = config.get_doc_path()
+                for c in doc_classes:
+                    env.doc_class_path[c] = "modules/" + x + "/" + doc_path
             except:
                 pass
+            # Get icon paths (if present)
+            try:
+                icons_path = config.get_icons_path()
+                env.module_icons_paths.append("modules/" + x + "/" + icons_path)
+            except:
+                # Default path for module icons
+                env.module_icons_paths.append("modules/" + x + "/" + "icons")
 
         sys.path.remove(tmppath)
         sys.modules.pop('config')

+ 9 - 1
editor/icons/SCsub

@@ -10,4 +10,12 @@ make_editor_icons_builder = Builder(action=run_in_subprocess(editor_icons_builde
                                     src_suffix='.svg')
 
 env['BUILDERS']['MakeEditorIconsBuilder'] = make_editor_icons_builder
-env.Alias('editor_icons', [env.MakeEditorIconsBuilder('#editor/editor_icons.gen.h', Glob("*.svg"))])
+
+# Editor's own icons
+icon_sources = Glob("*.svg")
+
+# Module icons
+for module_icons in env.module_icons_paths:
+    icon_sources += Glob('#' + module_icons + "/*.svg")
+
+env.Alias('editor_icons', [env.MakeEditorIconsBuilder('#editor/editor_icons.gen.h', icon_sources)])

+ 0 - 0
editor/icons/icon_c_s_g_box.svg → modules/csg/icons/icon_c_s_g_box.svg


+ 0 - 0
editor/icons/icon_c_s_g_capsule.svg → modules/csg/icons/icon_c_s_g_capsule.svg


+ 0 - 0
editor/icons/icon_c_s_g_combiner.svg → modules/csg/icons/icon_c_s_g_combiner.svg


+ 0 - 0
editor/icons/icon_c_s_g_cylinder.svg → modules/csg/icons/icon_c_s_g_cylinder.svg


+ 0 - 0
editor/icons/icon_c_s_g_mesh.svg → modules/csg/icons/icon_c_s_g_mesh.svg


+ 0 - 0
editor/icons/icon_c_s_g_polygon.svg → modules/csg/icons/icon_c_s_g_polygon.svg


+ 0 - 0
editor/icons/icon_c_s_g_sphere.svg → modules/csg/icons/icon_c_s_g_sphere.svg


+ 0 - 0
editor/icons/icon_c_s_g_torus.svg → modules/csg/icons/icon_c_s_g_torus.svg


+ 0 - 0
editor/icons/icon_g_d_native_library.svg → modules/gdnative/icons/icon_g_d_native_library.svg


+ 0 - 0
editor/icons/icon_native_script.svg → modules/gdnative/icons/icon_native_script.svg


+ 0 - 0
editor/icons/icon_g_d_script.svg → modules/gdscript/icons/icon_g_d_script.svg


+ 0 - 0
editor/icons/icon_grid_map.svg → modules/gridmap/icons/icon_grid_map.svg


+ 0 - 0
editor/icons/icon_noise_texture.svg → modules/opensimplex/icons/icon_noise_texture.svg


+ 0 - 0
editor/icons/icon_visual_script.svg → modules/visual_script/icons/icon_visual_script.svg