Path: blob/master/editor/project_manager/project_dialog.h
21318 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};6566enum InvalidStateFlag {67INVALID_STATE_FLAG_NONE = 0,68INVALID_STATE_FLAG_PATH_INPUT = 1 << 0,69INVALID_STATE_FLAG_RENDERER_SELECT = 1 << 1,70};7172Mode mode = MODE_NEW;73bool is_folder_empty = true;74ConfirmationDialog *nonempty_confirmation = nullptr;7576CheckButton *create_dir = nullptr;77Button *project_browse = nullptr;78Button *install_browse = nullptr;79VBoxContainer *name_container = nullptr;80VBoxContainer *project_path_container = nullptr;81VBoxContainer *install_path_container = nullptr;8283VBoxContainer *renderer_container = nullptr;84Label *renderer_info = nullptr;85HBoxContainer *default_files_container = nullptr;86Ref<ButtonGroup> renderer_button_group;87bool rendering_device_supported = false;88bool rendering_device_checked = false;89Label *rd_not_supported = nullptr;9091Label *msg = nullptr;92LineEdit *project_name = nullptr;93LineEdit *project_path = nullptr;94LineEdit *install_path = nullptr;95TextureRect *project_status_rect = nullptr;96TextureRect *install_status_rect = nullptr;9798OptionButton *vcs_metadata_selection = nullptr;99100CheckBox *edit_check_box = nullptr;101102EditorFileDialog *fdialog_project = nullptr;103EditorFileDialog *fdialog_install = nullptr;104AcceptDialog *dialog_error = nullptr;105106String zip_path;107String zip_title;108109String original_project_path;110bool duplicate_can_edit = false;111112BitField<InvalidStateFlag> invalid_state_flags = INVALID_STATE_FLAG_NONE;113114void _set_message(const String &p_msg, MessageType p_type, InputType input_type = PROJECT_PATH);115void _update_ok_button();116void _validate_path();117118// Project path for MODE_NEW and MODE_INSTALL. Install path for MODE_IMPORT.119// Install path is only visible when importing a ZIP.120String _get_target_path();121void _set_target_path(const String &p_text);122123// Calculated from project name / ZIP name.124String auto_dir;125126// Updates `auto_dir`. If the target path dir name is equal to `auto_dir` (the default state), the target path is also updated.127void _update_target_auto_dir();128129// While `create_dir` is disabled, stores the last target path dir name, or an empty string if equal to `auto_dir`.130String last_custom_target_dir;131void _create_dir_toggled(bool p_pressed);132133void _project_name_changed();134void _project_path_changed();135void _install_path_changed();136137void _browse_project_path();138void _browse_install_path();139140void _project_path_selected(const String &p_path);141void _install_path_selected(const String &p_path);142143void _reset_name();144void _renderer_selected();145void _nonempty_confirmation_ok_pressed();146147void ok_pressed() override;148149protected:150static void _bind_methods();151void _notification(int p_what);152153public:154void set_mode(Mode p_mode);155void set_project_name(const String &p_name);156void set_project_path(const String &p_path);157void set_zip_path(const String &p_path);158void set_zip_title(const String &p_title);159void set_original_project_path(const String &p_path);160void set_duplicate_can_edit(bool p_duplicate_can_edit);161162void ask_for_path_and_show();163void show_dialog(bool p_reset_name = true, bool p_is_confirmed = true);164165ProjectDialog();166};167168169