2023-01-05 13:25:55 +01:00
/**************************************************************************/
/* inspector_dock.cpp */
/**************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/**************************************************************************/
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
2018-05-17 08:01:47 +02:00
# include "inspector_dock.h"
2022-02-12 02:46:22 +01:00
# include "editor/editor_file_dialog.h"
# include "editor/editor_node.h"
2020-09-10 14:45:10 +02:00
# include "editor/editor_scale.h"
2022-07-31 20:14:15 +02:00
# include "editor/editor_settings.h"
2022-08-29 12:10:32 +02:00
# include "editor/editor_undo_redo_manager.h"
2023-01-04 18:44:57 +01:00
# include "editor/filesystem_dock.h"
2022-02-14 14:00:03 +01:00
# include "editor/plugins/script_editor_plugin.h"
2018-05-17 08:01:47 +02:00
2021-11-17 21:08:55 +01:00
InspectorDock * InspectorDock : : singleton = nullptr ;
2022-03-23 02:46:59 +01:00
void InspectorDock : : _prepare_menu ( ) {
PopupMenu * menu = object_menu - > get_popup ( ) ;
for ( int i = EditorPropertyNameProcessor : : STYLE_RAW ; i < = EditorPropertyNameProcessor : : STYLE_LOCALIZED ; i + + ) {
menu - > set_item_checked ( menu - > get_item_index ( PROPERTY_NAME_STYLE_RAW + i ) , i = = property_name_style ) ;
}
}
2018-05-17 08:01:47 +02:00
void InspectorDock : : _menu_option ( int p_option ) {
2020-09-10 14:45:10 +02:00
_menu_option_confirm ( p_option , false ) ;
}
void InspectorDock : : _menu_confirm_current ( ) {
_menu_option_confirm ( current_option , true ) ;
}
void InspectorDock : : _menu_option_confirm ( int p_option , bool p_confirmed ) {
if ( ! p_confirmed ) {
current_option = p_option ;
}
2018-05-17 08:01:47 +02:00
switch ( p_option ) {
2018-09-05 04:03:10 +02:00
case EXPAND_ALL : {
_menu_expandall ( ) ;
} break ;
case COLLAPSE_ALL : {
_menu_collapseall ( ) ;
} break ;
2022-07-30 15:12:51 +02:00
case EXPAND_REVERTABLE : {
_menu_expand_revertable ( ) ;
} break ;
2021-05-15 20:24:45 +02:00
case RESOURCE_SAVE : {
_save_resource ( false ) ;
} break ;
case RESOURCE_SAVE_AS : {
_save_resource ( true ) ;
} break ;
2018-08-20 18:38:18 +02:00
case RESOURCE_MAKE_BUILT_IN : {
_unref_resource ( ) ;
} break ;
case RESOURCE_COPY : {
_copy_resource ( ) ;
} break ;
case RESOURCE_EDIT_CLIPBOARD : {
_paste_resource ( ) ;
} break ;
2023-01-04 18:44:57 +01:00
case RESOURCE_SHOW_IN_FILESYSTEM : {
Ref < Resource > current_res = _get_current_resource ( ) ;
ERR_FAIL_COND ( current_res . is_null ( ) ) ;
FileSystemDock : : get_singleton ( ) - > navigate_to_path ( current_res - > get_path ( ) ) ;
} break ;
2018-08-20 18:38:18 +02:00
2018-05-17 08:01:47 +02:00
case OBJECT_REQUEST_HELP : {
if ( current ) {
2022-01-27 10:36:51 +01:00
EditorNode : : get_singleton ( ) - > set_visible_editor ( EditorNode : : EDITOR_SCRIPT ) ;
2021-07-17 23:22:52 +02:00
emit_signal ( SNAME ( " request_help " ) , current - > get_class ( ) ) ;
2018-05-17 08:01:47 +02:00
}
} break ;
case OBJECT_COPY_PARAMS : {
editor_data - > apply_changes_in_editors ( ) ;
2020-05-14 16:41:43 +02:00
if ( current ) {
2018-05-17 08:01:47 +02:00
editor_data - > copy_object_params ( current ) ;
2020-05-14 16:41:43 +02:00
}
2018-05-17 08:01:47 +02:00
} break ;
case OBJECT_PASTE_PARAMS : {
editor_data - > apply_changes_in_editors ( ) ;
2020-05-14 16:41:43 +02:00
if ( current ) {
2018-05-17 08:01:47 +02:00
editor_data - > paste_object_params ( current ) ;
2020-05-14 16:41:43 +02:00
}
2018-05-17 08:01:47 +02:00
} break ;
case OBJECT_UNIQUE_RESOURCES : {
2020-09-10 14:45:10 +02:00
if ( ! p_confirmed ) {
Vector < String > resource_propnames ;
2018-05-17 08:01:47 +02:00
2020-09-10 14:45:10 +02:00
if ( current ) {
List < PropertyInfo > props ;
current - > get_property_list ( & props ) ;
for ( List < PropertyInfo > : : Element * E = props . front ( ) ; E ; E = E - > next ( ) ) {
if ( ! ( E - > get ( ) . usage & PROPERTY_USAGE_STORAGE ) ) {
continue ;
}
Variant v = current - > get ( E - > get ( ) . name ) ;
2022-05-03 01:43:50 +02:00
Ref < RefCounted > ref = v ;
Ref < Resource > res = ref ;
2021-08-26 21:37:17 +02:00
if ( v . is_ref_counted ( ) & & ref . is_valid ( ) & & res . is_valid ( ) ) {
2020-09-10 14:45:10 +02:00
// Valid resource which would be duplicated if action is confirmed.
resource_propnames . append ( E - > get ( ) . name ) ;
}
}
}
if ( resource_propnames . size ( ) ) {
unique_resources_list_tree - > clear ( ) ;
TreeItem * root = unique_resources_list_tree - > create_item ( ) ;
2018-05-17 08:01:47 +02:00
2020-09-10 14:45:10 +02:00
for ( int i = 0 ; i < resource_propnames . size ( ) ; i + + ) {
String propname = resource_propnames [ i ] . replace ( " / " , " / " ) ;
TreeItem * ti = unique_resources_list_tree - > create_item ( root ) ;
ti - > set_text ( 0 , bool ( EDITOR_GET ( " interface/inspector/capitalize_properties " ) ) ? propname . capitalize ( ) : propname ) ;
}
2023-01-06 16:23:30 +01:00
unique_resources_label - > set_text ( TTR ( " The following resources will be duplicated and embedded within this resource/object. " ) ) ;
2020-09-10 14:45:10 +02:00
unique_resources_confirmation - > popup_centered ( ) ;
} else {
current_option = - 1 ;
2023-01-06 16:23:30 +01:00
unique_resources_label - > set_text ( TTR ( " This object has no resources. " ) ) ;
2020-09-10 14:45:10 +02:00
unique_resources_confirmation - > popup_centered ( ) ;
}
} else {
editor_data - > apply_changes_in_editors ( ) ;
if ( current ) {
List < PropertyInfo > props ;
current - > get_property_list ( & props ) ;
2022-05-13 15:04:37 +02:00
HashMap < Ref < Resource > , Ref < Resource > > duplicates ;
2020-09-10 14:45:10 +02:00
for ( const PropertyInfo & prop_info : props ) {
if ( ! ( prop_info . usage & PROPERTY_USAGE_STORAGE ) ) {
continue ;
}
Variant v = current - > get ( prop_info . name ) ;
2021-08-26 21:37:17 +02:00
if ( v . is_ref_counted ( ) ) {
2022-05-03 01:43:50 +02:00
Ref < RefCounted > ref = v ;
2020-09-10 14:45:10 +02:00
if ( ref . is_valid ( ) ) {
2022-05-03 01:43:50 +02:00
Ref < Resource > res = ref ;
2020-09-10 14:45:10 +02:00
if ( res . is_valid ( ) ) {
if ( ! duplicates . has ( res ) ) {
duplicates [ res ] = res - > duplicate ( ) ;
}
res = duplicates [ res ] ;
current - > set ( prop_info . name , res ) ;
2021-11-17 21:08:55 +01:00
get_inspector_singleton ( ) - > update_property ( prop_info . name ) ;
2020-09-10 14:45:10 +02:00
}
2018-05-17 08:01:47 +02:00
}
}
}
}
2022-12-23 23:53:16 +01:00
int history_id = EditorUndoRedoManager : : get_singleton ( ) - > get_history_for_object ( current ) . id ;
EditorUndoRedoManager : : get_singleton ( ) - > clear_history ( true , history_id ) ;
2018-05-17 08:01:47 +02:00
2023-01-21 22:49:06 +01:00
EditorNode : : get_singleton ( ) - > edit_item ( current , inspector ) ;
2020-09-10 14:45:10 +02:00
}
2018-05-17 08:01:47 +02:00
} break ;
2022-03-23 02:46:59 +01:00
case PROPERTY_NAME_STYLE_RAW :
case PROPERTY_NAME_STYLE_CAPITALIZED :
case PROPERTY_NAME_STYLE_LOCALIZED : {
property_name_style = ( EditorPropertyNameProcessor : : Style ) ( p_option - PROPERTY_NAME_STYLE_RAW ) ;
inspector - > set_property_name_style ( property_name_style ) ;
} break ;
2018-05-17 08:01:47 +02:00
default : {
if ( p_option > = OBJECT_METHOD_BASE ) {
ERR_FAIL_COND ( ! current ) ;
int idx = p_option - OBJECT_METHOD_BASE ;
List < MethodInfo > methods ;
current - > get_method_list ( & methods ) ;
ERR_FAIL_INDEX ( idx , methods . size ( ) ) ;
String name = methods [ idx ] . name ;
2019-04-08 11:03:37 +02:00
current - > call ( name ) ;
2018-05-17 08:01:47 +02:00
}
}
}
}
void InspectorDock : : _new_resource ( ) {
new_resource_dialog - > popup_create ( true ) ;
}
void InspectorDock : : _load_resource ( const String & p_type ) {
2020-03-06 18:00:16 +01:00
load_resource_dialog - > set_file_mode ( EditorFileDialog : : FILE_MODE_OPEN_FILE ) ;
2018-05-17 08:01:47 +02:00
List < String > extensions ;
ResourceLoader : : get_recognized_extensions_for_type ( p_type , & extensions ) ;
load_resource_dialog - > clear_filters ( ) ;
for ( int i = 0 ; i < extensions . size ( ) ; i + + ) {
2022-07-04 23:26:26 +02:00
load_resource_dialog - > add_filter ( " *. " + extensions [ i ] , extensions [ i ] . to_upper ( ) ) ;
2018-05-17 08:01:47 +02:00
}
2022-10-18 16:43:37 +02:00
const Vector < String > textfile_ext = ( ( String ) ( EDITOR_GET ( " docks/filesystem/textfile_extensions " ) ) ) . split ( " , " , false ) ;
2021-09-23 23:09:15 +02:00
for ( int i = 0 ; i < textfile_ext . size ( ) ; i + + ) {
2022-07-04 23:26:26 +02:00
load_resource_dialog - > add_filter ( " *. " + textfile_ext [ i ] , textfile_ext [ i ] . to_upper ( ) ) ;
2021-09-23 23:09:15 +02:00
}
2020-07-11 18:45:19 +02:00
load_resource_dialog - > popup_file_dialog ( ) ;
2018-05-17 08:01:47 +02:00
}
void InspectorDock : : _resource_file_selected ( String p_file ) {
2022-05-03 01:43:50 +02:00
Ref < Resource > res ;
2021-09-23 23:09:15 +02:00
if ( ResourceLoader : : exists ( p_file , " " ) ) {
res = ResourceLoader : : load ( p_file ) ;
} else {
2022-10-18 16:43:37 +02:00
const Vector < String > textfile_ext = ( ( String ) ( EDITOR_GET ( " docks/filesystem/textfile_extensions " ) ) ) . split ( " , " , false ) ;
2021-09-23 23:09:15 +02:00
if ( textfile_ext . has ( p_file . get_extension ( ) ) ) {
res = ScriptEditor : : get_singleton ( ) - > open_file ( p_file ) ;
}
}
2018-05-28 17:52:28 +02:00
2018-05-17 08:01:47 +02:00
if ( res . is_null ( ) ) {
2022-04-29 08:06:48 +02:00
info_dialog - > set_text ( TTR ( " Failed to load resource. " ) ) ;
2018-05-17 08:01:47 +02:00
return ;
} ;
2022-01-27 10:36:51 +01:00
EditorNode : : get_singleton ( ) - > push_item ( res . operator - > ( ) ) ;
2018-05-17 08:01:47 +02:00
}
2020-10-15 17:29:59 +02:00
void InspectorDock : : _save_resource ( bool save_as ) {
2023-01-04 19:22:29 +01:00
Ref < Resource > current_res = _get_current_resource ( ) ;
ERR_FAIL_COND ( current_res . is_null ( ) ) ;
2018-05-17 08:01:47 +02:00
2020-05-14 16:41:43 +02:00
if ( save_as ) {
2022-01-27 10:36:51 +01:00
EditorNode : : get_singleton ( ) - > save_resource_as ( current_res ) ;
2020-05-14 16:41:43 +02:00
} else {
2022-01-27 10:36:51 +01:00
EditorNode : : get_singleton ( ) - > save_resource ( current_res ) ;
2020-05-14 16:41:43 +02:00
}
2018-05-17 08:01:47 +02:00
}
2020-10-15 17:29:59 +02:00
void InspectorDock : : _unref_resource ( ) {
2023-01-04 19:22:29 +01:00
Ref < Resource > current_res = _get_current_resource ( ) ;
ERR_FAIL_COND ( current_res . is_null ( ) ) ;
2018-05-17 08:01:47 +02:00
current_res - > set_path ( " " ) ;
2022-01-27 10:36:51 +01:00
EditorNode : : get_singleton ( ) - > edit_current ( ) ;
2018-05-17 08:01:47 +02:00
}
2020-10-15 17:29:59 +02:00
void InspectorDock : : _copy_resource ( ) {
2023-01-04 19:22:29 +01:00
Ref < Resource > current_res = _get_current_resource ( ) ;
ERR_FAIL_COND ( current_res . is_null ( ) ) ;
2018-05-17 08:01:47 +02:00
EditorSettings : : get_singleton ( ) - > set_resource_clipboard ( current_res ) ;
}
2020-10-15 17:29:59 +02:00
void InspectorDock : : _paste_resource ( ) {
2022-05-03 01:43:50 +02:00
Ref < Resource > r = EditorSettings : : get_singleton ( ) - > get_resource_clipboard ( ) ;
2018-05-17 08:01:47 +02:00
if ( r . is_valid ( ) ) {
2022-01-27 10:36:51 +01:00
EditorNode : : get_singleton ( ) - > push_item ( EditorSettings : : get_singleton ( ) - > get_resource_clipboard ( ) . ptr ( ) , String ( ) ) ;
2018-05-17 08:01:47 +02:00
}
}
2021-08-16 16:34:17 +02:00
void InspectorDock : : _prepare_resource_extra_popup ( ) {
2022-05-03 01:43:50 +02:00
Ref < Resource > r = EditorSettings : : get_singleton ( ) - > get_resource_clipboard ( ) ;
2021-08-16 16:34:17 +02:00
PopupMenu * popup = resource_extra_button - > get_popup ( ) ;
popup - > set_item_disabled ( popup - > get_item_index ( RESOURCE_EDIT_CLIPBOARD ) , r . is_null ( ) ) ;
2023-01-04 18:44:57 +01:00
Ref < Resource > current_res = _get_current_resource ( ) ;
ERR_FAIL_COND ( current_res . is_null ( ) ) ;
popup - > set_item_disabled ( popup - > get_item_index ( RESOURCE_SHOW_IN_FILESYSTEM ) , current_res - > is_built_in ( ) ) ;
2021-08-16 16:34:17 +02:00
}
2023-01-04 19:22:29 +01:00
Ref < Resource > InspectorDock : : _get_current_resource ( ) const {
ObjectID current_id = EditorNode : : get_singleton ( ) - > get_editor_selection_history ( ) - > get_current ( ) ;
Object * current_obj = current_id . is_valid ( ) ? ObjectDB : : get_instance ( current_id ) : nullptr ;
return Ref < Resource > ( Object : : cast_to < Resource > ( current_obj ) ) ;
}
2018-05-17 08:01:47 +02:00
void InspectorDock : : _prepare_history ( ) {
2022-03-30 20:12:26 +02:00
EditorSelectionHistory * editor_history = EditorNode : : get_singleton ( ) - > get_editor_selection_history ( ) ;
2018-05-17 08:01:47 +02:00
int history_to = MAX ( 0 , editor_history - > get_history_len ( ) - 25 ) ;
history_menu - > get_popup ( ) - > clear ( ) ;
2022-05-19 17:00:06 +02:00
HashSet < ObjectID > already ;
2018-05-17 08:01:47 +02:00
for ( int i = editor_history - > get_history_len ( ) - 1 ; i > = history_to ; i - - ) {
ObjectID id = editor_history - > get_history_obj ( i ) ;
Object * obj = ObjectDB : : get_instance ( id ) ;
if ( ! obj | | already . has ( id ) ) {
if ( history_to > 0 ) {
history_to - - ;
}
continue ;
}
already . insert ( id ) ;
2022-06-14 20:34:17 +02:00
Ref < Texture2D > icon = EditorNode : : get_singleton ( ) - > get_object_icon ( obj , " Object " ) ;
2018-05-17 08:01:47 +02:00
String text ;
2022-06-14 20:34:17 +02:00
if ( obj - > has_method ( " _get_editor_name " ) ) {
text = obj - > call ( " _get_editor_name " ) ;
} else if ( Object : : cast_to < Resource > ( obj ) ) {
2018-05-17 08:01:47 +02:00
Resource * r = Object : : cast_to < Resource > ( obj ) ;
2020-05-14 16:41:43 +02:00
if ( r - > get_path ( ) . is_resource_file ( ) ) {
2018-05-17 08:01:47 +02:00
text = r - > get_path ( ) . get_file ( ) ;
2021-12-09 10:42:46 +01:00
} else if ( ! r - > get_name ( ) . is_empty ( ) ) {
2018-05-17 08:01:47 +02:00
text = r - > get_name ( ) ;
} else {
text = r - > get_class ( ) ;
}
} else if ( Object : : cast_to < Node > ( obj ) ) {
text = Object : : cast_to < Node > ( obj ) - > get_name ( ) ;
2020-02-07 02:52:05 +01:00
} else if ( obj - > is_class ( " EditorDebuggerRemoteObject " ) ) {
2018-05-17 08:01:47 +02:00
text = obj - > call ( " get_title " ) ;
} else {
text = obj - > get_class ( ) ;
}
2019-09-05 00:38:23 +02:00
if ( i = = editor_history - > get_history_pos ( ) & & current ) {
2022-06-14 20:34:17 +02:00
text + = " " + TTR ( " (Current) " ) ;
2018-05-17 08:01:47 +02:00
}
history_menu - > get_popup ( ) - > add_icon_item ( icon , text , i ) ;
}
}
2020-02-21 17:44:59 +01:00
void InspectorDock : : _select_history ( int p_idx ) {
2022-06-14 20:34:17 +02:00
// Push it to the top, it is not correct, but it's more useful.
2022-03-30 20:12:26 +02:00
ObjectID id = EditorNode : : get_singleton ( ) - > get_editor_selection_history ( ) - > get_history_obj ( p_idx ) ;
2018-05-17 08:01:47 +02:00
Object * obj = ObjectDB : : get_instance ( id ) ;
2020-05-14 16:41:43 +02:00
if ( ! obj ) {
2018-05-17 08:01:47 +02:00
return ;
2020-05-14 16:41:43 +02:00
}
2022-01-27 10:36:51 +01:00
EditorNode : : get_singleton ( ) - > push_item ( obj ) ;
2018-05-17 08:01:47 +02:00
}
2020-02-21 17:44:59 +01:00
void InspectorDock : : _resource_created ( ) {
2022-11-16 00:13:39 +01:00
Variant c = new_resource_dialog - > instantiate_selected ( ) ;
2018-05-17 08:01:47 +02:00
ERR_FAIL_COND ( ! c ) ;
Resource * r = Object : : cast_to < Resource > ( c ) ;
ERR_FAIL_COND ( ! r ) ;
2022-01-27 10:36:51 +01:00
EditorNode : : get_singleton ( ) - > push_item ( r ) ;
2018-05-17 08:01:47 +02:00
}
2022-05-03 01:43:50 +02:00
void InspectorDock : : _resource_selected ( const Ref < Resource > & p_res , const String & p_property ) {
2020-05-14 16:41:43 +02:00
if ( p_res . is_null ( ) ) {
2018-05-17 08:01:47 +02:00
return ;
2020-05-14 16:41:43 +02:00
}
2018-05-17 08:01:47 +02:00
2022-05-03 01:43:50 +02:00
Ref < Resource > r = p_res ;
2022-01-27 10:36:51 +01:00
EditorNode : : get_singleton ( ) - > push_item ( r . operator - > ( ) , p_property ) ;
2018-05-17 08:01:47 +02:00
}
void InspectorDock : : _edit_forward ( ) {
2022-03-30 20:12:26 +02:00
if ( EditorNode : : get_singleton ( ) - > get_editor_selection_history ( ) - > next ( ) ) {
2022-01-27 10:36:51 +01:00
EditorNode : : get_singleton ( ) - > edit_current ( ) ;
2020-05-14 16:41:43 +02:00
}
2018-05-17 08:01:47 +02:00
}
2020-05-14 14:29:06 +02:00
2018-05-17 08:01:47 +02:00
void InspectorDock : : _edit_back ( ) {
2022-03-30 20:12:26 +02:00
EditorSelectionHistory * editor_history = EditorNode : : get_singleton ( ) - > get_editor_selection_history ( ) ;
2020-05-14 16:41:43 +02:00
if ( ( current & & editor_history - > previous ( ) ) | | editor_history - > get_path_size ( ) = = 1 ) {
2022-01-27 10:36:51 +01:00
EditorNode : : get_singleton ( ) - > edit_current ( ) ;
2020-05-14 16:41:43 +02:00
}
2018-05-17 08:01:47 +02:00
}
void InspectorDock : : _menu_collapseall ( ) {
inspector - > collapse_all_folding ( ) ;
}
void InspectorDock : : _menu_expandall ( ) {
inspector - > expand_all_folding ( ) ;
}
2022-07-30 15:12:51 +02:00
void InspectorDock : : _menu_expand_revertable ( ) {
inspector - > expand_revertable ( ) ;
}
2022-04-29 08:06:48 +02:00
void InspectorDock : : _info_pressed ( ) {
info_dialog - > popup_centered ( ) ;
2018-05-17 08:01:47 +02:00
}
Container * InspectorDock : : get_addon_area ( ) {
return this ;
}
2018-10-05 20:37:26 +02:00
void InspectorDock : : _notification ( int p_what ) {
switch ( p_what ) {
2022-01-12 14:40:19 +01:00
case NOTIFICATION_ENTER_TREE :
2020-09-03 13:22:16 +02:00
case NOTIFICATION_TRANSLATION_CHANGED :
case NOTIFICATION_LAYOUT_DIRECTION_CHANGED :
2018-10-05 20:37:26 +02:00
case EditorSettings : : NOTIFICATION_EDITOR_SETTINGS_CHANGED : {
2022-01-27 10:36:51 +01:00
set_theme ( EditorNode : : get_singleton ( ) - > get_gui_base ( ) - > get_theme ( ) ) ;
2021-05-15 20:24:45 +02:00
2021-07-17 23:22:52 +02:00
resource_new_button - > set_icon ( get_theme_icon ( SNAME ( " New " ) , SNAME ( " EditorIcons " ) ) ) ;
resource_load_button - > set_icon ( get_theme_icon ( SNAME ( " Load " ) , SNAME ( " EditorIcons " ) ) ) ;
resource_save_button - > set_icon ( get_theme_icon ( SNAME ( " Save " ) , SNAME ( " EditorIcons " ) ) ) ;
2021-07-18 15:12:24 +02:00
resource_extra_button - > set_icon ( get_theme_icon ( SNAME ( " GuiTabMenuHl " ) , SNAME ( " EditorIcons " ) ) ) ;
2022-01-12 14:40:19 +01:00
open_docs_button - > set_icon ( get_theme_icon ( SNAME ( " HelpSearch " ) , SNAME ( " EditorIcons " ) ) ) ;
2021-05-15 20:24:45 +02:00
PopupMenu * resource_extra_popup = resource_extra_button - > get_popup ( ) ;
2021-07-17 23:22:52 +02:00
resource_extra_popup - > set_item_icon ( resource_extra_popup - > get_item_index ( RESOURCE_EDIT_CLIPBOARD ) , get_theme_icon ( SNAME ( " ActionPaste " ) , SNAME ( " EditorIcons " ) ) ) ;
resource_extra_popup - > set_item_icon ( resource_extra_popup - > get_item_index ( RESOURCE_COPY ) , get_theme_icon ( SNAME ( " ActionCopy " ) , SNAME ( " EditorIcons " ) ) ) ;
2021-05-15 20:24:45 +02:00
2020-09-03 13:22:16 +02:00
if ( is_layout_rtl ( ) ) {
2021-07-17 23:22:52 +02:00
backward_button - > set_icon ( get_theme_icon ( SNAME ( " Forward " ) , SNAME ( " EditorIcons " ) ) ) ;
forward_button - > set_icon ( get_theme_icon ( SNAME ( " Back " ) , SNAME ( " EditorIcons " ) ) ) ;
2020-09-03 13:22:16 +02:00
} else {
2021-07-17 23:22:52 +02:00
backward_button - > set_icon ( get_theme_icon ( SNAME ( " Back " ) , SNAME ( " EditorIcons " ) ) ) ;
forward_button - > set_icon ( get_theme_icon ( SNAME ( " Forward " ) , SNAME ( " EditorIcons " ) ) ) ;
2020-09-03 13:22:16 +02:00
}
2021-05-15 20:24:45 +02:00
2021-07-17 23:22:52 +02:00
history_menu - > set_icon ( get_theme_icon ( SNAME ( " History " ) , SNAME ( " EditorIcons " ) ) ) ;
object_menu - > set_icon ( get_theme_icon ( SNAME ( " Tools " ) , SNAME ( " EditorIcons " ) ) ) ;
2022-01-12 14:40:19 +01:00
search - > set_right_icon ( get_theme_icon ( SNAME ( " Search " ) , SNAME ( " EditorIcons " ) ) ) ;
2022-04-29 08:06:48 +02:00
if ( info_is_warning ) {
info - > set_icon ( get_theme_icon ( SNAME ( " NodeWarning " ) , SNAME ( " EditorIcons " ) ) ) ;
info - > add_theme_color_override ( " font_color " , get_theme_color ( SNAME ( " warning_color " ) , SNAME ( " Editor " ) ) ) ;
} else {
info - > set_icon ( get_theme_icon ( SNAME ( " NodeInfo " ) , SNAME ( " EditorIcons " ) ) ) ;
info - > add_theme_color_override ( " font_color " , get_theme_color ( SNAME ( " font_color " ) , SNAME ( " Editor " ) ) ) ;
}
2018-10-05 20:37:26 +02:00
} break ;
}
}
2018-05-17 08:01:47 +02:00
void InspectorDock : : _bind_methods ( ) {
ClassDB : : bind_method ( " _unref_resource " , & InspectorDock : : _unref_resource ) ;
ClassDB : : bind_method ( " _paste_resource " , & InspectorDock : : _paste_resource ) ;
ClassDB : : bind_method ( " _copy_resource " , & InspectorDock : : _copy_resource ) ;
ClassDB : : bind_method ( " _menu_collapseall " , & InspectorDock : : _menu_collapseall ) ;
ClassDB : : bind_method ( " _menu_expandall " , & InspectorDock : : _menu_expandall ) ;
2022-03-25 01:17:30 +01:00
ClassDB : : bind_method ( " edit_resource " , & InspectorDock : : edit_resource ) ;
2020-10-25 22:32:32 +01:00
ClassDB : : bind_method ( " store_script_properties " , & InspectorDock : : store_script_properties ) ;
ClassDB : : bind_method ( " apply_script_properties " , & InspectorDock : : apply_script_properties ) ;
2018-05-17 08:01:47 +02:00
ADD_SIGNAL ( MethodInfo ( " request_help " ) ) ;
}
void InspectorDock : : edit_resource ( const Ref < Resource > & p_resource ) {
_resource_selected ( p_resource , " " ) ;
}
void InspectorDock : : open_resource ( const String & p_type ) {
_load_resource ( p_type ) ;
}
2022-04-29 08:06:48 +02:00
void InspectorDock : : set_info ( const String & p_button_text , const String & p_message , bool p_is_warning ) {
info - > hide ( ) ;
info_is_warning = p_is_warning ;
if ( info_is_warning ) {
info - > set_icon ( get_theme_icon ( SNAME ( " NodeWarning " ) , SNAME ( " EditorIcons " ) ) ) ;
info - > add_theme_color_override ( " font_color " , get_theme_color ( SNAME ( " warning_color " ) , SNAME ( " Editor " ) ) ) ;
} else {
info - > set_icon ( get_theme_icon ( SNAME ( " NodeInfo " ) , SNAME ( " EditorIcons " ) ) ) ;
info - > add_theme_color_override ( " font_color " , get_theme_color ( SNAME ( " font_color " ) , SNAME ( " Editor " ) ) ) ;
}
if ( ! p_button_text . is_empty ( ) & & ! p_message . is_empty ( ) ) {
info - > show ( ) ;
info - > set_text ( p_button_text ) ;
info_dialog - > set_text ( p_message ) ;
2018-05-17 08:01:47 +02:00
}
}
void InspectorDock : : clear ( ) {
}
void InspectorDock : : update ( Object * p_object ) {
2022-03-30 20:12:26 +02:00
EditorSelectionHistory * editor_history = EditorNode : : get_singleton ( ) - > get_editor_selection_history ( ) ;
2018-05-17 08:01:47 +02:00
backward_button - > set_disabled ( editor_history - > is_at_beginning ( ) ) ;
forward_button - > set_disabled ( editor_history - > is_at_end ( ) ) ;
history_menu - > set_disabled ( true ) ;
if ( editor_history - > get_history_len ( ) > 0 ) {
history_menu - > set_disabled ( false ) ;
}
editor_path - > update_path ( ) ;
current = p_object ;
2021-08-04 05:01:52 +02:00
const bool is_object = p_object ! = nullptr ;
const bool is_resource = is_object & & p_object - > is_class ( " Resource " ) ;
2021-09-23 23:09:15 +02:00
const bool is_text_file = is_object & & p_object - > is_class ( " TextFile " ) ;
2021-08-04 05:01:52 +02:00
const bool is_node = is_object & & p_object - > is_class ( " Node " ) ;
2021-05-15 20:24:45 +02:00
2021-09-23 23:09:15 +02:00
object_menu - > set_disabled ( ! is_object | | is_text_file ) ;
search - > set_editable ( is_object & & ! is_text_file ) ;
resource_save_button - > set_disabled ( ! is_resource | | is_text_file ) ;
open_docs_button - > set_disabled ( is_text_file | | ( ! is_resource & & ! is_node ) ) ;
2021-05-15 20:24:45 +02:00
PopupMenu * resource_extra_popup = resource_extra_button - > get_popup ( ) ;
2021-09-23 23:09:15 +02:00
resource_extra_popup - > set_item_disabled ( resource_extra_popup - > get_item_index ( RESOURCE_COPY ) , ! is_resource | | is_text_file ) ;
resource_extra_popup - > set_item_disabled ( resource_extra_popup - > get_item_index ( RESOURCE_MAKE_BUILT_IN ) , ! is_resource | | is_text_file ) ;
2018-05-17 08:01:47 +02:00
2021-09-23 23:09:15 +02:00
if ( ! is_object | | is_text_file ) {
2022-04-29 08:06:48 +02:00
info - > hide ( ) ;
2021-08-04 05:01:52 +02:00
editor_path - > clear_path ( ) ;
return ;
}
editor_path - > enable_path ( ) ;
2018-05-17 08:01:47 +02:00
PopupMenu * p = object_menu - > get_popup ( ) ;
p - > clear ( ) ;
2021-07-17 23:22:52 +02:00
p - > add_icon_shortcut ( get_theme_icon ( SNAME ( " GuiTreeArrowDown " ) , SNAME ( " EditorIcons " ) ) , ED_SHORTCUT ( " property_editor/expand_all " , TTR ( " Expand All " ) ) , EXPAND_ALL ) ;
p - > add_icon_shortcut ( get_theme_icon ( SNAME ( " GuiTreeArrowRight " ) , SNAME ( " EditorIcons " ) ) , ED_SHORTCUT ( " property_editor/collapse_all " , TTR ( " Collapse All " ) ) , COLLAPSE_ALL ) ;
2022-07-30 15:12:51 +02:00
// Calling it 'revertable' internally, because that's what the implementation is based on, but labeling it as 'non-default' because that's more user friendly, even if not 100% accurate.
p - > add_shortcut ( ED_SHORTCUT ( " property_editor/expand_revertable " , TTR ( " Expand Non-Default " ) ) , EXPAND_REVERTABLE ) ;
2018-08-20 18:38:18 +02:00
2022-03-23 02:46:59 +01:00
p - > add_separator ( TTR ( " Property Name Style " ) ) ;
p - > add_radio_check_item ( TTR ( " Raw " ) , PROPERTY_NAME_STYLE_RAW ) ;
p - > add_radio_check_item ( TTR ( " Capitalized " ) , PROPERTY_NAME_STYLE_CAPITALIZED ) ;
p - > add_radio_check_item ( TTR ( " Localized " ) , PROPERTY_NAME_STYLE_LOCALIZED ) ;
if ( ! EditorPropertyNameProcessor : : is_localization_available ( ) ) {
const int index = p - > get_item_index ( PROPERTY_NAME_STYLE_LOCALIZED ) ;
p - > set_item_disabled ( index , true ) ;
p - > set_item_tooltip ( index , TTR ( " Localization not available for current language. " ) ) ;
}
p - > add_separator ( ) ;
2021-05-15 20:24:45 +02:00
p - > add_shortcut ( ED_SHORTCUT ( " property_editor/copy_params " , TTR ( " Copy Properties " ) ) , OBJECT_COPY_PARAMS ) ;
p - > add_shortcut ( ED_SHORTCUT ( " property_editor/paste_params " , TTR ( " Paste Properties " ) ) , OBJECT_PASTE_PARAMS ) ;
2018-05-17 08:01:47 +02:00
if ( is_resource | | is_node ) {
p - > add_separator ( ) ;
p - > add_shortcut ( ED_SHORTCUT ( " property_editor/make_subresources_unique " , TTR ( " Make Sub-Resources Unique " ) ) , OBJECT_UNIQUE_RESOURCES ) ;
}
List < MethodInfo > methods ;
p_object - > get_method_list ( & methods ) ;
2020-12-15 13:04:21 +01:00
if ( ! methods . is_empty ( ) ) {
2018-05-17 08:01:47 +02:00
bool found = false ;
List < MethodInfo > : : Element * I = methods . front ( ) ;
int i = 0 ;
while ( I ) {
if ( I - > get ( ) . flags & METHOD_FLAG_EDITOR ) {
if ( ! found ) {
p - > add_separator ( ) ;
found = true ;
}
p - > add_item ( I - > get ( ) . name . capitalize ( ) , OBJECT_METHOD_BASE + i ) ;
}
i + + ;
I = I - > next ( ) ;
}
}
}
2018-06-07 17:46:14 +02:00
void InspectorDock : : go_back ( ) {
_edit_back ( ) ;
}
2022-03-23 02:46:59 +01:00
EditorPropertyNameProcessor : : Style InspectorDock : : get_property_name_style ( ) const {
return property_name_style ;
}
2020-10-25 22:32:32 +01:00
void InspectorDock : : store_script_properties ( Object * p_object ) {
ERR_FAIL_NULL ( p_object ) ;
ScriptInstance * si = p_object - > get_script_instance ( ) ;
if ( ! si ) {
return ;
}
si - > get_property_state ( stored_properties ) ;
}
void InspectorDock : : apply_script_properties ( Object * p_object ) {
ERR_FAIL_NULL ( p_object ) ;
ScriptInstance * si = p_object - > get_script_instance ( ) ;
if ( ! si ) {
return ;
}
for ( const Pair < StringName , Variant > & E : stored_properties ) {
2022-09-29 11:53:28 +02:00
Variant current_prop ;
if ( si - > get ( E . first , current_prop ) & & current_prop . get_type ( ) = = E . second . get_type ( ) ) {
2020-10-25 22:32:32 +01:00
si - > set ( E . first , E . second ) ;
}
}
stored_properties . clear ( ) ;
}
2022-01-27 10:36:51 +01:00
InspectorDock : : InspectorDock ( EditorData & p_editor_data ) {
2021-11-17 21:08:55 +01:00
singleton = this ;
2018-05-17 08:01:47 +02:00
set_name ( " Inspector " ) ;
editor_data = & p_editor_data ;
2022-03-23 02:46:59 +01:00
property_name_style = EditorPropertyNameProcessor : : get_default_inspector_style ( ) ;
2018-05-17 08:01:47 +02:00
HBoxContainer * general_options_hb = memnew ( HBoxContainer ) ;
add_child ( general_options_hb ) ;
2020-06-19 20:49:04 +02:00
resource_new_button = memnew ( Button ) ;
resource_new_button - > set_flat ( true ) ;
2022-08-25 12:42:17 +02:00
resource_new_button - > set_tooltip_text ( TTR ( " Create a new resource in memory and edit it. " ) ) ;
2018-05-17 08:01:47 +02:00
general_options_hb - > add_child ( resource_new_button ) ;
2020-02-20 19:32:36 +01:00
resource_new_button - > connect ( " pressed " , callable_mp ( this , & InspectorDock : : _new_resource ) ) ;
2018-05-17 08:01:47 +02:00
resource_new_button - > set_focus_mode ( Control : : FOCUS_NONE ) ;
2020-06-19 20:49:04 +02:00
resource_load_button = memnew ( Button ) ;
resource_load_button - > set_flat ( true ) ;
2022-08-25 12:42:17 +02:00
resource_load_button - > set_tooltip_text ( TTR ( " Load an existing resource from disk and edit it. " ) ) ;
2018-05-17 08:01:47 +02:00
general_options_hb - > add_child ( resource_load_button ) ;
2020-02-21 18:28:45 +01:00
resource_load_button - > connect ( " pressed " , callable_mp ( this , & InspectorDock : : _open_resource_selector ) ) ;
2018-05-17 08:01:47 +02:00
resource_load_button - > set_focus_mode ( Control : : FOCUS_NONE ) ;
2018-12-13 22:24:25 +01:00
resource_save_button = memnew ( MenuButton ) ;
2022-08-25 12:42:17 +02:00
resource_save_button - > set_tooltip_text ( TTR ( " Save the currently edited resource. " ) ) ;
2018-12-13 22:24:25 +01:00
general_options_hb - > add_child ( resource_save_button ) ;
resource_save_button - > get_popup ( ) - > add_item ( TTR ( " Save " ) , RESOURCE_SAVE ) ;
resource_save_button - > get_popup ( ) - > add_item ( TTR ( " Save As... " ) , RESOURCE_SAVE_AS ) ;
2020-02-21 18:28:45 +01:00
resource_save_button - > get_popup ( ) - > connect ( " id_pressed " , callable_mp ( this , & InspectorDock : : _menu_option ) ) ;
2018-12-13 22:24:25 +01:00
resource_save_button - > set_focus_mode ( Control : : FOCUS_NONE ) ;
resource_save_button - > set_disabled ( true ) ;
2021-05-15 20:24:45 +02:00
resource_extra_button = memnew ( MenuButton ) ;
2022-08-25 12:42:17 +02:00
resource_extra_button - > set_tooltip_text ( TTR ( " Extra resource options. " ) ) ;
2021-05-15 20:24:45 +02:00
general_options_hb - > add_child ( resource_extra_button ) ;
2021-08-16 16:34:17 +02:00
resource_extra_button - > connect ( " about_to_popup " , callable_mp ( this , & InspectorDock : : _prepare_resource_extra_popup ) ) ;
2021-07-17 23:22:52 +02:00
resource_extra_button - > get_popup ( ) - > add_icon_shortcut ( get_theme_icon ( SNAME ( " ActionPaste " ) , SNAME ( " EditorIcons " ) ) , ED_SHORTCUT ( " property_editor/paste_resource " , TTR ( " Edit Resource from Clipboard " ) ) , RESOURCE_EDIT_CLIPBOARD ) ;
resource_extra_button - > get_popup ( ) - > add_icon_shortcut ( get_theme_icon ( SNAME ( " ActionCopy " ) , SNAME ( " EditorIcons " ) ) , ED_SHORTCUT ( " property_editor/copy_resource " , TTR ( " Copy Resource " ) ) , RESOURCE_COPY ) ;
2021-05-15 20:24:45 +02:00
resource_extra_button - > get_popup ( ) - > set_item_disabled ( 1 , true ) ;
resource_extra_button - > get_popup ( ) - > add_separator ( ) ;
2023-01-04 18:44:57 +01:00
resource_extra_button - > get_popup ( ) - > add_shortcut ( ED_SHORTCUT ( " property_editor/show_in_filesystem " , TTR ( " Show in FileSystem " ) ) , RESOURCE_SHOW_IN_FILESYSTEM ) ;
2021-05-15 20:24:45 +02:00
resource_extra_button - > get_popup ( ) - > add_shortcut ( ED_SHORTCUT ( " property_editor/unref_resource " , TTR ( " Make Resource Built-In " ) ) , RESOURCE_MAKE_BUILT_IN ) ;
resource_extra_button - > get_popup ( ) - > set_item_disabled ( 3 , true ) ;
resource_extra_button - > get_popup ( ) - > connect ( " id_pressed " , callable_mp ( this , & InspectorDock : : _menu_option ) ) ;
2018-05-17 08:01:47 +02:00
general_options_hb - > add_spacer ( ) ;
2020-06-19 20:49:04 +02:00
backward_button = memnew ( Button ) ;
backward_button - > set_flat ( true ) ;
2018-05-17 08:01:47 +02:00
general_options_hb - > add_child ( backward_button ) ;
2022-07-29 02:30:20 +02:00
backward_button - > set_tooltip_text ( TTR ( " Go to previous edited object in history. " ) ) ;
2018-05-17 08:01:47 +02:00
backward_button - > set_disabled ( true ) ;
2020-02-21 18:28:45 +01:00
backward_button - > connect ( " pressed " , callable_mp ( this , & InspectorDock : : _edit_back ) ) ;
2018-05-17 08:01:47 +02:00
2020-06-19 20:49:04 +02:00
forward_button = memnew ( Button ) ;
forward_button - > set_flat ( true ) ;
2018-05-17 08:01:47 +02:00
general_options_hb - > add_child ( forward_button ) ;
2022-07-29 02:30:20 +02:00
forward_button - > set_tooltip_text ( TTR ( " Go to next edited object in history. " ) ) ;
2018-05-17 08:01:47 +02:00
forward_button - > set_disabled ( true ) ;
2020-02-21 18:28:45 +01:00
forward_button - > connect ( " pressed " , callable_mp ( this , & InspectorDock : : _edit_forward ) ) ;
2018-05-17 08:01:47 +02:00
history_menu = memnew ( MenuButton ) ;
2022-08-25 12:42:17 +02:00
history_menu - > set_tooltip_text ( TTR ( " History of recently edited objects. " ) ) ;
2018-05-17 08:01:47 +02:00
general_options_hb - > add_child ( history_menu ) ;
2020-03-12 13:37:40 +01:00
history_menu - > connect ( " about_to_popup " , callable_mp ( this , & InspectorDock : : _prepare_history ) ) ;
2020-02-21 18:28:45 +01:00
history_menu - > get_popup ( ) - > connect ( " id_pressed " , callable_mp ( this , & InspectorDock : : _select_history ) ) ;
2018-05-17 08:01:47 +02:00
2021-05-15 20:24:45 +02:00
HBoxContainer * subresource_hb = memnew ( HBoxContainer ) ;
add_child ( subresource_hb ) ;
2022-03-30 20:12:26 +02:00
editor_path = memnew ( EditorPath ( EditorNode : : get_singleton ( ) - > get_editor_selection_history ( ) ) ) ;
2018-05-17 08:01:47 +02:00
editor_path - > set_h_size_flags ( Control : : SIZE_EXPAND_FILL ) ;
2021-05-15 20:24:45 +02:00
subresource_hb - > add_child ( editor_path ) ;
2018-05-17 08:01:47 +02:00
2021-05-15 20:24:45 +02:00
open_docs_button = memnew ( Button ) ;
open_docs_button - > set_flat ( true ) ;
2021-07-29 05:05:11 +02:00
open_docs_button - > set_disabled ( true ) ;
2022-08-25 12:42:17 +02:00
open_docs_button - > set_tooltip_text ( TTR ( " Open documentation for this object. " ) ) ;
2021-05-15 20:24:45 +02:00
open_docs_button - > set_shortcut ( ED_SHORTCUT ( " property_editor/open_help " , TTR ( " Open Documentation " ) ) ) ;
subresource_hb - > add_child ( open_docs_button ) ;
2022-07-28 22:56:41 +02:00
open_docs_button - > connect ( " pressed " , callable_mp ( this , & InspectorDock : : _menu_option ) . bind ( OBJECT_REQUEST_HELP ) ) ;
2018-05-17 08:01:47 +02:00
new_resource_dialog = memnew ( CreateDialog ) ;
2022-01-27 10:36:51 +01:00
EditorNode : : get_singleton ( ) - > get_gui_base ( ) - > add_child ( new_resource_dialog ) ;
2018-05-17 08:01:47 +02:00
new_resource_dialog - > set_base_type ( " Resource " ) ;
2020-02-21 18:28:45 +01:00
new_resource_dialog - > connect ( " create " , callable_mp ( this , & InspectorDock : : _resource_created ) ) ;
2018-05-17 08:01:47 +02:00
2021-05-15 20:24:45 +02:00
HBoxContainer * property_tools_hb = memnew ( HBoxContainer ) ;
add_child ( property_tools_hb ) ;
2018-05-17 08:01:47 +02:00
search = memnew ( LineEdit ) ;
search - > set_h_size_flags ( Control : : SIZE_EXPAND_FILL ) ;
2022-05-27 06:02:48 +02:00
search - > set_placeholder ( TTR ( " Filter Properties " ) ) ;
2018-07-26 13:45:38 +02:00
search - > set_clear_button_enabled ( true ) ;
2021-05-15 20:24:45 +02:00
property_tools_hb - > add_child ( search ) ;
object_menu = memnew ( MenuButton ) ;
object_menu - > set_shortcut_context ( this ) ;
property_tools_hb - > add_child ( object_menu ) ;
2022-08-25 12:42:17 +02:00
object_menu - > set_tooltip_text ( TTR ( " Manage object properties. " ) ) ;
2022-03-23 02:46:59 +01:00
object_menu - > get_popup ( ) - > connect ( " about_to_popup " , callable_mp ( this , & InspectorDock : : _prepare_menu ) ) ;
2021-05-15 20:24:45 +02:00
object_menu - > get_popup ( ) - > connect ( " id_pressed " , callable_mp ( this , & InspectorDock : : _menu_option ) ) ;
2018-05-17 08:01:47 +02:00
2022-04-29 08:06:48 +02:00
info = memnew ( Button ) ;
add_child ( info ) ;
info - > set_clip_text ( true ) ;
info - > hide ( ) ;
info - > connect ( " pressed " , callable_mp ( this , & InspectorDock : : _info_pressed ) ) ;
2018-05-17 08:01:47 +02:00
2020-09-10 14:45:10 +02:00
unique_resources_confirmation = memnew ( ConfirmationDialog ) ;
add_child ( unique_resources_confirmation ) ;
VBoxContainer * container = memnew ( VBoxContainer ) ;
unique_resources_confirmation - > add_child ( container ) ;
2023-01-06 16:23:30 +01:00
unique_resources_label = memnew ( Label ) ;
container - > add_child ( unique_resources_label ) ;
2020-09-10 14:45:10 +02:00
unique_resources_list_tree = memnew ( Tree ) ;
unique_resources_list_tree - > set_hide_root ( true ) ;
unique_resources_list_tree - > set_columns ( 1 ) ;
unique_resources_list_tree - > set_column_title ( 0 , TTR ( " Property " ) ) ;
unique_resources_list_tree - > set_custom_minimum_size ( Size2 ( 0 , 200 * EDSCALE ) ) ;
container - > add_child ( unique_resources_list_tree ) ;
Label * bottom_label = memnew ( Label ) ;
bottom_label - > set_text ( TTR ( " This cannot be undone. Are you sure? " ) ) ;
container - > add_child ( bottom_label ) ;
unique_resources_confirmation - > connect ( " confirmed " , callable_mp ( this , & InspectorDock : : _menu_confirm_current ) ) ;
2022-04-29 08:06:48 +02:00
info_dialog = memnew ( AcceptDialog ) ;
EditorNode : : get_singleton ( ) - > get_gui_base ( ) - > add_child ( info_dialog ) ;
2018-05-17 08:01:47 +02:00
load_resource_dialog = memnew ( EditorFileDialog ) ;
add_child ( load_resource_dialog ) ;
load_resource_dialog - > set_current_dir ( " res:// " ) ;
2020-02-21 18:28:45 +01:00
load_resource_dialog - > connect ( " file_selected " , callable_mp ( this , & InspectorDock : : _resource_file_selected ) ) ;
2018-05-17 08:01:47 +02:00
inspector = memnew ( EditorInspector ) ;
add_child ( inspector ) ;
inspector - > set_autoclear ( true ) ;
inspector - > set_show_categories ( true ) ;
inspector - > set_v_size_flags ( Control : : SIZE_EXPAND_FILL ) ;
inspector - > set_use_doc_hints ( true ) ;
2019-07-22 12:03:57 +02:00
inspector - > set_hide_script ( false ) ;
2022-03-23 21:08:54 +01:00
inspector - > set_hide_metadata ( false ) ;
2022-03-23 02:46:59 +01:00
inspector - > set_property_name_style ( EditorPropertyNameProcessor : : get_default_inspector_style ( ) ) ;
2018-06-14 20:36:38 +02:00
inspector - > set_use_folding ( ! bool ( EDITOR_GET ( " interface/inspector/disable_folding " ) ) ) ;
2018-05-17 08:01:47 +02:00
inspector - > register_text_enter ( search ) ;
inspector - > set_use_filter ( true ) ; // TODO: check me
2020-02-21 18:28:45 +01:00
inspector - > connect ( " resource_selected " , callable_mp ( this , & InspectorDock : : _resource_selected ) ) ;
2018-05-17 08:01:47 +02:00
}
InspectorDock : : ~ InspectorDock ( ) {
2021-11-17 21:08:55 +01:00
singleton = nullptr ;
2018-05-17 08:01:47 +02:00
}