Path: blob/master/editor/project_manager/project_dialog.h
9896 views
/**************************************************************************/1/* project_dialog.h */2/**************************************************************************/3/* This file is part of: */4/* GODOT ENGINE */5/* https://godotengine.org */6/**************************************************************************/7/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */8/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */9/* */10/* Permission is hereby granted, free of charge, to any person obtaining */11/* a copy of this software and associated documentation files (the */12/* "Software"), to deal in the Software without restriction, including */13/* without limitation the rights to use, copy, modify, merge, publish, */14/* distribute, sublicense, and/or sell copies of the Software, and to */15/* permit persons to whom the Software is furnished to do so, subject to */16/* the following conditions: */17/* */18/* The above copyright notice and this permission notice shall be */19/* included in all copies or substantial portions of the Software. */20/* */21/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */22/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */23/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */24/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */25/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */26/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */27/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */28/**************************************************************************/2930#pragma once3132#include "scene/gui/dialogs.h"3334class Button;35class CheckBox;36class CheckButton;37class EditorFileDialog;38class LineEdit;39class OptionButton;40class TextureRect;4142class ProjectDialog : public ConfirmationDialog {43GDCLASS(ProjectDialog, ConfirmationDialog);4445public:46enum Mode {47MODE_NEW,48MODE_IMPORT,49MODE_INSTALL,50MODE_RENAME,51MODE_DUPLICATE,52};5354private:55enum MessageType {56MESSAGE_ERROR,57MESSAGE_WARNING,58MESSAGE_SUCCESS,59};6061enum InputType {62PROJECT_PATH,63INSTALL_PATH,64};6566Mode mode = MODE_NEW;67bool is_folder_empty = true;68ConfirmationDialog *nonempty_confirmation = nullptr;6970CheckButton *create_dir = nullptr;71Button *project_browse = nullptr;72Button *install_browse = nullptr;73VBoxContainer *name_container = nullptr;74VBoxContainer *project_path_container = nullptr;75VBoxContainer *install_path_container = nullptr;7677VBoxContainer *renderer_container = nullptr;78Label *renderer_info = nullptr;79HBoxContainer *default_files_container = nullptr;80Ref<ButtonGroup> renderer_button_group;81bool rendering_device_supported = false;82Label *rd_not_supported = nullptr;8384Label *msg = nullptr;85LineEdit *project_name = nullptr;86LineEdit *project_path = nullptr;87LineEdit *install_path = nullptr;88TextureRect *project_status_rect = nullptr;89TextureRect *install_status_rect = nullptr;9091OptionButton *vcs_metadata_selection = nullptr;9293CheckBox *edit_check_box = nullptr;9495EditorFileDialog *fdialog_project = nullptr;96EditorFileDialog *fdialog_install = nullptr;97AcceptDialog *dialog_error = nullptr;9899String zip_path;100String zip_title;101102String original_project_path;103bool duplicate_can_edit = false;104105void _set_message(const String &p_msg, MessageType p_type, InputType input_type = PROJECT_PATH);106void _validate_path();107108// Project path for MODE_NEW and MODE_INSTALL. Install path for MODE_IMPORT.109// Install path is only visible when importing a ZIP.110String _get_target_path();111void _set_target_path(const String &p_text);112113// Calculated from project name / ZIP name.114String auto_dir;115116// Updates `auto_dir`. If the target path dir name is equal to `auto_dir` (the default state), the target path is also updated.117void _update_target_auto_dir();118119// While `create_dir` is disabled, stores the last target path dir name, or an empty string if equal to `auto_dir`.120String last_custom_target_dir;121void _create_dir_toggled(bool p_pressed);122123void _project_name_changed();124void _project_path_changed();125void _install_path_changed();126127void _browse_project_path();128void _browse_install_path();129130void _project_path_selected(const String &p_path);131void _install_path_selected(const String &p_path);132133void _reset_name();134void _renderer_selected();135void _nonempty_confirmation_ok_pressed();136137void ok_pressed() override;138139protected:140static void _bind_methods();141void _notification(int p_what);142143public:144void set_mode(Mode p_mode);145void set_project_name(const String &p_name);146void set_project_path(const String &p_path);147void set_zip_path(const String &p_path);148void set_zip_title(const String &p_title);149void set_original_project_path(const String &p_path);150void set_duplicate_can_edit(bool p_duplicate_can_edit);151152void ask_for_path_and_show();153void show_dialog(bool p_reset_name = true);154155ProjectDialog();156};157158159