summaryrefslogtreecommitdiff
path: root/scene/main
diff options
context:
space:
mode:
Diffstat (limited to 'scene/main')
-rw-r--r--scene/main/canvas_item.cpp10
-rw-r--r--scene/main/canvas_item.h1
-rw-r--r--scene/main/multiplayer_api.cpp2
-rw-r--r--scene/main/node.cpp11
-rw-r--r--scene/main/node.h1
-rw-r--r--scene/main/window.cpp20
-rw-r--r--scene/main/window.h6
7 files changed, 36 insertions, 15 deletions
diff --git a/scene/main/canvas_item.cpp b/scene/main/canvas_item.cpp
index bf0a8f7b6c..7b0554442c 100644
--- a/scene/main/canvas_item.cpp
+++ b/scene/main/canvas_item.cpp
@@ -388,6 +388,16 @@ Color CanvasItem::get_modulate() const {
return modulate;
}
+Color CanvasItem::get_modulate_in_tree() const {
+ Color final_modulate = modulate;
+ CanvasItem *parent_item = get_parent_item();
+ while (parent_item) {
+ final_modulate *= parent_item->get_modulate();
+ parent_item = parent_item->get_parent_item();
+ }
+ return final_modulate;
+}
+
void CanvasItem::set_as_top_level(bool p_top_level) {
if (top_level == p_top_level) {
return;
diff --git a/scene/main/canvas_item.h b/scene/main/canvas_item.h
index a7e9fc3c79..644fe856ec 100644
--- a/scene/main/canvas_item.h
+++ b/scene/main/canvas_item.h
@@ -224,6 +224,7 @@ public:
void set_modulate(const Color &p_modulate);
Color get_modulate() const;
+ Color get_modulate_in_tree() const;
void set_self_modulate(const Color &p_self_modulate);
Color get_self_modulate() const;
diff --git a/scene/main/multiplayer_api.cpp b/scene/main/multiplayer_api.cpp
index e36cbc4414..c54e61580f 100644
--- a/scene/main/multiplayer_api.cpp
+++ b/scene/main/multiplayer_api.cpp
@@ -135,7 +135,7 @@ Error MultiplayerAPI::encode_and_compress_variant(const Variant &p_variant, uint
return err;
}
if (r_buffer) {
- // The first byte is not used by the marshalling, so store the type
+ // The first byte is not used by the marshaling, so store the type
// so we know how to decompress and decode this variant.
r_buffer[0] = p_variant.get_type();
}
diff --git a/scene/main/node.cpp b/scene/main/node.cpp
index eb57ccfef1..0b1f8f101c 100644
--- a/scene/main/node.cpp
+++ b/scene/main/node.cpp
@@ -279,7 +279,10 @@ void Node::_propagate_exit_tree() {
//block while removing children
#ifdef DEBUG_ENABLED
- SceneDebugger::remove_from_cache(data.scene_file_path, this);
+ if (!data.scene_file_path.is_empty()) {
+ // Only remove if file path is set (optimization).
+ SceneDebugger::remove_from_cache(data.scene_file_path, this);
+ }
#endif
data.blocked++;
@@ -305,7 +308,6 @@ void Node::_propagate_exit_tree() {
}
// exit groups
-
for (KeyValue<StringName, GroupData> &E : data.grouped) {
data.tree->remove_from_group(E.key, this);
E.value.group = nullptr;
@@ -1166,7 +1168,7 @@ void Node::add_sibling(Node *p_sibling, bool p_force_readable_name) {
void Node::remove_child(Node *p_child) {
ERR_FAIL_NULL(p_child);
- ERR_FAIL_COND_MSG(data.blocked > 0, "Parent node is busy setting up children, `remove_child()` failed. Consider using `remove_child.call_deferred(child)` instead.");
+ ERR_FAIL_COND_MSG(data.blocked > 0, "Parent node is busy adding/removing children, `remove_child()` can't be called at this time. Consider using `remove_child.call_deferred(child)` instead.");
int child_count = data.children.size();
Node **children = data.children.ptrw();
@@ -1197,11 +1199,13 @@ void Node::remove_child(Node *p_child) {
data.internal_children_back--;
}
+ data.blocked++;
p_child->_set_tree(nullptr);
//}
remove_child_notify(p_child);
p_child->notification(NOTIFICATION_UNPARENTED);
+ data.blocked--;
data.children.remove_at(idx);
@@ -2943,6 +2947,7 @@ void Node::_bind_methods() {
BIND_CONSTANT(NOTIFICATION_POST_ENTER_TREE);
BIND_CONSTANT(NOTIFICATION_DISABLED);
BIND_CONSTANT(NOTIFICATION_ENABLED);
+ BIND_CONSTANT(NOTIFICATION_NODE_RECACHE_REQUESTED);
BIND_CONSTANT(NOTIFICATION_EDITOR_PRE_SAVE);
BIND_CONSTANT(NOTIFICATION_EDITOR_POST_SAVE);
diff --git a/scene/main/node.h b/scene/main/node.h
index dbdcca6170..493578bc5b 100644
--- a/scene/main/node.h
+++ b/scene/main/node.h
@@ -270,6 +270,7 @@ public:
NOTIFICATION_POST_ENTER_TREE = 27,
NOTIFICATION_DISABLED = 28,
NOTIFICATION_ENABLED = 29,
+ NOTIFICATION_NODE_RECACHE_REQUESTED = 30,
//keep these linked to node
NOTIFICATION_WM_MOUSE_ENTER = 1002,
diff --git a/scene/main/window.cpp b/scene/main/window.cpp
index 4baedc8c14..2c6599d849 100644
--- a/scene/main/window.cpp
+++ b/scene/main/window.cpp
@@ -227,7 +227,7 @@ void Window::_validate_property(PropertyInfo &p_property) const {
p_property.usage = PROPERTY_USAGE_NONE;
}
- if (p_property.name == "current_screen" && initial_position != WINDOW_INITIAL_POSITION_CENTER_SCREEN) {
+ if (p_property.name == "current_screen" && initial_position != WINDOW_INITIAL_POSITION_CENTER_OTHER_SCREEN) {
p_property.usage = PROPERTY_USAGE_NONE;
}
@@ -482,7 +482,11 @@ void Window::_make_window() {
Rect2i window_rect;
if (initial_position == WINDOW_INITIAL_POSITION_ABSOLUTE) {
window_rect = Rect2i(position, size);
- } else if (initial_position == WINDOW_INITIAL_POSITION_CENTER_SCREEN) {
+ } else if (initial_position == WINDOW_INITIAL_POSITION_CENTER_PRIMARY_SCREEN) {
+ window_rect = Rect2i(DisplayServer::get_singleton()->screen_get_position(DisplayServer::SCREEN_PRIMARY) + (DisplayServer::get_singleton()->screen_get_size(DisplayServer::SCREEN_PRIMARY) - size) / 2, size);
+ } else if (initial_position == WINDOW_INITIAL_POSITION_CENTER_MAIN_WINDOW_SCREEN) {
+ window_rect = Rect2i(DisplayServer::get_singleton()->screen_get_position(DisplayServer::SCREEN_OF_MAIN_WINDOW) + (DisplayServer::get_singleton()->screen_get_size(DisplayServer::SCREEN_OF_MAIN_WINDOW) - size) / 2, size);
+ } else if (initial_position == WINDOW_INITIAL_POSITION_CENTER_OTHER_SCREEN) {
window_rect = Rect2i(DisplayServer::get_singleton()->screen_get_position(current_screen) + (DisplayServer::get_singleton()->screen_get_size(current_screen) - size) / 2, size);
}
window_id = DisplayServer::get_singleton()->create_sub_window(DisplayServer::WindowMode(mode), vsync_mode, f, window_rect);
@@ -2246,18 +2250,14 @@ void Window::_bind_methods() {
ClassDB::bind_method(D_METHOD("popup_centered", "minsize"), &Window::popup_centered, DEFVAL(Size2i()));
ClassDB::bind_method(D_METHOD("popup_centered_clamped", "minsize", "fallback_ratio"), &Window::popup_centered_clamped, DEFVAL(Size2i()), DEFVAL(0.75));
- ADD_PROPERTY(PropertyInfo(Variant::INT, "initial_position", PROPERTY_HINT_ENUM, "Absolute,Screen Center"), "set_initial_position", "get_initial_position");
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "initial_position", PROPERTY_HINT_ENUM, "Absolute,Primary Screen Center,Main Window Screen Center,Other Screen Center"), "set_initial_position", "get_initial_position");
ADD_PROPERTY(PropertyInfo(Variant::STRING, "title"), "set_title", "get_title");
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2I, "position", PROPERTY_HINT_NONE, "suffix:px"), "set_position", "get_position");
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2I, "size", PROPERTY_HINT_NONE, "suffix:px"), "set_size", "get_size");
ADD_PROPERTY(PropertyInfo(Variant::INT, "mode", PROPERTY_HINT_ENUM, "Windowed,Minimized,Maximized,Fullscreen"), "set_mode", "get_mode");
// Keep the enum values in sync with the `DisplayServer::SCREEN_` enum.
- String screen_hints = "Primary Monitor:-2,Main Window Monitor:-1";
- for (int i = 0; i < 64; i++) {
- screen_hints += ",Monitor " + itos(i + 1) + ":" + itos(i);
- }
- ADD_PROPERTY(PropertyInfo(Variant::INT, "current_screen", PROPERTY_HINT_ENUM, screen_hints), "set_current_screen", "get_current_screen");
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "current_screen", PROPERTY_HINT_RANGE, "0,64,1,or_greater"), "set_current_screen", "get_current_screen");
ADD_PROPERTY(PropertyInfo(Variant::PACKED_VECTOR2_ARRAY, "mouse_passthrough_polygon"), "set_mouse_passthrough_polygon", "get_mouse_passthrough_polygon");
@@ -2340,7 +2340,9 @@ void Window::_bind_methods() {
BIND_ENUM_CONSTANT(LAYOUT_DIRECTION_RTL);
BIND_ENUM_CONSTANT(WINDOW_INITIAL_POSITION_ABSOLUTE);
- BIND_ENUM_CONSTANT(WINDOW_INITIAL_POSITION_CENTER_SCREEN);
+ BIND_ENUM_CONSTANT(WINDOW_INITIAL_POSITION_CENTER_PRIMARY_SCREEN);
+ BIND_ENUM_CONSTANT(WINDOW_INITIAL_POSITION_CENTER_MAIN_WINDOW_SCREEN);
+ BIND_ENUM_CONSTANT(WINDOW_INITIAL_POSITION_CENTER_OTHER_SCREEN);
}
Window::Window() {
diff --git a/scene/main/window.h b/scene/main/window.h
index d819ca7c60..e9c217f973 100644
--- a/scene/main/window.h
+++ b/scene/main/window.h
@@ -90,14 +90,16 @@ public:
enum WindowInitialPosition {
WINDOW_INITIAL_POSITION_ABSOLUTE,
- WINDOW_INITIAL_POSITION_CENTER_SCREEN,
+ WINDOW_INITIAL_POSITION_CENTER_PRIMARY_SCREEN,
+ WINDOW_INITIAL_POSITION_CENTER_MAIN_WINDOW_SCREEN,
+ WINDOW_INITIAL_POSITION_CENTER_OTHER_SCREEN,
};
private:
DisplayServer::WindowID window_id = DisplayServer::INVALID_WINDOW_ID;
String title;
- mutable int current_screen = DisplayServer::SCREEN_PRIMARY;
+ mutable int current_screen = 0;
mutable Vector2i position;
mutable Size2i size = Size2i(DEFAULT_WINDOW_SIZE, DEFAULT_WINDOW_SIZE);
mutable Size2i min_size;