summaryrefslogtreecommitdiff
path: root/modules/visual_script
diff options
context:
space:
mode:
Diffstat (limited to 'modules/visual_script')
-rw-r--r--modules/visual_script/visual_script_editor.cpp14
-rw-r--r--modules/visual_script/visual_script_editor.h1
-rw-r--r--modules/visual_script/visual_script_expression.cpp2
3 files changed, 15 insertions, 2 deletions
diff --git a/modules/visual_script/visual_script_editor.cpp b/modules/visual_script/visual_script_editor.cpp
index 2fcd9332a1..5581ea9318 100644
--- a/modules/visual_script/visual_script_editor.cpp
+++ b/modules/visual_script/visual_script_editor.cpp
@@ -2513,6 +2513,8 @@ RES VisualScriptEditor::get_edited_resource() const {
}
void VisualScriptEditor::set_edited_resource(const RES &p_res) {
+ ERR_FAIL_COND(script.is_valid());
+ ERR_FAIL_COND(p_res.is_null());
script = p_res;
signal_editor->script = script;
signal_editor->undo_redo = undo_redo;
@@ -2533,6 +2535,9 @@ void VisualScriptEditor::set_edited_resource(const RES &p_res) {
_update_members();
}
+void VisualScriptEditor::enable_editor() {
+}
+
Vector<String> VisualScriptEditor::get_functions() {
return Vector<String>();
}
@@ -2546,6 +2551,9 @@ String VisualScriptEditor::get_name() {
if (script->get_path().find("local://") == -1 && script->get_path().find("::") == -1) {
name = script->get_path().get_file();
if (is_unsaved()) {
+ if (script->get_path().empty()) {
+ name = TTR("[unsaved]");
+ }
name += "(*)";
}
} else if (script->get_name() != "") {
@@ -2562,7 +2570,11 @@ Ref<Texture2D> VisualScriptEditor::get_theme_icon() {
}
bool VisualScriptEditor::is_unsaved() {
- return script->is_edited() || script->are_subnodes_edited();
+ bool unsaved =
+ script->is_edited() ||
+ script->are_subnodes_edited() ||
+ script->get_path().empty(); // In memory.
+ return unsaved;
}
Variant VisualScriptEditor::get_edit_state() {
diff --git a/modules/visual_script/visual_script_editor.h b/modules/visual_script/visual_script_editor.h
index e59618e120..0c5665cee8 100644
--- a/modules/visual_script/visual_script_editor.h
+++ b/modules/visual_script/visual_script_editor.h
@@ -294,6 +294,7 @@ public:
virtual void apply_code() override;
virtual RES get_edited_resource() const override;
virtual void set_edited_resource(const RES &p_res) override;
+ virtual void enable_editor() override;
virtual Vector<String> get_functions() override;
virtual void reload_text() override;
virtual String get_name() override;
diff --git a/modules/visual_script/visual_script_expression.cpp b/modules/visual_script/visual_script_expression.cpp
index bd41117497..2ac7793b8c 100644
--- a/modules/visual_script/visual_script_expression.cpp
+++ b/modules/visual_script/visual_script_expression.cpp
@@ -489,7 +489,7 @@ Error VisualScriptExpression::_get_token(Token &r_token) {
r_token.type = TK_CONSTANT;
if (is_float) {
- r_token.value = num.to_double();
+ r_token.value = num.to_float();
} else {
r_token.value = num.to_int();
}