Skip to content

Commit

Permalink
restore legacy event parameter setting (#183)
Browse files Browse the repository at this point in the history
* restore legacy event parameter setting
  • Loading branch information
bitbrain authored Dec 18, 2023
1 parent f7645f4 commit 7350556
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
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
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

0 comments on commit 7350556

Please sign in to comment.