Fixes add script button update

This commit is contained in:
Gilles Roudiere 2018-01-11 21:58:17 +01:00
parent 9a62829759
commit ff8fe3d875
2 changed files with 16 additions and 13 deletions

View file

@ -350,8 +350,7 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
if (existing.is_valid()) {
const RefPtr empty;
selected->set_script(empty);
button_create_script->show();
button_clear_script->hide();
_update_script_button();
}
} break;
@ -1211,8 +1210,7 @@ void SceneTreeDock::_script_created(Ref<Script> p_script) {
return;
selected->set_script(p_script.get_ref_ptr());
editor->push_item(p_script.operator->());
button_create_script->hide();
button_clear_script->show();
_update_script_button();
}
void SceneTreeDock::_delete_confirm() {
@ -1299,15 +1297,8 @@ void SceneTreeDock::_delete_confirm() {
EditorNode::get_singleton()->call("_prepare_history");
}
void SceneTreeDock::_selection_changed() {
int selection_size = EditorNode::get_singleton()->get_editor_selection()->get_selection().size();
if (selection_size > 1) {
//automatically turn on multi-edit
_tool_selected(TOOL_MULTI_EDIT);
}
if (selection_size == 1) {
void SceneTreeDock::_update_script_button() {
if (EditorNode::get_singleton()->get_editor_selection()->get_selection().size() == 1) {
if (EditorNode::get_singleton()->get_editor_selection()->get_selection().front()->key()->get_script().is_null()) {
button_create_script->show();
button_clear_script->hide();
@ -1321,6 +1312,16 @@ void SceneTreeDock::_selection_changed() {
}
}
void SceneTreeDock::_selection_changed() {
int selection_size = EditorNode::get_singleton()->get_editor_selection()->get_selection().size();
if (selection_size > 1) {
//automatically turn on multi-edit
_tool_selected(TOOL_MULTI_EDIT);
}
_update_script_button();
}
void SceneTreeDock::_create() {
if (current_option == TOOL_NEW) {
@ -1655,6 +1656,7 @@ void SceneTreeDock::_script_dropped(String p_file, NodePath p_to) {
Node *n = get_node(p_to);
if (n) {
n->set_script(scr.get_ref_ptr());
_update_script_button();
}
}

View file

@ -160,6 +160,7 @@ class SceneTreeDock : public VBoxContainer {
bool _validate_no_foreign();
void _selection_changed();
void _update_script_button();
void _fill_path_renames(Vector<StringName> base_path, Vector<StringName> new_base_path, Node *p_node, List<Pair<NodePath, NodePath> > *p_renames);