2019-09-04 13:17:26 +02:00
|
|
|
/*************************************************************************/
|
|
|
|
/* version_control_editor_plugin.h */
|
|
|
|
/*************************************************************************/
|
|
|
|
/* This file is part of: */
|
|
|
|
/* GODOT ENGINE */
|
|
|
|
/* https://godotengine.org */
|
|
|
|
/*************************************************************************/
|
2022-01-03 21:27:34 +01:00
|
|
|
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
|
|
|
|
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
|
2019-09-04 13:17:26 +02:00
|
|
|
/* */
|
|
|
|
/* 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-02-12 02:46:22 +01:00
|
|
|
#include "scene/gui/box_container.h"
|
2019-09-03 16:28:32 +02:00
|
|
|
#include "scene/gui/rich_text_label.h"
|
2022-02-12 02:46:22 +01:00
|
|
|
#include "scene/gui/split_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:
|
|
|
|
enum ChangeType {
|
|
|
|
CHANGE_TYPE_NEW = 0,
|
|
|
|
CHANGE_TYPE_MODIFIED = 1,
|
|
|
|
CHANGE_TYPE_RENAMED = 2,
|
|
|
|
CHANGE_TYPE_DELETED = 3,
|
|
|
|
CHANGE_TYPE_TYPECHANGE = 4
|
|
|
|
};
|
|
|
|
|
|
|
|
private:
|
|
|
|
static VersionControlEditorPlugin *singleton;
|
|
|
|
|
|
|
|
int staged_files_count;
|
|
|
|
List<StringName> available_addons;
|
|
|
|
|
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;
|
|
|
|
VBoxContainer *set_up_vbc = nullptr;
|
|
|
|
HBoxContainer *set_up_hbc = nullptr;
|
|
|
|
Label *set_up_vcs_label = nullptr;
|
|
|
|
OptionButton *set_up_choice = nullptr;
|
|
|
|
PanelContainer *set_up_init_settings = nullptr;
|
|
|
|
Button *set_up_init_button = nullptr;
|
|
|
|
RichTextLabel *set_up_vcs_status = nullptr;
|
|
|
|
Button *set_up_ok_button = nullptr;
|
2019-09-03 16:28:32 +02:00
|
|
|
|
|
|
|
HashMap<ChangeType, String> change_type_to_strings;
|
|
|
|
HashMap<ChangeType, Color> change_type_to_color;
|
|
|
|
|
2022-04-04 15:06:57 +02:00
|
|
|
VBoxContainer *version_commit_dock = nullptr;
|
|
|
|
VBoxContainer *commit_box_vbc = nullptr;
|
|
|
|
HSplitContainer *stage_tools = nullptr;
|
|
|
|
Tree *stage_files = nullptr;
|
|
|
|
TreeItem *new_files = nullptr;
|
|
|
|
TreeItem *modified_files = nullptr;
|
|
|
|
TreeItem *renamed_files = nullptr;
|
|
|
|
TreeItem *deleted_files = nullptr;
|
|
|
|
TreeItem *typechange_files = nullptr;
|
|
|
|
Label *staging_area_label = nullptr;
|
|
|
|
HSplitContainer *stage_buttons = nullptr;
|
|
|
|
Button *stage_all_button = nullptr;
|
|
|
|
Button *stage_selected_button = nullptr;
|
|
|
|
Button *refresh_button = nullptr;
|
|
|
|
TextEdit *commit_message = nullptr;
|
|
|
|
Button *commit_button = nullptr;
|
|
|
|
Label *commit_status = nullptr;
|
2019-09-03 16:28:32 +02:00
|
|
|
|
2022-04-04 15:06:57 +02:00
|
|
|
PanelContainer *version_control_dock = nullptr;
|
|
|
|
Button *version_control_dock_button = nullptr;
|
|
|
|
VBoxContainer *diff_vbc = nullptr;
|
|
|
|
HBoxContainer *diff_hbc = nullptr;
|
|
|
|
Button *diff_refresh_button = nullptr;
|
|
|
|
Label *diff_file_name = nullptr;
|
|
|
|
Label *diff_heading = nullptr;
|
|
|
|
RichTextLabel *diff = nullptr;
|
2019-09-03 16:28:32 +02:00
|
|
|
|
|
|
|
void _populate_available_vcs_names();
|
2020-09-29 21:01:26 +02:00
|
|
|
void _create_vcs_metadata_files();
|
2019-09-03 16:28:32 +02:00
|
|
|
void _selected_a_vcs(int p_id);
|
|
|
|
void _initialize_vcs();
|
|
|
|
void _send_commit_msg();
|
|
|
|
void _refresh_stage_area();
|
|
|
|
void _stage_selected();
|
|
|
|
void _stage_all();
|
|
|
|
void _view_file_diff();
|
|
|
|
void _display_file_diff(String p_file_path);
|
|
|
|
void _refresh_file_diff();
|
|
|
|
void _clear_file_diff();
|
|
|
|
void _update_stage_status();
|
|
|
|
void _update_commit_status();
|
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);
|
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);
|
2020-06-19 20:49:04 +02:00
|
|
|
void set_version_control_tool_button(Button *p_button) { version_control_dock_button = p_button; }
|
2019-09-03 16:28:32 +02:00
|
|
|
|
|
|
|
PopupMenu *get_version_control_actions_panel() const { return version_control_actions; }
|
|
|
|
VBoxContainer *get_version_commit_dock() const { return version_commit_dock; }
|
|
|
|
PanelContainer *get_version_control_dock() const { return version_control_dock; }
|
|
|
|
|
|
|
|
List<StringName> get_available_vcs_names() const { return available_addons; }
|
2019-11-19 15:11:03 +01:00
|
|
|
bool is_vcs_initialized() const;
|
2019-09-03 16:28:32 +02:00
|
|
|
const String get_vcs_name() const;
|
|
|
|
|
|
|
|
void register_editor();
|
|
|
|
void fetch_available_vcs_addon_names();
|
|
|
|
void clear_stage_area();
|
|
|
|
void shut_down();
|
|
|
|
|
|
|
|
VersionControlEditorPlugin();
|
|
|
|
~VersionControlEditorPlugin();
|
|
|
|
};
|
|
|
|
|
|
|
|
VARIANT_ENUM_CAST(VersionControlEditorPlugin::ChangeType);
|
|
|
|
|
2022-07-23 23:41:51 +02:00
|
|
|
#endif // VERSION_CONTROL_EDITOR_PLUGIN_H
|