Path: blob/master/editor/script/script_create_dialog.h
9903 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;65VBoxContainer *path_vb = nullptr;66AcceptDialog *alert = nullptr;67CreateDialog *select_class = nullptr;6869bool is_browsing_parent = false;70String path_error;71String template_inactive_message;72bool is_new_script_created = true;73bool is_path_valid = false;74bool supports_built_in = false;75bool can_inherit_from_file = false;76bool is_parent_name_valid = false;77bool is_class_name_valid = false;78bool is_built_in = false;79bool is_using_templates = true;80bool built_in_enabled = true;81bool load_enabled = true;82int default_language;83bool re_check_path = false;8485Control *path_controls[2];86Control *name_controls[2];8788Vector<ScriptLanguage::ScriptTemplate> template_list;89ScriptLanguage *language = nullptr;9091String base_type;9293void _path_hbox_sorted();94bool _can_be_built_in();95void _path_changed(const String &p_path = String());96void _language_changed(int l = 0);97void _built_in_pressed();98void _use_template_pressed();99bool _validate_parent(const String &p_string);100String _validate_path(const String &p_path, bool p_file_must_exist, bool *r_path_valid = nullptr);101void _parent_name_changed(const String &p_parent);102void _template_changed(int p_template = 0);103void _browse_path(bool browse_parent, bool p_save);104void _file_selected(const String &p_file);105void _create();106void _browse_class_in_tree();107virtual void ok_pressed() override;108void _create_new();109void _load_exist();110void _update_template_menu();111void _update_dialog();112ScriptLanguage::ScriptTemplate _get_current_template() const;113Vector<ScriptLanguage::ScriptTemplate> _get_user_templates(const ScriptLanguage *p_language, const StringName &p_object, const String &p_dir, const ScriptLanguage::TemplateLocation &p_origin) const;114ScriptLanguage::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;115String _get_script_origin_label(const ScriptLanguage::TemplateLocation &p_origin) const;116String _adjust_file_path(const String &p_base_path) const;117118protected:119void _notification(int p_what);120static void _bind_methods();121122public:123void config(const String &p_base_name, const String &p_base_path, bool p_built_in_enabled = true, bool p_load_enabled = true);124void set_inheritance_base_type(const String &p_base);125ScriptCreateDialog();126};127128129