| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
#pragma once |
| 32 |
|
| 33 |
#include "editor/plugins/editor_plugin.h" |
| 34 |
#include "editor/version_control/editor_vcs_interface.h" |
| 35 |
#include "scene/gui/check_button.h" |
| 36 |
#include "scene/gui/file_dialog.h" |
| 37 |
#include "scene/gui/menu_button.h" |
| 38 |
#include "scene/gui/rich_text_label.h" |
| 39 |
#include "scene/gui/text_edit.h" |
| 40 |
#include "scene/gui/tree.h" |
| 41 |
|
| 42 |
class EditorDock; |
| 43 |
|
| 44 |
class VersionControlEditorPlugin : public EditorPlugin { |
| 45 |
GDCLASS(VersionControlEditorPlugin, EditorPlugin) |
| 46 |
|
| 47 |
public: |
| 48 |
enum ButtonType { |
| 49 |
BUTTON_TYPE_OPEN = 0, |
| 50 |
BUTTON_TYPE_DISCARD = 1, |
| 51 |
}; |
| 52 |
|
| 53 |
enum DiffViewType { |
| 54 |
DIFF_VIEW_TYPE_SPLIT = 0, |
| 55 |
DIFF_VIEW_TYPE_UNIFIED = 1, |
| 56 |
}; |
| 57 |
|
| 58 |
enum ExtraOption { |
| 59 |
EXTRA_OPTION_FORCE_PUSH, |
| 60 |
EXTRA_OPTION_CREATE_BRANCH, |
| 61 |
EXTRA_OPTION_CREATE_REMOTE, |
| 62 |
}; |
| 63 |
|
| 64 |
private: |
| 65 |
static VersionControlEditorPlugin *singleton; |
| 66 |
|
| 67 |
List<StringName> available_plugins; |
| 68 |
|
| 69 |
PopupMenu *version_control_actions = nullptr; |
| 70 |
ConfirmationDialog *metadata_dialog = nullptr; |
| 71 |
OptionButton *metadata_selection = nullptr; |
| 72 |
AcceptDialog *set_up_dialog = nullptr; |
| 73 |
CheckButton *toggle_vcs_choice = nullptr; |
| 74 |
OptionButton *set_up_choice = nullptr; |
| 75 |
VBoxContainer *set_up_vbc = nullptr; |
| 76 |
VBoxContainer *set_up_settings_vbc = nullptr; |
| 77 |
LineEdit *set_up_username = nullptr; |
| 78 |
LineEdit *set_up_password = nullptr; |
| 79 |
LineEdit *set_up_ssh_public_key_path = nullptr; |
| 80 |
LineEdit *set_up_ssh_private_key_path = nullptr; |
| 81 |
LineEdit *set_up_ssh_passphrase = nullptr; |
| 82 |
FileDialog *set_up_ssh_public_key_file_dialog = nullptr; |
| 83 |
FileDialog *set_up_ssh_private_key_file_dialog = nullptr; |
| 84 |
Label *set_up_warning_text = nullptr; |
| 85 |
Button *select_public_path_button = nullptr; |
| 86 |
Button *select_private_path_button = nullptr; |
| 87 |
|
| 88 |
AcceptDialog *discard_all_confirm = nullptr; |
| 89 |
|
| 90 |
OptionButton *commit_list_size_button = nullptr; |
| 91 |
|
| 92 |
AcceptDialog *branch_create_confirm = nullptr; |
| 93 |
LineEdit *branch_create_name_input = nullptr; |
| 94 |
Button *branch_create_ok = nullptr; |
| 95 |
|
| 96 |
AcceptDialog *remote_create_confirm = nullptr; |
| 97 |
LineEdit *remote_create_name_input = nullptr; |
| 98 |
LineEdit *remote_create_url_input = nullptr; |
| 99 |
Button *remote_create_ok = nullptr; |
| 100 |
|
| 101 |
HashMap<EditorVCSInterface::ChangeType, String> change_type_to_strings; |
| 102 |
HashMap<EditorVCSInterface::ChangeType, Color> change_type_to_color; |
| 103 |
HashMap<EditorVCSInterface::ChangeType, Ref<Texture>> change_type_to_icon; |
| 104 |
|
| 105 |
EditorDock *version_commit_dock = nullptr; |
| 106 |
Tree *staged_files = nullptr; |
| 107 |
Tree *unstaged_files = nullptr; |
| 108 |
Tree *commit_list = nullptr; |
| 109 |
|
| 110 |
OptionButton *branch_select = nullptr; |
| 111 |
Button *branch_remove_button = nullptr; |
| 112 |
AcceptDialog *branch_remove_confirm = nullptr; |
| 113 |
|
| 114 |
Button *fetch_button = nullptr; |
| 115 |
Button *pull_button = nullptr; |
| 116 |
Button *push_button = nullptr; |
| 117 |
OptionButton *remote_select = nullptr; |
| 118 |
Button *remote_remove_button = nullptr; |
| 119 |
AcceptDialog *remote_remove_confirm = nullptr; |
| 120 |
MenuButton *extra_options = nullptr; |
| 121 |
PopupMenu *extra_options_remove_branch_list = nullptr; |
| 122 |
PopupMenu *extra_options_remove_remote_list = nullptr; |
| 123 |
|
| 124 |
String branch_to_remove; |
| 125 |
String remote_to_remove; |
| 126 |
|
| 127 |
Button *stage_all_button = nullptr; |
| 128 |
Button *unstage_all_button = nullptr; |
| 129 |
Button *discard_all_button = nullptr; |
| 130 |
Button *refresh_button = nullptr; |
| 131 |
TextEdit *commit_message = nullptr; |
| 132 |
Button *commit_button = nullptr; |
| 133 |
|
| 134 |
VBoxContainer *version_control_dock = nullptr; |
| 135 |
Label *diff_title = nullptr; |
| 136 |
RichTextLabel *diff = nullptr; |
| 137 |
OptionButton *diff_view_type_select = nullptr; |
| 138 |
bool show_commit_diff_header = false; |
| 139 |
List<EditorVCSInterface::DiffFile> diff_content; |
| 140 |
|
| 141 |
void _notification(int p_what); |
| 142 |
void _update_theme(); |
| 143 |
void _initialize_vcs(); |
| 144 |
void _set_vcs_ui_state(bool p_enabled); |
| 145 |
void _set_credentials(); |
| 146 |
void _ssh_public_key_selected(const String &p_path); |
| 147 |
void _ssh_private_key_selected(const String &p_path); |
| 148 |
void _populate_available_vcs_names(); |
| 149 |
void _update_remotes_list(); |
| 150 |
void _update_set_up_warning(const String &p_new_text); |
| 151 |
void _update_opened_tabs(); |
| 152 |
void _update_extra_options(); |
| 153 |
|
| 154 |
bool _load_plugin(const String &p_name); |
| 155 |
|
| 156 |
void _pull(); |
| 157 |
void _push(); |
| 158 |
void _force_push(); |
| 159 |
void _fetch(); |
| 160 |
void _commit(); |
| 161 |
void _confirm_discard_all(); |
| 162 |
void _discard_all(); |
| 163 |
void _refresh_stage_area(); |
| 164 |
void _refresh_branch_list(); |
| 165 |
void _set_commit_list_size(int p_index); |
| 166 |
void _refresh_commit_list(); |
| 167 |
void _refresh_remote_list(); |
| 168 |
void _display_diff(int p_idx); |
| 169 |
void _move_all(Object *p_tree); |
| 170 |
void _load_diff(Object *p_tree); |
| 171 |
void _clear_diff(); |
| 172 |
int _get_item_count(Tree *p_tree); |
| 173 |
void _item_activated(Object *p_tree); |
| 174 |
void _create_branch(); |
| 175 |
void _create_remote(); |
| 176 |
void _update_branch_create_button(const String &p_new_text); |
| 177 |
void _update_remote_create_button(const String &p_new_text); |
| 178 |
void _branch_item_selected(int p_index); |
| 179 |
void _remote_selected(int p_index); |
| 180 |
void _remove_branch(); |
| 181 |
void _remove_remote(); |
| 182 |
void _popup_branch_remove_confirm(int p_index); |
| 183 |
void _popup_remote_remove_confirm(int p_index); |
| 184 |
void _move_item(Tree *p_tree, TreeItem *p_itme); |
| 185 |
void _display_diff_split_view(List<EditorVCSInterface::DiffLine> &p_diff_content); |
| 186 |
void _display_diff_unified_view(List<EditorVCSInterface::DiffLine> &p_diff_content); |
| 187 |
void _discard_file(const String &p_file_path, EditorVCSInterface::ChangeType p_change); |
| 188 |
void _cell_button_pressed(Object *p_item, int p_column, int p_id, int p_mouse_button_index); |
| 189 |
void _add_new_item(Tree *p_tree, const String &p_file_path, EditorVCSInterface::ChangeType p_change); |
| 190 |
void _update_commit_button(); |
| 191 |
void _commit_message_gui_input(const Ref<InputEvent> &p_event); |
| 192 |
void _extra_option_selected(int p_index); |
| 193 |
bool _is_staging_area_empty(); |
| 194 |
String _get_date_string_from(int64_t p_unix_timestamp, int64_t p_offset_minutes) const; |
| 195 |
void _create_vcs_metadata_files(); |
| 196 |
void _popup_file_dialog(const Variant &p_file_dialog_variant); |
| 197 |
void _toggle_vcs_integration(bool p_toggled); |
| 198 |
|
| 199 |
friend class EditorVCSInterface; |
| 200 |
|
| 201 |
protected: |
| 202 |
static void _bind_methods(); |
| 203 |
|
| 204 |
public: |
| 205 |
static VersionControlEditorPlugin *get_singleton(); |
| 206 |
|
| 207 |
void popup_vcs_metadata_dialog(); |
| 208 |
void popup_vcs_set_up_dialog(const Control *p_gui_base); |
| 209 |
|
| 210 |
PopupMenu *get_version_control_actions_panel() const { return version_control_actions; } |
| 211 |
|
| 212 |
void register_editor(); |
| 213 |
void fetch_available_vcs_plugin_names(); |
| 214 |
void shut_down(); |
| 215 |
|
| 216 |
VersionControlEditorPlugin(); |
| 217 |
~VersionControlEditorPlugin(); |
| 218 |
}; |