2019-09-04 13:17:26 +02:00
|
|
|
/**************************************************************************/
|
|
|
|
/* version_control_editor_plugin.h */
|
|
|
|
/**************************************************************************/
|
|
|
|
/* This file is part of: */
|
|
|
|
/* GODOT ENGINE */
|
|
|
|
/* https://godotengine.org */
|
|
|
|
/**************************************************************************/
|
|
|
|
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
|
|
|
|
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
|
|
|
|
/* */
|
|
|
|
/* Permission is hereby granted, free of charge, to any person obtaining */
|
|
|
|
/* a copy of this software and associated documentation files (the */
|
|
|
|
/* "Software"), to deal in the Software without restriction, including */
|
|
|
|
/* without limitation the rights to use, copy, modify, merge, publish, */
|
|
|
|
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
|
|
|
/* permit persons to whom the Software is furnished to do so, subject to */
|
|
|
|
/* the following conditions: */
|
|
|
|
/* */
|
|
|
|
/* The above copyright notice and this permission notice shall be */
|
|
|
|
/* included in all copies or substantial portions of the Software. */
|
|
|
|
/* */
|
|
|
|
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
|
|
|
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
|
|
|
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
|
|
|
|
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
|
|
|
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
|
|
|
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
|
|
|
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
|
|
|
/**************************************************************************/
|
|
|
|
|
2019-09-03 16:28:32 +02:00
|
|
|
#ifndef VERSION_CONTROL_EDITOR_PLUGIN_H
|
|
|
|
#define VERSION_CONTROL_EDITOR_PLUGIN_H
|
|
|
|
|
|
|
|
#include "editor/editor_plugin.h"
|
|
|
|
#include "editor/editor_vcs_interface.h"
|
2022-08-09 23:56:19 +02:00
|
|
|
#include "scene/gui/check_button.h"
|
2022-06-13 20:47:40 +02:00
|
|
|
#include "scene/gui/container.h"
|
|
|
|
#include "scene/gui/file_dialog.h"
|
|
|
|
#include "scene/gui/menu_button.h"
|
2019-09-03 16:28:32 +02:00
|
|
|
#include "scene/gui/rich_text_label.h"
|
2022-06-13 20:47:40 +02:00
|
|
|
#include "scene/gui/tab_container.h"
|
2019-09-03 16:28:32 +02:00
|
|
|
#include "scene/gui/text_edit.h"
|
|
|
|
#include "scene/gui/tree.h"
|
|
|
|
|
|
|
|
class VersionControlEditorPlugin : public EditorPlugin {
|
|
|
|
GDCLASS(VersionControlEditorPlugin, EditorPlugin)
|
|
|
|
|
|
|
|
public:
|
2022-06-13 20:47:40 +02:00
|
|
|
enum ButtonType {
|
|
|
|
BUTTON_TYPE_OPEN = 0,
|
|
|
|
BUTTON_TYPE_DISCARD = 1,
|
|
|
|
};
|
|
|
|
|
|
|
|
enum DiffViewType {
|
|
|
|
DIFF_VIEW_TYPE_SPLIT = 0,
|
|
|
|
DIFF_VIEW_TYPE_UNIFIED = 1,
|
|
|
|
};
|
|
|
|
|
|
|
|
enum ExtraOption {
|
|
|
|
EXTRA_OPTION_FORCE_PUSH,
|
|
|
|
EXTRA_OPTION_CREATE_BRANCH,
|
|
|
|
EXTRA_OPTION_CREATE_REMOTE,
|
2019-09-03 16:28:32 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
private:
|
|
|
|
static VersionControlEditorPlugin *singleton;
|
|
|
|
|
2022-06-13 20:47:40 +02:00
|
|
|
List<StringName> available_plugins;
|
2019-09-03 16:28:32 +02:00
|
|
|
|
2022-04-04 15:06:57 +02:00
|
|
|
PopupMenu *version_control_actions = nullptr;
|
|
|
|
ConfirmationDialog *metadata_dialog = nullptr;
|
|
|
|
OptionButton *metadata_selection = nullptr;
|
|
|
|
AcceptDialog *set_up_dialog = nullptr;
|
2022-08-09 23:56:19 +02:00
|
|
|
CheckButton *toggle_vcs_choice = nullptr;
|
2022-04-04 15:06:57 +02:00
|
|
|
OptionButton *set_up_choice = nullptr;
|
2022-06-13 20:47:40 +02:00
|
|
|
VBoxContainer *set_up_vbc = nullptr;
|
|
|
|
VBoxContainer *set_up_settings_vbc = nullptr;
|
|
|
|
LineEdit *set_up_username = nullptr;
|
|
|
|
LineEdit *set_up_password = nullptr;
|
|
|
|
LineEdit *set_up_ssh_public_key_path = nullptr;
|
|
|
|
LineEdit *set_up_ssh_private_key_path = nullptr;
|
|
|
|
LineEdit *set_up_ssh_passphrase = nullptr;
|
|
|
|
FileDialog *set_up_ssh_public_key_file_dialog = nullptr;
|
|
|
|
FileDialog *set_up_ssh_private_key_file_dialog = nullptr;
|
|
|
|
Label *set_up_warning_text = nullptr;
|
|
|
|
|
2022-12-20 22:51:33 +01:00
|
|
|
AcceptDialog *discard_all_confirm = nullptr;
|
|
|
|
|
2022-06-13 20:47:40 +02:00
|
|
|
OptionButton *commit_list_size_button = nullptr;
|
|
|
|
|
|
|
|
AcceptDialog *branch_create_confirm = nullptr;
|
|
|
|
LineEdit *branch_create_name_input = nullptr;
|
|
|
|
Button *branch_create_ok = nullptr;
|
|
|
|
|
|
|
|
AcceptDialog *remote_create_confirm = nullptr;
|
|
|
|
LineEdit *remote_create_name_input = nullptr;
|
|
|
|
LineEdit *remote_create_url_input = nullptr;
|
|
|
|
Button *remote_create_ok = nullptr;
|
|
|
|
|
|
|
|
HashMap<EditorVCSInterface::ChangeType, String> change_type_to_strings;
|
|
|
|
HashMap<EditorVCSInterface::ChangeType, Color> change_type_to_color;
|
|
|
|
HashMap<EditorVCSInterface::ChangeType, Ref<Texture>> change_type_to_icon;
|
2019-09-03 16:28:32 +02:00
|
|
|
|
2022-04-04 15:06:57 +02:00
|
|
|
VBoxContainer *version_commit_dock = nullptr;
|
2022-06-13 20:47:40 +02:00
|
|
|
Tree *staged_files = nullptr;
|
|
|
|
Tree *unstaged_files = nullptr;
|
|
|
|
Tree *commit_list = nullptr;
|
|
|
|
|
|
|
|
OptionButton *branch_select = nullptr;
|
|
|
|
Button *branch_remove_button = nullptr;
|
|
|
|
AcceptDialog *branch_remove_confirm = nullptr;
|
|
|
|
|
|
|
|
Button *fetch_button = nullptr;
|
|
|
|
Button *pull_button = nullptr;
|
|
|
|
Button *push_button = nullptr;
|
|
|
|
OptionButton *remote_select = nullptr;
|
|
|
|
Button *remote_remove_button = nullptr;
|
|
|
|
AcceptDialog *remote_remove_confirm = nullptr;
|
|
|
|
MenuButton *extra_options = nullptr;
|
|
|
|
PopupMenu *extra_options_remove_branch_list = nullptr;
|
|
|
|
PopupMenu *extra_options_remove_remote_list = nullptr;
|
|
|
|
|
|
|
|
String branch_to_remove;
|
|
|
|
String remote_to_remove;
|
|
|
|
|
2022-04-04 15:06:57 +02:00
|
|
|
Button *stage_all_button = nullptr;
|
2022-06-13 20:47:40 +02:00
|
|
|
Button *unstage_all_button = nullptr;
|
|
|
|
Button *discard_all_button = nullptr;
|
2022-04-04 15:06:57 +02:00
|
|
|
Button *refresh_button = nullptr;
|
|
|
|
TextEdit *commit_message = nullptr;
|
|
|
|
Button *commit_button = nullptr;
|
2019-09-03 16:28:32 +02:00
|
|
|
|
2022-06-13 20:47:40 +02:00
|
|
|
VBoxContainer *version_control_dock = nullptr;
|
2022-04-04 15:06:57 +02:00
|
|
|
Button *version_control_dock_button = nullptr;
|
2022-06-13 20:47:40 +02:00
|
|
|
Label *diff_title = nullptr;
|
2022-04-04 15:06:57 +02:00
|
|
|
RichTextLabel *diff = nullptr;
|
2022-06-13 20:47:40 +02:00
|
|
|
OptionButton *diff_view_type_select = nullptr;
|
|
|
|
bool show_commit_diff_header = false;
|
|
|
|
List<EditorVCSInterface::DiffFile> diff_content;
|
2019-09-03 16:28:32 +02:00
|
|
|
|
2022-06-13 20:47:40 +02:00
|
|
|
void _notification(int p_what);
|
2019-09-03 16:28:32 +02:00
|
|
|
void _initialize_vcs();
|
2022-08-09 23:56:19 +02:00
|
|
|
void _set_vcs_ui_state(bool p_enabled);
|
2022-06-13 20:47:40 +02:00
|
|
|
void _set_credentials();
|
2024-02-15 17:25:58 +01:00
|
|
|
void _ssh_public_key_selected(const String &p_path);
|
|
|
|
void _ssh_private_key_selected(const String &p_path);
|
2022-06-13 20:47:40 +02:00
|
|
|
void _populate_available_vcs_names();
|
|
|
|
void _update_remotes_list();
|
2024-02-15 17:25:58 +01:00
|
|
|
void _update_set_up_warning(const String &p_new_text);
|
2022-06-13 20:47:40 +02:00
|
|
|
void _update_opened_tabs();
|
|
|
|
void _update_extra_options();
|
|
|
|
|
2024-02-15 17:25:58 +01:00
|
|
|
bool _load_plugin(const String &p_name);
|
2022-06-13 20:47:40 +02:00
|
|
|
|
|
|
|
void _pull();
|
|
|
|
void _push();
|
|
|
|
void _force_push();
|
|
|
|
void _fetch();
|
|
|
|
void _commit();
|
2022-12-20 22:51:33 +01:00
|
|
|
void _confirm_discard_all();
|
2022-06-13 20:47:40 +02:00
|
|
|
void _discard_all();
|
2019-09-03 16:28:32 +02:00
|
|
|
void _refresh_stage_area();
|
2022-06-13 20:47:40 +02:00
|
|
|
void _refresh_branch_list();
|
2022-07-31 15:25:19 +02:00
|
|
|
void _set_commit_list_size(int p_index);
|
|
|
|
void _refresh_commit_list();
|
2022-06-13 20:47:40 +02:00
|
|
|
void _refresh_remote_list();
|
|
|
|
void _display_diff(int p_idx);
|
|
|
|
void _move_all(Object *p_tree);
|
|
|
|
void _load_diff(Object *p_tree);
|
|
|
|
void _clear_diff();
|
|
|
|
int _get_item_count(Tree *p_tree);
|
|
|
|
void _item_activated(Object *p_tree);
|
|
|
|
void _create_branch();
|
|
|
|
void _create_remote();
|
2024-02-15 17:25:58 +01:00
|
|
|
void _update_branch_create_button(const String &p_new_text);
|
|
|
|
void _update_remote_create_button(const String &p_new_text);
|
2022-06-13 20:47:40 +02:00
|
|
|
void _branch_item_selected(int p_index);
|
|
|
|
void _remote_selected(int p_index);
|
|
|
|
void _remove_branch();
|
|
|
|
void _remove_remote();
|
|
|
|
void _popup_branch_remove_confirm(int p_index);
|
|
|
|
void _popup_remote_remove_confirm(int p_index);
|
|
|
|
void _move_item(Tree *p_tree, TreeItem *p_itme);
|
|
|
|
void _display_diff_split_view(List<EditorVCSInterface::DiffLine> &p_diff_content);
|
|
|
|
void _display_diff_unified_view(List<EditorVCSInterface::DiffLine> &p_diff_content);
|
2024-02-15 17:25:58 +01:00
|
|
|
void _discard_file(const String &p_file_path, EditorVCSInterface::ChangeType p_change);
|
2022-06-13 20:47:40 +02:00
|
|
|
void _cell_button_pressed(Object *p_item, int p_column, int p_id, int p_mouse_button_index);
|
2024-02-15 17:25:58 +01:00
|
|
|
void _add_new_item(Tree *p_tree, const String &p_file_path, EditorVCSInterface::ChangeType p_change);
|
2020-12-20 17:43:50 +01:00
|
|
|
void _update_commit_button();
|
2021-07-13 19:04:47 +02:00
|
|
|
void _commit_message_gui_input(const Ref<InputEvent> &p_event);
|
2022-06-13 20:47:40 +02:00
|
|
|
void _extra_option_selected(int p_index);
|
|
|
|
bool _is_staging_area_empty();
|
|
|
|
String _get_date_string_from(int64_t p_unix_timestamp, int64_t p_offset_minutes) const;
|
|
|
|
void _create_vcs_metadata_files();
|
2024-02-15 17:25:58 +01:00
|
|
|
void _popup_file_dialog(const Variant &p_file_dialog_variant);
|
2022-08-09 23:56:19 +02:00
|
|
|
void _toggle_vcs_integration(bool p_toggled);
|
2019-09-03 16:28:32 +02:00
|
|
|
|
|
|
|
friend class EditorVCSInterface;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
static void _bind_methods();
|
|
|
|
|
|
|
|
public:
|
|
|
|
static VersionControlEditorPlugin *get_singleton();
|
|
|
|
|
2020-09-29 21:01:26 +02:00
|
|
|
void popup_vcs_metadata_dialog();
|
2019-09-03 16:28:32 +02:00
|
|
|
void popup_vcs_set_up_dialog(const Control *p_gui_base);
|
|
|
|
|
|
|
|
PopupMenu *get_version_control_actions_panel() const { return version_control_actions; }
|
|
|
|
|
|
|
|
void register_editor();
|
2022-06-13 20:47:40 +02:00
|
|
|
void fetch_available_vcs_plugin_names();
|
2019-09-03 16:28:32 +02:00
|
|
|
void shut_down();
|
|
|
|
|
|
|
|
VersionControlEditorPlugin();
|
|
|
|
~VersionControlEditorPlugin();
|
|
|
|
};
|
|
|
|
|
2022-08-09 23:56:19 +02:00
|
|
|
#endif // VERSION_CONTROL_EDITOR_PLUGIN_H
|