Path: blob/master/editor/settings/editor_build_profile.h
21344 views
/**************************************************************************/1/* editor_build_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/tree.h"3637class EditorBuildProfile : public RefCounted {38GDCLASS(EditorBuildProfile, RefCounted);3940public:41enum BuildOption {42BUILD_OPTION_3D,43BUILD_OPTION_NAVIGATION_2D,44BUILD_OPTION_NAVIGATION_3D,45BUILD_OPTION_ACCESSKIT,46BUILD_OPTION_SDL,47BUILD_OPTION_XR,48BUILD_OPTION_OPENXR,49BUILD_OPTION_WAYLAND,50BUILD_OPTION_X11,51BUILD_OPTION_PULSEAUDIO,52BUILD_OPTION_ALSA,53BUILD_OPTION_RENDERING_DEVICE,54BUILD_OPTION_FORWARD_RENDERER,55BUILD_OPTION_MOBILE_RENDERER,56BUILD_OPTION_VULKAN,57BUILD_OPTION_D3D12,58BUILD_OPTION_METAL,59BUILD_OPTION_OPENGL,60BUILD_OPTION_PHYSICS_2D,61BUILD_OPTION_PHYSICS_GODOT_2D,62BUILD_OPTION_PHYSICS_3D,63BUILD_OPTION_PHYSICS_GODOT_3D,64BUILD_OPTION_PHYSICS_JOLT,65BUILD_OPTION_TEXT_SERVER_FALLBACK,66BUILD_OPTION_TEXT_SERVER_ADVANCED,67BUILD_OPTION_DYNAMIC_FONTS,68BUILD_OPTION_WOFF2_FONTS,69BUILD_OPTION_GRAPHITE_FONTS,70BUILD_OPTION_MSDFGEN,71BUILD_OPTION_MAX,72};7374enum BuildOptionCategory {75BUILD_OPTION_CATEGORY_GENERAL,76BUILD_OPTION_CATEGORY_GRAPHICS,77BUILD_OPTION_CATEGORY_PHYSICS,78BUILD_OPTION_CATEGORY_TEXT_SERVER,79BUILD_OPTION_CATEGORY_MAX,80};8182private:83HashSet<StringName> disabled_classes;8485HashSet<StringName> collapsed_classes;8687String force_detect_classes;8889bool build_options_disabled[BUILD_OPTION_MAX] = {};90static const char *build_option_identifiers[BUILD_OPTION_MAX];91static const bool build_option_disabled_by_default[BUILD_OPTION_MAX];92static const bool build_option_disable_values[BUILD_OPTION_MAX];93static const bool build_option_explicit_use[BUILD_OPTION_MAX];94static const BuildOptionCategory build_option_category[BUILD_OPTION_MAX];95static const HashMap<BuildOption, LocalVector<BuildOption>> build_option_dependencies;96static HashMap<BuildOption, HashMap<String, LocalVector<Variant>>> build_option_settings;97static const HashMap<BuildOption, LocalVector<String>> build_option_classes;9899String _get_build_option_name(BuildOption p_build_option) { return get_build_option_name(p_build_option); }100101protected:102static void _bind_methods();103104public:105void set_disable_class(const StringName &p_class, bool p_disabled);106bool is_class_disabled(const StringName &p_class) const;107108void set_item_collapsed(const StringName &p_class, bool p_collapsed);109bool is_item_collapsed(const StringName &p_class) const;110111void set_disable_build_option(BuildOption p_build_option, bool p_disable);112bool is_build_option_disabled(BuildOption p_build_option) const;113114void reset_build_options();115116void set_force_detect_classes(const String &p_classes);117String get_force_detect_classes() const;118119void clear_disabled_classes();120121Error save_to_file(const String &p_path);122Error load_from_file(const String &p_path);123124static String get_build_option_name(BuildOption p_build_option);125static String get_build_option_description(BuildOption p_build_option);126static String get_build_option_identifier(BuildOption p_build_option);127static bool get_build_option_disable_value(BuildOption p_build_option);128static bool get_build_option_explicit_use(BuildOption p_build_option);129static BuildOptionCategory get_build_option_category(BuildOption p_build_option);130static LocalVector<BuildOption> get_build_option_dependencies(BuildOption p_build_option);131static HashMap<String, LocalVector<Variant>> get_build_option_settings(BuildOption p_build_option);132static LocalVector<String> get_build_option_classes(BuildOption p_build_option);133134static String get_build_option_category_name(BuildOptionCategory p_build_option_category);135136EditorBuildProfile();137};138139VARIANT_ENUM_CAST(EditorBuildProfile::BuildOption)140VARIANT_ENUM_CAST(EditorBuildProfile::BuildOptionCategory)141142class EditorFileDialog;143class EditorFileSystemDirectory;144145class EditorBuildProfileManager : public AcceptDialog {146GDCLASS(EditorBuildProfileManager, AcceptDialog);147148enum Action {149ACTION_NEW,150ACTION_RESET,151ACTION_LOAD,152ACTION_SAVE,153ACTION_SAVE_AS,154ACTION_DETECT,155ACTION_MAX156};157158Action last_action = ACTION_NEW;159160ConfirmationDialog *confirm_dialog = nullptr;161Button *profile_actions[ACTION_MAX];162163Tree *class_list = nullptr;164EditorHelpBit *description_bit = nullptr;165166EditorFileDialog *import_profile = nullptr;167EditorFileDialog *export_profile = nullptr;168169LineEdit *profile_path = nullptr;170171LineEdit *force_detect_classes = nullptr;172173void _profile_action(int p_action);174void _action_confirm();175void _hide_requested();176177void _update_edited_profile();178void _fill_classes_from(TreeItem *p_parent, const String &p_class, const String &p_selected);179180Ref<EditorBuildProfile> edited;181182void _import_profile(const String &p_path);183void _export_profile(const String &p_path);184185bool updating_build_options = false;186187void _class_list_item_selected();188void _class_list_item_edited();189void _class_list_item_collapsed(Object *p_item);190191bool project_scan_canceled = false;192193void _detect_from_project();194195void _force_detect_classes_changed(const String &p_text);196197struct DetectedFile {198uint32_t timestamp = 0;199String md5;200Vector<String> classes;201Vector<String> build_deps;202};203204void _find_files(EditorFileSystemDirectory *p_dir, const HashMap<String, DetectedFile> &p_cache, HashMap<String, DetectedFile> &r_detected);205206static EditorBuildProfileManager *singleton;207208protected:209static void _bind_methods();210void _notification(int p_what);211212public:213Ref<EditorBuildProfile> get_current_profile();214215static EditorBuildProfileManager *get_singleton() { return singleton; }216EditorBuildProfileManager();217};218219220