summaryrefslogtreecommitdiff
path: root/editor
diff options
context:
space:
mode:
Diffstat (limited to 'editor')
-rw-r--r--editor/animation_bezier_editor.cpp17
-rw-r--r--editor/editor_log.cpp22
-rw-r--r--editor/editor_log.h1
-rw-r--r--editor/editor_node.cpp10
-rw-r--r--editor/editor_node.h2
-rw-r--r--editor/editor_properties.cpp22
-rw-r--r--editor/editor_properties.h3
-rw-r--r--editor/editor_spin_slider.cpp2
-rw-r--r--editor/plugins/script_text_editor.cpp2
-rw-r--r--editor/property_editor.cpp4
10 files changed, 55 insertions, 30 deletions
diff --git a/editor/animation_bezier_editor.cpp b/editor/animation_bezier_editor.cpp
index f0650ee446..391cd009f1 100644
--- a/editor/animation_bezier_editor.cpp
+++ b/editor/animation_bezier_editor.cpp
@@ -44,17 +44,6 @@ float AnimationBezierTrackEdit::_bezier_h_to_pixel(float p_h) {
return h;
}
-static _FORCE_INLINE_ Vector2 _bezier_interp(real_t t, const Vector2 &start, const Vector2 &control_1, const Vector2 &control_2, const Vector2 &end) {
- /* Formula from Wikipedia article on Bezier curves. */
- real_t omt = (1.0 - t);
- real_t omt2 = omt * omt;
- real_t omt3 = omt2 * omt;
- real_t t2 = t * t;
- real_t t3 = t2 * t;
-
- return start * omt3 + control_1 * omt2 * t * 3.0 + control_2 * omt * t2 * 3.0 + end * t3;
-}
-
void AnimationBezierTrackEdit::_draw_track(int p_track, const Color &p_color) {
float scale = timeline->get_zoom_scale();
@@ -151,7 +140,7 @@ void AnimationBezierTrackEdit::_draw_track(int p_track, const Color &p_color) {
for (int k = 0; k < iterations; k++) {
float middle = (low + high) / 2;
- Vector2 interp = _bezier_interp(middle, start, out_handle, in_handle, end);
+ Vector2 interp = start.bezier_interpolate(out_handle, in_handle, end, middle);
if (interp.x < t) {
low = middle;
@@ -161,8 +150,8 @@ void AnimationBezierTrackEdit::_draw_track(int p_track, const Color &p_color) {
}
//interpolate the result:
- Vector2 low_pos = _bezier_interp(low, start, out_handle, in_handle, end);
- Vector2 high_pos = _bezier_interp(high, start, out_handle, in_handle, end);
+ Vector2 low_pos = start.bezier_interpolate(out_handle, in_handle, end, low);
+ Vector2 high_pos = start.bezier_interpolate(out_handle, in_handle, end, high);
float c = (t - low_pos.x) / (high_pos.x - low_pos.x);
diff --git a/editor/editor_log.cpp b/editor/editor_log.cpp
index dbe44aee1b..f26f47dbc7 100644
--- a/editor/editor_log.cpp
+++ b/editor/editor_log.cpp
@@ -181,7 +181,7 @@ void EditorLog::clear() {
}
void EditorLog::_process_message(const String &p_msg, MessageType p_type) {
- if (messages.size() > 0 && messages[messages.size() - 1].text == p_msg) {
+ if (messages.size() > 0 && messages[messages.size() - 1].text == p_msg && messages[messages.size() - 1].type == p_type) {
// If previous message is the same as the new one, increase previous count rather than adding another
// instance to the messages list.
LogMessage &previous = messages.write[messages.size() - 1];
@@ -258,6 +258,8 @@ void EditorLog::_add_log_line(LogMessage &p_message, bool p_replace_previous) {
switch (p_message.type) {
case MSG_TYPE_STD: {
} break;
+ case MSG_TYPE_STD_RICH: {
+ } break;
case MSG_TYPE_ERROR: {
log->push_color(get_theme_color(SNAME("error_color"), SNAME("Editor")));
Ref<Texture2D> icon = get_theme_icon(SNAME("Error"), SNAME("EditorIcons"));
@@ -285,11 +287,15 @@ void EditorLog::_add_log_line(LogMessage &p_message, bool p_replace_previous) {
log->pop();
}
- log->add_text(p_message.text);
+ if (p_message.type == MSG_TYPE_STD_RICH) {
+ log->append_text(p_message.text);
+ } else {
+ log->add_text(p_message.text);
+ }
// Need to use pop() to exit out of the RichTextLabels current "push" stack.
- // We only "push" in the above switch when message type != STD, so only pop when that is the case.
- if (p_message.type != MSG_TYPE_STD) {
+ // We only "push" in the above switch when message type != STD and RICH, so only pop when that is the case.
+ if (p_message.type != MSG_TYPE_STD && p_message.type != MSG_TYPE_STD_RICH) {
log->pop();
}
@@ -342,6 +348,7 @@ EditorLog::EditorLog() {
// Log - Rich Text Label.
log = memnew(RichTextLabel);
+ log->set_use_bbcode(true);
log->set_scroll_follow(true);
log->set_selection_enabled(true);
log->set_focus_mode(FOCUS_CLICK);
@@ -418,6 +425,7 @@ EditorLog::EditorLog() {
std_filter->initialize_button(TTR("Toggle visibility of standard output messages."), callable_mp(this, &EditorLog::_set_filter_active));
vb_right->add_child(std_filter->toggle_button);
type_filter_map.insert(MSG_TYPE_STD, std_filter);
+ type_filter_map.insert(MSG_TYPE_STD_RICH, std_filter);
LogFilter *error_filter = memnew(LogFilter(MSG_TYPE_ERROR));
error_filter->initialize_button(TTR("Toggle visibility of errors."), callable_mp(this, &EditorLog::_set_filter_active));
@@ -451,6 +459,10 @@ void EditorLog::deinit() {
EditorLog::~EditorLog() {
for (const KeyValue<MessageType, LogFilter *> &E : type_filter_map) {
- memdelete(E.value);
+ // MSG_TYPE_STD_RICH is connected to the std_filter button, so we do this
+ // to avoid it from being deleted twice, causing a crash on closing.
+ if (E.key != MSG_TYPE_STD_RICH) {
+ memdelete(E.value);
+ }
}
}
diff --git a/editor/editor_log.h b/editor/editor_log.h
index de0368501c..653fba9524 100644
--- a/editor/editor_log.h
+++ b/editor/editor_log.h
@@ -48,6 +48,7 @@ public:
enum MessageType {
MSG_TYPE_STD,
MSG_TYPE_ERROR,
+ MSG_TYPE_STD_RICH,
MSG_TYPE_WARNING,
MSG_TYPE_EDITOR,
};
diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp
index b4b82b1edf..b196cadcb1 100644
--- a/editor/editor_node.cpp
+++ b/editor/editor_node.cpp
@@ -5829,9 +5829,15 @@ static Node *_resource_get_edited_scene() {
return EditorNode::get_singleton()->get_edited_scene();
}
-void EditorNode::_print_handler(void *p_this, const String &p_string, bool p_error) {
+void EditorNode::_print_handler(void *p_this, const String &p_string, bool p_error, bool p_rich) {
EditorNode *en = static_cast<EditorNode *>(p_this);
- en->log->add_message(p_string, p_error ? EditorLog::MSG_TYPE_ERROR : EditorLog::MSG_TYPE_STD);
+ if (p_error) {
+ en->log->add_message(p_string, EditorLog::MSG_TYPE_ERROR);
+ } else if (p_rich) {
+ en->log->add_message(p_string, EditorLog::MSG_TYPE_STD_RICH);
+ } else {
+ en->log->add_message(p_string, EditorLog::MSG_TYPE_STD);
+ }
}
static void _execute_thread(void *p_ud) {
diff --git a/editor/editor_node.h b/editor/editor_node.h
index 89f80baeb9..c327a73ce9 100644
--- a/editor/editor_node.h
+++ b/editor/editor_node.h
@@ -505,7 +505,7 @@ private:
static void _load_error_notify(void *p_ud, const String &p_text);
static void _file_access_close_error_notify(const String &p_str);
- static void _print_handler(void *p_this, const String &p_string, bool p_error);
+ static void _print_handler(void *p_this, const String &p_string, bool p_error, bool p_rich);
static void _resource_saved(Ref<Resource> p_resource, const String &p_path);
static void _resource_loaded(Ref<Resource> p_resource, const String &p_path);
diff --git a/editor/editor_properties.cpp b/editor/editor_properties.cpp
index 0e6c9162ce..aff328bba7 100644
--- a/editor/editor_properties.cpp
+++ b/editor/editor_properties.cpp
@@ -165,6 +165,9 @@ void EditorPropertyMultilineText::_notification(int p_what) {
Ref<Font> font = get_theme_font(SNAME("font"), SNAME("Label"));
int font_size = get_theme_font_size(SNAME("font_size"), SNAME("Label"));
text->set_custom_minimum_size(Vector2(0, font->get_height(font_size) * 6));
+ text->add_theme_font_override("font", get_theme_font("expression", "EditorFonts"));
+ text->add_theme_font_size_override("font_size", get_theme_font_size("expression_size", "EditorFonts"));
+
} break;
}
}
@@ -172,7 +175,7 @@ void EditorPropertyMultilineText::_notification(int p_what) {
void EditorPropertyMultilineText::_bind_methods() {
}
-EditorPropertyMultilineText::EditorPropertyMultilineText() {
+EditorPropertyMultilineText::EditorPropertyMultilineText(bool p_expression) {
HBoxContainer *hb = memnew(HBoxContainer);
hb->add_theme_constant_override("separation", 0);
add_child(hb);
@@ -189,6 +192,12 @@ EditorPropertyMultilineText::EditorPropertyMultilineText() {
hb->add_child(open_big_text);
big_text_dialog = nullptr;
big_text = nullptr;
+ if (p_expression) {
+ expression = true;
+ Ref<EditorStandardSyntaxHighlighter> highlighter;
+ highlighter.instantiate();
+ text->set_syntax_highlighter(highlighter);
+ }
}
///////////////////// TEXT ENUM /////////////////////////
@@ -3026,13 +3035,17 @@ String EditorPropertyNodePath::_get_meta_pointer_property() const {
Variant EditorPropertyNodePath::_get_cache_value(const StringName &p_prop, bool &r_valid) const {
if (p_prop == get_edited_property()) {
r_valid = true;
- return const_cast<EditorPropertyNodePath *>(this)->get_edited_object()->get(_get_meta_pointer_property(), &r_valid);
+ return const_cast<EditorPropertyNodePath *>(this)->get_edited_object()->get(pointer_mode ? StringName(_get_meta_pointer_property()) : get_edited_property(), &r_valid);
}
return Variant();
}
StringName EditorPropertyNodePath::_get_revert_property() const {
- return _get_meta_pointer_property();
+ if (pointer_mode) {
+ return _get_meta_pointer_property();
+ } else {
+ return get_edited_property();
+ }
}
void EditorPropertyNodePath::_node_selected(const NodePath &p_path) {
@@ -3771,6 +3784,9 @@ EditorProperty *EditorInspectorDefaultPlugin::get_editor_for_property(Object *p_
} else if (p_hint == PROPERTY_HINT_MULTILINE_TEXT) {
EditorPropertyMultilineText *editor = memnew(EditorPropertyMultilineText);
return editor;
+ } else if (p_hint == PROPERTY_HINT_EXPRESSION) {
+ EditorPropertyMultilineText *editor = memnew(EditorPropertyMultilineText(true));
+ return editor;
} else if (p_hint == PROPERTY_HINT_TYPE_STRING) {
EditorPropertyClassName *editor = memnew(EditorPropertyClassName);
editor->setup("Object", p_hint_text);
diff --git a/editor/editor_properties.h b/editor/editor_properties.h
index 72b2b0b283..7cd6ea4f6b 100644
--- a/editor/editor_properties.h
+++ b/editor/editor_properties.h
@@ -81,6 +81,7 @@ class EditorPropertyMultilineText : public EditorProperty {
void _big_text_changed();
void _text_changed();
void _open_big_text();
+ bool expression = false;
protected:
virtual void _set_read_only(bool p_read_only) override;
@@ -89,7 +90,7 @@ protected:
public:
virtual void update_property() override;
- EditorPropertyMultilineText();
+ EditorPropertyMultilineText(bool p_expression = false);
};
class EditorPropertyTextEnum : public EditorProperty {
diff --git a/editor/editor_spin_slider.cpp b/editor/editor_spin_slider.cpp
index a0c818ba84..f23f0cf758 100644
--- a/editor/editor_spin_slider.cpp
+++ b/editor/editor_spin_slider.cpp
@@ -530,7 +530,7 @@ void EditorSpinSlider::_evaluate_input_text() {
return;
}
- Variant v = expr->execute(Array(), nullptr, false);
+ Variant v = expr->execute(Array(), nullptr, false, true);
if (v.get_type() == Variant::NIL) {
return;
}
diff --git a/editor/plugins/script_text_editor.cpp b/editor/plugins/script_text_editor.cpp
index 05c707c065..7d4ffd1a25 100644
--- a/editor/plugins/script_text_editor.cpp
+++ b/editor/plugins/script_text_editor.cpp
@@ -1196,7 +1196,7 @@ void ScriptTextEditor::_edit_option(int p_op) {
String whitespace = line.substr(0, line.size() - line.strip_edges(true, false).size()); //extract the whitespace at the beginning
if (expression.parse(line) == OK) {
- Variant result = expression.execute(Array(), Variant(), false);
+ Variant result = expression.execute(Array(), Variant(), false, true);
if (expression.get_error_text().is_empty()) {
results.push_back(whitespace + result.get_construct_string());
} else {
diff --git a/editor/property_editor.cpp b/editor/property_editor.cpp
index 771d34d841..d936e821df 100644
--- a/editor/property_editor.cpp
+++ b/editor/property_editor.cpp
@@ -1474,7 +1474,7 @@ void CustomPropertyEditor::_modified(String p_string) {
v = value_editor[0]->get_text().to_int();
return;
} else {
- v = expr->execute(Array(), nullptr, false);
+ v = expr->execute(Array(), nullptr, false, false);
}
if (v != prev_v) {
@@ -1650,7 +1650,7 @@ real_t CustomPropertyEditor::_parse_real_expression(String text) {
if (err != OK) {
out = value_editor[0]->get_text().to_float();
} else {
- out = expr->execute(Array(), nullptr, false);
+ out = expr->execute(Array(), nullptr, false, true);
}
return out;
}