mirror of
https://github.com/godotengine/godot.git
synced 2025-10-15 02:49:24 +00:00
Compare commits
24 Commits
e825169957
...
0400b703e4
Author | SHA1 | Date | |
---|---|---|---|
![]() |
0400b703e4 | ||
![]() |
9cdf3ff3ff | ||
![]() |
0b47123768 | ||
![]() |
9554c2bc56 | ||
![]() |
4d3a899c64 | ||
![]() |
920552812e | ||
![]() |
9659dc13bd | ||
![]() |
b7bbdfd31c | ||
![]() |
79e533679c | ||
![]() |
e6768b5db4 | ||
![]() |
c2720efb28 | ||
![]() |
879d4439e7 | ||
![]() |
66e5bce653 | ||
![]() |
b3bb376391 | ||
![]() |
7d3c25d083 | ||
![]() |
8173f43770 | ||
![]() |
1e0b41ab27 | ||
![]() |
bad44931a8 | ||
![]() |
d86a428994 | ||
![]() |
8e3499a961 | ||
![]() |
636763276e | ||
![]() |
36c7bbb47a | ||
![]() |
ddcb3cfcf5 | ||
![]() |
a4b5b0ec68 |
@@ -2284,6 +2284,8 @@ void Object::_construct_object(bool p_reference) {
|
||||
_block_signals = false;
|
||||
_can_translate = true;
|
||||
_emitting = false;
|
||||
_is_queued_for_deletion = false;
|
||||
_predelete_ok = false;
|
||||
|
||||
// ObjectDB::add_instance relies on AncestralClass::REF_COUNTED
|
||||
// being already set in the case of references.
|
||||
|
@@ -39,7 +39,6 @@
|
||||
#include "core/templates/hash_set.h"
|
||||
#include "core/templates/list.h"
|
||||
#include "core/templates/safe_refcount.h"
|
||||
#include "core/variant/callable_bind.h"
|
||||
#include "core/variant/variant.h"
|
||||
|
||||
template <typename T>
|
||||
|
@@ -33,6 +33,7 @@
|
||||
#include "core/io/resource.h"
|
||||
#include "core/os/os.h"
|
||||
#include "core/templates/local_vector.h"
|
||||
#include "core/variant/callable_bind.h"
|
||||
|
||||
void UndoRedo::Operation::delete_reference() {
|
||||
if (type != Operation::TYPE_REFERENCE) {
|
||||
|
@@ -285,7 +285,7 @@
|
||||
<method name="set_input_as_handled">
|
||||
<return type="void" />
|
||||
<description>
|
||||
Stops the input from propagating further down the [SceneTree].
|
||||
Stops the input from propagating further up the [SceneTree].
|
||||
[b]Note:[/b] This does not affect the methods in [Input], only the way events are propagated.
|
||||
</description>
|
||||
</method>
|
||||
|
@@ -30,6 +30,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "core/io/image.h"
|
||||
#include "editor/inspector/editor_resource_preview.h"
|
||||
|
||||
class ScriptLanguage;
|
||||
|
@@ -106,6 +106,7 @@
|
||||
#include "editor/scene/gradient_editor_plugin.h"
|
||||
#include "editor/scene/gui/control_editor_plugin.h"
|
||||
#include "editor/scene/gui/font_config_plugin.h"
|
||||
#include "editor/scene/gui/margin_container_editor_plugin.h"
|
||||
#include "editor/scene/gui/style_box_editor_plugin.h"
|
||||
#include "editor/scene/gui/theme_editor_plugin.h"
|
||||
#include "editor/scene/material_editor_plugin.h"
|
||||
@@ -231,6 +232,7 @@ void register_editor_types() {
|
||||
EditorPlugins::add_by_type<GradientTexture2DEditorPlugin>();
|
||||
EditorPlugins::add_by_type<InputEventEditorPlugin>();
|
||||
EditorPlugins::add_by_type<LightmapGIEditorPlugin>();
|
||||
EditorPlugins::add_by_type<MarginContainerEditorPlugin>();
|
||||
EditorPlugins::add_by_type<MaterialEditorPlugin>();
|
||||
EditorPlugins::add_by_type<MeshEditorPlugin>();
|
||||
EditorPlugins::add_by_type<MeshInstance3DEditorPlugin>();
|
||||
|
@@ -1573,6 +1573,37 @@ Transform3D Node3DEditorViewport::_compute_transform(TransformMode p_mode, const
|
||||
}
|
||||
}
|
||||
|
||||
void Node3DEditorViewport::_reset_transform(TransformType p_type) {
|
||||
List<Node *> selection = editor_selection->get_full_selected_node_list();
|
||||
if (selection.is_empty()) {
|
||||
return;
|
||||
}
|
||||
EditorUndoRedoManager *undo_redo = EditorUndoRedoManager::get_singleton();
|
||||
undo_redo->create_action(TTR("Reset Transform"));
|
||||
for (Node *node : selection) {
|
||||
Node3D *sp = Object::cast_to<Node3D>(node);
|
||||
if (!sp) {
|
||||
continue;
|
||||
}
|
||||
|
||||
switch (p_type) {
|
||||
case TransformType::POSITION:
|
||||
undo_redo->add_undo_method(sp, "set_position", sp->get_position());
|
||||
undo_redo->add_do_method(sp, "set_position", Vector3());
|
||||
break;
|
||||
case TransformType::ROTATION:
|
||||
undo_redo->add_undo_method(sp, "set_rotation", sp->get_rotation());
|
||||
undo_redo->add_do_method(sp, "set_rotation", Vector3());
|
||||
break;
|
||||
case TransformType::SCALE:
|
||||
undo_redo->add_undo_method(sp, "set_scale", sp->get_scale());
|
||||
undo_redo->add_do_method(sp, "set_scale", Vector3(1, 1, 1));
|
||||
break;
|
||||
}
|
||||
}
|
||||
undo_redo->commit_action();
|
||||
}
|
||||
|
||||
void Node3DEditorViewport::_surface_mouse_enter() {
|
||||
if (Input::get_singleton()->get_mouse_mode() == Input::MOUSE_MODE_CAPTURED) {
|
||||
return;
|
||||
@@ -2573,6 +2604,15 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
|
||||
cancel_transform();
|
||||
}
|
||||
if (!is_freelook_active() && !k->is_echo()) {
|
||||
if (ED_IS_SHORTCUT("spatial_editor/reset_transform_position", p_event)) {
|
||||
_reset_transform(TransformType::POSITION);
|
||||
}
|
||||
if (ED_IS_SHORTCUT("spatial_editor/reset_transform_rotation", p_event)) {
|
||||
_reset_transform(TransformType::ROTATION);
|
||||
}
|
||||
if (ED_IS_SHORTCUT("spatial_editor/reset_transform_scale", p_event)) {
|
||||
_reset_transform(TransformType::SCALE);
|
||||
}
|
||||
if (ED_IS_SHORTCUT("spatial_editor/instant_translate", p_event) && (_edit.mode != TRANSFORM_TRANSLATE || collision_reposition)) {
|
||||
if (_edit.mode == TRANSFORM_NONE) {
|
||||
begin_transform(TRANSFORM_TRANSLATE, true);
|
||||
@@ -6041,6 +6081,9 @@ Node3DEditorViewport::Node3DEditorViewport(Node3DEditor *p_spatial_editor, int p
|
||||
ED_SHORTCUT("spatial_editor/instant_rotate", TTRC("Begin Rotate Transformation"));
|
||||
ED_SHORTCUT("spatial_editor/instant_scale", TTRC("Begin Scale Transformation"));
|
||||
ED_SHORTCUT("spatial_editor/collision_reposition", TTRC("Reposition Using Collisions"), KeyModifierMask::SHIFT | Key::G);
|
||||
ED_SHORTCUT("spatial_editor/reset_transform_position", TTRC("Reset Position"), KeyModifierMask::ALT + Key::W);
|
||||
ED_SHORTCUT("spatial_editor/reset_transform_rotation", TTRC("Reset Rotation"), KeyModifierMask::ALT + Key::E);
|
||||
ED_SHORTCUT("spatial_editor/reset_transform_scale", TTRC("Reset Scale"), KeyModifierMask::ALT + Key::R);
|
||||
|
||||
translation_preview_button = memnew(EditorTranslationPreviewButton);
|
||||
hbox->add_child(translation_preview_button);
|
||||
|
@@ -365,6 +365,11 @@ private:
|
||||
TRANSFORM_XZ,
|
||||
TRANSFORM_XY,
|
||||
};
|
||||
enum TransformType {
|
||||
POSITION,
|
||||
ROTATION,
|
||||
SCALE,
|
||||
};
|
||||
|
||||
struct EditData {
|
||||
TransformMode mode;
|
||||
@@ -524,6 +529,8 @@ private:
|
||||
|
||||
Transform3D _compute_transform(TransformMode p_mode, const Transform3D &p_original, const Transform3D &p_original_local, Vector3 p_motion, double p_extra, bool p_local, bool p_orthogonal);
|
||||
|
||||
void _reset_transform(TransformType p_type);
|
||||
|
||||
void begin_transform(TransformMode p_mode, bool instant);
|
||||
void commit_transform();
|
||||
void apply_transform(Vector3 p_motion, double p_snap);
|
||||
|
@@ -530,6 +530,18 @@ void CanvasItemEditor::shortcut_input(const Ref<InputEvent> &p_ev) {
|
||||
viewport->queue_redraw();
|
||||
}
|
||||
}
|
||||
|
||||
if (k->is_pressed() && !k->is_echo()) {
|
||||
if (reset_transform_position_shortcut.is_valid() && reset_transform_position_shortcut->matches_event(p_ev)) {
|
||||
_reset_transform(TransformType::POSITION);
|
||||
}
|
||||
if (reset_transform_rotation_shortcut.is_valid() && reset_transform_rotation_shortcut->matches_event(p_ev)) {
|
||||
_reset_transform(TransformType::ROTATION);
|
||||
}
|
||||
if (reset_transform_scale_shortcut.is_valid() && reset_transform_scale_shortcut->matches_event(p_ev)) {
|
||||
_reset_transform(TransformType::SCALE);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1094,6 +1106,53 @@ void CanvasItemEditor::_on_grid_menu_id_pressed(int p_id) {
|
||||
viewport->queue_redraw();
|
||||
}
|
||||
|
||||
void CanvasItemEditor::_reset_transform(TransformType p_type) {
|
||||
List<Node *> selection = editor_selection->get_full_selected_node_list();
|
||||
if (selection.is_empty()) {
|
||||
return;
|
||||
}
|
||||
EditorUndoRedoManager *undo_redo = EditorUndoRedoManager::get_singleton();
|
||||
undo_redo->create_action(TTR("Reset Transform"));
|
||||
for (Node *node : selection) {
|
||||
Node2D *res_node = Object::cast_to<Node2D>(node);
|
||||
if (res_node) {
|
||||
switch (p_type) {
|
||||
case TransformType::POSITION:
|
||||
undo_redo->add_undo_method(res_node, "set_position", res_node->get_position());
|
||||
undo_redo->add_do_method(res_node, "set_position", Vector2());
|
||||
break;
|
||||
case TransformType::ROTATION:
|
||||
undo_redo->add_undo_method(res_node, "set_rotation", res_node->get_rotation());
|
||||
undo_redo->add_do_method(res_node, "set_rotation", 0);
|
||||
break;
|
||||
case TransformType::SCALE:
|
||||
undo_redo->add_undo_method(res_node, "set_scale", res_node->get_scale());
|
||||
undo_redo->add_do_method(res_node, "set_scale", Size2(1, 1));
|
||||
break;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
Control *res_control = Object::cast_to<Control>(node);
|
||||
if (res_control) {
|
||||
switch (p_type) {
|
||||
case TransformType::POSITION:
|
||||
undo_redo->add_undo_method(res_control, "set_position", res_control->get_position());
|
||||
undo_redo->add_do_method(res_control, "set_position", Vector2());
|
||||
break;
|
||||
case TransformType::ROTATION:
|
||||
undo_redo->add_undo_method(res_control, "set_rotation", res_control->get_rotation());
|
||||
undo_redo->add_do_method(res_control, "set_rotation", 0);
|
||||
break;
|
||||
case TransformType::SCALE:
|
||||
undo_redo->add_undo_method(res_control, "set_scale", res_control->get_scale());
|
||||
undo_redo->add_do_method(res_control, "set_scale", Size2(1, 1));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
undo_redo->commit_action();
|
||||
}
|
||||
|
||||
void CanvasItemEditor::_switch_theme_preview(int p_mode) {
|
||||
view_menu->get_popup()->hide();
|
||||
|
||||
@@ -5803,6 +5862,9 @@ CanvasItemEditor::CanvasItemEditor() {
|
||||
|
||||
multiply_grid_step_shortcut = ED_SHORTCUT("canvas_item_editor/multiply_grid_step", TTRC("Multiply grid step by 2"), Key::KP_MULTIPLY);
|
||||
divide_grid_step_shortcut = ED_SHORTCUT("canvas_item_editor/divide_grid_step", TTRC("Divide grid step by 2"), Key::KP_DIVIDE);
|
||||
reset_transform_position_shortcut = ED_SHORTCUT("canvas_item_editor/reset_transform_position", TTRC("Reset Position"), KeyModifierMask::ALT + Key::W);
|
||||
reset_transform_rotation_shortcut = ED_SHORTCUT("canvas_item_editor/reset_transform_rotation", TTRC("Reset Rotation"), KeyModifierMask::ALT + Key::E);
|
||||
reset_transform_scale_shortcut = ED_SHORTCUT("canvas_item_editor/reset_transform_scale", TTRC("Reset Scale"), KeyModifierMask::ALT + Key::R);
|
||||
|
||||
skeleton_menu->get_popup()->set_item_checked(skeleton_menu->get_popup()->get_item_index(SKELETON_SHOW_BONES), true);
|
||||
|
||||
|
@@ -186,6 +186,12 @@ private:
|
||||
GRID_VISIBILITY_HIDE,
|
||||
};
|
||||
|
||||
enum TransformType {
|
||||
POSITION,
|
||||
ROTATION,
|
||||
SCALE,
|
||||
};
|
||||
|
||||
const String locked_transform_warning = TTRC("All selected CanvasItems are either invisible or locked in some way and can't be transformed.");
|
||||
|
||||
bool selection_menu_additive_selection = false;
|
||||
@@ -381,6 +387,9 @@ private:
|
||||
Ref<Shortcut> set_pivot_shortcut;
|
||||
Ref<Shortcut> multiply_grid_step_shortcut;
|
||||
Ref<Shortcut> divide_grid_step_shortcut;
|
||||
Ref<Shortcut> reset_transform_position_shortcut;
|
||||
Ref<Shortcut> reset_transform_rotation_shortcut;
|
||||
Ref<Shortcut> reset_transform_scale_shortcut;
|
||||
|
||||
Ref<ViewPanner> panner;
|
||||
void _pan_callback(Vector2 p_scroll_vec, Ref<InputEvent> p_event);
|
||||
@@ -420,6 +429,7 @@ private:
|
||||
bool _is_grid_visible() const;
|
||||
void _prepare_grid_menu();
|
||||
void _on_grid_menu_id_pressed(int p_id);
|
||||
void _reset_transform(TransformType p_type);
|
||||
|
||||
public:
|
||||
enum ThemePreviewMode {
|
||||
|
@@ -30,6 +30,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "core/variant/callable_bind.h"
|
||||
#include "scene/gui/dialogs.h"
|
||||
#include "scene/gui/tree.h"
|
||||
|
||||
|
94
editor/scene/gui/margin_container_editor_plugin.cpp
Normal file
94
editor/scene/gui/margin_container_editor_plugin.cpp
Normal file
@@ -0,0 +1,94 @@
|
||||
/**************************************************************************/
|
||||
/* margin_container_editor_plugin.cpp */
|
||||
/**************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/**************************************************************************/
|
||||
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
|
||||
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
/* "Software"), to deal in the Software without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* */
|
||||
/* The above copyright notice and this permission notice shall be */
|
||||
/* included in all copies or substantial portions of the Software. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
|
||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#include "margin_container_editor_plugin.h"
|
||||
|
||||
#include "editor/scene/canvas_item_editor_plugin.h"
|
||||
#include "editor/themes/editor_scale.h"
|
||||
|
||||
void MarginContainerEditorPlugin::edit(Object *p_object) {
|
||||
if (margin_container) {
|
||||
margin_container->disconnect(SNAME("draw"), callable_mp(CanvasItemEditor::get_singleton(), &CanvasItemEditor::update_viewport));
|
||||
}
|
||||
|
||||
margin_container = Object::cast_to<MarginContainer>(p_object);
|
||||
|
||||
if (margin_container) {
|
||||
margin_container->connect(SNAME("draw"), callable_mp(CanvasItemEditor::get_singleton(), &CanvasItemEditor::update_viewport));
|
||||
}
|
||||
CanvasItemEditor::get_singleton()->update_viewport();
|
||||
}
|
||||
|
||||
bool MarginContainerEditorPlugin::handles(Object *p_object) const {
|
||||
return Object::cast_to<MarginContainer>(p_object) != nullptr;
|
||||
}
|
||||
|
||||
void MarginContainerEditorPlugin::forward_canvas_draw_over_viewport(Control *p_viewport_control) {
|
||||
if (!margin_container) {
|
||||
return;
|
||||
}
|
||||
|
||||
Transform2D xform = CanvasItemEditor::get_singleton()->get_canvas_transform() * margin_container->get_screen_transform();
|
||||
|
||||
// NOTE: This color is copied from Camera2DEditor::forward_canvas_draw_over_viewport.
|
||||
// We may want to unify them somehow in the future.
|
||||
Color border_color = Color(1, 1, 0.25, 0.63);
|
||||
|
||||
int border_width = Math::round(1 * EDSCALE);
|
||||
|
||||
Rect2 rect = margin_container->_edit_get_rect();
|
||||
|
||||
int margin_left = margin_container->get_margin_size(SIDE_LEFT);
|
||||
int margin_top = margin_container->get_margin_size(SIDE_TOP);
|
||||
int margin_right = margin_container->get_margin_size(SIDE_RIGHT);
|
||||
int margin_bottom = margin_container->get_margin_size(SIDE_BOTTOM);
|
||||
|
||||
Vector2 p1, p2;
|
||||
|
||||
// Calculate left margin line.
|
||||
p1 = xform.xform(rect.position + Vector2(margin_left, margin_top));
|
||||
p2 = xform.xform(rect.position + Vector2(margin_left, rect.size.y - margin_bottom));
|
||||
p_viewport_control->draw_line(p1, p2, border_color, border_width);
|
||||
|
||||
// Calculate top margin line.
|
||||
p1 = xform.xform(rect.position + Vector2(margin_left, margin_top));
|
||||
p2 = xform.xform(rect.position + Vector2(rect.size.x - margin_right, margin_top));
|
||||
p_viewport_control->draw_line(p1, p2, border_color, border_width);
|
||||
|
||||
// Calculate right margin line.
|
||||
p1 = xform.xform(rect.position + Vector2(rect.size.x - margin_right, margin_top));
|
||||
p2 = xform.xform(rect.position + Vector2(rect.size.x - margin_right, rect.size.y - margin_bottom));
|
||||
p_viewport_control->draw_line(p1, p2, border_color, border_width);
|
||||
|
||||
// Calculate bottom margin line.
|
||||
p1 = xform.xform(rect.position + Vector2(margin_left, rect.size.y - margin_bottom));
|
||||
p2 = xform.xform(rect.position + Vector2(rect.size.x - margin_right, rect.size.y - margin_bottom));
|
||||
p_viewport_control->draw_line(p1, p2, border_color, border_width);
|
||||
}
|
48
editor/scene/gui/margin_container_editor_plugin.h
Normal file
48
editor/scene/gui/margin_container_editor_plugin.h
Normal file
@@ -0,0 +1,48 @@
|
||||
/**************************************************************************/
|
||||
/* margin_container_editor_plugin.h */
|
||||
/**************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/**************************************************************************/
|
||||
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
|
||||
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
/* "Software"), to deal in the Software without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* */
|
||||
/* The above copyright notice and this permission notice shall be */
|
||||
/* included in all copies or substantial portions of the Software. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
|
||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "editor/plugins/editor_plugin.h"
|
||||
#include "scene/gui/margin_container.h"
|
||||
|
||||
class CanvasItemEditor;
|
||||
|
||||
class MarginContainerEditorPlugin : public EditorPlugin {
|
||||
GDCLASS(MarginContainerEditorPlugin, EditorPlugin);
|
||||
|
||||
MarginContainer *margin_container = nullptr;
|
||||
|
||||
public:
|
||||
void forward_canvas_draw_over_viewport(Control *p_viewport_control) override;
|
||||
|
||||
virtual void edit(Object *p_object) override;
|
||||
virtual bool handles(Object *p_object) const override;
|
||||
};
|
@@ -1291,6 +1291,16 @@ void _save_text_editor_theme_as(const String &p_file) {
|
||||
}
|
||||
}
|
||||
|
||||
bool ScriptEditor::_script_exists(const String &p_path) const {
|
||||
if (p_path.is_empty()) {
|
||||
return false;
|
||||
} else if (p_path.is_resource_file()) {
|
||||
return FileAccess::exists(p_path);
|
||||
} else {
|
||||
return FileAccess::exists(p_path.get_slice("::", 0));
|
||||
}
|
||||
}
|
||||
|
||||
void ScriptEditor::_file_dialog_action(const String &p_file) {
|
||||
switch (file_dialog_option) {
|
||||
case FILE_MENU_NEW_TEXTFILE: {
|
||||
@@ -3038,7 +3048,7 @@ void ScriptEditor::_save_editor_state(ScriptEditorBase *p_editor) {
|
||||
}
|
||||
|
||||
const String &path = p_editor->get_edited_resource()->get_path();
|
||||
if (!path.is_resource_file()) {
|
||||
if (path.is_empty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -3435,7 +3445,7 @@ void ScriptEditor::input(const Ref<InputEvent> &p_event) {
|
||||
void ScriptEditor::shortcut_input(const Ref<InputEvent> &p_event) {
|
||||
ERR_FAIL_COND(p_event.is_null());
|
||||
|
||||
if (!is_visible_in_tree() || !p_event->is_pressed() || p_event->is_echo()) {
|
||||
if (!is_visible_in_tree() || !p_event->is_pressed()) {
|
||||
return;
|
||||
}
|
||||
if (ED_IS_SHORTCUT("script_editor/next_script", p_event)) {
|
||||
@@ -3465,6 +3475,10 @@ void ScriptEditor::shortcut_input(const Ref<InputEvent> &p_event) {
|
||||
accept_event();
|
||||
}
|
||||
|
||||
if (p_event->is_echo()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Callable custom_callback = EditorContextMenuPluginManager::get_singleton()->match_custom_shortcut(EditorContextMenuPlugin::CONTEXT_SLOT_SCRIPT_EDITOR, p_event);
|
||||
if (custom_callback.is_valid()) {
|
||||
Ref<Resource> resource;
|
||||
@@ -3574,23 +3588,37 @@ void ScriptEditor::set_window_layout(Ref<ConfigFile> p_layout) {
|
||||
ResourceLoader::get_recognized_extensions_for_type("Script", &extensions);
|
||||
ResourceLoader::get_recognized_extensions_for_type("JSON", &extensions);
|
||||
|
||||
for (int i = 0; i < scripts.size(); i++) {
|
||||
String path = scripts[i];
|
||||
for (const Variant &v : scripts) {
|
||||
String path = v;
|
||||
|
||||
Dictionary script_info = scripts[i];
|
||||
Dictionary script_info = v;
|
||||
if (!script_info.is_empty()) {
|
||||
path = script_info["path"];
|
||||
}
|
||||
|
||||
if (!FileAccess::exists(path)) {
|
||||
if (!_script_exists(path)) {
|
||||
if (script_editor_cache->has_section(path)) {
|
||||
script_editor_cache->erase_section(path);
|
||||
}
|
||||
continue;
|
||||
} else if (!path.is_resource_file() && !EditorNode::get_singleton()->is_scene_open(path.get_slice("::", 0))) {
|
||||
continue;
|
||||
}
|
||||
loaded_scripts.insert(path);
|
||||
|
||||
if (extensions.find(path.get_extension())) {
|
||||
bool is_script = false;
|
||||
if (path.is_resource_file()) {
|
||||
is_script = extensions.find(path.get_extension());
|
||||
} else {
|
||||
Ref<Script> scr = ResourceCache::get_ref(path);
|
||||
if (scr.is_valid()) {
|
||||
is_script = true;
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (is_script) {
|
||||
Ref<Resource> scr = ResourceLoader::load(path);
|
||||
if (scr.is_null()) {
|
||||
continue;
|
||||
@@ -3645,7 +3673,7 @@ void ScriptEditor::set_window_layout(Ref<ConfigFile> p_layout) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!FileAccess::exists(E)) {
|
||||
if (!_script_exists(E)) {
|
||||
script_editor_cache->erase_section(E);
|
||||
continue;
|
||||
}
|
||||
@@ -3682,8 +3710,8 @@ void ScriptEditor::get_window_layout(Ref<ConfigFile> p_layout) {
|
||||
for (int i = 0; i < tab_container->get_tab_count(); i++) {
|
||||
ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(tab_container->get_tab_control(i));
|
||||
if (se) {
|
||||
String path = se->get_edited_resource()->get_path();
|
||||
if (!path.is_resource_file()) {
|
||||
const String path = se->get_edited_resource()->get_path();
|
||||
if (path.is_empty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@@ -409,6 +409,7 @@ class ScriptEditor : public PanelContainer {
|
||||
void _resave_scripts(const String &p_str);
|
||||
|
||||
bool _test_script_times_on_disk(Ref<Resource> p_for_script = Ref<Resource>());
|
||||
bool _script_exists(const String &p_path) const;
|
||||
|
||||
void _add_recent_script(const String &p_path);
|
||||
void _update_recent_scripts();
|
||||
|
@@ -518,6 +518,11 @@ void EditorSettingsDialog::_update_shortcuts() {
|
||||
}
|
||||
}
|
||||
|
||||
String prev_selected_shortcut;
|
||||
if (shortcuts->get_selected()) {
|
||||
prev_selected_shortcut = shortcuts->get_selected()->get_text(0);
|
||||
}
|
||||
|
||||
shortcuts->clear();
|
||||
|
||||
TreeItem *root = shortcuts->create_item();
|
||||
@@ -557,6 +562,9 @@ void EditorSettingsDialog::_update_shortcuts() {
|
||||
|
||||
TreeItem *item = _create_shortcut_treeitem(common_section, action_name, action_name, action_events, !same_as_defaults, true, collapse);
|
||||
item->set_auto_translate_mode(0, AUTO_TRANSLATE_MODE_DISABLED); // `ui_*` input action names are untranslatable identifiers.
|
||||
if (!prev_selected_shortcut.is_empty() && action_name == prev_selected_shortcut) {
|
||||
item->select(0);
|
||||
}
|
||||
}
|
||||
|
||||
// Editor Shortcuts
|
||||
@@ -616,7 +624,14 @@ void EditorSettingsDialog::_update_shortcuts() {
|
||||
bool same_as_defaults = Shortcut::is_event_array_equal(original, shortcuts_array);
|
||||
bool collapse = !collapsed.has(E) || (collapsed.has(E) && collapsed[E]);
|
||||
|
||||
_create_shortcut_treeitem(section, E, sc->get_name(), shortcuts_array, !same_as_defaults, false, collapse);
|
||||
TreeItem *shortcut_item = _create_shortcut_treeitem(section, E, sc->get_name(), shortcuts_array, !same_as_defaults, false, collapse);
|
||||
if (!prev_selected_shortcut.is_empty() && sc->get_name() == prev_selected_shortcut) {
|
||||
shortcut_item->select(0);
|
||||
}
|
||||
}
|
||||
|
||||
if (!prev_selected_shortcut.is_empty()) {
|
||||
shortcuts->ensure_cursor_is_visible();
|
||||
}
|
||||
|
||||
// remove sections with no shortcuts
|
||||
|
@@ -34,6 +34,7 @@
|
||||
#include "scene_replication_config.h"
|
||||
|
||||
#include "core/debugger/engine_debugger.h"
|
||||
#include "core/os/os.h"
|
||||
#include "scene/main/node.h"
|
||||
|
||||
List<Ref<EngineProfiler>> multiplayer_profilers;
|
||||
|
@@ -32,10 +32,7 @@
|
||||
|
||||
#include "core/debugger/engine_debugger.h"
|
||||
#include "core/io/marshalls.h"
|
||||
|
||||
#ifdef DEBUG_ENABLED
|
||||
#include "core/os/os.h"
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG_ENABLED
|
||||
_FORCE_INLINE_ void SceneMultiplayer::_profile_bandwidth(const String &p_what, int p_value) {
|
||||
|
@@ -34,6 +34,7 @@
|
||||
|
||||
#include "core/debugger/engine_debugger.h"
|
||||
#include "core/io/marshalls.h"
|
||||
#include "core/os/os.h"
|
||||
#include "scene/main/node.h"
|
||||
|
||||
#define MAKE_ROOM(m_amount) \
|
||||
|
@@ -34,6 +34,7 @@
|
||||
#include "multiplayer_synchronizer.h"
|
||||
|
||||
#include "core/object/ref_counted.h"
|
||||
#include "core/templates/rb_set.h"
|
||||
|
||||
class SceneMultiplayer;
|
||||
class SceneCacheInterface;
|
||||
|
@@ -1800,59 +1800,57 @@ Ref<Image> DisplayServerX11::screen_get_image(int p_screen) const {
|
||||
float DisplayServerX11::screen_get_refresh_rate(int p_screen) const {
|
||||
_THREAD_SAFE_METHOD_
|
||||
|
||||
ERR_FAIL_COND_V_MSG(!xrandr_ext_ok || !xrr_get_monitors, SCREEN_REFRESH_RATE_FALLBACK, "XRandR extension is not available.");
|
||||
|
||||
p_screen = _get_screen_index(p_screen);
|
||||
int screen_count = get_screen_count();
|
||||
ERR_FAIL_INDEX_V(p_screen, screen_count, SCREEN_REFRESH_RATE_FALLBACK);
|
||||
|
||||
//Use xrandr to get screen refresh rate.
|
||||
if (xrandr_ext_ok) {
|
||||
XRRScreenResources *screen_info = XRRGetScreenResourcesCurrent(x11_display, windows[MAIN_WINDOW_ID].x11_window);
|
||||
if (screen_info) {
|
||||
RRMode current_mode = 0;
|
||||
xrr_monitor_info *monitors = nullptr;
|
||||
|
||||
if (xrr_get_monitors) {
|
||||
int count = 0;
|
||||
monitors = xrr_get_monitors(x11_display, windows[MAIN_WINDOW_ID].x11_window, true, &count);
|
||||
ERR_FAIL_INDEX_V(p_screen, count, SCREEN_REFRESH_RATE_FALLBACK);
|
||||
} else {
|
||||
ERR_PRINT("An error occurred while trying to get the screen refresh rate.");
|
||||
return SCREEN_REFRESH_RATE_FALLBACK;
|
||||
}
|
||||
|
||||
bool found_active_mode = false;
|
||||
for (int crtc = 0; crtc < screen_info->ncrtc; crtc++) { // Loop through outputs to find which one is currently outputting.
|
||||
XRRCrtcInfo *monitor_info = XRRGetCrtcInfo(x11_display, screen_info, screen_info->crtcs[crtc]);
|
||||
if (monitor_info->x != monitors[p_screen].x || monitor_info->y != monitors[p_screen].y) { // If X and Y aren't the same as the monitor we're looking for, this isn't the right monitor. Continue.
|
||||
continue;
|
||||
}
|
||||
|
||||
if (monitor_info->mode != None) {
|
||||
current_mode = monitor_info->mode;
|
||||
found_active_mode = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (found_active_mode) {
|
||||
for (int mode = 0; mode < screen_info->nmode; mode++) {
|
||||
XRRModeInfo m_info = screen_info->modes[mode];
|
||||
if (m_info.id == current_mode) {
|
||||
// Snap to nearest 0.01 to stay consistent with other platforms.
|
||||
return Math::snapped((float)m_info.dotClock / ((float)m_info.hTotal * (float)m_info.vTotal), 0.01);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ERR_PRINT("An error occurred while trying to get the screen refresh rate."); // We should have returned the refresh rate by now. An error must have occurred.
|
||||
return SCREEN_REFRESH_RATE_FALLBACK;
|
||||
} else {
|
||||
ERR_PRINT("An error occurred while trying to get the screen refresh rate.");
|
||||
return SCREEN_REFRESH_RATE_FALLBACK;
|
||||
int target_x;
|
||||
int target_y;
|
||||
{
|
||||
int count = 0;
|
||||
xrr_monitor_info *monitors = xrr_get_monitors(x11_display, windows[MAIN_WINDOW_ID].x11_window, true, &count);
|
||||
ERR_FAIL_NULL_V(monitors, SCREEN_REFRESH_RATE_FALLBACK);
|
||||
if (count <= p_screen) {
|
||||
xrr_free_monitors(monitors);
|
||||
ERR_FAIL_V_MSG(SCREEN_REFRESH_RATE_FALLBACK, vformat("Invalid screen index: %d (count: %d).", p_screen, count));
|
||||
}
|
||||
target_x = monitors[p_screen].x;
|
||||
target_y = monitors[p_screen].y;
|
||||
xrr_free_monitors(monitors);
|
||||
}
|
||||
ERR_PRINT("An error occurred while trying to get the screen refresh rate.");
|
||||
return SCREEN_REFRESH_RATE_FALLBACK;
|
||||
|
||||
XRRScreenResources *screen_res = XRRGetScreenResourcesCurrent(x11_display, windows[MAIN_WINDOW_ID].x11_window);
|
||||
ERR_FAIL_NULL_V(screen_res, SCREEN_REFRESH_RATE_FALLBACK);
|
||||
|
||||
XRRModeInfo *mode_info = nullptr;
|
||||
for (int crtc = 0; crtc < screen_res->ncrtc; crtc++) { // Loop through outputs to find which one is currently outputting.
|
||||
XRRCrtcInfo *monitor_info = XRRGetCrtcInfo(x11_display, screen_res, screen_res->crtcs[crtc]);
|
||||
if (monitor_info->x != target_x || monitor_info->y != target_y || monitor_info->mode == None) {
|
||||
XRRFreeCrtcInfo(monitor_info);
|
||||
continue;
|
||||
}
|
||||
for (int mode = 0; mode < screen_res->nmode; mode++) {
|
||||
if (screen_res->modes[mode].id == monitor_info->mode) {
|
||||
mode_info = &screen_res->modes[mode];
|
||||
}
|
||||
}
|
||||
XRRFreeCrtcInfo(monitor_info);
|
||||
break;
|
||||
}
|
||||
|
||||
float result;
|
||||
if (mode_info) {
|
||||
// Snap to nearest 0.01 to stay consistent with other platforms.
|
||||
result = Math::snapped((float)mode_info->dotClock / ((float)mode_info->hTotal * (float)mode_info->vTotal), 0.01);
|
||||
} else {
|
||||
ERR_PRINT("An error occurred while trying to get the screen refresh rate.");
|
||||
result = SCREEN_REFRESH_RATE_FALLBACK;
|
||||
}
|
||||
|
||||
XRRFreeScreenResources(screen_res);
|
||||
return result;
|
||||
}
|
||||
|
||||
#ifdef DBUS_ENABLED
|
||||
|
@@ -350,10 +350,7 @@ def configure_msvc(env: "SConsEnvironment"):
|
||||
|
||||
env.AppendUnique(CCFLAGS=["/Gd", "/GR", "/nologo"])
|
||||
env.AppendUnique(CCFLAGS=["/utf-8"]) # Force to use Unicode encoding.
|
||||
# Once it was thought that only debug builds would be too large,
|
||||
# but this has recently stopped being true. See the mingw function
|
||||
# for notes on why this shouldn't be enabled for gcc
|
||||
env.AppendUnique(CCFLAGS=["/bigobj"])
|
||||
env.AppendUnique(CCFLAGS=["/bigobj"]) # Support big objects.
|
||||
|
||||
env.AppendUnique(
|
||||
CPPDEFINES=[
|
||||
@@ -450,10 +447,6 @@ def configure_msvc(env: "SConsEnvironment"):
|
||||
LIBS += ["dxgi", "dxguid"]
|
||||
LIBS += ["version"] # Mesa dependency.
|
||||
|
||||
# Needed for avoiding C1128.
|
||||
if env["target"] == "release_debug":
|
||||
env.Append(CXXFLAGS=["/bigobj"])
|
||||
|
||||
# PIX
|
||||
if env["arch"] not in ["x86_64", "arm64"] or env["pix_path"] == "" or not os.path.exists(env["pix_path"]):
|
||||
env["use_pix"] = False
|
||||
@@ -637,12 +630,6 @@ def configure_mingw(env: "SConsEnvironment"):
|
||||
print("Detected GCC to be a wrapper for Clang.")
|
||||
env["use_llvm"] = True
|
||||
|
||||
if env.dev_build:
|
||||
# Allow big objects. It's supposed not to have drawbacks but seems to break
|
||||
# GCC LTO, so enabling for debug builds only (which are not built with LTO
|
||||
# and are the only ones with too big objects).
|
||||
env.Append(CCFLAGS=["-Wa,-mbig-obj"])
|
||||
|
||||
if env["windows_subsystem"] == "gui":
|
||||
env.Append(LINKFLAGS=["-Wl,--subsystem,windows"])
|
||||
else:
|
||||
@@ -660,6 +647,10 @@ def configure_mingw(env: "SConsEnvironment"):
|
||||
if env["use_static_cpp"]:
|
||||
env.Append(LINKFLAGS=["-static"])
|
||||
|
||||
# NOTE: Big objects have historically broken LTO on mingw-gcc specifically. While that no
|
||||
# longer appears to be the case, this notice is retained for posterity.
|
||||
env.AppendUnique(CCFLAGS=["-Wa,-mbig-obj"]) # Support big objects.
|
||||
|
||||
if env["arch"] == "x86_32":
|
||||
env["x86_libtheora_opt_gcc"] = True
|
||||
|
||||
|
@@ -33,6 +33,7 @@
|
||||
|
||||
#include "scene/audio/audio_stream_player_internal.h"
|
||||
#include "servers/audio/audio_stream.h"
|
||||
#include "servers/display/display_server.h"
|
||||
|
||||
void AudioStreamPlayer::_notification(int p_what) {
|
||||
if (p_what == NOTIFICATION_ACCESSIBILITY_UPDATE) {
|
||||
|
@@ -33,7 +33,10 @@
|
||||
|
||||
STATIC_ASSERT_INCOMPLETE_TYPE(class, Mesh);
|
||||
STATIC_ASSERT_INCOMPLETE_TYPE(class, RenderingServer);
|
||||
STATIC_ASSERT_INCOMPLETE_TYPE(class, DisplayServer);
|
||||
STATIC_ASSERT_INCOMPLETE_TYPE(class, Shader);
|
||||
STATIC_ASSERT_INCOMPLETE_TYPE(class, OS);
|
||||
STATIC_ASSERT_INCOMPLETE_TYPE(class, Engine);
|
||||
|
||||
#include "core/config/project_settings.h"
|
||||
#include "core/io/resource_loader.h"
|
||||
|
@@ -30,6 +30,8 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "core/input/input_event.h"
|
||||
#include "core/io/resource.h"
|
||||
#include "core/string/node_path.h"
|
||||
#include "core/templates/iterable.h"
|
||||
#include "core/variant/typed_array.h"
|
||||
|
@@ -35,12 +35,12 @@
|
||||
#include "core/templates/paged_allocator.h"
|
||||
#include "core/templates/self_list.h"
|
||||
#include "scene/main/scene_tree_fti.h"
|
||||
#include "servers/display/display_server.h"
|
||||
|
||||
#undef Window
|
||||
|
||||
class ArrayMesh;
|
||||
class PackedScene;
|
||||
class InputEvent;
|
||||
class Node;
|
||||
#ifndef _3D_DISABLED
|
||||
class Node3D;
|
||||
@@ -337,7 +337,7 @@ public:
|
||||
void _accessibility_force_update();
|
||||
void _accessibility_notify_change(const Node *p_node, bool p_remove = false);
|
||||
void _flush_accessibility_changes();
|
||||
void _process_accessibility_changes(DisplayServer::WindowID p_window_id);
|
||||
void _process_accessibility_changes(int p_window_id); // Effectively DisplayServer::WindowID
|
||||
|
||||
virtual void initialize() override;
|
||||
|
||||
|
@@ -30,6 +30,8 @@
|
||||
|
||||
#include "timer.h"
|
||||
|
||||
#include "core/config/engine.h"
|
||||
|
||||
void Timer::_notification(int p_what) {
|
||||
switch (p_what) {
|
||||
case NOTIFICATION_READY: {
|
||||
|
@@ -32,6 +32,7 @@
|
||||
|
||||
#include "scene/main/node.h"
|
||||
#include "scene/resources/texture.h"
|
||||
#include "servers/display/display_server.h"
|
||||
|
||||
#ifndef _3D_DISABLED
|
||||
class Camera3D;
|
||||
|
@@ -36,6 +36,7 @@
|
||||
#include "core/io/resource_loader.h"
|
||||
#include "core/object/script_language.h"
|
||||
#include "core/templates/local_vector.h"
|
||||
#include "core/variant/callable_bind.h"
|
||||
#include "scene/2d/node_2d.h"
|
||||
#include "scene/gui/control.h"
|
||||
#include "scene/main/instance_placeholder.h"
|
||||
|
@@ -33,6 +33,7 @@
|
||||
#include "core/io/file_access.h"
|
||||
#include "core/io/resource_loader.h"
|
||||
#include "core/io/resource_saver.h"
|
||||
#include "core/templates/rb_map.h"
|
||||
#include "core/variant/variant_parser.h"
|
||||
#include "scene/resources/packed_scene.h"
|
||||
|
||||
|
@@ -412,6 +412,8 @@ void CopyEffects::copy_cubemap_to_panorama(RID p_source_cube, RID p_dest_panoram
|
||||
copy.push_constant.target[1] = 0;
|
||||
copy.push_constant.camera_z_far = p_lod;
|
||||
|
||||
copy.push_constant.luminance_multiplier = prefer_raster_effects ? 2.0 : 1.0;
|
||||
|
||||
// setup our uniforms
|
||||
RID default_sampler = material_storage->sampler_rd_get_default(RS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR, RS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED);
|
||||
|
||||
|
@@ -139,7 +139,7 @@ private:
|
||||
int32_t section[4];
|
||||
int32_t target[2];
|
||||
uint32_t flags;
|
||||
uint32_t pad;
|
||||
float luminance_multiplier;
|
||||
// Glow.
|
||||
float glow_strength;
|
||||
float glow_bloom;
|
||||
|
@@ -20,7 +20,7 @@ layout(push_constant, std430) uniform Params {
|
||||
ivec4 section;
|
||||
ivec2 target;
|
||||
uint flags;
|
||||
uint pad;
|
||||
float luminance_multiplier;
|
||||
// Glow.
|
||||
float glow_strength;
|
||||
float glow_bloom;
|
||||
@@ -276,7 +276,7 @@ void main() {
|
||||
#else
|
||||
vec4 color = textureLod(source_color, vec4(normal, params.camera_z_far), 0.0); //the biggest the lod the least the acne
|
||||
#endif
|
||||
imageStore(dest_buffer, pos + params.target, color);
|
||||
imageStore(dest_buffer, pos + params.target, color * params.luminance_multiplier);
|
||||
#endif // defined(MODE_CUBEMAP_TO_PANORAMA) || defined(MODE_CUBEMAP_ARRAY_TO_PANORAMA)
|
||||
|
||||
#ifdef MODE_SET_COLOR
|
||||
|
Reference in New Issue
Block a user