Path: blob/master/editor/settings/editor_build_profile.h
9896 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_XR,46BUILD_OPTION_OPENXR,47BUILD_OPTION_WAYLAND,48BUILD_OPTION_X11,49BUILD_OPTION_RENDERING_DEVICE,50BUILD_OPTION_FORWARD_RENDERER,51BUILD_OPTION_MOBILE_RENDERER,52BUILD_OPTION_VULKAN,53BUILD_OPTION_D3D12,54BUILD_OPTION_METAL,55BUILD_OPTION_OPENGL,56BUILD_OPTION_PHYSICS_2D,57BUILD_OPTION_PHYSICS_GODOT_2D,58BUILD_OPTION_PHYSICS_3D,59BUILD_OPTION_PHYSICS_GODOT_3D,60BUILD_OPTION_PHYSICS_JOLT,61BUILD_OPTION_TEXT_SERVER_FALLBACK,62BUILD_OPTION_TEXT_SERVER_ADVANCED,63BUILD_OPTION_DYNAMIC_FONTS,64BUILD_OPTION_WOFF2_FONTS,65BUILD_OPTION_GRAPHITE_FONTS,66BUILD_OPTION_MSDFGEN,67BUILD_OPTION_MAX,68};6970enum BuildOptionCategory {71BUILD_OPTION_CATEGORY_GENERAL,72BUILD_OPTION_CATEGORY_GRAPHICS,73BUILD_OPTION_CATEGORY_PHYSICS,74BUILD_OPTION_CATEGORY_TEXT_SERVER,75BUILD_OPTION_CATEGORY_MAX,76};7778private:79HashSet<StringName> disabled_classes;8081HashSet<StringName> collapsed_classes;8283String force_detect_classes;8485bool build_options_disabled[BUILD_OPTION_MAX] = {};86static const char *build_option_identifiers[BUILD_OPTION_MAX];87static const bool build_option_disabled_by_default[BUILD_OPTION_MAX];88static const bool build_option_disable_values[BUILD_OPTION_MAX];89static const bool build_option_explicit_use[BUILD_OPTION_MAX];90static const BuildOptionCategory build_option_category[BUILD_OPTION_MAX];91static const HashMap<BuildOption, LocalVector<BuildOption>> build_option_dependencies;92static HashMap<BuildOption, HashMap<String, LocalVector<Variant>>> build_option_settings;93static const HashMap<BuildOption, LocalVector<String>> build_option_classes;9495String _get_build_option_name(BuildOption p_build_option) { return get_build_option_name(p_build_option); }9697protected:98static void _bind_methods();99100public:101void set_disable_class(const StringName &p_class, bool p_disabled);102bool is_class_disabled(const StringName &p_class) const;103104void set_item_collapsed(const StringName &p_class, bool p_collapsed);105bool is_item_collapsed(const StringName &p_class) const;106107void set_disable_build_option(BuildOption p_build_option, bool p_disable);108bool is_build_option_disabled(BuildOption p_build_option) const;109110void reset_build_options();111112void set_force_detect_classes(const String &p_classes);113String get_force_detect_classes() const;114115void clear_disabled_classes();116117Error save_to_file(const String &p_path);118Error load_from_file(const String &p_path);119120static String get_build_option_name(BuildOption p_build_option);121static String get_build_option_description(BuildOption p_build_option);122static String get_build_option_identifier(BuildOption p_build_option);123static bool get_build_option_disable_value(BuildOption p_build_option);124static bool get_build_option_explicit_use(BuildOption p_build_option);125static BuildOptionCategory get_build_option_category(BuildOption p_build_option);126static LocalVector<BuildOption> get_build_option_dependencies(BuildOption p_build_option);127static HashMap<String, LocalVector<Variant>> get_build_option_settings(BuildOption p_build_option);128static LocalVector<String> get_build_option_classes(BuildOption p_build_option);129130static String get_build_option_category_name(BuildOptionCategory p_build_option_category);131132EditorBuildProfile();133};134135VARIANT_ENUM_CAST(EditorBuildProfile::BuildOption)136VARIANT_ENUM_CAST(EditorBuildProfile::BuildOptionCategory)137138class EditorFileDialog;139class EditorFileSystemDirectory;140141class EditorBuildProfileManager : public AcceptDialog {142GDCLASS(EditorBuildProfileManager, AcceptDialog);143144enum Action {145ACTION_NEW,146ACTION_RESET,147ACTION_LOAD,148ACTION_SAVE,149ACTION_SAVE_AS,150ACTION_DETECT,151ACTION_MAX152};153154Action last_action = ACTION_NEW;155156ConfirmationDialog *confirm_dialog = nullptr;157Button *profile_actions[ACTION_MAX];158159Tree *class_list = nullptr;160EditorHelpBit *description_bit = nullptr;161162EditorFileDialog *import_profile = nullptr;163EditorFileDialog *export_profile = nullptr;164165LineEdit *profile_path = nullptr;166167LineEdit *force_detect_classes = nullptr;168169void _profile_action(int p_action);170void _action_confirm();171void _hide_requested();172173void _update_edited_profile();174void _fill_classes_from(TreeItem *p_parent, const String &p_class, const String &p_selected);175176Ref<EditorBuildProfile> edited;177178void _import_profile(const String &p_path);179void _export_profile(const String &p_path);180181bool updating_build_options = false;182183void _class_list_item_selected();184void _class_list_item_edited();185void _class_list_item_collapsed(Object *p_item);186187bool project_scan_canceled = false;188189void _detect_from_project();190191void _force_detect_classes_changed(const String &p_text);192193struct DetectedFile {194uint32_t timestamp = 0;195String md5;196Vector<String> classes;197Vector<String> build_deps;198};199200void _find_files(EditorFileSystemDirectory *p_dir, const HashMap<String, DetectedFile> &p_cache, HashMap<String, DetectedFile> &r_detected);201202static EditorBuildProfileManager *singleton;203204protected:205static void _bind_methods();206void _notification(int p_what);207208public:209Ref<EditorBuildProfile> get_current_profile();210211static EditorBuildProfileManager *get_singleton() { return singleton; }212EditorBuildProfileManager();213};214215216