Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
godotengine
GitHub Repository: godotengine/godot
Path: blob/master/editor/project_manager/project_dialog.h
21318 views
1
/**************************************************************************/
2
/* project_dialog.h */
3
/**************************************************************************/
4
/* This file is part of: */
5
/* GODOT ENGINE */
6
/* https://godotengine.org */
7
/**************************************************************************/
8
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
9
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
10
/* */
11
/* Permission is hereby granted, free of charge, to any person obtaining */
12
/* a copy of this software and associated documentation files (the */
13
/* "Software"), to deal in the Software without restriction, including */
14
/* without limitation the rights to use, copy, modify, merge, publish, */
15
/* distribute, sublicense, and/or sell copies of the Software, and to */
16
/* permit persons to whom the Software is furnished to do so, subject to */
17
/* the following conditions: */
18
/* */
19
/* The above copyright notice and this permission notice shall be */
20
/* included in all copies or substantial portions of the Software. */
21
/* */
22
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
23
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
24
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
25
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
26
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
27
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
28
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
29
/**************************************************************************/
30
31
#pragma once
32
33
#include "scene/gui/dialogs.h"
34
35
class Button;
36
class CheckBox;
37
class CheckButton;
38
class EditorFileDialog;
39
class LineEdit;
40
class OptionButton;
41
class TextureRect;
42
43
class ProjectDialog : public ConfirmationDialog {
44
GDCLASS(ProjectDialog, ConfirmationDialog);
45
46
public:
47
enum Mode {
48
MODE_NEW,
49
MODE_IMPORT,
50
MODE_INSTALL,
51
MODE_RENAME,
52
MODE_DUPLICATE,
53
};
54
55
private:
56
enum MessageType {
57
MESSAGE_ERROR,
58
MESSAGE_WARNING,
59
MESSAGE_SUCCESS,
60
};
61
62
enum InputType {
63
PROJECT_PATH,
64
INSTALL_PATH,
65
};
66
67
enum InvalidStateFlag {
68
INVALID_STATE_FLAG_NONE = 0,
69
INVALID_STATE_FLAG_PATH_INPUT = 1 << 0,
70
INVALID_STATE_FLAG_RENDERER_SELECT = 1 << 1,
71
};
72
73
Mode mode = MODE_NEW;
74
bool is_folder_empty = true;
75
ConfirmationDialog *nonempty_confirmation = nullptr;
76
77
CheckButton *create_dir = nullptr;
78
Button *project_browse = nullptr;
79
Button *install_browse = nullptr;
80
VBoxContainer *name_container = nullptr;
81
VBoxContainer *project_path_container = nullptr;
82
VBoxContainer *install_path_container = nullptr;
83
84
VBoxContainer *renderer_container = nullptr;
85
Label *renderer_info = nullptr;
86
HBoxContainer *default_files_container = nullptr;
87
Ref<ButtonGroup> renderer_button_group;
88
bool rendering_device_supported = false;
89
bool rendering_device_checked = false;
90
Label *rd_not_supported = nullptr;
91
92
Label *msg = nullptr;
93
LineEdit *project_name = nullptr;
94
LineEdit *project_path = nullptr;
95
LineEdit *install_path = nullptr;
96
TextureRect *project_status_rect = nullptr;
97
TextureRect *install_status_rect = nullptr;
98
99
OptionButton *vcs_metadata_selection = nullptr;
100
101
CheckBox *edit_check_box = nullptr;
102
103
EditorFileDialog *fdialog_project = nullptr;
104
EditorFileDialog *fdialog_install = nullptr;
105
AcceptDialog *dialog_error = nullptr;
106
107
String zip_path;
108
String zip_title;
109
110
String original_project_path;
111
bool duplicate_can_edit = false;
112
113
BitField<InvalidStateFlag> invalid_state_flags = INVALID_STATE_FLAG_NONE;
114
115
void _set_message(const String &p_msg, MessageType p_type, InputType input_type = PROJECT_PATH);
116
void _update_ok_button();
117
void _validate_path();
118
119
// Project path for MODE_NEW and MODE_INSTALL. Install path for MODE_IMPORT.
120
// Install path is only visible when importing a ZIP.
121
String _get_target_path();
122
void _set_target_path(const String &p_text);
123
124
// Calculated from project name / ZIP name.
125
String auto_dir;
126
127
// Updates `auto_dir`. If the target path dir name is equal to `auto_dir` (the default state), the target path is also updated.
128
void _update_target_auto_dir();
129
130
// While `create_dir` is disabled, stores the last target path dir name, or an empty string if equal to `auto_dir`.
131
String last_custom_target_dir;
132
void _create_dir_toggled(bool p_pressed);
133
134
void _project_name_changed();
135
void _project_path_changed();
136
void _install_path_changed();
137
138
void _browse_project_path();
139
void _browse_install_path();
140
141
void _project_path_selected(const String &p_path);
142
void _install_path_selected(const String &p_path);
143
144
void _reset_name();
145
void _renderer_selected();
146
void _nonempty_confirmation_ok_pressed();
147
148
void ok_pressed() override;
149
150
protected:
151
static void _bind_methods();
152
void _notification(int p_what);
153
154
public:
155
void set_mode(Mode p_mode);
156
void set_project_name(const String &p_name);
157
void set_project_path(const String &p_path);
158
void set_zip_path(const String &p_path);
159
void set_zip_title(const String &p_title);
160
void set_original_project_path(const String &p_path);
161
void set_duplicate_can_edit(bool p_duplicate_can_edit);
162
163
void ask_for_path_and_show();
164
void show_dialog(bool p_reset_name = true, bool p_is_confirmed = true);
165
166
ProjectDialog();
167
};
168
169