summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJuan Linietsky <reduzio@gmail.com>2017-08-18 18:19:12 -0300
committerJuan Linietsky <reduzio@gmail.com>2017-08-18 18:21:53 -0300
commitcbcf40bd31649d18b24952aec0051cdfbfa78606 (patch)
tree0f2b2f6ddd2e4a2ea119501214090988319ccc6c
parentb044e7d30d1f722d502d9ad564091b2e4a03b390 (diff)
-Volume sliders, mute, solo and fx bypass are functional, closes #9021
-Fixed tree reselect, makes reselecting an audio bux FX work
-rw-r--r--editor/editor_audio_buses.cpp2
-rw-r--r--editor/editor_autoload_settings.cpp2
-rw-r--r--editor/plugins/sprite_frames_editor_plugin.cpp2
-rw-r--r--modules/visual_script/visual_script_editor.cpp2
-rw-r--r--scene/gui/tree.cpp32
-rw-r--r--scene/gui/tree.h9
-rw-r--r--servers/audio_server.cpp74
-rw-r--r--servers/audio_server.h2
8 files changed, 88 insertions, 37 deletions
diff --git a/editor/editor_audio_buses.cpp b/editor/editor_audio_buses.cpp
index 993429a5a4..282055be4a 100644
--- a/editor/editor_audio_buses.cpp
+++ b/editor/editor_audio_buses.cpp
@@ -705,8 +705,8 @@ EditorAudioBus::EditorAudioBus(EditorAudioBuses *p_buses) {
effects->set_drag_forwarding(this);
effects->connect("item_rmb_selected", this, "_effect_rmb");
effects->set_allow_rmb_select(true);
- effects->set_single_select_cell_editing_only_when_already_selected(true);
effects->set_focus_mode(FOCUS_CLICK);
+ effects->set_allow_reselect(true);
send = memnew(OptionButton);
send->set_clip_text(true);
diff --git a/editor/editor_autoload_settings.cpp b/editor/editor_autoload_settings.cpp
index dde94cb334..0d7874818c 100644
--- a/editor/editor_autoload_settings.cpp
+++ b/editor/editor_autoload_settings.cpp
@@ -580,7 +580,7 @@ EditorAutoloadSettings::EditorAutoloadSettings() {
tree = memnew(Tree);
tree->set_hide_root(true);
tree->set_select_mode(Tree::SELECT_MULTI);
- tree->set_single_select_cell_editing_only_when_already_selected(true);
+ tree->set_allow_reselect(true);
tree->set_drag_forwarding(this);
diff --git a/editor/plugins/sprite_frames_editor_plugin.cpp b/editor/plugins/sprite_frames_editor_plugin.cpp
index 0f008552d0..0608ecec58 100644
--- a/editor/plugins/sprite_frames_editor_plugin.cpp
+++ b/editor/plugins/sprite_frames_editor_plugin.cpp
@@ -747,7 +747,7 @@ SpriteFramesEditor::SpriteFramesEditor() {
animations->set_hide_root(true);
animations->connect("cell_selected", this, "_animation_select");
animations->connect("item_edited", this, "_animation_name_edited");
- animations->set_single_select_cell_editing_only_when_already_selected(true);
+ animations->set_allow_reselect(true);
anim_speed = memnew(SpinBox);
vbc_animlist->add_margin_child(TTR("Speed (FPS):"), anim_speed);
diff --git a/modules/visual_script/visual_script_editor.cpp b/modules/visual_script/visual_script_editor.cpp
index a39491ef5b..9a1033e954 100644
--- a/modules/visual_script/visual_script_editor.cpp
+++ b/modules/visual_script/visual_script_editor.cpp
@@ -3234,7 +3234,7 @@ VisualScriptEditor::VisualScriptEditor() {
members->connect("button_pressed", this, "_member_button");
members->connect("item_edited", this, "_member_edited");
members->connect("cell_selected", this, "_member_selected", varray(), CONNECT_DEFERRED);
- members->set_single_select_cell_editing_only_when_already_selected(true);
+ members->set_allow_reselect(true);
members->set_hide_folding(true);
members->set_drag_forwarding(this);
diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp
index fa499ff277..3e8d8aed8a 100644
--- a/scene/gui/tree.cpp
+++ b/scene/gui/tree.cpp
@@ -1455,7 +1455,7 @@ void Tree::select_single_item(TreeItem *p_selected, TreeItem *p_current, int p_c
if (select_mode == SELECT_ROW) {
- if (p_selected == p_current && !c.selected) {
+ if (p_selected == p_current && (!c.selected || allow_reselect)) {
c.selected = true;
selected_item = p_selected;
selected_col = 0;
@@ -1478,7 +1478,7 @@ void Tree::select_single_item(TreeItem *p_selected, TreeItem *p_current, int p_c
if (!r_in_range && &selected_cell == &c) {
- if (!selected_cell.selected || force_select_on_already_selected) {
+ if (!selected_cell.selected || allow_reselect) {
selected_cell.selected = true;
@@ -1743,7 +1743,7 @@ int Tree::propagate_mouse_event(const Point2i &p_pos, int x_ofs, int y_ofs, bool
/* editing */
- bool bring_up_editor = force_select_on_already_selected ? (c.selected && already_selected) : c.selected;
+ bool bring_up_editor = allow_reselect ? (c.selected && already_selected) : c.selected;
String editor_text = c.text;
switch (c.mode) {
@@ -3557,16 +3557,6 @@ int Tree::get_drop_mode_flags() const {
return drop_mode_flags;
}
-void Tree::set_single_select_cell_editing_only_when_already_selected(bool p_enable) {
-
- force_select_on_already_selected = p_enable;
-}
-
-bool Tree::get_single_select_cell_editing_only_when_already_selected() const {
-
- return force_select_on_already_selected;
-}
-
void Tree::set_edit_checkbox_cell_only_when_checkbox_is_pressed(bool p_enable) {
force_edit_checkbox_only_on_checkbox = p_enable;
@@ -3587,6 +3577,15 @@ bool Tree::get_allow_rmb_select() const {
return allow_rmb_select;
}
+void Tree::set_allow_reselect(bool p_allow) {
+ allow_reselect = p_allow;
+}
+
+bool Tree::get_allow_reselect() const {
+
+ return allow_reselect;
+}
+
void Tree::_bind_methods() {
ClassDB::bind_method(D_METHOD("_range_click_timeout"), &Tree::_range_click_timeout);
@@ -3640,8 +3639,8 @@ void Tree::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_allow_rmb_select", "allow"), &Tree::set_allow_rmb_select);
ClassDB::bind_method(D_METHOD("get_allow_rmb_select"), &Tree::get_allow_rmb_select);
- ClassDB::bind_method(D_METHOD("set_single_select_cell_editing_only_when_already_selected", "enable"), &Tree::set_single_select_cell_editing_only_when_already_selected);
- ClassDB::bind_method(D_METHOD("get_single_select_cell_editing_only_when_already_selected"), &Tree::get_single_select_cell_editing_only_when_already_selected);
+ ClassDB::bind_method(D_METHOD("set_allow_reselect", "allow"), &Tree::set_allow_reselect);
+ ClassDB::bind_method(D_METHOD("get_allow_reselect"), &Tree::get_allow_reselect);
ADD_SIGNAL(MethodInfo("item_selected"));
ADD_SIGNAL(MethodInfo("cell_selected"));
@@ -3751,7 +3750,6 @@ Tree::Tree() {
drop_mode_over = NULL;
drop_mode_section = 0;
single_select_defer = NULL;
- force_select_on_already_selected = false;
allow_rmb_select = false;
force_edit_checkbox_only_on_checkbox = false;
@@ -3760,6 +3758,8 @@ Tree::Tree() {
cache.hover_item = NULL;
cache.hover_cell = -1;
+
+ allow_reselect = false;
}
Tree::~Tree() {
diff --git a/scene/gui/tree.h b/scene/gui/tree.h
index 81880122a9..1e46956cd9 100644
--- a/scene/gui/tree.h
+++ b/scene/gui/tree.h
@@ -490,7 +490,8 @@ private:
bool allow_rmb_select;
bool scrolling;
- bool force_select_on_already_selected;
+ bool allow_reselect;
+
bool force_edit_checkbox_only_on_checkbox;
bool hide_folding;
@@ -566,15 +567,15 @@ public:
void set_drop_mode_flags(int p_flags);
int get_drop_mode_flags() const;
- void set_single_select_cell_editing_only_when_already_selected(bool p_enable);
- bool get_single_select_cell_editing_only_when_already_selected() const;
-
void set_edit_checkbox_cell_only_when_checkbox_is_pressed(bool p_enable);
bool get_edit_checkbox_cell_only_when_checkbox_is_pressed() const;
void set_allow_rmb_select(bool p_allow);
bool get_allow_rmb_select() const;
+ void set_allow_reselect(bool p_allow);
+ bool get_allow_reselect() const;
+
void set_value_evaluator(ValueEvaluator *p_evaluator);
Tree();
diff --git a/servers/audio_server.cpp b/servers/audio_server.cpp
index 3547f86eb3..f9fdd9432d 100644
--- a/servers/audio_server.cpp
+++ b/servers/audio_server.cpp
@@ -159,6 +159,8 @@ void AudioServer::_driver_process(int p_frames, int32_t *p_buffer) {
void AudioServer::_mix_step() {
+ bool solo_mode = false;
+
for (int i = 0; i < buses.size(); i++) {
Bus *bus = buses[i];
bus->index_cache = i; //might be moved around by editor, so..
@@ -166,6 +168,33 @@ void AudioServer::_mix_step() {
bus->channels[k].used = false;
}
+
+ if (bus->solo) {
+ //solo chain
+ solo_mode = true;
+ bus->soloed = true;
+ do {
+
+ if (bus != buses[0]) {
+ //everything has a send save for master bus
+ if (!bus_map.has(bus->send)) {
+ bus = buses[0]; //send to master
+ } else {
+ bus = bus_map[bus->send];
+ if (bus->index_cache >= bus->index_cache) { //invalid, send to master
+ bus = buses[0];
+ }
+ }
+
+ bus->soloed = true;
+ } else {
+ bus = NULL;
+ }
+
+ } while (bus);
+ } else {
+ bus->soloed = false;
+ }
}
//make callbacks for mixing the audio
@@ -192,24 +221,26 @@ void AudioServer::_mix_step() {
}
//process effects
- for (int j = 0; j < bus->effects.size(); j++) {
+ if (!bus->bypass) {
+ for (int j = 0; j < bus->effects.size(); j++) {
- if (!bus->effects[j].enabled)
- continue;
+ if (!bus->effects[j].enabled)
+ continue;
- for (int k = 0; k < bus->channels.size(); k++) {
+ for (int k = 0; k < bus->channels.size(); k++) {
- if (!bus->channels[k].active)
- continue;
- bus->channels[k].effect_instances[j]->process(bus->channels[k].buffer.ptr(), temp_buffer[k].ptr(), buffer_size);
- }
+ if (!bus->channels[k].active)
+ continue;
+ bus->channels[k].effect_instances[j]->process(bus->channels[k].buffer.ptr(), temp_buffer[k].ptr(), buffer_size);
+ }
- //swap buffers, so internal buffer always has the right data
- for (int k = 0; k < bus->channels.size(); k++) {
+ //swap buffers, so internal buffer always has the right data
+ for (int k = 0; k < bus->channels.size(); k++) {
- if (!buses[i]->channels[k].active)
- continue;
- SWAP(bus->channels[k].buffer, temp_buffer[k]);
+ if (!buses[i]->channels[k].active)
+ continue;
+ SWAP(bus->channels[k].buffer, temp_buffer[k]);
+ }
}
}
@@ -237,7 +268,24 @@ void AudioServer::_mix_step() {
AudioFrame *buf = bus->channels[k].buffer.ptr();
AudioFrame peak = AudioFrame(0, 0);
+
+ float volume = Math::db2linear(bus->volume_db);
+
+ if (solo_mode) {
+ if (!bus->soloed) {
+ volume = 0.0;
+ }
+ } else {
+ if (bus->mute) {
+ volume = 0.0;
+ }
+ }
+
+ //apply volume and compute peak
for (uint32_t j = 0; j < buffer_size; j++) {
+
+ buf[j] *= volume;
+
float l = ABS(buf[j].l);
if (l > peak.l) {
peak.l = l;
diff --git a/servers/audio_server.h b/servers/audio_server.h
index caa07891f7..c92ff6d3a0 100644
--- a/servers/audio_server.h
+++ b/servers/audio_server.h
@@ -125,6 +125,8 @@ private:
bool mute;
bool bypass;
+ bool soloed;
+
//Each channel is a stereo pair.
struct Channel {
bool used;