Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

restore legacy event parameter setting #183

Merged
merged 15 commits into from
Dec 18, 2023
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -134,3 +134,6 @@ config.log
**/*.editor

demo/addons/fmod/libs/android/aar/

*.pdb
.vs
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

those get generated when using visual studio, so I put them onto ignore

34 changes: 34 additions & 0 deletions src/nodes/fmod_event_emitter.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ namespace godot {

void play();
void stop();
Variant get_parameter(const String& p_name) const;
void set_parameter(const String& p_name, const Variant& p_property);
void set_paused(bool p_is_paused);
const Ref<FmodEvent>& get_event() const;
bool is_paused();
Expand Down Expand Up @@ -233,6 +235,36 @@ namespace godot {
}
}

template<class Derived, class NodeType>
Variant FmodEventEmitter<Derived, NodeType>::get_parameter(const String& p_name) const {
if (!_event.is_valid()) { return nullptr; }

Parameter* parameter {find_parameter_by_name(p_name)};

if (!parameter) { return nullptr; }

return parameter->value;
}

template<class Derived, class NodeType>
void FmodEventEmitter<Derived, NodeType>::set_parameter(const String& p_name, const Variant& p_property) {
if (!_event.is_valid()) { return; }

Parameter* parameter {find_parameter_by_name(p_name)};

if (!parameter) { return; }

parameter->value = p_property;

#ifdef TOOLS_ENABLED
if (!Engine::get_singleton()->is_editor_hint()) {
#endif
apply_parameters();
#ifdef TOOLS_ENABLED
}
#endif
}

template<class Derived, class NodeType>
void FmodEventEmitter<Derived, NodeType>::set_paused(bool p_is_paused) {
if (!_event.is_valid()) { return; }
Expand Down Expand Up @@ -696,6 +728,8 @@ namespace godot {
void FmodEventEmitter<Derived, NodeType>::_bind_methods() {
ClassDB::bind_method(D_METHOD("play"), &Derived::play);
ClassDB::bind_method(D_METHOD("stop"), &Derived::stop);
ClassDB::bind_method(D_METHOD("set_parameter", "name", "value"), &Derived::set_parameter);
ClassDB::bind_method(D_METHOD("get_parameter", "name"), &Derived::get_parameter);
ClassDB::bind_method(D_METHOD("is_paused"), &Derived::is_paused);
ClassDB::bind_method(D_METHOD("set_paused", "p_is_paused"), &Derived::set_paused);
ClassDB::bind_method(D_METHOD("set_event_name", "event_name"), &Derived::set_event_name);
Expand Down
Loading