Re-add clear script button and context menu from ce5200b30e
This commit is contained in:
parent
5d8d51719a
commit
1307ff7eb1
2 changed files with 38 additions and 3 deletions
|
@ -61,6 +61,8 @@ void SceneTreeDock::_unhandled_key_input(InputEvent p_event) {
|
|||
_tool_selected(TOOL_CREATE_SCRIPT);
|
||||
} else if (ED_IS_SHORTCUT("scene_tree/load_script", p_event)) {
|
||||
_tool_selected(TOOL_LOAD_SCRIPT);
|
||||
} else if(ED_IS_SHORTCUT("scene_tree/clear_script", p_event)) {
|
||||
_tool_selected(TOOL_CLEAR_SCRIPT);
|
||||
} else if (ED_IS_SHORTCUT("scene_tree/move_up", p_event)) {
|
||||
_tool_selected(TOOL_MOVE_UP);
|
||||
} else if (ED_IS_SHORTCUT("scene_tree/move_down", p_event)) {
|
||||
|
@ -381,6 +383,18 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
|
|||
//script_create_dialog->popup_centered_minsize();
|
||||
}
|
||||
|
||||
} break;
|
||||
case TOOL_CLEAR_SCRIPT: {
|
||||
Node *selected = scene_tree->get_selected();
|
||||
if(!selected)
|
||||
break;
|
||||
|
||||
Ref<Script> existing = selected->get_script();
|
||||
if(existing.is_valid()) {
|
||||
const RefPtr empty;
|
||||
selected->set_script(empty);
|
||||
}
|
||||
|
||||
} break;
|
||||
case TOOL_MOVE_UP:
|
||||
case TOOL_MOVE_DOWN: {
|
||||
|
@ -711,6 +725,7 @@ void SceneTreeDock::_notification(int p_what) {
|
|||
button_instance->set_icon(get_icon("Instance", "EditorIcons"));
|
||||
button_create_script->set_icon(get_icon("ScriptCreate","EditorIcons"));
|
||||
button_load_script->set_icon(get_icon("Script", "EditorIcons"));
|
||||
button_clear_script->set_icon(get_icon("Remove", "EditorIcons"));
|
||||
|
||||
filter_icon->set_texture(get_icon("Zoom", "EditorIcons"));
|
||||
|
||||
|
@ -1281,12 +1296,21 @@ void SceneTreeDock::_selection_changed() {
|
|||
_tool_selected(TOOL_MULTI_EDIT);
|
||||
}
|
||||
|
||||
if (selection_size==1 && EditorNode::get_singleton()->get_editor_selection()->get_selection().front()->key()->get_script().is_null()) {
|
||||
button_create_script->show();
|
||||
button_load_script->show();
|
||||
if (selection_size==1) {
|
||||
if(EditorNode::get_singleton()->get_editor_selection()->get_selection().front()->key()->get_script().is_null()) {
|
||||
button_create_script->show();
|
||||
button_load_script->show();
|
||||
button_clear_script->hide();
|
||||
}
|
||||
else {
|
||||
button_create_script->hide();
|
||||
button_load_script->hide();
|
||||
button_clear_script->show();
|
||||
}
|
||||
} else {
|
||||
button_create_script->hide();
|
||||
button_load_script->hide();
|
||||
button_clear_script->hide();
|
||||
}
|
||||
|
||||
//tool_buttons[TOOL_MULTI_EDIT]->set_disabled(EditorNode::get_singleton()->get_editor_selection()->get_selection().size()<2);
|
||||
|
@ -1710,6 +1734,7 @@ void SceneTreeDock::_tree_rmb(const Vector2 &p_menu_pos) {
|
|||
menu->add_separator();
|
||||
menu->add_icon_shortcut(get_icon("ScriptCreate", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/add_script"), TOOL_CREATE_SCRIPT);
|
||||
menu->add_icon_shortcut(get_icon("Script", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/load_script"), TOOL_LOAD_SCRIPT);
|
||||
menu->add_icon_shortcut(get_icon("Remove", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/clear_script"), TOOL_CLEAR_SCRIPT);
|
||||
menu->add_separator();
|
||||
}
|
||||
|
||||
|
@ -1800,6 +1825,7 @@ SceneTreeDock::SceneTreeDock(EditorNode *p_editor, Node *p_scene_root, EditorSel
|
|||
ED_SHORTCUT("scene_tree/change_node_type", TTR("Change Type"));
|
||||
ED_SHORTCUT("scene_tree/add_script", TTR("Add Script"));
|
||||
ED_SHORTCUT("scene_tree/load_script", TTR("Load Script"));
|
||||
ED_SHORTCUT("scene_tree/clear_script", TTR("Clear Script"));
|
||||
ED_SHORTCUT("scene_tree/move_up", TTR("Move Up"), KEY_MASK_CMD | KEY_UP);
|
||||
ED_SHORTCUT("scene_tree/move_down", TTR("Move Down"), KEY_MASK_CMD | KEY_DOWN);
|
||||
ED_SHORTCUT("scene_tree/duplicate", TTR("Duplicate"), KEY_MASK_CMD | KEY_D);
|
||||
|
@ -1847,6 +1873,13 @@ SceneTreeDock::SceneTreeDock(EditorNode *p_editor, Node *p_scene_root, EditorSel
|
|||
filter_hbc->add_child(tb);
|
||||
button_load_script = tb;
|
||||
|
||||
tb = memnew(ToolButton);
|
||||
tb->connect("pressed", this, "_tool_selected", make_binds(TOOL_CLEAR_SCRIPT, false));
|
||||
tb->set_tooltip(TTR("Clear a script for the selected node."));
|
||||
tb->set_shortcut(ED_GET_SHORTCUT("scene_tree/clear_script"));
|
||||
filter_hbc->add_child(tb);
|
||||
button_clear_script = tb;
|
||||
|
||||
scene_tree = memnew(SceneTreeEditor(false, true, true));
|
||||
vbc->add_child(scene_tree);
|
||||
scene_tree->set_v_size_flags(SIZE_EXPAND | SIZE_FILL);
|
||||
|
|
|
@ -60,6 +60,7 @@ class SceneTreeDock : public VBoxContainer {
|
|||
TOOL_GROUP,
|
||||
TOOL_CREATE_SCRIPT,
|
||||
TOOL_LOAD_SCRIPT,
|
||||
TOOL_CLEAR_SCRIPT,
|
||||
TOOL_MOVE_UP,
|
||||
TOOL_MOVE_DOWN,
|
||||
TOOL_DUPLICATE,
|
||||
|
@ -80,6 +81,7 @@ class SceneTreeDock : public VBoxContainer {
|
|||
ToolButton *button_instance;
|
||||
ToolButton *button_create_script;
|
||||
ToolButton *button_load_script;
|
||||
ToolButton *button_clear_script;
|
||||
|
||||
SceneTreeEditor *scene_tree;
|
||||
|
||||
|
|
Loading…
Reference in a new issue