Add some codes, returnes directly if the value is not changed.

Avoid executing the following value-changed logics if the value does not really change.
This commit is contained in:
风青山 2022-03-16 15:50:48 +08:00 committed by Rindbee
parent ba0421f3d9
commit e561c68256
33 changed files with 952 additions and 34 deletions

View file

@ -505,6 +505,10 @@ bool GraphNode::is_slot_enabled_left(int p_idx) const {
void GraphNode::set_slot_enabled_left(int p_idx, bool p_enable_left) {
ERR_FAIL_COND_MSG(p_idx < 0, vformat("Cannot set enable_left for the slot with p_idx (%d) lesser than zero.", p_idx));
if (slot_info[p_idx].enable_left == p_enable_left) {
return;
}
slot_info[p_idx].enable_left = p_enable_left;
update();
connpos_dirty = true;
@ -515,6 +519,10 @@ void GraphNode::set_slot_enabled_left(int p_idx, bool p_enable_left) {
void GraphNode::set_slot_type_left(int p_idx, int p_type_left) {
ERR_FAIL_COND_MSG(!slot_info.has(p_idx), vformat("Cannot set type_left for the slot '%d' because it hasn't been enabled.", p_idx));
if (slot_info[p_idx].type_left == p_type_left) {
return;
}
slot_info[p_idx].type_left = p_type_left;
update();
connpos_dirty = true;
@ -532,6 +540,10 @@ int GraphNode::get_slot_type_left(int p_idx) const {
void GraphNode::set_slot_color_left(int p_idx, const Color &p_color_left) {
ERR_FAIL_COND_MSG(!slot_info.has(p_idx), vformat("Cannot set color_left for the slot '%d' because it hasn't been enabled.", p_idx));
if (slot_info[p_idx].color_left == p_color_left) {
return;
}
slot_info[p_idx].color_left = p_color_left;
update();
connpos_dirty = true;
@ -556,6 +568,10 @@ bool GraphNode::is_slot_enabled_right(int p_idx) const {
void GraphNode::set_slot_enabled_right(int p_idx, bool p_enable_right) {
ERR_FAIL_COND_MSG(p_idx < 0, vformat("Cannot set enable_right for the slot with p_idx (%d) lesser than zero.", p_idx));
if (slot_info[p_idx].enable_right == p_enable_right) {
return;
}
slot_info[p_idx].enable_right = p_enable_right;
update();
connpos_dirty = true;
@ -566,6 +582,10 @@ void GraphNode::set_slot_enabled_right(int p_idx, bool p_enable_right) {
void GraphNode::set_slot_type_right(int p_idx, int p_type_right) {
ERR_FAIL_COND_MSG(!slot_info.has(p_idx), vformat("Cannot set type_right for the slot '%d' because it hasn't been enabled.", p_idx));
if (slot_info[p_idx].type_right == p_type_right) {
return;
}
slot_info[p_idx].type_right = p_type_right;
update();
connpos_dirty = true;
@ -583,6 +603,10 @@ int GraphNode::get_slot_type_right(int p_idx) const {
void GraphNode::set_slot_color_right(int p_idx, const Color &p_color_right) {
ERR_FAIL_COND_MSG(!slot_info.has(p_idx), vformat("Cannot set color_right for the slot '%d' because it hasn't been enabled.", p_idx));
if (slot_info[p_idx].color_right == p_color_right) {
return;
}
slot_info[p_idx].color_right = p_color_right;
update();
connpos_dirty = true;
@ -700,6 +724,10 @@ String GraphNode::get_language() const {
}
void GraphNode::set_position_offset(const Vector2 &p_offset) {
if (position_offset == p_offset) {
return;
}
position_offset = p_offset;
emit_signal(SNAME("position_offset_changed"));
update();
@ -710,6 +738,10 @@ Vector2 GraphNode::get_position_offset() const {
}
void GraphNode::set_selected(bool p_selected) {
if (selected == p_selected) {
return;
}
selected = p_selected;
update();
}
@ -731,6 +763,10 @@ Vector2 GraphNode::get_drag_from() {
}
void GraphNode::set_show_close_button(bool p_enable) {
if (show_close == p_enable) {
return;
}
show_close = p_enable;
update();
}
@ -931,6 +967,10 @@ void GraphNode::gui_input(const Ref<InputEvent> &p_ev) {
}
void GraphNode::set_overlay(Overlay p_overlay) {
if (overlay == p_overlay) {
return;
}
overlay = p_overlay;
update();
}
@ -940,6 +980,10 @@ GraphNode::Overlay GraphNode::get_overlay() const {
}
void GraphNode::set_comment(bool p_enable) {
if (comment == p_enable) {
return;
}
comment = p_enable;
update();
}
@ -949,6 +993,10 @@ bool GraphNode::is_comment() const {
}
void GraphNode::set_resizable(bool p_enable) {
if (resizable == p_enable) {
return;
}
resizable = p_enable;
update();
}