Path: blob/master/editor/settings/editor_feature_profile.h
21212 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,50#ifndef DISABLE_DEPRECATED51FEATURE_NODE_DOCK,52#endif53FEATURE_FILESYSTEM_DOCK,54FEATURE_IMPORT_DOCK,55FEATURE_HISTORY_DOCK,56FEATURE_GAME,57FEATURE_SIGNALS_DOCK,58FEATURE_GROUPS_DOCK,59FEATURE_MAX60};6162private:63HashSet<StringName> disabled_classes;64HashSet<StringName> disabled_editors;65HashMap<StringName, HashSet<StringName>> disabled_properties;6667HashSet<StringName> collapsed_classes;6869bool features_disabled[FEATURE_MAX];70static const char *feature_names[FEATURE_MAX];71static const char *feature_descriptions[FEATURE_MAX];72static const char *feature_identifiers[FEATURE_MAX];7374String _get_feature_name(Feature p_feature) { return get_feature_name(p_feature); }7576protected:77static void _bind_methods();7879public:80void set_disable_class(const StringName &p_class, bool p_disabled);81bool is_class_disabled(const StringName &p_class) const;8283void set_disable_class_editor(const StringName &p_class, bool p_disabled);84bool is_class_editor_disabled(const StringName &p_class) const;8586void set_disable_class_property(const StringName &p_class, const StringName &p_property, bool p_disabled);87bool is_class_property_disabled(const StringName &p_class, const StringName &p_property) const;88bool has_class_properties_disabled(const StringName &p_class) const;8990void set_item_collapsed(const StringName &p_class, bool p_collapsed);91bool is_item_collapsed(const StringName &p_class) const;9293void set_disable_feature(Feature p_feature, bool p_disable);94bool is_feature_disabled(Feature p_feature) const;9596Error save_to_file(const String &p_path);97Error load_from_file(const String &p_path);9899static String get_feature_name(Feature p_feature);100static String get_feature_description(Feature p_feature);101102EditorFeatureProfile();103};104105VARIANT_ENUM_CAST(EditorFeatureProfile::Feature)106107class EditorFeatureProfileManager : public AcceptDialog {108GDCLASS(EditorFeatureProfileManager, AcceptDialog);109110enum Action {111PROFILE_CLEAR,112PROFILE_SET,113PROFILE_IMPORT,114PROFILE_EXPORT,115PROFILE_NEW,116PROFILE_ERASE,117PROFILE_MAX118};119120enum ClassOptions {121CLASS_OPTION_DISABLE_EDITOR122};123124ConfirmationDialog *erase_profile_dialog = nullptr;125ConfirmationDialog *new_profile_dialog = nullptr;126LineEdit *new_profile_name = nullptr;127128LineEdit *current_profile_name = nullptr;129OptionButton *profile_list = nullptr;130Button *profile_actions[PROFILE_MAX];131132HSplitContainer *h_split = nullptr;133134VBoxContainer *class_list_vbc = nullptr;135Tree *class_list = nullptr;136VBoxContainer *property_list_vbc = nullptr;137Tree *property_list = nullptr;138EditorHelpBit *description_bit = nullptr;139Label *no_profile_selected_help = nullptr;140141EditorFileDialog *import_profiles = nullptr;142EditorFileDialog *export_profile = nullptr;143144void _profile_action(int p_action);145void _profile_selected(int p_what);146void _hide_requested();147148String current_profile;149void _update_profile_list(const String &p_select_profile = String());150void _update_selected_profile();151void _update_profile_tree_from(TreeItem *p_edited);152void _fill_classes_from(TreeItem *p_parent, const String &p_class, const String &p_selected, int p_class_insert_index = -1);153154Ref<EditorFeatureProfile> current;155Ref<EditorFeatureProfile> edited;156157void _erase_selected_profile();158void _create_new_profile();159String _get_selected_profile();160161void _import_profiles(const Vector<String> &p_paths);162void _export_profile(const String &p_path);163164bool updating_features = false;165166void _class_list_item_selected();167void _class_list_item_edited();168void _class_list_item_collapsed(Object *p_item);169void _property_item_edited();170void _save_and_update();171172Timer *update_timer = nullptr;173void _emit_current_profile_changed();174175static EditorFeatureProfileManager *singleton;176177protected:178static void _bind_methods();179void _notification(int p_what);180181public:182Ref<EditorFeatureProfile> get_current_profile();183String get_current_profile_name() const;184void set_current_profile(const String &p_profile_name, bool p_validate_profile);185void notify_changed();186187static EditorFeatureProfileManager *get_singleton() { return singleton; }188EditorFeatureProfileManager();189};190191192