diff options
Diffstat (limited to 'editor/editor_properties.cpp')
-rw-r--r-- | editor/editor_properties.cpp | 58 |
1 files changed, 54 insertions, 4 deletions
diff --git a/editor/editor_properties.cpp b/editor/editor_properties.cpp index 9c9302e7cd..c8b4831d63 100644 --- a/editor/editor_properties.cpp +++ b/editor/editor_properties.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */ +/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ @@ -233,7 +233,7 @@ void EditorPropertyPath::_path_pressed() { dialog->set_mode(EditorFileDialog::MODE_OPEN_DIR); dialog->set_current_dir(full_path); } else { - dialog->set_mode(EditorFileDialog::MODE_OPEN_FILE); + dialog->set_mode(save_mode ? EditorFileDialog::MODE_SAVE_FILE : EditorFileDialog::MODE_OPEN_FILE); for (int i = 0; i < extensions.size(); i++) { String e = extensions[i].strip_edges(); if (e != String()) { @@ -260,6 +260,11 @@ void EditorPropertyPath::setup(const Vector<String> &p_extensions, bool p_folder global = p_global; } +void EditorPropertyPath::set_save_mode() { + + save_mode = true; +} + void EditorPropertyPath::_notification(int p_what) { if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) { @@ -296,6 +301,7 @@ EditorPropertyPath::EditorPropertyPath() { path_edit->connect("pressed", this, "_path_pressed"); folder = false; global = false; + save_mode = false; } ///////////////////// CLASS NAME ///////////////////////// @@ -1090,6 +1096,8 @@ void EditorPropertyVector2::setup(double p_min, double p_max, double p_step, boo spin[i]->set_max(p_max); spin[i]->set_step(p_step); spin[i]->set_hide_slider(p_no_slider); + spin[i]->set_allow_greater(true); + spin[i]->set_allow_lesser(true); } } @@ -1171,6 +1179,8 @@ void EditorPropertyRect2::setup(double p_min, double p_max, double p_step, bool spin[i]->set_max(p_max); spin[i]->set_step(p_step); spin[i]->set_hide_slider(p_no_slider); + spin[i]->set_allow_greater(true); + spin[i]->set_allow_lesser(true); } } @@ -1251,6 +1261,8 @@ void EditorPropertyVector3::setup(double p_min, double p_max, double p_step, boo spin[i]->set_max(p_max); spin[i]->set_step(p_step); spin[i]->set_hide_slider(p_no_slider); + spin[i]->set_allow_greater(true); + spin[i]->set_allow_lesser(true); } } @@ -1331,6 +1343,8 @@ void EditorPropertyPlane::setup(double p_min, double p_max, double p_step, bool spin[i]->set_max(p_max); spin[i]->set_step(p_step); spin[i]->set_hide_slider(p_no_slider); + spin[i]->set_allow_greater(true); + spin[i]->set_allow_lesser(true); } } @@ -1413,6 +1427,8 @@ void EditorPropertyQuat::setup(double p_min, double p_max, double p_step, bool p spin[i]->set_max(p_max); spin[i]->set_step(p_step); spin[i]->set_hide_slider(p_no_slider); + spin[i]->set_allow_greater(true); + spin[i]->set_allow_lesser(true); } } @@ -1500,6 +1516,8 @@ void EditorPropertyAABB::setup(double p_min, double p_max, double p_step, bool p spin[i]->set_max(p_max); spin[i]->set_step(p_step); spin[i]->set_hide_slider(p_no_slider); + spin[i]->set_allow_greater(true); + spin[i]->set_allow_lesser(true); } } @@ -1574,6 +1592,8 @@ void EditorPropertyTransform2D::setup(double p_min, double p_max, double p_step, spin[i]->set_max(p_max); spin[i]->set_step(p_step); spin[i]->set_hide_slider(p_no_slider); + spin[i]->set_allow_greater(true); + spin[i]->set_allow_lesser(true); } } @@ -1653,6 +1673,8 @@ void EditorPropertyBasis::setup(double p_min, double p_max, double p_step, bool spin[i]->set_max(p_max); spin[i]->set_step(p_step); spin[i]->set_hide_slider(p_no_slider); + spin[i]->set_allow_greater(true); + spin[i]->set_allow_lesser(true); } } @@ -1738,6 +1760,8 @@ void EditorPropertyTransform::setup(double p_min, double p_max, double p_step, b spin[i]->set_max(p_max); spin[i]->set_step(p_step); spin[i]->set_hide_slider(p_no_slider); + spin[i]->set_allow_greater(true); + spin[i]->set_allow_lesser(true); } } @@ -1853,7 +1877,7 @@ void EditorPropertyNodePath::update_property() { assign->set_tooltip(p); if (p == NodePath()) { assign->set_icon(Ref<Texture>()); - assign->set_text(TTR("Assign..")); + assign->set_text(TTR("Assign...")); assign->set_flat(false); return; } @@ -1932,6 +1956,30 @@ EditorPropertyNodePath::EditorPropertyNodePath() { void EditorPropertyResource::_file_selected(const String &p_path) { RES res = ResourceLoader::load(p_path); + + List<PropertyInfo> prop_list; + get_edited_object()->get_property_list(&prop_list); + String property_types; + + for (List<PropertyInfo>::Element *E = prop_list.front(); E; E = E->next()) { + if (E->get().name == get_edited_property() && (E->get().hint & PROPERTY_HINT_RESOURCE_TYPE)) { + property_types = E->get().hint_string; + } + } + if (!property_types.empty()) { + bool any_type_matches = false; + const Vector<String> split_property_types = property_types.split(","); + for (int i = 0; i < split_property_types.size(); ++i) { + if (res->is_class(split_property_types[i])) { + any_type_matches = true; + break; + } + } + + if (!any_type_matches) + EditorNode::get_singleton()->show_warning(vformat(TTR("The selected resource (%s) does not match any type expected for this property (%s)."), res->get_class(), property_types)); + } + emit_signal("property_changed", get_edited_property(), res); update_property(); } @@ -2373,6 +2421,7 @@ void EditorPropertyResource::update_property() { if (!sub_inspector) { sub_inspector = memnew(EditorInspector); sub_inspector->set_enable_v_scroll(false); + sub_inspector->set_use_doc_hints(true); sub_inspector->set_use_sub_inspector_bg(true); sub_inspector->set_enable_capitalize_paths(true); @@ -2383,6 +2432,7 @@ void EditorPropertyResource::update_property() { sub_inspector->set_keying(is_keying()); sub_inspector->set_read_only(is_read_only()); sub_inspector->set_use_folding(is_using_folding()); + sub_inspector->set_undo_redo(EditorNode::get_singleton()->get_undo_redo()); sub_inspector_vbox = memnew(VBoxContainer); add_child(sub_inspector_vbox); |