Skip to content

Commit

Permalink
New editor class registration & build script update
Browse files Browse the repository at this point in the history
This commit registers the new editor classes to Godot's ClassDB and adds the plugins to the editor through a consolidated WwiseEditorPlugin helper class.
  • Loading branch information
alessandrofama committed Aug 16, 2023
1 parent 5a7c1fa commit e85ca2f
Show file tree
Hide file tree
Showing 4 changed files with 88 additions and 8 deletions.
6 changes: 5 additions & 1 deletion addons/Wwise/native/SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -348,15 +348,19 @@ env.Append(
)
env.Append(LIBPATH=[cpp_bindings_path + "bin/"])

env.Append(CPPPATH=["src/", "src/scene/"])
env.Append(CPPPATH=["src/", "src/scene/", "src/editor/inspector_plugin/", "src/editor/event_gizmo/", "src/editor/export_plugin/"])

sources = []
sources.append(Glob("src/*.cpp"))
sources.append(Glob("src/scene/*.cpp"))
sources.append(Glob("src/editor/inspector_plugin/*.cpp"))

if env["platform"] == "windows" or env["platform"] == "macos":
env.Append(CPPPATH=["src/waapi/"])
env.Append(CPPPATH=["src/editor/waapi_picker/"])
sources.append(Glob("src/waapi/*.cpp"))
sources.append(Glob("src/editor/waapi_picker/*.cpp"))

env.Append(LIBS=["AkAutobahn"])

if env["platform"] != "windows":
Expand Down
29 changes: 22 additions & 7 deletions addons/Wwise/native/src/register_types.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,27 @@ static AkUtils* ak_utils;

void register_wwise_types(ModuleInitializationLevel p_level)
{
#if !defined(AK_IOS) && !defined(AK_ANDROID) && !defined(AK_LINUX)
if (p_level == MODULE_INITIALIZATION_LEVEL_EDITOR)
{
#if !defined(AK_IOS) && !defined(AK_ANDROID) && !defined(AK_LINUX)
ClassDB::register_class<Waapi>();
waapi_module = memnew(Waapi);
Engine::get_singleton()->register_singleton("Waapi", Waapi::get_singleton());
}

ClassDB::register_class<WaapiPicker>();
EditorPlugins::add_by_type<WaapiPicker>();
#endif

ClassDB::register_class<AkInspectorWindow>();
ClassDB::register_class<AkInspectorTree>();
ClassDB::register_class<AkInspectorEditorInspectorPlugin>();
ClassDB::register_class<AkInspectorEditorProperty>();
ClassDB::register_class<AkEvent3DGizmoPlugin>();
ClassDB::register_class<AkEditorExportPlugin>();
ClassDB::register_class<WwiseEditorPlugin>();
EditorPlugins::add_by_type<WwiseEditorPlugin>();
}

if (p_level == MODULE_INITIALIZATION_LEVEL_SCENE)
{
ClassDB::register_class<AkUtils>();
Expand Down Expand Up @@ -60,23 +72,26 @@ void unregister_wwise_types(ModuleInitializationLevel p_level)
memdelete(ak_utils);
}

#if !defined(AK_IOS) && !defined(AK_ANDROID) && !defined(AK_LINUX)
if (p_level == MODULE_INITIALIZATION_LEVEL_EDITOR)
{
#if !defined(AK_IOS) && !defined(AK_ANDROID) && !defined(AK_LINUX)
Engine::get_singleton()->unregister_singleton("Waapi");
memdelete(waapi_module);
}
#endif

EditorPlugins::remove_by_type<WaapiPicker>();
EditorPlugins::remove_by_type<WwiseEditorPlugin>();
}
}

extern "C"
{
// Initialization.

GDExtensionBool GDE_EXPORT wwise_library_init(const GDExtensionInterface* p_interface,
const GDExtensionClassLibraryPtr p_library, GDExtensionInitialization* r_initialization)
GDExtensionBool GDE_EXPORT wwise_library_init(GDExtensionInterfaceGetProcAddress p_get_proc_address,
GDExtensionClassLibraryPtr p_library, GDExtensionInitialization* r_initialization)
{
godot::GDExtensionBinding::InitObject init_obj(p_interface, p_library, r_initialization);
godot::GDExtensionBinding::InitObject init_obj(p_get_proc_address, p_library, r_initialization);

init_obj.register_initializer(register_wwise_types);
init_obj.register_terminator(unregister_wwise_types);
Expand Down
8 changes: 8 additions & 0 deletions addons/Wwise/native/src/register_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
#include <godot_cpp/godot.hpp>

#include "ak_utils.h"
#include "editor/event_gizmo/ak_event_3d_gizmo_plugin.h"
#include "editor/export_plugin/ak_editor_export_plugin.h"
#include "editor/inspector_plugin/ak_inspector_plugin.h"
#include "scene/ak_bank.h"
#include "scene/ak_early_reflections.h"
#include "scene/ak_environment.h"
Expand All @@ -20,9 +23,14 @@
#include "scene/ak_state.h"
#include "scene/ak_switch.h"
#include "waapi/waapi_gdextension.h"
#include "wwise_editor.h"
#include "wwise_gdextension.h"
#include "wwise_settings.h"

#if !defined(AK_IOS) && !defined(AK_ANDROID) && !defined(AK_LINUX)
#include "editor/waapi_picker/waapi_picker.h"
#endif

using namespace godot;

void register_wwise_types(ModuleInitializationLevel p_level);
Expand Down
53 changes: 53 additions & 0 deletions addons/Wwise/native/src/wwise_editor.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#ifndef WWISE_EDITOR_MANAGER_H
#define WWISE_EDITOR_MANAGER_H

#include "editor/event_gizmo/ak_event_3d_gizmo_plugin.h"
#include "editor/export_plugin/ak_editor_export_plugin.h"
#include "editor/inspector_plugin/ak_inspector_plugin.h"
#include <godot_cpp/classes/editor_plugin.hpp>
#include <godot_cpp/classes/project_settings.hpp>

namespace godot
{
class WwiseEditorPlugin : public EditorPlugin
{
GDCLASS(WwiseEditorPlugin, EditorPlugin);

protected:
static void _bind_methods() {}

private:
Ref<AkEvent3DGizmoPlugin> gizmo_plugin;
Ref<AkEditorExportPlugin> export_plugin;
Ref<AkInspectorEditorInspectorPlugin> inspector_plugin;

public:
virtual void _enter_tree() override
{
if (!ProjectSettings::get_singleton()->has_setting("autoload/WwiseRuntimeManager"))
{
add_autoload_singleton("WwiseRuntimeManager", "res://addons/Wwise/runtime/wwise_runtime_manager.gd");
}

gizmo_plugin.instantiate();
add_node_3d_gizmo_plugin(gizmo_plugin);

export_plugin.instantiate();
add_export_plugin(export_plugin);

inspector_plugin.instantiate();
add_inspector_plugin(inspector_plugin);
}

virtual void _exit_tree() override
{
remove_autoload_singleton("WwiseRuntimeManager");
remove_node_3d_gizmo_plugin(gizmo_plugin);
remove_export_plugin(export_plugin);
remove_inspector_plugin(inspector_plugin);
}
};

} //namespace godot

#endif

0 comments on commit e85ca2f

Please sign in to comment.