Add a const call mode to Object, Variant and Script.

For this to work safely (user not call queue_free or something in the expression), a const call mode was added to Object and Variant (and optionally Script).

This mode ensures only const functions can be called, making it safe to use from the editor.

Co-Authored-By: reduz <reduzio@gmail.com>
This commit is contained in:
K. S. Ernest (iFire) Lee
2022-06-27 13:10:04 -07:00
parent c41e4b10c3
commit 9ddebc0c22
23 changed files with 179 additions and 53 deletions

View File

@@ -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 /////////////////////////
@@ -3771,6 +3780,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);