diff options
-rw-r--r-- | core/method_bind.h | 2 | ||||
-rw-r--r-- | core/ustring.cpp | 11 | ||||
-rw-r--r-- | core/variant.cpp | 260 | ||||
-rw-r--r-- | core/variant.h | 3 | ||||
-rw-r--r-- | demos/2d/platformer/enemy.gd | 2 | ||||
-rw-r--r-- | demos/3d/platformer/enemy.gd | 2 | ||||
-rw-r--r-- | drivers/theoraplayer/video_stream_theoraplayer.cpp | 2 | ||||
-rw-r--r-- | scene/gui/file_dialog.cpp | 1 | ||||
-rw-r--r-- | scene/gui/text_edit.cpp | 4 | ||||
-rw-r--r-- | scene/main/node.h | 1 | ||||
-rw-r--r-- | scene/resources/packed_scene.cpp | 2 | ||||
-rw-r--r-- | tools/editor/editor_import_export.cpp | 1 | ||||
-rw-r--r-- | tools/editor/editor_settings.cpp | 2 | ||||
-rw-r--r-- | tools/editor/io_plugins/editor_font_import_plugin.cpp | 7 | ||||
-rw-r--r-- | tools/editor/plugins/script_editor_plugin.cpp | 40 | ||||
-rw-r--r-- | tools/editor/plugins/script_editor_plugin.h | 4 |
16 files changed, 324 insertions, 20 deletions
diff --git a/core/method_bind.h b/core/method_bind.h index d32050cc5d..49c64bd11c 100644 --- a/core/method_bind.h +++ b/core/method_bind.h @@ -98,7 +98,7 @@ struct VariantCaster<m_enum> {\ #define CHECK_ARG(m_arg)\ if ((m_arg-1)<p_arg_count) {\ Variant::Type argtype=get_argument_type(m_arg-1);\ - if (!Variant::can_convert(p_args[m_arg-1]->get_type(),argtype)) {\ + if (!Variant::can_convert_strict(p_args[m_arg-1]->get_type(),argtype)) {\ r_error.error=Variant::CallError::CALL_ERROR_INVALID_ARGUMENT;\ r_error.argument=m_arg-1;\ r_error.expected=argtype;\ diff --git a/core/ustring.cpp b/core/ustring.cpp index ffd22c1f8f..5df95ac4c2 100644 --- a/core/ustring.cpp +++ b/core/ustring.cpp @@ -3297,8 +3297,11 @@ String String::path_to_file(const String& p_path) const { String src=this->replace("\\","/").get_base_dir(); String dst=p_path.replace("\\","/").get_base_dir(); - - return src.path_to(dst)+p_path.get_file(); + String rel = src.path_to(dst); + if (rel==dst) // failed + return p_path; + else + return rel+p_path.get_file(); } String String::path_to(const String& p_path) const { @@ -3333,7 +3336,9 @@ String String::path_to(const String& p_path) const { String src_begin=src.get_slice("/",0); String dst_begin=dst.get_slice("/",0); - ERR_FAIL_COND_V(src_begin!=dst_begin,p_path); //return dst absolute path + if (src_begin!=dst_begin) + return p_path; //impossible to do this + base=src_begin; src=src.substr(src_begin.length(),src.length()); dst=dst.substr(dst_begin.length(),dst.length()); diff --git a/core/variant.cpp b/core/variant.cpp index c06afb2984..f49b202a5b 100644 --- a/core/variant.cpp +++ b/core/variant.cpp @@ -214,7 +214,7 @@ bool Variant::can_convert(Variant::Type p_type_from,Variant::Type p_type_to) { static const Type valid[]={ INT, REAL, - //STRING, + STRING, NIL, }; @@ -225,7 +225,7 @@ bool Variant::can_convert(Variant::Type p_type_from,Variant::Type p_type_to) { static const Type valid[]={ BOOL, REAL, - //STRING, + STRING, NIL, }; @@ -237,7 +237,7 @@ bool Variant::can_convert(Variant::Type p_type_from,Variant::Type p_type_to) { static const Type valid[]={ BOOL, INT, - //STRING, + STRING, NIL, }; @@ -258,12 +258,12 @@ bool Variant::can_convert(Variant::Type p_type_from,Variant::Type p_type_to) { case MATRIX32: { - static const Type invalid[]={ + static const Type valid[]={ TRANSFORM, NIL }; - invalid_types=invalid; + valid_types=valid; } break; case QUAT: { @@ -302,6 +302,256 @@ bool Variant::can_convert(Variant::Type p_type_from,Variant::Type p_type_to) { case COLOR: { static const Type valid[] = { + //STRING, + //INT, + NIL, + }; + + valid_types = valid; + + } break; + + case _RID: { + + static const Type valid[]={ + OBJECT, + NIL + }; + + valid_types=valid; + } break; + case OBJECT: { + + static const Type valid[]={ + NIL + }; + + valid_types=valid; + } break; + case NODE_PATH: { + + static const Type valid[]={ + STRING, + NIL + }; + + valid_types=valid; + } break; + case ARRAY: { + + + static const Type valid[]={ + RAW_ARRAY, + INT_ARRAY, + STRING_ARRAY, + REAL_ARRAY, + COLOR_ARRAY, + VECTOR2_ARRAY, + VECTOR3_ARRAY, + NIL + }; + + valid_types=valid; + } break; + // arrays + case RAW_ARRAY: { + + static const Type valid[]={ + ARRAY, + NIL + }; + + valid_types=valid; + } break; + case INT_ARRAY: { + + static const Type valid[]={ + ARRAY, + NIL + }; + valid_types=valid; + } break; + case REAL_ARRAY: { + + static const Type valid[]={ + ARRAY, + NIL + }; + + valid_types=valid; + } break; + case STRING_ARRAY: { + + static const Type valid[]={ + ARRAY, + NIL + }; + valid_types=valid; + } break; + case VECTOR2_ARRAY: { + + static const Type valid[]={ + ARRAY, + NIL + }; + valid_types=valid; + + } break; + case VECTOR3_ARRAY: { + + static const Type valid[]={ + ARRAY, + NIL + }; + valid_types=valid; + + } break; + case COLOR_ARRAY: { + + static const Type valid[]={ + ARRAY, + NIL + }; + + valid_types=valid; + + } break; + default: {} + } + + + if (valid_types) { + + int i=0; + while(valid_types[i]!=NIL) { + + if (p_type_from==valid_types[i]) + return true; + i++; + } + } else if (invalid_types) { + + + int i=0; + while(invalid_types[i]!=NIL) { + + if (p_type_from==invalid_types[i]) + return false; + i++; + } + } + + return false; + +} + +bool Variant::can_convert_strict(Variant::Type p_type_from,Variant::Type p_type_to) { + + if (p_type_from==p_type_to) + return true; + if (p_type_to==NIL && p_type_from!=NIL) //nil can convert to anything + return true; + + if (p_type_from == NIL) { + return (p_type_to == OBJECT); + }; + + const Type *valid_types=NULL; + const Type *invalid_types=NULL; + + switch(p_type_to) { + case BOOL: { + + static const Type valid[]={ + //INT, + //REAL, + //STRING, + NIL, + }; + + valid_types=valid; + } break; + case INT: { + + static const Type valid[]={ + //BOOL, + REAL, + //STRING, + NIL, + }; + + valid_types=valid; + + } break; + case REAL: { + + static const Type valid[]={ + //BOOL, + INT, + //STRING, + NIL, + }; + + valid_types=valid; + + } break; + case STRING: { + + + static const Type valid[]={ + NODE_PATH, + NIL + }; + + valid_types=valid; + } break; + case MATRIX32: { + + + static const Type valid[]={ + TRANSFORM, + NIL + }; + + valid_types=valid; + } break; + case QUAT: { + + static const Type valid[]={ + MATRIX3, + NIL + }; + + valid_types=valid; + + } break; + case MATRIX3: { + + static const Type valid[]={ + QUAT, + NIL + }; + + valid_types=valid; + + + } break; + case TRANSFORM: { + + static const Type valid[]={ + MATRIX32, + QUAT, + MATRIX3, + NIL + }; + + valid_types=valid; + + } break; + + case COLOR: { + + static const Type valid[] = { STRING, INT, NIL, diff --git a/core/variant.h b/core/variant.h index 85c7b92c0d..5f338ef667 100644 --- a/core/variant.h +++ b/core/variant.h @@ -165,7 +165,8 @@ public: _FORCE_INLINE_ Type get_type() const { return type; } static String get_type_name(Variant::Type p_type); - static bool can_convert(Type p_type_from,Type p_type_to); + static bool can_convert(Type p_type_from, Type p_type_to); + static bool can_convert_strict(Type p_type_from, Type p_type_to); diff --git a/demos/2d/platformer/enemy.gd b/demos/2d/platformer/enemy.gd index b4e70477a8..a264cd0cff 100644 --- a/demos/2d/platformer/enemy.gd +++ b/demos/2d/platformer/enemy.gd @@ -56,7 +56,7 @@ func _integrate_forces(s): state=STATE_DYING #lv=s.get_contact_local_normal(i)*400 s.set_angular_velocity(sign(dp.x)*33.0) - set_friction(true) + set_friction(1) cc.disable() get_node("sound").play("hit") diff --git a/demos/3d/platformer/enemy.gd b/demos/3d/platformer/enemy.gd index 1d0e0315d9..cbbb2fe725 100644 --- a/demos/3d/platformer/enemy.gd +++ b/demos/3d/platformer/enemy.gd @@ -45,7 +45,7 @@ func _integrate_forces(state): state.set_angular_velocity( -dp.cross(up).normalized() *33.0) get_node("AnimationPlayer").play("impact") get_node("AnimationPlayer").queue("explode") - set_friction(true) + set_friction(1) cc.disabled=true get_node("sound").play("hit") return diff --git a/drivers/theoraplayer/video_stream_theoraplayer.cpp b/drivers/theoraplayer/video_stream_theoraplayer.cpp index ecafda9d84..ef1f5651ab 100644 --- a/drivers/theoraplayer/video_stream_theoraplayer.cpp +++ b/drivers/theoraplayer/video_stream_theoraplayer.cpp @@ -388,7 +388,7 @@ void VideoStreamTheoraplayer::pop_frame(Ref<ImageTexture> p_tex) { { DVector<uint8_t>::Write wr = data.write(); uint8_t* ptr = wr.ptr(); - memcpy(ptr, f->getBuffer(), imgsize); + copymem(ptr, f->getBuffer(), imgsize); } /* for (int i=0; i<h; i++) { diff --git a/scene/gui/file_dialog.cpp b/scene/gui/file_dialog.cpp index 50ce657d2e..13cf87ac2b 100644 --- a/scene/gui/file_dialog.cpp +++ b/scene/gui/file_dialog.cpp @@ -92,7 +92,6 @@ void FileDialog::_file_entered(const String& p_file) { } void FileDialog::_save_confirm_pressed() { - String f=dir_access->get_current_dir().plus_file(file->get_text()); emit_signal("file_selected",f); hide(); diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp index 6cdff20aaf..75174a85de 100644 --- a/scene/gui/text_edit.cpp +++ b/scene/gui/text_edit.cpp @@ -489,7 +489,7 @@ void TextEdit::_notification(int p_what) { CharType cc = text[i][j]; //ignore any brackets inside a string - if (cc== '"' | cc == '\'') { + if (cc== '"' || cc == '\'') { CharType quotation = cc; do { j++; @@ -560,7 +560,7 @@ void TextEdit::_notification(int p_what) { CharType cc = text[i][j]; //ignore any brackets inside a string - if (cc== '"' | cc == '\'') { + if (cc== '"' || cc == '\'') { CharType quotation = cc; do { j--; diff --git a/scene/main/node.h b/scene/main/node.h index aeada3c5bb..4d0a84d347 100644 --- a/scene/main/node.h +++ b/scene/main/node.h @@ -170,6 +170,7 @@ public: NOTIFICATION_PROCESS = 17, NOTIFICATION_PARENTED=18, NOTIFICATION_UNPARENTED=19, + NOTIFICATION_INSTANCED=20, }; /* NODE/TREE */ diff --git a/scene/resources/packed_scene.cpp b/scene/resources/packed_scene.cpp index 9f36510739..a1cb1205e5 100644 --- a/scene/resources/packed_scene.cpp +++ b/scene/resources/packed_scene.cpp @@ -182,6 +182,8 @@ Node *PackedScene::instance(bool p_gen_edit_state) const { if (get_path()!="" && get_path().find("::")==-1) s->set_filename(get_path()); + + s->notification(Node::NOTIFICATION_INSTANCED); return ret_nodes[0]; } diff --git a/tools/editor/editor_import_export.cpp b/tools/editor/editor_import_export.cpp index d76009a72a..4e6435b22e 100644 --- a/tools/editor/editor_import_export.cpp +++ b/tools/editor/editor_import_export.cpp @@ -47,6 +47,7 @@ String EditorImportPlugin::validate_source_path(const String& p_path) { String rp = Globals::get_singleton()->get_resource_path(); if (!rp.ends_with("/")) rp+="/"; + return rp.path_to_file(gp); } diff --git a/tools/editor/editor_settings.cpp b/tools/editor/editor_settings.cpp index 52eeb1fefd..9a4505efed 100644 --- a/tools/editor/editor_settings.cpp +++ b/tools/editor/editor_settings.cpp @@ -408,7 +408,7 @@ void EditorSettings::_load_defaults() { set("text_editor/idle_parse_delay",2); set("text_editor/create_signal_callbacks",true); - set("text_editor/autosave_interval_seconds",60); + set("text_editor/autosave_interval_secs",0); set("text_editor/font",""); hints["text_editor/font"]=PropertyInfo(Variant::STRING,"text_editor/font",PROPERTY_HINT_GLOBAL_FILE,"*.fnt"); set("text_editor/auto_brace_complete", false); diff --git a/tools/editor/io_plugins/editor_font_import_plugin.cpp b/tools/editor/io_plugins/editor_font_import_plugin.cpp index b0ff6f6e74..375333ddf6 100644 --- a/tools/editor/io_plugins/editor_font_import_plugin.cpp +++ b/tools/editor/io_plugins/editor_font_import_plugin.cpp @@ -406,7 +406,10 @@ class EditorFontImportDialog : public ConfirmationDialog { imd->set_option(opt,v); } - imd->add_source(EditorImportPlugin::validate_source_path(source->get_line_edit()->get_text())); + String src_path = EditorImportPlugin::validate_source_path(source->get_line_edit()->get_text()); + //print_line("pre src path "+source->get_line_edit()->get_text()); + //print_line("src path "+src_path); + imd->add_source(src_path); imd->set_option("font/size",font_size->get_val()); return imd; @@ -1018,7 +1021,7 @@ Ref<Font> EditorFontImportPlugin::generate_font(const Ref<ResourceImportMetadata int h = slot->bitmap.rows; int p = slot->bitmap.pitch; - print_line("W: "+itos(w)+" P: "+itos(slot->bitmap.pitch)); + //print_line("W: "+itos(w)+" P: "+itos(slot->bitmap.pitch)); if (font_mode==_EditorFontImportOptions::FONT_DISTANCE_FIELD) { diff --git a/tools/editor/plugins/script_editor_plugin.cpp b/tools/editor/plugins/script_editor_plugin.cpp index 7deb856fa6..e6e311cfa1 100644 --- a/tools/editor/plugins/script_editor_plugin.cpp +++ b/tools/editor/plugins/script_editor_plugin.cpp @@ -130,6 +130,7 @@ void ScriptEditorQuickOpen::_bind_methods() { ObjectTypeDB::bind_method(_MD("_confirmed"),&ScriptEditorQuickOpen::_confirmed); ObjectTypeDB::bind_method(_MD("_sbox_input"),&ScriptEditorQuickOpen::_sbox_input); + ADD_SIGNAL(MethodInfo("goto_line",PropertyInfo(Variant::INT,"line"))); } @@ -1089,6 +1090,18 @@ void ScriptEditor::_notification(int p_what) { editor->connect("stop_pressed",this,"_editor_stop"); editor->connect("script_add_function_request",this,"_add_callback"); editor->connect("resource_saved",this,"_res_saved_callback"); + autosave_timer->connect("timeout",this,"_autosave_scripts"); + { + float autosave_time = EditorSettings::get_singleton()->get("text_editor/autosave_interval_secs"); + if (autosave_time>0) { + autosave_timer->set_wait_time(autosave_time); + autosave_timer->start(); + } else { + autosave_timer->stop(); + } + } + + EditorSettings::get_singleton()->connect("settings_changed",this,"_editor_settings_changed"); } @@ -1339,7 +1352,8 @@ void ScriptEditor::_bind_methods() { ObjectTypeDB::bind_method("_breaked",&ScriptEditor::_breaked); ObjectTypeDB::bind_method("_show_debugger",&ScriptEditor::_show_debugger); ObjectTypeDB::bind_method("_get_debug_tooltip",&ScriptEditor::_get_debug_tooltip); - + ObjectTypeDB::bind_method("_autosave_scripts",&ScriptEditor::_autosave_scripts); + ObjectTypeDB::bind_method("_editor_settings_changed",&ScriptEditor::_editor_settings_changed); } @@ -1568,6 +1582,25 @@ void ScriptEditor::_add_callback(Object *p_obj, const String& p_function, const } +void ScriptEditor::_editor_settings_changed() { + + print_line("settings changed"); + float autosave_time = EditorSettings::get_singleton()->get("text_editor/autosave_interval_secs"); + if (autosave_time>0) { + autosave_timer->set_wait_time(autosave_time); + autosave_timer->start(); + } else { + autosave_timer->stop(); + } + +} + +void ScriptEditor::_autosave_scripts() { + + print_line("autosaving"); + save_external_data(); +} + ScriptEditor::ScriptEditor(EditorNode *p_editor) { editor=p_editor; @@ -1718,6 +1751,11 @@ ScriptEditor::ScriptEditor(EditorNode *p_editor) { v_split->add_child(debugger); debugger->connect("breaked",this,"_breaked"); + + autosave_timer = memnew( Timer ); + autosave_timer->set_one_shot(false); + add_child(autosave_timer); + // debugger_gui->hide(); } diff --git a/tools/editor/plugins/script_editor_plugin.h b/tools/editor/plugins/script_editor_plugin.h index 7526138112..acfdd1e966 100644 --- a/tools/editor/plugins/script_editor_plugin.h +++ b/tools/editor/plugins/script_editor_plugin.h @@ -154,6 +154,7 @@ class ScriptEditor : public VBoxContainer { MenuButton *window_menu; MenuButton *debug_menu; MenuButton *help_menu; + Timer *autosave_timer; uint64_t idle; TabContainer *tab_container; @@ -195,6 +196,9 @@ class ScriptEditor : public VBoxContainer { void _show_debugger(bool p_show); void _update_window_menu(); + void _editor_settings_changed(); + void _autosave_scripts(); + static ScriptEditor *script_editor; protected: void _notification(int p_what); |