Path: blob/master/editor/script/script_create_dialog.h
20873 views
/**************************************************************************/1/* script_create_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 "core/object/script_language.h"33#include "scene/gui/check_box.h"34#include "scene/gui/dialogs.h"35#include "scene/gui/option_button.h"36#include "scene/gui/panel_container.h"3738class CreateDialog;39class EditorFileDialog;40class EditorValidationPanel;41class LineEdit;4243class ScriptCreateDialog : public ConfirmationDialog {44GDCLASS(ScriptCreateDialog, ConfirmationDialog);4546enum {47MSG_ID_SCRIPT,48MSG_ID_PATH,49MSG_ID_BUILT_IN,50MSG_ID_TEMPLATE,51};5253EditorValidationPanel *validation_panel = nullptr;54LineEdit *parent_name = nullptr;55Button *parent_browse_button = nullptr;56Button *parent_search_button = nullptr;57OptionButton *language_menu = nullptr;58OptionButton *template_menu = nullptr;59LineEdit *file_path = nullptr;60LineEdit *built_in_name = nullptr;61Button *path_button = nullptr;62EditorFileDialog *file_browse = nullptr;63CheckBox *built_in = nullptr;64CheckBox *use_templates = nullptr;65AcceptDialog *alert = nullptr;66CreateDialog *select_class = nullptr;6768bool is_browsing_parent = false;69String path_error;70String template_inactive_message;71bool is_new_script_created = true;72bool is_path_valid = false;73bool supports_built_in = false;74bool can_inherit_from_file = false;75bool is_parent_name_valid = false;76bool is_built_in = false;77bool is_using_templates = true;78bool built_in_enabled = true;79bool load_enabled = true;80int default_language;81bool re_check_path = false;8283Control *path_controls[2];84Control *name_controls[2];8586Vector<ScriptLanguage::ScriptTemplate> template_list;87ScriptLanguage *language = nullptr;8889String base_type;9091void _path_hbox_sorted();92bool _can_be_built_in();93void _path_changed(const String &p_path = String());94void _language_changed(int l = 0);95void _built_in_pressed();96void _use_template_pressed();97bool _validate_parent(const String &p_string);98String _validate_path(const String &p_path, bool p_file_must_exist, bool *r_path_valid = nullptr);99void _parent_name_changed(const String &p_parent);100void _template_changed(int p_template = 0);101void _browse_path(bool browse_parent, bool p_save);102void _file_selected(const String &p_file);103void _create();104void _browse_class_in_tree();105virtual void ok_pressed() override;106void _create_new();107void _load_exist();108void _update_template_menu();109void _update_dialog();110ScriptLanguage::ScriptTemplate _get_current_template() const;111Vector<ScriptLanguage::ScriptTemplate> _get_user_templates(const ScriptLanguage *p_language, const StringName &p_object, const String &p_dir, const ScriptLanguage::TemplateLocation &p_origin) const;112ScriptLanguage::ScriptTemplate _parse_template(const ScriptLanguage *p_language, const String &p_path, const String &p_filename, const ScriptLanguage::TemplateLocation &p_origin, const String &p_inherits) const;113String _get_script_origin_label(const ScriptLanguage::TemplateLocation &p_origin) const;114String _adjust_file_path(const String &p_base_path) const;115116protected:117void _notification(int p_what);118static void _bind_methods();119120public:121void config(const String &p_base_name, const String &p_base_path, bool p_built_in_enabled = true, bool p_load_enabled = true);122void set_inheritance_base_type(const String &p_base);123ScriptCreateDialog();124};125126127