/**************************************************************************/1/* property_info.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/extension/gdextension_interface.gen.h"33#include "core/variant/variant.h"3435template <typename T>36class TypedArray;3738enum PropertyHint {39PROPERTY_HINT_NONE, ///< no hint provided.40PROPERTY_HINT_RANGE, ///< hint_text = "min,max[,step][,or_greater][,or_less][,prefer_slider][,hide_control][,radians_as_degrees][,degrees][,exp][,suffix:<keyword>] range.41PROPERTY_HINT_ENUM, ///< hint_text= "val1,val2,val3,etc"42PROPERTY_HINT_ENUM_SUGGESTION, ///< hint_text= "val1,val2,val3,etc"43PROPERTY_HINT_EXP_EASING, /// exponential easing function (Math::ease) use "attenuation" hint string to revert (flip h), "positive_only" to exclude in-out and out-in. (ie: "attenuation,positive_only")44PROPERTY_HINT_LINK,45PROPERTY_HINT_FLAGS, ///< hint_text= "flag1,flag2,etc" (as bit flags)46PROPERTY_HINT_LAYERS_2D_RENDER,47PROPERTY_HINT_LAYERS_2D_PHYSICS,48PROPERTY_HINT_LAYERS_2D_NAVIGATION,49PROPERTY_HINT_LAYERS_3D_RENDER,50PROPERTY_HINT_LAYERS_3D_PHYSICS,51PROPERTY_HINT_LAYERS_3D_NAVIGATION,52PROPERTY_HINT_FILE, ///< a file path must be passed, hint_text (optionally) is a filter "*.png,*.wav,*.doc,"53PROPERTY_HINT_DIR, ///< a directory path must be passed54PROPERTY_HINT_GLOBAL_FILE, ///< a file path must be passed, hint_text (optionally) is a filter "*.png,*.wav,*.doc,"55PROPERTY_HINT_GLOBAL_DIR, ///< a directory path must be passed56PROPERTY_HINT_RESOURCE_TYPE, ///< a comma-separated resource object type, e.g. "NoiseTexture,GradientTexture2D". Subclasses can be excluded with a "-" prefix if placed *after* the base class, e.g. "Texture2D,-MeshTexture".57PROPERTY_HINT_MULTILINE_TEXT, ///< used for string properties that can contain multiple lines58PROPERTY_HINT_EXPRESSION, ///< used for string properties that can contain multiple lines59PROPERTY_HINT_PLACEHOLDER_TEXT, ///< used to set a placeholder text for string properties60PROPERTY_HINT_COLOR_NO_ALPHA, ///< used for ignoring alpha component when editing a color61PROPERTY_HINT_OBJECT_ID,62PROPERTY_HINT_TYPE_STRING, ///< a type string, the hint is the base type to choose63PROPERTY_HINT_NODE_PATH_TO_EDITED_NODE, // Deprecated.64PROPERTY_HINT_OBJECT_TOO_BIG, ///< object is too big to send65PROPERTY_HINT_NODE_PATH_VALID_TYPES,66PROPERTY_HINT_SAVE_FILE, ///< a file path must be passed, hint_text (optionally) is a filter "*.png,*.wav,*.doc,". This opens a save dialog67PROPERTY_HINT_GLOBAL_SAVE_FILE, ///< a file path must be passed, hint_text (optionally) is a filter "*.png,*.wav,*.doc,". This opens a save dialog68PROPERTY_HINT_INT_IS_OBJECTID, // Deprecated.69PROPERTY_HINT_INT_IS_POINTER,70PROPERTY_HINT_ARRAY_TYPE,71PROPERTY_HINT_LOCALE_ID,72PROPERTY_HINT_LOCALIZABLE_STRING,73PROPERTY_HINT_NODE_TYPE, ///< a node object type74PROPERTY_HINT_HIDE_QUATERNION_EDIT, /// Only Node3D::transform should hide the quaternion editor.75PROPERTY_HINT_PASSWORD,76PROPERTY_HINT_LAYERS_AVOIDANCE,77PROPERTY_HINT_DICTIONARY_TYPE,78PROPERTY_HINT_TOOL_BUTTON,79PROPERTY_HINT_ONESHOT, ///< the property will be changed by self after setting, such as AudioStreamPlayer.playing, Particles.emitting.80PROPERTY_HINT_NO_NODEPATH, /// < this property will not contain a NodePath, regardless of type (Array, Dictionary, List, etc.). Needed for SceneTreeDock.81PROPERTY_HINT_GROUP_ENABLE, ///< used to make the property's group checkable. Only use for boolean types.82PROPERTY_HINT_INPUT_NAME,83PROPERTY_HINT_FILE_PATH,84PROPERTY_HINT_MAX,85};8687enum PropertyUsageFlags {88PROPERTY_USAGE_NONE = 0,89PROPERTY_USAGE_STORAGE = 1 << 1,90PROPERTY_USAGE_EDITOR = 1 << 2,91PROPERTY_USAGE_INTERNAL = 1 << 3,92PROPERTY_USAGE_CHECKABLE = 1 << 4, // Used for editing global variables.93PROPERTY_USAGE_CHECKED = 1 << 5, // Used for editing global variables.94PROPERTY_USAGE_GROUP = 1 << 6, // Used for grouping props in the editor.95PROPERTY_USAGE_CATEGORY = 1 << 7,96PROPERTY_USAGE_SUBGROUP = 1 << 8,97PROPERTY_USAGE_CLASS_IS_BITFIELD = 1 << 9,98PROPERTY_USAGE_NO_INSTANCE_STATE = 1 << 10,99PROPERTY_USAGE_RESTART_IF_CHANGED = 1 << 11,100PROPERTY_USAGE_SCRIPT_VARIABLE = 1 << 12,101PROPERTY_USAGE_STORE_IF_NULL = 1 << 13,102PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED = 1 << 14,103PROPERTY_USAGE_SCRIPT_DEFAULT_VALUE = 1 << 15, // Deprecated.104PROPERTY_USAGE_CLASS_IS_ENUM = 1 << 16,105PROPERTY_USAGE_NIL_IS_VARIANT = 1 << 17,106PROPERTY_USAGE_ARRAY = 1 << 18, // Used in the inspector to group properties as elements of an array.107PROPERTY_USAGE_ALWAYS_DUPLICATE = 1 << 19, // When duplicating a resource, always duplicate, even with subresource duplication disabled.108PROPERTY_USAGE_NEVER_DUPLICATE = 1 << 20, // When duplicating a resource, never duplicate, even with subresource duplication enabled.109PROPERTY_USAGE_HIGH_END_GFX = 1 << 21,110PROPERTY_USAGE_NODE_PATH_FROM_SCENE_ROOT = 1 << 22,111PROPERTY_USAGE_RESOURCE_NOT_PERSISTENT = 1 << 23,112PROPERTY_USAGE_KEYING_INCREMENTS = 1 << 24, // Used in inspector to increment property when keyed in animation player.113PROPERTY_USAGE_DEFERRED_SET_RESOURCE = 1 << 25, // Deprecated.114PROPERTY_USAGE_EDITOR_INSTANTIATE_OBJECT = 1 << 26, // For Object properties, instantiate them when creating in editor.115PROPERTY_USAGE_EDITOR_BASIC_SETTING = 1 << 27, //for project or editor settings, show when basic settings are selected.116PROPERTY_USAGE_READ_ONLY = 1 << 28, // Mark a property as read-only in the inspector.117PROPERTY_USAGE_SECRET = 1 << 29, // Export preset credentials that should be stored separately from the rest of the export config.118119PROPERTY_USAGE_DEFAULT = PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_EDITOR,120PROPERTY_USAGE_NO_EDITOR = PROPERTY_USAGE_STORAGE,121};122123struct PropertyInfo {124Variant::Type type = Variant::NIL;125String name;126StringName class_name; // For classes127PropertyHint hint = PROPERTY_HINT_NONE;128String hint_string;129uint32_t usage = PROPERTY_USAGE_DEFAULT;130131// If you are thinking about adding another member to this class, ask the maintainer (Juan) first.132133_FORCE_INLINE_ PropertyInfo added_usage(uint32_t p_fl) const {134PropertyInfo pi = *this;135pi.usage |= p_fl;136return pi;137}138139operator Dictionary() const;140141static PropertyInfo from_dict(const Dictionary &p_dict);142143PropertyInfo() {}144145PropertyInfo(const Variant::Type p_type, const String &p_name, const PropertyHint p_hint = PROPERTY_HINT_NONE, const String &p_hint_string = "", const uint32_t p_usage = PROPERTY_USAGE_DEFAULT, const StringName &p_class_name = StringName()) :146type(p_type),147name(p_name),148hint(p_hint),149hint_string(p_hint_string),150usage(p_usage) {151if (hint == PROPERTY_HINT_RESOURCE_TYPE) {152class_name = hint_string;153} else {154class_name = p_class_name;155}156}157158PropertyInfo(const StringName &p_class_name) :159type(Variant::OBJECT),160class_name(p_class_name) {}161162explicit PropertyInfo(const GDExtensionPropertyInfo &pinfo) :163type((Variant::Type)pinfo.type),164name(*reinterpret_cast<StringName *>(pinfo.name)),165class_name(*reinterpret_cast<StringName *>(pinfo.class_name)),166hint((PropertyHint)pinfo.hint),167hint_string(*reinterpret_cast<String *>(pinfo.hint_string)),168usage(pinfo.usage) {}169170bool operator==(const PropertyInfo &p_info) const {171return ((type == p_info.type) &&172(name == p_info.name) &&173(class_name == p_info.class_name) &&174(hint == p_info.hint) &&175(hint_string == p_info.hint_string) &&176(usage == p_info.usage));177}178179bool operator<(const PropertyInfo &p_info) const {180return name < p_info.name;181}182};183184TypedArray<Dictionary> convert_property_list(const List<PropertyInfo> *p_list);185TypedArray<Dictionary> convert_property_list(const Vector<PropertyInfo> &p_vector);186187188