Merge pull request #31423 from Calinou/improve-node-signal-group-tooltip

Improve the scene tree signals/groups tooltip
This commit is contained in:
Rémi Verschelde 2019-08-18 10:55:16 +02:00 committed by GitHub
commit 5c853a45e6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 38 additions and 19 deletions

View file

@ -1400,8 +1400,9 @@ void Object::get_signal_connection_list(const StringName &p_signal, List<Connect
p_connections->push_back(s->slot_map.getv(i).conn); p_connections->push_back(s->slot_map.getv(i).conn);
} }
bool Object::has_persistent_signal_connections() const { int Object::get_persistent_signal_connection_count() const {
int count = 0;
const StringName *S = NULL; const StringName *S = NULL;
while ((S = signal_map.next(S))) { while ((S = signal_map.next(S))) {
@ -1409,13 +1410,13 @@ bool Object::has_persistent_signal_connections() const {
const Signal *s = &signal_map[*S]; const Signal *s = &signal_map[*S];
for (int i = 0; i < s->slot_map.size(); i++) { for (int i = 0; i < s->slot_map.size(); i++) {
if (s->slot_map.getv(i).conn.flags & CONNECT_PERSIST) {
if (s->slot_map.getv(i).conn.flags & CONNECT_PERSIST) count += 1;
return true; }
} }
} }
return false; return count;
} }
void Object::get_signals_connected_to_this(List<Connection> *p_connections) const { void Object::get_signals_connected_to_this(List<Connection> *p_connections) const {

View file

@ -707,7 +707,7 @@ public:
void get_signal_list(List<MethodInfo> *p_signals) const; void get_signal_list(List<MethodInfo> *p_signals) const;
void get_signal_connection_list(const StringName &p_signal, List<Connection> *p_connections) const; void get_signal_connection_list(const StringName &p_signal, List<Connection> *p_connections) const;
void get_all_signal_connections(List<Connection> *p_connections) const; void get_all_signal_connections(List<Connection> *p_connections) const;
bool has_persistent_signal_connections() const; int get_persistent_signal_connection_count() const;
void get_signals_connected_to_this(List<Connection> *p_connections) const; void get_signals_connected_to_this(List<Connection> *p_connections) const;
Error connect(const StringName &p_signal, Object *p_to_object, const StringName &p_to_method, const Vector<Variant> &p_binds = Vector<Variant>(), uint32_t p_flags = 0); Error connect(const StringName &p_signal, Object *p_to_object, const StringName &p_to_method, const Vector<Variant> &p_binds = Vector<Variant>(), uint32_t p_flags = 0);

View file

@ -270,15 +270,30 @@ bool SceneTreeEditor::_add_nodes(Node *p_node, TreeItem *p_parent) {
item->add_button(0, get_icon("NodeWarning", "EditorIcons"), BUTTON_WARNING, false, TTR("Node configuration warning:") + "\n" + p_node->get_configuration_warning()); item->add_button(0, get_icon("NodeWarning", "EditorIcons"), BUTTON_WARNING, false, TTR("Node configuration warning:") + "\n" + p_node->get_configuration_warning());
} }
bool has_connections = p_node->has_persistent_signal_connections(); int num_connections = p_node->get_persistent_signal_connection_count();
bool has_groups = p_node->has_persistent_groups(); int num_groups = p_node->get_persistent_group_count();
if (has_connections && has_groups) { if (num_connections >= 1 && num_groups >= 1) {
item->add_button(0, get_icon("SignalsAndGroups", "EditorIcons"), BUTTON_SIGNALS, false, TTR("Node has connection(s) and group(s).\nClick to show signals dock.")); item->add_button(
} else if (has_connections) { 0,
item->add_button(0, get_icon("Signals", "EditorIcons"), BUTTON_SIGNALS, false, TTR("Node has connections.\nClick to show signals dock.")); get_icon("SignalsAndGroups", "EditorIcons"),
} else if (has_groups) { BUTTON_SIGNALS,
item->add_button(0, get_icon("Groups", "EditorIcons"), BUTTON_GROUPS, false, TTR("Node is in group(s).\nClick to show groups dock.")); false,
vformat(TTR("Node has %s connection(s) and %s group(s).\nClick to show signals dock."), num_connections, num_groups));
} else if (num_connections >= 1) {
item->add_button(
0,
get_icon("Signals", "EditorIcons"),
BUTTON_SIGNALS,
false,
vformat(TTR("Node has %s connection(s).\nClick to show signals dock."), num_connections));
} else if (num_groups >= 1) {
item->add_button(
0,
get_icon("Groups", "EditorIcons"),
BUTTON_GROUPS,
false,
vformat(TTR("Node is in %s group(s).\nClick to show groups dock."), num_groups));
} }
} }

View file

@ -1716,14 +1716,17 @@ void Node::get_groups(List<GroupInfo> *p_groups) const {
} }
} }
bool Node::has_persistent_groups() const { int Node::get_persistent_group_count() const {
int count = 0;
for (const Map<StringName, GroupData>::Element *E = data.grouped.front(); E; E = E->next()) { for (const Map<StringName, GroupData>::Element *E = data.grouped.front(); E; E = E->next()) {
if (E->get().persistent) if (E->get().persistent) {
return true; count += 1;
}
} }
return false; return count;
} }
void Node::_print_tree_pretty(const String &prefix, const bool last) { void Node::_print_tree_pretty(const String &prefix, const bool last) {

View file

@ -300,7 +300,7 @@ public:
}; };
void get_groups(List<GroupInfo> *p_groups) const; void get_groups(List<GroupInfo> *p_groups) const;
bool has_persistent_groups() const; int get_persistent_group_count() const;
void move_child(Node *p_child, int p_pos); void move_child(Node *p_child, int p_pos);
void raise(); void raise();