Path: blob/master/editor/settings/editor_feature_profile.h
9896 views
/**************************************************************************/1/* editor_feature_profile.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/ref_counted.h"33#include "editor/doc/editor_help.h"34#include "scene/gui/dialogs.h"35#include "scene/gui/option_button.h"36#include "scene/gui/split_container.h"37#include "scene/gui/tree.h"3839class EditorFileDialog;4041class EditorFeatureProfile : public RefCounted {42GDCLASS(EditorFeatureProfile, RefCounted);4344public:45enum Feature {46FEATURE_3D,47FEATURE_SCRIPT,48FEATURE_ASSET_LIB,49FEATURE_SCENE_TREE,50FEATURE_NODE_DOCK,51FEATURE_FILESYSTEM_DOCK,52FEATURE_IMPORT_DOCK,53FEATURE_HISTORY_DOCK,54FEATURE_GAME,55FEATURE_MAX56};5758private:59HashSet<StringName> disabled_classes;60HashSet<StringName> disabled_editors;61HashMap<StringName, HashSet<StringName>> disabled_properties;6263HashSet<StringName> collapsed_classes;6465bool features_disabled[FEATURE_MAX];66static const char *feature_names[FEATURE_MAX];67static const char *feature_descriptions[FEATURE_MAX];68static const char *feature_identifiers[FEATURE_MAX];6970String _get_feature_name(Feature p_feature) { return get_feature_name(p_feature); }7172protected:73static void _bind_methods();7475public:76void set_disable_class(const StringName &p_class, bool p_disabled);77bool is_class_disabled(const StringName &p_class) const;7879void set_disable_class_editor(const StringName &p_class, bool p_disabled);80bool is_class_editor_disabled(const StringName &p_class) const;8182void set_disable_class_property(const StringName &p_class, const StringName &p_property, bool p_disabled);83bool is_class_property_disabled(const StringName &p_class, const StringName &p_property) const;84bool has_class_properties_disabled(const StringName &p_class) const;8586void set_item_collapsed(const StringName &p_class, bool p_collapsed);87bool is_item_collapsed(const StringName &p_class) const;8889void set_disable_feature(Feature p_feature, bool p_disable);90bool is_feature_disabled(Feature p_feature) const;9192Error save_to_file(const String &p_path);93Error load_from_file(const String &p_path);9495static String get_feature_name(Feature p_feature);96static String get_feature_description(Feature p_feature);9798EditorFeatureProfile();99};100101VARIANT_ENUM_CAST(EditorFeatureProfile::Feature)102103class EditorFeatureProfileManager : public AcceptDialog {104GDCLASS(EditorFeatureProfileManager, AcceptDialog);105106enum Action {107PROFILE_CLEAR,108PROFILE_SET,109PROFILE_IMPORT,110PROFILE_EXPORT,111PROFILE_NEW,112PROFILE_ERASE,113PROFILE_MAX114};115116enum ClassOptions {117CLASS_OPTION_DISABLE_EDITOR118};119120ConfirmationDialog *erase_profile_dialog = nullptr;121ConfirmationDialog *new_profile_dialog = nullptr;122LineEdit *new_profile_name = nullptr;123124LineEdit *current_profile_name = nullptr;125OptionButton *profile_list = nullptr;126Button *profile_actions[PROFILE_MAX];127128HSplitContainer *h_split = nullptr;129130VBoxContainer *class_list_vbc = nullptr;131Tree *class_list = nullptr;132VBoxContainer *property_list_vbc = nullptr;133Tree *property_list = nullptr;134EditorHelpBit *description_bit = nullptr;135Label *no_profile_selected_help = nullptr;136137EditorFileDialog *import_profiles = nullptr;138EditorFileDialog *export_profile = nullptr;139140void _profile_action(int p_action);141void _profile_selected(int p_what);142void _hide_requested();143144String current_profile;145void _update_profile_list(const String &p_select_profile = String());146void _update_selected_profile();147void _update_profile_tree_from(TreeItem *p_edited);148void _fill_classes_from(TreeItem *p_parent, const String &p_class, const String &p_selected, int p_class_insert_index = -1);149150Ref<EditorFeatureProfile> current;151Ref<EditorFeatureProfile> edited;152153void _erase_selected_profile();154void _create_new_profile();155String _get_selected_profile();156157void _import_profiles(const Vector<String> &p_paths);158void _export_profile(const String &p_path);159160bool updating_features = false;161162void _class_list_item_selected();163void _class_list_item_edited();164void _class_list_item_collapsed(Object *p_item);165void _property_item_edited();166void _save_and_update();167168Timer *update_timer = nullptr;169void _emit_current_profile_changed();170171static EditorFeatureProfileManager *singleton;172173protected:174static void _bind_methods();175void _notification(int p_what);176177public:178Ref<EditorFeatureProfile> get_current_profile();179String get_current_profile_name() const;180void set_current_profile(const String &p_profile_name, bool p_validate_profile);181void notify_changed();182183static EditorFeatureProfileManager *get_singleton() { return singleton; }184EditorFeatureProfileManager();185};186187188