Display an error message if no version control systems are available

This removes the need for a dedicated placeholder entry.

This closes #32135.
This commit is contained in:
Hugo Locurcio 2019-09-14 19:40:15 +02:00
parent 24e1039eb6
commit 6df03fe61f
No known key found for this signature in database
GPG Key ID: 39E8F8BE30B0A49C
1 changed files with 14 additions and 24 deletions

View File

@ -59,14 +59,6 @@ void VersionControlEditorPlugin::_selected_a_vcs(int p_id) {
List<StringName> available_addons = get_available_vcs_names(); List<StringName> available_addons = get_available_vcs_names();
const StringName selected_vcs = set_up_choice->get_item_text(p_id); const StringName selected_vcs = set_up_choice->get_item_text(p_id);
if (available_addons.find(selected_vcs) != NULL) {
set_up_init_button->set_disabled(false);
} else {
set_up_init_button->set_disabled(true);
}
} }
void VersionControlEditorPlugin::_populate_available_vcs_names() { void VersionControlEditorPlugin::_populate_available_vcs_names() {
@ -75,9 +67,6 @@ void VersionControlEditorPlugin::_populate_available_vcs_names() {
if (!called) { if (!called) {
set_up_choice->add_item("Select an available VCS");
fetch_available_vcs_addon_names();
List<StringName> available_addons = get_available_vcs_names(); List<StringName> available_addons = get_available_vcs_names();
for (int i = 0; i < available_addons.size(); i++) { for (int i = 0; i < available_addons.size(); i++) {
@ -95,19 +84,22 @@ VersionControlEditorPlugin *VersionControlEditorPlugin::get_singleton() {
void VersionControlEditorPlugin::popup_vcs_set_up_dialog(const Control *p_gui_base) { void VersionControlEditorPlugin::popup_vcs_set_up_dialog(const Control *p_gui_base) {
fetch_available_vcs_addon_names();
List<StringName> available_addons = get_available_vcs_names();
if (available_addons.size() >= 1) {
Size2 popup_size = Size2(400, 100); Size2 popup_size = Size2(400, 100);
Size2 window_size = p_gui_base->get_viewport_rect().size; Size2 window_size = p_gui_base->get_viewport_rect().size;
popup_size.x = MIN(window_size.x * 0.5, popup_size.x); popup_size.x = MIN(window_size.x * 0.5, popup_size.x);
popup_size.y = MIN(window_size.y * 0.5, popup_size.y); popup_size.y = MIN(window_size.y * 0.5, popup_size.y);
if (get_is_vcs_intialized()) {
set_up_init_button->set_disabled(true);
}
_populate_available_vcs_names(); _populate_available_vcs_names();
set_up_dialog->popup_centered_clamped(popup_size * EDSCALE); set_up_dialog->popup_centered_clamped(popup_size * EDSCALE);
} else {
EditorNode::get_singleton()->show_warning(TTR("No VCS addons are available."), TTR("Error"));
}
} }
void VersionControlEditorPlugin::_initialize_vcs() { void VersionControlEditorPlugin::_initialize_vcs() {
@ -120,7 +112,7 @@ void VersionControlEditorPlugin::_initialize_vcs() {
return; return;
} }
int id = set_up_choice->get_selected_id(); const int id = set_up_choice->get_selected_id();
String selected_addon = set_up_choice->get_item_text(id); String selected_addon = set_up_choice->get_item_text(id);
String path = ScriptServer::get_global_class_path(selected_addon); String path = ScriptServer::get_global_class_path(selected_addon);
@ -427,7 +419,6 @@ VersionControlEditorPlugin::VersionControlEditorPlugin() {
version_control_actions->add_child(set_up_dialog); version_control_actions->add_child(set_up_dialog);
set_up_ok_button = set_up_dialog->get_ok(); set_up_ok_button = set_up_dialog->get_ok();
set_up_ok_button->set_disabled(false);
set_up_ok_button->set_text(TTR("Close")); set_up_ok_button->set_text(TTR("Close"));
set_up_vbc = memnew(VBoxContainer); set_up_vbc = memnew(VBoxContainer);
@ -454,7 +445,6 @@ VersionControlEditorPlugin::VersionControlEditorPlugin() {
set_up_init_settings = NULL; set_up_init_settings = NULL;
set_up_init_button = memnew(Button); set_up_init_button = memnew(Button);
set_up_init_button->set_disabled(true);
set_up_init_button->set_text(TTR("Initialize")); set_up_init_button->set_text(TTR("Initialize"));
set_up_init_button->connect("pressed", this, "_initialize_vcs"); set_up_init_button->connect("pressed", this, "_initialize_vcs");
set_up_vbc->add_child(set_up_init_button); set_up_vbc->add_child(set_up_init_button);