Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
godotengine
GitHub Repository: godotengine/godot
Path: blob/master/editor/project_manager/project_dialog.h
9896 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
Mode mode = MODE_NEW;
68
bool is_folder_empty = true;
69
ConfirmationDialog *nonempty_confirmation = nullptr;
70
71
CheckButton *create_dir = nullptr;
72
Button *project_browse = nullptr;
73
Button *install_browse = nullptr;
74
VBoxContainer *name_container = nullptr;
75
VBoxContainer *project_path_container = nullptr;
76
VBoxContainer *install_path_container = nullptr;
77
78
VBoxContainer *renderer_container = nullptr;
79
Label *renderer_info = nullptr;
80
HBoxContainer *default_files_container = nullptr;
81
Ref<ButtonGroup> renderer_button_group;
82
bool rendering_device_supported = false;
83
Label *rd_not_supported = nullptr;
84
85
Label *msg = nullptr;
86
LineEdit *project_name = nullptr;
87
LineEdit *project_path = nullptr;
88
LineEdit *install_path = nullptr;
89
TextureRect *project_status_rect = nullptr;
90
TextureRect *install_status_rect = nullptr;
91
92
OptionButton *vcs_metadata_selection = nullptr;
93
94
CheckBox *edit_check_box = nullptr;
95
96
EditorFileDialog *fdialog_project = nullptr;
97
EditorFileDialog *fdialog_install = nullptr;
98
AcceptDialog *dialog_error = nullptr;
99
100
String zip_path;
101
String zip_title;
102
103
String original_project_path;
104
bool duplicate_can_edit = false;
105
106
void _set_message(const String &p_msg, MessageType p_type, InputType input_type = PROJECT_PATH);
107
void _validate_path();
108
109
// Project path for MODE_NEW and MODE_INSTALL. Install path for MODE_IMPORT.
110
// Install path is only visible when importing a ZIP.
111
String _get_target_path();
112
void _set_target_path(const String &p_text);
113
114
// Calculated from project name / ZIP name.
115
String auto_dir;
116
117
// Updates `auto_dir`. If the target path dir name is equal to `auto_dir` (the default state), the target path is also updated.
118
void _update_target_auto_dir();
119
120
// While `create_dir` is disabled, stores the last target path dir name, or an empty string if equal to `auto_dir`.
121
String last_custom_target_dir;
122
void _create_dir_toggled(bool p_pressed);
123
124
void _project_name_changed();
125
void _project_path_changed();
126
void _install_path_changed();
127
128
void _browse_project_path();
129
void _browse_install_path();
130
131
void _project_path_selected(const String &p_path);
132
void _install_path_selected(const String &p_path);
133
134
void _reset_name();
135
void _renderer_selected();
136
void _nonempty_confirmation_ok_pressed();
137
138
void ok_pressed() override;
139
140
protected:
141
static void _bind_methods();
142
void _notification(int p_what);
143
144
public:
145
void set_mode(Mode p_mode);
146
void set_project_name(const String &p_name);
147
void set_project_path(const String &p_path);
148
void set_zip_path(const String &p_path);
149
void set_zip_title(const String &p_title);
150
void set_original_project_path(const String &p_path);
151
void set_duplicate_can_edit(bool p_duplicate_can_edit);
152
153
void ask_for_path_and_show();
154
void show_dialog(bool p_reset_name = true);
155
156
ProjectDialog();
157
};
158
159