diff options
-rw-r--r-- | drivers/gles3/rasterizer_scene_gles3.cpp | 4 | ||||
-rw-r--r-- | drivers/gles3/shader_compiler_gles3.cpp | 1 | ||||
-rw-r--r-- | editor/editor_node.cpp | 51 | ||||
-rw-r--r-- | editor/editor_node.h | 9 | ||||
-rw-r--r-- | editor/editor_settings.cpp | 5 | ||||
-rw-r--r-- | modules/gdscript/gd_compiler.cpp | 2 | ||||
-rw-r--r-- | scene/2d/screen_button.cpp | 23 | ||||
-rw-r--r-- | scene/2d/screen_button.h | 1 | ||||
-rw-r--r-- | scene/gui/dialogs.cpp | 14 | ||||
-rw-r--r-- | scene/main/node.cpp | 7 | ||||
-rw-r--r-- | scene/resources/packed_scene.cpp | 25 | ||||
-rw-r--r-- | scene/resources/packed_scene.h | 2 | ||||
-rw-r--r-- | scene/resources/shader_graph.cpp | 2 | ||||
-rw-r--r-- | servers/visual/shader_types.cpp | 4 |
14 files changed, 130 insertions, 20 deletions
diff --git a/drivers/gles3/rasterizer_scene_gles3.cpp b/drivers/gles3/rasterizer_scene_gles3.cpp index 9c4eecfa1f..d3936801dd 100644 --- a/drivers/gles3/rasterizer_scene_gles3.cpp +++ b/drivers/gles3/rasterizer_scene_gles3.cpp @@ -4519,8 +4519,8 @@ void RasterizerSceneGLES3::initialize() { glGenTextures(1, &directional_shadow.depth); glBindTexture(GL_TEXTURE_2D, directional_shadow.depth); glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT24, directional_shadow.size, directional_shadow.size, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, NULL); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE); diff --git a/drivers/gles3/shader_compiler_gles3.cpp b/drivers/gles3/shader_compiler_gles3.cpp index 12934a82e7..48ca86ebe2 100644 --- a/drivers/gles3/shader_compiler_gles3.cpp +++ b/drivers/gles3/shader_compiler_gles3.cpp @@ -624,6 +624,7 @@ ShaderCompilerGLES3::ShaderCompilerGLES3() { actions[VS::SHADER_CANVAS_ITEM].renames["TEXTURE_PIXEL_SIZE"] = "color_texpixel_size"; actions[VS::SHADER_CANVAS_ITEM].renames["SCREEN_UV"] = "screen_uv"; actions[VS::SHADER_CANVAS_ITEM].renames["SCREEN_TEXTURE"] = "screen_texture"; + actions[VS::SHADER_CANVAS_ITEM].renames["POSITION"] = "(gl_FragCoord.xy)"; actions[VS::SHADER_CANVAS_ITEM].renames["POINT_COORD"] = "gl_PointCoord"; actions[VS::SHADER_CANVAS_ITEM].renames["LIGHT_VEC"] = "light_vec"; diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index 00df0f337d..6a2222345a 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -925,6 +925,11 @@ void EditorNode::_save_scene(String p_file, int idx) { return; } + // force creation of node path cache + // (hacky but needed for the tree to update properly) + Node *dummy_scene = sdata->instance(PackedScene::GEN_EDIT_STATE_INSTANCE); + memdelete(dummy_scene); + int flg = 0; if (EditorSettings::get_singleton()->get("filesystem/on_save/compress_binary_resources")) flg |= ResourceSaver::FLAG_COMPRESS; @@ -4716,6 +4721,44 @@ void EditorNode::_open_imported() { load_scene(open_import_request, true, false, true, true); } +void EditorNode::dim_editor(bool p_dimming) { + static int dim_count = 0; + bool dim_ui = EditorSettings::get_singleton()->get("interface/dim_editor_on_dialog_popup"); + if (p_dimming) { + if (dim_ui && dim_count == 0) + _start_dimming(true); + dim_count++; + } else { + dim_count--; + if (dim_count < 1) + _start_dimming(false); + } +} + +void EditorNode::_start_dimming(bool p_dimming) { + _dimming = p_dimming; + _dim_time = 0.0f; + _dim_timer->start(); +} + +void EditorNode::_dim_timeout() { + + _dim_time += _dim_timer->get_wait_time(); + float wait_time = EditorSettings::get_singleton()->get("interface/dim_transition_time"); + + float c = 1.0f - (float)EditorSettings::get_singleton()->get("interface/dim_amount"); + + Color base = _dimming ? Color(1, 1, 1) : Color(c, c, c); + Color final = _dimming ? Color(c, c, c) : Color(1, 1, 1); + + if (_dim_time + _dim_timer->get_wait_time() >= wait_time) { + gui_base->set_modulate(final); + _dim_timer->stop(); + } else { + gui_base->set_modulate(base.linear_interpolate(final, _dim_time / wait_time)); + } +} + void EditorNode::_bind_methods() { ClassDB::bind_method("_menu_option", &EditorNode::_menu_option); @@ -4792,6 +4835,7 @@ void EditorNode::_bind_methods() { ClassDB::bind_method(D_METHOD("_open_imported"), &EditorNode::_open_imported); ClassDB::bind_method(D_METHOD("_inherit_imported"), &EditorNode::_inherit_imported); + ClassDB::bind_method(D_METHOD("_dim_timeout"), &EditorNode::_dim_timeout); ADD_SIGNAL(MethodInfo("play_pressed")); ADD_SIGNAL(MethodInfo("pause_pressed")); @@ -6102,6 +6146,13 @@ EditorNode::EditorNode() { FileAccess::set_file_close_fail_notify_callback(_file_access_close_error_notify); waiting_for_first_scan = true; + + _dimming = false; + _dim_time = 0.0f; + _dim_timer = memnew(Timer); + _dim_timer->set_wait_time(0.01666f); + _dim_timer->connect("timeout", this, "_dim_timeout"); + add_child(_dim_timer); } EditorNode::~EditorNode() { diff --git a/editor/editor_node.h b/editor/editor_node.h index cb165bdf21..ef8ae34475 100644 --- a/editor/editor_node.h +++ b/editor/editor_node.h @@ -598,6 +598,13 @@ private: void _tool_menu_insert_item(const ToolMenuItem &p_item); void _rebuild_tool_menu() const; + bool _dimming; + float _dim_time; + Timer *_dim_timer; + + void _start_dimming(bool p_dimming); + void _dim_timeout(); + protected: void _notification(int p_what); static void _bind_methods(); @@ -753,6 +760,8 @@ public: void add_tool_submenu_item(const String &p_name, PopupMenu *p_submenu); void remove_tool_menu_item(const String &p_name); + void dim_editor(bool p_dimming); + EditorNode(); ~EditorNode(); void get_singleton(const char *arg1, bool arg2); diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp index 8794a34f62..9e5021af6e 100644 --- a/editor/editor_settings.cpp +++ b/editor/editor_settings.cpp @@ -502,6 +502,11 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) { hints["interface/custom_font"] = PropertyInfo(Variant::STRING, "interface/custom_font", PROPERTY_HINT_GLOBAL_FILE, "*.fnt", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED); set("interface/custom_theme", ""); hints["interface/custom_theme"] = PropertyInfo(Variant::STRING, "interface/custom_theme", PROPERTY_HINT_GLOBAL_FILE, "*.res,*.tres,*.theme", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED); + set("interface/dim_editor_on_dialog_popup", true); + set("interface/dim_amount", 0.6f); + hints["interface/dim_amount"] = PropertyInfo(Variant::REAL, "interface/dim_amount", PROPERTY_HINT_RANGE, "0,1,0.01", PROPERTY_USAGE_DEFAULT); + set("interface/dim_transition_time", 0.11f); + hints["interface/dim_transition_time"] = PropertyInfo(Variant::REAL, "interface/dim_transition_time", PROPERTY_HINT_RANGE, "0,1,0.001", PROPERTY_USAGE_DEFAULT); set("filesystem/directories/autoscan_project_path", ""); hints["filesystem/directories/autoscan_project_path"] = PropertyInfo(Variant::STRING, "filesystem/directories/autoscan_project_path", PROPERTY_HINT_GLOBAL_DIR); diff --git a/modules/gdscript/gd_compiler.cpp b/modules/gdscript/gd_compiler.cpp index 9591740438..3f8c710674 100644 --- a/modules/gdscript/gd_compiler.cpp +++ b/modules/gdscript/gd_compiler.cpp @@ -1310,6 +1310,7 @@ Error GDCompiler::_parse_block(CodeGen &codegen, const GDParser::BlockNode *p_bl } } break; case GDParser::Node::TYPE_ASSERT: { +#ifdef DEBUG_ENABLED // try subblocks const GDParser::AssertNode *as = static_cast<const GDParser::AssertNode *>(s); @@ -1320,6 +1321,7 @@ Error GDCompiler::_parse_block(CodeGen &codegen, const GDParser::BlockNode *p_bl codegen.opcodes.push_back(GDFunction::OPCODE_ASSERT); codegen.opcodes.push_back(ret); +#endif } break; case GDParser::Node::TYPE_BREAKPOINT: { #ifdef DEBUG_ENABLED diff --git a/scene/2d/screen_button.cpp b/scene/2d/screen_button.cpp index 9b9fa6cfa8..db822ed306 100644 --- a/scene/2d/screen_button.cpp +++ b/scene/2d/screen_button.cpp @@ -135,7 +135,7 @@ void TouchScreenButton::_notification(int p_what) { update(); if (!get_tree()->is_editor_hint()) - set_process_input(true); + set_process_input(is_visible_in_tree()); if (action.operator String() != "" && InputMap::get_singleton()->has_action(action)) { action_id = InputMap::get_singleton()->get_action_id(action); @@ -147,10 +147,21 @@ void TouchScreenButton::_notification(int p_what) { if (is_pressed()) _release(true); } break; + case NOTIFICATION_VISIBILITY_CHANGED: { + if (get_tree()->is_editor_hint()) + break; + if (is_visible_in_tree()) { + set_process_input(true); + } else { + set_process_input(false); + if (is_pressed()) + _release(); + } + } break; case NOTIFICATION_PAUSED: { - // So the button can be pressed again even though the release gets unhandled because of coming during pause - allow_repress = true; - } + if (is_pressed()) + _release(); + } break; } } @@ -230,7 +241,7 @@ void TouchScreenButton::_input(const InputEvent &p_event) { if (!is_visible_in_tree()) return; - const bool can_press = finger_pressed == -1 || allow_repress; + const bool can_press = finger_pressed == -1; if (!can_press) return; //already fingering @@ -276,7 +287,6 @@ void TouchScreenButton::_input(const InputEvent &p_event) { void TouchScreenButton::_press(int p_finger_pressed) { finger_pressed = p_finger_pressed; - allow_repress = false; if (action_id != -1) { @@ -394,7 +404,6 @@ void TouchScreenButton::_bind_methods() { TouchScreenButton::TouchScreenButton() { finger_pressed = -1; - allow_repress = false; action_id = -1; passby_press = false; visibility = VISIBILITY_ALWAYS; diff --git a/scene/2d/screen_button.h b/scene/2d/screen_button.h index d648920b21..201d908bf6 100644 --- a/scene/2d/screen_button.h +++ b/scene/2d/screen_button.h @@ -56,7 +56,6 @@ private: StringName action; bool passby_press; int finger_pressed; - bool allow_repress; int action_id; VisibilityMode visibility; diff --git a/scene/gui/dialogs.cpp b/scene/gui/dialogs.cpp index d081eda86d..a58e62f061 100644 --- a/scene/gui/dialogs.cpp +++ b/scene/gui/dialogs.cpp @@ -31,6 +31,10 @@ #include "print_string.h" #include "translation.h" +#ifdef TOOLS_ENABLED +#include "editor/editor_node.h" +#endif + void WindowDialog::_post_popup() { drag_type = DRAG_NONE; // just in case @@ -199,6 +203,16 @@ void WindowDialog::_notification(int p_what) { set_default_cursor_shape(CURSOR_ARROW); } } break; +#ifdef TOOLS_ENABLED + case NOTIFICATION_POST_POPUP: { + if (get_tree() && get_tree()->is_editor_hint() && EditorNode::get_singleton()) + EditorNode::get_singleton()->dim_editor(true); + } break; + case NOTIFICATION_POPUP_HIDE: { + if (get_tree() && get_tree()->is_editor_hint() && EditorNode::get_singleton()) + EditorNode::get_singleton()->dim_editor(false); + } break; +#endif } } diff --git a/scene/main/node.cpp b/scene/main/node.cpp index 864e26a651..0245944154 100644 --- a/scene/main/node.cpp +++ b/scene/main/node.cpp @@ -2498,8 +2498,11 @@ void Node::_replace_connections_target(Node *p_new_target) { Connection &c = E->get(); - c.source->disconnect(c.signal, this, c.method); - c.source->connect(c.signal, p_new_target, c.method, c.binds, c.flags); + if (c.flags & CONNECT_PERSIST) { + c.source->disconnect(c.signal, this, c.method); + ERR_CONTINUE(!p_new_target->has_method(c.method)); + c.source->connect(c.signal, p_new_target, c.method, c.binds, c.flags); + } } } diff --git a/scene/resources/packed_scene.cpp b/scene/resources/packed_scene.cpp index 0c2f07aa4a..e46d9db7bc 100644 --- a/scene/resources/packed_scene.cpp +++ b/scene/resources/packed_scene.cpp @@ -995,12 +995,12 @@ int SceneState::find_node_by_path(const NodePath &p_node) const { if (_get_base_scene_state().is_valid()) { int idx = _get_base_scene_state()->find_node_by_path(p_node); if (idx >= 0) { - if (!base_scene_node_remap.has(idx)) { - int ridx = nodes.size() + base_scene_node_remap.size(); - base_scene_node_remap[ridx] = idx; + int rkey = _find_base_scene_node_remap_key(idx); + if (rkey == -1) { + rkey = nodes.size() + base_scene_node_remap.size(); + base_scene_node_remap[rkey] = idx; } - - return base_scene_node_remap[idx]; + return rkey; } } return -1; @@ -1013,11 +1013,24 @@ int SceneState::find_node_by_path(const NodePath &p_node) const { //the node in the instanced scene, as a property may be missing //from the local one int idx = _get_base_scene_state()->find_node_by_path(p_node); - base_scene_node_remap[nid] = idx; + if (idx != -1) { + base_scene_node_remap[nid] = idx; + } } return nid; } + +int SceneState::_find_base_scene_node_remap_key(int p_idx) const { + + for (Map<int, int>::Element *E = base_scene_node_remap.front(); E; E = E->next()) { + if (E->value() == p_idx) { + return E->key(); + } + } + return -1; +} + Variant SceneState::get_property_value(int p_node, const StringName &p_property, bool &found) const { found = false; diff --git a/scene/resources/packed_scene.h b/scene/resources/packed_scene.h index 5fa54413a8..b0e89205cb 100644 --- a/scene/resources/packed_scene.h +++ b/scene/resources/packed_scene.h @@ -100,6 +100,8 @@ class SceneState : public Reference { PoolVector<String> _get_node_groups(int p_idx) const; + int _find_base_scene_node_remap_key(int p_idx) const; + protected: static void _bind_methods(); diff --git a/scene/resources/shader_graph.cpp b/scene/resources/shader_graph.cpp index 49e987727d..28b8490cb4 100644 --- a/scene/resources/shader_graph.cpp +++ b/scene/resources/shader_graph.cpp @@ -1469,6 +1469,7 @@ const ShaderGraph::InOutParamInfo ShaderGraph::inout_param_info[]={ {MODE_CANVAS_ITEM,SHADER_TYPE_FRAGMENT,"Var1","VAR1.rgb","",SLOT_TYPE_VEC,SLOT_IN}, {MODE_CANVAS_ITEM,SHADER_TYPE_FRAGMENT,"Var2","VAR2.rgb","",SLOT_TYPE_VEC,SLOT_IN}, {MODE_CANVAS_ITEM,SHADER_TYPE_FRAGMENT,"PointCoord","POINT_COORD","",SLOT_TYPE_VEC,SLOT_IN}, + {MODE_CANVAS_ITEM,SHADER_TYPE_FRAGMENT,"Position","POSITION","",SLOT_TYPE_VEC,SLOT_IN}, //canvas item fragment out {MODE_CANVAS_ITEM,SHADER_TYPE_FRAGMENT,"Color","COLOR.rgb","",SLOT_TYPE_VEC,SLOT_OUT}, {MODE_CANVAS_ITEM,SHADER_TYPE_FRAGMENT,"Alpha","COLOR.a","",SLOT_TYPE_SCALAR,SLOT_OUT}, @@ -1489,6 +1490,7 @@ const ShaderGraph::InOutParamInfo ShaderGraph::inout_param_info[]={ {MODE_CANVAS_ITEM,SHADER_TYPE_LIGHT,"Var1","VAR1.rgb","",SLOT_TYPE_VEC,SLOT_IN}, {MODE_CANVAS_ITEM,SHADER_TYPE_LIGHT,"Var2","VAR2.rgb","",SLOT_TYPE_VEC,SLOT_IN}, {MODE_CANVAS_ITEM,SHADER_TYPE_LIGHT,"PointCoord","POINT_COORD","",SLOT_TYPE_VEC,SLOT_IN}, + {MODE_CANVAS_ITEM,SHADER_TYPE_LIGHT,"Position","POSITION","",SLOT_TYPE_VEC,SLOT_IN}, //canvas item light out {MODE_CANVAS_ITEM,SHADER_TYPE_LIGHT,"LightColor","LIGHT.rgb","",SLOT_TYPE_VEC,SLOT_OUT}, {MODE_CANVAS_ITEM,SHADER_TYPE_LIGHT,"LightAlpha","LIGHT.a","",SLOT_TYPE_SCALAR,SLOT_OUT}, diff --git a/servers/visual/shader_types.cpp b/servers/visual/shader_types.cpp index cd9afa7735..c5e31b235a 100644 --- a/servers/visual/shader_types.cpp +++ b/servers/visual/shader_types.cpp @@ -138,7 +138,7 @@ ShaderTypes::ShaderTypes() { shader_modes[VS::SHADER_CANVAS_ITEM].functions["vertex"]["TIME"] = ShaderLanguage::TYPE_FLOAT; shader_modes[VS::SHADER_CANVAS_ITEM].functions["fragment"]["SRC_COLOR"] = ShaderLanguage::TYPE_VEC4; - shader_modes[VS::SHADER_CANVAS_ITEM].functions["fragment"]["POSITION"] = ShaderLanguage::TYPE_VEC4; + shader_modes[VS::SHADER_CANVAS_ITEM].functions["fragment"]["POSITION"] = ShaderLanguage::TYPE_VEC2; shader_modes[VS::SHADER_CANVAS_ITEM].functions["fragment"]["NORMAL"] = ShaderLanguage::TYPE_VEC3; shader_modes[VS::SHADER_CANVAS_ITEM].functions["fragment"]["NORMALMAP"] = ShaderLanguage::TYPE_VEC3; shader_modes[VS::SHADER_CANVAS_ITEM].functions["fragment"]["NORMALMAP_DEPTH"] = ShaderLanguage::TYPE_FLOAT; @@ -150,7 +150,7 @@ ShaderTypes::ShaderTypes() { shader_modes[VS::SHADER_CANVAS_ITEM].functions["fragment"]["POINT_COORD"] = ShaderLanguage::TYPE_VEC2; shader_modes[VS::SHADER_CANVAS_ITEM].functions["fragment"]["TIME"] = ShaderLanguage::TYPE_FLOAT; - shader_modes[VS::SHADER_CANVAS_ITEM].functions["light"]["POSITION"] = ShaderLanguage::TYPE_VEC4; + shader_modes[VS::SHADER_CANVAS_ITEM].functions["light"]["POSITION"] = ShaderLanguage::TYPE_VEC2; shader_modes[VS::SHADER_CANVAS_ITEM].functions["light"]["NORMAL"] = ShaderLanguage::TYPE_VEC3; shader_modes[VS::SHADER_CANVAS_ITEM].functions["light"]["UV"] = ShaderLanguage::TYPE_VEC2; shader_modes[VS::SHADER_CANVAS_ITEM].functions["light"]["COLOR"] = ShaderLanguage::TYPE_VEC4; |