Path: blob/master/editor/settings/editor_autoload_settings.h
9898 views
/**************************************************************************/1/* editor_autoload_settings.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/box_container.h"33#include "scene/gui/button.h"34#include "scene/gui/tree.h"3536class EditorFileDialog;3738class EditorAutoloadSettings : public VBoxContainer {39GDCLASS(EditorAutoloadSettings, VBoxContainer);4041enum {42BUTTON_OPEN,43BUTTON_MOVE_UP,44BUTTON_MOVE_DOWN,45BUTTON_DELETE46};4748String path = "res://";49String autoload_changed = "autoload_changed";5051struct AutoloadInfo {52String name;53String path;54bool is_singleton = false;55bool in_editor = false;56int order = 0;57Node *node = nullptr;5859bool operator==(const AutoloadInfo &p_info) const {60return order == p_info.order;61}62};6364List<AutoloadInfo> autoload_cache;6566bool updating_autoload = false;67String selected_autoload;6869Tree *tree = nullptr;70LineEdit *autoload_add_name = nullptr;71Button *add_autoload = nullptr;72LineEdit *autoload_add_path = nullptr;73Label *error_message = nullptr;74Button *browse_button = nullptr;75EditorFileDialog *file_dialog = nullptr;7677bool _autoload_name_is_valid(const String &p_name, String *r_error = nullptr);7879void _autoload_add();80void _autoload_selected();81void _autoload_edited();82void _autoload_button_pressed(Object *p_item, int p_column, int p_button, MouseButton p_mouse_button);83void _autoload_activated();84void _autoload_path_text_changed(const String &p_path);85void _autoload_text_submitted(const String &p_name);86void _autoload_text_changed(const String &p_name);87void _autoload_open(const String &fpath);88void _autoload_file_callback(const String &p_path);89Node *_create_autoload(const String &p_path);9091void _script_created(Ref<Script> p_script);9293Variant get_drag_data_fw(const Point2 &p_point, Control *p_control);94bool can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_control) const;95void drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_control);9697void _set_autoload_add_path(const String &p_text);98void _browse_autoload_add_path();99100protected:101void _notification(int p_what);102static void _bind_methods();103104public:105void init_autoloads();106void update_autoload();107bool autoload_add(const String &p_name, const String &p_path);108void autoload_remove(const String &p_name);109110LineEdit *get_path_box() const;111112EditorAutoloadSettings();113~EditorAutoloadSettings();114};115116117