summaryrefslogtreecommitdiff
path: root/servers
diff options
context:
space:
mode:
authorBruno Lourenço <bmlourenco@gmail.com>2017-07-10 21:51:29 +0100
committerBruno Lourenço <bmlourenco@gmail.com>2017-07-10 21:51:29 +0100
commit62e06657bbd6f02c4c3a483e52296e9be568fb2c (patch)
tree00776e486b6ecea16d9a2454bee8cc16c33b3c43 /servers
parent93405830802d32795194bbf505bd2cb6ea8ac2e5 (diff)
Added get_bus_index to AudioServer
Diffstat (limited to 'servers')
-rw-r--r--servers/audio_server.cpp10
-rw-r--r--servers/audio_server.h1
2 files changed, 11 insertions, 0 deletions
diff --git a/servers/audio_server.cpp b/servers/audio_server.cpp
index f32784343c..43f1175c79 100644
--- a/servers/audio_server.cpp
+++ b/servers/audio_server.cpp
@@ -515,6 +515,15 @@ String AudioServer::get_bus_name(int p_bus) const {
return buses[p_bus]->name;
}
+int AudioServer::get_bus_index(const StringName &p_bus_name) const {
+ for (int i = 0; i < buses.size(); ++i) {
+ if (buses[i]->name == p_bus_name) {
+ return i;
+ }
+ }
+ return -1;
+}
+
void AudioServer::set_bus_volume_db(int p_bus, float p_volume_db) {
ERR_FAIL_INDEX(p_bus, buses.size());
@@ -958,6 +967,7 @@ void AudioServer::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_bus_name", "bus_idx", "name"), &AudioServer::set_bus_name);
ClassDB::bind_method(D_METHOD("get_bus_name", "bus_idx"), &AudioServer::get_bus_name);
+ ClassDB::bind_method(D_METHOD("get_bus_index", "bus_name"), &AudioServer::get_bus_index);
ClassDB::bind_method(D_METHOD("set_bus_volume_db", "bus_idx", "volume_db"), &AudioServer::set_bus_volume_db);
ClassDB::bind_method(D_METHOD("get_bus_volume_db", "bus_idx"), &AudioServer::get_bus_volume_db);
diff --git a/servers/audio_server.h b/servers/audio_server.h
index e3b4a3021c..caa07891f7 100644
--- a/servers/audio_server.h
+++ b/servers/audio_server.h
@@ -215,6 +215,7 @@ public:
void set_bus_name(int p_bus, const String &p_name);
String get_bus_name(int p_bus) const;
+ int get_bus_index(const StringName &p_bus_name) const;
void set_bus_volume_db(int p_bus, float p_volume_db);
float get_bus_volume_db(int p_bus) const;