Modules: Don't build editor-specific classes in templates

They're moved to an `editor` subfolder so that we can easily handle them
separately.
This commit is contained in:
Rémi Verschelde 2022-03-28 14:10:28 +02:00
parent 41d075de58
commit 5fe6984639
23 changed files with 105 additions and 48 deletions

View file

@ -3,7 +3,10 @@
Import("env") Import("env")
Import("env_modules") Import("env_modules")
# Godot's own source files
env_csg = env_modules.Clone() env_csg = env_modules.Clone()
# Godot's own source files # Godot's own source files
env_csg.add_source_files(env.modules_sources, "*.cpp") env_csg.add_source_files(env.modules_sources, "*.cpp")
if env["tools"]:
env_csg.add_source_files(env.modules_sources, "editor/*.cpp")

View file

@ -30,6 +30,8 @@
#include "csg_gizmos.h" #include "csg_gizmos.h"
#ifdef TOOLS_ENABLED
#include "editor/editor_settings.h" #include "editor/editor_settings.h"
#include "editor/plugins/node_3d_editor_plugin.h" #include "editor/plugins/node_3d_editor_plugin.h"
#include "scene/3d/camera_3d.h" #include "scene/3d/camera_3d.h"
@ -425,3 +427,5 @@ EditorPluginCSG::EditorPluginCSG() {
Ref<CSGShape3DGizmoPlugin> gizmo_plugin = Ref<CSGShape3DGizmoPlugin>(memnew(CSGShape3DGizmoPlugin)); Ref<CSGShape3DGizmoPlugin> gizmo_plugin = Ref<CSGShape3DGizmoPlugin>(memnew(CSGShape3DGizmoPlugin));
Node3DEditor::get_singleton()->add_gizmo_plugin(gizmo_plugin); Node3DEditor::get_singleton()->add_gizmo_plugin(gizmo_plugin);
} }
#endif // TOOLS_ENABLED

View file

@ -31,7 +31,9 @@
#ifndef CSG_GIZMOS_H #ifndef CSG_GIZMOS_H
#define CSG_GIZMOS_H #define CSG_GIZMOS_H
#include "csg_shape.h" #ifdef TOOLS_ENABLED
#include "../csg_shape.h"
#include "editor/editor_plugin.h" #include "editor/editor_plugin.h"
#include "editor/plugins/node_3d_editor_gizmos.h" #include "editor/plugins/node_3d_editor_gizmos.h"
@ -60,4 +62,6 @@ public:
EditorPluginCSG(); EditorPluginCSG();
}; };
#endif // TOOLS_ENABLED
#endif // CSG_GIZMOS_H #endif // CSG_GIZMOS_H

View file

@ -30,12 +30,15 @@
#include "register_types.h" #include "register_types.h"
#include "csg_gizmos.h"
#include "csg_shape.h"
void register_csg_types() {
#ifndef _3D_DISABLED #ifndef _3D_DISABLED
#include "csg_shape.h"
#ifdef TOOLS_ENABLED
#include "editor/csg_gizmos.h"
#endif
void register_csg_types() {
GDREGISTER_ABSTRACT_CLASS(CSGShape3D); GDREGISTER_ABSTRACT_CLASS(CSGShape3D);
GDREGISTER_ABSTRACT_CLASS(CSGPrimitive3D); GDREGISTER_ABSTRACT_CLASS(CSGPrimitive3D);
GDREGISTER_CLASS(CSGMesh3D); GDREGISTER_CLASS(CSGMesh3D);
@ -49,8 +52,9 @@ void register_csg_types() {
#ifdef TOOLS_ENABLED #ifdef TOOLS_ENABLED
EditorPlugins::add_by_type<EditorPluginCSG>(); EditorPlugins::add_by_type<EditorPluginCSG>();
#endif #endif
#endif
} }
void unregister_csg_types() { void unregister_csg_types() {
} }
#endif // _3D_DISABLED

View file

@ -4,7 +4,8 @@ Import("env")
Import("env_modules") Import("env_modules")
env_gltf = env_modules.Clone() env_gltf = env_modules.Clone()
env_gltf.Prepend(CPPPATH=["."])
# Godot's own source files # Godot's own source files
env_gltf.add_source_files(env.modules_sources, "*.cpp") env_gltf.add_source_files(env.modules_sources, "*.cpp")
if env["tools"]:
env_gltf.add_source_files(env.modules_sources, "editor/*.cpp")

View file

@ -28,23 +28,24 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/ /*************************************************************************/
#if TOOLS_ENABLED #ifdef TOOLS_ENABLED
#include "editor_scene_exporter_gltf_plugin.h" #include "editor_scene_exporter_gltf_plugin.h"
#include "../gltf_document.h"
#include "../gltf_state.h"
#include "core/config/project_settings.h" #include "core/config/project_settings.h"
#include "core/error/error_list.h" #include "core/error/error_list.h"
#include "core/object/object.h" #include "core/object/object.h"
#include "core/templates/vector.h" #include "core/templates/vector.h"
#include "editor/editor_file_dialog.h" #include "editor/editor_file_dialog.h"
#include "editor/editor_file_system.h" #include "editor/editor_file_system.h"
#include "gltf_document.h" #include "editor/editor_node.h"
#include "gltf_state.h"
#include "scene/3d/mesh_instance_3d.h" #include "scene/3d/mesh_instance_3d.h"
#include "scene/gui/check_box.h" #include "scene/gui/check_box.h"
#include "scene/main/node.h" #include "scene/main/node.h"
#include "editor/editor_node.h"
String SceneExporterGLTFPlugin::get_name() const { String SceneExporterGLTFPlugin::get_name() const {
return "ConvertGLTF2"; return "ConvertGLTF2";
} }

View file

@ -31,7 +31,8 @@
#ifndef EDITOR_SCENE_EXPORTER_GLTF_PLUGIN_H #ifndef EDITOR_SCENE_EXPORTER_GLTF_PLUGIN_H
#define EDITOR_SCENE_EXPORTER_GLTF_PLUGIN_H #define EDITOR_SCENE_EXPORTER_GLTF_PLUGIN_H
#if TOOLS_ENABLED #ifdef TOOLS_ENABLED
#include "editor/editor_plugin.h" #include "editor/editor_plugin.h"
#include "editor_scene_importer_gltf.h" #include "editor_scene_importer_gltf.h"
@ -47,5 +48,7 @@ public:
bool has_main_screen() const override; bool has_main_screen() const override;
SceneExporterGLTFPlugin(); SceneExporterGLTFPlugin();
}; };
#endif // TOOLS_ENABLED #endif // TOOLS_ENABLED
#endif // EDITOR_SCENE_EXPORTER_GLTF_PLUGIN_H #endif // EDITOR_SCENE_EXPORTER_GLTF_PLUGIN_H

View file

@ -28,11 +28,12 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/ /*************************************************************************/
#if TOOLS_ENABLED #ifdef TOOLS_ENABLED
#include "editor_scene_importer_gltf.h" #include "editor_scene_importer_gltf.h"
#include "gltf_document.h" #include "../gltf_document.h"
#include "gltf_state.h" #include "../gltf_state.h"
#include "scene/3d/node_3d.h" #include "scene/3d/node_3d.h"
#include "scene/animation/animation_player.h" #include "scene/animation/animation_player.h"

View file

@ -30,10 +30,11 @@
#ifndef EDITOR_SCENE_IMPORTER_GLTF_H #ifndef EDITOR_SCENE_IMPORTER_GLTF_H
#define EDITOR_SCENE_IMPORTER_GLTF_H #define EDITOR_SCENE_IMPORTER_GLTF_H
#ifdef TOOLS_ENABLED
#include "gltf_state.h"
#include "gltf_document_extension.h" #ifdef TOOLS_ENABLED
#include "../gltf_document_extension.h"
#include "../gltf_state.h"
#include "editor/import/resource_importer_scene.h" #include "editor/import/resource_importer_scene.h"
#include "scene/main/node.h" #include "scene/main/node.h"
@ -51,5 +52,7 @@ public:
virtual Ref<Animation> import_animation(const String &p_path, virtual Ref<Animation> import_animation(const String &p_path,
uint32_t p_flags, const Map<StringName, Variant> &p_options, int p_bake_fps) override; uint32_t p_flags, const Map<StringName, Variant> &p_options, int p_bake_fps) override;
}; };
#endif // TOOLS_ENABLED #endif // TOOLS_ENABLED
#endif // EDITOR_SCENE_IMPORTER_GLTF_H #endif // EDITOR_SCENE_IMPORTER_GLTF_H

View file

@ -30,9 +30,8 @@
#include "register_types.h" #include "register_types.h"
#include "editor/editor_node.h" #ifndef _3D_DISABLED
#include "editor_scene_exporter_gltf_plugin.h"
#include "editor_scene_importer_gltf.h"
#include "gltf_accessor.h" #include "gltf_accessor.h"
#include "gltf_animation.h" #include "gltf_animation.h"
#include "gltf_buffer_view.h" #include "gltf_buffer_view.h"
@ -49,18 +48,19 @@
#include "gltf_state.h" #include "gltf_state.h"
#include "gltf_texture.h" #include "gltf_texture.h"
#ifndef _3D_DISABLED
#ifdef TOOLS_ENABLED #ifdef TOOLS_ENABLED
#include "editor/editor_node.h"
#include "editor/editor_scene_exporter_gltf_plugin.h"
#include "editor/editor_scene_importer_gltf.h"
static void _editor_init() { static void _editor_init() {
Ref<EditorSceneFormatImporterGLTF> import_gltf; Ref<EditorSceneFormatImporterGLTF> import_gltf;
import_gltf.instantiate(); import_gltf.instantiate();
ResourceImporterScene::get_singleton()->add_importer(import_gltf); ResourceImporterScene::get_singleton()->add_importer(import_gltf);
} }
#endif #endif
#endif
void register_gltf_types() { void register_gltf_types() {
#ifndef _3D_DISABLED
#ifdef TOOLS_ENABLED #ifdef TOOLS_ENABLED
ClassDB::APIType prev_api = ClassDB::get_current_api(); ClassDB::APIType prev_api = ClassDB::get_current_api();
ClassDB::set_current_api(ClassDB::API_EDITOR); ClassDB::set_current_api(ClassDB::API_EDITOR);
@ -84,8 +84,9 @@ void register_gltf_types() {
GDREGISTER_CLASS(GLTFDocumentExtensionConvertImporterMesh); GDREGISTER_CLASS(GLTFDocumentExtensionConvertImporterMesh);
GDREGISTER_CLASS(GLTFDocumentExtension); GDREGISTER_CLASS(GLTFDocumentExtension);
GDREGISTER_CLASS(GLTFDocument); GDREGISTER_CLASS(GLTFDocument);
#endif
} }
void unregister_gltf_types() { void unregister_gltf_types() {
} }
#endif // _3D_DISABLED

View file

@ -5,4 +5,7 @@ Import("env_modules")
env_gridmap = env_modules.Clone() env_gridmap = env_modules.Clone()
# Godot's own source files
env_gridmap.add_source_files(env.modules_sources, "*.cpp") env_gridmap.add_source_files(env.modules_sources, "*.cpp")
if env["tools"]:
env_gridmap.add_source_files(env.modules_sources, "editor/*.cpp")

View file

@ -29,14 +29,16 @@
/*************************************************************************/ /*************************************************************************/
#include "grid_map_editor_plugin.h" #include "grid_map_editor_plugin.h"
#ifdef TOOLS_ENABLED
#include "core/input/input.h" #include "core/input/input.h"
#include "core/os/keyboard.h"
#include "editor/editor_node.h" #include "editor/editor_node.h"
#include "editor/editor_scale.h" #include "editor/editor_scale.h"
#include "editor/editor_settings.h" #include "editor/editor_settings.h"
#include "editor/plugins/node_3d_editor_plugin.h" #include "editor/plugins/node_3d_editor_plugin.h"
#include "scene/3d/camera_3d.h" #include "scene/3d/camera_3d.h"
#include "core/os/keyboard.h"
#include "scene/main/window.h" #include "scene/main/window.h"
void GridMapEditor::_node_removed(Node *p_node) { void GridMapEditor::_node_removed(Node *p_node) {
@ -1479,3 +1481,5 @@ GridMapEditorPlugin::GridMapEditorPlugin() {
GridMapEditorPlugin::~GridMapEditorPlugin() { GridMapEditorPlugin::~GridMapEditorPlugin() {
} }
#endif // TOOLS_ENABLED

View file

@ -31,8 +31,10 @@
#ifndef GRID_MAP_EDITOR_PLUGIN_H #ifndef GRID_MAP_EDITOR_PLUGIN_H
#define GRID_MAP_EDITOR_PLUGIN_H #define GRID_MAP_EDITOR_PLUGIN_H
#ifdef TOOLS_ENABLED
#include "../grid_map.h"
#include "editor/editor_plugin.h" #include "editor/editor_plugin.h"
#include "grid_map.h"
#include "scene/gui/item_list.h" #include "scene/gui/item_list.h"
#include "scene/gui/slider.h" #include "scene/gui/slider.h"
#include "scene/gui/spin_box.h" #include "scene/gui/spin_box.h"
@ -249,4 +251,6 @@ public:
~GridMapEditorPlugin(); ~GridMapEditorPlugin();
}; };
#endif // CUBE_GRID_MAP_EDITOR_PLUGIN_H #endif // TOOLS_ENABLED
#endif // GRID_MAP_EDITOR_PLUGIN_H

View file

@ -28,21 +28,25 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/ /*************************************************************************/
#include "register_types.h"
#ifndef _3D_DISABLED #ifndef _3D_DISABLED
#include "register_types.h"
#include "core/object/class_db.h" #include "core/object/class_db.h"
#include "grid_map.h" #include "grid_map.h"
#include "grid_map_editor_plugin.h"
#ifdef TOOLS_ENABLED
#include "editor/grid_map_editor_plugin.h"
#endif #endif
void register_gridmap_types() { void register_gridmap_types() {
#ifndef _3D_DISABLED
GDREGISTER_CLASS(GridMap); GDREGISTER_CLASS(GridMap);
#ifdef TOOLS_ENABLED #ifdef TOOLS_ENABLED
EditorPlugins::add_by_type<GridMapEditorPlugin>(); EditorPlugins::add_by_type<GridMapEditorPlugin>();
#endif #endif
#endif
} }
void unregister_gridmap_types() { void unregister_gridmap_types() {
} }
#endif // _3D_DISABLED

View file

@ -57,6 +57,8 @@ env.modules_sources += thirdparty_obj
module_obj = [] module_obj = []
env_navigation.add_source_files(module_obj, "*.cpp") env_navigation.add_source_files(module_obj, "*.cpp")
if env["tools"]:
env_navigation.add_source_files(module_obj, "editor/*.cpp")
env.modules_sources += module_obj env.modules_sources += module_obj
# Needed to force rebuilding the module files when the thirdparty library is updated. # Needed to force rebuilding the module files when the thirdparty library is updated.

View file

@ -28,13 +28,14 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/ /*************************************************************************/
#ifdef TOOLS_ENABLED
#include "navigation_mesh_editor_plugin.h" #include "navigation_mesh_editor_plugin.h"
#ifdef TOOLS_ENABLED
#include "../navigation_mesh_generator.h"
#include "core/io/marshalls.h" #include "core/io/marshalls.h"
#include "core/io/resource_saver.h" #include "core/io/resource_saver.h"
#include "editor/editor_node.h" #include "editor/editor_node.h"
#include "navigation_mesh_generator.h"
#include "scene/3d/mesh_instance_3d.h" #include "scene/3d/mesh_instance_3d.h"
#include "scene/gui/box_container.h" #include "scene/gui/box_container.h"
@ -153,4 +154,4 @@ NavigationMeshEditorPlugin::NavigationMeshEditorPlugin() {
NavigationMeshEditorPlugin::~NavigationMeshEditorPlugin() { NavigationMeshEditorPlugin::~NavigationMeshEditorPlugin() {
} }
#endif #endif // TOOLS_ENABLED

View file

@ -81,6 +81,6 @@ public:
~NavigationMeshEditorPlugin(); ~NavigationMeshEditorPlugin();
}; };
#endif #endif // TOOLS_ENABLED
#endif #endif // NAVIGATION_MESH_EDITOR_PLUGIN_H

View file

@ -40,7 +40,7 @@
#endif #endif
#ifdef TOOLS_ENABLED #ifdef TOOLS_ENABLED
#include "navigation_mesh_editor_plugin.h" #include "editor/navigation_mesh_editor_plugin.h"
#endif #endif
#ifndef _3D_DISABLED #ifndef _3D_DISABLED

View file

@ -41,6 +41,8 @@ elif env["builtin_wslay"]:
module_obj = [] module_obj = []
env_ws.add_source_files(module_obj, "*.cpp") env_ws.add_source_files(module_obj, "*.cpp")
if env["tools"]:
env_ws.add_source_files(module_obj, "editor/*.cpp")
env.modules_sources += module_obj env.modules_sources += module_obj
# Needed to force rebuilding the module files when the thirdparty library is updated. # Needed to force rebuilding the module files when the thirdparty library is updated.

View file

@ -30,11 +30,13 @@
#include "editor_debugger_server_websocket.h" #include "editor_debugger_server_websocket.h"
#ifdef TOOLS_ENABLED
#include "../remote_debugger_peer_websocket.h"
#include "core/config/project_settings.h" #include "core/config/project_settings.h"
#include "editor/editor_log.h" #include "editor/editor_log.h"
#include "editor/editor_node.h" #include "editor/editor_node.h"
#include "editor/editor_settings.h" #include "editor/editor_settings.h"
#include "modules/websocket/remote_debugger_peer_websocket.h"
void EditorDebuggerServerWebSocket::_peer_connected(int p_id, String _protocol) { void EditorDebuggerServerWebSocket::_peer_connected(int p_id, String _protocol) {
pending_peers.push_back(p_id); pending_peers.push_back(p_id);
@ -129,3 +131,5 @@ EditorDebuggerServer *EditorDebuggerServerWebSocket::create(const String &p_prot
ERR_FAIL_COND_V(p_protocol != "ws://", nullptr); ERR_FAIL_COND_V(p_protocol != "ws://", nullptr);
return memnew(EditorDebuggerServerWebSocket); return memnew(EditorDebuggerServerWebSocket);
} }
#endif // TOOLS_ENABLED

View file

@ -31,8 +31,10 @@
#ifndef EDITOR_DEBUGGER_SERVER_WEBSOCKET_H #ifndef EDITOR_DEBUGGER_SERVER_WEBSOCKET_H
#define EDITOR_DEBUGGER_SERVER_WEBSOCKET_H #define EDITOR_DEBUGGER_SERVER_WEBSOCKET_H
#ifdef TOOLS_ENABLED
#include "../websocket_server.h"
#include "editor/debugger/editor_debugger_server.h" #include "editor/debugger/editor_debugger_server.h"
#include "modules/websocket/websocket_server.h"
class EditorDebuggerServerWebSocket : public EditorDebuggerServer { class EditorDebuggerServerWebSocket : public EditorDebuggerServer {
GDCLASS(EditorDebuggerServerWebSocket, EditorDebuggerServer); GDCLASS(EditorDebuggerServerWebSocket, EditorDebuggerServer);
@ -60,4 +62,6 @@ public:
~EditorDebuggerServerWebSocket(); ~EditorDebuggerServerWebSocket();
}; };
#endif // TOOLS_ENABLED
#endif // EDITOR_DEBUGGER_SERVER_WEBSOCKET_H #endif // EDITOR_DEBUGGER_SERVER_WEBSOCKET_H

View file

@ -29,8 +29,10 @@
/*************************************************************************/ /*************************************************************************/
#include "register_types.h" #include "register_types.h"
#include "core/config/project_settings.h" #include "core/config/project_settings.h"
#include "core/error/error_macros.h" #include "core/error/error_macros.h"
#ifdef JAVASCRIPT_ENABLED #ifdef JAVASCRIPT_ENABLED
#include "emscripten.h" #include "emscripten.h"
#include "emws_client.h" #include "emws_client.h"
@ -40,10 +42,11 @@
#include "wsl_client.h" #include "wsl_client.h"
#include "wsl_server.h" #include "wsl_server.h"
#endif #endif
#ifdef TOOLS_ENABLED #ifdef TOOLS_ENABLED
#include "editor/debugger/editor_debugger_server.h" #include "editor/debugger/editor_debugger_server.h"
#include "editor/editor_debugger_server_websocket.h"
#include "editor/editor_node.h" #include "editor/editor_node.h"
#include "editor_debugger_server_websocket.h"
#endif #endif
#ifdef TOOLS_ENABLED #ifdef TOOLS_ENABLED

View file

@ -31,13 +31,14 @@
#ifndef REMOTE_DEBUGGER_PEER_WEBSOCKET_H #ifndef REMOTE_DEBUGGER_PEER_WEBSOCKET_H
#define REMOTE_DEBUGGER_PEER_WEBSOCKET_H #define REMOTE_DEBUGGER_PEER_WEBSOCKET_H
#ifdef JAVASCRIPT_ENABLED
#include "modules/websocket/emws_client.h"
#else
#include "modules/websocket/wsl_client.h"
#endif
#include "core/debugger/remote_debugger_peer.h" #include "core/debugger/remote_debugger_peer.h"
#ifdef JAVASCRIPT_ENABLED
#include "emws_client.h"
#else
#include "wsl_client.h"
#endif
class RemoteDebuggerPeerWebSocket : public RemoteDebuggerPeer { class RemoteDebuggerPeerWebSocket : public RemoteDebuggerPeer {
Ref<WebSocketClient> ws_client; Ref<WebSocketClient> ws_client;
Ref<WebSocketPeer> ws_peer; Ref<WebSocketPeer> ws_peer;